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