]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourEventHandler.h
61b122a1363484cdb96dc65acd01951d2c31f2b3
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourEventHandler.h
1 #ifndef __wxContourEventHandler_h_INCLUDED_H__
2 #define __wxContourEventHandler_h_INCLUDED_H__
3
4
5 // -----------------------------------------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // -----------------------------------------------------------------------------------------------------------
9
10 #include <wx/wxprec.h>
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14 #ifndef WX_PRECOMP
15 #include <wx/wx.h>
16 #endif
17
18 #include <wx/grid.h>
19
20 //------------------------------------------------------------------------------------------------------------
21 // Includes
22 //------------------------------------------------------------------------------------------------------------
23 #include "OutlineModelManager.h"
24 #include "ContourWorkspace.h"
25 #include "wxContourViewPanel.h"
26 #include "wxInstantChooserPanel.h"
27 #include "wxContour_ButtonsBar.h"
28 #include "wxContour_Grid.h"
29 #include "wxContour_DrawToolsPanel.h"
30 #include "wxContour_OperationsToolsPanel.h"
31 #include "wxContour_AutomaticFormsToolsPanel.h"
32 #include "wxContour_StandardToolsPanel.h"
33 #include "wxContour_EdtionToolsPanel.h"
34 #include "wxContour_ListViewPanel.h"
35 #include "wxContour_ActionCommandsID.h"
36 #include "PerformingOperation.h"
37
38 #include "ContourThing.h"
39 #include "AxeThing.h"
40 #include "ImageSourceThing.h"
41 #include "ImageSectionThing.h"
42 #include "InstantMembersNameList.h"
43 #include "OutlineGroup.h"
44 #include "SomeEnvironment.h"
45 #include "ContourWorkspace.h"
46 #include "ContourWrap_ViewControl.h"
47 #include "Instant.h"
48
49 #include "wxVtkBaseView_SceneManager.h"
50
51
52 #include "Contour/ContourPropagation.h"
53 #include "mBarRange.h"
54
55
56 /** file wxContourEventHandler.h */
57
58
59
60 class  PanelBullEyeOptions : public wxPanel {
61 public:
62         PanelBullEyeOptions(wxWindow* parent, wxSize size);
63         ~PanelBullEyeOptions ();
64         void onRefreshPanel( wxCommandEvent& event );
65         int GetNumberOfCrowns();
66         int GetNumberOfSections(int nCrown);
67         int GetRadioOfCrown(int nCrown);
68         double GetAngOfCrownSection(int nCrown,int section);
69         double GetAngDeltaOfCrownSection(int nCrown);
70 protected:
71
72 private:
73         int                                                     _maxLevels;
74         int                                                     _maxSections;
75         wxRadioBox                                      *_radioboxBullEyeGenOpt;
76         wxSpinCtrl                                      *_spinctrlBullEyeNumOfCrowns;
77         wxSpinCtrl                                      *_spinctrlBullEyeNumOfSec;
78         wxSlider                                        *_sliderBullEyeAngle;
79         std::vector<wxSpinCtrl *>       _lstBullEyeDetailNumOfSec;
80         std::vector<wxSlider *>         _lstBullEyeDetailRadio;
81         std::vector<wxSlider *>         _lstBullEyeDetailAngle;
82
83
84         
85
86         void RefreshPanel();
87 };
88
89
90
91
92 //------------------------------------------------------------------------------------------------------------
93 // Class definition
94 //------------------------------------------------------------------------------------------------------------
95 class wxContourEventHandler : public wxEvtHandler {
96
97         public:
98
99         //------------------------------------------------------------------------------------------------------------
100         // Constructors & Destructors
101         //------------------------------------------------------------------------------------------------------------
102         wxContourEventHandler();
103         ~wxContourEventHandler();
104
105         //------------------------------------------------------------------------------------------------------------
106         // Configuration methods
107         //------------------------------------------------------------------------------------------------------------
108         bool configureEventsHandling();
109         
110         //------------------------------------------------------------------------------------------------------------
111         // Methods for capturing events
112         //------------------------------------------------------------------------------------------------------------
113         void onProcessMessage( wxCommandEvent& event );
114         void onActionButtonPressed( wxCommandEvent& event );
115         void onChangedDeep ( wxCommandEvent& event );
116         void onChangeInstant( wxCommandEvent& event );
117         void onCreateMultipleROI( wxCommandEvent& event );
118         void onSelectMultipleROI( wxCommandEvent& event );
119         void onCreateROI( wxCommandEvent& event );
120         void onStopCreateROI( wxCommandEvent& event );
121         void onDeleterROI( wxCommandEvent& event );
122         void onSelectROI( wxCommandEvent& event );
123         void onUnSelectROI( wxCommandEvent& event );
124         void onManualHidedROI( wxCommandEvent& event );
125         void onManualShowedROI( wxCommandEvent& event );
126         void onEditingROI( wxCommandEvent& event );
127         void onMovingROI( wxCommandEvent& event );
128
129         //------------------------------------------------------------------------------------------------------------
130         //  Model management methods
131         //------------------------------------------------------------------------------------------------------------
132
133         void createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append = false );
134         void createContour( int typeContour=1 );
135         void deleteContour( std::string theKeyName );
136         void deleteContours( std::vector<std::string> & keyNamesVector );       
137         void deleteAllContours(  );     
138         void openContours( FILE *pFile, bool staticContour );
139         void openFileWithContours();
140         void saveFileWithContours();
141         void saveFileWithContours( std::string filename );
142         void saveFileWithContoursAutomatique();
143         void onSpread( );
144         void onSpreadInDepth( std::vector<std::string> & keyNamesVector );
145         void onAutomatiqueSegmentation( );
146         void onOutline_Union_Of( std::vector<std::string> & keyNamesVector );
147         void onOutline_Intersection_Of( std::vector<std::string> & keyNamesVector );
148         void onOutline_Combination_Of( std::vector<std::string> & keyNamesVector );
149         void onOutline_Fragmentation_Of( std::vector<std::string> & keyNamesVector );
150         void onOutline_Agrupation_Of( std::vector<std::string> & keyNamesVector );
151         void onCopyOutlines( std::vector<std::string> & keyNamesVector );
152         void onPasteOutlines(  );
153         void onShowOutlines( std::vector<std::string> & keyNamesVector );
154         void onHideOutlines( std::vector<std::string> & keyNamesVector );
155         void onSelectOutlines( std::vector<std::string> & keyNamesVector );
156         void onEditOutlines( std::vector<std::string> & keyNamesVector );
157         void onREDO();
158         void onUNDO();
159         void changeContourOfManager(std::string keyName, Instant *instant);
160         void changeContoursOfManager(std::vector<std::string> & keyNamesVector);
161
162         
163         //------------------------------------------------------------------------------------------------------------
164         //  Attributes getters and setters
165         //------------------------------------------------------------------------------------------------------------
166         void setModelManager( OutlineModelManager * theModelManager );
167         void setViewPanel(  wxContourViewPanel * theViewPanel );
168         void setInstantChooserPanel(  wxInstantChooserPanel * theInstantChooserPanel );
169         void setButtonsBar(  wxContour_ButtonsBar * theButtonsBar );
170         void setGrid(  wxContour_Grid * theGridPanel );
171         void setDrawToolsPanel(  wxContour_DrawToolsPanel * theDrawToolsPanel );
172         void setOperationsToolsPanel(  wxContour_OperationsToolsPanel * theDrawToolsPanel );
173         void setAutomaticFormsPanel(  wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel );
174         void setStandardToolsPanel(  wxContour_StandardToolsPanel * theStandardToolsPanel );
175         void setEditionToolsPanel(  wxContour_EdtionToolsPanel * theEditionToolsPanel );
176         void setListViewPanel(  wxContour_ListViewPanel * theListViewPanel );
177
178         //------------------------------------------------------------------------------------------------------------
179         //  Other functional methods
180         //------------------------------------------------------------------------------------------------------------
181         void executeActionCommand( const char  toolCommand );
182
183         //------------------------------------------------------------------------------------------------------------
184         //  Getting information methods
185         //------------------------------------------------------------------------------------------------------------
186
187         //------------------------------------------------------------------------------------------------------------
188         //  Responding Spread Tools 
189         //------------------------------------------------------------------------------------------------------------
190         void onSpreadReset( wxCommandEvent& event );
191         void onSpreadAdd( wxCommandEvent& event );
192         void onSpreadGo( wxCommandEvent& event );
193         
194         void onSegmentationAllSlice( wxCommandEvent& event );
195         void onSegmentationOneSlice( wxCommandEvent& event );
196         void SegmentationOneSlice( int x, int y, int z );
197
198
199         void onTest( wxCommandEvent& event );
200         void onTestReset( wxCommandEvent& event );
201         void onTestAdd( wxCommandEvent& event );
202         void onTestGo( wxCommandEvent& event );
203
204
205         void onCreateContourSpline( wxCommandEvent& event );
206         void onCreateContourRectangle( wxCommandEvent& event );
207         void onCreateContourCircle( wxCommandEvent& event );
208         void onCreateContourBullEye( wxCommandEvent& event );
209         void onCreateContourFrame( );
210         void onDeleteFrame( );
211         void onDeleteContour( wxCommandEvent& event );
212         void onDeleteContoursActSlice( wxCommandEvent& event );
213         void onDeleteAllContours( wxCommandEvent& event );
214         void onInformationContourFrame();
215         void onInformationContourLabels( wxCommandEvent& event );
216         void onExtractInformation( wxCommandEvent& event );
217         void onSaveResults( wxCommandEvent& event );
218         void onInterfaceConfigurationFrame();
219         void onWidthOfContour(wxScrollEvent& event);
220         void onBrigthnessColorWindowLevel(wxScrollEvent& event);
221         void OnInterpolation(wxCommandEvent& event);
222
223         void onInterfaceTestFrame();
224
225         void SaveValuesXYZ(std::string directory,std::string namefile);
226         void SaveImageResult(std::string directory,std::string namefile);
227
228 /**
229 **      JCP 13-10-08 This methods group the diferent kind of panels
230 **/
231         wxPanel* getInformationPanel(wxWindow* parent);
232         wxPanel* getConfigurationPanel(wxWindow* parent);
233         wxPanel* getSegmentationPanel(wxWindow* parent);
234         wxPanel* getSegmentationPanelITK(wxWindow* parent);
235         wxPanel* getSpreadPanel(wxWindow* parent);
236         void onSegmentationAllSliceITK( wxCommandEvent& event );
237         void onSegmentationOneSliceITK( wxCommandEvent& event );
238         void onSnakePressed(wxWindow* parent);
239
240         void showAxis(bool show);
241 //JCP 13-10-09 Fill grid as public
242         void FillGridWithContoursInformation();
243 //JCP 13-10-09
244 //JCP 16-10-09
245         void createContourBullsEye(PanelBullEyeOptions* panel );
246
247         //void getValuesXYZ(std::vector<double *>* vectx, std::vector<double*>* vecty, std::vector<double*>* vectz, std::vector<int>* size);
248 //JCP 22-10-09
249         /**
250         **      This method gets the information of the contours in each slice
251         **/
252         void getValuesXYZ(double ** vectx, double ** vecty, double ** vectz, std::vector<int>* size);
253         /**
254         **      This method gets the mask and value images generated by the contours
255         **/
256         void getMaskValue(vtkImageData* mask, vtkImageData* value);
257         /**This Method checks for the information panel, it initalizes all the values 
258         ** in the controls so they can be retreived
259         **/
260         void checkInformationPanel();
261 //JCP 22-10-09
262
263 //JCP 16-10-09
264
265
266 private:
267         //------------------------------------------------------------------------------------------------------------
268         //  Private methods
269         //------------------------------------------------------------------------------------------------------------
270         void updateInstantOutlines();
271         void updateInstantImageData();
272         void updateInstantAxes();
273         void changeInstant();
274         void RefreshInterface();
275
276         // EED
277 //JCP 13-10-09 must be a public method
278         //void FillGridWithContoursInformation();
279 //JCP 13-10-09
280         manualContourModel * factoryManualContourModel(int typeContour);
281         manualContourModel * factoryManualContourModel(PanelBullEyeOptions* panel);
282         std::vector<manualContourModel*> ExploseEachModel( std::vector<manualContourModel*> lstManConMod );
283
284         //------------------------------------------------------------------------------------------------------------
285         // Attributtes
286         //------------------------------------------------------------------------------------------------------------
287
288         wxContourViewPanel                                      * _theViewPanel;
289         OutlineModelManager                                     * _modelManager;
290         ContourWorkspace                                        * _workSpace;
291         wxInstantChooserPanel                           * _instantPanel;
292         wxContour_ButtonsBar                            * _buttonsBar;
293
294         wxVtkBaseView_SceneManager                      * _sceneManager;
295         
296         Instant                                                         * _actualInstant;
297         wxContour_Grid                                          * _gridPanel;
298         wxContour_DrawToolsPanel                        * _drawToolsPanel;
299         wxContour_OperationsToolsPanel          * _operationsToolsPanel;
300         wxContour_AutomaticFormsToolsPanel      * _autoFormsPanel; 
301         wxContour_StandardToolsPanel            * _standardToolsPanel;
302         wxContour_EdtionToolsPanel                      * _editionToolsPanel;
303         wxContour_ListViewPanel                         * _listViewPanel;
304
305         /*DECLARE_CLASS(wxContourMainFrame)
306         // any class wishing to process wxWindows events must use this macro
307         DECLARE_EVENT_TABLE()*/
308         bool                                                            _creatingContoursActive;
309         PerformingOperation                                     * _performingOperation;
310
311         // Interface EED
312         wxFrame                                                         *_spreadFrame;
313         wxFrame                                                         *_segmentationFrame;
314         wxFrame                                                         *_createContourFrame;
315         wxFrame                                                         *_deleteFrame;
316         wxFrame                                                         *_InformationContourFrame;
317         wxFrame                                                         *_interfaceConfigurationFrame;
318         wxFrame                                                         *_TestFrame;
319         wxTextCtrl                                                      * _wxtextctrlTest;
320
321         std::string                                                     fileNameContourROI; 
322
323         wxRadioBox                                                      *methodRadiobox;
324         ContourPropagation                                      *_contourPropagation;
325         wxSlider                                                        *_isovalue;
326         wxSlider                                                        *_sampling;
327         wxStaticText                                            *_staticTextSegmentation;
328         mBarRange                                                       *_mbarrange;
329         wxTextCtrl                                                      *_wxtextctrlSpread;
330         wxRadioBox                                                      *_informationRadiobox;
331         wxListCtrl                                                      *_wxlistctrl;
332         wxGrid                                                          *_grid; 
333         wxStaticText                                            *_staticTextInformation;
334         mBarRange                                                       *_mbarrangeSliceInformation;
335         mBarRange                                                       *_mbarrangeRangeInformation;
336         wxSlider                                                        *_withOfContourLine; 
337         wxSlider                                                        *_brithtnessWindowLevel;
338         wxSlider                                                        *_brithtnessColorLevel;
339         mBarRange                                                       *_mbarrangeDeleteAll;
340         wxCheckBox                                                      *_interpolationCheckBox;
341         wxRadioBox                                                      *_spreadMethodRadiobox;
342         wxRadioBox                                                      *_radiolstboxContourGroup;
343         wxStaticText                                            *_staticTextSpread;
344         PanelBullEyeOptions                                     *_panelBullEyeOptions;
345         int                                                                     _numberOfVariablesStatistics;
346
347         int                                                     inundo;
348         int                                                     inredo;
349         std::string                                     stundoredo;
350
351         void                                            saveState();
352         void                                            loadState(std::string filename);
353 };
354 #endif // __wxContourEventHandler_HEADER_FILE__