26 #include <wx/wxprec.h>
28 #include "ShowCamWxFormat7Frame.hh"
29 #include "ShowCamWxFrame.hh"
30 #include <Gui/StringConv.hh>
31 #include <Base/Common/FileHandling.hh>
34 #include <wx/choicdlg.h>
42 EVT_CLOSE( ShowCamWxFormat7Frame::OnCloseWindow )
43 EVT_BUTTON( ID_BUTTON_OK,ShowCamWxFormat7Frame::OnButtonOK )
44 EVT_BUTTON( ID_BUTTON_CANCEL,ShowCamWxFormat7Frame::OnButtonCancel)
45 EVT_BUTTON( ID_BUTTON_CHECK,ShowCamWxFormat7Frame::OnButtonCheck)
46 EVT_SCROLL_CHANGED(ShowCamWxFormat7Frame::OnScrollSlider)
47 EVT_SCROLL(ShowCamWxFormat7Frame::OnSlide)
48 EVT_TEXT(ID_TEXT_DA_XOFFSET, ShowCamWxFormat7Frame::OnTextChange)
49 EVT_TEXT(ID_TEXT_DA_YOFFSET, ShowCamWxFormat7Frame::OnTextChange)
50 EVT_TEXT(ID_TEXT_DA_XSIZE, ShowCamWxFormat7Frame::OnTextChange)
51 EVT_TEXT(ID_TEXT_DA_YSIZE, ShowCamWxFormat7Frame::OnTextChange)
62 ShowCamWxFormat7Frame::
63 ShowCamWxFormat7Frame(wxFrame* parent,const wxString& title, const wxPoint& pos,
65 : wxDialog(parent, -1, title, pos, size, wxSTAY_ON_TOP|wxCAPTION|wxRESIZE_BORDER)
68 if(dynamic_cast< ShowCamWxFrame*>(parent) != NULL){
95 yOffsetMin_ = xSizeMin_ = ySizeMin_ = xOffsetMin_=0;
96 yOffsetMax_ = xSizeMax_ = ySizeMax_ = xOffsetMax_ = 1024;
109 itemButtonOK=
new wxButton(
this, ID_BUTTON_OK,
110 _(
"OK"), wxDefaultPosition,
113 itemButtonCancel=
new wxButton(
this, ID_BUTTON_CANCEL,
114 _(
"Cancel"), wxDefaultPosition,
115 wxDefaultSize, 0 );itemButtonCheck=
new wxButton(
this, ID_BUTTON_CHECK,
116 _(
"Check"), wxDefaultPosition,
118 itemButtonCheck->Disable();
121 wxFlexGridSizer* itemFlexGridSizer =
new wxFlexGridSizer(11, 3, 0, 0);
122 this->SetSizer(itemFlexGridSizer);
124 wxSize sliderSize(300,45);
126 xSizeSB =
new wxSlider(
this, ID_SB_XSIZE, 20, xSizeMin_, xSizeMax_,
127 wxDefaultPosition,sliderSize,
128 wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS,
129 wxDefaultValidator, wxT(
"XSize"));
131 ySizeSB =
new wxSlider(
this, ID_SB_YSIZE,20, ySizeMin_, ySizeMax_,
132 wxDefaultPosition,sliderSize,
133 wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS,
134 wxDefaultValidator, wxT(
"YSize"));
136 xOffsetSB =
new wxSlider(
this, ID_SB_XOFFSET,20, xOffsetMin_, xOffsetMax_,
137 wxDefaultPosition,sliderSize,
138 wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS,
139 wxDefaultValidator, wxT(
"XOffset"));
141 yOffsetSB =
new wxSlider(
this, ID_SB_YOFFSET,20, yOffsetMin_, yOffsetMax_,
142 wxDefaultPosition,sliderSize,
143 wxSL_HORIZONTAL | wxSL_LABELS |wxSL_AUTOTICKS,
144 wxDefaultValidator, wxT(
"YOffset"));
146 wxString cm_choices[8];
147 cm_choices[0] = wxT(
"Mono 8bpp");
148 cm_choices[1] = wxT(
"YUV 4:1:1");
149 cm_choices[2] = wxT(
"YUV 4:2:2");
150 cm_choices[3] = wxT(
"YUV 4:4:4");
151 cm_choices[4] = wxT(
"RGB 24bpp");
152 cm_choices[5] = wxT(
"Mono 16bpp");
153 cm_choices[6] = wxT(
"Raw 8bpp");
154 cm_choices[7] = wxT(
"Raw 16bpp");
156 colorModeCB =
new wxChoice(
this, ID_CB_COLORMODE, wxDefaultPosition, wxDefaultSize, 8, cm_choices, 0, wxDefaultValidator, wxT(
"Color Mode for Cam"));
158 wxString cmv_choices[6];
159 cmv_choices[0] = wxT(
"Same as Cam");
160 cmv_choices[1] = wxT(
"Grey");
161 cmv_choices[2] = wxT(
"Bayer BGGR");
162 cmv_choices[3] = wxT(
"Bayer GBRG");
163 cmv_choices[4] = wxT(
"Bayer GRBG");
164 cmv_choices[5] = wxT(
"Bayer RGGB");
166 colorModeViewCB =
new wxChoice(
this,ID_CB_COLORMODEVIEW, wxDefaultPosition, wxDefaultSize, 6, cmv_choices, 0, wxDefaultValidator, wxT(
"Color Mode for Viewing"));
167 BpPSB =
new wxSlider(
this, ID_SB_BPP,20, bppMin_, bppMax_,
168 wxDefaultPosition,sliderSize,
169 wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS,
170 wxDefaultValidator, wxT(
"Bits per packet"));
172 directAccessXSize =
new wxTextCtrl(
this,ID_TEXT_DA_XSIZE, _(
"0"),
173 wxDefaultPosition,wxDefaultSize, 0);
174 directAccessYSize =
new wxTextCtrl(
this,ID_TEXT_DA_YSIZE, _(
"0"),
175 wxDefaultPosition,wxDefaultSize, 0);
176 directAccessXOffset =
new wxTextCtrl(
this,ID_TEXT_DA_XOFFSET, _(
"0"),
177 wxDefaultPosition,wxDefaultSize, 0);
178 directAccessYOffset =
new wxTextCtrl(
this,ID_TEXT_DA_YOFFSET, _(
"0"),
179 wxDefaultPosition,wxDefaultSize, 0);
182 wxStaticText* itemStaticText1 =
183 new wxStaticText(
this, wxID_STATIC, _(
"XSize"),
184 wxDefaultPosition, wxDefaultSize, 0 );
185 itemFlexGridSizer->Add(itemStaticText1, 0,
186 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
187 itemFlexGridSizer->Add(xSizeSB, 0,
188 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
189 itemFlexGridSizer->Add(directAccessXSize,0,wxALIGN_CENTER|wxALL,5);
191 wxStaticText* itemStaticText2 =
192 new wxStaticText(
this, wxID_STATIC, _(
"YSize"),
193 wxDefaultPosition, wxDefaultSize, 0 );
194 itemFlexGridSizer->Add(itemStaticText2, 0,
195 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
196 itemFlexGridSizer->Add(ySizeSB, 0,
197 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
198 itemFlexGridSizer->Add(directAccessYSize,0,wxALIGN_CENTER|wxALL,5);
200 wxStaticText* itemStaticText3 =
201 new wxStaticText(
this, wxID_STATIC, _(
"XOffset"),
202 wxDefaultPosition, wxDefaultSize, 0 );
204 itemFlexGridSizer->Add(itemStaticText3, 0,
205 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
206 itemFlexGridSizer->Add(xOffsetSB, 0,
207 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
209 itemFlexGridSizer->Add(directAccessXOffset,0,wxALIGN_CENTER|wxALL,5);
211 wxStaticText* itemStaticText4 =
212 new wxStaticText(
this, wxID_STATIC, _(
"YOffset"),
213 wxDefaultPosition, wxDefaultSize, 0 );
214 itemFlexGridSizer->Add(itemStaticText4, 0,
215 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
216 itemFlexGridSizer->Add(yOffsetSB, 0,
217 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
218 itemFlexGridSizer->Add(directAccessYOffset,0,wxALIGN_CENTER|wxALL,5);
220 wxStaticText* itemStaticText5 =
221 new wxStaticText(
this, wxID_STATIC, _(
"Color Mode for cam"),
222 wxDefaultPosition, wxDefaultSize, 0 );
223 itemFlexGridSizer->Add(itemStaticText5, 0,
224 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
225 itemFlexGridSizer->Add(colorModeCB, 0,
226 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
227 itemFlexGridSizer->Add(itemButtonCheck,0,wxALIGN_CENTER|wxALL,5);
229 wxStaticText* itemStaticText51 =
230 new wxStaticText(
this, wxID_STATIC, _(
"Color Mode for view"),
231 wxDefaultPosition, wxDefaultSize, 0 );
232 itemFlexGridSizer->Add(itemStaticText51, 0,
233 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
234 itemFlexGridSizer->Add(colorModeViewCB, 0,
235 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
236 itemFlexGridSizer->AddSpacer(10);
238 wxStaticText* itemStaticText6 =
239 new wxStaticText(
this, wxID_STATIC, _(
"Bits per packet"),
240 wxDefaultPosition, wxDefaultSize, 0 );
241 itemFlexGridSizer->Add(itemStaticText6, 0,
242 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
243 itemFlexGridSizer->Add(BpPSB, 0,
244 wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
245 itemStaticTextFPS =
new wxTextCtrl(
this,ID_TEXT_FPS, _(
"= 0.0 FPS"),
246 wxDefaultPosition,wxDefaultSize, 0);
247 itemFlexGridSizer->Add(itemStaticTextFPS,0,wxALIGN_CENTER|wxALL,5);
252 wxBoxSizer *boxSizerCCD =
new wxBoxSizer(wxHORIZONTAL);
253 boxSizerCCD->Add(itemButtonOK, 1,wxEXPAND|wxALL,2);
254 boxSizerCCD->Add(itemButtonCancel, 1,wxEXPAND|wxALL,2);
255 itemFlexGridSizer->Add(5, 5, 0,
256 wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
257 itemFlexGridSizer->Add(boxSizerCCD, 0,
258 wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
278 if((ySizeSB->GetValue() % 2) != 0){
279 wxMessageDialog* dialog =
new wxMessageDialog(
this, wxT(
"Y-Size has to be an even value"),wxT(
"Message box"),wxOK,wxDefaultPosition);
285 xSize = xSizeSB->GetValue();
286 ySize = ySizeSB->GetValue();
287 xOffset = xOffsetSB->GetValue();
288 yOffset = yOffsetSB->GetValue();
289 bpp = BpPSB->GetValue();
290 #ifdef BIAS_HAVE_DCAM
291 switch (colorModeCB->GetSelection()) {
293 colorMode = DC1394_COLOR_CODING_MONO8;
296 colorMode = DC1394_COLOR_CODING_YUV411;
299 colorMode = DC1394_COLOR_CODING_YUV422;
302 colorMode = DC1394_COLOR_CODING_YUV444;
305 colorMode = DC1394_COLOR_CODING_RGB8;
308 colorMode = DC1394_COLOR_CODING_MONO16;
311 colorMode = DC1394_COLOR_CODING_RAW8;
314 colorMode = DC1394_COLOR_CODING_RAW16;
317 colorMode = DC1394_COLOR_CODING_MONO8;
321 switch(colorModeViewCB->GetSelection()){
338 #endif // BIAS_HAVE_DCAM
340 #if wxCHECK_VERSION(2, 9, 0)
343 this->MakeModal(
false);
347 this->SetReturnCode(wxID_OK);
352 #if wxCHECK_VERSION(2, 9, 0)
355 this->MakeModal(
false);
363 if(wxAtoi(directAccessXSize->GetValue()) != xSizeSB->GetValue()){
364 xSizeSB->SetValue(wxAtoi(directAccessXSize->GetValue()));
365 ScrollSliderHelper(xSizeSB,xSize,xSizeMin_);
368 if(wxAtoi(directAccessYSize->GetValue()) != ySizeSB->GetValue()){
369 ySizeSB->SetValue(wxAtoi(directAccessYSize->GetValue()));
370 ScrollSliderHelper(ySizeSB,ySize,ySizeMin_);
373 if(wxAtoi(directAccessXOffset->GetValue()) != xOffsetSB->GetValue()){
374 xOffsetSB->SetValue(wxAtoi(directAccessXOffset->GetValue()));
375 ScrollSliderHelper(xOffsetSB,xSize,xSizeMin_,xSizeMax_,xSizeSB,
true);
378 if(wxAtoi(directAccessYOffset->GetValue()) != yOffsetSB->GetValue()){
379 yOffsetSB->SetValue(wxAtoi(directAccessYOffset->GetValue()));
380 ScrollSliderHelper(yOffsetSB,ySize,ySizeMin_,ySizeMax_,ySizeSB,
true);
383 AdjustBytesPerPacket();
387 itemButtonOK->Enable();
393 itemButtonOK->Disable();
394 itemButtonCheck->Enable();
400 int value = slider->GetValue();
401 int diff = abs(size -value);
403 if(diff > sizeMin/2){
404 int mod = value % sizeMin;
406 if(mod > (sizeMin/2))
407 value = value + (sizeMin - mod);
411 slider->SetValue(value);
414 }
else if(diff < sizeMin/2){
416 value = size - sizeMin;
417 }
else if(size -value < 0){
418 value = size + sizeMin;
420 slider->SetValue(value);
423 sliderSize->SetMax(sizeMax - slider->GetValue());
426 if(slider->GetId() == ID_SB_XSIZE) directAccessXSize->SetValue(wxString::Format(wxT(
"%d"), value));
427 if(slider->GetId() == ID_SB_YSIZE) directAccessYSize->SetValue(wxString::Format(wxT(
"%d"), value));
428 if(slider->GetId() == ID_SB_XOFFSET) directAccessXOffset->SetValue(wxString::Format(wxT(
"%d"), value));
429 if(slider->GetId() == ID_SB_YOFFSET) directAccessYOffset->SetValue(wxString::Format(wxT(
"%d"), value));
434 #ifdef BIAS_HAVE_DCAM
435 unsigned int minbpp, maxbpp;
436 dcam->GetBytesPerPacketForFormat7(CamID_, Mode_,xSizeSB->GetValue(), ySizeSB->GetValue(), minbpp, maxbpp);
438 BpPSB->SetRange(minbpp,maxbpp);
445 int id =
event.GetId();
449 if(
id == ID_SB_XSIZE){
450 ScrollSliderHelper(xSizeSB,xSize,xSizeMin_);
451 AdjustBytesPerPacket();
454 if(
id == ID_SB_XOFFSET){
455 ScrollSliderHelper(xOffsetSB,xSize,xSizeMin_,xSizeMax_,xSizeSB,
true);
458 if(
id == ID_SB_YSIZE){
459 ScrollSliderHelper(ySizeSB,ySize,ySizeMin_);
460 AdjustBytesPerPacket();
463 if(
id == ID_SB_YOFFSET){
464 ScrollSliderHelper(yOffsetSB,ySize,ySizeMin_,ySizeMax_,ySizeSB,
true);
468 int value = BpPSB->GetValue();
469 int mod = value % bppMin_;
471 if(mod > (bppMin_/2))
472 value = value + (bppMin_ - mod);
476 BpPSB->SetValue(value);
484 if(event.GetId() == ID_SB_BPP){
488 if(event.GetId() == ID_SB_XOFFSET){
490 xSizeSB->SetMax(xSizeMax_ - xOffsetSB->GetValue());
494 if (event.GetId() == ID_SB_YOFFSET){
495 ySizeSB->SetMax(ySizeMax_ - yOffsetSB->GetValue());
505 switch (colorModeCB->GetSelection()) {
524 int denom = 8 * BpPSB->GetValue();
527 int num_packets = (xSizeSB->GetValue() * ySizeSB->GetValue() * depth + denom -1)/denom;
529 int fps = 1.0/((double)0.000125 * (
double)num_packets);
531 wxString stringnumber = wxString::Format(wxT(
" = %d fps"), (
int)fps);
533 itemStaticTextFPS->SetValue(stringnumber);
Bayer_GRBG, 1 channel RGB image Bayer tile.
Bayer_RGGB, 1 channel RGB image Bayer tile.
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
Bayer_BGGR, 1 channel RGB image Bayer tile.
Bayer_GBRG, 1 channel RGB image Bayer tile.
invalid (not set) image format