diff --git a/Code/Common/Core/mvdImageSettingsInterface.cxx b/Code/Common/Core/mvdImageSettingsInterface.cxx index 98c0e41361bd3f25180bd9bf706382e63ba949a0..2cc84d847368234ffe9bb0da7a875852ce2d5c45 100644 --- a/Code/Common/Core/mvdImageSettingsInterface.cxx +++ b/Code/Common/Core/mvdImageSettingsInterface.cxx @@ -87,6 +87,15 @@ ImageSettingsInterface { delete m_Settings; m_Settings = settings; + + virtual_SetSettings( settings ); +} + +/*****************************************************************************/ +void +ImageSettingsInterface +::virtual_SetSettings( ImageSettings * ) +{ } /*****************************************************************************/ diff --git a/Code/Common/Core/mvdImageSettingsInterface.h b/Code/Common/Core/mvdImageSettingsInterface.h index 04977aae4460e1d02731f0b4eba31ddaf46204c4..d0e087a2bbd4f14272cb64f24dd249730f10ca0b 100644 --- a/Code/Common/Core/mvdImageSettingsInterface.h +++ b/Code/Common/Core/mvdImageSettingsInterface.h @@ -117,6 +117,8 @@ private: /** */ void SetSettings( ImageSettings * ); + /** */ + virtual void virtual_SetSettings( ImageSettings * ); // // Private attributes. diff --git a/Code/Common/Gui/mvdShaderWidget.cxx b/Code/Common/Gui/mvdShaderWidget.cxx index 50aee505cb885c2d012e200edc8aaec073cc8e6e..7abb69d0e1900f7659fb25560278296de905e720 100644 --- a/Code/Common/Gui/mvdShaderWidget.cxx +++ b/Code/Common/Gui/mvdShaderWidget.cxx @@ -29,6 +29,7 @@ // // System includes (sorted by alphabetic order) +#include <cassert> // // ITK includes (sorted by alphabetic order) @@ -38,6 +39,9 @@ // // Monteverdi includes (sorted by alphabetic order) +#include "Core/mvdAlgorithm.h" +#include "Core/mvdImageSettings.h" + namespace mvd { @@ -66,9 +70,17 @@ namespace mvd ShaderWidget ::ShaderWidget( QWidget * parent, Qt::WindowFlags flags ): QWidget( parent, flags ), - m_UI( new mvd::Ui::ShaderWidget() ) + m_UI( new mvd::Ui::ShaderWidget() ), + m_Settings( NULL ) { m_UI->setupUi( this ); + + for( int i=0; i<ImageSettings::EFFECT_COUNT; ++i ) + m_UI->effectComboBox->addItem( ImageSettings::EFFECT_NAME[ i ] ); + + m_UI->valueLineEdit->setValidator( + new QDoubleValidator( m_UI->valueLineEdit ) + ); } /*******************************************************************************/ @@ -79,8 +91,80 @@ ShaderWidget m_UI = NULL; } +/*******************************************************************************/ +void +ShaderWidget +::virtual_SetSettings( ImageSettings * settings ) +{ + assert( m_UI!=NULL ); + + m_UI->effectComboBox->setEnabled( settings!=NULL ); + m_UI->sizeLabel->setEnabled( settings!=NULL ); + m_UI->sizeSpinBox->setEnabled( settings!=NULL && settings->HasSize() ); + m_UI->valueLabel->setEnabled( settings!=NULL ); + m_UI->valueLineEdit->setEnabled( settings!=NULL && settings->HasValue() ); + + if( settings!=NULL ) + { + for( int i=0; i<m_UI->effectComboBox->count(); ++i ) + if( QString::compare( ImageSettings::EFFECT_NAME[ i ], + m_UI->effectComboBox->itemText( i ) )==0 ) + { + m_UI->effectComboBox->setCurrentIndex( i ); + + break; + } + + m_UI->sizeSpinBox->setValue( settings->GetSize() ); + m_UI->valueLineEdit->setText( ToQString( settings->GetValue() ) ); + } +} + /*******************************************************************************/ /* SLOTS */ /*******************************************************************************/ +void +ShaderWidget +::on_effectComboBox_currentIndexChanged( const QString & text ) +{ + for( int i=0; i<ImageSettings::EFFECT_COUNT; ++i ) + if( QString::compare( text, ImageSettings::EFFECT_NAME[ i ] )==0 ) + { + assert( m_Settings!=NULL ); + + m_Settings->SetEffect( static_cast< ImageSettings::Effect >( i ) ); + + m_UI->sizeSpinBox->setEnabled( m_Settings->HasSize() ); + m_UI->valueLineEdit->setEnabled( m_Settings->HasValue() ); + + return; + } +} + +/*******************************************************************************/ +void +ShaderWidget +::on_sizeSpinBox_valueChanged( int value ) +{ + assert( m_Settings!=NULL ); + assert( m_Settings->HasSize() ); + + m_Settings->SetSize( value ); +} + +/*******************************************************************************/ +void +ShaderWidget +::on_valueLineEdit_textChanged( const QString & text ) +{ + assert( m_Settings!=NULL ); + assert( m_Settings->HasValue() ); + + bool isOk = true; + + m_Settings->SetValue( text.toDouble( &isOk ) ); + + assert( isOk ); +} } // end namespace 'mvd' diff --git a/Code/Common/Gui/mvdShaderWidget.h b/Code/Common/Gui/mvdShaderWidget.h index e4b55e63f09ff8ce1d457b8a235dccb63b9cd8d7..9ffada5ed53b452c1def1dd6e0ba7df81c41261c 100644 --- a/Code/Common/Gui/mvdShaderWidget.h +++ b/Code/Common/Gui/mvdShaderWidget.h @@ -44,6 +44,7 @@ // // Monteverdi includes (sorted by alphabetic order) +#include "Core/mvdImageSettingsInterface.h" /*****************************************************************************/ @@ -65,6 +66,7 @@ namespace Ui class ShaderWidget; }; +class ImageSettings; /*****************************************************************************/ /* CLASS DEFINITION SECTION */ @@ -76,7 +78,8 @@ class ShaderWidget; * widget class. */ class Monteverdi2_EXPORT ShaderWidget : - public QWidget + public QWidget, + public ImageSettingsInterface { /*-[ QOBJECT SECTION ]-----------------------------------------------------*/ @@ -95,6 +98,10 @@ public: /** \brief Destructor. */ virtual ~ShaderWidget(); + /** + */ + void SetSettings( ImageSettings ); + /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ // @@ -123,6 +130,9 @@ protected: // Private methods. private: + /** */ + virtual void virtual_SetSettings( ImageSettings * ); + // // Private attributes. private: @@ -131,11 +141,17 @@ private: */ Ui::ShaderWidget * m_UI; + /** */ + ImageSettings * m_Settings; + /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/ // // Slots. private slots: + void on_effectComboBox_currentIndexChanged( const QString & ); + void on_sizeSpinBox_valueChanged( int ); + void on_valueLineEdit_textChanged( const QString & ); }; } // end namespace 'mvd' diff --git a/Code/Common/Gui/mvdShaderWidget.ui b/Code/Common/Gui/mvdShaderWidget.ui index cb1fa505051dbb5b8cbea229c1feb68f2972b640..7bdfc6e1d1f1f113feac8f37c16edbb2b625ffef 100644 --- a/Code/Common/Gui/mvdShaderWidget.ui +++ b/Code/Common/Gui/mvdShaderWidget.ui @@ -21,75 +21,51 @@ <number>1</number> </property> <item> - <widget class="QComboBox" name="comboBox"> + <widget class="QComboBox" name="effectComboBox"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="insertPolicy"> <enum>QComboBox::InsertAlphabetically</enum> </property> - <item> - <property name="text"> - <string>Chessboard</string> - </property> - </item> - <item> - <property name="text"> - <string>Gradient</string> - </property> - </item> - <item> - <property name="text"> - <string>Local constrast</string> - </property> - </item> - <item> - <property name="text"> - <string>Local translucency</string> - </property> - </item> - <item> - <property name="text"> - <string>Normal</string> - </property> - </item> - <item> - <property name="text"> - <string>Spectral angle</string> - </property> - </item> - <item> - <property name="text"> - <string>Swipe (horizontal)</string> - </property> - </item> - <item> - <property name="text"> - <string>Swipe (vertical)</string> - </property> - </item> </widget> </item> <item> - <widget class="QLabel" name="label"> + <widget class="QLabel" name="sizeLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Size:</string> </property> </widget> </item> <item> - <widget class="QSpinBox" name="spinBox"> + <widget class="QSpinBox" name="sizeSpinBox"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="value"> <number>16</number> </property> </widget> </item> <item> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="valueLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Value:</string> </property> </widget> </item> <item> - <widget class="QLineEdit" name="lineEdit"/> + <widget class="QLineEdit" name="valueLineEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> </layout> </widget>