Commit ee2144bc authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - texture now gets registered and texture properties are provided. Note:...

[ADD] - texture now gets registered and texture properties are provided. Note: this is not the best and final solution but enough to view arbitrary outputs on navslices for example.
parent 887d7835
......@@ -24,6 +24,7 @@
#include <string>
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../kernel/WKernel.h"
......@@ -77,6 +78,34 @@ void WMTextureMapper::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
WPropertyBase::PropertyChangeNotifierType propertyCallback = boost::bind( &WMTextureMapper::propertyChanged, this, _1 );
m_groupTex = m_properties->addPropertyGroup( "Texture Properties", "Properties only related to the texture representation." );
// several other properties
m_interpolation = m_groupTex->addProperty( "Interpolation",
"If active, the boundaries of single voxels"
" will not be visible in colormaps. The transition between"
" them will be smooth by using interpolation then.",
true,
propertyCallback );
m_threshold = m_groupTex->addProperty( "Threshold", "Values below this threshold will not be "
"shown in colormaps.", 0., propertyCallback );
m_opacity = m_groupTex->addProperty( "Opacity %", "The opacity of this data in colormaps combining"
" values from several data sets.", 100, propertyCallback );
m_opacity->setMax( 100 );
m_opacity->setMin( 0 );
m_colorMapSelectionsList = boost::shared_ptr< WItemSelection >( new WItemSelection() );
m_colorMapSelectionsList->addItem( "Grayscale", "" );
m_colorMapSelectionsList->addItem( "Rainbow", "" );
m_colorMapSelectionsList->addItem( "Hot iron", "" );
m_colorMapSelectionsList->addItem( "Red-Yellow", "" );
m_colorMapSelectionsList->addItem( "Atlas", "" );
m_colorMapSelectionsList->addItem( "Blue-Green-Purple", "" );
m_colorMapSelection = m_groupTex->addProperty( "Colormap", "Colormap type.", m_colorMapSelectionsList->getSelectorFirst(), propertyCallback );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_colorMapSelection );
WModule::properties();
}
......@@ -109,12 +138,71 @@ void WMTextureMapper::moduleMain()
{
boost::shared_ptr< WDataSetSingle > dataSet = m_input->getData();
// valid data?
if( dataSet )
debugLog() << "Registering new texture";
// de-register at datahandler
if ( m_lastDataSet )
{
WDataHandler::deregisterDataSet( m_lastDataSet );
}
// register only valid data
if( dataSet )
{
m_lastDataSet = dataSet;
// register new
if ( m_lastDataSet->isTexture() )
{
WDataHandler::registerDataSet( m_lastDataSet );
}
else
{
warnLog() << "Connected dataset is not usable as a texture.";
}
}
}
}
}
void WMTextureMapper::activate()
{
// deactivate the output if wanted
if ( m_lastDataSet )
{
m_lastDataSet->getTexture()->setGloballyActive( m_active->get( true ) );
}
// Always call WModule's activate!
WModule::activate();
}
void WMTextureMapper::propertyChanged( boost::shared_ptr< WPropertyBase > property )
{
if ( !m_lastDataSet )
{
return;
}
if ( property == m_threshold )
{
m_lastDataSet->getTexture()->setThreshold( m_threshold->get() );
}
else if ( property == m_opacity )
{
m_lastDataSet->getTexture()->setOpacity( m_opacity->get() );
}
else if ( property == m_active )
{
m_lastDataSet->getTexture()->setGloballyActive( m_active->get() );
}
else if ( property == m_interpolation )
{
m_lastDataSet->getTexture()->setInterpolation( m_interpolation->get() );
}
else if ( property == m_colorMapSelection )
{
m_lastDataSet->getTexture()->setSelectedColormap( m_colorMapSelection->get( true ).getItemIndexOfSelected( 0 ) );
}
}
......@@ -93,6 +93,10 @@ protected:
*/
virtual void properties();
/**
* Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
*/
virtual void activate();
private:
/**
......@@ -101,6 +105,50 @@ private:
boost::shared_ptr< WCondition > m_propCondition;
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
/**
* This is a pointer to the dataset the module is currently working on.
*/
boost::shared_ptr< WDataSetSingle > m_lastDataSet;
// TODO(ebaum): cleanup -> belongs to some central place
/**
* Called whenever a property changes.
*
* \param property the property that has been changed
*/
void propertyChanged( boost::shared_ptr< WPropertyBase > property );
/**
* grouping the texture display properties
*/
WPropGroup m_groupTex;
/**
* Interpolation?
*/
WPropBool m_interpolation;
/**
* A list of color map selection types
*/
boost::shared_ptr< WItemSelection > m_colorMapSelectionsList;
/**
* Selection property for color map
*/
WPropSelection m_colorMapSelection;
/**
* Threshold value for this data.
*/
WPropDouble m_threshold;
/**
* Opacity value for this data.
*/
WPropInt m_opacity;
};
#endif // WMTEXTUREMAPPER_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