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, 1 , 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(true);
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 printf("EED interfInformationPanel::interfInformationPanel Start\n");
284 //wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
285 wxString lstOptions[4];
286 lstOptions[0]=_T("Current Slice");
287 lstOptions[1]=_T("Range Slices");
288 // lstOptions[2]=_T("All Slices");
289 _informationRadiobox = new wxRadioBox(this, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS);
291 wxString lstOptContOperation[5];
292 lstOptContOperation[0]=_T("AND");
293 lstOptContOperation[1]=_T("OR");
294 lstOptContOperation[2]=_T("XOR");
295 lstOptContOperation[3]=_T("ALL");
296 _radiolstboxContourGroup = new wxRadioBox(this, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
297 _radiolstboxContourGroup->SetSelection(1);
298 Connect( _radiolstboxContourGroup->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &interfInformationPanel::onContourGroup );
300 printf("EED interfInformationPanel::interfInformationPanel 1\n");
303 _XYZValues = new wxCheckBox(this, -1, _T("Save Contour Values") );
304 _XYZValues->SetValue(true);
305 _contourImage = new wxCheckBox(this, -1, _T("Extract Contours as Images") );
306 _contourImage->SetValue(true);
307 _statistics = new wxCheckBox(this, -1, _T("Save Statistics") );
308 _statistics->SetValue(true);
311 wxButton *informationContourLabelsBtn = new wxButton(this,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
312 #if wxMAJOR_VERSION <= 2
313 informationContourLabelsBtn->SetEventHandler( this );
315 // informationContourLabelsBtn->SetEventHandler( this );
316 printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo informationContourLabelsBtn->SetEventHandler \n");
318 Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onInformationContourLabels );
320 wxButton *statisticsContourBtn = new wxButton(this,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
321 #if wxMAJOR_VERSION <= 2
322 statisticsContourBtn->SetEventHandler( this );
324 //statisticsContourBtn->SetEventHandler( this );
325 printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo statisticsContourBtn->SetEventHandler \n");
327 Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onExtractInformation );
329 wxButton *showResultImagesBtn = new wxButton(this,-1,_T("Show result images"),wxDefaultPosition, wxSize(140,35) );
330 #if wxMAJOR_VERSION <= 2
331 showResultImagesBtn->SetEventHandler( this );
333 //showResultImagesBtn->SetEventHandler( this );
334 printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo showResultImagesBtn->SetEventHandler \n");
336 Connect( showResultImagesBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onShowResultImages );
338 wxButton *saveResultsBtn = new wxButton(this,-1,_T("Save Results"),wxDefaultPosition, wxSize(140,35) );
339 #if wxMAJOR_VERSION <= 2
340 saveResultsBtn->SetEventHandler( this );
342 //EED saveResultsBtn->SetEventHandler( this );
343 printf("EED interfInformationPanel::interfInformationPanel OOOjjjooooooo saveResultsBtn->SetEventHandler \n");
346 Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onSaveResults );
348 int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
350 //_theViewPanel->getSceneManager()->GetImageDataSizeZ();
351 _mbarrangeSliceInformation = new mBarRange(this,65,65);
352 _mbarrangeSliceInformation->SetMin(0);
353 _mbarrangeSliceInformation->SetStart(0);
354 _mbarrangeSliceInformation->SetOrientation( true );
355 _mbarrangeSliceInformation->setActiveStateTo(true);
356 _mbarrangeSliceInformation->setVisibleLabels( true );
357 _mbarrangeSliceInformation->setDeviceEndMargin(10);
358 _mbarrangeSliceInformation->setRepresentedValues( 0 , sizeZ-1 );
359 _mbarrangeSliceInformation->setDeviceBlitStart(10,10);
360 _mbarrangeSliceInformation->setIfWithActualDrawed( false );
361 _mbarrangeSliceInformation->SetStart( 0 );
362 _mbarrangeSliceInformation->SetEnd( sizeZ-1 );
365 interfMainPanel::getInstance()->getImageRange(range);
366 printf("EED interfInformationPanel::interfInformationPanel 2\n");
368 int min = (int)floor (range[0]);
369 int max = (int)ceil (range[1]);
371 _mbarrangeRangeInformation = new mBarRange(this,65,65);
372 _mbarrangeRangeInformation->SetMin(0);
373 _mbarrangeRangeInformation->SetStart(0);
374 _mbarrangeRangeInformation->SetOrientation( true );
375 _mbarrangeRangeInformation->setActiveStateTo(true);
376 _mbarrangeRangeInformation->setVisibleLabels( true );
377 _mbarrangeRangeInformation->setDeviceEndMargin(10);
378 _mbarrangeRangeInformation->setRepresentedValues( min , max );
379 _mbarrangeRangeInformation->setDeviceBlitStart(10,10);
380 _mbarrangeRangeInformation->setIfWithActualDrawed( false );
381 _mbarrangeRangeInformation->SetStart( min );
382 _mbarrangeRangeInformation->SetEnd( max );
384 // _mbarrangeSliceInformation->PushEventHandler(this);
385 // Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
386 // Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
387 Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
388 Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
389 // Connect(_mbarrangeRangeInformation->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
390 Connect(_mbarrangeRangeInformation->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &interfInformationPanel::onRangeSliceInformation );
393 printf("EED interfInformationPanel::interfInformationPanel 3\n");
394 _staticTextInformation = new wxStaticText(this,-1,_T(" "));
395 _grid = new wxGrid( this,
398 wxSize( 200, 250 ) );
399 int i,gridCol=10,gridRow=sizeZ+2;
400 _grid->CreateGrid( 0, 0 );
401 _grid->AppendRows(gridRow);
402 _grid->AppendCols(gridCol);
403 for (i=0;i<gridRow;i++)
405 _grid->SetRowLabelValue(i, _T(" ") );
407 // _grid->SetColLabelSize(0);
408 FillGridWithContoursInformation();
411 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
412 #if wxMAJOR_VERSION <= 2
413 wxFlexGridSizer * sizerSave = new wxFlexGridSizer(2,2);
415 wxFlexGridSizer * sizerSave = new wxFlexGridSizer(2,2,0,0);
417 sizerSave -> Add( new wxStaticText(this,-1,_T("Save Options: ")) , 1, wxGROW );
418 sizerSave->Add( _XYZValues, 1, wxALL, 2 );
419 sizerSave->Add( _statistics, 1, wxALL, 2 );
420 sizerSave->Add( _contourImage, 1, wxALL, 2 );
423 printf("EED interfInformationPanel::interfInformationPanel 4\n");
424 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
425 #if wxMAJOR_VERSION <= 2
426 wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
428 wxFlexGridSizer * sizerA = new wxFlexGridSizer(1,10,0,0);
430 sizerA->Add( _informationRadiobox, 1, wxALL, 2 );
431 sizerA->Add( _radiolstboxContourGroup, 1, wxALL, 2 );
432 sizerA->Add( sizerSave, 1, wxALL, 2 );
435 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
436 #if wxMAJOR_VERSION <= 2
437 wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
439 wxFlexGridSizer * sizerB = new wxFlexGridSizer(1,4,0,0);
441 sizerB->Add( informationContourLabelsBtn, 1, wxALL, 2 );
442 sizerB->Add( statisticsContourBtn, 1, wxALL, 2 );
443 sizerB->Add( showResultImagesBtn, 1, wxALL, 2 );
444 sizerB->Add( saveResultsBtn, 1, wxALL, 2 );
446 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
447 #if wxMAJOR_VERSION <= 2
448 wxFlexGridSizer * sizer = new wxFlexGridSizer(1,8);
450 wxFlexGridSizer * sizer = new wxFlexGridSizer(20,1,0,0);
452 printf("EED interfInformationPanel::interfInformationPanel 5\n");
453 sizer->Add( sizerA , 1, wxALL , 0 );
454 printf("EED interfInformationPanel::interfInformationPanel 5.1\n");
455 sizer->Add( new wxStaticText(this ,1,_T("Slice Range")) , 1, wxALL , 0 );
456 printf("EED interfInformationPanel::interfInformationPanel 5.2\n");
457 sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
458 printf("EED interfInformationPanel::interfInformationPanel 5.3\n");
459 sizer->Add( new wxStaticText(this ,1,_T("Gray Range")) , 1, wxALL , 0 );
460 printf("EED interfInformationPanel::interfInformationPanel 5.4\n");
461 sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
464 sizer->Add( sizerB , 1, wxEXPAND , 0 );
465 sizer->Add( _staticTextInformation , 1, wxEXPAND , 0 );
466 sizer->Add( _grid , 1, wxEXPAND , 0 );
467 this->SetSizer( sizer );
468 this->SetSize( wxSize(1500,1500) );
469 this->SetAutoLayout( true );
470 printf("EED interfInformationPanel::interfInformationPanel 5.10\n");
474 printf("EED interfInformationPanel::interfInformationPanel End\n");
478 interfInformationPanel::~interfInformationPanel()
483 void interfInformationPanel::onRangeSliceInformation(wxCommandEvent& event)
485 int grayRangeMin = _mbarrangeRangeInformation->GetStart();
486 int grayRangeMax = _mbarrangeRangeInformation->GetEnd();
487 interfMainPanel::getInstance()->SetScalarRange(grayRangeMin,grayRangeMax);
488 interfMainPanel::getInstance()->RefreshInterface();
492 void interfInformationPanel::onInformationContourLabels(wxCommandEvent& event){
494 FillGridWithContoursInformation();
498 void interfInformationPanel::onShowResultImages(wxCommandEvent& event)
500 // onExtractInformation( event );
501 int selection = _informationRadiobox->GetSelection();
502 int minZ = _mbarrangeSliceInformation->GetStart();
503 int maxZ = _mbarrangeSliceInformation->GetEnd();
504 int typeContourGroup = _radiolstboxContourGroup->GetSelection();
505 interfMainPanel::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
509 void interfInformationPanel::onExtractInformation(wxCommandEvent& event){
513 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
514 int selection = _informationRadiobox->GetSelection();
515 int minZ = _mbarrangeSliceInformation->GetStart();
516 int maxZ = _mbarrangeSliceInformation->GetEnd();
517 int grayRangeMin = _mbarrangeRangeInformation->GetStart();
518 int grayRangeMax = _mbarrangeRangeInformation->GetEnd();
520 interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ, grayRangeMin, grayRangeMax);
523 void interfInformationPanel::onSaveResults(wxCommandEvent& event)
525 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
526 #if wxMAJOR_VERSION <= 2
527 wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxSAVE );
529 wxFileDialog dialog(this, _T("Choose a filename"), _T(""), _T(""), wxFileSelectorDefaultWildcardStr, wxFD_SAVE );
531 if (dialog.ShowModal() == wxID_OK)
533 onExtractInformation( event );
534 int selection = _informationRadiobox->GetSelection();
535 int minZ = _mbarrangeSliceInformation->GetStart();
536 int maxZ = _mbarrangeSliceInformation->GetEnd();
537 std::string directory = (const char *)(dialog.GetDirectory().mb_str());
538 std::string namefile = (const char *)(dialog.GetFilename().mb_str());
539 std::string filename = (const char *)(dialog.GetPath().mb_str() );
540 int typeContourGroup = _radiolstboxContourGroup->GetSelection();
541 interfMainPanel::getInstance()->onSaveResults(directory, namefile, filename,
544 _XYZValues->GetValue(), _contourImage->GetValue(), _statistics->GetValue());
548 void interfInformationPanel::FillGridWithContoursInformation(){
552 _grid->SetColLabelValue(0, _T("A") );
553 _grid->SetColLabelValue(1, _T("B") );
554 _grid->SetColLabelValue(2, _T("C") );
555 _grid->SetColLabelValue(3, _T("D") );
556 _grid->SetColLabelValue(4, _T("E") );
557 _grid->SetColLabelValue(5, _T("F") );
558 //_instantPanel->getInstant( tempVector );
560 int z,sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();//->getSceneManager()->GetImageDataSizeZ();
561 int ii,sizeLstContourThings;
562 for ( z=0 ; z<sizeZ ; z++)
565 std::vector<std::string> lstContourThings = interfMainPanel::getInstance()->getOutlinesName(z);
567 //this->_modelManager->getOutlinesAtInstant( &instant );
569 sizeLstContourThings = lstContourThings.size();
570 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
571 _grid->SetRowLabelValue(z, tempString );
573 for (ii=0 ; ii<sizeLstContourThings ; ii++)
575 //ContourThing **contourthing = lstContourThings[ii];
576 //tempString = wxString((*contourthing)->getName().c_str(),wxConvUTF8) ;
577 tempString = wxString(lstContourThings[ii].c_str(),wxConvUTF8) ;
578 _grid->SetCellValue( z, ii, tempString );
583 _grid->SetRowLabelValue(sizeZ, _T(" ") );
584 for (ii=0 ; ii<sizeLstContourThings ; ii++)
586 _grid->SetCellValue( sizeZ, ii, _T(" ") );
591 void interfInformationPanel::setStringInfoPanel(wxString tmpString){
592 _staticTextInformation->SetLabel(tmpString);
595 void interfInformationPanel::setRowLabelInfoPanel(int z,wxString tempString){
596 _grid->SetRowLabelValue(z, tempString );
599 int interfInformationPanel::getNumberCols(){
600 return _grid->GetNumberCols();
603 void interfInformationPanel::appendCols(int numcols){
604 _grid->AppendCols(numcols);
607 void interfInformationPanel::setCellValue(int z,int tmpIntA,wxString tempString){
608 _grid->SetCellValue( z, tmpIntA , tempString );
611 void interfInformationPanel::setColLabel(int tmpIntB,wxString tmpTitleString){
612 _grid->SetColLabelValue(tmpIntB, tmpTitleString);
615 wxString interfInformationPanel::getCellValue(int j,int i){
616 return _grid->GetCellValue( j , i );
619 void interfInformationPanel::onContourGroup(wxCommandEvent& event)
621 printf("EED interfInformationPanel::onContourGroup \n");
622 int contourGroup=_radiolstboxContourGroup->GetSelection();
627 interfMainPanel::getInstance()->SetContourGroup( _radiolstboxContourGroup->GetSelection() );
630 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
631 interfCalibrationPanel:: interfCalibrationPanel(wxWindow * parent)
632 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
635 interfMainPanel::getInstance()->getImageRange(range);
641 options[2]=_T("inch");
643 _unitsRadiobox = new wxRadioBox(this, -1, _T("Unit of measurement"), wxPoint(2, 25), wxSize(145,45), 3 , options, 3, wxRA_SPECIFY_COLS);
644 _unitsRadiobox->SetSelection(0);
647 new wxStaticText(this, wxID_ANY, wxT("Real Size: "), wxPoint(2, 5));
650 _size = new wxTextCtrl(this, wxID_ANY, wxT(""), wxPoint(78,3), wxSize(70, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
653 new wxButton(this, 1, wxT("Calibrate"), wxPoint(78, 70), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
655 //Conexion del boton con su respectivo manejador
656 Connect(1, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfCalibrationPanel::onCalibrate);
660 interfCalibrationPanel:: ~interfCalibrationPanel()
664 void interfCalibrationPanel::onCalibrate(wxCommandEvent& event)
666 wxString size =_size->GetValue();
667 int unit = _unitsRadiobox->GetSelection();
668 interfMainPanel::getInstance()->onCalibration(size, unit);
670 //------------------------------------------------------------------------------------------------------------
674 //////////////////////////////////////////////////////////////
676 interfFlipPanel::interfFlipPanel(wxWindow* parent)
677 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
679 wxButton *buttonFlipX = new wxButton(this,wxID_ANY,_T("Flip Horizontally"), wxDefaultPosition, wxSize(200,35) );
680 wxButton *buttonFlipY = new wxButton(this,wxID_ANY,_T("Flip Vertically"), wxDefaultPosition, wxSize(200,35) );
682 wxString lstOptions[3];
683 lstOptions[0]=_T("Flip selected contours");
684 lstOptions[1]=_T("Flip all contours of actual slice");
685 lstOptions[2]=_T("Flip all contours");
686 _wichContoursRadioBox = new wxRadioBox(this, -1, _T("Transform"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 1, wxRA_SPECIFY_COLS);
687 _wichContoursRadioBox->SetSelection(2);
690 Connect( buttonFlipX->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipXPressed );
691 Connect( buttonFlipY->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfFlipPanel::onFlipYPressed );
693 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
694 sizer -> Add( _wichContoursRadioBox, 1, wxGROW );
695 sizer -> Add( buttonFlipX, 1, wxGROW );
696 sizer -> Add( buttonFlipY, 1, wxGROW );
698 this->SetSizer( sizer );
699 this->SetAutoLayout( true );
706 interfFlipPanel::~interfFlipPanel(){
709 void interfFlipPanel::onFlipXPressed(wxCommandEvent& event)
711 std::cout << "interfToolsPanels.cxx interfFlipPanel::onFlipXPressed FlipX (btn)" << std::endl;
712 int typeContoursFlip = _wichContoursRadioBox->GetSelection();
713 interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 0 ); // type, direction
716 void interfFlipPanel::onFlipYPressed(wxCommandEvent& event)
718 std::cout << "interfToolsPanels.cxx interfFlipPanel::onFlipYPressed FlipY (btn)" << std::endl;
719 int typeContoursFlip = _wichContoursRadioBox->GetSelection();
720 interfMainPanel::getInstance()->FlipContours( typeContoursFlip , 1 ); // type, direction