2#include "ui_mainwindow.h" 
   18    dc1394Thread(loc,rem),
 
   33    connect(ui->tabWidget,SIGNAL(currentChanged(
int)),
 
   34            this,SLOT(onTabClicked(
int)));
 
 
   46void MainWindow::onTabClicked(
int index)
 
   48    if(index == 0 || index == 1){
 
   49        for(
int i=0;i<m_pSli.count();i++){
 
   55void MainWindow::initMainWindow()
 
   57    setWindowTitle(
"Grabber Remote GUI");
 
   93    video_rate_labels << 
"1.875 fps" << 
"3.75 fps" << 
"7.5 fps" << 
"15 fps" << 
"30 fps" << 
"60 fps" << 
"120 fps" <<
"240 fps";
 
   94    color_coding_labels << 
"MONO8" << 
"YUV411" << 
"YUV422" << 
"YUV444" << 
"RGB8" << 
"MONO16" << 
"RGB16" << 
"MONO16S" << 
"RGB16S" << 
"RAW8" << 
"RAW16";
 
   95    iso_speed_labels << 
"100 Mbps" << 
"200 Mbps" << 
"400 Mbps" << 
"800 Mbps" << 
"1600 Mbps" << 
"3200 Mbps";
 
   98    connect(ui->btnRefresh1,SIGNAL(clicked()),
this,SLOT(onReloadClicked()));
 
   99    connect(ui->btnRefresh2,SIGNAL(clicked()),
this,SLOT(onReloadClicked()));
 
  102    connect(&dc1394Thread,SIGNAL(initFormatTabDone(uint,uint,uint)),
 
  103            this,SLOT(initFormatTab(uint,uint,uint)),Qt::QueuedConnection);
 
  104    connect(&dc1394Thread,SIGNAL(initDone(uint,uint,uint,
bool,uint,QSize,QSize,QSize,QSize,QSize,uint,
bool)),
 
  105            this,SLOT(Init(uint,uint,uint,
bool,uint,QSize,QSize,QSize,QSize,QSize,uint,
bool)),Qt::QueuedConnection);
 
  106    connect(&dc1394Thread,SIGNAL(reloadDone(uint,uint,QSize,QSize,QSize,QSize,QSize,uint,uint,uint,uint,uint)),
 
  107            this,SLOT(Reload(uint,uint,QSize,QSize,QSize,QSize,QSize,uint,uint,uint,uint,uint)),Qt::QueuedConnection);
 
  108    connect(&dc1394Thread,SIGNAL(loadDefaultDone(uint,uint,
bool)),
 
  109            this,SLOT(loadDefault(uint,uint,
bool)),Qt::QueuedConnection);
 
  110    connect(&dc1394Thread,SIGNAL(resetDone(uint,uint,
bool)),
 
  111            this,SLOT(reset(uint,uint,
bool)),Qt::QueuedConnection);
 
  112    connect(&dc1394Thread,SIGNAL(setTransmissionDC1394Done()),
 
  113            this,SLOT(onTransmissionOnoffDone()),Qt::QueuedConnection);
 
  114    connect(&dc1394Thread,SIGNAL(setPowerDC1394Done()),
 
  115            this,SLOT(onPowerOnoffDone()),Qt::QueuedConnection);
 
  116    connect(&dc1394Thread,SIGNAL(setFormat7WindowDC1394Done()),
 
  117            this,SLOT(onFormat7WindowDone()),Qt::QueuedConnection);
 
  118    connect(&dc1394Thread,SIGNAL(setVideoModeDC1394Done()),
 
  119            this,SLOT(onVideoFormatCurrentDone()),Qt::QueuedConnection);
 
  120    connect(&dc1394Thread,SIGNAL(setColorCodingDC1394Done()),
 
  121            this,SLOT(onColorCodingDone()),Qt::QueuedConnection);
 
  122    connect(&dc1394Thread,SIGNAL(setFPSDC1394Done()),
 
  123            this,SLOT(onFramerateDone()),Qt::QueuedConnection);
 
  124    connect(&dc1394Thread,SIGNAL(setISOSpeedDC1394Done()),
 
  125            this,SLOT(onISOSpeedDone()),Qt::QueuedConnection);
 
  126    connect(&dc1394Thread,SIGNAL(setBytesPerPacketDC1394Done()),
 
  127            this,SLOT(onSizeByteDone()),Qt::QueuedConnection);
 
  128    connect(&dc1394Thread,SIGNAL(setOperationModeDC1394Done()),
 
  129            this,SLOT(onOpModeDone()),Qt::QueuedConnection);
 
  131    connect(&dc1394Thread,SIGNAL(startLoading()),
 
  132            this,SLOT(onStartLoading()),Qt::QueuedConnection);
 
  133    connect(&dc1394Thread,SIGNAL(stopLoading()),
 
  134            this,SLOT(onStopLoading()),Qt::QueuedConnection);
 
  136    dc1394Thread.start();
 
  138    m_pSli.append(ui->sliderSharpness);
 
  139    m_pSli.append(ui->sliderHue);
 
  140    m_pSli.append(ui->sliderSaturation);
 
  141    m_pSli.append(ui->sliderGamma);
 
  142    m_pSli.append(ui->sliderIris);
 
  143    m_pSli.append(ui->sliderFocus);
 
  144    m_pSli.append(ui->sliderShutter);
 
  145    m_pSli.append(ui->sliderBrightness);
 
  146    m_pSli.append(ui->sliderGain);
 
  147    m_pSli.append(ui->sliderExposure);
 
  148    m_pSli.append(ui->sliderWB);
 
  150    for(
int i=0;i<m_pSli.count();i++){
 
  151        connect(((
DC1394SliderBase*)m_pSli.at(i)),SIGNAL(featureDisabled(QObject*)),
 
  152                this,SLOT(onSliderDisabled(QObject *)),Qt::QueuedConnection);
 
  156void MainWindow::onReloadClicked()
 
  161void MainWindow::connectWidgets()
 
  163    connect(ui->m_MenuMode,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onVideoFormatCurrentIndexChanged(
int)));
 
  164    connect(ui->m_MenuColorCoding,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onColorCodingCurrentIndexChanged(
int)));
 
  165    connect(ui->m_MenuFPS,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onFramerateCurrentIndexChanged(
int)));
 
  166    connect(ui->m_MenuISO,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onISOSpeedCurrentIndexChanged(
int)));
 
  167    connect(ui->m_MenuOpMode,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onOpModeCurrentIndexChanged(
int)));
 
  168    connect(ui->m_bpp,SIGNAL(valueChanged(
int)),
this,SLOT(onSizeByteValueChanged(
int)));
 
  169    connect(ui->m_xdim,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  170    connect(ui->m_ydim,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  171    connect(ui->m_xoff,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  172    connect(ui->m_yoff,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  173    connect(ui->m_power,SIGNAL(toggled(
bool)),
this,SLOT(onPowerOnoffChange(
bool)));
 
  174    connect(ui->m_transmission,SIGNAL(toggled(
bool)),
this,SLOT(onTransmissionOnoffChange(
bool)));
 
  175    connect(ui->m_reset,SIGNAL(clicked()),
this,SLOT(onResetChange()));
 
  176    connect(ui->m_defaults,SIGNAL(clicked()),
this,SLOT(onLoadDefaultsChange()));
 
  180void MainWindow::disconnectWidgets()
 
  182    disconnect(ui->m_MenuMode,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onVideoFormatCurrentIndexChanged(
int)));
 
  183    disconnect(ui->m_MenuColorCoding,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onColorCodingCurrentIndexChanged(
int)));
 
  184    disconnect(ui->m_MenuFPS,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onFramerateCurrentIndexChanged(
int)));
 
  185    disconnect(ui->m_MenuISO,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onISOSpeedCurrentIndexChanged(
int)));
 
  186    disconnect(ui->m_MenuOpMode,SIGNAL(currentIndexChanged(
int)),
this,SLOT(onOpModeCurrentIndexChanged(
int)));
 
  187    disconnect(ui->m_bpp,SIGNAL(valueChanged(
int)),
this,SLOT(onSizeByteValueChanged(
int)));
 
  188    disconnect(ui->m_xdim,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  189    disconnect(ui->m_ydim,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  190    disconnect(ui->m_xoff,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  191    disconnect(ui->m_yoff,SIGNAL(valueChanged(
int)),
this,SLOT(onFormat7WindowChange(
int)));
 
  192    disconnect(ui->m_power,SIGNAL(toggled(
bool)),
this,SLOT(onPowerOnoffChange(
bool)));
 
  193    disconnect(ui->m_transmission,SIGNAL(toggled(
bool)),
this,SLOT(onTransmissionOnoffChange(
bool)));
 
  194    disconnect(ui->m_reset,SIGNAL(clicked()),
this,SLOT(onResetChange()));
 
  195    disconnect(ui->m_defaults,SIGNAL(clicked()),
this,SLOT(onLoadDefaultsChange()));
 
  201    ui->sliderSharpness->init(YARP_FEATURE_SHARPNESS,(
char*)
"Sharpness",&dc1394Thread);
 
  202    ui->sliderHue->init(YARP_FEATURE_HUE,(
char*)
"Hue",&dc1394Thread);
 
  203    ui->sliderSaturation->init(YARP_FEATURE_SATURATION,(
char*)
"Saturation",&dc1394Thread);
 
  204    ui->sliderGamma->init(YARP_FEATURE_GAMMA,(
char*)
"Gamma",&dc1394Thread);
 
  205    ui->sliderIris->init(YARP_FEATURE_IRIS,(
char*)
"Iris",&dc1394Thread);
 
  206    ui->sliderFocus->init(YARP_FEATURE_FOCUS,(
char*)
"Focus",&dc1394Thread);
 
 
  211    ui->sliderShutter->init(YARP_FEATURE_SHUTTER,(
char*)
"Shutter",&dc1394Thread);
 
  212    ui->sliderBrightness->init(YARP_FEATURE_BRIGHTNESS,(
char*)
"Brightness",&dc1394Thread);
 
  213    ui->sliderGain->init(YARP_FEATURE_GAIN,(
char*)
"Gain",&dc1394Thread);
 
  214    ui->sliderExposure->init(YARP_FEATURE_EXPOSURE,(
char*)
"Exposure",&dc1394Thread);
 
  215    ui->sliderWB->init(&dc1394Thread);
 
 
  218void MainWindow::onSliderDisabled(QObject *slider)
 
  220    sliderInitMutex.lock();
 
  222    QWidget *s = (QWidget*)slider;
 
  223    QWidget *
p = (QWidget*)s->parent();
 
  224    p->layout()->removeWidget(s);
 
  227    sliderInitMutex.unlock();
 
  230void MainWindow::initFormatTab(
unsigned int videoModeMaskDC1394,
 
  231                               unsigned int fPSMaskDC1394,
 
  232                               unsigned int colorCodingMaskDC1394)
 
  236    unsigned int mask=videoModeMaskDC1394;
 
  238    for (
int i=0,
e=0; i<32; ++i){
 
  246    for (
int i=0,
e=0; i<8; ++i){
 
  258    mask=colorCodingMaskDC1394;
 
  259    for (
int i=0,
e=0; i<32; ++i){
 
  261            m_ColorCodingLut[
e]=i;
 
  279    ui->m_power->setChecked(
true);
 
 
  285void MainWindow::Init(uint videoModeDC1394, uint fPSDC1394, uint iSOSpeedDC1394, 
bool operationModeDC1394,
 
  286                      uint colorCodingDC1394, QSize max, QSize step, QSize 
offset, QSize dim, QSize pos,
 
  287                      uint bytesPerPacketDC1394, 
bool transmissionDC1394)
 
  296    bool bFormat7=videoModeDC1394>=24;
 
  298    ui->m_MenuColorCoding->setEnabled(bFormat7);
 
  299    ui->m_xdim->setEnabled(bFormat7);
 
  300    ui->m_ydim->setEnabled(bFormat7);
 
  301    ui->m_xoff->setEnabled(bFormat7);
 
  302    ui->m_yoff->setEnabled(bFormat7);
 
  304    ui->m_MenuFPS->setEnabled(!bFormat7);
 
  313    unsigned int xmax,ymax,xstep,ystep,xoffstep,yoffstep;
 
  316    xstep = step.width();
 
  317    ystep = step.height();
 
  318    xoffstep = 
offset.width();
 
  319    yoffstep = 
offset.height();
 
  321    unsigned int xdim,ydim;
 
  336    ui->m_xdim->setRange(0,xmax);
 
  337    ui->m_ydim->setRange(0,ymax);
 
  338    ui->m_xdim->setSingleStep(xstep);
 
  339    ui->m_ydim->setSingleStep(ystep);
 
  340    ui->m_xdim->setValue(xdim);
 
  341    ui->m_ydim->setValue(ydim);
 
  343    int xoffMax=(xmax-xdim)/2;
 
  344    int yoffMax=(ymax-ydim)/2;
 
  347    ui->m_xoff->setRange(-xoffMax,xoffMax);
 
  348    ui->m_yoff->setRange(-yoffMax,yoffMax);
 
  349    ui->m_xoff->setSingleStep(xoffstep);
 
  350    ui->m_yoff->setSingleStep(yoffstep);
 
  351    ui->m_xoff->setValue(x0);
 
  352    ui->m_yoff->setValue(y0);
 
  354    ui->labelMaxWidth->setText(QString(
"%1").arg(xmax));
 
  355    ui->labelMaxHeight->setText(QString(
"%1").arg(ymax));
 
  357    ui->m_bpp->setValue(bytesPerPacketDC1394);
 
  358    ui->m_bpp->setEnabled(bFormat7);
 
  359    ui->m_transmission->setChecked(transmissionDC1394);
 
  362    CameraDescriptor camera;
 
  365        std::cout << 
"BUS type is " << camera.busType << 
"; description is " << camera.deviceDescription << std::endl;
 
  367        if(camera.busType != BUS_FIREWIRE)
 
  368            ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabCamera));
 
  373        LOG(
"Remote camera device has no IFrameGrabberControl2 interface\n");
 
  378void MainWindow::Reload(uint videoModeDC1394, uint colorCodingMaskDC1394,
 
  379                        QSize max, QSize step, QSize 
offset, QSize dim, QSize pos,
 
  380                        uint colorCodingDC1394, uint bytesPerPacketDC1394,uint fPSMaskDC1394,
 
  381                        uint fPSDC1394,uint iSOSpeedDC1394)
 
  385    unsigned int video_mode=videoModeDC1394;
 
  388    ui->m_MenuColorCoding->clear();
 
  390    unsigned int mask=colorCodingMaskDC1394;
 
  392    for (
int i=0,
e=0; i<32; ++i){
 
  394            m_ColorCodingLut[
e]=i;
 
  399    unsigned int xmax,ymax,xstep,ystep,xoffstep,yoffstep;
 
  402    xstep = step.width();
 
  403    ystep = step.height();
 
  404    xoffstep = 
offset.width();
 
  405    yoffstep = 
offset.height();
 
  407    unsigned int xdim,ydim;
 
  422    ui->m_xdim->setRange(0,xmax);
 
  423    ui->m_ydim->setRange(0,ymax);
 
  424    ui->m_xdim->setSingleStep(xstep);
 
  425    ui->m_ydim->setSingleStep(ystep);
 
  426    ui->m_xdim->setValue(xdim);
 
  427    ui->m_ydim->setValue(ydim);
 
  429    int xoffMax=(xmax-xdim)/2;
 
  430    int yoffMax=(ymax-ydim)/2;
 
  432    ui->m_xoff->setRange(-xoffMax,xoffMax);
 
  433    ui->m_yoff->setRange(-yoffMax,yoffMax);
 
  434    ui->m_xoff->setSingleStep(xoffstep);
 
  435    ui->m_yoff->setSingleStep(yoffstep);
 
  436    ui->m_xoff->setValue(x0);
 
  437    ui->m_yoff->setValue(y0);
 
  439    ui->labelMaxWidth->setText(QString(
"%1").arg(xmax));
 
  440    ui->labelMaxHeight->setText(QString(
"%1").arg(ymax));
 
  445        ui->m_MenuColorCoding->setEnabled(
true);
 
  450        ui->m_bpp->setEnabled(
true);
 
  452        ui->m_bpp->setValue(bytesPerPacketDC1394);
 
  454        ui->m_xdim->setEnabled(
true);
 
  455        ui->m_ydim->setEnabled(
true);
 
  456        ui->m_xoff->setEnabled(
true);
 
  457        ui->m_yoff->setEnabled(
true);
 
  461        ui->m_MenuFPS->clear();
 
  465        for (
int i=0,
e=0; i<8; ++i){
 
  474        ui->m_MenuColorCoding->setEnabled(
false);
 
  475        ui->m_bpp->setEnabled(
false);
 
  480    for (
int n=0; 
n<m_pSli.count(); 
n++){
 
  496void MainWindow::onResetChange()
 
  498    LOG(
"on_reset_change()\n");
 
  502void MainWindow::reset(uint bytesPerPacketDC1394,uint colorCodingMaskDC1394,
bool transmissionDC1394)
 
  504    ui->m_bpp->setValue(bytesPerPacketDC1394);
 
  505    ui->m_bpp->setEnabled(colorCodingMaskDC1394);
 
  506    ui->m_transmission->setChecked(transmissionDC1394);
 
  509void MainWindow::onLoadDefaultsChange()
 
  511    LOG(
"on_load_defaults_change()\n");
 
  516void MainWindow::loadDefault(uint bytesPerPacketDC1394,uint colorCodingMaskDC1394,
bool transmissionDC1394)
 
  519    ui->m_bpp->setValue(bytesPerPacketDC1394);
 
  520    ui->m_bpp->setEnabled(colorCodingMaskDC1394);
 
  521    ui->m_transmission->setChecked(transmissionDC1394);
 
  524void MainWindow::onTransmissionOnoffChange(
bool value)
 
  526    LOG(
"on_transmission_onoff_change()\n");
 
  528    list.append(QVariant(value));
 
  532void MainWindow::onTransmissionOnoffDone()
 
  537void MainWindow::onPowerOnoffChange(
bool value)
 
  539    LOG(
"on_power_onoff_change()\n");
 
  541    list.append(QVariant(value));
 
  545void MainWindow::onPowerOnoffDone()
 
  550void MainWindow::onFormat7WindowChange(
int value)
 
  554    if (!ui->m_xdim->isEnabled() || !ui->m_ydim->isEnabled() || !ui->m_xoff->isEnabled() || !ui->m_yoff->isEnabled()){
 
  558    LOG(
"on_format7_window_change()\n");
 
  560    unsigned int xdim=(unsigned)ui->m_xdim->value();
 
  561    unsigned int ydim=(unsigned)ui->m_ydim->value();
 
  562    int x0=(unsigned)ui->m_xoff->value();
 
  563    int y0=(unsigned)ui->m_yoff->value();
 
  566    list.append(QVariant(xdim));
 
  567    list.append(QVariant(ydim));
 
  568    list.append(QVariant(x0));
 
  569    list.append(QVariant(y0));
 
  573void MainWindow::onFormat7WindowDone()
 
  578void MainWindow::onVideoFormatCurrentIndexChanged(
int value)
 
  580    LOG(
"on_mode_change()\n");
 
  581    unsigned int video_mode=m_VideoModeLut[value];
 
  583    list.append(video_mode);
 
  588void MainWindow::onVideoFormatCurrentDone()
 
  593void MainWindow::onColorCodingCurrentIndexChanged(
int value)
 
  595    if (!ui->m_MenuColorCoding->isEnabled()){
 
  603    LOG(
"on_color_coding_change()\n");
 
  606    list.append(m_ColorCodingLut[value]);
 
  613void MainWindow::onColorCodingDone()
 
  615    for (
int n=0; 
n<m_pSli.count(); 
n++){
 
  625void MainWindow::onFramerateCurrentIndexChanged(
int value)
 
  627    if(!ui->m_MenuFPS->isEnabled()){
 
  635    LOG(
"on_framerate_change()\n");
 
  638    list.append(m_FPSLut[value]);
 
  643void MainWindow::onFramerateDone()
 
  648void MainWindow::onISOSpeedCurrentIndexChanged(
int value)
 
  650    LOG(
"on_iso_speed_change()\n");
 
  658void MainWindow::onISOSpeedDone()
 
  663void MainWindow::onSizeByteValueChanged(
int value)
 
  665    if (!ui->m_bpp->isEnabled()){
 
  671    LOG(
"on_bpp_change()\n");
 
  673    list.append((
unsigned int)value);
 
  678void MainWindow::onSizeByteDone()
 
  683void MainWindow::onOpModeCurrentIndexChanged(
int value)
 
  685    LOG(
"on_operation_mode_change()\n");
 
  691void MainWindow::onOpModeDone()
 
  697void MainWindow::onStartLoading()
 
  699    loadingWidget.
start();
 
  702void MainWindow::onStopLoading()
 
  704    loadingWidget.accept();
 
  705    loadingWidget.
stop();
 
void doTask(threadFunction)
 
bool getCameraDescription(CameraDescriptor *camera)
 
MainWindow(FirmwareUpdaterCore *core, bool adminMode, QWidget *parent=0)
 
@ _setOperationModeDC1394
 
@ _setBytesPerPacketDC1394
 
@ _setFormat7WindowDC1394
 
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