7#include "ui_mainwindow.h"
24 dc1394Thread(loc,rem),
37 connect(ui->tabWidget,
SIGNAL(currentChanged(
int)),
38 this,SLOT(onTabClicked(
int)));
50void MainWindow::onTabClicked(
int index)
52 if(index == 0 || index == 1){
53 for(
int i=0;i<m_pSli.count();i++){
59void MainWindow::initMainWindow()
61 setWindowTitle(
"Grabber Remote GUI");
97 video_rate_labels <<
"1.875 fps" <<
"3.75 fps" <<
"7.5 fps" <<
"15 fps" <<
"30 fps" <<
"60 fps" <<
"120 fps" <<
"240 fps";
98 color_coding_labels <<
"MONO8" <<
"YUV411" <<
"YUV422" <<
"YUV444" <<
"RGB8" <<
"MONO16" <<
"RGB16" <<
"MONO16S" <<
"RGB16S" <<
"RAW8" <<
"RAW16";
99 iso_speed_labels <<
"100 Mbps" <<
"200 Mbps" <<
"400 Mbps" <<
"800 Mbps" <<
"1600 Mbps" <<
"3200 Mbps";
102 connect(ui->btnRefresh1,
SIGNAL(clicked()),
this,SLOT(onReloadClicked()));
103 connect(ui->btnRefresh2,
SIGNAL(clicked()),
this,SLOT(onReloadClicked()));
106 connect(&dc1394Thread,
SIGNAL(initFormatTabDone(uint,uint,uint)),
107 this,SLOT(initFormatTab(uint,uint,uint)),Qt::QueuedConnection);
108 connect(&dc1394Thread,
SIGNAL(initDone(uint,uint,uint,
bool,uint,QSize,QSize,QSize,QSize,QSize,uint,
bool)),
109 this,SLOT(Init(uint,uint,uint,
bool,uint,QSize,QSize,QSize,QSize,QSize,uint,
bool)),Qt::QueuedConnection);
110 connect(&dc1394Thread,
SIGNAL(reloadDone(uint,uint,QSize,QSize,QSize,QSize,QSize,uint,uint,uint,uint,uint)),
111 this,SLOT(Reload(uint,uint,QSize,QSize,QSize,QSize,QSize,uint,uint,uint,uint,uint)),Qt::QueuedConnection);
112 connect(&dc1394Thread,
SIGNAL(loadDefaultDone(uint,uint,
bool)),
113 this,SLOT(loadDefault(uint,uint,
bool)),Qt::QueuedConnection);
114 connect(&dc1394Thread,
SIGNAL(resetDone(uint,uint,
bool)),
115 this,SLOT(reset(uint,uint,
bool)),Qt::QueuedConnection);
116 connect(&dc1394Thread,
SIGNAL(setTransmissionDC1394Done()),
117 this,SLOT(onTransmissionOnoffDone()),Qt::QueuedConnection);
118 connect(&dc1394Thread,
SIGNAL(setPowerDC1394Done()),
119 this,SLOT(onPowerOnoffDone()),Qt::QueuedConnection);
120 connect(&dc1394Thread,
SIGNAL(setFormat7WindowDC1394Done()),
121 this,SLOT(onFormat7WindowDone()),Qt::QueuedConnection);
122 connect(&dc1394Thread,
SIGNAL(setVideoModeDC1394Done()),
123 this,SLOT(onVideoFormatCurrentDone()),Qt::QueuedConnection);
124 connect(&dc1394Thread,
SIGNAL(setColorCodingDC1394Done()),
125 this,SLOT(onColorCodingDone()),Qt::QueuedConnection);
126 connect(&dc1394Thread,
SIGNAL(setFPSDC1394Done()),
127 this,SLOT(onFramerateDone()),Qt::QueuedConnection);
128 connect(&dc1394Thread,
SIGNAL(setISOSpeedDC1394Done()),
129 this,SLOT(onISOSpeedDone()),Qt::QueuedConnection);
130 connect(&dc1394Thread,
SIGNAL(setBytesPerPacketDC1394Done()),
131 this,SLOT(onSizeByteDone()),Qt::QueuedConnection);
132 connect(&dc1394Thread,
SIGNAL(setOperationModeDC1394Done()),
133 this,SLOT(onOpModeDone()),Qt::QueuedConnection);
135 connect(&dc1394Thread,
SIGNAL(startLoading()),
136 this,SLOT(onStartLoading()),Qt::QueuedConnection);
137 connect(&dc1394Thread,
SIGNAL(stopLoading()),
138 this,SLOT(onStopLoading()),Qt::QueuedConnection);
140 dc1394Thread.start();
142 m_pSli.append(ui->sliderSharpness);
143 m_pSli.append(ui->sliderHue);
144 m_pSli.append(ui->sliderSaturation);
145 m_pSli.append(ui->sliderGamma);
146 m_pSli.append(ui->sliderIris);
147 m_pSli.append(ui->sliderFocus);
148 m_pSli.append(ui->sliderShutter);
149 m_pSli.append(ui->sliderBrightness);
150 m_pSli.append(ui->sliderGain);
151 m_pSli.append(ui->sliderExposure);
152 m_pSli.append(ui->sliderWB);
154 for(
int i=0;i<m_pSli.count();i++){
156 this,SLOT(onSliderDisabled(QObject *)),Qt::QueuedConnection);
160void MainWindow::onReloadClicked()
165void MainWindow::connectWidgets()
167 connect(ui->m_MenuMode,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onVideoFormatCurrentIndexChanged(
int)));
168 connect(ui->m_MenuColorCoding,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onColorCodingCurrentIndexChanged(
int)));
169 connect(ui->m_MenuFPS,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onFramerateCurrentIndexChanged(
int)));
170 connect(ui->m_MenuISO,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onISOSpeedCurrentIndexChanged(
int)));
171 connect(ui->m_MenuOpMode,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onOpModeCurrentIndexChanged(
int)));
172 connect(ui->m_bpp,
SIGNAL(valueChanged(
int)),
this,SLOT(onSizeByteValueChanged(
int)));
173 connect(ui->m_xdim,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
174 connect(ui->m_ydim,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
175 connect(ui->m_xoff,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
176 connect(ui->m_yoff,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
177 connect(ui->m_power,
SIGNAL(toggled(
bool)),
this,SLOT(onPowerOnoffChange(
bool)));
178 connect(ui->m_transmission,
SIGNAL(toggled(
bool)),
this,SLOT(onTransmissionOnoffChange(
bool)));
179 connect(ui->m_reset,
SIGNAL(clicked()),
this,SLOT(onResetChange()));
180 connect(ui->m_defaults,
SIGNAL(clicked()),
this,SLOT(onLoadDefaultsChange()));
184void MainWindow::disconnectWidgets()
186 disconnect(ui->m_MenuMode,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onVideoFormatCurrentIndexChanged(
int)));
187 disconnect(ui->m_MenuColorCoding,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onColorCodingCurrentIndexChanged(
int)));
188 disconnect(ui->m_MenuFPS,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onFramerateCurrentIndexChanged(
int)));
189 disconnect(ui->m_MenuISO,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onISOSpeedCurrentIndexChanged(
int)));
190 disconnect(ui->m_MenuOpMode,
SIGNAL(currentIndexChanged(
int)),
this,SLOT(onOpModeCurrentIndexChanged(
int)));
191 disconnect(ui->m_bpp,
SIGNAL(valueChanged(
int)),
this,SLOT(onSizeByteValueChanged(
int)));
192 disconnect(ui->m_xdim,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
193 disconnect(ui->m_ydim,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
194 disconnect(ui->m_xoff,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
195 disconnect(ui->m_yoff,
SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
196 disconnect(ui->m_power,
SIGNAL(toggled(
bool)),
this,SLOT(onPowerOnoffChange(
bool)));
197 disconnect(ui->m_transmission,
SIGNAL(toggled(
bool)),
this,SLOT(onTransmissionOnoffChange(
bool)));
198 disconnect(ui->m_reset,
SIGNAL(clicked()),
this,SLOT(onResetChange()));
199 disconnect(ui->m_defaults,
SIGNAL(clicked()),
this,SLOT(onLoadDefaultsChange()));
205 ui->sliderSharpness->init(cameraFeature_id_t::YARP_FEATURE_SHARPNESS, (
char*)
"Sharpness", &dc1394Thread);
206 ui->sliderHue->init(cameraFeature_id_t::YARP_FEATURE_HUE, (
char*)
"Hue", &dc1394Thread);
207 ui->sliderSaturation->init(cameraFeature_id_t::YARP_FEATURE_SATURATION, (
char*)
"Saturation", &dc1394Thread);
208 ui->sliderGamma->init(cameraFeature_id_t::YARP_FEATURE_GAMMA, (
char*)
"Gamma", &dc1394Thread);
209 ui->sliderIris->init(cameraFeature_id_t::YARP_FEATURE_IRIS, (
char*)
"Iris", &dc1394Thread);
210 ui->sliderFocus->init(cameraFeature_id_t::YARP_FEATURE_FOCUS, (
char*)
"Focus", &dc1394Thread);
215 ui->sliderShutter->init(cameraFeature_id_t::YARP_FEATURE_SHUTTER, (
char*)
"Shutter", &dc1394Thread);
216 ui->sliderBrightness->init(cameraFeature_id_t::YARP_FEATURE_BRIGHTNESS, (
char*)
"Brightness", &dc1394Thread);
217 ui->sliderGain->init(cameraFeature_id_t::YARP_FEATURE_GAIN, (
char*)
"Gain", &dc1394Thread);
218 ui->sliderExposure->init(cameraFeature_id_t::YARP_FEATURE_EXPOSURE, (
char*)
"Exposure", &dc1394Thread);
219 ui->sliderWB->init(&dc1394Thread);
222void MainWindow::onSliderDisabled(QObject *slider)
224 sliderInitMutex.lock();
226 QWidget *s = (QWidget*)slider;
227 QWidget *p = (QWidget*)s->parent();
228 p->layout()->removeWidget(s);
231 sliderInitMutex.unlock();
234void MainWindow::initFormatTab(
unsigned int videoModeMaskDC1394,
235 unsigned int fPSMaskDC1394,
236 unsigned int colorCodingMaskDC1394)
240 unsigned int mask=videoModeMaskDC1394;
242 for (
int i=0,e=0; i<32; ++i){
250 for (
int i=0,e=0; i<8; ++i){
262 mask=colorCodingMaskDC1394;
263 for (
int i=0,e=0; i<32; ++i){
265 m_ColorCodingLut[e]=i;
283 ui->m_power->setChecked(
true);
289void MainWindow::Init(uint videoModeDC1394, uint fPSDC1394, uint iSOSpeedDC1394,
bool operationModeDC1394,
290 uint colorCodingDC1394, QSize max, QSize step, QSize offset, QSize dim, QSize pos,
291 uint bytesPerPacketDC1394,
bool transmissionDC1394)
300 ui->m_MenuMode->setCurrentText(sst);
302 bool bFormat7=videoModeDC1394>=24;
304 ui->m_MenuColorCoding->setEnabled(bFormat7);
305 ui->m_xdim->setEnabled(bFormat7);
306 ui->m_ydim->setEnabled(bFormat7);
307 ui->m_xoff->setEnabled(bFormat7);
308 ui->m_yoff->setEnabled(bFormat7);
310 ui->m_MenuFPS->setEnabled(!bFormat7);
313 ui->m_MenuFPS->setCurrentText(sst);
317 ui->m_MenuISO->setCurrentText(sst);
319 ui->m_MenuOpMode->setCurrentText(sst);
321 ui->m_MenuColorCoding->setCurrentText(sst);
323 unsigned int xmax,ymax,xstep,ystep,xoffstep,yoffstep;
326 xstep =
step.width();
327 ystep =
step.height();
328 xoffstep = offset.width();
329 yoffstep = offset.height();
331 unsigned int xdim,ydim;
346 ui->m_xdim->setRange(0,xmax);
347 ui->m_ydim->setRange(0,ymax);
348 ui->m_xdim->setSingleStep(xstep);
349 ui->m_ydim->setSingleStep(ystep);
350 ui->m_xdim->setValue(xdim);
351 ui->m_ydim->setValue(ydim);
353 int xoffMax=(xmax-xdim)/2;
354 int yoffMax=(ymax-ydim)/2;
357 ui->m_xoff->setRange(-xoffMax,xoffMax);
358 ui->m_yoff->setRange(-yoffMax,yoffMax);
359 ui->m_xoff->setSingleStep(xoffstep);
360 ui->m_yoff->setSingleStep(yoffstep);
361 ui->m_xoff->setValue(x0);
362 ui->m_yoff->setValue(y0);
364 ui->labelMaxWidth->setText(QString(
"%1").arg(xmax));
365 ui->labelMaxHeight->setText(QString(
"%1").arg(ymax));
367 ui->m_bpp->setValue(bytesPerPacketDC1394);
368 ui->m_bpp->setEnabled(bFormat7);
369 ui->m_transmission->setChecked(transmissionDC1394);
378 ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabCamera));
383 yDebug(
"Remote camera device has no IFrameGrabberControl2 interface\n");
388void MainWindow::Reload(uint videoModeDC1394, uint colorCodingMaskDC1394,
389 QSize max, QSize step, QSize offset, QSize dim, QSize pos,
390 uint colorCodingDC1394, uint bytesPerPacketDC1394,uint fPSMaskDC1394,
391 uint fPSDC1394,uint iSOSpeedDC1394)
395 unsigned int video_mode=videoModeDC1394;
398 ui->m_MenuColorCoding->clear();
400 unsigned int mask=colorCodingMaskDC1394;
402 for (
int i=0,e=0; i<32; ++i){
404 m_ColorCodingLut[e]=i;
409 unsigned int xmax,ymax,xstep,ystep,xoffstep,yoffstep;
412 xstep =
step.width();
413 ystep =
step.height();
414 xoffstep = offset.width();
415 yoffstep = offset.height();
417 unsigned int xdim,ydim;
432 ui->m_xdim->setRange(0,xmax);
433 ui->m_ydim->setRange(0,ymax);
434 ui->m_xdim->setSingleStep(xstep);
435 ui->m_ydim->setSingleStep(ystep);
436 ui->m_xdim->setValue(xdim);
437 ui->m_ydim->setValue(ydim);
439 int xoffMax=(xmax-xdim)/2;
440 int yoffMax=(ymax-ydim)/2;
442 ui->m_xoff->setRange(-xoffMax,xoffMax);
443 ui->m_yoff->setRange(-yoffMax,yoffMax);
444 ui->m_xoff->setSingleStep(xoffstep);
445 ui->m_yoff->setSingleStep(yoffstep);
446 ui->m_xoff->setValue(x0);
447 ui->m_yoff->setValue(y0);
449 ui->labelMaxWidth->setText(QString(
"%1").arg(xmax));
450 ui->labelMaxHeight->setText(QString(
"%1").arg(ymax));
455 ui->m_MenuColorCoding->setEnabled(
true);
460 ui->m_bpp->setEnabled(
true);
462 ui->m_bpp->setValue(bytesPerPacketDC1394);
464 ui->m_xdim->setEnabled(
true);
465 ui->m_ydim->setEnabled(
true);
466 ui->m_xoff->setEnabled(
true);
467 ui->m_yoff->setEnabled(
true);
471 ui->m_MenuFPS->clear();
475 for (
int i=0,e=0; i<8; ++i){
484 ui->m_MenuColorCoding->setEnabled(
false);
485 ui->m_bpp->setEnabled(
false);
490 for (
int n=0; n<m_pSli.count(); n++){
506void MainWindow::onResetChange()
508 yDebug(
"on_reset_change()\n");
512void MainWindow::reset(uint bytesPerPacketDC1394,uint colorCodingMaskDC1394,
bool transmissionDC1394)
514 ui->m_bpp->setValue(bytesPerPacketDC1394);
515 ui->m_bpp->setEnabled(colorCodingMaskDC1394);
516 ui->m_transmission->setChecked(transmissionDC1394);
519void MainWindow::onLoadDefaultsChange()
521 yDebug(
"on_load_defaults_change()\n");
526void MainWindow::loadDefault(uint bytesPerPacketDC1394,uint colorCodingMaskDC1394,
bool transmissionDC1394)
529 ui->m_bpp->setValue(bytesPerPacketDC1394);
530 ui->m_bpp->setEnabled(colorCodingMaskDC1394);
531 ui->m_transmission->setChecked(transmissionDC1394);
534void MainWindow::onTransmissionOnoffChange(
bool value)
536 yDebug(
"on_transmission_onoff_change()\n");
538 list.append(QVariant(value));
542void MainWindow::onTransmissionOnoffDone()
547void MainWindow::onPowerOnoffChange(
bool value)
549 yDebug(
"on_power_onoff_change()\n");
551 list.append(QVariant(value));
555void MainWindow::onPowerOnoffDone()
560void MainWindow::onFormat7WindowChange(
int value)
564 if (!ui->m_xdim->isEnabled() || !ui->m_ydim->isEnabled() || !ui->m_xoff->isEnabled() || !ui->m_yoff->isEnabled()){
568 yDebug(
"on_format7_window_change()\n");
570 unsigned int xdim=(unsigned)ui->m_xdim->value();
571 unsigned int ydim=(unsigned)ui->m_ydim->value();
572 int x0=(unsigned)ui->m_xoff->value();
573 int y0=(unsigned)ui->m_yoff->value();
576 list.append(QVariant(xdim));
577 list.append(QVariant(ydim));
578 list.append(QVariant(x0));
579 list.append(QVariant(y0));
583void MainWindow::onFormat7WindowDone()
588void MainWindow::onVideoFormatCurrentIndexChanged(
int value)
590 yDebug(
"on_mode_change()\n");
591 unsigned int video_mode=m_VideoModeLut[value];
593 list.append(video_mode);
598void MainWindow::onVideoFormatCurrentDone()
603void MainWindow::onColorCodingCurrentIndexChanged(
int value)
605 if (!ui->m_MenuColorCoding->isEnabled()){
613 yDebug(
"on_color_coding_change()\n");
616 list.append(m_ColorCodingLut[value]);
623void MainWindow::onColorCodingDone()
625 for (
int n=0; n<m_pSli.count(); n++){
635void MainWindow::onFramerateCurrentIndexChanged(
int value)
637 if(!ui->m_MenuFPS->isEnabled()){
645 yDebug(
"on_framerate_change()\n");
648 list.append(m_FPSLut[value]);
653void MainWindow::onFramerateDone()
658void MainWindow::onISOSpeedCurrentIndexChanged(
int value)
660 yDebug(
"on_iso_speed_change()\n");
668void MainWindow::onISOSpeedDone()
673void MainWindow::onSizeByteValueChanged(
int value)
675 if (!ui->m_bpp->isEnabled()){
679 yDebug(
"on_bpp_change()\n");
681 list.append((
unsigned int)value);
686void MainWindow::onSizeByteDone()
691void MainWindow::onOpModeCurrentIndexChanged(
int value)
693 yDebug(
"on_operation_mode_change()\n");
699void MainWindow::onOpModeDone()
705void MainWindow::onStartLoading()
707 loadingWidget.
start();
710void MainWindow::onStopLoading()
712 loadingWidget.accept();
713 loadingWidget.
stop();
int SIGNAL(int pid, int signum)
void doTask(threadFunction)
bool getCameraDescription(yarp::dev::CameraDescriptor &camera)
MainWindow(const yarp::os::ResourceFinder &rf, yarp::dev::IBattery *ibat, QWidget *parent=0, double refresh_period=10.0)
bool step() override
function that that handles an IDL message - step
@ _setOperationModeDC1394
@ _setBytesPerPacketDC1394
@ _setFormat7WindowDC1394
For streams capable of holding different kinds of content, check what they actually have.
std::string deviceDescription
static QStringList op_mode_labels
static QStringList iso_speed_labels
static QStringList video_rate_labels
static QStringList video_mode_labels
static QStringList color_coding_labels