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