25 #include <Base/Common/BIASpragmaStart.hh>
29 # pragma warning(disable: 4005)
32 #include <Gui/StringConv.hh>
34 #include "VideoSource_Controller_SwissRanger.hh"
35 #include <Base/Common/getopt_W32.h>
36 #include <Base/Image/ImageIO.hh>
37 #include <Image/Camera.hh>
38 #include <Gui/StringConv.hh>
59 ,wxDefaultPosition,wxSize(500,500),wxSTAY_ON_TOP |wxCAPTION)
63 SliderAmplitude = NULL;
64 SliderSaturation = NULL;
65 SliderIntegration = NULL;
66 mIntTimeMs = NULL,mSaturation = NULL,mAmplitude = NULL,mDistance = NULL;
67 SliderDistanceOffset = NULL;
68 comboBoxModFreq = NULL;
69 checkBoxEnsureLatest = NULL;
70 checkBoxShowDepth = NULL;
71 sliderBox_ShGa = NULL;
75 min_amplitudeThreshold_=0; max_amplitudeThreshold_=2000;
76 min_saturationThreshold_=0; max_saturationThreshold_=2000;
77 min_integrationTime_=0; max_integrationTime_=0xFF;
78 min_distanceOffset_=0; max_distanceOffset_=10000;
83 SetAmplitudeThresholdRange(min_amplitudeThreshold_, max_amplitudeThreshold_);
84 SetSaturationThresholdRange(min_saturationThreshold_, max_saturationThreshold_);
85 SetDistanceOffsetRange(min_distanceOffset_, max_distanceOffset_);
86 SetIntegrationTimeRange(min_integrationTime_, max_integrationTime_);
91 VideoSource_Controller_SwissRanger::
92 ~VideoSource_Controller_SwissRanger()
95 void VideoSource_Controller_SwissRanger::
98 sliderBox_ShGa_Visible =
true;
101 wxSize SlSize(200,35);
102 wxSize BtSize(80,30);
103 wxSize reduzedDefSize(60,wxDefaultSize.y);
105 wxFlexGridSizer* itemFlexGridSizer =
new wxFlexGridSizer(11, 3, 0, 0);
106 this->SetSizer(itemFlexGridSizer);
107 wxStaticText *tInt =
new wxStaticText(
this,ID_TEXT, wxT(
"Integration Time"));
108 SliderIntegration =
new wxSlider(
this, ID_INT, 0, 0, 30000,
109 wxDefaultPosition,SlSize,
110 wxSL_HORIZONTAL |wxSL_LABELS,
111 wxDefaultValidator, wxT(
"Int"));
113 SliderIntegration->Enable(
true);
115 mIntTimeMs =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, reduzedDefSize, 0 );
116 mIntTimeMs->SetMaxLength( 4 );
117 mIntTimeMs->Enable(
false );
119 wxStaticText *tms =
new wxStaticText(
this,ID_TEXT, wxT(
"ms"));
120 wxBoxSizer *vbms =
new wxBoxSizer(wxHORIZONTAL);
121 vbms->Add(mIntTimeMs,0,wxALIGN_LEFT | wxBOTTOM);
122 vbms->Add(tms, 0, wxALIGN_RIGHT | wxBOTTOM);
124 itemFlexGridSizer->Add(tInt, 0,
125 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
126 itemFlexGridSizer->Add(SliderIntegration, 0,
127 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
128 itemFlexGridSizer->Add(vbms, 0,
129 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
131 wxStaticText *tAmp =
new wxStaticText(
this,ID_TEXT, wxT(
"Amplitude Threshold"));
133 SliderAmplitude =
new wxSlider(
this, ID_AMP, 0, 0, 30000,
134 wxDefaultPosition,SlSize,
135 wxSL_HORIZONTAL | wxSL_LABELS ,
136 wxDefaultValidator, wxT(
"Amp"));
137 mAmplitude =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
138 mAmplitude->SetMaxLength( 4 );
139 mAmplitude->Enable(
false );
141 SliderAmplitude->Enable(
true);
142 itemFlexGridSizer->Add(tAmp, 0,
143 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
144 itemFlexGridSizer->Add(SliderAmplitude, 0,
145 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
146 itemFlexGridSizer->Add(mAmplitude, 0,
147 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
149 wxStaticText *tSat =
new wxStaticText(
this,ID_TEXT, wxT(
"Saturation Threshold"));
150 SliderSaturation =
new wxSlider(
this, ID_SAT, 0, 0, 30000,
151 wxDefaultPosition,SlSize,
152 wxSL_HORIZONTAL | wxSL_LABELS,
153 wxDefaultValidator, wxT(
"Sat"));
154 mSaturation =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
155 mSaturation->SetMaxLength( 4 );
156 mSaturation->Enable(
false );
158 SliderSaturation->Enable(
true);
159 itemFlexGridSizer->Add(tSat, 0,
160 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
161 itemFlexGridSizer->Add(SliderSaturation, 0,
162 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
163 itemFlexGridSizer->Add(mSaturation, 0,
164 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
167 wxStaticText *tDist =
new wxStaticText(
this,ID_TEXT, wxT(
"Distance Offset"));
168 SliderDistanceOffset =
new wxSlider(
this, ID_DIST, 0, 0, 30000,
169 wxDefaultPosition,SlSize,
170 wxSL_HORIZONTAL | wxSL_LABELS,
171 wxDefaultValidator, wxT(
"Dist"));
172 SliderDistanceOffset->Enable(
true);
174 mDistance =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, reduzedDefSize, 0 );
175 mDistance->SetMaxLength( 4 );
176 mDistance->Enable(
false );
178 wxStaticText *tms2 =
new wxStaticText(
this,ID_TEXT, wxT(
"mm"));
179 wxBoxSizer *vbmd =
new wxBoxSizer(wxHORIZONTAL);
180 vbmd->Add(mDistance,0,wxALIGN_LEFT | wxBOTTOM);
181 vbmd->Add(tms2, 0, wxALIGN_RIGHT | wxBOTTOM);
183 itemFlexGridSizer->Add(tDist, 0,
184 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
185 itemFlexGridSizer->Add(SliderDistanceOffset, 0,
186 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
187 itemFlexGridSizer->Add(vbmd, 0,
188 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
191 wxBoxSizer *slMod =
new wxBoxSizer(wxVERTICAL);
192 wxStaticText *tMod =
new wxStaticText(
this,ID_TEXT, wxT(
"Modulation Freq"));
193 wxSize comboSize(150,25);
194 wxString choices[10] = {wxT(
"MF_60MHz"),
204 comboBoxModFreq =
new wxComboBox(
this,ID_MOD,wxT(
"ModFreq"),wxDefaultPosition,
205 comboSize,10,choices,wxCB_READONLY);
206 comboBoxModFreq->SetSelection(6,6);
207 comboBoxModFreq->SetValue(wxT(
"MF_20MHz"));
209 comboBoxModFreq->Enable(
true);
210 slMod->Add(tMod,0,wxALL,2);
211 slMod->Add(comboBoxModFreq,0, wxALL,2);
213 checkBoxEnsureLatest =
new wxCheckBox(
this, ID_CHECK_ENSURELATEST, wxT(
"Ensure Latest"), wxDefaultPosition, wxDefaultSize, 0 );
214 checkBoxShowDepth =
new wxCheckBox(
this, ID_CHECK_SHOWDEPTH, wxT(
"Show Depth"), wxDefaultPosition, wxDefaultSize, 0 );
215 wxBoxSizer *slCheckBox =
new wxBoxSizer(wxVERTICAL);
216 slCheckBox->Add( checkBoxEnsureLatest, 0, wxALL, 5 );
217 slCheckBox->Add( checkBoxShowDepth, 0, wxALL, 5 );
219 wxBoxSizer *slButton =
new wxBoxSizer(wxVERTICAL);
220 showButton =
new wxButton(
this, ID_HIDE, wxT(
"Hide"),
221 wxDefaultPosition,BtSize);
222 update_Button =
new wxButton(
this, ID_BUTTON_UPDATE,
223 wxT(
"Update"),wxDefaultPosition,BtSize);
225 slButton->Add(showButton,0,wxALIGN_LEFT | wxBOTTOM);
226 slButton->Add(update_Button, 0, wxALIGN_RIGHT | wxBOTTOM);
228 itemFlexGridSizer->Add(slMod,0,wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
229 itemFlexGridSizer->Add(slCheckBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
230 itemFlexGridSizer->Add(slButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
239 void VideoSource_Controller_SwissRanger::
246 void VideoSource_Controller_SwissRanger::
247 OnHide(wxCommandEvent& event){
251 void VideoSource_Controller_SwissRanger::
252 OnClose(wxCloseEvent& event) {
257 void VideoSource_Controller_SwissRanger::
258 OnAmplitude(wxScrollEvent& event) {
259 double value = SliderAmplitude->GetValue();
261 Cam_->SetAmplitudeThreshold((
unsigned short)value);
264 Cam_->GetAmplitudeThreshold(val);
266 mAmplitude->SetValue(tval);
270 void VideoSource_Controller_SwissRanger::
271 OnSaturation(wxScrollEvent& event) {
272 double value = SliderSaturation->GetValue();
274 Cam_->SetSaturationThreshold((
unsigned short)value);
277 Cam_->GetSaturationThreshold(val);
279 mSaturation->SetValue(tval);
283 void VideoSource_Controller_SwissRanger::
284 OnIntegration(wxScrollEvent& event) {
285 double value = SliderIntegration->GetValue();
287 Cam_->SetIntegrationTime((
unsigned char)value);
291 Cam_->GetIntegrationTimeMS(fval);
293 mIntTimeMs->SetValue(tval);
296 void VideoSource_Controller_SwissRanger::
297 OnModFreq(wxCommandEvent& event) {
298 std::string text = WxToAscii(comboBoxModFreq->GetValue());
299 ModulationFrq freq = MF_20MHz;
301 if(text.compare(
"MF_60MHz") == 0)
303 else if(text.compare(
"MF_40MHz") == 0)
305 else if(text.compare(
"MF_31MHz") == 0)
307 else if(text.compare(
"MF_30MHz") == 0)
309 else if(text.compare(
"MF_29MHz") == 0)
311 else if(text.compare(
"MF_21MHz") == 0)
313 else if(text.compare(
"MF_20MHz") == 0)
315 else if(text.compare(
"MF_19MHz") == 0)
317 else if(text.compare(
"MF_15MHz") == 0)
319 else if(text.compare(
"MF_10MHz") == 0)
323 Cam_->SetModulationFrequency(freq);
327 void VideoSource_Controller_SwissRanger::
328 OnDistance(wxScrollEvent& event) {
329 double value = SliderDistanceOffset->GetValue();
331 Cam_->SetDistanceOffset((
unsigned short)value);
334 Cam_->GetDistanceOffset(val);
336 mDistance->SetValue(tval);
342 void VideoSource_Controller_SwissRanger::
345 unsigned short currentShort =0;
346 unsigned char currentChar =0;
347 unsigned int currentInt = 0;
349 Cam_->GetAmplitudeThreshold(currentShort);
350 SliderAmplitude->SetValue(
int(currentShort));
351 Cam_->GetSaturationThreshold(currentShort);
352 SliderSaturation->SetValue(
int(currentShort));
353 Cam_->GetIntegrationTime(currentChar);
354 SliderIntegration->SetValue(
int(currentChar));
355 Cam_->GetDistanceOffset(currentShort);
356 SliderDistanceOffset->SetValue(
int(currentShort));
357 unsigned int freq = MF_20MHz;
358 Cam_->GetModulationFrequency(freq);
362 else if(freq == MF_40MHz)
364 else if(freq == MF_31MHz)
366 else if(freq == MF_30MHz)
368 else if(freq == MF_29MHz)
370 else if(freq == MF_21MHz)
372 else if(freq == MF_20MHz)
374 else if(freq == MF_19MHz)
376 else if(freq == MF_15MHz)
378 else if(freq == MF_10MHz)
381 comboBoxModFreq->SetSelection(currentInt,currentInt);
386 void VideoSource_Controller_SwissRanger::
387 OnUpdate(wxCommandEvent& event) {
391 void VideoSource_Controller_SwissRanger::
392 SetAmplitudeThresholdRange(
unsigned int min,
unsigned int max)
394 SliderAmplitude->SetRange(min,max);
398 void VideoSource_Controller_SwissRanger::
399 SetSaturationThresholdRange(
unsigned int min,
unsigned int max)
401 SliderSaturation->SetRange(min,max);
406 void VideoSource_Controller_SwissRanger::
407 SetDistanceOffsetRange(
unsigned int min,
unsigned int max)
409 SliderDistanceOffset->SetRange(min,max);
412 void VideoSource_Controller_SwissRanger::
413 SetIntegrationTimeRange(
unsigned int min,
unsigned int max)
415 SliderIntegration->SetRange(min,max);
418 void VideoSource_Controller_SwissRanger::
419 OnCheckEnsureLatest(wxCommandEvent& event) {
420 Cam_->EnsureLatestFrame(event.IsChecked());
423 void VideoSource_Controller_SwissRanger::
424 OnCheckShowDepth(wxCommandEvent& event) {
425 Cam_->GrabImageReturnsDepth(event.IsChecked());
429 #include <Base/Common/BIASpragmaEnd.hh>
Defines a common interface to different devices.
Support for SwissRanger usb cam.