creaContours_lib
interfSegmentationPanels.cxx
Go to the documentation of this file.
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 # pour la Sant�)
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
8 #
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.
15 #
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
20 # liability.
21 #
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 # ------------------------------------------------------------------------ */
25 
27 #include "interfMainPanel.h"
28 
30 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
31 {
33 
34  double range[2];
36 
37  int min = (int)floor (range[0]);
38  int max = (int)ceil (range[1]);
39 
40  wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) );
41  wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
42  _isovalue = new wxSlider(this, -1, 40 , min, max, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
43  _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
44  wxString lstOptions[3];
45  lstOptions[0]=_T("A");
46  lstOptions[1]=_T("B");
47  lstOptions[2]=_T("C");
48  methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
49  methodRadiobox->SetSelection(2);
50  _staticTextSegmentation = new wxStaticText(this,-1,_T(" "));
51 
52  _mbarrange = new mBarRange(this,70, 65);
53  _mbarrange->SetMin(0);
54  _mbarrange->SetStart(0);
55 
56  _mbarrange->SetOrientation( true );
57  _mbarrange->setActiveStateTo(true);
58  _mbarrange->setVisibleLabels( true );
59  _mbarrange->setDeviceEndMargin(10);
60  _mbarrange->setRepresentedValues( 0 , sizeZ );
61  _mbarrange->setDeviceBlitStart(10,10);
62  _mbarrange->setIfWithActualDrawed( false );
63  _mbarrange->SetStart( 0 );
64  _mbarrange->SetEnd( sizeZ );
65 
66  wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
67  sizer->Add( new wxStaticText(this, -1, _T("Isovalue (Gray level)")), 1, wxGROW );
68  sizer->Add( _isovalue, 1, wxGROW );
69  sizer->Add( methodRadiobox , 1, wxGROW );
70  sizer->Add( new wxStaticText(this, -1 ,_T("Sampling (%)")), 1, wxGROW );
71  sizer->Add( _sampling, 1, wxGROW );
72  sizer->Add( segmentationOneSliceBtn, 1, wxGROW );
73  sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW );
74  sizer->Add( _staticTextSegmentation, 1, wxGROW );
75  sizer->Add( segmentationAllSliceBtn, 1, wxGROW );
76  sizer->Add( _mbarrange, 1, wxGROW );
77 
78  this->SetSizer( sizer );
79 // panel->SetSize( sizePanel );
80  this->SetSize( wxDefaultSize );
81  this->SetAutoLayout( true );
82  this->Layout();
83 
84 //_segmentationFrame->SetEventHandler( this );
85  //segmentationOneSliceBtn->SetEventHandler( this );
86  //segmentationAllSliceBtn->SetEventHandler( this );
87  //panel->SetEventHandler(this);
88  Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationOneSlice);
89  Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationAllSlice);
90 }
91 
92 
94 {
95 }
96 
105  if(segmentPanelITK == NULL) {
106  segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
107 
108  wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
109  segmentPanelITK->SetSizer(flexsizer, true);
110  segmentPanelITK->SetAutoLayout( true );
111 
112  wxPanel* panel = new wxPanel(this, -1);//contourevent->getSegmentationPanelITK(segmentPanelITK);
113 
114  wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
115  wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
116 
117  flexsizer->Add(stattext, wxALIGN_CENTER | wxALIGN_CENTRE);
118  flexsizer->Add(panel, wxEXPAND);
119  segmentPanelITK->Layout();
120  }
122  //contourevent->showAxis(true);
123  //axisshown = true;
124 }
125 
127 {
128  int isovalue = _isovalue->GetValue();
129  int sampling = _sampling->GetValue();
130  int method = methodRadiobox->GetSelection();
131  interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
132 
133 }
135 {
136  int minZ=_mbarrange->GetStart();
137  int maxZ=_mbarrange->GetEnd();
138 
139  int isovalue = _isovalue->GetValue();
140  int sampling = _sampling->GetValue();
141  int method = methodRadiobox->GetSelection();
142 
143  interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);
144 }
145 
146 void interfSegmentationPanelVTK::setLabel(wxString tmpString){
147  _staticTextSegmentation->SetLabel(tmpString);
148 }
154 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
155 {
156  double range[2];
158 
159 // int min = (int)floor (range[0]);
160 // int max = (int)ceil (range[1]);
161 
162  //The labels
163  //wxStaticText * distance =
164  new wxStaticText(this, wxID_ANY, wxT("Initial Distance"), wxPoint(5, 5));
165  //wxStaticText * sigma =
166  new wxStaticText(this, wxID_ANY, wxT("Sigma"), wxPoint(5, 30));
167  //wxStaticText * alfa =
168  new wxStaticText(this, wxID_ANY, wxT("Sigmoid Alfa"), wxPoint(5, 55));
169  //wxStaticText * beta =
170  new wxStaticText(this, wxID_ANY, wxT("Sigmoid Beta"), wxPoint(5, 80));
171  //wxStaticText * propagation =
172  new wxStaticText(this, wxID_ANY, wxT("Propagation Scaling"),wxPoint(5, 105));
173  //wxStaticText * iterations =
174  new wxStaticText(this, wxID_ANY, wxT("Iterations"), wxPoint(5, 130));
175  //wxStaticText * infStrength =
176  new wxStaticText(this, wxID_ANY, wxT("Inflation Strength"), wxPoint(5, 155));
177 
178  //Text Controls
179 
180  _distance = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,5), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
181  _sigma = new wxTextCtrl(this, wxID_ANY, wxT("1.2"), wxPoint(98,30), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
182  _alfa = new wxTextCtrl(this, wxID_ANY, wxT("-1.0"), wxPoint(98,55), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
183  _beta = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,80), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
184  _propagation = new wxTextCtrl(this, wxID_ANY, wxT("6.0"), wxPoint(98,105), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
185  _iterations = new wxTextCtrl(this, wxID_ANY, wxT("800"), wxPoint(98,130), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
186  _infStrength = new wxTextCtrl(this, wxID_ANY, wxT("3.0"), wxPoint(98,155), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr);
187 
188  //El boton
189  //wxButton * bot =
190  new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
191 
192  //Conexion del boton con su respectivo manejador
193  Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfSegmentationPanelITK::onSegmentationOneSlice);
194 
195 
196 }
198 
199 }
200 
202 {
203  wxString distanc=_distance->GetValue();
204  wxString sigm=_sigma->GetValue();
205  wxString alf=_alfa->GetValue();
206  wxString bet=_beta->GetValue();
207  wxString prop=_propagation->GetValue();
208  wxString iter=_iterations->GetValue();
209  wxString infS=_infStrength->GetValue();
210 
211  interfMainPanel::getInstance()->onSegmentationOneSliceITK(distanc, sigm, alf, bet, prop, iter, infS);
212 
213 }
215 {
216 
217  /*int minZ=_mbarrange->GetStart();
218  int maxZ=_mbarrange->GetEnd();
219 
220  int isovalue = _isovalue->GetValue();
221  int sampling = _sampling->GetValue();
222  int method = methodRadiobox->GetSelection();
223 
224 
225  interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);*/
226 
227 }
228 
229 //------------------------------------------------------------------------------------------------------------
230 
231 
237 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
238 {
239  _axisStatus = true;
240 
241  wxButton *axisShowBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Axis"), wxDefaultPosition, wxSize(200,35) );
242  wxButton *mirrorGoBtn = new wxButton(this,wxID_ANY,_T("Mirror Contour"), wxDefaultPosition, wxSize(200,35) );
243  _thickness = new wxSlider(this, -1, 4, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
244 
245  Connect( axisShowBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisShow );
246  Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo );
247 
248  wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
249  sizer -> Add( axisShowBtn, 1, wxGROW );
250  sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
251  sizer -> Add( new wxStaticText(this,-1,_T("Thickness")) , 1, wxGROW );
252  sizer -> Add( _thickness, 1, wxGROW );
253  sizer -> Add( mirrorGoBtn, 1, wxGROW );
254 
255  this->SetSizer( sizer );
256  this->SetAutoLayout( true );
257  this->Layout();
258 }
259 
261 }
262 
263 void interfMirrorPanel::onAxisShow(wxCommandEvent& event)
264 {
265 
266  if (!_axisStatus)
267  {
269  _axisStatus=true;
270  }
271  else
272  {
274  _axisStatus=false;
275  }
276 }
277 
278 void interfMirrorPanel::onMirrorGo(wxCommandEvent& event)
279 {
280  if (_axisStatus)
281  {
283  }
284 }
285 
286 void interfMirrorPanel::onChangeWidth(wxScrollEvent& event)
287 {
288  int width = _thickness->GetValue();
290 }
291 
292 
293 
294 
295 
296 
297 
298 BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel)
299 EVT_SCROLL(interfMirrorPanel :: onChangeWidth)
300 END_EVENT_TABLE()
301 
303 
305 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
306 {
307  wxButton *button1 = new wxButton(this,wxID_ANY,_T("Button 1"), wxDefaultPosition, wxSize(200,35) );
308  wxButton *button2 = new wxButton(this,wxID_ANY,_T("Button 2"), wxDefaultPosition, wxSize(200,35) );
309 
310  Connect( button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfTestPanel::onButton1Pressed );
311  Connect( button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfTestPanel::onButton2Pressed );
312 
313  wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
314  sizer -> Add( button1, 1, wxGROW );
315  sizer -> Add( button2, 1, wxGROW );
316 
317  this->SetSizer( sizer );
318  this->SetAutoLayout( true );
319  this->Layout();
320 }
321 
323 }
324 
325 void interfTestPanel::onButton1Pressed(wxCommandEvent& event)
326 {
327  std::cout << "Button 1 has been pressed" << std::endl;
328 }
329 
330 void interfTestPanel::onButton2Pressed(wxCommandEvent& event)
331 {
332  std::cout << "Button 2 has been pressed" << std::endl;
333 }