Commit 1c6e6ee2 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] functionality to scale the opacity output by the transfer function

parent 9adbaca5
......@@ -175,10 +175,11 @@ void WTransferFunction::sample1DTransferFunction( unsigned char*array, int width
color[ 3 ] = ablend( a1->alpha, 1.-alphaParameter, a2->alpha, alphaParameter );
}
}
for( int j = 0; j < 4; ++j )
for( int j = 0; j < 3; ++j )
{
array[ 4*i + j ] = color[ j ]*255.;
}
array[ 4*i + 3 ] = color[ 3 ] * 255.0 * m_opacityScale;
}
}
......
......@@ -40,7 +40,7 @@ public:
/**
* Default constructor of a meaningless transfer function
*/
WTransferFunction() : m_isomin( 0. ), m_isomax( 0. )
WTransferFunction() : m_isomin( 0. ), m_isomax( 0. ), m_opacityScale( 1.0 )
{
}
......@@ -50,7 +50,8 @@ public:
* \param rhs the value to histogram
*/
WTransferFunction( const WTransferFunction &rhs )
: m_colors( rhs.m_colors ), m_alphas( rhs.m_alphas ), m_isomin( rhs.m_isomin ), m_isomax( rhs.m_isomax ), m_histogram( rhs.m_histogram )
: m_colors( rhs.m_colors ), m_alphas( rhs.m_alphas ), m_isomin( rhs.m_isomin ), m_isomax( rhs.m_isomax )
, m_opacityScale( 1.0 ) , m_histogram( rhs.m_histogram )
{
}
......@@ -115,6 +116,25 @@ public:
return m_colors.size();
}
/**
* Get the scaling factor for the opacity.
*
* \returns scaling factor
*/
double getOpacityScale() const
{
return m_opacityScale;
}
/**
* Set the scaling factor for the opacity.
* \param factor scaling factor of opacity values
*/
void setOpacityScale( double factor )
{
m_opacityScale = factor;
}
/**
* Get the isovalue at a given index in the alpha values.
*
......@@ -145,7 +165,7 @@ public:
*/
double getAlpha( size_t i ) const
{
return m_alphas.at( i ).alpha;
return m_alphas.at( i ).alpha*m_opacityScale;
}
/**
......@@ -357,6 +377,13 @@ private:
*/
double m_isomax;
/**
* Factor by which the output opacity is scaled
* to allow for easier specification of very small
* opacity values.
*/
double m_opacityScale;
/**
* Sores a histogram. This is used for property-handling only
* and does not change the transfer function at all.
......
......@@ -92,6 +92,11 @@ void WMTransferFunction1D::properties()
tf.addColor( 1.0, WColor( 1.0, 0.0, 0.0, 1.0 ) );
m_transferFunction = m_properties->addProperty( "Transfer Function", "The transfer function editor.", tf, m_propCondition, false );
m_opacityScale = m_properties->addProperty( "Opacity Scaling",
"Factor used to scale opacity for easier interaction",
1.0,
m_propCondition );
m_binSize = m_properties->addProperty( "Histogram Resolution", "Number of bins in histogram.", 64, m_propCondition );
m_binSize->setMin( 2 );
m_binSize->setMax( 512 );
......@@ -168,7 +173,7 @@ void WMTransferFunction1D::moduleMain()
boost::shared_ptr< std::vector<unsigned char> > data( new std::vector<unsigned char>( resolution * 4 ) );
// FIXME: get transfer function and publish the function
tf.setOpacityScale( m_opacityScale->get( true ) );
tf.sample1DTransferFunction( &( *data )[ 0 ], resolution, 0.0, 1.0 );
boost::shared_ptr< WValueSetBase > newValueSet( new WValueSet<unsigned char>( 1, 4, data, W_DT_UNSIGNED_CHAR ) );
......
......@@ -122,6 +122,11 @@ nnectors must not be handled by the module.
*/
WPropInt m_resolution;
/**
* Histogram bin size
*/
WPropDouble m_opacityScale;
/**
* Histogram bin size
*/
......
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