Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_Controller_PMDZess.cpp
1 #ifdef WIN32
2 // workaround for wx 2.6.x redefiniton of _CRT_SECURE_NO_DEPRECATE
3 // fixed in wx 2.7.2
4 # pragma warning(disable: 4005)
5 #endif
6 
7 #include "VideoSource_Controller_PMDZess.hh"
8 
9 #ifdef WIN32
10 # include <Base/Common/getopt_W32.h>
11 #endif
12 
13 #include <iostream>
14 #include <Base/Image/ImageIO.hh>
15 #include <Image/Camera.hh>
16 #include <Gui/StringConv.hh>
17 
18 using namespace std;
19 using namespace BIAS;
20 
21 BEGIN_EVENT_TABLE(VideoSource_Controller_PMDZess, wxFrame)
22  EVT_BUTTON(ID_HIDE, VideoSource_Controller_PMDZess::OnHide)
23  EVT_BUTTON(ID_MODULATIONFREQUENCY, VideoSource_Controller_PMDZess::OnModFreq)
24  EVT_COMMAND_SCROLL(ID_GAIN2D, VideoSource_Controller_PMDZess::OnGain2D)
25  EVT_COMMAND_SCROLL(ID_SHUTTER2D, VideoSource_Controller_PMDZess::OnShutter2D)
26  EVT_COMMAND_SCROLL(ID_SHUTTER3D, VideoSource_Controller_PMDZess::OnShutter3D)
27  EVT_BUTTON(ID_BUTTON_UPDATE, VideoSource_Controller_PMDZess::OnUpdate)
28 END_EVENT_TABLE()
29 
30 
31 
32 
34 VideoSource_Controller_PMDZess(VideoSource *cam, wxFrame *parent, const std::string& title)
35  : VideoSource_Controller_Base(parent, -1, AsciiToWx(title)
36  ,wxDefaultPosition,wxSize(500,500),wxSTAY_ON_TOP |wxCAPTION){
37 
38  Initialize();
39  SetShutter2DRange();
40  SetShutter3DRange();
41  SetGain2DRange();
42  Cam_ = dynamic_cast<VideoSource_PMDZess*>(cam);
43 
44 }
45 
46 
47 
48 VideoSource_Controller_PMDZess::
49 ~VideoSource_Controller_PMDZess()
50 {
51 
52 }
53 
54 void VideoSource_Controller_PMDZess::
55 Initialize(){
56 
57  sliderBox_ShGa_Visible = true;
58  vBoxVisible = true;
59 
60  wxSize SlSize(100,200);
61  wxSize BtSize(55,30);
62 
63  //Gain 2D Part
64  wxBoxSizer *slGa = new wxBoxSizer(wxVERTICAL);
65  wxStaticText *textGain = new wxStaticText(this,ID_TEXT, wxT("Gain 2D\n[dB]"));
66  SliderGain2D = new wxSlider(this, ID_GAIN2D, 0, 0, 30000,
67  wxDefaultPosition,SlSize,
68  wxSL_VERTICAL | wxSL_LABELS | wxSL_RIGHT,
69  wxDefaultValidator, wxT("Gain2D"));
70 
71  SliderGain2D->Enable(true);
72  slGa->Add(textGain,0,wxALL,2);
73  slGa->Add(SliderGain2D,0, wxALL,2);
74 
75  //Shutter 2D
76  wxBoxSizer *slSh = new wxBoxSizer(wxVERTICAL);
77  wxStaticText *textShutter = new wxStaticText(this,ID_TEXT, wxT("Shutter 2D\n[ms*100]"));
78  SliderShutter2D = new wxSlider(this, ID_SHUTTER2D, 20, 0, 80000,
79  wxDefaultPosition,SlSize,
80  wxSL_VERTICAL | wxSL_LABELS | wxSL_RIGHT,
81  wxDefaultValidator, wxT("Shutter2D"));
82 
83  SliderShutter2D->Enable(true);
84  slSh->Add(textShutter,0,wxALL,2);
85  slSh->Add(SliderShutter2D,0,wxALL, 2);
86 
87 
88  //Shutter 3D
89  wxBoxSizer *slSh3D = new wxBoxSizer(wxVERTICAL);
90  wxStaticText *textShutter3D = new wxStaticText(this,ID_TEXT, wxT("Shutter 3D\n[ms*100]"));
91  SliderShutter3D = new wxSlider(this, ID_SHUTTER3D, 20, 0, 80000,
92  wxDefaultPosition,SlSize,
93  wxSL_VERTICAL | wxSL_LABELS | wxSL_RIGHT,
94  wxDefaultValidator, wxT("Shutter3D"));
95 
96  SliderShutter3D->Enable(true);
97  slSh3D->Add(textShutter3D,0,wxALL,2);
98  slSh3D->Add(SliderShutter3D,0,wxALL, 2);
99 
100  //ModulationFrequency
101  wxBoxSizer *boxModFreq = new wxBoxSizer(wxVERTICAL);
102  wxStaticText *textModFreq = new wxStaticText(this,ID_TEXT, wxT("Modulation\nFrequency\n[MHz]"));
103  modulationFreqText = new wxTextCtrl(this,ID_MODULATION_TEXT,"20.0",
104  wxDefaultPosition,wxSize(50,20));
105  setModFreqButton = new wxButton(this, ID_MODULATIONFREQUENCY, wxT("SetModFreq"),
106  wxDefaultPosition,wxSize(100,50));
107 
108  boxModFreq->Add(textModFreq,0,wxALL|wxCENTER,2);
109  boxModFreq->Add(modulationFreqText,0,wxALL|wxCENTER,2);
110  boxModFreq->Add(setModFreqButton,0,wxALL|wxCENTER,2);
111 
112  wxBoxSizer *sl = new wxBoxSizer(wxHORIZONTAL);
113  sl->Add(slGa,0,wxALL, 2);
114  sl->Add(slSh,0,wxALL,2);
115  sl->Add(slSh3D,0,wxALL,2);
116  sl->Add(boxModFreq,0,wxALL,2);
117 
118  showButton = new wxButton(this, ID_HIDE, wxT("Hide"),
119  wxDefaultPosition,BtSize);
120  update_Button = new wxButton(this, ID_BUTTON_UPDATE,
121  wxT("UPDATE"),wxDefaultPosition,BtSize);
122 
123  vBox = new wxBoxSizer(wxHORIZONTAL);
124  vBox->Add(showButton,0,wxALIGN_LEFT | wxBOTTOM);
125  vBox->Add(update_Button, 0, wxALIGN_RIGHT | wxBOTTOM);
126 
127 
128  sliderBox_ShGa = new wxBoxSizer(wxVERTICAL);
129  sliderBox_ShGa->Add(sl,0,wxALL, 2);
130  sliderBox_ShGa->Add(vBox,0,wxALL,2);
131 
132  vBox->SetSizeHints(this);
133  this->SetSizer(sliderBox_ShGa);
134  SetAutoLayout(true);
135  Layout();
136  Fit();
137  wxCommandEvent fakeEvent;
138  // OnUpdate(fakeEvent);
139  Show(TRUE);
140 }
141 
142 void VideoSource_Controller_PMDZess::
143 SetVideoSource(BIAS::VideoSource *cam){
144  Cam_ = cam;
145 }
146 
147 
148 void VideoSource_Controller_PMDZess::
149 OnHide(wxCommandEvent& event){
150  Show(false);
151 }
152 
153 void VideoSource_Controller_PMDZess::
154 OnClose(wxCloseEvent& event) {
155 
156  Show(false);
157 }
158 
159 void VideoSource_Controller_PMDZess::
160 OnModFreq(wxCommandEvent& event) {
161  wxString modFreq = modulationFreqText->GetValue();
162  double current =0.0;
163  int res = modFreq.ToDouble(&current);
164  if (res >=0 && Cam_!= NULL) {
165  //Cam_->SetModulationFrequency(rint(current));
166  cout<<"Setting ModulationFreq "<<current<<endl;
167  }
168 }
169 
170 void VideoSource_Controller_PMDZess::
171 OnGain2D(wxScrollEvent& event) {
172  double value = SliderGain2D->GetValue();
173  if (Cam_!= NULL) {
174  //Cam_->SetGain2D(value);
175  BIASERR("Not working");
176  }
177  cout<<"Setting Gain 2D "<<value/100.0f<<endl;
178 }
179 
180 void VideoSource_Controller_PMDZess::
181 OnShutter2D(wxScrollEvent& event) {
182  double value = SliderShutter2D->GetValue();
183  if (Cam_!= NULL) {
184  Cam_->SetShutter2D(value/100.0);
185  }
186 }
187 
188 void VideoSource_Controller_PMDZess::
189 OnShutter3D(wxScrollEvent& event) {
190  double value = SliderShutter3D->GetValue();
191  if (Cam_!= NULL) {
192  Cam_->SetShutter3D(value/100.0);
193  }
194 }
195 
196 
197 void VideoSource_Controller_PMDZess::
198 Update() {
199  if (Cam_!= NULL) {
200  float currentShutter2D =0.0;
201  currentShutter2D = Cam_->GetShutter2D();
202  SliderShutter2D->SetValue(int(currentShutter2D*100.0));
203 
204  float currentShutter3D= Cam_->GetShutter3D();
205  SliderShutter3D->SetValue(int(currentShutter3D*100.0f));
206 
207  float currentGain2D = Cam_->GetGain2D();
208  SliderGain2D->SetValue(int(currentGain2D));
209 
210  int modFreq = Cam_->GetModulationFrequency();
211  if(modFreq <= 0)
212  BIASERR("Camera returned wrong Modulation Frequency");
213  wxString text;
214  text.Printf(wxT("%d"),modFreq );
215  modulationFreqText->SetValue(text);
216  }
217 }
218 
219 void VideoSource_Controller_PMDZess::
220 OnUpdate(wxCommandEvent& event) {
221  Update();
222 }
223 
224 void VideoSource_Controller_PMDZess::
225 SetShutter2DRange(unsigned int min,unsigned int max)
226 {
227  SliderShutter2D->SetRange(min,max);
228 
229 }
230 
231 void VideoSource_Controller_PMDZess::
232 SetShutter3DRange(unsigned int min,unsigned int max)
233 {
234  SliderShutter3D->SetRange(min,max);
235 
236 }
237 
238 void VideoSource_Controller_PMDZess::
239 SetGain2DRange(unsigned int min,unsigned int max)
240 {
241  SliderGain2D->SetRange(min,max);
242 }
represents Zess PMD camera driver interface TODO: include support for normal images (2DImg_)...
Defines a common interface to different devices.