]> Creatis software - cpPlugins.git/blob - lib/cpBaseQtApplication/MainWindow.h
...
[cpPlugins.git] / lib / cpBaseQtApplication / MainWindow.h
1 #ifndef __cpBaseQtApplication__MainWindow__h__
2 #define __cpBaseQtApplication__MainWindow__h__
3
4 #include <cpBaseQtApplication_Export.h>
5 #include <QMainWindow>
6 #include <QMessageBox>
7 #include <cpPlugins/Interface/Plugins.h>
8 #include <cpPlugins/Interface/Workspace.h>
9 #include <cpBaseQtApplication/Blocker.h>
10
11 // -------------------------------------------------------------------------
12 #define cpBaseQtApplication_ConnectAction( _act_, _slt_ )               \
13   this->connect(                                                        \
14     this->m_UI->_act_, SIGNAL( triggered( ) ), this, SLOT( _slt_( ) )   \
15     )
16
17 // -------------------------------------------------------------------------
18 #define cpBaseQtApplication_Execute( _cmd_ )            \
19   {                                                     \
20     this->m_Blocker.block( );                           \
21     try                                                 \
22     {                                                   \
23       _cmd_;                                            \
24       this->m_Blocker.unblock( );                       \
25     }                                                   \
26     catch( std::exception& err )                        \
27     {                                                   \
28       this->m_Blocker.unblock( );                       \
29       QMessageBox::critical(                            \
30         this,                                           \
31         QMessageBox::tr( "Error executing filter" ),    \
32         QMessageBox::tr( err.what( ) )                  \
33         );                                              \
34     }                                                   \
35     catch( ... )                                        \
36     {                                                   \
37       this->m_Blocker.unblock( );                       \
38       QMessageBox::critical(                            \
39         this,                                           \
40         QMessageBox::tr( "Error executing filter" ),    \
41         QMessageBox::tr( "Unknown error" )              \
42         );                                              \
43     }                                                   \
44     this->m_Blocker.unblock( );                         \
45   }
46
47 // -------------------------------------------------------------------------
48 namespace cpExtensions { namespace QT { class ActorsWidgetInterface; } }
49
50 // -------------------------------------------------------------------------
51 namespace cpBaseQtApplication
52 {
53   namespace Pipeline { class Canvas; }
54   namespace Plugins  { class Navigator; }
55
56   /**
57    */
58   class cpBaseQtApplication_EXPORT MainWindow
59     : public QMainWindow
60   {
61     Q_OBJECT;
62
63   public:
64     typedef MainWindow  Self;
65     typedef QMainWindow Superclass;
66
67     typedef cpPlugins::Interface::Plugins   TPlugins;
68     typedef cpPlugins::Interface::Workspace TWorkspace;
69
70   public:
71     explicit MainWindow(
72       int argc, char* argv[],
73       QWidget* parent = NULL
74       );
75     virtual ~MainWindow( );
76
77     /* TODO
78        void updateEnvironment( );
79        void updateFilter( const std::string& name );
80        void showData( const std::string& name, const std::string& port );
81        void showData(
82        cpPlugins::BaseObjects::DataObject* data, const std::string& name
83        );
84        void hideData( const std::string& name, const std::string& port );
85        void hideData( const std::string& name );
86        void dataProperties( const std::string& name, const std::string& port );
87        void dataProperties( const std::string& name );
88     */
89
90     TWorkspace* workspace( const std::string& wname );
91     const TWorkspace* workspace( const std::string& wname ) const;
92
93     Pipeline::Canvas* canvas( );
94     const Pipeline::Canvas* canvas( ) const;
95     void setCanvas( Pipeline::Canvas* c );
96
97     Plugins::Navigator* navigator( );
98     const Plugins::Navigator* navigator( ) const;
99     void setNavigator( Plugins::Navigator* n );
100
101     cpExtensions::QT::ActorsWidgetInterface* viewer( );
102     const cpExtensions::QT::ActorsWidgetInterface* viewer( ) const;
103     void setViewer( cpExtensions::QT::ActorsWidgetInterface* v );
104
105     /* TODO
106        protected:
107        void _configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt );
108        void _updatePlugins( );
109     */
110
111   protected slots:
112     void _loadPlugins( const std::string& filename );
113     void _loadPlugins( );
114     void _loadPluginsFromPath( const std::string& path );
115     void _loadPluginsFromPath( );
116
117     void _clearWorkspaces( );
118
119     virtual void _addWorkspace( const std::string& name );
120     void _addWorkspace( );
121
122     void _saveWorkspace( const std::string& wname, const std::string& fname );
123     void _saveWorkspace( const std::string& wname, bool force );
124     void _saveWorkspace( );
125
126     void _loadWorkspace( const std::string& fname );
127     void _loadWorkspace( );
128
129     /* TODO
130        void _loadWorkspace( const std::string& filename );
131        void _loadWorkspace( );
132        void _saveWorkspace( const std::string& filename );
133        void _saveWorkspace( );
134        void _showPlugins( );
135        void _addEnvironmentPaths( const std::string& envs );
136        void _addEnvironmentPaths( );
137        void _actorsProperties( );
138     */
139
140     /* TODO
141        void _ClearWorkspace( );
142        void _LoadPlugins( const std::string& filename );
143        void _LoadPluginsFromPath( const std::string& path );
144
145        void _LoadWorkspace( const std::string& filename );
146        void _SaveWorkspace( const std::string& filename );
147
148        void _BackgroundProperties( unsigned int i );
149        void _DataProperties( const std::string& actor );
150
151        void _AddEnviromentPaths( );
152        void _LoadPlugins( );
153        void _LoadPluginsFromPath( );
154        void _ShowPlugins( );
155        void _LoadWorkspace( );
156        void _SaveWorkspace( );
157        void _DataProperties(
158        const std::string& filter_name, const std::string& output_name
159        );
160     */
161
162   protected:
163     Blocker           m_Blocker;
164     std::string       m_RunPath;
165     TPlugins::Pointer m_Plugins;
166     std::string       m_LastSaveFileName;
167     std::map< std::string, TWorkspace::Pointer > m_Workspaces;
168
169     bool        m_SingleWorkspace;
170     std::string m_BaseWindowTitle;
171
172     Pipeline::Canvas*                        m_Canvas;
173     Plugins::Navigator*                      m_Navigator;
174     cpExtensions::QT::ActorsWidgetInterface* m_Viewer;
175   };
176
177 } // ecapseman
178
179 #endif // __cpBaseQtApplication__MainWindow__h__
180
181 // eof - $RCSfile$