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