Commit 00c4768a authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - now activate checks whether whether the node exists and also...

[CHANGE] - now activate checks whether whether the node exists and also deactivates nodes on creation to avoid missing the activate change. This allows especially project files to set the active property.
parent 3498222c
......@@ -103,6 +103,8 @@ void WMBoundingBox::moduleMain()
std::pair< wmath::WPosition, wmath::WPosition > bb = grid->getBoundingBox();
m_bBoxNode = osg::ref_ptr< WGEGroupNode >( new WGEGroupNode );
m_bBoxNode->setNodeMask( m_active->get() ? 0xFFFFFFFF : 0x0 );
m_bBoxNode->insert( wge::generateBoundingBoxGeode( bb.first, bb.second, WColor( 0.3, 0.3, 0.3, 1 ) ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_bBoxNode );
......@@ -139,15 +141,17 @@ void WMBoundingBox::properties()
void WMBoundingBox::activate()
{
if ( m_active->get() )
{
m_bBoxNode->setNodeMask( 0xFFFFFFFF );
}
else
if ( m_bBoxNode )
{
m_bBoxNode->setNodeMask( 0x0 );
if ( m_active->get() )
{
m_bBoxNode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_bBoxNode->setNodeMask( 0x0 );
}
}
WModule::activate();
}
......@@ -220,6 +220,7 @@ void WMDirectVolumeRendering::moduleMain()
// update node
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
m_rootNode = cube;
m_rootNode->setNodeMask( m_active->get() ? 0xFFFFFFFF : 0x0 );
debugLog() << "Adding new rendering.";
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
}
......@@ -264,13 +265,16 @@ void WMDirectVolumeRendering::SafeUniformCallback::operator()( osg::Uniform* uni
void WMDirectVolumeRendering::activate()
{
// Activate/Deactivate the DVR
if ( m_active->get() )
if ( m_rootNode )
{
m_rootNode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_rootNode->setNodeMask( 0x0 );
if ( m_active->get() )
{
m_rootNode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_rootNode->setNodeMask( 0x0 );
}
}
// Always call WModule's activate!
......
......@@ -220,6 +220,7 @@ void WMSurfaceParticles::moduleMain()
// update node
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
m_rootNode = cube;
m_rootNode->setNodeMask( m_active->get() ? 0xFFFFFFFF : 0x0 );
debugLog() << "Adding new rendering.";
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
}
......
......@@ -353,6 +353,10 @@ void WMTemplate::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
m_rootNode = newRootNode;
// please also ensure that, according to m_active, the node is active or not. Setting it here allows the user to deactivate modules
// in project files for example.
m_rootNode->setNodeMask( m_active->get() ? 0xFFFFFFFF : 0x0 );
// OSG allows you to add custom callbacks. These callbacks get executed on each update traversal. They can be used to modify several
// attributes and modes of existing nodes. You do not want to remove the node and recreate another one to simply change some color,
// right? Setting the color can be done in such an update callback. See in the header file, how this class is defined.
......
......@@ -280,6 +280,8 @@ void WMVoxelizer::update()
m_voxelGeode = genDataSetGeode( outputDataSet );
m_osgNode->insert( m_voxelGeode );
}
m_osgNode->setNodeMask( m_active->get() ? 0xFFFFFFFF : 0x0 );
m_osgNode->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_osgNode );
}
......
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