]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/MainWindow.h
Cast image filter added. ROI filter modified.
[cpPlugins.git] / lib / cpBaseQtApplication / MainWindow.h
index 6a7190ea653bc1b73fffa03f0c9bf3945b9b1a3e..a29ad0fcb194c0311c8502d6e2e89893518a1e7b 100644 (file)
@@ -1,23 +1,57 @@
-#ifndef __CPBASEQTAPPLICATION__MAINWINDOW__H__
-#define __CPBASEQTAPPLICATION__MAINWINDOW__H__
+#ifndef __cpBaseQtApplication__MainWindow__h__
+#define __cpBaseQtApplication__MainWindow__h__
 
 #include <cpBaseQtApplication_Export.h>
 #include <QMainWindow>
-#include <cpPlugins/Interface.h>
-#include <cpPlugins/Workspace.h>
-
-namespace cpExtensions
-{
-  namespace QT
-  {
-    class SimpleMPRWidget;
+#include <QMessageBox>
+#include <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/Interface/Workspace.h>
+#include <cpBaseQtApplication/Blocker.h>
+
+// -------------------------------------------------------------------------
+#define cpBaseQtApplication_ConnectAction( _act_, _slt_ )               \
+  this->connect(                                                        \
+    this->m_UI->_act_, SIGNAL( triggered( ) ), this, SLOT( _slt_( ) )   \
+    )
+
+// -------------------------------------------------------------------------
+#define cpBaseQtApplication_Execute( _cmd_ )            \
+  {                                                     \
+    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( );                         \
   }
-}
-class QTreeWidget;
 
+// -------------------------------------------------------------------------
+namespace cpExtensions { namespace QT { class ActorsWidgetInterface; } }
+
+// -------------------------------------------------------------------------
 namespace cpBaseQtApplication
 {
-  class Editor;
+  namespace Pipeline { class Canvas; }
+  namespace Plugins  { class Navigator; }
 
   /**
    */
@@ -30,79 +64,73 @@ namespace cpBaseQtApplication
     typedef MainWindow  Self;
     typedef QMainWindow Superclass;
 
-  protected:
-    /**
-     */
-    class _TBlocker
-      : public QObject
-    {
-    protected:
-      virtual bool eventFilter( QObject* obj, QEvent* event ) ITK_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( );
+    TWorkspace* workspace( );
+    const TWorkspace* workspace( ) const;
 
-  protected:
-    void _Configure(
-      QTreeWidget* tree,
-      cpExtensions::QT::SimpleMPRWidget* mpr,
-      cpBaseQtApplication::Editor* editor
-      );
-    void _ClearWorkspace( );
-    void _AddEnvironments( const std::string& environments );
-    void _LoadPlugins( const std::string& filename );
-    void _LoadPluginsFromPath( const std::string& path );
-    void _UpdateLoadedPlugins( );
-    void _Block( );
-    void _UnBlock( );
+    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 );
 
-    void _LoadWorkspace( const std::string& filename );
-    void _SaveWorkspace( const std::string& filename );
+    cpExtensions::QT::ActorsWidgetInterface* viewer( );
+    const cpExtensions::QT::ActorsWidgetInterface* viewer( ) const;
+    void setViewer( cpExtensions::QT::ActorsWidgetInterface* v );
 
-    void _BackgroundProperties( unsigned int i );
+  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 _InteractiveLoadPlugins( );
-    void _InteractiveLoadPluginsFromPath( );
-    void _ShowPlugins( );
-    void _InteractiveLoadWorkspace( );
-    void _InteractiveSaveWorkspace( );
-    void _InteractiveAddEnviromentPaths( );
-    void _ExecFilter( const std::string& filter_name );
-    void _ShowData(
-      const std::string& filter_name, const std::string& output_name
-      );
-    void _HideData(
-      const std::string& filter_name, const std::string& output_name
-      );
-    void _DataProperties(
-      const std::string& filter_name, const std::string& output_name
-      );
+    void _loadPlugins( const std::string& filename );
+    void _loadPlugins( );
+    void _loadPluginsFromPath( const std::string& path );
+    void _loadPluginsFromPath( );
+
+    void _clearWorkspace( );
+
+    void _saveWorkspace( const std::string& fname );
+    void _saveWorkspace( );
+
+    void _loadWorkspace( const std::string& fname );
+    void _loadWorkspace( );
+
+    void _actorsProperties( );
 
   protected:
-    QApplication* m_Application;
-    _TBlocker     m_Blocker;
-    std::string   m_PluginsPath;
+    Blocker             m_Blocker;
+    std::string         m_RunPath;
+    TPlugins::Pointer   m_Plugins;
+    std::string         m_LastSaveFileName;
+    TWorkspace::Pointer m_Workspace;
 
-    std::string m_RunPath;
-    cpPlugins::Interface m_Interface;
-    cpPlugins::Workspace m_Workspace;
+    std::string m_BaseWindowTitle;
 
-    QTreeWidget* m_TreeWidget;
-    Editor*      m_Editor;
-    cpExtensions::QT::SimpleMPRWidget* m_MPR;
+    Pipeline::Canvas*                        m_Canvas;
+    Plugins::Navigator*                      m_Navigator;
+    cpExtensions::QT::ActorsWidgetInterface* m_Viewer;
   };
 
 } // ecapseman
 
-#endif // __CPBASEQTAPPLICATION__MAINWINDOW__H__
+#endif // __cpBaseQtApplication__MainWindow__h__
 
 // eof - $RCSfile$