X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpBaseQtApplication%2FMainWindow.h;h=2e967d9d526e8a1b60e6fa69e31e054b5ff2a927;hb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;hp=1f2f2c285deb00ae2a2c55c4d97a80f2db1bd1e3;hpb=3393941bf8f26babc7b592db434b40c1b747a687;p=cpPlugins.git diff --git a/lib/cpBaseQtApplication/MainWindow.h b/lib/cpBaseQtApplication/MainWindow.h index 1f2f2c2..2e967d9 100644 --- a/lib/cpBaseQtApplication/MainWindow.h +++ b/lib/cpBaseQtApplication/MainWindow.h @@ -3,8 +3,10 @@ #include #include -#include +#include +#include #include +#include // ------------------------------------------------------------------------- #define cpBaseQtApplication_ConnectAction( _act_, _slt_ ) \ @@ -15,50 +17,41 @@ // ------------------------------------------------------------------------- #define cpBaseQtApplication_Execute( _cmd_ ) \ { \ - this->_block( ); \ - try \ - { \ - _cmd_; \ - this->_unBlock( ); \ - } \ - catch( itk::ExceptionObject& err1 ) \ - { \ - this->_unBlock( ); \ - QMessageBox::critical( \ - this, \ - QMessageBox::tr( "Error executing filter" ), \ - QMessageBox::tr( err1.GetDescription( ) ) \ - ); \ - } \ - catch( std::exception& err2 ) \ - { \ - this->_unBlock( ); \ - QMessageBox::critical( \ - this, \ - QMessageBox::tr( "Error executing filter" ), \ - QMessageBox::tr( err2.what( ) ) \ - ); \ - } \ - catch( ... ) \ - { \ - this->_unBlock( ); \ - QMessageBox::critical( \ - this, \ - QMessageBox::tr( "Error executing filter" ), \ - QMessageBox::tr( "Unknown error" ) \ - ); \ - } \ - this->_unBlock( ); \ + this->m_Blocker.block( ); \ + try \ + { \ + _cmd_; \ + this->m_Blocker.unblock( ); \ + } \ + catch( std::exception& err ) \ + { \ + this->m_Blocker.unblock( ); \ + QMessageBox::critical( \ + this, \ + QMessageBox::tr( "Error executing filter" ), \ + QMessageBox::tr( err.what( ) ) \ + ); \ + } \ + catch( ... ) \ + { \ + this->m_Blocker.unblock( ); \ + QMessageBox::critical( \ + this, \ + QMessageBox::tr( "Error executing filter" ), \ + QMessageBox::tr( "Unknown error" ) \ + ); \ + } \ + this->m_Blocker.unblock( ); \ } // ------------------------------------------------------------------------- -namespace cpExtensions { namespace QT { class SimpleMPRWidget; } } +namespace cpExtensions { namespace QT { class ActorsWidgetInterface; } } // ------------------------------------------------------------------------- namespace cpBaseQtApplication { - class Editor; - class PluginsNavigator; + namespace Pipeline { class Canvas; } + namespace Plugins { class Navigator; } /** */ @@ -71,97 +64,69 @@ namespace cpBaseQtApplication typedef MainWindow Self; typedef QMainWindow Superclass; - typedef cpPlugins::Interface::Plugins TPlugins; - typedef cpPlugins::Interface::Workspace TWorkspace; - typedef cpExtensions::QT::SimpleMPRWidget TMPR; - - protected: - /** - */ - class _TBlocker - : public QObject - { - protected: - virtual bool eventFilter( QObject* obj, QEvent* event ) cpPlugins_OVERRIDE; - }; + typedef cpPlugins::Interface::Loader TLoader; + typedef cpPlugins::Interface::Workspace TWorkspace; public: explicit MainWindow( int argc, char* argv[], - QApplication* app, QWidget* parent = NULL ); virtual ~MainWindow( ); - 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 - ); + TWorkspace* workspace( ); + const TWorkspace* workspace( ) const; - /* TODO - 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 ); + Pipeline::Canvas* canvas( ); + const Pipeline::Canvas* canvas( ) const; + void setCanvas( Pipeline::Canvas* c ); + + Plugins::Navigator* navigator( ); + const Plugins::Navigator* navigator( ) const; + void setNavigator( Plugins::Navigator* n ); + + cpExtensions::QT::ActorsWidgetInterface* viewer( ); + const cpExtensions::QT::ActorsWidgetInterface* viewer( ) const; + void setViewer( cpExtensions::QT::ActorsWidgetInterface* v ); protected: - void _block( ); - void _unBlock( ); - void _configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt ); - void _updatePlugins( ); + template< class _TViewer > + _TViewer* _configureViewer( QWidget* w ) + { + _TViewer* v = dynamic_cast< _TViewer* >( w ); + if( v == NULL ) + v = new _TViewer( ); + return( v ); + } protected slots: - 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 _loadPlugins( const std::string& filename ); void _loadPlugins( ); void _loadPluginsFromPath( const std::string& path ); void _loadPluginsFromPath( ); - /* TODO - void _ClearWorkspace( ); - void _LoadPlugins( const std::string& filename ); - void _LoadPluginsFromPath( const std::string& path ); + void _clearWorkspace( ); - void _LoadWorkspace( const std::string& filename ); - void _SaveWorkspace( const std::string& filename ); + void _saveWorkspace( const std::string& fname ); + void _saveWorkspace( ); - void _BackgroundProperties( unsigned int i ); - void _DataProperties( const std::string& actor ); + void _loadWorkspace( const std::string& fname ); + void _loadWorkspace( ); - 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: - QApplication* m_Application; - _TBlocker m_Blocker; - + Blocker m_Blocker; std::string m_RunPath; - TPlugins::Pointer m_Plugins; + TLoader m_Loader; + std::string m_LastSaveFileName; TWorkspace::Pointer m_Workspace; - PluginsNavigator* m_Navigator; - Editor* m_Editor; - TMPR* m_MPR; + std::string m_BaseWindowTitle; - /* TODO - */ + Pipeline::Canvas* m_Canvas; + Plugins::Navigator* m_Navigator; + cpExtensions::QT::ActorsWidgetInterface* m_Viewer; }; } // ecapseman