1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifndef __wxContourEventHandler_h_INCLUDED_H__
27 #define __wxContourEventHandler_h_INCLUDED_H__
30 // -----------------------------------------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // -----------------------------------------------------------------------------------------------------------
35 #include <wx/wxprec.h>
46 //------------------------------------------------------------------------------------------------------------
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"
65 #include "PerformingOperation.h"
67 #include "ContourThing.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"
78 #include "wxVtkBaseView_SceneManager.h"
81 #include "Contour/ContourPropagation.h"
82 #include "mBarRange.h"
84 #include "PanelBullEyeOptions.h"
86 /** file wxContourEventHandler.h */
90 class PanelBullEyeOptions : public wxPanel {
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);
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;
122 //------------------------------------------------------------------------------------------------------------
124 //------------------------------------------------------------------------------------------------------------
125 class wxContourEventHandler : public wxEvtHandler {
129 //------------------------------------------------------------------------------------------------------------
130 // Constructors & Destructors
131 //------------------------------------------------------------------------------------------------------------
132 wxContourEventHandler();
133 ~wxContourEventHandler();
135 //------------------------------------------------------------------------------------------------------------
136 // Configuration methods
137 //------------------------------------------------------------------------------------------------------------
138 bool configureEventsHandling();
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 );
159 //------------------------------------------------------------------------------------------------------------
160 // Model management methods
161 //------------------------------------------------------------------------------------------------------------
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();
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 );
189 void changeContourOfManager(std::string keyName, Instant *instant);
190 void changeContoursOfManager(std::vector<std::string> & keyNamesVector);
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 );
208 //------------------------------------------------------------------------------------------------------------
209 // Other functional methods
210 //------------------------------------------------------------------------------------------------------------
211 void executeActionCommand( const char toolCommand );
213 //------------------------------------------------------------------------------------------------------------
214 // Getting information methods
215 //------------------------------------------------------------------------------------------------------------
217 //------------------------------------------------------------------------------------------------------------
218 // Responding Spread Tools
219 //------------------------------------------------------------------------------------------------------------
220 void onSpreadReset( wxCommandEvent& event );
221 void onSpreadAdd( wxCommandEvent& event );
222 void onSpreadGo( wxCommandEvent& event );
224 void onSegmentationAllSlice( wxCommandEvent& event );
225 void onSegmentationOneSlice( wxCommandEvent& event );
226 void SegmentationOneSlice( int x, int y, int z );
229 void onTest( wxCommandEvent& event );
230 void onTestReset( wxCommandEvent& event );
231 void onTestAdd( wxCommandEvent& event );
232 void onTestGo( wxCommandEvent& event );
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);
253 void onInterfaceTestFrame();
255 void SaveValuesXYZ(std::string directory,std::string namefile);
256 void SaveImageResult(std::string directory,std::string namefile);
259 ** JCP 13-10-08 This methods group the diferent kind of panels
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);
270 void showAxis(bool show);
271 //JCP 13-10-09 Fill grid as public
272 void FillGridWithContoursInformation();
275 void createContourBullsEye(PanelBullEyeOptions* panel );
277 //void getValuesXYZ(std::vector<double *>* vectx, std::vector<double*>* vecty, std::vector<double*>* vectz, std::vector<int>* size);
280 ** This method gets the information of the contours in each slice
282 void getValuesXYZ(double ** vectx, double ** vecty, double ** vectz, std::vector<int>* size);
284 ** This method gets the mask and value images generated by the contours
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
290 void checkInformationPanel();
297 //------------------------------------------------------------------------------------------------------------
299 //------------------------------------------------------------------------------------------------------------
300 void updateInstantOutlines();
301 void updateInstantImageData();
302 void updateInstantAxes();
303 void changeInstant();
304 void RefreshInterface();
307 //JCP 13-10-09 must be a public method
308 //void FillGridWithContoursInformation();
310 manualContourModel * factoryManualContourModel(int typeContour);
311 manualContourModel * factoryManualContourModel(PanelBullEyeOptions* panel);
312 std::vector<manualContourModel*> ExploseEachModel( std::vector<manualContourModel*> lstManConMod );
314 //------------------------------------------------------------------------------------------------------------
316 //------------------------------------------------------------------------------------------------------------
318 wxContourViewPanel* _theViewPanel;
319 OutlineModelManager * _modelManager;
320 ContourWorkspace * _workSpace;
321 wxInstantChooserPanel * _instantPanel;
322 wxContour_ButtonsBar * _buttonsBar;
324 wxVtkBaseView_SceneManager * _sceneManager;
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;
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;
342 wxFrame *_spreadFrame;
343 wxFrame *_segmentationFrame;
344 wxFrame *_createContourFrame;
345 wxFrame *_deleteFrame;
346 wxFrame *_InformationContourFrame;
347 wxFrame *_interfaceConfigurationFrame;
349 wxTextCtrl * _wxtextctrlTest;
351 std::string fileNameContourROI;
353 wxRadioBox *methodRadiobox;
354 ContourPropagation *_contourPropagation;
357 wxStaticText *_staticTextSegmentation;
358 mBarRange *_mbarrange;
359 wxTextCtrl *_wxtextctrlSpread;
360 wxRadioBox *_informationRadiobox;
361 wxListCtrl *_wxlistctrl;
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;
379 std::string stundoredo;
382 void loadState(std::string filename);
384 std::string intToString(int num);
386 #endif // __wxContourEventHandler_HEADER_FILE__