1 #include "interfSegmentationPanels.h"
2 #include "interfMainPanel.h"
4 interfSegmentationPanelVTK::interfSegmentationPanelVTK(wxWindow * parent)
5 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
7 int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
8 //int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
10 //_theViewPanel->getSceneManager()->GetImageDataRange(range);
11 interfMainPanel::getInstance()->GetImageDataRange(range);
13 wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) );
14 wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
15 _isovalue = new wxSlider(this, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
16 _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
17 wxString lstOptions[3];
18 lstOptions[0]=_T("A");
19 lstOptions[1]=_T("B");
20 lstOptions[2]=_T("C");
21 methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
22 methodRadiobox->SetSelection(2);
23 _staticTextSegmentation = new wxStaticText(this,-1,_T(" "));
25 _mbarrange = new mBarRange(this,70, 65);
26 _mbarrange->SetMin(0);
27 _mbarrange->SetStart(0);
29 _mbarrange->SetOrientation( true );
30 _mbarrange->setActiveStateTo(true);
31 _mbarrange->setVisibleLabels( true );
32 _mbarrange->setDeviceEndMargin(10);
33 _mbarrange->setRepresentedValues( 0 , sizeZ );
34 _mbarrange->setDeviceBlitStart(10,10);
35 _mbarrange->setIfWithActualDrawed( false );
36 _mbarrange->SetStart( 0 );
37 _mbarrange->SetEnd( sizeZ );
39 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
40 sizer->Add( new wxStaticText(this, -1, _T("Isovalue (Gray level)")), 1, wxGROW );
41 sizer->Add( _isovalue, 1, wxGROW );
42 sizer->Add( methodRadiobox , 1, wxGROW );
43 sizer->Add( new wxStaticText(this, -1 ,_T("Sampling (%)")), 1, wxGROW );
44 sizer->Add( _sampling, 1, wxGROW );
45 sizer->Add( segmentationOneSliceBtn, 1, wxGROW );
46 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
47 sizer->Add( _staticTextSegmentation, 1, wxGROW );
48 sizer->Add( segmentationAllSliceBtn, 1, wxGROW );
49 sizer->Add( _mbarrange, 1, wxGROW );
51 this->SetSizer( sizer );
52 // panel->SetSize( sizePanel );
53 this->SetSize( wxDefaultSize );
54 this->SetAutoLayout( true );
57 //_segmentationFrame->SetEventHandler( this );
58 //segmentationOneSliceBtn->SetEventHandler( this );
59 //segmentationAllSliceBtn->SetEventHandler( this );
60 //panel->SetEventHandler(this);
61 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationOneSlice);
62 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationAllSlice);
66 interfSegmentationPanelVTK::~interfSegmentationPanelVTK()
71 ** Responds to the events of the buttons, when the same panel is responsible for it. It gets the name
72 ** of the button corresponding to the method that has to be executed,
73 ** it uses attribute eventHandler to call the methods define by the application.
74 ** see setEventHandler(wxEventHandler*)
77 void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event){
78 if(segmentPanelITK == NULL) {
79 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
81 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
82 segmentPanelITK->SetSizer(flexsizer, true);
83 segmentPanelITK->SetAutoLayout( true );
85 wxPanel* panel = new wxPanel(this, -1);//contourevent->getSegmentationPanelITK(segmentPanelITK);
87 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
88 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
90 flexsizer->Add(stattext, wxALIGN_CENTER | wxALIGN_CENTRE);
91 flexsizer->Add(panel, wxEXPAND);
92 segmentPanelITK->Layout();
94 interfMainPanel::getInstance()->showPanel(segmentPanelITK);
95 //contourevent->showAxis(true);
99 void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event )
101 int isovalue = _isovalue->GetValue();
102 int sampling = _sampling->GetValue();
103 int method = methodRadiobox->GetSelection();
104 interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
107 void interfSegmentationPanelVTK::onSegmentationAllSlice( wxCommandEvent& event )
109 int minZ=_mbarrange->GetStart();
110 int maxZ=_mbarrange->GetEnd();
112 int isovalue = _isovalue->GetValue();
113 int sampling = _sampling->GetValue();
114 int method = methodRadiobox->GetSelection();
116 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);
119 void interfSegmentationPanelVTK::setLabel(wxString tmpString){
120 _staticTextSegmentation->SetLabel(tmpString);
123 ** start of new implementation
124 ** interfSegmentationPanelITK
126 interfSegmentationPanelITK::interfSegmentationPanelITK(wxWindow * parent)
127 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
129 // int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
130 //int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
132 //_theViewPanel->getSceneManager()->GetImageDataRange(range);
133 interfMainPanel::getInstance()->GetImageDataRange(range);
136 //wxStaticText * distance =
137 new wxStaticText(this, wxID_ANY, wxT("Initial Distance"), wxPoint(5, 5));
138 //wxStaticText * sigma =
139 new wxStaticText(this, wxID_ANY, wxT("Sigma"), wxPoint(5, 30));
140 //wxStaticText * alfa =
141 new wxStaticText(this, wxID_ANY, wxT("Sigmoid Alfa"), wxPoint(5, 55));
142 //wxStaticText * beta =
143 new wxStaticText(this, wxID_ANY, wxT("Sigmoid Beta"), wxPoint(5, 80));
144 //wxStaticText * propagation =
145 new wxStaticText(this, wxID_ANY, wxT("Propagation Scaling"),wxPoint(5, 105));
146 //wxStaticText * iterations =
147 new wxStaticText(this, wxID_ANY, wxT("Iterations"), wxPoint(5, 130));
148 //wxStaticText * infStrength =
149 new wxStaticText(this, wxID_ANY, wxT("Inflation Strength"), wxPoint(5, 155));
153 _distance = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,5), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
154 _sigma = new wxTextCtrl(this, wxID_ANY, wxT("1.2"), wxPoint(98,30), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
155 _alfa = new wxTextCtrl(this, wxID_ANY, wxT("-1.0"), wxPoint(98,55), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
156 _beta = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,80), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
157 _propagation = new wxTextCtrl(this, wxID_ANY, wxT("6.0"), wxPoint(98,105), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
158 _iterations = new wxTextCtrl(this, wxID_ANY, wxT("800"), wxPoint(98,130), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
159 _infStrength = new wxTextCtrl(this, wxID_ANY, wxT("3.0"), wxPoint(98,155), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
163 new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
165 //Conexion del boton con su respectivo manejador
166 Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfSegmentationPanelITK::onSegmentationOneSlice);
170 interfSegmentationPanelITK::~interfSegmentationPanelITK(){
174 void interfSegmentationPanelITK::onSegmentationOneSlice( wxCommandEvent& event )
176 wxString distanc=_distance->GetValue();
177 wxString sigm=_sigma->GetValue();
178 wxString alf=_alfa->GetValue();
179 wxString bet=_beta->GetValue();
180 wxString prop=_propagation->GetValue();
181 wxString iter=_iterations->GetValue();
182 wxString infS=_infStrength->GetValue();
184 interfMainPanel::getInstance()->onSegmentationOneSliceITK(distanc, sigm, alf, bet, prop, iter, infS);
187 void interfSegmentationPanelITK::onSegmentationAllSlice( wxCommandEvent& event )
190 /*int minZ=_mbarrange->GetStart();
191 int maxZ=_mbarrange->GetEnd();
193 int isovalue = _isovalue->GetValue();
194 int sampling = _sampling->GetValue();
195 int method = methodRadiobox->GetSelection();
198 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);*/
202 //------------------------------------------------------------------------------------------------------------
206 ** Begin of the mirror panel
209 interfMirrorPanel::interfMirrorPanel(wxWindow* parent)
210 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
212 wxButton *axisShowBtn = new wxButton(this,wxID_ANY,_T("Show Axis"), wxDefaultPosition, wxSize(200,35) );
213 wxButton *axisHideBtn = new wxButton(this,wxID_ANY,_T("Hide Axis"), wxDefaultPosition, wxSize(200,35) );
214 wxButton *mirrorGoBtn = new wxButton(this,wxID_ANY,_T("Mirror Contour"), wxDefaultPosition, wxSize(200,35) );
215 _thickness = new wxSlider(this, -1, 4, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
217 Connect( axisShowBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisShow );
218 Connect( axisHideBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisHide );
219 Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo );
221 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
222 sizer -> Add( axisShowBtn, 1, wxGROW );
223 sizer -> Add( axisHideBtn, 1, wxGROW );
224 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
225 sizer -> Add( new wxStaticText(this,-1,_T("Thickness")) , 1, wxGROW );
226 sizer -> Add( _thickness, 1, wxGROW );
227 sizer -> Add( mirrorGoBtn, 1, wxGROW );
229 this->SetSizer( sizer );
230 this->SetAutoLayout( true );
234 interfMirrorPanel::~interfMirrorPanel(){
237 void interfMirrorPanel::onAxisShow(wxCommandEvent& event)
239 interfMainPanel::getInstance()->onMirrorAxisShow();
242 void interfMirrorPanel::onAxisHide(wxCommandEvent& event)
244 interfMainPanel::getInstance()->onMirrorAxisHide();
247 void interfMirrorPanel::onMirrorGo(wxCommandEvent& event)
249 interfMainPanel::getInstance()->onMirror();
252 void interfMirrorPanel::onChangeWidth(wxScrollEvent& event)
254 int width = _thickness->GetValue();
255 interfMainPanel::getInstance()->onMirrorChangeWidth(width);
261 ** Begin of the threshold panel
263 interfThresholdPanel::interfThresholdPanel(wxWindow* parent)
264 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
266 wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Add Fake Color"), wxDefaultPosition, wxSize(200,30) );
267 wxButton *thresholdRemoveBtn = new wxButton(this,wxID_ANY,_T("Remove Fake Color"), wxDefaultPosition, wxSize(200,30) );
268 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
269 _interpolationCheckBox->SetValue(true);
270 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
271 _thresholdGo = false;
274 interfMainPanel::getInstance()->getImageRange(range);
276 int min = (int)floor (range[0]);
277 int max = (int)ceil (range[1]);
279 _mBarThreshold = new mBarRange(this,70,65);
280 _mBarThreshold->SetMin(0);
281 _mBarThreshold->SetStart(0);
282 _mBarThreshold-> SetOrientation( true );
283 _mBarThreshold-> setActiveStateTo(true);
284 _mBarThreshold-> setVisibleLabels( true );
285 _mBarThreshold-> setDeviceEndMargin(10);
286 _mBarThreshold-> setRepresentedValues( min , max );
287 _mBarThreshold-> setDeviceBlitStart(10,10);
288 _mBarThreshold-> setIfWithActualDrawed( false );
289 _mBarThreshold-> SetStart( min );
290 _mBarThreshold-> SetEnd( max );
292 Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdGo );
293 Connect( thresholdRemoveBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdRemove );
294 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfThresholdPanel::onThresholdInterpolation );
296 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
297 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
298 sizer -> Add( _mBarThreshold, 1, wxGROW );
299 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
300 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
301 sizer -> Add( _opacity, 1, wxGROW );
302 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
303 sizer -> Add( thresholdGoBtn, 1, wxGROW );
304 sizer -> Add( thresholdRemoveBtn, 1, wxGROW );
305 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
306 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
308 this->SetSizer( sizer );
309 this->SetAutoLayout( true );
313 interfThresholdPanel::~interfThresholdPanel(){
318 void interfThresholdPanel::onThresholdChange(wxCommandEvent& event)
322 int minVal = _mBarThreshold->GetStart();
323 int maxVal = _mBarThreshold->GetEnd();
325 interfMainPanel::getInstance()->onThresholdChange(minVal, maxVal);
327 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
331 void interfThresholdPanel::onThresholdGo(wxCommandEvent& event)
335 int minVal = _mBarThreshold->GetStart();
336 int maxVal = _mBarThreshold->GetEnd();
338 interfMainPanel::getInstance()->onThreshold(minVal, maxVal);
343 void interfThresholdPanel::onThresholdRemove(wxCommandEvent& event)
345 interfMainPanel::getInstance()->onThresholdRemove( );
349 void interfThresholdPanel::onThresholdStop()
351 interfMainPanel::getInstance()->onThresholdRemove( );
355 void interfThresholdPanel::onThresholdInstantChange(int range[])
357 range[0] = _mBarThreshold->GetStart();
358 range[1] = _mBarThreshold->GetEnd();
361 void interfThresholdPanel::onThresholdInterpolation(wxCommandEvent& event)
363 interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue());
366 void interfThresholdPanel::onChangeOpacity(wxScrollEvent& event)
368 int opacity = _opacity->GetValue();
369 interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity);
373 BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel)
374 EVT_SCROLL(interfMirrorPanel :: onChangeWidth)
377 BEGIN_EVENT_TABLE(interfThresholdPanel, wxPanel)
378 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, interfThresholdPanel :: onThresholdChange)
379 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, interfThresholdPanel :: onThresholdChange)
380 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, interfThresholdPanel :: onThresholdChange)
381 EVT_SCROLL(interfThresholdPanel :: onChangeOpacity)