Commit 4c05945a authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - coloring can now be modiefied using a color MAD (multiply and add)

parent f705d533
......@@ -96,6 +96,11 @@ void WMFiberParameterColoring::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_baseColor = m_properties->addProperty( "Base Color", "The base color. Some kind of color offset.", WColor( 1.0, 1.0, 1.0, 0.0 ),
m_propCondition );
m_scaleColor = m_properties->addProperty( "Scale Color", "The color which gets scaled with the calculated value and added to the base color.",
WColor( 0.0, 0.0, 0.0, 1.0 ), m_propCondition );
// call WModule's initialization
WModule::properties();
}
......@@ -147,7 +152,8 @@ void WMFiberParameterColoring::moduleMain()
bool dataUpdated = m_fiberInput->handledUpdate();
boost::shared_ptr< WDataSetFibers > dataSet = m_fiberInput->getData();
bool dataValid = ( dataSet );
if ( !dataValid || ( dataValid && !dataUpdated ) )
bool propUpdated = m_baseColor->changed() || m_scaleColor->changed();
if ( !dataValid || ( dataValid && !( dataUpdated || propUpdated ) ) )
{
continue;
}
......@@ -174,6 +180,16 @@ void WMFiberParameterColoring::moduleMain()
m_progress->addSubProgress( progress1 );
m_progress->addSubProgress( progress2 );
// for fastness:
double baseColorR = m_baseColor->get( true ).getRed();
double baseColorG = m_baseColor->get( true ).getGreen();
double baseColorB = m_baseColor->get( true ).getBlue();
double baseColorA = m_baseColor->get( true ).getAlpha();
double scaleColorR = m_scaleColor->get( true ).getRed();
double scaleColorG = m_scaleColor->get( true ).getGreen();
double scaleColorB = m_scaleColor->get( true ).getBlue();
double scaleColorA = m_scaleColor->get( true ).getAlpha();
// for each fiber:
debugLog() << "Iterating over all fibers.";
std::vector< double > maxSegLengths;
......@@ -235,10 +251,10 @@ void WMFiberParameterColoring::moduleMain()
double z = ( 2.0 / ( lenLast + segLen ) ) * ( current[2] - prev[2] );
double curvature = std::sqrt( x*x + y*y + z*z );
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 0 ] = 1.5 * curvature;
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 1 ] = 0.0;
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 2 ] = 0.0;
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 3 ] = 1.0;
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 0 ] = baseColorR + ( 1.5 * scaleColorR * curvature );
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 1 ] = baseColorG + ( 1.5 * scaleColorG * curvature );
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 2 ] = baseColorB + ( 1.5 * scaleColorB * curvature );
( *m_fibCurvatureColors )[ ( colorMode * k ) + cidx + 3 ] = baseColorA + ( 1.5 * scaleColorA * curvature );
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 0 ] = segLen;
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 1 ] = 0.0;
......@@ -273,10 +289,10 @@ void WMFiberParameterColoring::moduleMain()
for ( size_t k = 1; k < len - 1; ++k ) // len -1 because we interpret it as segments
{
double relSegLen = ( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 0 ] / maxSegLengths[ fidx ];
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 0 ] = relSegLen;
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 1 ] = relSegLen;
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 2 ] = relSegLen;
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 3 ] = 1.0;
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 0 ] = baseColorR + ( scaleColorR * relSegLen );
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 1 ] = baseColorG + ( scaleColorG * relSegLen );
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 2 ] = baseColorB + ( scaleColorB * relSegLen );
( *m_fibLengthColors )[ ( colorMode * k ) + cidx + 3 ] = baseColorA + ( scaleColorA * relSegLen );
}
}
progress2->finish();
......
......@@ -120,6 +120,16 @@ private:
* The colors encoding the segment length
*/
WDataSetFibers::ColorArray m_fibLengthColors;
/**
* The offset color.
*/
WPropColor m_baseColor;
/**
* The color gets scaled by the calculated color (i.e. Curvature) and added to m_baseColor for each vertex.
*/
WPropColor m_scaleColor;
};
#endif // WMFIBERPARAMETERCOLORING_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment