1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #include "interfToolsPanels.h"
27 #include "interfMainPanel.h"
29 interfConfigurationPanel::interfConfigurationPanel(wxWindow * parent)
30 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
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);
36 interfMainPanel::getInstance()->getImageRange(range);
37 //this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
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();
44 int colorwindow = interfMainPanel::getInstance()->getColorWindow();
45 int windowlevel = interfMainPanel::getInstance()->getWindowLevel();
47 int min = (int)floor (range[0]);
48 int max = (int)ceil (range[1]);
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);
54 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolation") );
55 _interpolationCheckBox->SetValue(true);
57 _showTextContourCheckBox = new wxCheckBox(this, -1, _T("Labels") );
58 _showTextContourCheckBox->SetValue(false);
60 _beforContourCheckBox = new wxCheckBox(this, -1, _T("Befor Contour") );
61 _beforContourCheckBox->SetValue(false);
63 _afterContourCheckBox = new wxCheckBox(this, -1, _T("After Contour") );
64 _afterContourCheckBox->SetValue(false);
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);
73 Connect( _withOfContourLine->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction) &interfConfigurationPanel::onWidthOfContour);
74 Connect( _withOfContourLine->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &interfConfigurationPanel::onWidthOfContour);
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 );
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 );
98 wxFlexGridSizer * sizerB1 = new wxFlexGridSizer(2);
99 sizerB1-> Add( jumpBackwareSlice , 1, wxGROW );
100 sizerB1 -> Add( jumpFordwareSlice , 1, wxGROW );
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 );
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 );
120 this->SetSizer( sizer );
122 //panel->SetSize( sizepanel );
124 this->SetAutoLayout( true );
130 interfConfigurationPanel::~interfConfigurationPanel()
134 void interfConfigurationPanel::onWidthOfContour(wxScrollEvent& event)
136 double width = (double)_withOfContourLine->GetValue() / 2.0;
137 interfMainPanel::getInstance()->onWidthOfContour(width);
140 void interfConfigurationPanel::onBrigthnessColorWindowLevel(wxScrollEvent& event){
141 int colorwindow = _brithtnessColorLevel->GetValue();
142 int windowlevel = _brithtnessWindowLevel->GetValue();
143 interfMainPanel::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
146 void interfConfigurationPanel::OnInterpolation(wxCommandEvent& event)
148 interfMainPanel::getInstance()->onInterpolation(_interpolationCheckBox->GetValue());
151 void interfConfigurationPanel::OnBeforAfterContour(wxCommandEvent& event)
153 interfMainPanel::getInstance()->onBeforAfterContour(_beforContourCheckBox->GetValue() , _afterContourCheckBox->GetValue() );
156 void interfConfigurationPanel::OnShowTextContour(wxCommandEvent& event)
158 interfMainPanel::getInstance()->onShowTextContour(_showTextContourCheckBox->GetValue() );
161 void interfConfigurationPanel::OnBackwareSlice(wxCommandEvent& event)
163 interfMainPanel::getInstance()->onJumpSlice( -_jumpSpinCtrl->GetValue(), _shiftSpinCtrl->GetValue() );
166 void interfConfigurationPanel::OnFordwareSlice(wxCommandEvent& event)
168 interfMainPanel::getInstance()->onJumpSlice( _jumpSpinCtrl->GetValue(), _shiftSpinCtrl->GetValue() );
173 ** Begin of the spread panel
176 interfSpreadPanel::interfSpreadPanel(wxWindow* parent)
177 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
180 //wxPanel *panel = new wxPanel(parent,-1);
182 //_contourPropagation = new ContourPropagation();
184 //wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("",wxConvUTF8));
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);
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);
197 wxButton *spreadGoBtn = new wxButton(this,-1,_T("Go"),wxDefaultPosition, wxDefaultSize);
198 _staticTextSpread = new wxStaticText(this,-1,_T(" "));
200 _wxtextctrlSpread = new wxTextCtrl(this,-1, _T(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
201 _wxtextctrlSpread->SetEditable(false);
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 );
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 );
218 this->SetSizer( sizer );
219 //this->SetSize( wxDefaultSize );
220 this->SetAutoLayout( true );
225 interfSpreadPanel::~interfSpreadPanel(){
228 void interfSpreadPanel::onSpreadReset(wxCommandEvent& event){
229 setStringSpread(" ");
230 _wxtextctrlSpread->SetValue(wxString("",wxConvUTF8));
231 interfMainPanel::getInstance()->resetAppend();
234 void interfSpreadPanel::onSpreadAdd(wxCommandEvent& event){
235 interfMainPanel::getInstance()->onSpreadAdd();
238 void interfSpreadPanel::onSpreadAddAll(wxCommandEvent& event){
239 interfMainPanel::getInstance()->onSpreadAddAll();
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);
250 void interfSpreadPanel::appendStringSpread(std::string val){
253 //newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice );
255 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
256 #if wxMAJOR_VERSION <= 2
257 newstring.append(wxString(_wxtextctrlSpread->GetValue(),wxConvUTF8));
259 newstring.append( _wxtextctrlSpread->GetValue() );
263 newstring.append(wxString(" ",wxConvUTF8));
264 newstring.append(wxString(val.c_str(),wxConvUTF8));
265 _wxtextctrlSpread->SetValue(newstring);
268 void interfSpreadPanel::setStringSpread(std::string stringtemp){
270 wxString newstring(stringtemp.c_str(),wxConvUTF8);
271 //_wxtextctrlSpread->SetEditable(true);
272 _staticTextSpread->SetLabel(newstring);
273 //_wxtextctrlSpread->SetEditable(false);
277 ** Begin of information panel
279 interfInformationPanel::interfInformationPanel(wxWindow * parent)
280 //: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
281 : wxPanel(parent, -1)
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);
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 );
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);
307 wxButton *informationContourLabelsBtn = new wxButton(this,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
308 #if wxMAJOR_VERSION <= 2
309 informationContourLabelsBtn->SetEventHandler( this );
311 // informationContourLabelsBtn->SetEventHandler( this );
313 Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onInformationContourLabels );
315 wxButton *statisticsContourBtn = new wxButton(this,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
316 #if wxMAJOR_VERSION <= 2
317 statisticsContourBtn->SetEventHandler( this );
319 //statisticsContourBtn->SetEventHandler( this );
321 Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onExtractInformation );
323 wxButton *showResultImagesBtn = new wxButton(this,-1,_T("Show result images"),wxDefaultPosition, wxSize(140,35) );
324 #if wxMAJOR_VERSION <= 2
325 showResultImagesBtn->SetEventHandler( this );
327 //showResultImagesBtn->SetEventHandler( this );
329 Connect( showResultImagesBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onShowResultImages );
331 wxButton *saveResultsBtn = new wxButton(this,-1,_T("Save Results"),wxDefaultPosition, wxSize(140,35) );
332 #if wxMAJOR_VERSION <= 2
333 saveResultsBtn->SetEventHandler( this );
335 //EED saveResultsBtn->SetEventHandler( this );
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 );
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,
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++)
387 _grid->SetRowLabelValue(i, _T(" ") );
389 // _grid->SetColLabelSize(0);
390 FillGridWithContoursInformation();
392 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
393 #if wxMAJOR_VERSION <= 2
394 wxFlexGridSizer * sizerSave = new wxFlexGridSizer(2,2);
396 wxFlexGridSizer * sizerSave = new wxFlexGridSizer(2,2,0,0);
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 );
403 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
404 #if wxMAJOR_VERSION <= 2
405 wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
407 wxFlexGridSizer * sizerA = new wxFlexGridSizer(1,10,0,0);
409 sizerA->Add( _informationRadiobox, 1, wxALL, 2 );
410 sizerA->Add( _radiolstboxContourGroup, 1, wxALL, 2 );
411 sizerA->Add( sizerSave, 1, wxALL, 2 );
414 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
415 #if wxMAJOR_VERSION <= 2
416 wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
418 wxFlexGridSizer * sizerB = new wxFlexGridSizer(1,4,0,0);
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 );
425 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
426 #if wxMAJOR_VERSION <= 2
427 wxFlexGridSizer * sizer = new wxFlexGridSizer(1,8);
429 wxFlexGridSizer * sizer = new wxFlexGridSizer(20,1,0,0);
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 );
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 );
447 interfInformationPanel::~interfInformationPanel()
452 void interfInformationPanel::onRangeSliceInformation(wxCommandEvent& event)
454 int grayRangeMin = _mbarrangeRangeInformation->GetStart();
455 int grayRangeMax = _mbarrangeRangeInformation->GetEnd();
456 interfMainPanel::getInstance()->SetScalarRange(grayRangeMin,grayRangeMax);
457 interfMainPanel::getInstance()->RefreshInterface();
461 void interfInformationPanel::onInformationContourLabels(wxCommandEvent& event){
463 FillGridWithContoursInformation();
467 void interfInformationPanel::onShowResultImages(wxCommandEvent& event)
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);
478 void interfInformationPanel::onExtractInformation(wxCommandEvent& event){
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();
489 interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ, grayRangeMin, grayRangeMax);
492 void interfInformationPanel::onSaveResults(wxCommandEvent& event)
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 );
498 wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxFD_SAVE );
500 if (dialog.ShowModal() == wxID_OK)
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,
513 _XYZValues->GetValue(), _contourImage->GetValue(), _statistics->GetValue());
517 void interfInformationPanel::FillGridWithContoursInformation(){
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 );
529 int z,sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();//->getSceneManager()->GetImageDataSizeZ();
530 int ii,sizeLstContourThings;
531 for ( z=0 ; z<sizeZ ; z++)
534 std::vector<std::string> lstContourThings = interfMainPanel::getInstance()->getOutlinesName(z);
536 //this->_modelManager->getOutlinesAtInstant( &instant );
538 sizeLstContourThings = lstContourThings.size();
539 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
540 _grid->SetRowLabelValue(z, tempString );
542 for (ii=0 ; ii<sizeLstContourThings ; ii++)
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 );
552 _grid->SetRowLabelValue(sizeZ, _T(" ") );
553 for (ii=0 ; ii<sizeLstContourThings ; ii++)
555 _grid->SetCellValue( sizeZ, ii, _T(" ") );
560 void interfInformationPanel::setStringInfoPanel(wxString tmpString){
561 _staticTextInformation->SetLabel(tmpString);
564 void interfInformationPanel::setRowLabelInfoPanel(int z,wxString tempString){
565 _grid->SetRowLabelValue(z, tempString );
568 int interfInformationPanel::getNumberCols(){
569 return _grid->GetNumberCols();
572 void interfInformationPanel::appendCols(int numcols){
573 _grid->AppendCols(numcols);
576 void interfInformationPanel::setCellValue(int z,int tmpIntA,wxString tempString){
577 _grid->SetCellValue( z, tmpIntA , tempString );
580 void interfInformationPanel::setColLabel(int tmpIntB,wxString tmpTitleString){
581 _grid->SetColLabelValue(tmpIntB, tmpTitleString);
584 wxString interfInformationPanel::getCellValue(int j,int i){
585 return _grid->GetCellValue( j , i );
588 void interfInformationPanel::onContourGroup(wxCommandEvent& event)
590 printf("EED interfInformationPanel::onContourGroup \n");
591 int contourGroup=_radiolstboxContourGroup->GetSelection();
596 interfMainPanel::getInstance()->SetContourGroup( _radiolstboxContourGroup->GetSelection() );
599 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
600 interfCalibrationPanel:: interfCalibrationPanel(wxWindow * parent)
601 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
604 interfMainPanel::getInstance()->getImageRange(range);
610 options[2]=_T("inch");
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);
616 new wxStaticText(this, wxID_ANY, wxT("Real Size: "), wxPoint(2, 5));
619 _size = new wxTextCtrl(this, wxID_ANY, wxT(""), wxPoint(78,3), wxSize(70, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
622 new wxButton(this, 1, wxT("Calibrate"), wxPoint(78, 70), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
624 //Conexion del boton con su respectivo manejador
625 Connect(1, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfCalibrationPanel::onCalibrate);
629 interfCalibrationPanel:: ~interfCalibrationPanel()
633 void interfCalibrationPanel::onCalibrate(wxCommandEvent& event)
635 wxString size =_size->GetValue();
636 int unit = _unitsRadiobox->GetSelection();
637 interfMainPanel::getInstance()->onCalibration(size, unit);
639 //------------------------------------------------------------------------------------------------------------
643 //////////////////////////////////////////////////////////////
645 interfFlipPanel::interfFlipPanel(wxWindow* parent)
646 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
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) );
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);
659 Connect( buttonFlipX->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipXPressed );
660 Connect( buttonFlipY->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipYPressed );
662 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
663 sizer -> Add( _wichContoursRadioBox, 1, wxGROW );
664 sizer -> Add( buttonFlipX, 1, wxGROW );
665 sizer -> Add( buttonFlipY, 1, wxGROW );
667 this->SetSizer( sizer );
668 this->SetAutoLayout( true );
675 interfFlipPanel::~interfFlipPanel(){
678 void interfFlipPanel::onFlipXPressed(wxCommandEvent& event)
680 std::cout << "interfToolsPanels.cxx interfFlipPanel::onFlipXPressed FlipX (btn)" << std::endl;
681 int typeContoursFlip = _wichContoursRadioBox->GetSelection();
682 interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 0 ); // type, direction
685 void interfFlipPanel::onFlipYPressed(wxCommandEvent& event)
687 std::cout << "interfToolsPanels.cxx interfFlipPanel::onFlipYPressed FlipY (btn)" << std::endl;
688 int typeContoursFlip = _wichContoursRadioBox->GetSelection();
689 interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 1 ); // type, direction