]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfToolsPanels.cxx
#3140 creaContours Feature New Normal - branch vtk7itk4wx3
[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 printf("EED interfInformationPanel::interfInformationPanel Start\n");
227         //wxPanel *panel                                                                        = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
228         wxString lstOptions[4];
229         lstOptions[0]=_T("Current Slice");
230         lstOptions[1]=_T("Range Slices");
231 //      lstOptions[2]=_T("All Slices");
232         _informationRadiobox     = new wxRadioBox(this, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 2 , lstOptions,  2, wxRA_SPECIFY_COLS);
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 printf("EED interfInformationPanel::interfInformationPanel 1\n");
244
245
246         _XYZValues      = new wxCheckBox(this, -1, _T("Save Contour Values") );
247         _XYZValues->SetValue(true);
248         _contourImage   = new wxCheckBox(this, -1, _T("Extract Contours as Images") );
249         _contourImage->SetValue(true);
250         _statistics     = new wxCheckBox(this, -1, _T("Save Statistics") );
251         _statistics->SetValue(true);
252
253
254         wxButton *informationContourLabelsBtn           = new wxButton(this,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
255 #if wxMAJOR_VERSION <= 2
256         informationContourLabelsBtn->SetEventHandler( this );
257 #else
258         //      informationContourLabelsBtn->SetEventHandler( this );
259         printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo informationContourLabelsBtn->SetEventHandler \n");
260 #endif
261         Connect( informationContourLabelsBtn->GetId(),          wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onInformationContourLabels );
262
263         wxButton *statisticsContourBtn                  = new wxButton(this,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
264 #if wxMAJOR_VERSION <= 2
265         statisticsContourBtn->SetEventHandler( this );
266 #else
267         //statisticsContourBtn->SetEventHandler( this );
268         printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo statisticsContourBtn->SetEventHandler \n");
269 #endif
270         Connect( statisticsContourBtn->GetId(),         wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onExtractInformation );
271
272         wxButton *showResultImagesBtn                   = new wxButton(this,-1,_T("Show result images"),wxDefaultPosition, wxSize(140,35) );
273 #if wxMAJOR_VERSION <= 2
274         showResultImagesBtn->SetEventHandler( this );
275 #else
276         //showResultImagesBtn->SetEventHandler( this );
277         printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo showResultImagesBtn->SetEventHandler \n");
278 #endif
279         Connect( showResultImagesBtn->GetId(),          wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onShowResultImages );
280
281         wxButton *saveResultsBtn                        = new wxButton(this,-1,_T("Save Results"),wxDefaultPosition, wxSize(140,35) );
282 #if wxMAJOR_VERSION <= 2
283         saveResultsBtn->SetEventHandler( this );
284 #else
285 //EED   saveResultsBtn->SetEventHandler( this );
286 printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo saveResultsBtn->SetEventHandler \n");
287 #endif
288
289         Connect( saveResultsBtn->GetId(),               wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onSaveResults );
290
291         int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
292
293         //_theViewPanel->getSceneManager()->GetImageDataSizeZ();
294         _mbarrangeSliceInformation                      =  new mBarRange(this,65,65);
295         _mbarrangeSliceInformation->SetMin(0);
296         _mbarrangeSliceInformation->SetStart(0);
297         _mbarrangeSliceInformation->SetOrientation( true );
298         _mbarrangeSliceInformation->setActiveStateTo(true);
299         _mbarrangeSliceInformation->setVisibleLabels( true );
300         _mbarrangeSliceInformation->setDeviceEndMargin(10);
301         _mbarrangeSliceInformation->setRepresentedValues( 0 , sizeZ-1 );
302         _mbarrangeSliceInformation->setDeviceBlitStart(10,10);
303         _mbarrangeSliceInformation->setIfWithActualDrawed( false );
304         _mbarrangeSliceInformation->SetStart( 0 );
305         _mbarrangeSliceInformation->SetEnd( sizeZ-1 );
306
307         double range[2];
308         interfMainPanel::getInstance()->getImageRange(range);
309 printf("EED interfInformationPanel::interfInformationPanel 2\n");
310
311         int min = (int)floor (range[0]);
312         int max = (int)ceil (range[1]);
313
314         _mbarrangeRangeInformation      =  new mBarRange(this,65,65);
315         _mbarrangeRangeInformation->SetMin(0);
316         _mbarrangeRangeInformation->SetStart(0);
317         _mbarrangeRangeInformation->SetOrientation( true );
318         _mbarrangeRangeInformation->setActiveStateTo(true);
319         _mbarrangeRangeInformation->setVisibleLabels( true );
320         _mbarrangeRangeInformation->setDeviceEndMargin(10);
321         _mbarrangeRangeInformation->setRepresentedValues( min , max );
322         _mbarrangeRangeInformation->setDeviceBlitStart(10,10);
323         _mbarrangeRangeInformation->setIfWithActualDrawed( false );
324         _mbarrangeRangeInformation->SetStart( min );
325         _mbarrangeRangeInformation->SetEnd( max );
326
327 //      _mbarrangeSliceInformation->PushEventHandler(this);
328 //      Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
329 //      Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
330         Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
331         Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
332 //      Connect(_mbarrangeRangeInformation->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
333         Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &interfInformationPanel::onRangeSliceInformation );
334
335
336 printf("EED interfInformationPanel::interfInformationPanel 3\n");
337         _staticTextInformation  = new wxStaticText(this,-1,_T("    "));
338         _grid = new wxGrid( this,
339                 wxID_ANY,
340                 wxPoint( 0, 0 ),
341                 wxSize( 200, 500 ) );
342         int i,gridCol=10,gridRow=sizeZ+2;
343         _grid->CreateGrid( 0, 0 );
344         _grid->AppendRows(gridRow);
345         _grid->AppendCols(gridCol);
346         for (i=0;i<gridRow;i++)
347         {
348                 _grid->SetRowLabelValue(i, _T(" ") );
349         }
350 //                      _grid->SetColLabelSize(0);
351         FillGridWithContoursInformation();
352
353
354 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
355 #if wxMAJOR_VERSION <= 2
356         wxFlexGridSizer * sizerSave             = new wxFlexGridSizer(2,2);
357 #else
358         wxFlexGridSizer * sizerSave             = new wxFlexGridSizer(2,2,0,0);
359 #endif
360         sizerSave -> Add( new wxStaticText(this,-1,_T("Save Options: "))  , 1, wxGROW );
361         sizerSave->Add( _XYZValues,    1, wxALL, 2 );
362         sizerSave->Add( _statistics,   1, wxALL, 2 );
363         sizerSave->Add( _contourImage, 1, wxALL, 2 );
364
365
366 printf("EED interfInformationPanel::interfInformationPanel 4\n");
367 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
368 #if wxMAJOR_VERSION <= 2
369         wxFlexGridSizer * sizerA                = new wxFlexGridSizer(10);
370 #else
371         wxFlexGridSizer * sizerA                = new wxFlexGridSizer(1,10,0,0);
372 #endif
373         sizerA->Add( _informationRadiobox,     1, wxALL, 2 );
374         sizerA->Add( _radiolstboxContourGroup, 1, wxALL, 2 );
375         sizerA->Add( sizerSave,                1, wxALL, 2 );
376
377
378 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
379 #if wxMAJOR_VERSION <= 2
380         wxFlexGridSizer * sizerB                = new wxFlexGridSizer(10);
381 #else
382         wxFlexGridSizer * sizerB                = new wxFlexGridSizer(1,4,0,0);
383 #endif
384         sizerB->Add( informationContourLabelsBtn, 1, wxALL, 2 );
385         sizerB->Add( statisticsContourBtn,        1, wxALL, 2 );
386         sizerB->Add( showResultImagesBtn,         1, wxALL, 2 );
387         sizerB->Add( saveResultsBtn,              1, wxALL, 2 );
388
389 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
390 #if wxMAJOR_VERSION <= 2
391         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1,8);
392 #else
393         wxFlexGridSizer * sizer         = new wxFlexGridSizer(20,1,0,0);
394 #endif
395 printf("EED interfInformationPanel::interfInformationPanel 5\n");
396         sizer->Add( sizerA                     , 1, wxALL               , 0 );
397 printf("EED interfInformationPanel::interfInformationPanel 5.1\n");
398         sizer->Add( new wxStaticText(this      ,1,_T("Slice Range"))    , 1, wxALL , 0 );
399 printf("EED interfInformationPanel::interfInformationPanel 5.2\n");
400         sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW        , 2 );
401 printf("EED interfInformationPanel::interfInformationPanel 5.3\n");
402         sizer->Add( new wxStaticText(this      ,1,_T("Gray Range"))     , 1, wxALL , 0 );
403 printf("EED interfInformationPanel::interfInformationPanel 5.4\n");
404         sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW        , 2 );
405 printf("EED interfInformationPanel::interfInformationPanel 5.5\n");
406
407         sizer->Add( sizerB                     , 1, wxEXPAND            , 0 );
408
409 printf("EED interfInformationPanel::interfInformationPanel 5.6\n");
410         sizer->Add( _staticTextInformation     , 1, wxEXPAND            , 0 );
411 printf("EED interfInformationPanel::interfInformationPanel 5.7\n");
412         sizer->Add( _grid                      , 1, wxEXPAND            , 0 );
413 printf("EED interfInformationPanel::interfInformationPanel 5.8\n");
414         this->SetSizer( sizer );
415 printf("EED interfInformationPanel::interfInformationPanel 5.9\n");
416         this->SetSize( wxSize(1500,1500) );
417         //this->SetBackgroundColour( wxColour(100,100,100) );
418         this->SetAutoLayout( true );
419 printf("EED interfInformationPanel::interfInformationPanel 5.10\n");
420         this->Layout();
421         //return panel;
422
423 printf("EED interfInformationPanel::interfInformationPanel End\n");
424
425 }
426
427 interfInformationPanel::~interfInformationPanel()
428 {
429 }
430
431
432 void interfInformationPanel::onRangeSliceInformation(wxCommandEvent& event)
433 {
434         int     grayRangeMin    = _mbarrangeRangeInformation->GetStart();
435         int     grayRangeMax    = _mbarrangeRangeInformation->GetEnd();
436         interfMainPanel::getInstance()->SetScalarRange(grayRangeMin,grayRangeMax);
437         interfMainPanel::getInstance()->RefreshInterface();
438 }
439
440
441 void interfInformationPanel::onInformationContourLabels(wxCommandEvent& event){
442         wxBusyCursor wait;
443         FillGridWithContoursInformation();
444 }
445
446
447 void interfInformationPanel::onShowResultImages(wxCommandEvent& event)
448 {
449 //      onExtractInformation( event );
450         int selection        = _informationRadiobox->GetSelection();
451         int minZ             = _mbarrangeSliceInformation->GetStart();
452         int maxZ             = _mbarrangeSliceInformation->GetEnd();
453         int typeContourGroup = _radiolstboxContourGroup->GetSelection();
454         interfMainPanel::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
455 }
456
457
458 void interfInformationPanel::onExtractInformation(wxCommandEvent& event){
459         wxBusyCursor wait;
460         _grid->ClearGrid();
461
462         int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
463         int selection        = _informationRadiobox->GetSelection();
464         int minZ             = _mbarrangeSliceInformation->GetStart();
465         int maxZ             = _mbarrangeSliceInformation->GetEnd();
466         int grayRangeMin     = _mbarrangeRangeInformation->GetStart();
467         int grayRangeMax     = _mbarrangeRangeInformation->GetEnd();
468
469         interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ, grayRangeMin, grayRangeMax);
470 }
471
472 void interfInformationPanel::onSaveResults(wxCommandEvent& event)
473 {
474 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
475 #if wxMAJOR_VERSION <= 2
476         wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxSAVE );
477 #else
478         wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxFD_SAVE );
479 #endif
480         if (dialog.ShowModal() == wxID_OK)
481         {
482                 onExtractInformation( event );
483                 int selection         = _informationRadiobox->GetSelection();
484                 int minZ              = _mbarrangeSliceInformation->GetStart();
485                 int maxZ              = _mbarrangeSliceInformation->GetEnd();
486                 std::string directory = (const char *)(dialog.GetDirectory().mb_str());
487                 std::string namefile  = (const char *)(dialog.GetFilename().mb_str());
488                 std::string filename  = (const char *)(dialog.GetPath().mb_str() );
489                 int typeContourGroup  = _radiolstboxContourGroup->GetSelection();
490                 interfMainPanel::getInstance()->onSaveResults(directory, namefile, filename,
491                         typeContourGroup,
492                         selection,minZ,maxZ,
493                         _XYZValues->GetValue(), _contourImage->GetValue(), _statistics->GetValue());
494         }
495 }
496
497 void interfInformationPanel::FillGridWithContoursInformation(){
498
499         wxString tempString;
500         _grid->ClearGrid();
501         _grid->SetColLabelValue(0, _T("A") );
502         _grid->SetColLabelValue(1, _T("B") );
503         _grid->SetColLabelValue(2, _T("C") );
504         _grid->SetColLabelValue(3, _T("D") );
505         _grid->SetColLabelValue(4, _T("E") );
506         _grid->SetColLabelValue(5, _T("F") );
507         //_instantPanel->getInstant( tempVector );
508
509         int z,sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();//->getSceneManager()->GetImageDataSizeZ();
510         int ii,sizeLstContourThings;
511         for ( z=0 ; z<sizeZ ; z++)
512         {
513
514                 std::vector<std::string> lstContourThings = interfMainPanel::getInstance()->getOutlinesName(z);
515
516                         //this->_modelManager->getOutlinesAtInstant( &instant );
517
518                 sizeLstContourThings = lstContourThings.size();
519                 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
520                 _grid->SetRowLabelValue(z, tempString );
521
522                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
523                 {
524                         //ContourThing **contourthing = lstContourThings[ii];
525                         //tempString = wxString((*contourthing)->getName().c_str(),wxConvUTF8) ;
526                         tempString = wxString(lstContourThings[ii].c_str(),wxConvUTF8) ;
527                         _grid->SetCellValue( z, ii, tempString );
528                 } // for ii
529         }// for z
530
531         // Last line
532         _grid->SetRowLabelValue(sizeZ, _T(" ") );
533         for (ii=0 ; ii<sizeLstContourThings ; ii++)
534         {
535                 _grid->SetCellValue( sizeZ, ii, _T(" ") );
536         } // for ii
537
538 }
539
540 void interfInformationPanel::setStringInfoPanel(wxString tmpString){
541         _staticTextInformation->SetLabel(tmpString);
542 }
543
544 void interfInformationPanel::setRowLabelInfoPanel(int z,wxString tempString){
545         _grid->SetRowLabelValue(z, tempString );
546 }
547
548 int interfInformationPanel::getNumberCols(){
549         return _grid->GetNumberCols();
550 }
551
552 void interfInformationPanel::appendCols(int numcols){
553     _grid->AppendCols(numcols);
554 }
555
556 void interfInformationPanel::setCellValue(int z,int tmpIntA,wxString tempString){
557         _grid->SetCellValue( z, tmpIntA , tempString );
558 }
559
560 void interfInformationPanel::setColLabel(int tmpIntB,wxString tmpTitleString){
561         _grid->SetColLabelValue(tmpIntB, tmpTitleString);
562 }
563
564 wxString interfInformationPanel::getCellValue(int j,int i){
565         return _grid->GetCellValue( j , i );
566 }
567
568 void interfInformationPanel::onContourGroup(wxCommandEvent& event)
569 {
570         printf("EED interfInformationPanel::onContourGroup \n");
571         int contourGroup=_radiolstboxContourGroup->GetSelection();
572         if (contourGroup==3)
573         {
574                 contourGroup=0;
575         }
576         interfMainPanel::getInstance()->SetContourGroup( _radiolstboxContourGroup->GetSelection() );
577 }
578
579 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
580 interfCalibrationPanel:: interfCalibrationPanel(wxWindow * parent)
581 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
582 {
583         double range[2];
584         interfMainPanel::getInstance()->getImageRange(range);
585
586         //Radio buttons
587         wxString options[3];
588         options[0]=_T("mm");
589         options[1]=_T("cm");
590         options[2]=_T("inch");
591
592         _unitsRadiobox = new wxRadioBox(this, -1, _T("Unit of measurement"), wxPoint(2, 25), wxSize(145,45), 3 , options,  3, wxRA_SPECIFY_COLS);
593         _unitsRadiobox->SetSelection(0);
594
595         //The label
596         new wxStaticText(this, wxID_ANY, wxT("Real Size: "),   wxPoint(2, 5));
597
598         //Text Control
599         _size = new wxTextCtrl(this, wxID_ANY, wxT(""),  wxPoint(78,3),   wxSize(70, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
600
601         //The button
602         new wxButton(this, 1, wxT("Calibrate"), wxPoint(78, 70), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
603
604         //Conexion del boton con su respectivo manejador
605         Connect(1, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfCalibrationPanel::onCalibrate);
606
607 }
608
609 interfCalibrationPanel:: ~interfCalibrationPanel()
610 {
611 }
612
613 void interfCalibrationPanel::onCalibrate(wxCommandEvent& event)
614 {
615         wxString size =_size->GetValue();
616         int unit = _unitsRadiobox->GetSelection();
617         interfMainPanel::getInstance()->onCalibration(size, unit);
618 }
619 //------------------------------------------------------------------------------------------------------------
620
621
622
623 //////////////////////////////////////////////////////////////
624
625 interfFlipPanel::interfFlipPanel(wxWindow* parent)
626 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
627 {
628         wxButton *buttonFlipX = new wxButton(this,wxID_ANY,_T("Flip Horizontally"), wxDefaultPosition, wxSize(200,35) );
629         wxButton *buttonFlipY = new wxButton(this,wxID_ANY,_T("Flip Vertically"), wxDefaultPosition, wxSize(200,35) );
630
631         wxString lstOptions[3];
632         lstOptions[0]=_T("Flip selected contours");
633         lstOptions[1]=_T("Flip all contours of actual slice");
634         lstOptions[2]=_T("Flip all contours");
635         _wichContoursRadioBox = new wxRadioBox(this, -1, _T("Transform"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions,  1, wxRA_SPECIFY_COLS);
636         _wichContoursRadioBox->SetSelection(2);
637
638         
639         Connect( buttonFlipX->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipXPressed );
640         Connect( buttonFlipY->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipYPressed ); 
641         
642         wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
643         sizer -> Add( _wichContoursRadioBox, 1, wxGROW );
644         sizer -> Add( buttonFlipX, 1, wxGROW );
645         sizer -> Add( buttonFlipY, 1, wxGROW );
646
647         this->SetSizer( sizer );
648         this->SetAutoLayout( true );
649         this->Layout();
650 }
651
652
653
654
655 interfFlipPanel::~interfFlipPanel(){
656 }
657
658 void interfFlipPanel::onFlipXPressed(wxCommandEvent& event)
659 {
660         std::cout << "interfToolsPanels.cxx  interfFlipPanel::onFlipXPressed     FlipX (btn)" << std::endl;
661         int typeContoursFlip = _wichContoursRadioBox->GetSelection(); 
662         interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 0 );  // type, direction
663 }
664
665 void interfFlipPanel::onFlipYPressed(wxCommandEvent& event)
666 {
667         std::cout << "interfToolsPanels.cxx   interfFlipPanel::onFlipYPressed FlipY  (btn)" << std::endl;
668         int typeContoursFlip = _wichContoursRadioBox->GetSelection(); 
669         interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 1 );  // type, direction
670 }
671
672