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