]> Creatis software - cpMesh.git/blob - appli/InteractiveDeformableMeshSegmentation/MainWnd.h
...
[cpMesh.git] / appli / InteractiveDeformableMeshSegmentation / MainWnd.h
1 #ifndef __MAINWND__H__
2 #define __MAINWND__H__
3
4 // Standard stuff
5 #include <map>
6 #include <string>
7
8 // Qt stuff
9 #include <QMainWindow>
10 #include <QWidget>
11
12 // vtk stuff
13 #include <vtkCommand.h>
14 #include <vtkOrientationMarkerWidget.h>
15 #include <vtkRenderer.h>
16 #include <vtkSmartPointer.h>
17
18 // Plugins interface
19 #include <cpPlugins/Interface/Interface.h>
20 #include <cpPlugins/Interface/ProcessObject.h>
21 #include <cpPlugins/Interface/Image.h>
22 #include <cpPlugins/Interface/DataObject.h>
23 #include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
24
25 // -------------------------------------------------------------------------
26 class MainWnd;
27
28 class DoubleClickCommand
29   : public vtkCommand
30 {
31 public:
32   typedef DoubleClickCommand Self;
33
34 public:
35   vtkTypeMacro( DoubleClickCommand, vtkCommand );
36
37 public:
38   static DoubleClickCommand* New( );
39
40   void SetMainWnd( MainWnd* wnd );
41   void Execute( vtkObject* caller, unsigned long eid, void* data );
42
43 protected:
44   DoubleClickCommand( );
45   virtual ~DoubleClickCommand( );
46
47 private:
48   // Purposely not implemented
49   DoubleClickCommand( const Self& );
50   Self& operator=( const Self& );
51
52 protected:
53   MainWnd* m_MainWnd;
54 };
55
56 // -------------------------------------------------------------------------
57 namespace Ui
58 {
59   class MainWnd;
60 }
61
62 // -------------------------------------------------------------------------
63 /**
64  */
65 class MainWnd
66   : public QMainWindow
67 {
68   Q_OBJECT;
69
70 public:
71   friend class DoubleClickCommand;
72
73   typedef MainWnd Self;
74
75   // Plugins types
76   typedef cpPlugins::Interface::Interface     TPluginsInterface;
77   typedef cpPlugins::Interface::Object        TPluginObject;
78   typedef cpPlugins::Interface::DataObject    TPluginData;
79   typedef cpPlugins::Interface::Image         TPluginImage;
80   typedef cpPlugins::Interface::ProcessObject TPlugin;
81   typedef cpPlugins::Interface::Parameters    TParameters;
82   typedef cpPlugins::Extensions::Visualization::MPRWithDifferentWindows TMPR;
83
84   typedef std::map< std::string, std::string > TStringMap;
85
86   enum PluginType
87   {
88     GlobalPluginType = 0,
89     DoubleClickPluginType,
90     SpherePluginType,
91     NonePluginType
92   };
93
94   enum PluginCategory
95   {
96     SegmentationPluginCategory = 0,
97     SegmentationFilteringPluginCategory,
98     MeshProcessingPluginCategory,
99     NonePluginCategory
100   };
101
102 public:
103   explicit MainWnd( QWidget* parent = 0 );
104   virtual ~MainWnd( );
105
106 protected:
107   void _LoadApplicationPreferences( );
108   bool _LoadPlugins( );
109   bool _CheckClassesInPlugins( const TStringMap& classes );
110   void _AddPluginActions(
111     const TStringMap& classes, QMenu* menu, const char* method
112     );
113   TPluginImage* _LoadImage(
114     const std::string& image_type, const std::string& image_dim
115     );
116   void _UpdateEnabledFlags( );
117
118   bool _ParametersDialog( const TParameters& parameters );
119   void _ExecuteDoubleClickPlugin( const double* pnt );
120
121   template< class P >
122   void _JoinSegmentations( );
123
124   /* TODO
125      template< class I >
126   */
127   /*
128     void _SliceMesh( int axis );
129     static void _SliceEventCallback(
130     vtkObject* caller,
131     long unsigned int eventId,
132     void* clientData, void* callData
133     );
134   */
135
136 private slots:
137   void _triggered_actionReloadPlugins( );
138   void _triggered_actionOpenInputImage( );
139   void _triggered_actionOpenSegmentedImage( );
140   void _triggered_actionSwitchMode( );
141   
142   void _triggered_actionSegmentImage( );
143   void _triggered_actionFilterSegmentation( );
144   void _triggered_actionProcessMesh( );
145
146   /* TODO
147      void triggered_aOpenSegmentedImage( );
148      void triggered_aFilterSegmentedImage( );
149      void triggered_aSegmentedImageToMesh( );
150      void triggered_aLoadInputImage( );
151      void triggered_aLoadSegmentedImage( );
152   */
153
154 private:
155   Ui::MainWnd* m_UI;
156
157   // Application preferences
158   std::string m_ApplicationPreferencesFile;
159   TStringMap m_ApplicationPreferences;
160
161   // Plugins objects
162   std::string       m_PluginsConfigurationFile;
163   TPluginsInterface m_Plugins;
164
165   // Needed object from plugins
166   TStringMap m_BaseClasses;
167   TStringMap m_SegmentationClasses;
168   TStringMap m_SegmentationFilterClasses;
169   TStringMap m_MeshFilterClasses;
170
171   // Historic objects
172   std::string m_LastOpenedFile;
173
174   // Real data
175   TPluginImage* m_InputImage;
176   TPluginImage* m_SegmentedImage;
177
178   // Visualization stuff
179   TMPR* m_MPR;
180
181   // Active plugin
182   TPlugin* m_ActivePlugin;
183   QWidget* m_ActiveParameters;
184   Self::PluginType m_ActivePluginType;
185   Self::PluginCategory m_ActivePluginCategory;
186
187   vtkSmartPointer< DoubleClickCommand > m_DoubleClickCommand;
188 };
189
190 #endif // __MAINWND__H__
191
192 // eof - $RCSfile$