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