From: Leonardo Flórez-Valencia Date: Tue, 22 Nov 2016 03:44:56 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~40 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2fed0327528e671e32cc7151cb65ebd769c053e6;p=cpPlugins.git ... --- diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index d14d0cf..f0b8616 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -1,12 +1,9 @@ #include #include -/* TODO - #include - #include - #include -*/ #include +#include +#include #include #include #include @@ -31,6 +28,10 @@ PipelineEditor( int argc, char* argv[], QWidget* parent ) cpBaseQtApplication_ConnectAction( actionOpenWorkspace, _loadWorkspace ); cpBaseQtApplication_ConnectAction( actionSaveWorkspace, _saveWorkspace ); cpBaseQtApplication_ConnectAction( actionSaveWorkspaceAs, _saveWorkspace ); + cpBaseQtApplication_ConnectAction( actionActorsProperties, _actorsProperties ); + this->m_UI->Canvas->connectOutputPortSlot( + this, SLOT( _slotView( const std::string&, bool ) ) + ); // Load command-line given workspace (if any) this->m_ActiveWS = "empty"; @@ -41,31 +42,6 @@ PipelineEditor( int argc, char* argv[], QWidget* parent ) } else this->_addWorkspace( this->m_ActiveWS ); - - /* TODO - this->connect( - this->m_UI->actionOpenWorkspace, SIGNAL( triggered( ) ), - this, SLOT( _slotOpenWorkspace( ) ) - ); - this->connect( - this->m_UI->actionSaveWorkspace, SIGNAL( triggered( ) ), - this, SLOT( _slotSaveWorkspace( ) ) - ); - this->connect( - this->m_UI->actionSaveWorkspaceAs, SIGNAL( triggered( ) ), - this, SLOT( _slotSaveWorkspaceAs( ) ) - ); - this->connect( - this->m_UI->actionActorsProperties, SIGNAL( triggered( ) ), - this, SLOT( _slotActorsProperties( ) ) - ); - this->m_UI->Canvas->connectOutputPortSlot( - this, SLOT( _slotView( const std::string&, bool ) ) - ); - */ - - - // Associate qt-based objects } // ------------------------------------------------------------------------- @@ -75,33 +51,6 @@ PipelineEditor:: delete this->m_UI; } -// ------------------------------------------------------------------------- -template< class _TWidget > -std::pair< _TWidget*, bool > PipelineEditor:: -_configureViewer( ) -{ - /* TODO - auto new_viewer = dynamic_cast< _TWidget* >( this->m_UI->Viewer ); - bool ok = false; - if( new_viewer == NULL ) - { - new_viewer = new _TWidget( ); - delete this->m_UI->Viewer; - this->m_UI->Viewer = new_viewer; - ok = true; - - auto interactors = new_viewer->GetInteractors( ); - for( auto w : this->m_Workspaces ) - for( auto i : interactors ) - w.second->AddInteractor( i ); - - } // fi - this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer ); - return( std::pair< _TWidget*, bool >( new_viewer, ok ) ); - */ - return( std::pair< _TWidget*, bool >( NULL, false ) ); -} - // ------------------------------------------------------------------------- void PipelineEditor:: _slotView( const std::string& name, bool show ) @@ -117,124 +66,78 @@ _slotView( const std::string& name, bool show ) auto output_name = tokens[ 0 ]; // Process data - try + if( show ) { - auto ws = this->workspace( this->m_ActiveWS ); - auto filter = ws->GetFilter( filter_name ); - cpBaseQtApplication_Execute( filter->Update( ) ); - auto image = filter->GetOutputData< vtkImageData >( output_name ); - auto mesh = filter->GetOutputData< vtkPolyData >( output_name ); - _TViewer* viewer = NULL; - if( image != NULL ) + try { - int dim = image->GetDataDimension( ); - if( dim == 2 ) - viewer = - this->_configureViewer< cpExtensions::QT::ImageWidget >( - this->m_UI->Viewer - ); - else if( dim == 3 ) - viewer = - this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( - this->m_UI->Viewer - ); + auto ws = this->workspace( this->m_ActiveWS ); + auto filter = ws->GetFilter( filter_name ); + cpBaseQtApplication_Execute( filter->Update( ) ); + auto image = filter->GetOutputData< vtkImageData >( output_name ); + auto mesh = filter->GetOutputData< vtkPolyData >( output_name ); + _TViewer* viewer = NULL; + if( image != NULL ) + { + int dim = image->GetDataDimension( ); + if( dim == 2 ) + viewer = + this->_configureViewer< cpExtensions::QT::ImageWidget >( + this->m_UI->Viewer + ); + else if( dim == 3 ) + viewer = + this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( + this->m_UI->Viewer + ); + } + else if( mesh != NULL ) + { + // TODO + + } // fi + if( + dynamic_cast< QWidget* >( viewer ) != + dynamic_cast< QWidget* >( this->m_UI->Viewer ) + ) + { + delete this->m_UI->Viewer; + this->m_UI->Viewer = dynamic_cast< QWidget* >( viewer ); + this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer ); + this->setViewer( viewer ); + + } // fi + if( image != NULL ) + { + this->m_Blocker.block( ); + auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer ); + auto imv = dynamic_cast< cpExtensions::QT::ImageWidget* >( viewer ); + if( mpr != NULL ) + mpr->SetImage( image, name ); + else if( imv != NULL ) + imv->SetImage( image, name ); + this->m_Blocker.unblock( ); + } + else if( mesh != NULL ) + { + this->m_Blocker.block( ); + auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer ); + if( mpr != NULL ) + mpr->Add( mesh, name ); + this->m_Blocker.unblock( ); + + } // fi } - else if( mesh != NULL ) - viewer = - this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( - this->m_UI->Viewer - ); - if( ( QWidget* )( viewer ) != ( QWidget* )( this->m_UI->Viewer ) ) + catch( std::exception& err ) { - delete this->m_UI->Viewer; - this->m_UI->Viewer = viewer; - this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer ); - this->setViewer( viewer ); - - } // fi - } - catch( std::exception& err ) - { - QMessageBox::critical( - NULL, - QMessageBox::tr( "Error showing data" ), - QMessageBox::tr( err.what( ) ) - ); - - } // yrt - - /* TODO - try - { - if( filter != NULL ) - { - if( image != NULL ) - { - int dim = image->GetDataDimension( ); - if( dim == 2 ) - { - auto viewer = - this->_configureViewer< cpExtensions::QT::ImageWidget >( ); - this->m_Blocker.block( ); - viewer.first->SetImage( image, 2, name ); - viewer.first->ResetCamera( ); - viewer.first->Render( ); - this->m_Blocker.unblock( ); - } - else if( dim == 3 ) - { - auto viewer = - this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( ); - this->m_Blocker.block( ); - viewer.first->SetImage( image, name ); - viewer.first->ResetCameras( ); - viewer.first->Render( ); - this->m_Blocker.unblock( ); - - } // fi - } - else if( mesh != NULL ) - { - auto viewer = - dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( - this->m_UI->Viewer - ); - if( viewer != NULL ) - { - this->m_Blocker.block( ); - viewer->Add( mesh, name ); - viewer->Render( ); - this->m_Blocker.unblock( ); - - } // fi - - } // fi + QMessageBox::critical( + NULL, + QMessageBox::tr( "Error showing data" ), + QMessageBox::tr( err.what( ) ) + ); - } // fi - } - catch( std::exception& err ) - { - } // yrt - */ -} - -// ------------------------------------------------------------------------- -void PipelineEditor:: -_slotActorsProperties( ) -{ - /* TODO - auto data = - dynamic_cast< cpExtensions::QT::ActorsWidgetInterface* >( - this->m_UI->Viewer - ); - if( data != NULL ) - { - auto dlg = new cpExtensions::QT::ConfigurationChooser( this ); - dlg->setData( data ); - dlg->exec( ); + } // yrt - } // fi - */ + } // fi } // ------------------------------------------------------------------------- diff --git a/appli/PipelineEditor/PipelineEditor.h b/appli/PipelineEditor/PipelineEditor.h index eb2c333..3f4a68b 100644 --- a/appli/PipelineEditor/PipelineEditor.h +++ b/appli/PipelineEditor/PipelineEditor.h @@ -23,13 +23,8 @@ public: ); virtual ~PipelineEditor( ); -protected: - template< class _TWidget > - inline std::pair< _TWidget*, bool > _configureViewer( ); - protected slots: void _slotView( const std::string& name, bool show ); - void _slotActorsProperties( ); private: Ui::PipelineEditor* m_UI; diff --git a/lib/cpBaseQtApplication/MainWindow.cxx b/lib/cpBaseQtApplication/MainWindow.cxx index bfe8b5b..37b18aa 100644 --- a/lib/cpBaseQtApplication/MainWindow.cxx +++ b/lib/cpBaseQtApplication/MainWindow.cxx @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include @@ -223,6 +225,8 @@ _addWorkspace( const std::string& name ) if( this->m_SingleWorkspace ) this->m_Workspaces.clear( ); this->m_Workspaces[ name ] = TWorkspace::New( ); + if( this->m_Canvas != NULL ) + this->m_Canvas->setWorkspace( this->m_Workspaces[ name ] ); this->setWindowTitle( ( this->m_BaseWindowTitle + name ).c_str( ) ); } // fi @@ -388,4 +392,21 @@ _loadWorkspace( ) this->_loadWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) ); } +// ------------------------------------------------------------------------- +void cpBaseQtApplication::MainWindow:: +_actorsProperties( ) +{ + auto data = + dynamic_cast< cpExtensions::QT::ActorsWidgetInterface* >( + this->m_Viewer + ); + if( data != NULL ) + { + auto dlg = new cpExtensions::QT::ConfigurationChooser( this ); + dlg->setData( data ); + dlg->exec( ); + + } // fi +} + // eof - $RCSfile$ diff --git a/lib/cpBaseQtApplication/MainWindow.h b/lib/cpBaseQtApplication/MainWindow.h index b62d30f..53aebf2 100644 --- a/lib/cpBaseQtApplication/MainWindow.h +++ b/lib/cpBaseQtApplication/MainWindow.h @@ -74,19 +74,6 @@ namespace cpBaseQtApplication ); virtual ~MainWindow( ); - /* TODO - void updateEnvironment( ); - void updateFilter( const std::string& name ); - void showData( const std::string& name, const std::string& port ); - void showData( - cpPlugins::BaseObjects::DataObject* data, const std::string& name - ); - void hideData( const std::string& name, const std::string& port ); - void hideData( const std::string& name ); - void dataProperties( const std::string& name, const std::string& port ); - void dataProperties( const std::string& name ); - */ - TWorkspace* workspace( const std::string& wname ); const TWorkspace* workspace( const std::string& wname ) const; @@ -102,11 +89,15 @@ namespace cpBaseQtApplication const cpExtensions::QT::ActorsWidgetInterface* viewer( ) const; void setViewer( cpExtensions::QT::ActorsWidgetInterface* v ); - /* TODO - protected: - void _configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt ); - void _updatePlugins( ); - */ + protected: + template< class _TViewer > + _TViewer* _configureViewer( QWidget* w ) + { + _TViewer* v = dynamic_cast< _TViewer* >( w ); + if( v == NULL ) + v = new _TViewer( ); + return( v ); + } protected slots: void _loadPlugins( const std::string& filename ); @@ -126,38 +117,7 @@ namespace cpBaseQtApplication void _loadWorkspace( const std::string& fname ); void _loadWorkspace( ); - /* TODO - void _loadWorkspace( const std::string& filename ); - void _loadWorkspace( ); - void _saveWorkspace( const std::string& filename ); - void _saveWorkspace( ); - void _showPlugins( ); - void _addEnvironmentPaths( const std::string& envs ); - void _addEnvironmentPaths( ); - void _actorsProperties( ); - */ - - /* TODO - void _ClearWorkspace( ); - void _LoadPlugins( const std::string& filename ); - void _LoadPluginsFromPath( const std::string& path ); - - void _LoadWorkspace( const std::string& filename ); - void _SaveWorkspace( const std::string& filename ); - - void _BackgroundProperties( unsigned int i ); - void _DataProperties( const std::string& actor ); - - void _AddEnviromentPaths( ); - void _LoadPlugins( ); - void _LoadPluginsFromPath( ); - void _ShowPlugins( ); - void _LoadWorkspace( ); - void _SaveWorkspace( ); - void _DataProperties( - const std::string& filter_name, const std::string& output_name - ); - */ + void _actorsProperties( ); protected: Blocker m_Blocker; diff --git a/lib/cpBaseQtApplication/Pipeline/Canvas.cxx b/lib/cpBaseQtApplication/Pipeline/Canvas.cxx index 780e03d..8457187 100644 --- a/lib/cpBaseQtApplication/Pipeline/Canvas.cxx +++ b/lib/cpBaseQtApplication/Pipeline/Canvas.cxx @@ -68,9 +68,9 @@ setWorkspace( TWorkspace* ws ) { this->clear( ); this->m_Workspace = ws; - this->_redrawWorkspace( ); } // fi + this->_redrawWorkspace( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpExtensions/QT/ImageWidget.cxx b/lib/cpExtensions/QT/ImageWidget.cxx index 8a3d2c3..e55b69b 100644 --- a/lib/cpExtensions/QT/ImageWidget.cxx +++ b/lib/cpExtensions/QT/ImageWidget.cxx @@ -49,7 +49,7 @@ Clear( ) // ------------------------------------------------------------------------- void cpExtensions::QT::ImageWidget:: -SetImage( vtkImageData* image, int orientation, const std::string& name ) +SetImage( vtkImageData* image, const std::string& name, int orientation ) { if( name == "" ) return; diff --git a/lib/cpExtensions/QT/ImageWidget.h b/lib/cpExtensions/QT/ImageWidget.h index 6627610..897172d 100644 --- a/lib/cpExtensions/QT/ImageWidget.h +++ b/lib/cpExtensions/QT/ImageWidget.h @@ -45,7 +45,7 @@ namespace cpExtensions void Clear( ); void SetImage( - vtkImageData* image, int orientation, const std::string& name + vtkImageData* image, const std::string& name, int orientation = 2 ); void Add( vtkDataSet* data, const std::string& name ); virtual void ResetCamera( ) cpExtensions_OVERRIDE; diff --git a/lib/cpExtensions/QT/SimpleMPRWidget.cxx b/lib/cpExtensions/QT/SimpleMPRWidget.cxx index 543ae15..42dd1cd 100644 --- a/lib/cpExtensions/QT/SimpleMPRWidget.cxx +++ b/lib/cpExtensions/QT/SimpleMPRWidget.cxx @@ -164,9 +164,9 @@ SetImage( vtkImageData* image, const std::string& name ) if( this->m_MainImage != NULL && this->m_MainImageName != "" ) { - this->m_XImage->SetImage( this->m_MainImage, 0, name ); - this->m_YImage->SetImage( this->m_MainImage, 1, name ); - this->m_ZImage->SetImage( this->m_MainImage, 2, name ); + this->m_XImage->SetImage( this->m_MainImage, name, 0 ); + this->m_YImage->SetImage( this->m_MainImage, name, 1 ); + this->m_ZImage->SetImage( this->m_MainImage, name, 2 ); this->m_3DView->SetImage( this->m_MainImage, name ); } // fi