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