2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 //#include "wxContourEventHandler.h"
6 #include "PanelBullEyeOptions.h"
8 //------------------------------------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------------------------------------
12 PanelBullEyeOptions::PanelBullEyeOptions (wxWindow * parent, wxSize size) :
13 wxPanel(parent, -1, wxDefaultPosition, size)
18 wxSize sizepanel(190,300);
19 wxPanel *panel = this;
22 wxString lstOptions[2];
23 lstOptions[0]= wxString("General options",wxConvUTF8);
24 lstOptions[1]= wxString("Detail options",wxConvUTF8);
25 _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, wxString("General/Detail options",wxConvUTF8), wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS);
26 _radioboxBullEyeGenOpt->SetSelection(0);
28 _spinctrlBullEyeNumOfCrowns = new wxSpinCtrl( panel , -1,_T("B"),wxDefaultPosition, wxSize(40,20) );
29 _spinctrlBullEyeNumOfCrowns->SetRange(1,_maxLevels);
30 _spinctrlBullEyeNumOfCrowns->SetValue(3);
32 _spinctrlBullEyeNumOfSec = new wxSpinCtrl( panel , -1,_T("A"),wxDefaultPosition, wxSize(40,20) );
33 _spinctrlBullEyeNumOfSec->SetRange(1,_maxSections);
34 _spinctrlBullEyeNumOfSec->SetValue(5);
37 _sliderBullEyeAngle = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
39 wxFlexGridSizer * sizerGeneralOptions = new wxFlexGridSizer(10);
41 wxFlexGridSizer * sizerGeneralOptionsA = new wxFlexGridSizer(1);
42 wxFlexGridSizer * sizerGeneralOptionsB = new wxFlexGridSizer(1);
43 wxFlexGridSizer * sizerGeneralOptionsC = new wxFlexGridSizer(1);
44 sizerGeneralOptionsA -> Add( new wxStaticText(panel,-1,_T("Crowns")) , 1, wxGROW );
45 sizerGeneralOptionsA -> Add( _spinctrlBullEyeNumOfCrowns , 1/*, wxGROW*/ );
46 sizerGeneralOptionsB -> Add( new wxStaticText(panel,-1,_T("Sections")) , 1, wxGROW );
47 sizerGeneralOptionsB -> Add( _spinctrlBullEyeNumOfSec , 1/*, wxGROW*/ );
48 sizerGeneralOptionsC -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
49 sizerGeneralOptionsC -> Add( _sliderBullEyeAngle , 1/*, wxGROW*/ );
51 sizerGeneralOptions -> Add( sizerGeneralOptionsA , 1/*, wxGROW*/ );
52 sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
53 sizerGeneralOptions -> Add( sizerGeneralOptionsB , 1/*, wxGROW*/ );
54 sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
55 sizerGeneralOptions -> Add( sizerGeneralOptionsC , 1/*, wxGROW*/ );
58 wxSpinCtrl *tmpSpinSection;
59 wxSlider *tmpSliderRadio;
60 wxSlider *tmpSliderAng;
62 wxFlexGridSizer * sizerDetailOptions = new wxFlexGridSizer(6);
64 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T("Crown ")) , 1, wxGROW );
65 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Sections ")) , 1, wxGROW );
66 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
67 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Radio %")) , 1, wxGROW );
68 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
69 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
73 for (i=0;i<_maxLevels;i++){
74 tmpSpinSection = new wxSpinCtrl( panel , -1,_T(""),wxDefaultPosition, wxSize(40,20) );
75 tmpSliderRadio = new wxSlider( panel , -1 ,0,0,100, wxDefaultPosition, wxSize(110,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
76 tmpSliderAng = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
78 tmpSpinSection ->SetRange(1,_maxSections);
80 tmpwxstring.Printf(_T(" %d. "),i+1);
81 sizerDetailOptions -> Add( new wxStaticText(panel,-1,tmpwxstring) , 1, wxGROW );
82 sizerDetailOptions -> Add( tmpSpinSection, 1 );
83 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
84 sizerDetailOptions -> Add( tmpSliderRadio, 1, wxGROW );
85 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
86 sizerDetailOptions -> Add( tmpSliderAng, 1, wxGROW );
88 tmpSpinSection -> SetValue(5);
89 tmpSliderRadio -> SetValue( 100-(double)((i)*100.0/_maxLevels) );
90 tmpSliderAng -> SetValue(0);
92 Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
93 Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
95 _lstBullEyeDetailNumOfSec.push_back( tmpSpinSection );
96 _lstBullEyeDetailRadio.push_back( tmpSliderRadio );
97 _lstBullEyeDetailAngle.push_back( tmpSliderAng );
101 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
102 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
103 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
104 sizer -> Add( _radioboxBullEyeGenOpt , 1, wxGROW );
105 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
106 sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye general options --")) , 1, wxGROW );
107 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
108 sizer -> Add( sizerGeneralOptions , 1, wxGROW );
109 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
110 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
111 sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye detail options --")) , 1, wxGROW );
112 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
113 sizer -> Add( sizerDetailOptions , 1, wxGROW );
115 Connect( _radioboxBullEyeGenOpt->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
116 Connect( _spinctrlBullEyeNumOfCrowns->GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
118 panel->SetSizer( sizer );
119 panel->SetSize( sizepanel );
120 panel->SetAutoLayout( true );
127 //------------------------------------------------------------------------------------------------------------
128 PanelBullEyeOptions::~PanelBullEyeOptions()
132 //------------------------------------------------------------------------------------------------------------
133 void PanelBullEyeOptions::onRefreshPanel( wxCommandEvent& event )
138 //------------------------------------------------------------------------------------------------------------
139 void PanelBullEyeOptions::RefreshPanel()
143 if (this->_radioboxBullEyeGenOpt->GetSelection()==0){
144 for (i=0; i<_maxLevels; i++)
146 _lstBullEyeDetailNumOfSec[i] -> Enable(false);
147 _lstBullEyeDetailRadio[i] -> Enable(false);
148 _lstBullEyeDetailAngle[i] -> Enable(false);
151 int spinSelec = _spinctrlBullEyeNumOfCrowns->GetValue();
152 for (i=0; i<_maxLevels; i++)
154 ok = (i < spinSelec);
155 _lstBullEyeDetailNumOfSec[i] -> Enable(ok);
156 _lstBullEyeDetailRadio[i] -> Enable(ok);
157 _lstBullEyeDetailAngle[i] -> Enable(ok);
160 if (_lstBullEyeDetailRadio[i]->GetValue() > _lstBullEyeDetailRadio[i-1]->GetValue())
162 _lstBullEyeDetailRadio[i]->SetValue( _lstBullEyeDetailRadio[i-1]->GetValue() );
169 //------------------------------------------------------------------------------------------------------------
170 int PanelBullEyeOptions::GetNumberOfCrowns()
172 return this->_spinctrlBullEyeNumOfCrowns->GetValue();
175 //------------------------------------------------------------------------------------------------------------
176 int PanelBullEyeOptions::GetNumberOfSections(int nCrown)
179 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
181 result = this->_spinctrlBullEyeNumOfSec->GetValue();
183 result = this->_lstBullEyeDetailNumOfSec[nCrown]->GetValue();
188 //------------------------------------------------------------------------------------------------------------
189 int PanelBullEyeOptions::GetRadioOfCrown(int nCrown)
193 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
195 sizeCrowns = (double)( this->_spinctrlBullEyeNumOfCrowns->GetValue() );
196 result = 100.0 * (nCrown+1)/sizeCrowns ;
198 result = this->_lstBullEyeDetailRadio[nCrown]->GetValue();
203 //------------------------------------------------------------------------------------------------------------
204 double PanelBullEyeOptions::GetAngOfCrownSection(int nCrown,int section)
207 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
209 angle = this->_sliderBullEyeAngle->GetValue();
211 angle = this->_lstBullEyeDetailAngle[nCrown]->GetValue();
213 double numOfSec = (double)GetNumberOfSections(nCrown);
214 double deltaSec = GetAngDeltaOfCrownSection(nCrown);
215 return angle + section*deltaSec ;
218 //------------------------------------------------------------------------------------------------------------
219 double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown)
221 double numOfSec = (double)GetNumberOfSections(nCrown);
222 return 360.0/numOfSec;