2#include "ui_dc1394sliderwb.h"
14 m_old_red=m_old_blu=-1.0;
27 int rvalue = ui->m_SliderRed->value();
28 double rval = (double)rvalue/1000;
29 int rw = ui->m_SliderRed->width() - 30;
30 double rnewX = ((double)rw/(
double)1000) * (
double)rvalue;
31 ui->lblValueRed->setGeometry(rnewX,0,30,20);
32 ui->lblValueRed->setText(QString(
"%L1").arg(rval,0,
'f',3));
34 int bvalue = ui->m_SliderBlue->value();
35 double bval = (double)bvalue/1000;
36 int bw = ui->m_SliderBlue->width() - 30;
37 double bnewX = ((double)bw/(
double)1000) * (
double)bvalue;
38 ui->lblValueBlue->setGeometry(bnewX,0,30,20);
39 ui->lblValueBlue->setText(QString(
"%L1").arg(bval,0,
'f',3));
44 QWidget::resizeEvent(event);
57 this->controlThread = controlThread;
59 connect(controlThread,SIGNAL(sliderHasFeatureDone(QObject*,
bool)),
60 this,SLOT(onHasFeatureDone(QObject*,
bool)),Qt::QueuedConnection);
62 connect(controlThread,SIGNAL(sliderWBRefreshDone(QObject*,
bool,
bool,
bool,
bool,
bool,
bool,
double,
double)),
63 this,SLOT(onRefreshDone(QObject*,
bool,
bool,
bool,
bool,
bool,
bool,
double,
double)),Qt::QueuedConnection);
65 connect(controlThread,SIGNAL(sliderWBSetFeatureDC1394Done(QObject*,
double,
double)),
66 this,SLOT(onSliderWBSetFeatureDone(QObject*,
double,
double)),Qt::QueuedConnection);
68 connect(controlThread,SIGNAL(sliderRadioAutoDone(QObject*,
bool,
bool)),
69 this,SLOT(onRadioAutoDone(QObject*,
bool,
bool)),Qt::QueuedConnection);
71 connect(controlThread,SIGNAL(sliderPowerDone(QObject*,
bool,
bool,
bool,
bool)),
72 this,SLOT(onPowerDone(QObject*,
bool,
bool,
bool,
bool)),Qt::QueuedConnection);
74 connect(controlThread,SIGNAL(sliderWBOnePushDone(QObject*,
double,
double)),
75 this,SLOT(onOnePushDone(QObject*,
double,
double)),Qt::QueuedConnection);
79 ui->label->setTitle(
"White Balance");
84 list.append(qVariantFromValue((
void*)
this));
85 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
92void DC1394SliderWB::onHasFeatureDone(QObject *slider,
bool hasFeature)
111void DC1394SliderWB::connectWidgets()
113 connect(ui->m_SliderRed,SIGNAL(valueChanged(
int)),
this,SLOT(onSliderRedValueChanged(
int)));
114 connect(ui->m_SliderRed,SIGNAL(sliderReleased()),
this,SLOT(onSliderRedReleased()));
117 connect(ui->m_SliderBlue,SIGNAL(valueChanged(
int)),
this,SLOT(onSliderBlueValueChanged(
int)));
118 connect(ui->m_SliderBlue,SIGNAL(sliderReleased()),
this,SLOT(onSliderBlueReleased()));
120 connect(ui->m_OnePush,SIGNAL(clicked()),
this,SLOT(onOnePushClicked()));
121 connect(ui->pRBa,SIGNAL(toggled(
bool)),
this,SLOT(onRadioAuto(
bool)));
122 connect(ui->pPwr,SIGNAL(toggled(
bool)),
this,SLOT(onPower(
bool)));
125void DC1394SliderWB::disconnectWidgets()
127 disconnect(ui->m_SliderRed,SIGNAL(valueChanged(
int)),
this,SLOT(onSliderRedValueChanged(
int)));
128 disconnect(ui->m_SliderRed,SIGNAL(sliderReleased()),
this,SLOT(onSliderRedReleased()));
129 disconnect(ui->m_SliderBlue,SIGNAL(valueChanged(
int)),
this,SLOT(onSliderBlueValueChanged(
int)));
130 disconnect(ui->m_SliderBlue,SIGNAL(sliderReleased()),
this,SLOT(onSliderBlueReleased()));
132 disconnect(ui->m_OnePush,SIGNAL(clicked()),
this,SLOT(onOnePushClicked()));
133 disconnect(ui->pRBa,SIGNAL(toggled(
bool)),
this,SLOT(onRadioAuto(
bool)));
134 disconnect(ui->pPwr,SIGNAL(toggled(
bool)),
this,SLOT(onPower(
bool)));
144 int f = (int)YARP_FEATURE_WHITE_BALANCE;
146 list.append(qVariantFromValue((
void*)
this));
147 list.append(QVariant(
f));
151void DC1394SliderWB::onRefreshDone(QObject *slider,
bool bON,
bool bAuto,
bool bHasOnOff,
bool bHasAuto,
bool bHasManual,
bool bHasOnePush,
double redVal,
double blueVal)
159 ui->pRBa->setChecked(
true);
161 ui->pRBm->setChecked(
true);
164 ui->pPwr->setChecked(bON);
166 ui->pPwr->setEnabled(bHasOnOff || bON || bAuto);
167 ui->pRBa->setEnabled(bON && bHasAuto);
168 ui->pRBm->setEnabled(bON && bHasManual);
169 ui->m_SliderRed->setEnabled(bHasManual && !bAuto);
170 ui->m_SliderBlue->setEnabled(bHasManual && !bAuto);
171 ui->m_OnePush->setEnabled(bON && bHasOnePush);
177 ui->pRBa->setChecked(
true);
179 ui->pRBm->setChecked(
true);
182 if (m_new_blu!=m_old_blu){
184 ui->m_SliderBlue->setValue(m_new_blu * 1000);
185 ui->m_SliderBlue->update();
186 onSliderBlueValueChanged(m_new_blu * 1000);
189 if (m_new_red!=m_old_red){
191 ui->m_SliderRed->setValue(m_new_red * 1000);
192 ui->m_SliderRed->update();
193 onSliderRedValueChanged(m_new_red * 1000);
206 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
207 list.append(QVariant((
double)ui->m_SliderRed->value()/1000));
208 list.append(QVariant((
double)ui->m_SliderBlue->value()/1000));
209 list.append(QVariant(ui->pRBa->isChecked()));
210 list.append(QVariant(ui->pPwr->isChecked()));
220void DC1394SliderWB::onSliderRedReleased()
222 double val = (double)ui->m_SliderRed->value()/1000;
224 list.append(qVariantFromValue((
void*)
this));
225 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
226 list.append(QVariant(val));
227 list.append(QVariant((
double)ui->m_SliderBlue->value()/1000));
231void DC1394SliderWB::onSliderRedValueChanged(
int value)
233 double val = (double)value/1000;
234 int w = ui->m_SliderRed->width() - 30;
235 double newX = ((double)w/(
double)1000) * (
double)value;
236 ui->lblValueRed->setGeometry(newX,0,30,20);
237 ui->lblValueRed->setText(QString(
"%L1").arg(val,0,
'f',3));
243void DC1394SliderWB::onSliderBlueReleased()
245 double val = (double)ui->m_SliderBlue->value()/1000;
247 list.append(qVariantFromValue((
void*)
this));
248 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
249 list.append(QVariant((
double)ui->m_SliderRed->value()/1000));
250 list.append(QVariant(val));
254void DC1394SliderWB::onSliderBlueValueChanged(
int value)
256 double val = (double)value/1000;
257 int w = ui->m_SliderBlue->width() - 30;
258 double newX = ((double)w/(
double)1000) * (
double)value;
259 ui->lblValueBlue->setGeometry(newX,0,30,20);
260 ui->lblValueBlue->setText(QString(
"%L1").arg(val,0,
'f',3));
266void DC1394SliderWB::onSliderWBSetFeatureDone(QObject *slider,
double redVal,
double blueVal)
271 LOG(
"white balance %f %f\n",blueVal,redVal);
274void DC1394SliderWB::onOnePushClicked()
277 list.append(qVariantFromValue((
void*)
this));
278 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
304void DC1394SliderWB::onOnePushDone(QObject *slider,
double redVal,
double blueVal)
314 if (m_new_blu!=m_old_blu){
316 ui->m_SliderBlue->setValue(m_new_blu * 1000);
318 onSliderBlueReleased();
321 if (m_new_red!=m_old_red){
323 ui->m_SliderRed->setValue(m_new_red * 1000);
325 onSliderRedReleased();
334void DC1394SliderWB::onRadioAuto(
bool toggled)
339 list.append(qVariantFromValue((
void*)
this));
340 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
341 list.append(QVariant(bAuto));
351void DC1394SliderWB::onRadioAutoDone(QObject *slider,
bool bON,
bool bAuto)
357 ui->m_SliderRed->setEnabled(!bAuto);
358 ui->m_SliderBlue->setEnabled(!bAuto);
359 LOG(
"%s\n",ui->pRBa->isEnabled() ?
"auto":
"man");
363void DC1394SliderWB::onPower(
bool checked)
368 list.append(qVariantFromValue((
void*)
this));
369 list.append(QVariant((
int)YARP_FEATURE_WHITE_BALANCE));
370 list.append(QVariant(bON));
383void DC1394SliderWB::onPowerDone(QObject *slider,
bool bON,
bool hasAuto,
bool hasManual,
bool hasOnePush)
390 ui->pRBa->setEnabled(bON && hasAuto);
391 ui->pRBm->setEnabled(bON && hasManual);
392 ui->m_SliderRed->setEnabled(bON && ui->pRBm->isChecked());
393 ui->m_SliderBlue->setEnabled(bON && ui->pRBm->isChecked());
394 ui->m_OnePush->setEnabled(bON && hasOnePush);
395 LOG(
"power %s\n",ui->pPwr->isChecked()?
"on":
"off");
404 ui->m_SliderBlue->setValue(blue * 1000);
405 ui->m_SliderRed->setValue(red * 1000);
407 onSliderBlueReleased();
408 onSliderRedReleased();
void featureDisabled(QObject *)
void resizeEvent(QResizeEvent *event)
DC1394SliderWB(QWidget *parent=0)
void set_value(double blue, double red)
bool init(DC1394Thread *controlThread)
void doTask(threadFunction)