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