X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPipelineEditor%2FBaseQtMainWindow.cxx;h=b600c0ee12002dc33e7c09d49fec0a8cc5bf2ec7;hb=e2fb8817731f6231d34941a208e46b36dad425b2;hp=24953f02e7270e92ebb0445859b2f49626719209;hpb=25bbcded53b31313762477b2f8dde29b5a845a34;p=cpPlugins.git diff --git a/lib/cpPipelineEditor/BaseQtMainWindow.cxx b/lib/cpPipelineEditor/BaseQtMainWindow.cxx index 24953f0..b600c0e 100644 --- a/lib/cpPipelineEditor/BaseQtMainWindow.cxx +++ b/lib/cpPipelineEditor/BaseQtMainWindow.cxx @@ -1,6 +1,4 @@ -#include - -#ifdef cpPlugins_QT4 +#include #include #include @@ -12,7 +10,7 @@ #include // ------------------------------------------------------------------------- -bool cpPlugins::BaseQtMainWindow::_TBlocker:: +bool cpPipelineEditor::BaseQtMainWindow::_TBlocker:: eventFilter( QObject* obj, QEvent* event ) { return( true ); // -> Block all events @@ -33,7 +31,7 @@ eventFilter( QObject* obj, QEvent* event ) } // ------------------------------------------------------------------------- -cpPlugins::BaseQtMainWindow:: +cpPipelineEditor::BaseQtMainWindow:: BaseQtMainWindow( int argc, char* argv[], QApplication* app, @@ -45,36 +43,30 @@ BaseQtMainWindow( m_TreeWidget( NULL ), m_Editor( NULL ) { - // Prepare plugins interface + this->m_Interface.GuessAccesiblePlugins( ); + QFileInfo info( argv[ 0 ] ); if( info.exists( ) ) { - this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE ); - this->_LoadPluginsFromPath( this->m_PluginsPath ); - this->m_PluginsPath = info.canonicalPath( ).toStdString( ); - - } // fi - QDir exec_dir( "." ); - if( exec_dir.exists( ) ) - { - this->_LoadPluginsFromPath( exec_dir.canonicalPath( ).toStdString( ) ); - this->m_PluginsPath = exec_dir.canonicalPath( ).toStdString( ); + auto exec_dir = info.canonicalPath( ).toStdString( ); + this->_LoadPluginsFromPath( exec_dir ); } // fi + this->_UpdateLoadedPlugins( ); // Prepare workspace this->m_Workspace.SetInterface( &( this->m_Interface ) ); } // ------------------------------------------------------------------------- -cpPlugins::BaseQtMainWindow:: +cpPipelineEditor::BaseQtMainWindow:: ~BaseQtMainWindow( ) { this->m_Interface.UnloadAll( ); } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _Configure( QTreeWidget* tree, cpExtensions::QT::SimpleMPRWidget* mpr, @@ -92,7 +84,7 @@ _Configure( } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _LoadPlugins( const std::string& filename ) { try @@ -112,7 +104,7 @@ _LoadPlugins( const std::string& filename ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _LoadPluginsFromPath( const std::string& path ) { try @@ -132,7 +124,7 @@ _LoadPluginsFromPath( const std::string& path ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _UpdateLoadedPlugins( ) { this->_Block( ); @@ -199,7 +191,7 @@ _UpdateLoadedPlugins( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _Block( ) { this->m_Application->setOverrideCursor( Qt::WaitCursor ); @@ -207,7 +199,7 @@ _Block( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _UnBlock( ) { while( this->m_Application->overrideCursor( ) ) @@ -216,7 +208,7 @@ _UnBlock( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _LoadWorkspace( const std::string& filename ) { std::string err = this->m_Workspace.LoadWorkspace( filename ); @@ -237,7 +229,7 @@ _LoadWorkspace( const std::string& filename ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _SaveWorkspace( const std::string& filename ) { std::string err = this->m_Workspace.SaveWorkspace( filename ); @@ -250,7 +242,7 @@ _SaveWorkspace( const std::string& filename ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _InteractiveLoadPlugins( ) { QFileDialog dlg( this ); @@ -272,7 +264,7 @@ _InteractiveLoadPlugins( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _InteractiveLoadPluginsFromPath( ) { QFileDialog dlg( this ); @@ -284,7 +276,7 @@ _InteractiveLoadPluginsFromPath( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _InteractiveLoadWorkspace( ) { QFileDialog dlg( this ); @@ -300,7 +292,7 @@ _InteractiveLoadWorkspace( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _InteractiveSaveWorkspace( ) { QFileDialog dlg( this ); @@ -317,20 +309,43 @@ _InteractiveSaveWorkspace( ) } // ------------------------------------------------------------------------- -void cpPlugins::BaseQtMainWindow:: +void cpPipelineEditor::BaseQtMainWindow:: _ExecFilter( const std::string& filter_name ) { this->_Block( ); - std::string err = this->m_Workspace.Execute( filter_name ); - this->_UnBlock( ); - if( err != "" ) + try + { + this->m_Workspace.Execute( filter_name ); + this->_UnBlock( ); + } + catch( itk::ExceptionObject& err1 ) + { + this->_UnBlock( ); QMessageBox::critical( this, QMessageBox::tr( "Error executing filter" ), - QMessageBox::tr( err.c_str( ) ) + 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" ) ); -} -#endif // cpPlugins_QT4 + } // yrt +} // eof - $RCSfile$