Commit 72a6d3f8 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - added feature to show/hide properties on the fly. Simply hide them...

[ADD] - added feature to show/hide properties on the fly. Simply hide them using setHidden and the GUI properly updated. See WMTemplate::hideButtonPressed for an example.
parent b1936dae
......@@ -85,6 +85,8 @@ bool WPropertyWidget::event( QEvent* event )
// a property changed
if ( event->type() == WQT_PROPERTY_CHANGED_EVENT )
setHidden( m_property->isHidden() );
m_label.setHidden( m_property->isHidden() );
return true;
......@@ -154,40 +154,6 @@ void WMIsosurfaceRaytracer::moduleMain()
osg::ref_ptr< WGEManagedGroupNode > rootNode = new WGEManagedGroupNode( m_active );
bool rootInserted = false;
// Setup post-processing pipeline
// NOTE: the code is for testing only.
// the WGEOffscreenRenderNode manages each of the render-passes for us
/*osg::ref_ptr< WGEOffscreenRenderNode > offscreen = new WGEOffscreenRenderNode(
// allow en-/disabling the HUD:
offscreen->getTextureHUD()->addUpdateCallback( new WGENodeMaskCallback( m_showHUD ) );
osg::ref_ptr< WGEOffscreenRenderPass > render = offscreen->addGeometryRenderPass(
// finally, put it back on screen, clip it, color it and apply depth buffer to on-screen buffer
osg::ref_ptr< WGEOffscreenRenderPass > postprocess = offscreen->addFinalOnScreenPass(
new WGEShader( "WMIsosurfaceRaytracer-Postprocessor", m_localPath ),
// Texture bindings
osg::ref_ptr< osg::Texture2D > renderColor = render->attach( osg::Camera::COLOR_BUFFER0 );
osg::ref_ptr< osg::Texture2D > renderNormals = render->attach( osg::Camera::COLOR_BUFFER1 );
osg::ref_ptr< osg::Texture2D > renderDepth = render->attach( osg::Camera::DEPTH_BUFFER );
postprocess->bind( renderColor, 0 );
postprocess->bind( renderNormals, 1 );
postprocess->bind( renderDepth, 2 );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( offscreen );*/
// Normally, you will have a loop which runs as long as the module should not shutdown. In this loop you can react on changing data on input
// connectors or on changed in your properties.
debugLog() << "Entering main loop";
......@@ -263,6 +263,12 @@ void WMTemplate::properties()
m_group1a->addProperty( m_aDouble );
m_group1a->addProperty( m_enableFeature );
// and add another button to group2. But this time, we do not want to wake up the main thread. We handle this directly. Fortunately,
// WPropertyVariable offers you the possibility to specify your own change callback. This callback is used for hiding the m_aColor property
// on the fly.
m_hideButton = m_group2->addProperty( "(Un-)Hide Color", "Trigger Button Text.", WPVBaseTypes::PV_TRIGGER_READY,
boost::bind( &WMTemplate::hideButtonPressed, this ) );
// How can the values of the properties be changed? You can take a look at moduleMain where this is shown. For short: m_anInteger->set( 2 )
// and m_anInteger->get().
......@@ -732,3 +738,20 @@ void WMTemplate::activate()
void WMTemplate::hideButtonPressed()
// This method is called whenever m_hideButton changes its value. You can use such callbacks to avoid waking-up or disturbing the module
// thread for certain operations.
// If the button was triggered, switch the hide-state of m_aColor.
if ( m_hideButton->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
// switch the hide flag of the color prop.
m_aColor->setHidden( !m_aColor->isHidden() );
// never forget to reset a trigger. If not done, the trigger is disabled in the GUI and can't be used again.
m_hideButton->set( WPVBaseTypes::PV_TRIGGER_READY );
// NOTE: this again triggers an update, which is why we need to check the state of the trigger in this if-clause.
......@@ -254,6 +254,16 @@ private:
boost::shared_ptr< WItemSelection > m_possibleSelections;
* A Property used to show the callback mechanism avoiding the thread wake up on change.
WPropTrigger m_hideButton;
* The callback triggering the hide flag of m_aColor for demonstration.
void hideButtonPressed();
* Node callback to change the color of the shapes inside the root node. For more details on this class, refer to the documentation in
* moduleMain().
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