]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/MainWindow.h
...
[cpPlugins.git] / lib / cpBaseQtApplication / MainWindow.h
index 9e2b6072f1137ec501cf3c08b555cfc29fbaff02..b62d30f62fe388343bb95ef6018257cdc57f0073 100644 (file)
@@ -3,8 +3,10 @@
 
 #include <cpBaseQtApplication_Export.h>
 #include <QMainWindow>
+#include <QMessageBox>
 #include <cpPlugins/Interface/Plugins.h>
 #include <cpPlugins/Interface/Workspace.h>
+#include <cpBaseQtApplication/Blocker.h>
 
 // -------------------------------------------------------------------------
 #define cpBaseQtApplication_ConnectAction( _act_, _slt_ )               \
 // -------------------------------------------------------------------------
 #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,61 +64,78 @@ 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::Plugins   TPlugins;
+    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
-      );
-
     /* 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 );
     */
-    void dataProperties( const std::string& name, const std::string& port );
-    void dataProperties( const std::string& name );
 
-  protected:
-    void _block( );
-    void _unBlock( );
-    void _configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt );
-    void _updatePlugins( );
+    TWorkspace* workspace( const std::string& wname );
+    const TWorkspace* workspace( const std::string& wname ) const;
+
+    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 );
+
+    /* TODO
+       protected:
+       void _configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt );
+       void _updatePlugins( );
+    */
 
   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( );
-    void _actorsProperties( );
+
+    void _clearWorkspaces( );
+
+    virtual void _addWorkspace( const std::string& name );
+    void _addWorkspace( );
+
+    void _saveWorkspace( const std::string& wname, const std::string& fname );
+    void _saveWorkspace( const std::string& wname, bool force );
+    void _saveWorkspace( );
+
+    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( );
@@ -150,19 +160,18 @@ namespace cpBaseQtApplication
     */
 
   protected:
-    QApplication* m_Application;
-    _TBlocker     m_Blocker;
-
-    std::string         m_RunPath;
-    TPlugins::Pointer   m_Plugins;
-    TWorkspace::Pointer m_Workspace;
-
-    PluginsNavigator* m_Navigator;
-    Editor*           m_Editor;
-    TMPR*             m_MPR;
-
-    /* TODO
-    */
+    Blocker           m_Blocker;
+    std::string       m_RunPath;
+    TPlugins::Pointer m_Plugins;
+    std::string       m_LastSaveFileName;
+    std::map< std::string, TWorkspace::Pointer > m_Workspaces;
+
+    bool        m_SingleWorkspace;
+    std::string m_BaseWindowTitle;
+
+    Pipeline::Canvas*                        m_Canvas;
+    Plugins::Navigator*                      m_Navigator;
+    cpExtensions::QT::ActorsWidgetInterface* m_Viewer;
   };
 
 } // ecapseman