]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfToolsPanels.cxx
Clean code
[creaContours.git] / lib / Interface_Icons_NDimensions / interfToolsPanels.cxx
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 #include "interfToolsPanels.h"
27 #include "interfMainPanel.h"
28
29 interfConfigurationPanel::interfConfigurationPanel(wxWindow * parent)
30 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
31 {
32 //      wxPanel *panel                                                  = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(_T("")));
33         _withOfContourLine                                              = new wxSlider(this, -1, 1 , 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
34
35         double range[2];
36         interfMainPanel::getInstance()->getImageRange(range);
37         //this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
38
39         //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
40         //vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
41         //int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
42         //int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
43
44         int colorwindow = interfMainPanel::getInstance()->getColorWindow();
45         int windowlevel = interfMainPanel::getInstance()->getWindowLevel();
46
47         int min = (int)floor (range[0]);
48         int max = (int)ceil (range[1]);
49
50
51         _brithtnessWindowLevel                                  = new wxSlider(this, -1, windowlevel , min, max, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
52         _brithtnessColorLevel                                   = new wxSlider(this, -1, colorwindow , min, max, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
53
54         _interpolationCheckBox                                  = new wxCheckBox(this, -1, _T("Interpolation") );
55         _interpolationCheckBox->SetValue(true);
56
57         _showTextContourCheckBox                                = new wxCheckBox(this, -1, _T("Labels") );
58         _showTextContourCheckBox->SetValue(true);
59
60         _beforContourCheckBox                                   = new wxCheckBox(this, -1, _T("Befor Contour") );
61         _beforContourCheckBox->SetValue(false);
62
63         _afterContourCheckBox                                   = new wxCheckBox(this, -1, _T("After Contour") );
64         _afterContourCheckBox->SetValue(false);
65
66         wxButton        *jumpBackwareSlice                      = new wxButton(this,-1,_T("-"),wxDefaultPosition, wxDefaultSize);
67         wxButton        *jumpFordwareSlice                      = new wxButton(this,-1,_T("+"),wxDefaultPosition, wxDefaultSize);
68                                 _jumpSpinCtrl                           = new wxSpinCtrl(this,-1,wxString("10") );
69                                 _jumpSpinCtrl->SetRange(1,100);
70                                 _shiftSpinCtrl                          = new wxSpinCtrl(this,-1,wxString("0") );
71                                 _shiftSpinCtrl->SetRange(0,99);
72
73         Connect( _withOfContourLine->GetId(),     wxEVT_SCROLL_CHANGED,           (wxObjectEventFunction) &interfConfigurationPanel::onWidthOfContour);
74         Connect( _withOfContourLine->GetId(),     wxEVT_SCROLL_THUMBTRACK,        (wxObjectEventFunction) &interfConfigurationPanel::onWidthOfContour);
75
76         Connect( _brithtnessWindowLevel->GetId(), wxEVT_SCROLL_CHANGED,           (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel);
77         Connect( _brithtnessWindowLevel->GetId(), wxEVT_SCROLL_THUMBTRACK,        (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel);
78         Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED,           (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel);
79         Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK,        (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel);
80         Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnInterpolation);
81         Connect( _showTextContourCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnShowTextContour);
82         Connect( _beforContourCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnBeforAfterContour);
83         Connect( _afterContourCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnBeforAfterContour);
84         Connect( jumpBackwareSlice->GetId(),    wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfConfigurationPanel::OnBackwareSlice );
85         Connect( jumpFordwareSlice->GetId(),    wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfConfigurationPanel::OnFordwareSlice );
86
87
88         wxFlexGridSizer * sizerA                                        = new wxFlexGridSizer(1);
89         sizerA -> Add( new wxStaticText(this,-1, _T("Contour width"))  , 1, wxGROW );
90         sizerA -> Add( _withOfContourLine               , 1, wxGROW );
91         sizerA -> Add( new wxStaticText(this,-1, _T(" "))  , 1, wxGROW );
92         sizerA -> Add( new wxStaticText(this,-1, _T("Window level"))  , 1, wxGROW );
93         sizerA -> Add( _brithtnessWindowLevel   , 1, wxGROW );
94         sizerA -> Add( new wxStaticText(this,-1, _T("Color level"))  , 1, wxGROW );
95         sizerA -> Add( _brithtnessColorLevel    , 1, wxGROW );
96         sizerA -> Add( new wxStaticText(this,-1, _T(" "))  , 1, wxGROW );
97
98         wxFlexGridSizer * sizerB1                                       = new wxFlexGridSizer(2);
99         sizerB1-> Add( jumpBackwareSlice                , 1, wxGROW );
100         sizerB1 -> Add( jumpFordwareSlice               , 1, wxGROW );
101
102         wxFlexGridSizer * sizerB                                        = new wxFlexGridSizer(1);
103         sizerB -> Add( _interpolationCheckBox   , 1, wxGROW );
104         sizerB -> Add( new wxStaticText(this    ,-1, _T(" "))  , 1, wxGROW );
105         sizerB -> Add( _showTextContourCheckBox , 1, wxGROW );
106         sizerB -> Add( new wxStaticText(this,-1, _T(" "))  , 1, wxGROW );
107         sizerB -> Add( _beforContourCheckBox    , 1, wxGROW );
108         sizerB -> Add( _afterContourCheckBox    , 1, wxGROW );
109         sizerB -> Add( new wxStaticText(this,-1, _T(" "))  , 1, wxGROW );
110         sizerB -> Add( sizerB1                                  , 1, wxGROW );
111         sizerB -> Add( _jumpSpinCtrl                    , 1, wxGROW );
112         sizerB -> Add( _shiftSpinCtrl                   , 1, wxGROW );
113         
114
115         wxFlexGridSizer * sizer                                         = new wxFlexGridSizer(3);
116         sizer -> Add( sizerA            , 1, wxGROW );
117         sizer -> Add( new wxStaticText(this,-1, _T("       "))  , 1, wxGROW );
118         sizer -> Add( sizerB            , 1, wxGROW );
119
120         this->SetSizer( sizer );
121         //JCP 13-10-08
122         //panel->SetSize( sizepanel );
123         //13-10-08
124         this->SetAutoLayout( true );
125         this->Layout();
126
127 }
128
129
130 interfConfigurationPanel::~interfConfigurationPanel()
131 {
132 }
133
134 void interfConfigurationPanel::onWidthOfContour(wxScrollEvent& event)
135 {
136     double width = (double)_withOfContourLine->GetValue() / 2.0;
137         interfMainPanel::getInstance()->onWidthOfContour(width);
138 }
139
140 void interfConfigurationPanel::onBrigthnessColorWindowLevel(wxScrollEvent& event){
141         int colorwindow                         = _brithtnessColorLevel->GetValue();
142         int windowlevel                         = _brithtnessWindowLevel->GetValue();
143         interfMainPanel::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
144 }
145
146 void interfConfigurationPanel::OnInterpolation(wxCommandEvent& event)
147 {
148         interfMainPanel::getInstance()->onInterpolation(_interpolationCheckBox->GetValue());
149 }
150
151 void interfConfigurationPanel::OnBeforAfterContour(wxCommandEvent& event)
152 {
153         interfMainPanel::getInstance()->onBeforAfterContour(_beforContourCheckBox->GetValue() , _afterContourCheckBox->GetValue() );
154 }
155
156 void interfConfigurationPanel::OnShowTextContour(wxCommandEvent& event)
157 {
158         interfMainPanel::getInstance()->onShowTextContour(_showTextContourCheckBox->GetValue() );
159 }
160
161 void interfConfigurationPanel::OnBackwareSlice(wxCommandEvent& event)
162 {
163         interfMainPanel::getInstance()->onJumpSlice( -_jumpSpinCtrl->GetValue(), _shiftSpinCtrl->GetValue() );
164 }
165
166 void interfConfigurationPanel::OnFordwareSlice(wxCommandEvent& event)
167 {
168         interfMainPanel::getInstance()->onJumpSlice( _jumpSpinCtrl->GetValue(), _shiftSpinCtrl->GetValue() );
169 }
170
171
172 /**
173 ** Begin of the spread panel
174 **/
175
176 interfSpreadPanel::interfSpreadPanel(wxWindow* parent)
177 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
178 {
179
180         //wxPanel *panel                                = new wxPanel(parent,-1);
181
182         //_contourPropagation                   = new ContourPropagation();
183
184         //wxPanel *panel                                                        = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("",wxConvUTF8));
185
186         wxButton *spreadResetBtn        = new wxButton(this,-1,_T("Reset"),wxDefaultPosition, wxDefaultSize );
187         wxButton *spreadAddBtn          = new wxButton(this,-1,_T("Add key contour "),wxDefaultPosition, wxDefaultSize);
188         wxButton *spreadAddAllBtn       = new wxButton(this,-1,_T("Add All to key contour"),wxDefaultPosition, wxDefaultSize);
189
190         wxString lstOptions[3];
191         lstOptions[0]=_T("A");
192         lstOptions[1]=_T("B");
193         lstOptions[2]=_T("C");
194         _spreadMethodRadiobox                                           = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions,  3, wxRA_SPECIFY_COLS);
195         _spreadMethodRadiobox->SetSelection(2);
196
197         wxButton *spreadGoBtn           = new wxButton(this,-1,_T("Go"),wxDefaultPosition, wxDefaultSize);
198         _staticTextSpread                       = new wxStaticText(this,-1,_T("    "));
199
200         _wxtextctrlSpread           = new wxTextCtrl(this,-1, _T(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
201         _wxtextctrlSpread->SetEditable(false);
202
203         Connect( spreadResetBtn->GetId(),       wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadReset );
204         Connect( spreadAddBtn->GetId(),         wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadAdd );
205         Connect( spreadAddAllBtn->GetId(),      wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadAddAll );
206         Connect( spreadGoBtn->GetId(),          wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadGo );
207
208         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
209         sizer -> Add( spreadResetBtn            , 1, wxGROW );
210         sizer -> Add( spreadAddBtn                      , 1, wxGROW );
211         sizer -> Add( spreadAddAllBtn           , 1, wxGROW );
212         sizer -> Add( _spreadMethodRadiobox     , 1, wxGROW );
213         sizer -> Add( spreadGoBtn                       , 1, wxGROW );
214         sizer -> Add( _staticTextSpread         , 1, wxGROW );
215         sizer -> Add( _wxtextctrlSpread         , 1, wxGROW );
216
217
218         this->SetSizer( sizer );
219         //this->SetSize( wxDefaultSize );
220         this->SetAutoLayout( true );
221         this->Layout();
222         //return panel;
223 }
224
225 interfSpreadPanel::~interfSpreadPanel(){
226 }
227
228 void interfSpreadPanel::onSpreadReset(wxCommandEvent& event){
229         setStringSpread("   ");
230         _wxtextctrlSpread->SetValue(wxString("",wxConvUTF8));
231         interfMainPanel::getInstance()->resetAppend();
232 }
233
234 void interfSpreadPanel::onSpreadAdd(wxCommandEvent& event){
235         interfMainPanel::getInstance()->onSpreadAdd();
236 }
237
238 void interfSpreadPanel::onSpreadAddAll(wxCommandEvent& event){
239         interfMainPanel::getInstance()->onSpreadAddAll();
240 }
241
242 void interfSpreadPanel::onSpreadGo(wxCommandEvent& event){
243         setStringSpread("   ");
244         int typeMethodFindCtrlPoints=_spreadMethodRadiobox->GetSelection();
245 printf("EED interfSpreadPanel::onSpreadGo %d\n",typeMethodFindCtrlPoints);
246         interfMainPanel::getInstance()->onSpreadGo(typeMethodFindCtrlPoints);
247
248 }
249
250 void interfSpreadPanel::appendStringSpread(std::string val){
251         /* // if */
252         wxString newstring;
253         //newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice );
254
255 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
256 #if wxMAJOR_VERSION <= 2
257         newstring.append(wxString(_wxtextctrlSpread->GetValue(),wxConvUTF8));
258 #else
259         newstring.append( _wxtextctrlSpread->GetValue() );
260 #endif
261
262
263         newstring.append(wxString(" ",wxConvUTF8));
264         newstring.append(wxString(val.c_str(),wxConvUTF8));
265         _wxtextctrlSpread->SetValue(newstring);
266 }
267
268 void interfSpreadPanel::setStringSpread(std::string stringtemp){
269
270         wxString newstring(stringtemp.c_str(),wxConvUTF8);
271         //_wxtextctrlSpread->SetEditable(true);
272         _staticTextSpread->SetLabel(newstring);
273         //_wxtextctrlSpread->SetEditable(false);
274 }
275
276 /**
277 ** Begin of information panel
278 **/
279 interfInformationPanel::interfInformationPanel(wxWindow * parent)
280 //: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
281 : wxPanel(parent, -1)
282 {
283 printf("EED interfInformationPanel::interfInformationPanel Start\n");
284         //wxPanel *panel                                                                        = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
285         wxString lstOptions[4];
286         lstOptions[0]=_T("Current Slice");
287         lstOptions[1]=_T("Range Slices");
288 //      lstOptions[2]=_T("All Slices");
289         _informationRadiobox     = new wxRadioBox(this, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 2 , lstOptions,  2, wxRA_SPECIFY_COLS);
290
291         wxString lstOptContOperation[5];
292         lstOptContOperation[0]=_T("AND");
293         lstOptContOperation[1]=_T("OR");
294         lstOptContOperation[2]=_T("XOR");
295         lstOptContOperation[3]=_T("ALL");
296         _radiolstboxContourGroup = new wxRadioBox(this, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation,  4, wxRA_SPECIFY_COLS);
297         _radiolstboxContourGroup->SetSelection(1);
298         Connect( _radiolstboxContourGroup->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &interfInformationPanel::onContourGroup );
299
300 printf("EED interfInformationPanel::interfInformationPanel 1\n");
301
302
303         _XYZValues      = new wxCheckBox(this, -1, _T("Save Contour Values") );
304         _XYZValues->SetValue(true);
305         _contourImage   = new wxCheckBox(this, -1, _T("Extract Contours as Images") );
306         _contourImage->SetValue(true);
307         _statistics     = new wxCheckBox(this, -1, _T("Save Statistics") );
308         _statistics->SetValue(true);
309
310
311         wxButton *informationContourLabelsBtn           = new wxButton(this,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
312 #if wxMAJOR_VERSION <= 2
313         informationContourLabelsBtn->SetEventHandler( this );
314 #else
315         //      informationContourLabelsBtn->SetEventHandler( this );
316         printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo informationContourLabelsBtn->SetEventHandler \n");
317 #endif
318         Connect( informationContourLabelsBtn->GetId(),          wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onInformationContourLabels );
319
320         wxButton *statisticsContourBtn                  = new wxButton(this,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
321 #if wxMAJOR_VERSION <= 2
322         statisticsContourBtn->SetEventHandler( this );
323 #else
324         //statisticsContourBtn->SetEventHandler( this );
325         printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo statisticsContourBtn->SetEventHandler \n");
326 #endif
327         Connect( statisticsContourBtn->GetId(),         wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onExtractInformation );
328
329         wxButton *showResultImagesBtn                   = new wxButton(this,-1,_T("Show result images"),wxDefaultPosition, wxSize(140,35) );
330 #if wxMAJOR_VERSION <= 2
331         showResultImagesBtn->SetEventHandler( this );
332 #else
333         //showResultImagesBtn->SetEventHandler( this );
334         printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo showResultImagesBtn->SetEventHandler \n");
335 #endif
336         Connect( showResultImagesBtn->GetId(),          wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onShowResultImages );
337
338         wxButton *saveResultsBtn                        = new wxButton(this,-1,_T("Save Results"),wxDefaultPosition, wxSize(140,35) );
339 #if wxMAJOR_VERSION <= 2
340         saveResultsBtn->SetEventHandler( this );
341 #else
342 //EED   saveResultsBtn->SetEventHandler( this );
343 printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo saveResultsBtn->SetEventHandler \n");
344 #endif
345
346         Connect( saveResultsBtn->GetId(),               wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onSaveResults );
347
348         int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
349
350         //_theViewPanel->getSceneManager()->GetImageDataSizeZ();
351         _mbarrangeSliceInformation                      =  new mBarRange(this,65,65);
352         _mbarrangeSliceInformation->SetMin(0);
353         _mbarrangeSliceInformation->SetStart(0);
354         _mbarrangeSliceInformation->SetOrientation( true );
355         _mbarrangeSliceInformation->setActiveStateTo(true);
356         _mbarrangeSliceInformation->setVisibleLabels( true );
357         _mbarrangeSliceInformation->setDeviceEndMargin(10);
358         _mbarrangeSliceInformation->setRepresentedValues( 0 , sizeZ-1 );
359         _mbarrangeSliceInformation->setDeviceBlitStart(10,10);
360         _mbarrangeSliceInformation->setIfWithActualDrawed( false );
361         _mbarrangeSliceInformation->SetStart( 0 );
362         _mbarrangeSliceInformation->SetEnd( sizeZ-1 );
363
364         double range[2];
365         interfMainPanel::getInstance()->getImageRange(range);
366 printf("EED interfInformationPanel::interfInformationPanel 2\n");
367
368         int min = (int)floor (range[0]);
369         int max = (int)ceil (range[1]);
370
371         _mbarrangeRangeInformation      =  new mBarRange(this,65,65);
372         _mbarrangeRangeInformation->SetMin(0);
373         _mbarrangeRangeInformation->SetStart(0);
374         _mbarrangeRangeInformation->SetOrientation( true );
375         _mbarrangeRangeInformation->setActiveStateTo(true);
376         _mbarrangeRangeInformation->setVisibleLabels( true );
377         _mbarrangeRangeInformation->setDeviceEndMargin(10);
378         _mbarrangeRangeInformation->setRepresentedValues( min , max );
379         _mbarrangeRangeInformation->setDeviceBlitStart(10,10);
380         _mbarrangeRangeInformation->setIfWithActualDrawed( false );
381         _mbarrangeRangeInformation->SetStart( min );
382         _mbarrangeRangeInformation->SetEnd( max );
383
384 //      _mbarrangeSliceInformation->PushEventHandler(this);
385 //      Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
386 //      Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
387         Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
388         Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
389 //      Connect(_mbarrangeRangeInformation->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
390         Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
391
392
393 printf("EED interfInformationPanel::interfInformationPanel 3\n");
394         _staticTextInformation  = new wxStaticText(this,-1,_T("    "));
395         _grid = new wxGrid( this,
396                 wxID_ANY,
397                 wxPoint( 0, 0 ),
398                 wxSize( 200, 250 ) );
399         int i,gridCol=10,gridRow=sizeZ+2;
400         _grid->CreateGrid( 0, 0 );
401         _grid->AppendRows(gridRow);
402         _grid->AppendCols(gridCol);
403         for (i=0;i<gridRow;i++)
404         {
405                 _grid->SetRowLabelValue(i, _T(" ") );
406         }
407 //                      _grid->SetColLabelSize(0);
408         FillGridWithContoursInformation();
409
410
411 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
412 #if wxMAJOR_VERSION <= 2
413         wxFlexGridSizer * sizerSave             = new wxFlexGridSizer(2,2);
414 #else
415         wxFlexGridSizer * sizerSave             = new wxFlexGridSizer(2,2,0,0);
416 #endif
417         sizerSave -> Add( new wxStaticText(this,-1,_T("Save Options: "))  , 1, wxGROW );
418         sizerSave->Add( _XYZValues,    1, wxALL, 2 );
419         sizerSave->Add( _statistics,   1, wxALL, 2 );
420         sizerSave->Add( _contourImage, 1, wxALL, 2 );
421
422
423 printf("EED interfInformationPanel::interfInformationPanel 4\n");
424 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
425 #if wxMAJOR_VERSION <= 2
426         wxFlexGridSizer * sizerA                = new wxFlexGridSizer(10);
427 #else
428         wxFlexGridSizer * sizerA                = new wxFlexGridSizer(1,10,0,0);
429 #endif
430         sizerA->Add( _informationRadiobox,     1, wxALL, 2 );
431         sizerA->Add( _radiolstboxContourGroup, 1, wxALL, 2 );
432         sizerA->Add( sizerSave,                1, wxALL, 2 );
433
434
435 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
436 #if wxMAJOR_VERSION <= 2
437         wxFlexGridSizer * sizerB                = new wxFlexGridSizer(10);
438 #else
439         wxFlexGridSizer * sizerB                = new wxFlexGridSizer(1,4,0,0);
440 #endif
441         sizerB->Add( informationContourLabelsBtn, 1, wxALL, 2 );
442         sizerB->Add( statisticsContourBtn,        1, wxALL, 2 );
443         sizerB->Add( showResultImagesBtn,         1, wxALL, 2 );
444         sizerB->Add( saveResultsBtn,              1, wxALL, 2 );
445
446 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
447 #if wxMAJOR_VERSION <= 2
448         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1,8);
449 #else
450         wxFlexGridSizer * sizer         = new wxFlexGridSizer(20,1,0,0);
451 #endif
452 printf("EED interfInformationPanel::interfInformationPanel 5\n");
453         sizer->Add( sizerA                     , 1, wxALL               , 0 );
454 printf("EED interfInformationPanel::interfInformationPanel 5.1\n");
455         sizer->Add( new wxStaticText(this      ,1,_T("Slice Range"))    , 1, wxALL , 0 );
456 printf("EED interfInformationPanel::interfInformationPanel 5.2\n");
457         sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW        , 2 );
458 printf("EED interfInformationPanel::interfInformationPanel 5.3\n");
459         sizer->Add( new wxStaticText(this      ,1,_T("Gray Range"))     , 1, wxALL , 0 );
460 printf("EED interfInformationPanel::interfInformationPanel 5.4\n");
461         sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW        , 2 );
462         
463         
464         sizer->Add( sizerB                     , 1, wxEXPAND            , 0 );
465         sizer->Add( _staticTextInformation     , 1, wxEXPAND            , 0 );
466         sizer->Add( _grid                      , 1, wxEXPAND            , 0 );
467         this->SetSizer( sizer );
468         this->SetSize( wxSize(1500,1500) );
469         this->SetAutoLayout( true );
470 printf("EED interfInformationPanel::interfInformationPanel 5.10\n");
471         this->Layout();
472         //return panel;
473
474 printf("EED interfInformationPanel::interfInformationPanel End\n");
475
476 }
477
478 interfInformationPanel::~interfInformationPanel()
479 {
480 }
481
482
483 void interfInformationPanel::onRangeSliceInformation(wxCommandEvent& event)
484 {
485         int     grayRangeMin    = _mbarrangeRangeInformation->GetStart();
486         int     grayRangeMax    = _mbarrangeRangeInformation->GetEnd();
487         interfMainPanel::getInstance()->SetScalarRange(grayRangeMin,grayRangeMax);
488         interfMainPanel::getInstance()->RefreshInterface();
489 }
490
491
492 void interfInformationPanel::onInformationContourLabels(wxCommandEvent& event){
493         wxBusyCursor wait;
494         FillGridWithContoursInformation();
495 }
496
497
498 void interfInformationPanel::onShowResultImages(wxCommandEvent& event)
499 {
500 //      onExtractInformation( event );
501         int selection        = _informationRadiobox->GetSelection();
502         int minZ             = _mbarrangeSliceInformation->GetStart();
503         int maxZ             = _mbarrangeSliceInformation->GetEnd();
504         int typeContourGroup = _radiolstboxContourGroup->GetSelection();
505         interfMainPanel::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
506 }
507
508
509 void interfInformationPanel::onExtractInformation(wxCommandEvent& event){
510         wxBusyCursor wait;
511         _grid->ClearGrid();
512
513         int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
514         int selection        = _informationRadiobox->GetSelection();
515         int minZ             = _mbarrangeSliceInformation->GetStart();
516         int maxZ             = _mbarrangeSliceInformation->GetEnd();
517         int grayRangeMin     = _mbarrangeRangeInformation->GetStart();
518         int grayRangeMax     = _mbarrangeRangeInformation->GetEnd();
519
520         interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ, grayRangeMin, grayRangeMax);
521 }
522
523 void interfInformationPanel::onSaveResults(wxCommandEvent& event)
524 {
525 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
526 #if wxMAJOR_VERSION <= 2
527         wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxSAVE );
528 #else
529         wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxFD_SAVE );
530 #endif
531         if (dialog.ShowModal() == wxID_OK)
532         {
533                 onExtractInformation( event );
534                 int selection         = _informationRadiobox->GetSelection();
535                 int minZ              = _mbarrangeSliceInformation->GetStart();
536                 int maxZ              = _mbarrangeSliceInformation->GetEnd();
537                 std::string directory = (const char *)(dialog.GetDirectory().mb_str());
538                 std::string namefile  = (const char *)(dialog.GetFilename().mb_str());
539                 std::string filename  = (const char *)(dialog.GetPath().mb_str() );
540                 int typeContourGroup  = _radiolstboxContourGroup->GetSelection();
541                 interfMainPanel::getInstance()->onSaveResults(directory, namefile, filename,
542                         typeContourGroup,
543                         selection,minZ,maxZ,
544                         _XYZValues->GetValue(), _contourImage->GetValue(), _statistics->GetValue());
545         }
546 }
547
548 void interfInformationPanel::FillGridWithContoursInformation(){
549
550         wxString tempString;
551         _grid->ClearGrid();
552         _grid->SetColLabelValue(0, _T("A") );
553         _grid->SetColLabelValue(1, _T("B") );
554         _grid->SetColLabelValue(2, _T("C") );
555         _grid->SetColLabelValue(3, _T("D") );
556         _grid->SetColLabelValue(4, _T("E") );
557         _grid->SetColLabelValue(5, _T("F") );
558         //_instantPanel->getInstant( tempVector );
559
560         int z,sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();//->getSceneManager()->GetImageDataSizeZ();
561         int ii,sizeLstContourThings;
562         for ( z=0 ; z<sizeZ ; z++)
563         {
564
565                 std::vector<std::string> lstContourThings = interfMainPanel::getInstance()->getOutlinesName(z);
566
567                         //this->_modelManager->getOutlinesAtInstant( &instant );
568
569                 sizeLstContourThings = lstContourThings.size();
570                 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
571                 _grid->SetRowLabelValue(z, tempString );
572
573                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
574                 {
575                         //ContourThing **contourthing = lstContourThings[ii];
576                         //tempString = wxString((*contourthing)->getName().c_str(),wxConvUTF8) ;
577                         tempString = wxString(lstContourThings[ii].c_str(),wxConvUTF8) ;
578                         _grid->SetCellValue( z, ii, tempString );
579                 } // for ii
580         }// for z
581
582         // Last line
583         _grid->SetRowLabelValue(sizeZ, _T(" ") );
584         for (ii=0 ; ii<sizeLstContourThings ; ii++)
585         {
586                 _grid->SetCellValue( sizeZ, ii, _T(" ") );
587         } // for ii
588
589 }
590
591 void interfInformationPanel::setStringInfoPanel(wxString tmpString){
592         _staticTextInformation->SetLabel(tmpString);
593 }
594
595 void interfInformationPanel::setRowLabelInfoPanel(int z,wxString tempString){
596         _grid->SetRowLabelValue(z, tempString );
597 }
598
599 int interfInformationPanel::getNumberCols(){
600         return _grid->GetNumberCols();
601 }
602
603 void interfInformationPanel::appendCols(int numcols){
604     _grid->AppendCols(numcols);
605 }
606
607 void interfInformationPanel::setCellValue(int z,int tmpIntA,wxString tempString){
608         _grid->SetCellValue( z, tmpIntA , tempString );
609 }
610
611 void interfInformationPanel::setColLabel(int tmpIntB,wxString tmpTitleString){
612         _grid->SetColLabelValue(tmpIntB, tmpTitleString);
613 }
614
615 wxString interfInformationPanel::getCellValue(int j,int i){
616         return _grid->GetCellValue( j , i );
617 }
618
619 void interfInformationPanel::onContourGroup(wxCommandEvent& event)
620 {
621         printf("EED interfInformationPanel::onContourGroup \n");
622         int contourGroup=_radiolstboxContourGroup->GetSelection();
623         if (contourGroup==3)
624         {
625                 contourGroup=0;
626         }
627         interfMainPanel::getInstance()->SetContourGroup( _radiolstboxContourGroup->GetSelection() );
628 }
629
630 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
631 interfCalibrationPanel:: interfCalibrationPanel(wxWindow * parent)
632 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
633 {
634         double range[2];
635         interfMainPanel::getInstance()->getImageRange(range);
636
637         //Radio buttons
638         wxString options[3];
639         options[0]=_T("mm");
640         options[1]=_T("cm");
641         options[2]=_T("inch");
642
643         _unitsRadiobox = new wxRadioBox(this, -1, _T("Unit of measurement"), wxPoint(2, 25), wxSize(145,45), 3 , options,  3, wxRA_SPECIFY_COLS);
644         _unitsRadiobox->SetSelection(0);
645
646         //The label
647         new wxStaticText(this, wxID_ANY, wxT("Real Size: "),   wxPoint(2, 5));
648
649         //Text Control
650         _size = new wxTextCtrl(this, wxID_ANY, wxT(""),  wxPoint(78,3),   wxSize(70, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
651
652         //The button
653         new wxButton(this, 1, wxT("Calibrate"), wxPoint(78, 70), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
654
655         //Conexion del boton con su respectivo manejador
656         Connect(1, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfCalibrationPanel::onCalibrate);
657
658 }
659
660 interfCalibrationPanel:: ~interfCalibrationPanel()
661 {
662 }
663
664 void interfCalibrationPanel::onCalibrate(wxCommandEvent& event)
665 {
666         wxString size =_size->GetValue();
667         int unit = _unitsRadiobox->GetSelection();
668         interfMainPanel::getInstance()->onCalibration(size, unit);
669 }
670 //------------------------------------------------------------------------------------------------------------
671
672
673
674 //////////////////////////////////////////////////////////////
675
676 interfFlipPanel::interfFlipPanel(wxWindow* parent)
677 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
678 {
679         wxButton *buttonFlipX = new wxButton(this,wxID_ANY,_T("Flip Horizontally"), wxDefaultPosition, wxSize(200,35) );
680         wxButton *buttonFlipY = new wxButton(this,wxID_ANY,_T("Flip Vertically"), wxDefaultPosition, wxSize(200,35) );
681
682         wxString lstOptions[3];
683         lstOptions[0]=_T("Flip selected contours");
684         lstOptions[1]=_T("Flip all contours of actual slice");
685         lstOptions[2]=_T("Flip all contours");
686         _wichContoursRadioBox = new wxRadioBox(this, -1, _T("Transform"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions,  1, wxRA_SPECIFY_COLS);
687         _wichContoursRadioBox->SetSelection(2);
688
689         
690         Connect( buttonFlipX->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipXPressed );
691         Connect( buttonFlipY->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipYPressed ); 
692         
693         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
694         sizer -> Add( _wichContoursRadioBox, 1, wxGROW );
695         sizer -> Add( buttonFlipX, 1, wxGROW );
696         sizer -> Add( buttonFlipY, 1, wxGROW );
697
698         this->SetSizer( sizer );
699         this->SetAutoLayout( true );
700         this->Layout();
701 }
702
703
704
705
706 interfFlipPanel::~interfFlipPanel(){
707 }
708
709 void interfFlipPanel::onFlipXPressed(wxCommandEvent& event)
710 {
711         std::cout << "interfToolsPanels.cxx  interfFlipPanel::onFlipXPressed     FlipX (btn)" << std::endl;
712         int typeContoursFlip = _wichContoursRadioBox->GetSelection(); 
713         interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 0 );  // type, direction
714 }
715
716 void interfFlipPanel::onFlipYPressed(wxCommandEvent& event)
717 {
718         std::cout << "interfToolsPanels.cxx   interfFlipPanel::onFlipYPressed FlipY  (btn)" << std::endl;
719         int typeContoursFlip = _wichContoursRadioBox->GetSelection(); 
720         interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 1 );  // type, direction
721 }
722
723