]> Creatis software - cpMesh.git/blob - appli/InteractiveDeformableMeshSegmentation/MainWnd.h
Simple flood fill plugin added.
[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 TPlugin::TParameter                 TParameter;
82   typedef TPlugin::TParameters                TParameters;
83   typedef cpPlugins::Extensions::Visualization::MPRWithDifferentWindows TMPR;
84
85   typedef std::map< std::string, std::string > TStringMap;
86
87   enum PluginType
88   {
89     GlobalPluginType = 0,
90     DoubleClickPluginType,
91     SpherePluginType,
92     NonePluginType
93   };
94
95   enum PluginCategory
96   {
97     SegmentationPluginCategory = 0,
98     SegmentationFilteringPluginCategory,
99     MeshProcessingPluginCategory,
100     NonePluginCategory
101   };
102
103 public:
104   explicit MainWnd( QWidget* parent = 0 );
105   virtual ~MainWnd( );
106
107 protected:
108   void _LoadApplicationPreferences( );
109   bool _LoadPlugins( );
110   bool _CheckClassesInPlugins( const TStringMap& classes );
111   void _AddPluginActions(
112     const TStringMap& classes, QMenu* menu, const char* method
113     );
114   TPluginImage* _LoadImage(
115     const std::string& image_type, const std::string& image_dim
116     );
117   void _UpdateEnabledFlags( );
118
119   bool _ParametersDialog( const TParameters& parameters );
120   void _ExecuteDoubleClickPlugin( const double* pnt );
121
122   template< class P >
123   void _JoinSegmentations( );
124
125   /* TODO
126      template< class I >
127   */
128   /*
129     void _SliceMesh( int axis );
130     static void _SliceEventCallback(
131     vtkObject* caller,
132     long unsigned int eventId,
133     void* clientData, void* callData
134     );
135   */
136
137 private slots:
138   void _triggered_actionReloadPlugins( );
139   void _triggered_actionOpenInputImage( );
140   void _triggered_actionOpenSegmentedImage( );
141   void _triggered_actionSwitchMode( );
142   
143   void _triggered_actionSegmentImage( );
144   void _triggered_actionFilterSegmentation( );
145   void _triggered_actionProcessMesh( );
146
147   /* TODO
148      void triggered_aOpenSegmentedImage( );
149      void triggered_aFilterSegmentedImage( );
150      void triggered_aSegmentedImageToMesh( );
151      void triggered_aLoadInputImage( );
152      void triggered_aLoadSegmentedImage( );
153   */
154
155 private:
156   Ui::MainWnd* m_UI;
157
158   // Application preferences
159   std::string m_ApplicationPreferencesFile;
160   TStringMap m_ApplicationPreferences;
161
162   // Plugins objects
163   std::string       m_PluginsConfigurationFile;
164   TPluginsInterface m_Plugins;
165
166   // Needed object from plugins
167   TStringMap m_BaseClasses;
168   TStringMap m_SegmentationClasses;
169   TStringMap m_SegmentationFilterClasses;
170   TStringMap m_MeshFilterClasses;
171
172   // Historic objects
173   std::string m_LastOpenedFile;
174
175   // Real data
176   TPluginImage* m_InputImage;
177   TPluginImage* m_SegmentedImage;
178
179   // Visualization stuff
180   TMPR* m_MPR;
181
182   // Active plugin
183   TPlugin* m_ActivePlugin;
184   QWidget* m_ActiveParameters;
185   Self::PluginType m_ActivePluginType;
186   Self::PluginCategory m_ActivePluginCategory;
187
188   vtkSmartPointer< DoubleClickCommand > m_DoubleClickCommand;
189 };
190
191 #endif // __MAINWND__H__
192
193 // eof - $RCSfile$