From 1665cfc73d119c2e63708dbd9ddbbd0e1f4ccd68 Mon Sep 17 00:00:00 2001 From: Sebastian Eichelbaum Date: Mon, 10 May 2010 14:39:08 +0200 Subject: [PATCH] [CHANGE] - Information properties now supported by the prop widgets. Also extended template. --- .../datasetbrowser/WPropertyBoolWidget.cpp | 9 ++++- .../qt4/datasetbrowser/WPropertyBoolWidget.h | 10 ++++++ .../datasetbrowser/WPropertyColorWidget.cpp | 15 +++++++- .../qt4/datasetbrowser/WPropertyColorWidget.h | 10 ++++++ .../datasetbrowser/WPropertyDoubleWidget.cpp | 14 ++++++-- .../datasetbrowser/WPropertyDoubleWidget.h | 10 ++++++ .../WPropertyFilenameWidget.cpp | 12 +++++-- .../datasetbrowser/WPropertyFilenameWidget.h | 10 ++++++ .../qt4/datasetbrowser/WPropertyIntWidget.cpp | 22 ++++++++---- .../qt4/datasetbrowser/WPropertyIntWidget.h | 10 ++++++ .../WPropertySelectionWidget.cpp | 22 ++++++++++-- .../datasetbrowser/WPropertySelectionWidget.h | 1 + .../datasetbrowser/WPropertyStringWidget.cpp | 15 ++++++-- .../datasetbrowser/WPropertyStringWidget.h | 10 ++++++ .../datasetbrowser/WPropertyTriggerWidget.cpp | 11 +++++- .../datasetbrowser/WPropertyTriggerWidget.h | 10 ++++++ .../qt4/datasetbrowser/WPropertyWidget.cpp | 9 +++++ src/gui/qt4/datasetbrowser/WPropertyWidget.h | 5 +++ src/modules/template/WMTemplate.cpp | 21 +++++++++-- src/modules/template/WMTemplate.h | 35 ++++++++++++++++--- 20 files changed, 236 insertions(+), 25 deletions(-) diff --git a/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp index fb9665da1..d9435c51c 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.cpp @@ -32,7 +32,9 @@ WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* prope m_checkbox( &m_parameterWidgets ), m_button( &m_parameterWidgets ), m_layout( &m_parameterWidgets ), - m_asButton( asButton ) + m_asButton( asButton ), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_button.setCheckable( true ); @@ -49,6 +51,10 @@ WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* prope } m_parameterWidgets.setLayout( &m_layout ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + // connect the modification signal of m_checkbox with our callback connect( &m_checkbox, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) ); connect( &m_button, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) ); @@ -64,6 +70,7 @@ void WPropertyBoolWidget::update() // simply set the new state m_checkbox.setChecked( m_boolProperty->get() ); m_button.setChecked( m_boolProperty->get() ); + m_asText.setText( m_boolProperty->get() ? QString( "Yes" ) : QString( "No") ); } QPushButton* WPropertyBoolWidget::getButton() diff --git a/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h b/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h index 170b9234e..fab5e5409 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyBoolWidget.h @@ -96,6 +96,16 @@ protected: */ bool m_asButton; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp index c606edafc..d926548af 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyColorWidget.cpp @@ -38,7 +38,9 @@ WPropertyColorWidget::WPropertyColorWidget( WPropColor property, QGridLayout* pr WPropertyWidget( property, propertyGrid, parent ), m_colorProperty( property ), m_button( &m_parameterWidgets ), - m_layout() + m_layout(), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_parameterWidgets.setLayout( &m_layout ); @@ -46,6 +48,10 @@ WPropertyColorWidget::WPropertyColorWidget( WPropColor property, QGridLayout* pr // layout both against each other m_layout.addWidget( &m_button ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + // set the initial values update(); @@ -61,6 +67,13 @@ WPropertyColorWidget::~WPropertyColorWidget() void WPropertyColorWidget::update() { m_button.setPalette( QPalette( toQColor( m_colorProperty->get() ) ) ); + + // if this is a info property -> set background of label and some text + m_asText.setText( QString::fromStdString( m_colorProperty->getAsString() ) ); + QPalette pal = QPalette(); + pal.setColor( QPalette::Background, toQColor( m_colorProperty->get() ) ); + m_asText.setAutoFillBackground( true ); + m_asText.setPalette( pal ); } QColor WPropertyColorWidget::toQColor( WColor color ) diff --git a/src/gui/qt4/datasetbrowser/WPropertyColorWidget.h b/src/gui/qt4/datasetbrowser/WPropertyColorWidget.h index 5cb7833a0..b53c5a5f2 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyColorWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyColorWidget.h @@ -76,6 +76,16 @@ protected: */ QHBoxLayout m_layout; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: /** diff --git a/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp index e5eb13aac..3bf3aed10 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp @@ -38,7 +38,9 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout* m_doubleProperty( property ), m_slider( Qt::Horizontal, &m_parameterWidgets ), m_edit( &m_parameterWidgets ), - m_layout( &m_parameterWidgets ) + m_layout( &m_parameterWidgets ), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_edit.resize( m_edit.minimumSizeHint().width() *.8 , m_edit.size().height() ); @@ -50,6 +52,10 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout* m_parameterWidgets.setLayout( &m_layout ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + update(); // connect the modification signal of the edit and slider with our callback @@ -132,8 +138,12 @@ void WPropertyDoubleWidget::update() // m_edit.resize( m_edit.minimumSizeHint().width() * length / 2, m_edit.size().height() ); // set the initial values - m_edit.setText( QString( toString( m_doubleProperty->get() ).c_str() ) ); + QString valStr = QString( toString( m_doubleProperty->get() ).c_str() ); + m_edit.setText( valStr ); m_slider.setValue( toPercent( m_doubleProperty->get() ) ); + + // do not forget to update the label + m_asText.setText( valStr ); } int WPropertyDoubleWidget::toPercent( double value ) diff --git a/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h index 795528ba5..d1d6848c0 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h @@ -110,6 +110,16 @@ protected: */ double m_max; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp index ccb3b036e..aefe6ea3c 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.cpp @@ -39,7 +39,9 @@ WPropertyFilenameWidget::WPropertyFilenameWidget( WPropFilename property, QGridL WPropertyWidget( property, propertyGrid, parent ), m_fnProperty( property ), m_button( &m_parameterWidgets ), - m_layout( &m_parameterWidgets ) + m_layout( &m_parameterWidgets ), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_parameterWidgets.setLayout( &m_layout ); @@ -50,6 +52,10 @@ WPropertyFilenameWidget::WPropertyFilenameWidget( WPropFilename property, QGridL // this prevents the button from resizing when a long path is selected m_button.setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + // set the initial values update(); @@ -64,7 +70,9 @@ WPropertyFilenameWidget::~WPropertyFilenameWidget() void WPropertyFilenameWidget::update() { - m_button.setText( QString::fromStdString( m_fnProperty->get().file_string() ) ); + QString val = QString::fromStdString( m_fnProperty->get().file_string() ); + m_button.setText( val ); + m_asText.setText( val ); } void WPropertyFilenameWidget::buttonReleased() diff --git a/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h b/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h index b8ea4ec60..81e6003ed 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyFilenameWidget.h @@ -76,6 +76,16 @@ protected: */ QHBoxLayout m_layout; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp index 448576e03..e6294e773 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp @@ -39,7 +39,9 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property m_intProperty( property ), m_slider( Qt::Horizontal, &m_parameterWidgets ), m_edit( &m_parameterWidgets ), - m_layout( &m_parameterWidgets ) + m_layout( &m_parameterWidgets ), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_edit.resize( m_edit.minimumSizeHint().width(), m_edit.size().height() ); @@ -48,9 +50,12 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property // layout both against each other m_layout.addWidget( &m_slider ); m_layout.addWidget( &m_edit ); - m_parameterWidgets.setLayout( &m_layout ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + update(); // connect the modification signal of the edit and slider with our callback @@ -112,15 +117,18 @@ void WPropertyIntWidget::update() int length = 6; // use fixed length to have a uniform look among several widgets // resize the text widget -// m_edit.setMaxLength( length ); + // m_edit.setMaxLength( length ); m_edit.setMaximumWidth( m_edit.minimumSizeHint().width() * length / 2 ); -// m_edit.setMinimumWidth( m_edit.minimumSizeHint().width() * length / 4 ); -// m_edit.resize( m_edit.minimumSizeHint().width() * length / 4, m_edit.size().height() ); - + // m_edit.setMinimumWidth( m_edit.minimumSizeHint().width() * length / 4 ); + // m_edit.resize( m_edit.minimumSizeHint().width() * length / 4, m_edit.size().height() ); // set the initial values - m_edit.setText( QString( boost::lexical_cast< std::string >( m_intProperty->get() ).c_str() ) ); + QString valStr = QString( boost::lexical_cast< std::string >( m_intProperty->get() ).c_str() ); + m_edit.setText( valStr ); m_slider.setValue( m_intProperty->get() ); + + // do not forget to update the label + m_asText.setText( valStr ); } void WPropertyIntWidget::sliderChanged( int value ) diff --git a/src/gui/qt4/datasetbrowser/WPropertyIntWidget.h b/src/gui/qt4/datasetbrowser/WPropertyIntWidget.h index f947dd2b4..67f660522 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyIntWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyIntWidget.h @@ -82,6 +82,16 @@ protected: */ QHBoxLayout m_layout; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp index 174bfae95..c73d1fb97 100644 --- a/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.cpp @@ -44,8 +44,6 @@ WPropertySelectionWidget::WPropertySelectionWidget( WPropSelection property, QGr m_update( false ) { // initialize members - m_parameterWidgets.setLayout( &m_layout ); - m_combo = NULL; m_list = NULL; @@ -102,6 +100,26 @@ WPropertySelectionWidget::WPropertySelectionWidget( WPropSelection property, QGr connect( m_list, SIGNAL( itemSelectionChanged() ), this, SLOT( listSelectionChanged() ) ); } + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + // In this case -> use some disabled lists/combos here + if ( m_property->getPurpose() == PV_PURPOSE_INFORMATION ) + { + m_informationWidgets.setLayout( &m_layout ); + + if ( m_list ) + { + m_list->setEnabled( false ); + } + else + { + m_combo->setEnabled( false ); + } + } + else + { + m_parameterWidgets.setLayout( &m_layout ); + } + // set the initial values update(); } diff --git a/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.h b/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.h index 25ffe6599..7ac7c899e 100644 --- a/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertySelectionWidget.h @@ -87,6 +87,7 @@ protected: * called when changed programmatically. */ bool m_update; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp index f3a341db7..7986012c5 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp @@ -36,7 +36,9 @@ WPropertyStringWidget::WPropertyStringWidget( WPropString property, QGridLayout* WPropertyWidget( property, propertyGrid, parent ), m_stringProperty( property ), m_edit( &m_parameterWidgets ), - m_layout( &m_parameterWidgets ) + m_layout( &m_parameterWidgets ), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_parameterWidgets.setLayout( &m_layout ); @@ -44,6 +46,13 @@ WPropertyStringWidget::WPropertyStringWidget( WPropString property, QGridLayout* // layout m_layout.addWidget( &m_edit ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + m_asText.setWordWrap( true ); + // To have word warp work correctly -> set size policy + m_asText.setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); + // set the initial values update(); @@ -59,7 +68,9 @@ WPropertyStringWidget::~WPropertyStringWidget() void WPropertyStringWidget::update() { - m_edit.setText( QString( m_stringProperty->get().c_str() ) ); + QString val = QString( m_stringProperty->get().c_str() ); + m_edit.setText( val ); + m_asText.setText( val ); } void WPropertyStringWidget::editChanged() diff --git a/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h index a19d6cbb3..9a8f19f7c 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h @@ -77,6 +77,16 @@ protected: */ QHBoxLayout m_layout; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.cpp index 898579d8d..2788117fd 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.cpp @@ -30,7 +30,9 @@ WPropertyTriggerWidget::WPropertyTriggerWidget( WPropTrigger property, QGridLayo WPropertyWidget( property, propertyGrid, parent ), m_triggerProperty( property ), m_button( &m_parameterWidgets ), - m_layout( &m_parameterWidgets ) + m_layout( &m_parameterWidgets ), + m_asText( &m_informationWidgets ), + m_infoLayout( &m_informationWidgets ) { // initialize members m_button.setCheckable( true ); @@ -43,6 +45,10 @@ WPropertyTriggerWidget::WPropertyTriggerWidget( WPropTrigger property, QGridLayo m_layout.setContentsMargins( 1, 1, 1, 1 ); m_parameterWidgets.setLayout( &m_layout ); + // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION ) + m_infoLayout.addWidget( &m_asText ); + m_informationWidgets.setLayout( &m_infoLayout ); + // connect the modification signal of m_checkbox with our callback connect( &m_button, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) ); } @@ -57,6 +63,9 @@ void WPropertyTriggerWidget::update() // simply set the new state m_button.setChecked( m_triggerProperty->get() == WPVBaseTypes::PV_TRIGGER_TRIGGERED ); m_button.setEnabled( m_triggerProperty->get() == WPVBaseTypes::PV_TRIGGER_READY ); + + // do not forget to update the label + m_asText.setText( m_triggerProperty->get() == WPVBaseTypes::PV_TRIGGER_TRIGGERED ? QString( "Operation triggered" ) : QString( "Ready" ) ); } QPushButton* WPropertyTriggerWidget::getButton() diff --git a/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.h b/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.h index 1227b4107..0b80ec01e 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyTriggerWidget.h @@ -84,6 +84,16 @@ protected: */ QHBoxLayout m_layout; + /** + * Used to show the property as text. + */ + QLabel m_asText; + + /** + * The layout used for the pure output (information properties) + */ + QHBoxLayout m_infoLayout; + private: public slots: diff --git a/src/gui/qt4/datasetbrowser/WPropertyWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyWidget.cpp index bc37b79a6..136dee19f 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyWidget.cpp @@ -38,6 +38,7 @@ WPropertyWidget::WPropertyWidget( boost::shared_ptr< WPropertyBase > property, m_label( this ), m_useLabel( m_propertyGrid ), m_parameterWidgets(), // parent gets set by the QStackWidget + m_informationWidgets(), // parent gets set by the QStackWidget m_invalid( false ) { if ( m_useLabel ) @@ -54,7 +55,15 @@ WPropertyWidget::WPropertyWidget( boost::shared_ptr< WPropertyBase > property, m_propertyGrid->addWidget( this, row, 1 ); } + // add both widgets to the stacked widget, it then uses the first as default. addWidget( &m_parameterWidgets ); + addWidget( &m_informationWidgets ); + + // if the purpose of the property is INFORMTION -> activate the information widget + if ( m_property->getPurpose() == PV_PURPOSE_INFORMATION ) + { + setCurrentIndex( 1 ); + } // setup the update callback m_connection = m_property->getUpdateCondition()->subscribeSignal( boost::bind( &WPropertyWidget::propertyChangeNotifier, this ) ); diff --git a/src/gui/qt4/datasetbrowser/WPropertyWidget.h b/src/gui/qt4/datasetbrowser/WPropertyWidget.h index 838290748..e7613110f 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyWidget.h +++ b/src/gui/qt4/datasetbrowser/WPropertyWidget.h @@ -113,6 +113,11 @@ protected: */ QWidget m_parameterWidgets; + /** + * The widget containing a layout and provides the widgets for showing information properties. + */ + QWidget m_informationWidgets; + /** * Flag denoting whether the widget is set to an invalid value. */ diff --git a/src/modules/template/WMTemplate.cpp b/src/modules/template/WMTemplate.cpp index 8db50c986..80e8bc712 100644 --- a/src/modules/template/WMTemplate.cpp +++ b/src/modules/template/WMTemplate.cpp @@ -297,12 +297,21 @@ void WMTemplate::properties() // In more detail, the purpose type of the property gets set to PV_PURPOSE_INFORMATION automatically by m_infoProperties. You can, of course, // add information properties to your custom groups or m_properties too. There, you need to set the purpose flag of the property manually: std::string message = std::string( "Hey you! Besides all these parameters, you also can print values, html formatted strings, colors and " ) + - std::string( "so on using properties! Isn't it amazing?" ); + std::string( "so on using properties! Isn't it amazing?" ); m_aStringOutput = m_group1a->addProperty( "A Message", "A message to the user.", message ); m_aStringOutput->setPurpose( PV_PURPOSE_INFORMATION ); // This adds the property m_aStringOutput to your group and sets its purpose. The default purpose for all properties is always // "PV_PURPOSE_PARAMETER". It simply denotes the meaning of the property - its meant to be used as modifier for the module's behaviour; a // parameter. + // + // Some more examples. Please note: Although every property type can be used as information property, not everything is really useful. + m_aTriggerOutput = m_infoProperties->addProperty( "A Trigger", "Trigger As String", WPVBaseTypes::PV_TRIGGER_READY ); + m_aDoubleOutput = m_infoProperties->addProperty( "Some Double", "a Double. Nice isn't it?", 3.1415 ); + m_aColorOutput = m_infoProperties->addProperty( "A Color", "Some Color. Nice isn't it?", WColor( 0.5, 0.5, 1.0, 1.0 ) ); + m_aFilenameOutput = m_infoProperties->addProperty( "Nice File", "a Double. Nice isn't it?", WKernel::getAppPathObject() ); + m_aSelectionOutput = m_infoProperties->addProperty( "A Selection", "Selection As String", m_possibleSelections->getSelectorFirst() ); + // We can add info another property here too: + m_infoProperties->addProperty( m_aStringOutput ); } void WMTemplate::moduleMain() @@ -320,7 +329,7 @@ void WMTemplate::moduleMain() // useful whenever your module needs to do long operations to initialize. No other module can connect to your module before it signals its // ready state. You can assume the code before ready() to be some kind of initialization code. debugLog() << "Doing time consuming operations"; - sleep( 5 ); + sleep( 0 ); // Your module can use an moduleState variable to wait for certain events. Most commonly, these events are new data on input connectors or // changed properties. You can decide which events the moduleState should handle. Therefore, use m_moduleState.add( ... ) to insert every @@ -352,7 +361,7 @@ void WMTemplate::moduleMain() // modified but the module can modify it. This is useful to provide statistics, counts, times or even a "hello world" string to the user // as an information or status report. Please do not abuse these information properties as progress indicators. A short overview on how // to make progress indicators is provided some lines below. Here, we simply increase the value. - m_aIntegerOutput->set( m_aIntegerOutput->get() +1 ); + m_aIntegerOutput->set( m_aIntegerOutput->get() + 1 ); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // After waking up, the module has to check whether the shutdownFlag fired. If yes, simply quit the module. @@ -529,6 +538,9 @@ void WMTemplate::moduleMain() // Now that the trigger has the state "triggered", a time consuming operation can be done here. debugLog() << "User triggered an important and time consuming operation."; + // Update the output property + m_aTriggerOutput->set( WPVBaseTypes::PV_TRIGGER_TRIGGERED ); + // Do something here. As above, do not forget to inform the user about your progress. int steps = 10; boost::shared_ptr< WProgress > progress1 = boost::shared_ptr< WProgress >( new WProgress( "Doing something important", steps ) ); @@ -546,6 +558,9 @@ void WMTemplate::moduleMain() // To avoid the moduleMain- loop to awake every time we reset the trigger, provide a second parameter to the set() method. It denotes // whether the change notification should be fired or not. In our case, we avoid this by providing false to the second parameter. m_aTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, false ); + + // Also update the information property. + m_aTriggerOutput->set( WPVBaseTypes::PV_TRIGGER_READY ); } // This checks the selections. diff --git a/src/modules/template/WMTemplate.h b/src/modules/template/WMTemplate.h index 468d00977..dff91bda5 100644 --- a/src/modules/template/WMTemplate.h +++ b/src/modules/template/WMTemplate.h @@ -190,25 +190,52 @@ private: */ WPropTrigger m_aTrigger; + /** + * A property allowing the user to select ONE item of some list + */ + WPropSelection m_aSingleSelection; + + /** + * A property allowing the user to select multiple elements of a list. + */ + WPropSelection m_aMultiSelection; + + // Outputs -> demonstrate the use of information properties: + /** * A property simply providing a integer value to the outside world. */ WPropInt m_aIntegerOutput; + /** + * A property simply providing a double value to the outside world. + */ + WPropDouble m_aDoubleOutput; + /** * A property simply providing some text to the outside world. */ WPropString m_aStringOutput; /** - * A property allowing the user to select ONE item of some list + * A Property used to show some color to the user. */ - WPropSelection m_aSingleSelection; + WPropColor m_aColorOutput; /** - * A property allowing the user to select multiple elements of a list. + * A Property used to show some filename to the user. */ - WPropSelection m_aMultiSelection; + WPropFilename m_aFilenameOutput; + + /** + * A Property used to show some trigger to the user. + */ + WPropTrigger m_aTriggerOutput; + + /** + * A Property used to show some selection to the user. + */ + WPropSelection m_aSelectionOutput; /** * A list of items that can be selected using m_aSingleSelection or m_aMultiSelection. -- GitLab