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();
10 interfMainPanel::getInstance()->getImageRange(range);
12 int min = (int)floor (range[0]);
13 int max = (int)ceil (range[1]);
15 wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) );
16 wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
17 _isovalue = new wxSlider(this, -1, 40 , min, max, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
18 _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
19 wxString lstOptions[3];
20 lstOptions[0]=_T("A");
21 lstOptions[1]=_T("B");
22 lstOptions[2]=_T("C");
23 methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
24 methodRadiobox->SetSelection(2);
25 _staticTextSegmentation = new wxStaticText(this,-1,_T(" "));
27 _mbarrange = new mBarRange(this,70, 65);
28 _mbarrange->SetMin(0);
29 _mbarrange->SetStart(0);
31 _mbarrange->SetOrientation( true );
32 _mbarrange->setActiveStateTo(true);
33 _mbarrange->setVisibleLabels( true );
34 _mbarrange->setDeviceEndMargin(10);
35 _mbarrange->setRepresentedValues( 0 , sizeZ );
36 _mbarrange->setDeviceBlitStart(10,10);
37 _mbarrange->setIfWithActualDrawed( false );
38 _mbarrange->SetStart( 0 );
39 _mbarrange->SetEnd( sizeZ );
41 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
42 sizer->Add( new wxStaticText(this, -1, _T("Isovalue (Gray level)")), 1, wxGROW );
43 sizer->Add( _isovalue, 1, wxGROW );
44 sizer->Add( methodRadiobox , 1, wxGROW );
45 sizer->Add( new wxStaticText(this, -1 ,_T("Sampling (%)")), 1, wxGROW );
46 sizer->Add( _sampling, 1, wxGROW );
47 sizer->Add( segmentationOneSliceBtn, 1, wxGROW );
48 sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
49 sizer->Add( _staticTextSegmentation, 1, wxGROW );
50 sizer->Add( segmentationAllSliceBtn, 1, wxGROW );
51 sizer->Add( _mbarrange, 1, wxGROW );
53 this->SetSizer( sizer );
54 // panel->SetSize( sizePanel );
55 this->SetSize( wxDefaultSize );
56 this->SetAutoLayout( true );
59 //_segmentationFrame->SetEventHandler( this );
60 //segmentationOneSliceBtn->SetEventHandler( this );
61 //segmentationAllSliceBtn->SetEventHandler( this );
62 //panel->SetEventHandler(this);
63 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationOneSlice);
64 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationAllSlice);
68 interfSegmentationPanelVTK::~interfSegmentationPanelVTK()
73 ** Responds to the events of the buttons, when the same panel is responsible for it. It gets the name
74 ** of the button corresponding to the method that has to be executed,
75 ** it uses attribute eventHandler to call the methods define by the application.
76 ** see setEventHandler(wxEventHandler*)
79 void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event){
80 if(segmentPanelITK == NULL) {
81 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
83 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
84 segmentPanelITK->SetSizer(flexsizer, true);
85 segmentPanelITK->SetAutoLayout( true );
87 wxPanel* panel = new wxPanel(this, -1);//contourevent->getSegmentationPanelITK(segmentPanelITK);
89 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
90 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
92 flexsizer->Add(stattext, wxALIGN_CENTER | wxALIGN_CENTRE);
93 flexsizer->Add(panel, wxEXPAND);
94 segmentPanelITK->Layout();
96 interfMainPanel::getInstance()->showPanel(segmentPanelITK);
97 //contourevent->showAxis(true);
101 void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event )
103 int isovalue = _isovalue->GetValue();
104 int sampling = _sampling->GetValue();
105 int method = methodRadiobox->GetSelection();
106 interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
109 void interfSegmentationPanelVTK::onSegmentationAllSlice( wxCommandEvent& event )
111 int minZ=_mbarrange->GetStart();
112 int maxZ=_mbarrange->GetEnd();
114 int isovalue = _isovalue->GetValue();
115 int sampling = _sampling->GetValue();
116 int method = methodRadiobox->GetSelection();
118 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);
121 void interfSegmentationPanelVTK::setLabel(wxString tmpString){
122 _staticTextSegmentation->SetLabel(tmpString);
125 ** start of new implementation
126 ** interfSegmentationPanelITK
128 interfSegmentationPanelITK::interfSegmentationPanelITK(wxWindow * parent)
129 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
132 interfMainPanel::getInstance()->getImageRange(range);
134 // int min = (int)floor (range[0]);
135 // int max = (int)ceil (range[1]);
138 //wxStaticText * distance =
139 new wxStaticText(this, wxID_ANY, wxT("Initial Distance"), wxPoint(5, 5));
140 //wxStaticText * sigma =
141 new wxStaticText(this, wxID_ANY, wxT("Sigma"), wxPoint(5, 30));
142 //wxStaticText * alfa =
143 new wxStaticText(this, wxID_ANY, wxT("Sigmoid Alfa"), wxPoint(5, 55));
144 //wxStaticText * beta =
145 new wxStaticText(this, wxID_ANY, wxT("Sigmoid Beta"), wxPoint(5, 80));
146 //wxStaticText * propagation =
147 new wxStaticText(this, wxID_ANY, wxT("Propagation Scaling"),wxPoint(5, 105));
148 //wxStaticText * iterations =
149 new wxStaticText(this, wxID_ANY, wxT("Iterations"), wxPoint(5, 130));
150 //wxStaticText * infStrength =
151 new wxStaticText(this, wxID_ANY, wxT("Inflation Strength"), wxPoint(5, 155));
155 _distance = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,5), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
156 _sigma = new wxTextCtrl(this, wxID_ANY, wxT("1.2"), wxPoint(98,30), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
157 _alfa = new wxTextCtrl(this, wxID_ANY, wxT("-1.0"), wxPoint(98,55), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
158 _beta = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,80), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
159 _propagation = new wxTextCtrl(this, wxID_ANY, wxT("6.0"), wxPoint(98,105), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
160 _iterations = new wxTextCtrl(this, wxID_ANY, wxT("800"), wxPoint(98,130), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
161 _infStrength = new wxTextCtrl(this, wxID_ANY, wxT("3.0"), wxPoint(98,155), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
165 new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
167 //Conexion del boton con su respectivo manejador
168 Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfSegmentationPanelITK::onSegmentationOneSlice);
172 interfSegmentationPanelITK::~interfSegmentationPanelITK(){
176 void interfSegmentationPanelITK::onSegmentationOneSlice( wxCommandEvent& event )
178 wxString distanc=_distance->GetValue();
179 wxString sigm=_sigma->GetValue();
180 wxString alf=_alfa->GetValue();
181 wxString bet=_beta->GetValue();
182 wxString prop=_propagation->GetValue();
183 wxString iter=_iterations->GetValue();
184 wxString infS=_infStrength->GetValue();
186 interfMainPanel::getInstance()->onSegmentationOneSliceITK(distanc, sigm, alf, bet, prop, iter, infS);
189 void interfSegmentationPanelITK::onSegmentationAllSlice( wxCommandEvent& event )
192 /*int minZ=_mbarrange->GetStart();
193 int maxZ=_mbarrange->GetEnd();
195 int isovalue = _isovalue->GetValue();
196 int sampling = _sampling->GetValue();
197 int method = methodRadiobox->GetSelection();
200 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);*/
204 //------------------------------------------------------------------------------------------------------------
208 ** Begin of the mirror panel
211 interfMirrorPanel::interfMirrorPanel(wxWindow* parent)
212 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
216 wxButton *axisShowBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Axis"), wxDefaultPosition, wxSize(200,35) );
217 wxButton *mirrorGoBtn = new wxButton(this,wxID_ANY,_T("Mirror Contour"), wxDefaultPosition, wxSize(200,35) );
218 _thickness = new wxSlider(this, -1, 4, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
220 Connect( axisShowBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisShow );
221 Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo );
223 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
224 sizer -> Add( axisShowBtn, 1, wxGROW );
225 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
226 sizer -> Add( new wxStaticText(this,-1,_T("Thickness")) , 1, wxGROW );
227 sizer -> Add( _thickness, 1, wxGROW );
228 sizer -> Add( mirrorGoBtn, 1, wxGROW );
230 this->SetSizer( sizer );
231 this->SetAutoLayout( true );
235 interfMirrorPanel::~interfMirrorPanel(){
238 void interfMirrorPanel::onAxisShow(wxCommandEvent& event)
243 interfMainPanel::getInstance()->onMirrorAxisShow();
248 interfMainPanel::getInstance()->onMirrorAxisHide();
253 void interfMirrorPanel::onMirrorGo(wxCommandEvent& event)
257 interfMainPanel::getInstance()->onMirror();
261 void interfMirrorPanel::onChangeWidth(wxScrollEvent& event)
263 int width = _thickness->GetValue();
264 interfMainPanel::getInstance()->onMirrorChangeWidth(width);
270 ** Begin of the threshold panel
272 interfThresholdPanel::interfThresholdPanel(wxWindow* parent)
273 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
275 wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
276 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
277 _interpolationCheckBox->SetValue(true);
278 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
279 _thresholdGo = false;
282 interfMainPanel::getInstance()->getImageRange(range);
284 int min = (int)floor (range[0]);
285 int max = (int)ceil (range[1]);
287 _mBarThreshold = new mBarRange(this,70,65);
288 _mBarThreshold->SetMin(0);
289 _mBarThreshold->SetStart(0);
290 _mBarThreshold-> SetOrientation( true );
291 _mBarThreshold-> setActiveStateTo(true);
292 _mBarThreshold-> setVisibleLabels( true );
293 _mBarThreshold-> setDeviceEndMargin(10);
294 _mBarThreshold-> setRepresentedValues( min , max );
295 _mBarThreshold-> setDeviceBlitStart(10,10);
296 _mBarThreshold-> setIfWithActualDrawed( false );
297 _mBarThreshold-> SetStart( min );
298 _mBarThreshold-> SetEnd( max );
300 Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdGo );
301 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfThresholdPanel::onThresholdInterpolation );
303 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
304 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
305 sizer -> Add( _mBarThreshold, 1, wxGROW );
306 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
307 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
308 sizer -> Add( _opacity, 1, wxGROW );
309 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
310 sizer -> Add( thresholdGoBtn, 1, wxGROW );
311 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
312 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
314 this->SetSizer( sizer );
315 this->SetAutoLayout( true );
319 interfThresholdPanel::~interfThresholdPanel(){
324 void interfThresholdPanel::onThresholdChange(wxCommandEvent& event)
328 interfMainPanel::getInstance()->onThresholdChange();
330 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
334 void interfThresholdPanel::onThresholdGo(wxCommandEvent& event)
338 interfMainPanel::getInstance()->onThreshold();
343 interfMainPanel::getInstance()->onThresholdRemove( );
348 void interfThresholdPanel::onThresholdStop()
352 interfMainPanel::getInstance()->onThresholdRemove( );
357 void interfThresholdPanel::onThresholdInstantChange(double range[])
359 range[0] = _mBarThreshold->GetStart();
360 range[1] = _mBarThreshold->GetEnd();
363 void interfThresholdPanel::onThresholdInterpolation(wxCommandEvent& event)
365 interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue());
368 void interfThresholdPanel::onChangeOpacity(wxScrollEvent& event)
370 int opacity = _opacity->GetValue();
371 interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity);
375 BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel)
376 EVT_SCROLL(interfMirrorPanel :: onChangeWidth)
379 BEGIN_EVENT_TABLE(interfThresholdPanel, wxPanel)
380 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, interfThresholdPanel :: onThresholdChange)
381 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, interfThresholdPanel :: onThresholdChange)
382 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, interfThresholdPanel :: onThresholdChange)
383 EVT_SCROLL(interfThresholdPanel :: onChangeOpacity)