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 *mirrorGoBtn = new wxButton(this,-1,_T("Go"), wxDefaultPosition, wxSize(200,35) );
205 _thickness = new wxSlider(this, -1, 4, 1, 10, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
207 Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo );
209 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
210 sizer -> Add( new wxStaticText(this,-1,_T("Thickness")) , 1, wxGROW );
211 sizer -> Add( _thickness, 1, wxGROW );
212 sizer -> Add( mirrorGoBtn, 1, wxGROW );
214 this->SetSizer( sizer );
215 this->SetAutoLayout( true );
219 interfMirrorPanel::~interfMirrorPanel(){
222 void interfMirrorPanel::onMirrorGo(wxCommandEvent& event)
224 interfMainPanel::getInstance()->onMirror();
227 void interfMirrorPanel::onChangeWidth(wxScrollEvent& event)
229 int width = _thickness->GetValue();
230 interfMainPanel::getInstance()->onMirrorChangeWidth(width);
236 ** Begin of the threshold panel
238 interfThresholdPanel::interfThresholdPanel(wxWindow* parent)
239 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
241 wxButton *thresholdGoBtn = new wxButton(this,-1,_T("Threshold Go"), wxDefaultPosition, wxSize(200,30) );
243 _thresholdGo = false;
246 interfMainPanel::getInstance()->getImageRange(range);
248 _mBarThreshold = new mBarRange(this,70,65);
249 _mBarThreshold->SetMin(0);
250 _mBarThreshold->SetStart(0);
251 _mBarThreshold-> SetOrientation( true );
252 _mBarThreshold-> setActiveStateTo(true);
253 _mBarThreshold-> setVisibleLabels( true );
254 _mBarThreshold-> setDeviceEndMargin(10);
255 _mBarThreshold-> setRepresentedValues( range[0] , range[1] );
256 _mBarThreshold-> setDeviceBlitStart(10,10);
257 _mBarThreshold-> setIfWithActualDrawed( false );
258 _mBarThreshold-> SetStart( range[0] );
259 _mBarThreshold-> SetEnd( range[1] );
261 Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdGo );
263 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
264 sizer -> Add( _mBarThreshold, 1, wxGROW );
265 sizer -> Add( thresholdGoBtn, 1, wxGROW );
266 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
267 sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
268 //sizer -> Add( new wxStaticText(this,-1,_T("Select the image's range to superpose a Fake Color")) , 1, wxGROW );
271 this->SetSizer( sizer );
272 this->SetAutoLayout( true );
276 interfThresholdPanel::~interfThresholdPanel(){
281 void interfThresholdPanel::onThresholdChange(wxCommandEvent& event)
285 int minVal = _mBarThreshold->GetStart();
286 int maxVal = _mBarThreshold->GetEnd();
288 interfMainPanel::getInstance()->onThreshold(minVal, maxVal);
290 std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
294 void interfThresholdPanel::onThresholdGo(wxCommandEvent& event)
298 int minVal = _mBarThreshold->GetStart();
299 int maxVal = _mBarThreshold->GetEnd();
301 interfMainPanel::getInstance()->onThreshold(minVal, maxVal);
306 void interfThresholdPanel::onThresholdStop()
312 BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel)
313 EVT_SCROLL(interfMirrorPanel :: onChangeWidth)
316 BEGIN_EVENT_TABLE(interfThresholdPanel, wxPanel)
317 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, interfThresholdPanel :: onThresholdChange)
318 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, interfThresholdPanel :: onThresholdChange)
319 EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, interfThresholdPanel :: onThresholdChange)