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+"_internal_gui",QVPropertyContainer::outputFlag,value,"",min,max);
00045 gui_holder->linkProperty(property+"_internal_gui",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+"_internal_gui",QVPropertyContainer::outputFlag,value,"");
00073 gui_holder->linkProperty(property+"_internal_gui",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+"_internal_gui",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+"_internal_gui");
00099 }
00100 else if(sender() == slider) {
00101 value = slider->value();
00102 }
00103 else
00104 value = gui_holder->getPropertyValue<int>(property+"_internal_gui");
00105
00106 lineedit->setText(QString("%1").arg(value));
00107 if(orig_holder->hasRange(property))
00108 slider->setValue(value);
00109 gui_holder->setPropertyValue<int>(property+"_internal_gui",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+"_internal_gui",QVPropertyContainer::outputFlag,value,"",min,max);
00123 gui_holder->linkProperty(property+"_internal_gui",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+"_internal_gui",QVPropertyContainer::outputFlag,value,"");
00152 gui_holder->linkProperty(property+"_internal_gui",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+"_internal_gui",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+"_internal_gui");
00179 }
00180 else if(sender() == qwtslider) {
00181 value = qwtslider->value();
00182 }
00183 else
00184 value = gui_holder->getPropertyValue<double>(property+"_internal_gui");
00185
00186 lineedit->setText(QString("%1").arg(value));
00187 if(orig_holder->hasRange(property))
00188 qwtslider->setValue(value);
00189 gui_holder->setPropertyValue<double>(property+"_internal_gui",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
00196 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00197
00198 QLabel *label = new QLabel(QString("<i>bool</i> <b>%1</b>").arg(property),this);
00199 hboxlayout->addWidget(label);
00200 checkbox = new QCheckBox(this);
00201 hboxlayout->addWidget(checkbox);
00202
00203 value = orig_holder->getPropertyValue<bool>(property);
00204
00205 gui_holder->addProperty<bool>(property+"_internal_gui",QVPropertyContainer::outputFlag,value,"");
00206
00207 gui_holder->linkProperty(property+"_internal_gui",orig_holder,property,QVPropertyContainer::AsynchronousLink);
00208
00209 connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(setValue()));
00210 gui_holder->setPropertyValue<bool>(property+"_internal_gui",value);
00211 if(value)
00212 checkbox->setCheckState(Qt::Checked);
00213 else
00214 checkbox->setCheckState(Qt::Unchecked);
00215 emit valueChanged(value);
00216 }
00217
00218 void QVBoolParamWidget::setValue()
00219 {
00220 if (checkbox->checkState() == Qt::Unchecked)
00221 value = false;
00222 else if (checkbox->checkState() == Qt::Checked)
00223 value = true;
00224
00225 gui_holder->setPropertyValue<bool>(property+"_internal_gui",value);
00226 emit valueChanged(value);
00227 }
00228
00229 QVWorkerTriggerWidget::QVWorkerTriggerWidget(QVWorker *worker, const QString triggername, QWidget *parent): QWidget(parent), worker(worker), triggername(triggername)
00230 {
00231 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00232 toolbutton = new QToolButton(this);
00233 toolbutton->setText(triggername);
00234 hboxlayout->addWidget(new QLabel(QString("<i>trigger</i> <b>%1</b>").arg(triggername)));
00235 hboxlayout->addStretch();
00236 hboxlayout->addWidget(toolbutton);
00237
00238 connect(toolbutton,SIGNAL(pressed()),this,SLOT(setValue()));
00239 connect(this,SIGNAL(valueChanged(QString)),worker,SLOT(processTrigger(QString)));
00240 }
00241
00242 void QVWorkerTriggerWidget::setValue()
00243 {
00244 emit valueChanged(triggername);
00245 }
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257