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 # ------------------------------------------------------------------------ */
27 //----------------------------------------------------------------------------------------------------------------
28 // Class definition include
29 //----------------------------------------------------------------------------------------------------------------
30 //#include "wxContourEventHandler.h"
31 #include "PanelBullEyeOptions.h"
33 //------------------------------------------------------------------------------------------------------------
34 //------------------------------------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------------------------------------
37 PanelBullEyeOptions::PanelBullEyeOptions (wxWindow * parent, wxSize size) :
38 wxPanel(parent, -1, wxDefaultPosition, size)
43 wxSize sizepanel(190,300);
44 wxPanel *panel = this;
47 wxString lstOptions[2];
48 lstOptions[0]= wxString("General options",wxConvUTF8);
49 lstOptions[1]= wxString("Detail options",wxConvUTF8);
50 _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, wxString("General/Detail options",wxConvUTF8), wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS);
51 _radioboxBullEyeGenOpt->SetSelection(0);
53 _spinctrlBullEyeNumOfCrowns = new wxSpinCtrl( panel , -1,_T("B"),wxDefaultPosition, wxSize(40,20) );
54 _spinctrlBullEyeNumOfCrowns->SetRange(1,_maxLevels);
55 _spinctrlBullEyeNumOfCrowns->SetValue(3);
57 _spinctrlBullEyeNumOfSec = new wxSpinCtrl( panel , -1,_T("A"),wxDefaultPosition, wxSize(40,20) );
58 _spinctrlBullEyeNumOfSec->SetRange(1,_maxSections);
59 _spinctrlBullEyeNumOfSec->SetValue(5);
62 _sliderBullEyeAngle = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
64 wxFlexGridSizer * sizerGeneralOptions = new wxFlexGridSizer(10);
66 wxFlexGridSizer * sizerGeneralOptionsA = new wxFlexGridSizer(1);
67 wxFlexGridSizer * sizerGeneralOptionsB = new wxFlexGridSizer(1);
68 wxFlexGridSizer * sizerGeneralOptionsC = new wxFlexGridSizer(1);
69 sizerGeneralOptionsA -> Add( new wxStaticText(panel,-1,_T("Crowns")) , 1, wxGROW );
70 sizerGeneralOptionsA -> Add( _spinctrlBullEyeNumOfCrowns , 1/*, wxGROW*/ );
71 sizerGeneralOptionsB -> Add( new wxStaticText(panel,-1,_T("Sections")) , 1, wxGROW );
72 sizerGeneralOptionsB -> Add( _spinctrlBullEyeNumOfSec , 1/*, wxGROW*/ );
73 sizerGeneralOptionsC -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
74 sizerGeneralOptionsC -> Add( _sliderBullEyeAngle , 1/*, wxGROW*/ );
76 sizerGeneralOptions -> Add( sizerGeneralOptionsA , 1/*, wxGROW*/ );
77 sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
78 sizerGeneralOptions -> Add( sizerGeneralOptionsB , 1/*, wxGROW*/ );
79 sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
80 sizerGeneralOptions -> Add( sizerGeneralOptionsC , 1/*, wxGROW*/ );
83 wxSpinCtrl *tmpSpinSection;
84 wxSlider *tmpSliderRadio;
85 wxSlider *tmpSliderAng;
87 wxFlexGridSizer * sizerDetailOptions = new wxFlexGridSizer(6);
89 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T("Crown ")) , 1, wxGROW );
90 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Sections ")) , 1, wxGROW );
91 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
92 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Radio %")) , 1, wxGROW );
93 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
94 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
98 for (i=0;i<_maxLevels;i++){
99 tmpSpinSection = new wxSpinCtrl( panel , -1,_T(""),wxDefaultPosition, wxSize(40,20) );
100 tmpSliderRadio = new wxSlider( panel , -1 ,0,0,100, wxDefaultPosition, wxSize(110,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
101 tmpSliderAng = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
103 tmpSpinSection ->SetRange(1,_maxSections);
105 tmpwxstring.Printf(_T(" %d. "),i+1);
106 sizerDetailOptions -> Add( new wxStaticText(panel,-1,tmpwxstring) , 1, wxGROW );
107 sizerDetailOptions -> Add( tmpSpinSection, 1 );
108 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
109 sizerDetailOptions -> Add( tmpSliderRadio, 1, wxGROW );
110 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
111 sizerDetailOptions -> Add( tmpSliderAng, 1, wxGROW );
113 tmpSpinSection -> SetValue(5);
114 tmpSliderRadio -> SetValue( 100-(double)((i)*100.0/_maxLevels) );
115 tmpSliderAng -> SetValue(0);
117 Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
118 Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
120 _lstBullEyeDetailNumOfSec.push_back( tmpSpinSection );
121 _lstBullEyeDetailRadio.push_back( tmpSliderRadio );
122 _lstBullEyeDetailAngle.push_back( tmpSliderAng );
126 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
127 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
128 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
129 sizer -> Add( _radioboxBullEyeGenOpt , 1, wxGROW );
130 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
131 sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye general options --")) , 1, wxGROW );
132 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
133 sizer -> Add( sizerGeneralOptions , 1, wxGROW );
134 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
135 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
136 sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye detail options --")) , 1, wxGROW );
137 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
138 sizer -> Add( sizerDetailOptions , 1, wxGROW );
140 Connect( _radioboxBullEyeGenOpt->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
141 Connect( _spinctrlBullEyeNumOfCrowns->GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
143 panel->SetSizer( sizer );
144 panel->SetSize( sizepanel );
145 panel->SetAutoLayout( true );
152 //------------------------------------------------------------------------------------------------------------
153 PanelBullEyeOptions::~PanelBullEyeOptions()
157 //------------------------------------------------------------------------------------------------------------
158 void PanelBullEyeOptions::onRefreshPanel( wxCommandEvent& event )
163 //------------------------------------------------------------------------------------------------------------
164 void PanelBullEyeOptions::RefreshPanel()
168 if (this->_radioboxBullEyeGenOpt->GetSelection()==0){
169 for (i=0; i<_maxLevels; i++)
171 _lstBullEyeDetailNumOfSec[i] -> Enable(false);
172 _lstBullEyeDetailRadio[i] -> Enable(false);
173 _lstBullEyeDetailAngle[i] -> Enable(false);
176 int spinSelec = _spinctrlBullEyeNumOfCrowns->GetValue();
177 for (i=0; i<_maxLevels; i++)
179 ok = (i < spinSelec);
180 _lstBullEyeDetailNumOfSec[i] -> Enable(ok);
181 _lstBullEyeDetailRadio[i] -> Enable(ok);
182 _lstBullEyeDetailAngle[i] -> Enable(ok);
185 if (_lstBullEyeDetailRadio[i]->GetValue() > _lstBullEyeDetailRadio[i-1]->GetValue())
187 _lstBullEyeDetailRadio[i]->SetValue( _lstBullEyeDetailRadio[i-1]->GetValue() );
194 //------------------------------------------------------------------------------------------------------------
195 int PanelBullEyeOptions::GetNumberOfCrowns()
197 return this->_spinctrlBullEyeNumOfCrowns->GetValue();
200 //------------------------------------------------------------------------------------------------------------
201 int PanelBullEyeOptions::GetNumberOfSections(int nCrown)
204 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
206 result = this->_spinctrlBullEyeNumOfSec->GetValue();
208 result = this->_lstBullEyeDetailNumOfSec[nCrown]->GetValue();
213 //------------------------------------------------------------------------------------------------------------
214 int PanelBullEyeOptions::GetRadioOfCrown(int nCrown)
218 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
220 sizeCrowns = (double)( this->_spinctrlBullEyeNumOfCrowns->GetValue() );
221 result = 100.0 * (nCrown+1)/sizeCrowns ;
223 result = this->_lstBullEyeDetailRadio[nCrown]->GetValue();
228 //------------------------------------------------------------------------------------------------------------
229 double PanelBullEyeOptions::GetAngOfCrownSection(int nCrown,int section)
232 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
234 angle = this->_sliderBullEyeAngle->GetValue();
236 angle = this->_lstBullEyeDetailAngle[nCrown]->GetValue();
238 // double numOfSec = (double)GetNumberOfSections(nCrown);
239 double deltaSec = GetAngDeltaOfCrownSection(nCrown);
240 return angle + section*deltaSec ;
243 //------------------------------------------------------------------------------------------------------------
244 double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown)
246 double numOfSec = (double)GetNumberOfSections(nCrown);
247 return 360.0/numOfSec;