Commit 21f1ce87 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - BBox module now uses new properties

parent 0f3c25ef
......@@ -124,7 +124,7 @@ boost::shared_ptr< WDataSet > WSubject::getDataSetByID( size_t datasetID )
return result;
}
std::vector< boost::shared_ptr< WDataTexture3D > > WSubject::getDataTextures()
std::vector< boost::shared_ptr< WDataTexture3D > > WSubject::getDataTextures( bool onlyActive )
{
std::vector< boost::shared_ptr< WDataTexture3D > > tex;
......@@ -134,7 +134,7 @@ std::vector< boost::shared_ptr< WDataTexture3D > > WSubject::getDataTextures()
for ( DatasetContainerType::iterator iter = m_datasetAccess->get().begin(); iter != m_datasetAccess->get().end(); ++iter )
{
// is it a texture?
if ( ( *iter )->isTexture() )
if ( ( *iter )->isTexture() && ( !onlyActive || ( *iter )->getTexture()->isGloballyActive() ) )
{
tex.push_back( ( *iter )->getTexture() );
}
......
......@@ -135,9 +135,10 @@ public:
/**
* This gives a list of data textures from all supporting datasets in this subject.
*
* \param onlyActive true whenever only textures should be returned where isGloballyActive() == true.
* \return the list of textures.
*/
std::vector< boost::shared_ptr< WDataTexture3D > > getDataTextures();
std::vector< boost::shared_ptr< WDataTexture3D > > getDataTextures( bool onlyActive = false );
/**
* Gets an access object which allows thread save iteration over the datasets.
......
......@@ -76,6 +76,7 @@ const std::string WMBoundingBox::getDescription() const
void WMBoundingBox::moduleMain()
{
// use the m_input "data changed" flag
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
// signal ready state
......@@ -84,18 +85,16 @@ void WMBoundingBox::moduleMain()
// loop until the module container requests the module to quit
while ( !m_shutdownFlag() )
{
sleep( 3 ); // TODO(wiebel): remove this
// acquire data from the input connector
m_dataSet = m_input->getData();
if ( !m_dataSet )
if ( !m_dataSet.get() )
{
// ok, the output has not yet sent data
// OK, the output has not yet sent data
// NOTE: see comment at the end of this while loop for m_moduleState
debugLog() << "Waiting for data ...";
m_moduleState.wait();
continue;
}
assert( m_dataSet );
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() );
......@@ -133,6 +132,13 @@ void WMBoundingBox::connectors()
void WMBoundingBox::properties()
{
// ( m_properties->addInt( "Thickness", 1 ) )->connect( boost::bind( &WMBoundingBox::slotPropertyChanged, this, _1 ) );
// m_active get initialized in WModule and is available for all modules.
// simply register our activate function
// It should get triggered whever m_active changes
m_active->getCondition()->subscribeSignal( boost::bind( &WMBoundingBox::activate, this ) );
}
void WMBoundingBox::slotPropertyChanged( std::string propertyName )
......@@ -147,3 +153,16 @@ void WMBoundingBox::slotPropertyChanged( std::string propertyName )
assert( 0 && "This property name is not supported by this function yet." );
}
}
void WMBoundingBox::activate()
{
if ( m_active->get() )
{
m_bBoxNode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_bBoxNode->setNodeMask( 0x0 );
}
}
......@@ -106,6 +106,12 @@ protected:
private:
/**
* Gets signaled from the properties object when something was changed. Now, only m_active is used. This method therefore simply
* activates/deactivates the BBox.
*/
void activate();
osg::ref_ptr< WGEGroupNode > m_bBoxNode; //!< OSG root node for this module
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
boost::shared_ptr< WDataSetSingle > m_dataSet; //!< Pointer providing access to the treated data set in the whole module.
......
......@@ -130,11 +130,6 @@ void WMDirectVolumeRendering::connectors()
}
void WMDirectVolumeRendering::properties()
{
m_properties->addBool( "active", true, true )->connect( boost::bind( &WMDirectVolumeRendering::slotPropertyChanged, this, _1 ) );
}
void WMDirectVolumeRendering::slotPropertyChanged( std::string propertyName )
{
}
......@@ -66,12 +66,6 @@ public:
*/
virtual const std::string getDescription() const;
/**
* Determine what to do if a property was changed.
* \param propertyName Name of the property.
*/
void slotPropertyChanged( std::string propertyName );
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
......
......@@ -412,10 +412,10 @@ void WMNavSlices::updateGeometry()
osg::ref_ptr<osg::Drawable> oldz = osg::ref_ptr<osg::Drawable>( m_zSliceNode->getDrawable( 0 ) );
m_zSliceNode->replaceDrawable( oldz, zSliceGeometry );
std::vector< boost::shared_ptr< WDataSet > > dsl = WKernel::getRunningKernel()->getGui()->getDataSetList( 0, true );
bool noTexture = ( dsl.size() == 0 );
std::vector< boost::shared_ptr< WDataTexture3D > > tex = WDataHandler::getDefaultSubject()->getDataTextures( true );
bool noSlices = ( tex.size() == 0 ) || !m_active->get() ;
if ( m_showAxial->get() && !noTexture )
if ( m_showAxial->get() && !noSlices )
{
m_zSliceNode->setNodeMask( 0xFFFFFFFF );
}
......@@ -424,7 +424,7 @@ void WMNavSlices::updateGeometry()
m_zSliceNode->setNodeMask( 0x0 );
}
if ( m_showCoronal->get() && !noTexture )
if ( m_showCoronal->get() && !noSlices )
{
m_xSliceNode->setNodeMask( 0xFFFFFFFF );
}
......@@ -433,7 +433,7 @@ void WMNavSlices::updateGeometry()
m_xSliceNode->setNodeMask( 0x0 );
}
if ( m_showSagittal->get() && !noTexture )
if ( m_showSagittal->get() && !noSlices )
{
m_ySliceNode->setNodeMask( 0xFFFFFFFF );
}
......@@ -456,7 +456,7 @@ void WMNavSlices::updateTextures()
m_textureChanged = false;
// grab a list of data textures
std::vector< boost::shared_ptr< WDataTexture3D > > tex = WDataHandler::getDefaultSubject()->getDataTextures();
std::vector< boost::shared_ptr< WDataTexture3D > > tex = WDataHandler::getDefaultSubject()->getDataTextures( true );
if ( tex.size() > 0 )
{
......@@ -471,21 +471,18 @@ void WMNavSlices::updateTextures()
int c = 0;
for ( std::vector< boost::shared_ptr< WDataTexture3D > >::const_iterator iter = tex.begin(); iter != tex.end(); ++iter )
{
if ( ( *iter )->isGloballyActive() )
{
osg::ref_ptr<osg::Texture3D> texture3D = ( *iter )->getTexture();
rootState->setTextureAttributeAndModes( c, texture3D, osg::StateAttribute::ON );
osg::ref_ptr<osg::Texture3D> texture3D = ( *iter )->getTexture();
rootState->setTextureAttributeAndModes( c, texture3D, osg::StateAttribute::ON );
// set threshold/opacity as uniforms
float t = ( *iter )->getThreshold() / 255.0;
float a = ( *iter )->getAlpha();
// set threshold/opacity as uniforms
float t = ( *iter )->getThreshold() / 255.0;
float a = ( *iter )->getAlpha();
m_typeUniforms[c]->set( ( *iter )->getDataType() );
m_thresholdUniforms[c]->set( t );
m_alphaUniforms[c]->set( a );
m_typeUniforms[c]->set( ( *iter )->getDataType() );
m_thresholdUniforms[c]->set( t );
m_alphaUniforms[c]->set( a );
++c;
}
++c;
}
}
}
......
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