00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <qvgui/qvparamwidget.h>
00026
00027 #include <QLineEdit>
00028 #include <QSlider>
00029 #include <QLabel>
00030 #include <QCheckBox>
00031
00032 #include <QVBoxLayout>
00033 #include <QHBoxLayout>
00034
00035 #include <qwt_slider.h>
00036
00037 QVIntParamWidget::QVIntParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00038 {
00039 value = orig_holder->getPropertyValue<int>(property);
00040 if(orig_holder->hasRange(property))
00041 {
00042 max = orig_holder->getPropertyMaximum<int>(property);
00043 min = orig_holder->getPropertyMinimum<int>(property);
00044 gui_holder->addProperty<int>(property,QVPropertyContainer::outputFlag,value,"",min,max);
00045 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00046
00047 lineedit = new QLineEdit(this);
00048 lineedit->setFixedWidth(80);
00049 slider = new QSlider(Qt::Horizontal,this);
00050 slider->setMinimum(min);
00051 slider->setMaximum(max);
00052 slider->setFixedWidth(150);
00053
00054 QVBoxLayout *vboxlayout = new QVBoxLayout(this);
00055 vboxlayout->setSpacing(0);
00056 QHBoxLayout *hboxlayout1 = new QHBoxLayout();
00057 hboxlayout1->addWidget(new QLabel(QString("<i>int</i> <b>%1</b>").arg(property)));
00058 hboxlayout1->addStretch();
00059 hboxlayout1->addWidget(new QLabel(QString("(%1,%2)").arg(min).arg(max)));
00060 QHBoxLayout *hboxlayout2 = new QHBoxLayout();
00061 hboxlayout2->addWidget(lineedit);
00062 hboxlayout2->addStretch();
00063 hboxlayout2->addWidget(slider);
00064 vboxlayout->addLayout(hboxlayout1);
00065 vboxlayout->addLayout(hboxlayout2);
00066
00067 slider->setValue(value);
00068 connect(slider,SIGNAL(valueChanged(int)),this,SLOT(setValue()));
00069 }
00070 else
00071 {
00072 gui_holder->addProperty<int>(property,QVPropertyContainer::outputFlag,value,"");
00073 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00074
00075 lineedit = new QLineEdit(this);
00076 lineedit->setFixedWidth(80);
00077
00078 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00079 hboxlayout->addWidget(new QLabel(QString("<i>int</i> <b>%1</b>").arg(property)));
00080 hboxlayout->addWidget(lineedit);
00081 hboxlayout->addStretch();
00082 }
00083
00084 connect(lineedit,SIGNAL(editingFinished()),this,SLOT(setValue()));
00085 gui_holder->setPropertyValue<int>(property,value);
00086 lineedit->setText(QString("%1").arg(value));
00087 emit valueChanged(value);
00088 }
00089
00090 void QVIntParamWidget::setValue()
00091 {
00092 if(sender() == lineedit)
00093 {
00094 bool ok;
00095 value = lineedit->text().toInt(&ok);
00096 if( (not ok) or
00097 (orig_holder->hasRange(property) and (value<min or value>max) ) )
00098 value = gui_holder->getPropertyValue<int>(property);
00099 }
00100 else if(sender() == slider) {
00101 value = slider->value();
00102 }
00103 else
00104 value = gui_holder->getPropertyValue<int>(property);
00105
00106 lineedit->setText(QString("%1").arg(value));
00107 if(orig_holder->hasRange(property))
00108 slider->setValue(value);
00109 gui_holder->setPropertyValue<int>(property,value);
00110 emit valueChanged(value);
00111 }
00112
00113
00114 QVDoubleParamWidget::QVDoubleParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00115 {
00116
00117 value = orig_holder->getPropertyValue<double>(property);
00118 if(orig_holder->hasRange(property))
00119 {
00120 max = orig_holder->getPropertyMaximum<double>(property);
00121 min = orig_holder->getPropertyMinimum<double>(property);
00122 gui_holder->addProperty<double>(property,QVPropertyContainer::outputFlag,value,"",min,max);
00123 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00124
00125 lineedit = new QLineEdit(this);
00126 lineedit->setFixedWidth(80);
00127 qwtslider = new QwtSlider(this,Qt::Horizontal,QwtSlider::NoScale,QwtSlider::BgSlot);
00128 qwtslider->setThumbLength(20);
00129 qwtslider->setThumbWidth(10);
00130 qwtslider->setRange(min,max);
00131 qwtslider->setFixedWidth(150);
00132
00133 QVBoxLayout *vboxlayout = new QVBoxLayout(this);
00134 vboxlayout->setSpacing(0);
00135 QHBoxLayout *hboxlayout1 = new QHBoxLayout();
00136 hboxlayout1->addWidget(new QLabel(QString("<i>double</i> <b>%1</b>").arg(property)));
00137 hboxlayout1->addStretch();
00138 hboxlayout1->addWidget(new QLabel(QString("(%1,%2)").arg(min).arg(max)));
00139 QHBoxLayout *hboxlayout2 = new QHBoxLayout();
00140 hboxlayout2->addWidget(lineedit);
00141 hboxlayout2->addStretch();
00142 hboxlayout2->addWidget(qwtslider);
00143 vboxlayout->addLayout(hboxlayout1);
00144 vboxlayout->addLayout(hboxlayout2);
00145
00146 qwtslider->setValue(value);
00147 connect(qwtslider,SIGNAL(valueChanged(double)),this,SLOT(setValue()));
00148 }
00149 else
00150 {
00151 gui_holder->addProperty<double>(property,QVPropertyContainer::outputFlag,value,"");
00152 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00153
00154 lineedit = new QLineEdit(this);
00155 lineedit->setFixedWidth(80);
00156
00157 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00158 hboxlayout->addWidget(new QLabel(QString("<i>double</i> <b>%1</b>").arg(property)));
00159 hboxlayout->addWidget(lineedit);
00160 hboxlayout->addStretch();
00161 }
00162
00163 connect(lineedit,SIGNAL(editingFinished()),this,SLOT(setValue()));
00164 gui_holder->setPropertyValue<double>(property,value);
00165 lineedit->setText(QString("%1").arg(value));
00166 emit valueChanged(value);
00167
00168 }
00169
00170 void QVDoubleParamWidget::setValue()
00171 {
00172 if(sender() == lineedit)
00173 {
00174 bool ok;
00175 value = lineedit->text().toDouble(&ok);
00176 if( (not ok) or
00177 (orig_holder->hasRange(property) and (value<min or value>max) ) )
00178 value = gui_holder->getPropertyValue<double>(property);
00179 }
00180 else if(sender() == qwtslider) {
00181 value = qwtslider->value();
00182 }
00183 else
00184 value = gui_holder->getPropertyValue<double>(property);
00185
00186 lineedit->setText(QString("%1").arg(value));
00187 if(orig_holder->hasRange(property))
00188 qwtslider->setValue(value);
00189 gui_holder->setPropertyValue<double>(property,value);
00190 emit valueChanged(value);
00191 }
00192
00193 QVBoolParamWidget::QVBoolParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00194 {
00195 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00196
00197 QLabel *label = new QLabel(QString("<i>bool</i> <b>%1</b>").arg(property),this);
00198 hboxlayout->addWidget(label);
00199 checkbox = new QCheckBox(this);
00200 hboxlayout->addWidget(checkbox);
00201
00202 value = orig_holder->getPropertyValue<bool>(property);
00203
00204 gui_holder->addProperty<bool>(property,QVPropertyContainer::outputFlag,value,"");
00205
00206 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00207
00208 connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(setValue()));
00209 gui_holder->setPropertyValue<bool>(property,value);
00210 if(value)
00211 checkbox->setCheckState(Qt::Checked);
00212 else
00213 checkbox->setCheckState(Qt::Unchecked);
00214 emit valueChanged(value);
00215 }
00216
00217 void QVBoolParamWidget::setValue()
00218 {
00219 if (checkbox->checkState() == Qt::Unchecked)
00220 value = false;
00221 else if (checkbox->checkState() == Qt::Checked)
00222 value = true;
00223
00224 gui_holder->setPropertyValue<bool>(property,value);
00225 emit valueChanged(value);
00226 }
00227
00228 QVStringParamWidget::QVStringParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00229 {
00230 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00231 hboxlayout->setSpacing(0);
00232 QLabel *label = new QLabel(QString("<i>string</i> <b>%1</b>").arg(property),this);
00233 hboxlayout->addWidget(label);
00234 lineedit = new QLineEdit(this);
00235 hboxlayout->addWidget(lineedit);
00236
00237 value = orig_holder->getPropertyValue<QString>(property);
00238 lineedit->setText(value);
00239
00240 gui_holder->addProperty<QString>(property,QVPropertyContainer::outputFlag,value,"");
00241 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00242
00243 connect(lineedit,SIGNAL(textChanged(QString)),this,SLOT(setValue()));
00244
00245 gui_holder->setPropertyValue<QString>(property,value);
00246
00247 emit valueChanged(value);
00248 }
00249
00250 void QVStringParamWidget::setValue()
00251 {
00252 value = lineedit->text();
00253 gui_holder->setPropertyValue<QString>(property,value);
00254 emit valueChanged(value);
00255 }
00256
00257
00258 QVStringListParamWidget::QVStringListParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00259 {
00260 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00261 hboxlayout->setSpacing(0);
00262 QLabel *label = new QLabel(QString("<i>stringlist</i> <b>%1</b>").arg(property),this);
00263 hboxlayout->addWidget(label);
00264 combobox = new QComboBox(this);
00265 hboxlayout->addWidget(combobox);
00266
00267 value = orig_holder->getPropertyValue<QVIndexedStringList>(property);
00268
00269 gui_holder->addProperty<QVIndexedStringList>(property,QVPropertyContainer::outputFlag,value,"");
00270 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00271
00272 connect(combobox,SIGNAL(activated(int)),this,SLOT(setValue()));
00273
00274 gui_holder->setPropertyValue<QVIndexedStringList>(property,value);
00275
00276 combobox->addItems(value);
00277 combobox->setCurrentIndex(value.getIndex());
00278 emit valueChanged(value);
00279 }
00280
00281 void QVStringListParamWidget::setValue()
00282 {
00283 value.setIndex(combobox->currentIndex());
00284 gui_holder->setPropertyValue<QVIndexedStringList>(property,value);
00285 emit valueChanged(value);
00286 }
00287
00288 QVWorkerTriggerWidget::QVWorkerTriggerWidget(QVWorker *worker, const QString triggername, QWidget *parent): QWidget(parent), worker(worker), triggername(triggername)
00289 {
00290 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00291 toolbutton = new QToolButton(this);
00292 toolbutton->setText(triggername);
00293 hboxlayout->addWidget(new QLabel(QString("<i>trigger</i> <b>%1</b>").arg(triggername)));
00294 hboxlayout->addStretch();
00295 hboxlayout->addWidget(toolbutton);
00296
00297 connect(toolbutton,SIGNAL(pressed()),this,SLOT(setValue()));
00298 connect(this,SIGNAL(valueChanged(QString)),worker,SLOT(processTrigger(QString)));
00299 }
00300
00301 void QVWorkerTriggerWidget::setValue()
00302 {
00303 emit valueChanged(triggername);
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316