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 = new wxStaticText(this, wxID_ANY, wxT("Initial Distance"), wxPoint(5, 5));
137 wxStaticText * sigma = new wxStaticText(this, wxID_ANY, wxT("Sigma"), wxPoint(5, 30));
138 wxStaticText * alfa = new wxStaticText(this, wxID_ANY, wxT("Sigmoid Alfa"), wxPoint(5, 55));
139 wxStaticText * beta = new wxStaticText(this, wxID_ANY, wxT("Sigmoid Beta"), wxPoint(5, 80));
140 wxStaticText * propagation = new wxStaticText(this, wxID_ANY, wxT("Propagation Scaling"),wxPoint(5, 105));
141 wxStaticText * iterations = new wxStaticText(this, wxID_ANY, wxT("Iterations"), wxPoint(5, 130));
142 wxStaticText * infStrength = new wxStaticText(this, wxID_ANY, wxT("Inflation Strength"), wxPoint(5, 155));
146 _distance = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,5), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
147 _sigma = new wxTextCtrl(this, wxID_ANY, wxT("1.2"), wxPoint(98,30), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
148 _alfa = new wxTextCtrl(this, wxID_ANY, wxT("-1.0"), wxPoint(98,55), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
149 _beta = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,80), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
150 _propagation = new wxTextCtrl(this, wxID_ANY, wxT("6.0"), wxPoint(98,105), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
151 _iterations = new wxTextCtrl(this, wxID_ANY, wxT("800"), wxPoint(98,130), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
152 _infStrength = new wxTextCtrl(this, wxID_ANY, wxT("3.0"), wxPoint(98,155), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
155 wxButton * bot = new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
157 //Conexion del boton con su respectivo manejador
158 Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfSegmentationPanelITK::onSegmentationOneSlice);
162 interfSegmentationPanelITK::~interfSegmentationPanelITK(){
166 void interfSegmentationPanelITK::onSegmentationOneSlice( wxCommandEvent& event )
168 wxString distanc=_distance->GetValue();
169 wxString sigm=_sigma->GetValue();
170 wxString alf=_alfa->GetValue();
171 wxString bet=_beta->GetValue();
172 wxString prop=_propagation->GetValue();
173 wxString iter=_iterations->GetValue();
174 wxString infS=_infStrength->GetValue();
176 interfMainPanel::getInstance()->onSegmentationOneSliceITK(distanc, sigm, alf, bet, prop, iter, infS);
179 void interfSegmentationPanelITK::onSegmentationAllSlice( wxCommandEvent& event )
182 /*int minZ=_mbarrange->GetStart();
183 int maxZ=_mbarrange->GetEnd();
185 int isovalue = _isovalue->GetValue();
186 int sampling = _sampling->GetValue();
187 int method = methodRadiobox->GetSelection();
190 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);*/
194 //------------------------------------------------------------------------------------------------------------
198 ** Begin of the mirror panel
201 interfMirrorPanel::interfMirrorPanel(wxWindow* parent)
202 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
204 wxButton *axisShowBtn = new wxButton(this,wxID_ANY,_T("Show Axis"), wxDefaultPosition, wxSize(200,35) );
205 wxButton *axisHideBtn = new wxButton(this,wxID_ANY,_T("Hide Axis"), wxDefaultPosition, wxSize(200,35) );
206 wxButton *mirrorGoBtn = new wxButton(this,wxID_ANY,_T("Mirror Contour"), wxDefaultPosition, wxSize(200,35) );
207 _thickness = new wxSlider(this, -1, 4, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
209 Connect( axisShowBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisShow );
210 Connect( axisHideBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisHide );
211 Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo );
213 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
214 sizer -> Add( axisShowBtn, 1, wxGROW );
215 sizer -> Add( axisHideBtn, 1, wxGROW );
216 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
217 sizer -> Add( new wxStaticText(this,-1,_T("Thickness")) , 1, wxGROW );
218 sizer -> Add( _thickness, 1, wxGROW );
219 sizer -> Add( mirrorGoBtn, 1, wxGROW );
221 this->SetSizer( sizer );
222 this->SetAutoLayout( true );
226 interfMirrorPanel::~interfMirrorPanel(){
229 void interfMirrorPanel::onAxisShow(wxCommandEvent& event)
231 interfMainPanel::getInstance()->onMirrorAxisShow();
234 void interfMirrorPanel::onAxisHide(wxCommandEvent& event)
236 interfMainPanel::getInstance()->onMirrorAxisHide();
239 void interfMirrorPanel::onMirrorGo(wxCommandEvent& event)
241 interfMainPanel::getInstance()->onMirror();
244 void interfMirrorPanel::onChangeWidth(wxScrollEvent& event)
246 int width = _thickness->GetValue();
247 interfMainPanel::getInstance()->onMirrorChangeWidth(width);
253 ** Begin of the threshold panel
255 interfThresholdPanel::interfThresholdPanel(wxWindow* parent)
256 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
258 wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Add Fake Color"), wxDefaultPosition, wxSize(200,30) );
259 wxButton *thresholdRemoveBtn = new wxButton(this,wxID_ANY,_T("Remove Fake Color"), wxDefaultPosition, wxSize(200,30) );
260 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
261 _interpolationCheckBox->SetValue(true);
262 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
263 _thresholdGo = false;
266 interfMainPanel::getInstance()->getImageRange(range);
268 int min = (int)floor (range[0]);
269 int max = (int)ceil (range[1]);
271 _mBarThreshold = new mBarRange(this,70,65);
272 _mBarThreshold->SetMin(0);
273 _mBarThreshold->SetStart(0);
274 _mBarThreshold-> SetOrientation( true );
275 _mBarThreshold-> setActiveStateTo(true);
276 _mBarThreshold-> setVisibleLabels( true );
277 _mBarThreshold-> setDeviceEndMargin(10);
278 _mBarThreshold-> setRepresentedValues( min , max );
279 _mBarThreshold-> setDeviceBlitStart(10,10);
280 _mBarThreshold-> setIfWithActualDrawed( false );
281 _mBarThreshold-> SetStart( min );
282 _mBarThreshold-> SetEnd( max );
284 Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdGo );
285 Connect( thresholdRemoveBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdRemove );
286 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfThresholdPanel::onThresholdInterpolation );
288 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
289 sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
290 sizer -> Add( _mBarThreshold, 1, wxGROW );
291 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
292 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
293 sizer -> Add( _opacity, 1, wxGROW );
294 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
295 sizer -> Add( thresholdGoBtn, 1, wxGROW );
296 sizer -> Add( thresholdRemoveBtn, 1, wxGROW );
297 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
298 sizer -> Add( _interpolationCheckBox, 1, wxGROW );
300 this->SetSizer( sizer );
301 this->SetAutoLayout( true );
305 interfThresholdPanel::~interfThresholdPanel(){
310 void interfThresholdPanel::onThresholdChange(wxCommandEvent& event)
314 int minVal = _mBarThreshold->GetStart();
315 int maxVal = _mBarThreshold->GetEnd();
317 interfMainPanel::getInstance()->onThresholdChange(minVal, maxVal);
319 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
323 void interfThresholdPanel::onThresholdGo(wxCommandEvent& event)
327 int minVal = _mBarThreshold->GetStart();
328 int maxVal = _mBarThreshold->GetEnd();
330 interfMainPanel::getInstance()->onThreshold(minVal, maxVal);
335 void interfThresholdPanel::onThresholdRemove(wxCommandEvent& event)
337 interfMainPanel::getInstance()->onThresholdRemove( );
341 void interfThresholdPanel::onThresholdStop()
343 interfMainPanel::getInstance()->onThresholdRemove( );
347 void interfThresholdPanel::onThresholdInstantChange(int range[])
349 range[0] = _mBarThreshold->GetStart();
350 range[1] = _mBarThreshold->GetEnd();
353 void interfThresholdPanel::onThresholdInterpolation(wxCommandEvent& event)
355 interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue());
358 void interfThresholdPanel::onChangeOpacity(wxScrollEvent& event)
360 int opacity = _opacity->GetValue();
361 interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity);
365 BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel)
366 EVT_SCROLL(interfMirrorPanel :: onChangeWidth)
369 BEGIN_EVENT_TABLE(interfThresholdPanel, wxPanel)
370 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, interfThresholdPanel :: onThresholdChange)
371 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, interfThresholdPanel :: onThresholdChange)
372 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, interfThresholdPanel :: onThresholdChange)
373 EVT_SCROLL(interfThresholdPanel :: onChangeOpacity)