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

[CHANGE] - active property now has a default callback activate() available for every module

parent 48f01652
......@@ -64,6 +64,8 @@ WModule::WModule():
m_properties = boost::shared_ptr< WProperties >( new WProperties() );
m_properties2 = boost::shared_ptr< WProperties2 >( new WProperties2() );
m_active = m_properties2->addProperty( "active", "Determines whether the module should be activated.", true, true );
m_active->getCondition()->subscribeSignal( boost::bind( &WModule::activate, this ) );
m_container = boost::shared_ptr< WModuleContainer >();
m_progress = boost::shared_ptr< WProgressCombiner >( new WProgressCombiner() );
......@@ -129,6 +131,10 @@ void WModule::properties()
{
}
void WModule::activate()
{
}
void WModule::initialize()
{
// doing it twice is not allowed
......
......@@ -299,6 +299,11 @@ protected:
*/
void disconnectAll();
/**
* Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
*/
virtual void activate();
// **************************************************************************************************************************
//
// Signal handlers that HAVE to be in every module. By default they do nothing. You should overwrite them to get notified
......
......@@ -133,24 +133,8 @@ 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 )
{
// if( propertyName == "Filter Size" )
// {
// // TODO(wiebel): need code here
// }
// else
{
std::cout << propertyName << std::endl;
assert( 0 && "This property name is not supported by this function yet." );
}
// m_active gets initialized in WModule and is available for all modules. Overwrite activate() to have a special callback for m_active
// changes.
}
void WMBoundingBox::activate()
......
......@@ -31,7 +31,6 @@
WMEEGView::WMEEGView()
: WModule(),
m_dataChanged( new WCondition, true ),
m_isActive( new WCondition, true ),
m_wasActive( false ),
m_event( -1.0 ),
m_eventPositionFlag( NULL )
......@@ -72,22 +71,8 @@ void WMEEGView::connectors()
void WMEEGView::properties()
{
// properties
m_properties->addBool( "active", true, true )->connect( boost::bind( &WMEEGView::slotPropertyChanged, this, _1 ) );
}
void WMEEGView::slotPropertyChanged( std::string propertyName )
{
if( propertyName == "active" )
{
m_isActive.set( m_properties->getValue< bool >( propertyName ) );
}
else
{
// instead of WLogger we must use std::cerr since WLogger needs to much time!
std::cerr << propertyName << std::endl;
assert( 0 && "This property name is not supported by this function yet." );
}
// m_active gets initialized in WModule and is available for all modules. Overwrite activate() to have a special callback for m_active
// changes or add a callback manually.
}
void WMEEGView::notifyConnectionEstablished(
......@@ -107,7 +92,7 @@ void WMEEGView::moduleMain()
// do initialization
m_moduleState.setResetable( true, true );
m_moduleState.add( m_dataChanged.getCondition() );
m_moduleState.add( m_isActive.getCondition() );
m_moduleState.add( m_active->getCondition() );
// signal ready
ready();
......@@ -138,7 +123,7 @@ void WMEEGView::moduleMain()
}
// "active" property changed?
bool isActive = m_isActive();
bool isActive = m_active->get();
if( isActive != m_wasActive )
{
if( isActive )
......
......@@ -146,13 +146,6 @@ private:
*/
WBoolFlag m_dataChanged;
/**
* Bool flag to represent the state which is selected in the GUI.
* The module thread waits for changes of this flag and hiddes/displays its
* data according to it.
*/
WBoolFlag m_isActive;
/**
* The current active-state. Whether the widget is open and usable.
*/
......
......@@ -61,11 +61,8 @@ void WMHud::connectors()
void WMHud::properties()
{
// 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( &WMHud::activate, this ) );
// m_active gets initialized in WModule and is available for all modules. Overwrite activate() to have a special callback for m_active
// changes or add a callback manually.
}
void WMHud::moduleMain()
......
......@@ -110,6 +110,7 @@ void WMPrototypeBoxManipulation::connectors()
void WMPrototypeBoxManipulation::properties()
{
// m_active get initialized in WModule and is available for all modules.
// m_active gets initialized in WModule and is available for all modules. Overwrite activate() to have a special callback for m_active
// changes or add a callback manually.
}
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