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