]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/MainWindow.h
...
[cpPlugins.git] / lib / cpBaseQtApplication / MainWindow.h
index 6a7190ea653bc1b73fffa03f0c9bf3945b9b1a3e..9e2b6072f1137ec501cf3c08b555cfc29fbaff02 100644 (file)
@@ -1,23 +1,64 @@
-#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 <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/Interface/Workspace.h>
+
+// -------------------------------------------------------------------------
+#define cpBaseQtApplication_ConnectAction( _act_, _slt_ )               \
+  this->connect(                                                        \
+    this->m_UI->_act_, SIGNAL( triggered( ) ), this, SLOT( _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( );                                    \
   }
-}
-class QTreeWidget;
 
+// -------------------------------------------------------------------------
+namespace cpExtensions { namespace QT { class SimpleMPRWidget; } }
+
+// -------------------------------------------------------------------------
 namespace cpBaseQtApplication
 {
   class Editor;
+  class PluginsNavigator;
 
   /**
    */
@@ -30,6 +71,10 @@ namespace cpBaseQtApplication
     typedef MainWindow  Self;
     typedef QMainWindow Superclass;
 
+    typedef cpPlugins::Interface::Plugins     TPlugins;
+    typedef cpPlugins::Interface::Workspace   TWorkspace;
+    typedef cpExtensions::QT::SimpleMPRWidget TMPR;
+
   protected:
     /**
      */
@@ -37,7 +82,7 @@ namespace cpBaseQtApplication
       : public QObject
     {
     protected:
-      virtual bool eventFilter( QObject* obj, QEvent* event ) ITK_OVERRIDE;
+      virtual bool eventFilter( QObject* obj, QEvent* event ) cpPlugins_OVERRIDE;
     };
 
   public:
@@ -48,61 +93,80 @@ namespace cpBaseQtApplication
       );
     virtual ~MainWindow( );
 
-    void UpdateEnvironment( );
-
-  protected:
-    void _Configure(
-      QTreeWidget* tree,
-      cpExtensions::QT::SimpleMPRWidget* mpr,
-      cpBaseQtApplication::Editor* editor
+    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 _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( );
 
-    void _LoadWorkspace( const std::string& filename );
-    void _SaveWorkspace( const std::string& filename );
+    /* 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 );
 
-    void _BackgroundProperties( unsigned int i );
+  protected:
+    void _block( );
+    void _unBlock( );
+    void _configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt );
+    void _updatePlugins( );
 
   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 _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( );
+
+    /* 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
+       );
+    */
 
   protected:
     QApplication* m_Application;
     _TBlocker     m_Blocker;
-    std::string   m_PluginsPath;
 
-    std::string m_RunPath;
-    cpPlugins::Interface m_Interface;
-    cpPlugins::Workspace m_Workspace;
+    std::string         m_RunPath;
+    TPlugins::Pointer   m_Plugins;
+    TWorkspace::Pointer m_Workspace;
+
+    PluginsNavigator* m_Navigator;
+    Editor*           m_Editor;
+    TMPR*             m_MPR;
 
-    QTreeWidget* m_TreeWidget;
-    Editor*      m_Editor;
-    cpExtensions::QT::SimpleMPRWidget* m_MPR;
+    /* TODO
+    */
   };
 
 } // ecapseman
 
-#endif // __CPBASEQTAPPLICATION__MAINWINDOW__H__
+#endif // __cpBaseQtApplication__MainWindow__h__
 
 // eof - $RCSfile$