7#include "ui_dc1394sliderwb.h"
19 m_old_red=m_old_blu=-1.0;
30 int rvalue = ui->m_SliderRed->value();
31 double rval = (double)rvalue/1000;
32 int rw = ui->m_SliderRed->width() - 30;
33 double rnewX = ((double)rw/(
double)1000) * (
double)rvalue;
34 ui->lblValueRed->setGeometry(rnewX,0,30,20);
35 ui->lblValueRed->setText(QString(
"%L1").arg(rval,0,
'f',3));
37 int bvalue = ui->m_SliderBlue->value();
38 double bval = (double)bvalue/1000;
39 int bw = ui->m_SliderBlue->width() - 30;
40 double bnewX = ((double)bw/(
double)1000) * (
double)bvalue;
41 ui->lblValueBlue->setGeometry(bnewX,0,30,20);
42 ui->lblValueBlue->setText(QString(
"%L1").arg(bval,0,
'f',3));
47 QWidget::resizeEvent(event);
54 this->controlThread = controlThread;
56 connect(controlThread,
SIGNAL(sliderHasFeatureDone(QObject*,
bool)),
57 this,SLOT(onHasFeatureDone(QObject*,
bool)),Qt::QueuedConnection);
59 connect(controlThread,
SIGNAL(sliderWBRefreshDone(QObject*,
bool,
bool,
bool,
bool,
bool,
bool,
double,
double)),
60 this,SLOT(onRefreshDone(QObject*,
bool,
bool,
bool,
bool,
bool,
bool,
double,
double)),Qt::QueuedConnection);
62 connect(controlThread,
SIGNAL(sliderWBSetFeatureDC1394Done(QObject*,
double,
double)),
63 this,SLOT(onSliderWBSetFeatureDone(QObject*,
double,
double)),Qt::QueuedConnection);
65 connect(controlThread,
SIGNAL(sliderRadioAutoDone(QObject*,
bool,
bool)),
66 this,SLOT(onRadioAutoDone(QObject*,
bool,
bool)),Qt::QueuedConnection);
68 connect(controlThread,
SIGNAL(sliderPowerDone(QObject*,
bool,
bool,
bool,
bool)),
69 this,SLOT(onPowerDone(QObject*,
bool,
bool,
bool,
bool)),Qt::QueuedConnection);
71 connect(controlThread,
SIGNAL(sliderWBOnePushDone(QObject*,
double,
double)),
72 this,SLOT(onOnePushDone(QObject*,
double,
double)),Qt::QueuedConnection);
76 ui->label->setTitle(
"White Balance");
81 list.append(qVariantFromValue((
void*)
this));
82 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
89void DC1394SliderWB::onHasFeatureDone(QObject *slider,
bool hasFeature)
108void DC1394SliderWB::connectWidgets()
110 connect(ui->m_SliderRed,
SIGNAL(valueChanged(
int)),
this,SLOT(onSliderRedValueChanged(
int)));
111 connect(ui->m_SliderRed,
SIGNAL(sliderReleased()),
this,SLOT(onSliderRedReleased()));
114 connect(ui->m_SliderBlue,
SIGNAL(valueChanged(
int)),
this,SLOT(onSliderBlueValueChanged(
int)));
115 connect(ui->m_SliderBlue,
SIGNAL(sliderReleased()),
this,SLOT(onSliderBlueReleased()));
117 connect(ui->m_OnePush,
SIGNAL(clicked()),
this,SLOT(onOnePushClicked()));
118 connect(ui->pRBa,
SIGNAL(toggled(
bool)),
this,SLOT(onRadioAuto(
bool)));
119 connect(ui->pPwr,
SIGNAL(toggled(
bool)),
this,SLOT(onPower(
bool)));
122void DC1394SliderWB::disconnectWidgets()
124 disconnect(ui->m_SliderRed,
SIGNAL(valueChanged(
int)),
this,SLOT(onSliderRedValueChanged(
int)));
125 disconnect(ui->m_SliderRed,
SIGNAL(sliderReleased()),
this,SLOT(onSliderRedReleased()));
126 disconnect(ui->m_SliderBlue,
SIGNAL(valueChanged(
int)),
this,SLOT(onSliderBlueValueChanged(
int)));
127 disconnect(ui->m_SliderBlue,
SIGNAL(sliderReleased()),
this,SLOT(onSliderBlueReleased()));
129 disconnect(ui->m_OnePush,
SIGNAL(clicked()),
this,SLOT(onOnePushClicked()));
130 disconnect(ui->pRBa,
SIGNAL(toggled(
bool)),
this,SLOT(onRadioAuto(
bool)));
131 disconnect(ui->pPwr,
SIGNAL(toggled(
bool)),
this,SLOT(onPower(
bool)));
141 int f = (int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE;
143 list.append(qVariantFromValue((
void*)
this));
144 list.append(QVariant(f));
148void DC1394SliderWB::onRefreshDone(QObject *slider,
bool bON,
bool bAuto,
bool bHasOnOff,
bool bHasAuto,
bool bHasManual,
bool bHasOnePush,
double redVal,
double blueVal)
156 ui->pRBa->setChecked(
true);
158 ui->pRBm->setChecked(
true);
161 ui->pPwr->setChecked(bON);
163 ui->pPwr->setEnabled(bHasOnOff || bON || bAuto);
164 ui->pRBa->setEnabled(bON && bHasAuto);
165 ui->pRBm->setEnabled(bON && bHasManual);
166 ui->m_SliderRed->setEnabled(bHasManual && !bAuto);
167 ui->m_SliderBlue->setEnabled(bHasManual && !bAuto);
168 ui->m_OnePush->setEnabled(bON && bHasOnePush);
174 ui->pRBa->setChecked(
true);
176 ui->pRBm->setChecked(
true);
179 if (m_new_blu!=m_old_blu){
181 ui->m_SliderBlue->setValue(m_new_blu * 1000);
182 ui->m_SliderBlue->update();
183 onSliderBlueValueChanged(m_new_blu * 1000);
186 if (m_new_red!=m_old_red){
188 ui->m_SliderRed->setValue(m_new_red * 1000);
189 ui->m_SliderRed->update();
190 onSliderRedValueChanged(m_new_red * 1000);
203 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
204 list.append(QVariant((
double)ui->m_SliderRed->value()/1000));
205 list.append(QVariant((
double)ui->m_SliderBlue->value()/1000));
206 list.append(QVariant(ui->pRBa->isChecked()));
207 list.append(QVariant(ui->pPwr->isChecked()));
212void DC1394SliderWB::onSliderRedReleased()
214 double val = (double)ui->m_SliderRed->value()/1000;
216 list.append(qVariantFromValue((
void*)
this));
217 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
218 list.append(QVariant(val));
219 list.append(QVariant((
double)ui->m_SliderBlue->value()/1000));
223void DC1394SliderWB::onSliderRedValueChanged(
int value)
225 double val = (double)value/1000;
226 int w = ui->m_SliderRed->width() - 30;
227 double newX = ((double)w/(
double)1000) * (
double)value;
228 ui->lblValueRed->setGeometry(newX,0,30,20);
229 ui->lblValueRed->setText(QString(
"%L1").arg(val,0,
'f',3));
232void DC1394SliderWB::onSliderBlueReleased()
234 double val = (double)ui->m_SliderBlue->value()/1000;
236 list.append(qVariantFromValue((
void*)
this));
237 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
238 list.append(QVariant((
double)ui->m_SliderRed->value()/1000));
239 list.append(QVariant(val));
243void DC1394SliderWB::onSliderBlueValueChanged(
int value)
245 double val = (double)value/1000;
246 int w = ui->m_SliderBlue->width() - 30;
247 double newX = ((double)w/(
double)1000) * (
double)value;
248 ui->lblValueBlue->setGeometry(newX,0,30,20);
249 ui->lblValueBlue->setText(QString(
"%L1").arg(val,0,
'f',3));
252void DC1394SliderWB::onSliderWBSetFeatureDone(QObject *slider,
double redVal,
double blueVal)
257 yDebug(
"white balance %f %f\n", blueVal, redVal);
260void DC1394SliderWB::onOnePushClicked()
263 list.append(qVariantFromValue((
void*)
this));
264 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
268void DC1394SliderWB::onOnePushDone(QObject *slider,
double redVal,
double blueVal)
278 if (m_new_blu!=m_old_blu){
280 ui->m_SliderBlue->setValue(m_new_blu * 1000);
281 onSliderBlueReleased();
284 if (m_new_red!=m_old_red){
286 ui->m_SliderRed->setValue(m_new_red * 1000);
287 onSliderRedReleased();
296void DC1394SliderWB::onRadioAuto(
bool toggled)
301 list.append(qVariantFromValue((
void*)
this));
302 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
303 list.append(QVariant(bAuto));
307void DC1394SliderWB::onRadioAutoDone(QObject *slider,
bool bON,
bool bAuto)
313 ui->m_SliderRed->setEnabled(!bAuto);
314 ui->m_SliderBlue->setEnabled(!bAuto);
315 yDebug(
"%s\n", ui->pRBa->isEnabled() ?
"auto" :
"man");
319void DC1394SliderWB::onPower(
bool checked)
324 list.append(qVariantFromValue((
void*)
this));
325 list.append(QVariant((
int)cameraFeature_id_t::YARP_FEATURE_WHITE_BALANCE));
326 list.append(QVariant(bON));
336 ui->pRBa->setEnabled(bON &&
hasAuto);
338 ui->m_SliderRed->setEnabled(bON && ui->pRBm->isChecked());
339 ui->m_SliderBlue->setEnabled(bON && ui->pRBm->isChecked());
341 yDebug(
"power %s\n", ui->pPwr->isChecked() ?
"on" :
"off");
348 ui->m_SliderBlue->setValue(blue * 1000);
349 ui->m_SliderRed->setValue(red * 1000);
351 onSliderBlueReleased();
352 onSliderRedReleased();
int SIGNAL(int pid, int signum)
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)
For streams capable of holding different kinds of content, check what they actually have.