1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #include "interfSegmentationPanels.h"
27 #include "interfMainPanel.h"
29 interfSegmentationPanelVTK::interfSegmentationPanelVTK(wxWindow * parent)
30 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
32 int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
35 interfMainPanel::getInstance()->getImageRange(range);
37 int min = (int)floor (range[0]);
38 int max = (int)ceil (range[1]);
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(" "));
52 _mbarrange = new mBarRange(this,70, 65);
53 _mbarrange->SetMin(0);
54 _mbarrange->SetStart(0);
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 );
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 );
78 this->SetSizer( sizer );
79 // panel->SetSize( sizePanel );
80 this->SetSize( wxDefaultSize );
81 this->SetAutoLayout( true );
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);
93 interfSegmentationPanelVTK::~interfSegmentationPanelVTK()
98 ** Responds to the events of the buttons, when the same panel is responsible for it. It gets the name
99 ** of the button corresponding to the method that has to be executed,
100 ** it uses attribute eventHandler to call the methods define by the application.
101 ** see setEventHandler(wxEventHandler*)
104 void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event){
105 if(segmentPanelITK == NULL) {
106 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
108 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
109 segmentPanelITK->SetSizer(flexsizer, true);
110 segmentPanelITK->SetAutoLayout( true );
112 wxPanel* panel = new wxPanel(this, -1);//contourevent->getSegmentationPanelITK(segmentPanelITK);
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("")));
117 flexsizer->Add(stattext, wxALIGN_CENTER | wxALIGN_CENTRE);
118 flexsizer->Add(panel, wxEXPAND);
119 segmentPanelITK->Layout();
121 interfMainPanel::getInstance()->showPanel(segmentPanelITK);
122 //contourevent->showAxis(true);
126 void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event )
128 int isovalue = _isovalue->GetValue();
129 int sampling = _sampling->GetValue();
130 int method = methodRadiobox->GetSelection();
131 interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
134 void interfSegmentationPanelVTK::onSegmentationAllSlice( wxCommandEvent& event )
136 int minZ=_mbarrange->GetStart();
137 int maxZ=_mbarrange->GetEnd();
139 int isovalue = _isovalue->GetValue();
140 int sampling = _sampling->GetValue();
141 int method = methodRadiobox->GetSelection();
143 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);
146 void interfSegmentationPanelVTK::setLabel(wxString tmpString){
147 _staticTextSegmentation->SetLabel(tmpString);
150 ** start of new implementation
151 ** interfSegmentationPanelITK
153 interfSegmentationPanelITK::interfSegmentationPanelITK(wxWindow * parent)
154 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
157 interfMainPanel::getInstance()->getImageRange(range);
159 // int min = (int)floor (range[0]);
160 // int max = (int)ceil (range[1]);
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));
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);
190 new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, wxT("button"));
192 //Conexion del boton con su respectivo manejador
193 Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfSegmentationPanelITK::onSegmentationOneSlice);
197 interfSegmentationPanelITK::~interfSegmentationPanelITK(){
201 void interfSegmentationPanelITK::onSegmentationOneSlice( wxCommandEvent& event )
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();
211 interfMainPanel::getInstance()->onSegmentationOneSliceITK(distanc, sigm, alf, bet, prop, iter, infS);
214 void interfSegmentationPanelITK::onSegmentationAllSlice( wxCommandEvent& event )
217 /*int minZ=_mbarrange->GetStart();
218 int maxZ=_mbarrange->GetEnd();
220 int isovalue = _isovalue->GetValue();
221 int sampling = _sampling->GetValue();
222 int method = methodRadiobox->GetSelection();
225 interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);*/
229 //------------------------------------------------------------------------------------------------------------
233 ** Begin of the mirror panel
236 interfMirrorPanel::interfMirrorPanel(wxWindow* parent)
237 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
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);
245 Connect( axisShowBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisShow );
246 Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo );
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 );
255 this->SetSizer( sizer );
256 this->SetAutoLayout( true );
260 interfMirrorPanel::~interfMirrorPanel(){
263 void interfMirrorPanel::onAxisShow(wxCommandEvent& event)
268 interfMainPanel::getInstance()->onMirrorAxisShow();
273 interfMainPanel::getInstance()->onMirrorAxisHide();
278 void interfMirrorPanel::onMirrorGo(wxCommandEvent& event)
282 interfMainPanel::getInstance()->onMirror();
286 void interfMirrorPanel::onChangeWidth(wxScrollEvent& event)
288 int width = _thickness->GetValue();
289 interfMainPanel::getInstance()->onMirrorChangeWidth(width);
293 BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel)
294 EVT_SCROLL(interfMirrorPanel :: onChangeWidth)
298 //////////////////////////////////////////////////////////////
300 interfTestPanel::interfTestPanel(wxWindow* parent)
301 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
303 wxButton *button1 = new wxButton(this,wxID_ANY,_T("Button 1"), wxDefaultPosition, wxSize(200,35) );
304 wxButton *button2 = new wxButton(this,wxID_ANY,_T("Button 2"), wxDefaultPosition, wxSize(200,35) );
306 Connect( button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfTestPanel::onButton1Pressed );
307 Connect( button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfTestPanel::onButton2Pressed );
309 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
310 sizer -> Add( button1, 1, wxGROW );
311 sizer -> Add( button2, 1, wxGROW );
313 this->SetSizer( sizer );
314 this->SetAutoLayout( true );
318 interfTestPanel::~interfTestPanel(){
321 void interfTestPanel::onButton1Pressed(wxCommandEvent& event)
323 std::cout << "Button 1 has been pressed" << std::endl;
326 void interfTestPanel::onButton2Pressed(wxCommandEvent& event)
328 std::cout << "Button 2 has been pressed" << std::endl;