diff --git a/Code/Application/Mv2/mvdMainWindow.cxx b/Code/Application/Mv2/mvdMainWindow.cxx index 08af77280b09c17198aa9ad28987e5d2ee313ce6..475994fa7b608f3336191bae0e510196ba1eb3a0 100644 --- a/Code/Application/Mv2/mvdMainWindow.cxx +++ b/Code/Application/Mv2/mvdMainWindow.cxx @@ -127,6 +127,8 @@ MainWindow m_ImageView( NULL ), m_QuicklookViewDock( NULL ), m_CentralTabWidget( NULL ), + m_StatusBarWidget( NULL ), + m_ShaderWidget( NULL ), m_FilenameDragAndDropEventFilter( NULL ) { m_UI->setupUi( this ); @@ -917,9 +919,11 @@ MainWindow m_UI->m_RenderToolBar->addSeparator(); { - m_UI->m_RenderToolBar->addWidget( - new ShaderWidget( m_UI->m_RenderToolBar ) - ); + assert( m_ShaderWidget==NULL ); + + m_ShaderWidget = new ShaderWidget( m_UI->m_RenderToolBar ); + + m_UI->m_RenderToolBar->addWidget( m_ShaderWidget ); } } @@ -1439,6 +1443,8 @@ MainWindow if( layerModel->inherits( VectorImageModel::staticMetaObject.className() ) ) { + m_ShaderWidget->SetSettings( NULL ); + // Disconnect previously selected image-model from view. QObject::disconnect( layerModel, @@ -1457,6 +1463,16 @@ MainWindow m_QuicklookViewDock->widget(), SLOT( updateGL() ) ); + + // + // Disconnect shader-widget from model-updated slot. + QObject::disconnect( + m_ShaderWidget, + SIGNAL( SettingsChanged() ), + // from: + layerModel, + SLOT( OnModelUpdated() ) + ); } else @@ -1523,7 +1539,17 @@ MainWindow SIGNAL( SettingsUpdated() ), // to: m_QuicklookViewDock->widget(), - SLOT( updateGL() ) + SLOT( updateGL() ) + ); + + // + // Connect shader-widget to model-updated slot. + QObject::connect( + m_ShaderWidget, + SIGNAL( SettingsChanged() ), + // to: + layerModel, + SLOT( OnModelUpdated() ) ); VectorImageModel * imageModel = @@ -1535,6 +1561,8 @@ MainWindow QString( PROJECT_NAME " - %1" ) .arg( QFileInfo( imageModel->GetFilename() ).fileName() ) ); + + m_ShaderWidget->SetSettings( &imageModel->GetSettings() ); } else { diff --git a/Code/Application/Mv2/mvdMainWindow.h b/Code/Application/Mv2/mvdMainWindow.h index c36eb9b47299c40494390f8cfd37341f72e40b51..0c8c0c1118476c677a6805a22a16c751a22d54c9 100644 --- a/Code/Application/Mv2/mvdMainWindow.h +++ b/Code/Application/Mv2/mvdMainWindow.h @@ -77,6 +77,7 @@ class AbstractLayerModel; class FilenameDragAndDropEventFilter; class ImageViewWidget; class LayerStackWidget; +class ShaderWidget; class StatusBarWidget; namespace Ui @@ -372,6 +373,10 @@ private: */ StatusBarWidget* m_StatusBarWidget; + /** + */ + ShaderWidget * m_ShaderWidget; + /** */ FilenameDragAndDropEventFilter* m_FilenameDragAndDropEventFilter; diff --git a/Code/Common/Core/mvdImageSettings.cxx b/Code/Common/Core/mvdImageSettings.cxx index b924aa2933cfd02dde5852e924fc60cbe6a27386..41b7c990c01aff9f71bb7500ea50bfe60e261538 100644 --- a/Code/Common/Core/mvdImageSettings.cxx +++ b/Code/Common/Core/mvdImageSettings.cxx @@ -77,23 +77,25 @@ ImageSettings /*****************************************************************************/ /* CLASS IMPLEMENTATION SECTION */ - -/*******************************************************************************/ +/*****************************************************************************/ ImageSettings ::ImageSettings() : m_IsModified( false ), - m_IsApplied( false ) + m_IsApplied( false ), + m_Effect( EFFECT_NORMAL ), + m_Size( 16 ), + m_Value( 0.0 ) { } -/*******************************************************************************/ +/*****************************************************************************/ ImageSettings ::~ImageSettings() { } -/*******************************************************************************/ -/* SLOTS */ -/*******************************************************************************/ +/*****************************************************************************/ +/* SLOTS */ +/*****************************************************************************/ } // end namespace 'mvd' diff --git a/Code/Common/Core/mvdImageSettingsInterface.cxx b/Code/Common/Core/mvdImageSettingsInterface.cxx index 2cc84d847368234ffe9bb0da7a875852ce2d5c45..716746bb37c833a2b5982c71b4dc90247147b5a0 100644 --- a/Code/Common/Core/mvdImageSettingsInterface.cxx +++ b/Code/Common/Core/mvdImageSettingsInterface.cxx @@ -76,8 +76,10 @@ ImageSettingsInterface ImageSettingsInterface ::~ImageSettingsInterface() { +#if 0 delete m_Settings; m_Settings = NULL; +#endif } /*****************************************************************************/ @@ -85,7 +87,10 @@ void ImageSettingsInterface ::SetSettings( ImageSettings * settings ) { +#if 0 delete m_Settings; +#endif + m_Settings = settings; virtual_SetSettings( settings ); diff --git a/Code/Common/Core/mvdImageSettingsInterface.h b/Code/Common/Core/mvdImageSettingsInterface.h index d0e087a2bbd4f14272cb64f24dd249730f10ca0b..8f2a315da7a59b87f22761d935b21dbc9b4fcafe 100644 --- a/Code/Common/Core/mvdImageSettingsInterface.h +++ b/Code/Common/Core/mvdImageSettingsInterface.h @@ -96,6 +96,10 @@ public: const T * GetSettings() const; #endif + /** */ + void SetSettings( ImageSettings * ); + + /*-[ PROTECTED SECTION ]---------------------------------------------------*/ // @@ -114,9 +118,6 @@ protected: // // Private methods. private: - /** */ - void SetSettings( ImageSettings * ); - /** */ virtual void virtual_SetSettings( ImageSettings * ); diff --git a/Code/Common/Gui/mvdShaderWidget.cxx b/Code/Common/Gui/mvdShaderWidget.cxx index 7abb69d0e1900f7659fb25560278296de905e720..2d204b3fa5ecfb105803d3b1df5e84d9f0644afb 100644 --- a/Code/Common/Gui/mvdShaderWidget.cxx +++ b/Code/Common/Gui/mvdShaderWidget.cxx @@ -70,8 +70,7 @@ namespace mvd ShaderWidget ::ShaderWidget( QWidget * parent, Qt::WindowFlags flags ): QWidget( parent, flags ), - m_UI( new mvd::Ui::ShaderWidget() ), - m_Settings( NULL ) + m_UI( new mvd::Ui::ShaderWidget() ) { m_UI->setupUi( this ); @@ -107,8 +106,8 @@ ShaderWidget 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 ) + if( QString::compare( m_UI->effectComboBox->itemText( i ), + ImageSettings::EFFECT_NAME[ settings->GetEffect() ] )==0 ) { m_UI->effectComboBox->setCurrentIndex( i ); @@ -127,15 +126,18 @@ void ShaderWidget ::on_effectComboBox_currentIndexChanged( const QString & text ) { + if( !HasSettings() ) + return; + for( int i=0; i<ImageSettings::EFFECT_COUNT; ++i ) if( QString::compare( text, ImageSettings::EFFECT_NAME[ i ] )==0 ) { - assert( m_Settings!=NULL ); + GetSettings()->SetEffect( static_cast< ImageSettings::Effect >( i ) ); - m_Settings->SetEffect( static_cast< ImageSettings::Effect >( i ) ); + m_UI->sizeSpinBox->setEnabled( GetSettings()->HasSize() ); + m_UI->valueLineEdit->setEnabled( GetSettings()->HasValue() ); - m_UI->sizeSpinBox->setEnabled( m_Settings->HasSize() ); - m_UI->valueLineEdit->setEnabled( m_Settings->HasValue() ); + emit SettingsChanged(); return; } @@ -146,10 +148,12 @@ void ShaderWidget ::on_sizeSpinBox_valueChanged( int value ) { - assert( m_Settings!=NULL ); - assert( m_Settings->HasSize() ); + if( !HasSettings() ) + return; + + GetSettings()->SetSize( value ); - m_Settings->SetSize( value ); + emit SettingsChanged(); } /*******************************************************************************/ @@ -157,14 +161,16 @@ void ShaderWidget ::on_valueLineEdit_textChanged( const QString & text ) { - assert( m_Settings!=NULL ); - assert( m_Settings->HasValue() ); + if( !HasSettings() ) + return; bool isOk = true; - m_Settings->SetValue( text.toDouble( &isOk ) ); + GetSettings()->SetValue( text.toDouble( &isOk ) ); assert( isOk ); + + emit SettingsChanged(); } } // end namespace 'mvd' diff --git a/Code/Common/Gui/mvdShaderWidget.h b/Code/Common/Gui/mvdShaderWidget.h index 9ffada5ed53b452c1def1dd6e0ba7df81c41261c..83e13ceffb7961b36c256fb7961234499c7d81a3 100644 --- a/Code/Common/Gui/mvdShaderWidget.h +++ b/Code/Common/Gui/mvdShaderWidget.h @@ -98,10 +98,6 @@ public: /** \brief Destructor. */ virtual ~ShaderWidget(); - /** - */ - void SetSettings( ImageSettings ); - /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ // @@ -113,6 +109,7 @@ public slots: // // Signals. signals: + void SettingsChanged(); /*-[ PROTECTED SECTION ]---------------------------------------------------*/ @@ -141,9 +138,6 @@ private: */ Ui::ShaderWidget * m_UI; - /** */ - ImageSettings * m_Settings; - /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/ //