Commit c14a116c authored by schurade's avatar schurade
Browse files

[CHANGE] properties emit a signal now when their value changed

parent 33e5c76f
......@@ -296,6 +296,7 @@ void WKernel::slotFinishLoadData( boost::shared_ptr< WDataSet > dataSet )
module->getProperties()->addBool( "active", true );
module->getProperties()->addInt( "threshold", 0 );
module->getProperties()->addInt( "alpha", 100 );
module->getProperties()->setMax( "alpha", 100 );
module->getProperties()->setValue( "name", dataSet->getFileName() );
m_gui->addDatasetToBrowser( module, 0 );
......
......@@ -38,10 +38,10 @@
WModule::WModule():
WThreadedRunner(),
m_properties()
m_properties(),
m_initialized( false )
{
// initialize members
m_initialized = false;
}
WModule::~WModule()
......
......@@ -30,7 +30,7 @@
class WModuleConnector;
/**
/**
* Enum of all possible signals between WModuleConnector instances.
* TODO(ebaum): Replace this by an automatic mapping class also able to allow varying function signatures.
*/
......@@ -46,9 +46,9 @@ MODULE_CONNECTOR_SIGNAL;
// Types
// **************************************************************************************************************************
/**
/**
* Signal transmitting sender and receiver.
*
*
* \param boost::shared_ptr<WModuleConnector> this should be the receiver, depending on specific signal.
* \param boost::shared_ptr<WModuleConnector> this should be the sender, depending on specific signal.
*
......@@ -56,9 +56,9 @@ MODULE_CONNECTOR_SIGNAL;
typedef boost::function<void ( boost::shared_ptr<WModuleConnector>,
boost::shared_ptr<WModuleConnector> )> t_GenericSignalHandlerType;
/**
/**
* Generic signal type used in the most signals involving a sender and receiver.
*
*
* \param recv The connector receiving the signal.
* \param sender The counterpart (sender).
*/
......
......@@ -39,45 +39,50 @@ WProperties::~WProperties()
{
}
void WProperties::addBool( std::string name, bool value, std::string shortDesc, std::string longDesc )
boost::signal1< void, std::string >* WProperties::addBool( std::string name, bool value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList[name] = prop;
return prop->getSignalValueChanged();
}
void WProperties::addChar( std::string name, char value, std::string shortDesc, std::string longDesc )
boost::signal1< void, std::string >* WProperties::addChar( std::string name, char value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList[name] = prop;
return prop->getSignalValueChanged();
}
void WProperties::addInt( std::string name, int value, std::string shortDesc, std::string longDesc )
boost::signal1< void, std::string >* WProperties::addInt( std::string name, int value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList[name] = prop;
return prop->getSignalValueChanged();
}
void WProperties::addFloat( std::string name, float value, std::string shortDesc, std::string longDesc )
boost::signal1< void, std::string >* WProperties::addFloat( std::string name, float value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList[name] = prop;
return prop->getSignalValueChanged();
}
void WProperties::addDouble( std::string name, double value, std::string shortDesc, std::string longDesc )
boost::signal1< void, std::string >* WProperties::addDouble( std::string name, double value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList[name] = prop;
return prop->getSignalValueChanged();
}
void WProperties::addString( std::string name, std::string value, std::string shortDesc, std::string longDesc )
boost::signal1< void, std::string >* WProperties::addString( std::string name, std::string value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList[name] = prop;
return prop->getSignalValueChanged();
}
WProperty* WProperties::findProp( std::string name )
......
......@@ -49,12 +49,12 @@ public:
std::map < std::string, WProperty* >* getProperties();
void addBool( std::string name, bool value = false, std::string shortDesc = "", std::string longDesc = "" );
void addChar( std::string name, char value = 0, std::string shortDesc = "", std::string longDesc = "" );
void addInt( std::string name, int value = 0, std::string shortDesc = "", std::string longDesc = "" );
void addFloat( std::string name, float value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
void addDouble( std::string name, double value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
void addString( std::string name, std::string value = "", std::string shortDesc = "", std::string longDesc = "" );
boost::signal1< void, std::string >* addBool( std::string name, bool value = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signal1< void, std::string >* addChar( std::string name, char value = 0, std::string shortDesc = "", std::string longDesc = "" );
boost::signal1< void, std::string >* addInt( std::string name, int value = 0, std::string shortDesc = "", std::string longDesc = "" );
boost::signal1< void, std::string >* addFloat( std::string name, float value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
boost::signal1< void, std::string >* addDouble( std::string name, double value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
boost::signal1< void, std::string >* addString( std::string name, std::string value = "", std::string shortDesc = "", std::string longDesc = "" );
std::string getValueString( const std::string prop );
......@@ -66,6 +66,22 @@ public:
}
}
template < typename T > void setMin( std::string prop, const T& arg )
{
if ( findProp( prop ) )
{
findProp( prop )->setMin( arg );
}
}
template < typename T > void setMax( std::string prop, const T& arg )
{
if ( findProp( prop ) )
{
findProp( prop )->setMax( arg );
}
}
template < typename T > T getValue( std::string prop )
{
if ( findProp( prop ) )
......@@ -74,6 +90,26 @@ public:
}
return 0;
}
template < typename T > T getMin( std::string prop )
{
if ( findProp( prop ) )
{
return findProp( prop )->getMin< T >();
}
return 0;
}
template < typename T > T getMax( std::string prop )
{
if ( findProp( prop ) )
{
return findProp( prop )->getMax< T >();
}
return 0;
}
private:
WProperty* findProp( std::string name );
......
......@@ -31,7 +31,8 @@ WProperty::WProperty( std::string name, std::string value, std::string shortDesc
m_name( name ),
m_value( value ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc )
m_longDesc( longDesc ),
m_isHidden( false )
{
}
......@@ -39,7 +40,8 @@ WProperty::WProperty( std::string name, bool value, std::string shortDesc, std::
: m_type( P_BOOL ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc )
m_longDesc( longDesc ),
m_isHidden( false )
{
setValue( value );
}
......@@ -48,7 +50,8 @@ WProperty::WProperty( std::string name, char value, std::string shortDesc, std::
: m_type( P_CHAR ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc )
m_longDesc( longDesc ),
m_isHidden( false )
{
setMin( -128 );
setMax( 127 );
......@@ -59,7 +62,8 @@ WProperty::WProperty( std::string name, int value, std::string shortDesc, std::s
: m_type( P_INT ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc )
m_longDesc( longDesc ),
m_isHidden( false )
{
setMin( 0 );
setMax( 255 );
......@@ -70,7 +74,8 @@ WProperty::WProperty( std::string name, float value, std::string shortDesc, std:
: m_type( P_FLOAT ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc )
m_longDesc( longDesc ),
m_isHidden( false )
{
setMin( 0.0 );
setMax( 100.0 );
......@@ -81,7 +86,8 @@ WProperty::WProperty( std::string name, double value, std::string shortDesc, std
: m_type( P_DOUBLE ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc )
m_longDesc( longDesc ),
m_isHidden( false )
{
setMin( 0.0 );
setMax( 100.0 );
......@@ -132,3 +138,18 @@ std::string WProperty::getValueString()
{
return m_value;
}
void WProperty::setHidden()
{
m_isHidden = true;
}
bool WProperty::isHidden()
{
return m_isHidden;
}
boost::signal1< void, std::string >* WProperty::getSignalValueChanged()
{
return &m_signalValueChanged;
}
......@@ -28,6 +28,7 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include "../gui/qt4/signalslib.hpp"
typedef enum
{
......@@ -70,9 +71,14 @@ public:
void setShortDesc( const std::string desc );
void setLongDesc( const std::string desc );
void setHidden();
bool isHidden();
std::string getShortDesc();
std::string getLongDesc();
boost::signal1< void, std::string >* getSignalValueChanged();
template < typename T > void setValue( const T& arg )
{
......@@ -84,6 +90,7 @@ public:
{
m_value = "";
}
m_signalValueChanged( m_name );
}
template < typename T > void setMin( const T& arg )
......@@ -137,6 +144,10 @@ private:
std::string m_max;
std::string m_shortDesc;
std::string m_longDesc;
bool m_isHidden;
boost::signal1< void, std::string >m_signalValueChanged;
};
#endif // WPROPERTY_H
......@@ -97,19 +97,19 @@ void WNavigationSliceModule::connectors()
void WNavigationSliceModule::properties()
{
m_properties.addBool( "textureChanged", true );
( m_properties.addBool( "textureChanged", true ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
m_properties.addInt( "axialPos", 80 );
m_properties.addInt( "coronalPos", 100 );
m_properties.addInt( "sagittalPos", 80 );
( m_properties.addInt( "axialPos", 80 ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
( m_properties.addInt( "coronalPos", 100 ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
( m_properties.addInt( "sagittalPos", 80 ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
m_properties.addInt( "maxAxial", 160 );
m_properties.addInt( "maxCoronal", 200 );
m_properties.addInt( "maxSagittal", 160 );
m_properties.addBool( "showAxial", true );
m_properties.addBool( "showCoronal", true );
m_properties.addBool( "showSagittal", true );
( m_properties.addBool( "showAxial", true ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
( m_properties.addBool( "showCoronal", true ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
( m_properties.addBool( "showSagittal", true ) )->connect( boost::bind( &WNavigationSliceModule::slotPropertyChanged, this, _1 ) );
}
void WNavigationSliceModule::notifyDataChange( boost::shared_ptr<WModuleConnector> input,
......@@ -414,3 +414,15 @@ void WNavigationSliceModule::initUniforms( osg::StateSet* sliceState )
sliceState->addUniform( m_samplerUniforms[i] );
}
}
void WNavigationSliceModule::slotPropertyChanged( std::string propertyName )
{
if ( propertyName == "textureChanged" )
{
updateTextures();
}
else
{
updateSlices();
}
}
......@@ -79,6 +79,11 @@ public:
*/
void connectToGui();
/**
*
*/
void slotPropertyChanged( std::string propertyName );
protected:
/**
......
......@@ -1983,9 +1983,9 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error):
if (not line.startswith('#include') and not is_header_guard and
not Match(r'^\s*//.*http(s?)://\S*$', line)):
line_width = GetLineWidth(line)
if line_width > 130:
if line_width > 150:
error(filename, linenum, 'whitespace/line_length', 4,
'Lines should be <= 130 characters long')
'Lines should be <= 150 characters long')
if (cleansed_line.count(';') > 1 and
# for loops are allowed two ;'s (and may run over two lines).
......
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