PARP Research Group University of Murcia, Spain


src/qvgui/qvparamwidget.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008, 2009. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
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 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)
00037         {
00038         value = orig_holder->getPropertyValue<int>(property);
00039         info = orig_holder->getPropertyInfo(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                 QLabel *label = new QLabel(QString("<i>int</i> <b>%1</b>").arg(property));
00058                 label->setToolTip(info);
00059                 hboxlayout1->addWidget(label);
00060                 hboxlayout1->addStretch();
00061                 hboxlayout1->addWidget(new QLabel(QString("(%1,%2)").arg(min).arg(max)));
00062                 QHBoxLayout *hboxlayout2 = new QHBoxLayout();
00063                 hboxlayout2->addWidget(lineedit);
00064                 hboxlayout2->addStretch();
00065                 hboxlayout2->addWidget(slider);
00066                 vboxlayout->addLayout(hboxlayout1);
00067                 vboxlayout->addLayout(hboxlayout2);
00068 
00069                 slider->setValue(value);
00070                 connect(slider,SIGNAL(valueChanged(int)),this,SLOT(setValue()));
00071                 }
00072         else
00073                 {
00074                 gui_holder->addProperty<int>(property,QVPropertyContainer::outputFlag,value,"");
00075                 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00076 
00077                 lineedit = new QLineEdit(this);
00078                 lineedit->setFixedWidth(80);
00079 
00080                 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00081                 QLabel *label = new QLabel(QString("<i>int</i> <b>%1</b>").arg(property));
00082                 label->setToolTip(info);
00083                 hboxlayout->addWidget(label);
00084                 hboxlayout->addStretch();
00085                 hboxlayout->addWidget(lineedit);
00086                 //hboxlayout->addStretch();
00087                 }
00088 
00089         connect(lineedit,SIGNAL(editingFinished()),this,SLOT(setValue()));
00090         gui_holder->setPropertyValue<int>(property,value);
00091         lineedit->setText(QString("%1").arg(value));
00092         emit valueChanged(value);
00093         }
00094 
00095 void QVIntParamWidget::setValue()
00096         {
00097         if(sender() == lineedit)
00098                 {
00099                 bool ok;
00100                 value = lineedit->text().toInt(&ok);
00101                 if( (not ok) or
00102                         (orig_holder->hasRange(property) and (value<min or value>max) ) )
00103                         value = gui_holder->getPropertyValue<int>(property);
00104                 }
00105         else if(sender() == slider) {
00106                 value = slider->value();
00107                 }
00108         else
00109                 value = gui_holder->getPropertyValue<int>(property);
00110 
00111         lineedit->setText(QString("%1").arg(value));
00112         if(orig_holder->hasRange(property))
00113                 slider->setValue(value);
00114         gui_holder->setPropertyValue<int>(property,value);
00115         emit valueChanged(value);
00116         }
00117 
00119 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)
00120         {
00121 
00122         value = orig_holder->getPropertyValue<double>(property);
00123         info = orig_holder->getPropertyInfo(property);
00124         if(orig_holder->hasRange(property))
00125                 {
00126                 max = orig_holder->getPropertyMaximum<double>(property);
00127                 min = orig_holder->getPropertyMinimum<double>(property);
00128                 gui_holder->addProperty<double>(property,QVPropertyContainer::outputFlag,value,"",min,max);
00129                 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00130 
00131                 lineedit = new QLineEdit(this);
00132                 lineedit->setFixedWidth(80);
00133                 qwtslider = new QwtSlider(this,Qt::Horizontal,QwtSlider::NoScale,QwtSlider::BgSlot);
00134                 qwtslider->setThumbLength(20);
00135                 qwtslider->setThumbWidth(10);
00136                 qwtslider->setRange(min,max);
00137                 qwtslider->setFixedWidth(150);
00138 
00139                 QVBoxLayout *vboxlayout = new QVBoxLayout(this);
00140                 vboxlayout->setSpacing(0);
00141                 QHBoxLayout *hboxlayout1 = new QHBoxLayout();
00142                 QLabel *label = new QLabel(QString("<i>double</i> <b>%1</b>").arg(property));
00143                 label->setToolTip(info);
00144                 hboxlayout1->addWidget(label);
00145                 hboxlayout1->addStretch();
00146                 hboxlayout1->addWidget(new QLabel(QString("(%1,%2)").arg(min).arg(max)));
00147                 QHBoxLayout *hboxlayout2 = new QHBoxLayout();
00148                 hboxlayout2->addWidget(lineedit);
00149                 hboxlayout2->addStretch();
00150                 hboxlayout2->addWidget(qwtslider);
00151                 vboxlayout->addLayout(hboxlayout1);
00152                 vboxlayout->addLayout(hboxlayout2);
00153 
00154                 qwtslider->setValue(value);
00155                 connect(qwtslider,SIGNAL(valueChanged(double)),this,SLOT(setValue()));
00156                 }
00157         else
00158                 {
00159                 gui_holder->addProperty<double>(property,QVPropertyContainer::outputFlag,value,"");
00160                 gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00161 
00162                 lineedit = new QLineEdit(this);
00163                 lineedit->setFixedWidth(80);
00164 
00165                 QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00166                 QLabel *label = new QLabel(QString("<i>double</i> <b>%1</b>").arg(property));
00167                 label->setToolTip(info);
00168                 hboxlayout->addWidget(label);
00169                 hboxlayout->addStretch();
00170                 hboxlayout->addWidget(lineedit);
00171                 //hboxlayout->addStretch();
00172                 }
00173 
00174         connect(lineedit,SIGNAL(editingFinished()),this,SLOT(setValue()));
00175         gui_holder->setPropertyValue<double>(property,value);
00176         lineedit->setText(QString("%1").arg(value));
00177         emit valueChanged(value);
00178 
00179         }
00180 
00181 void QVDoubleParamWidget::setValue()
00182         {
00183         if(sender() == lineedit)
00184                 {
00185                 bool ok;
00186                 value = lineedit->text().toDouble(&ok);
00187                 if( (not ok) or
00188                         (orig_holder->hasRange(property) and (value<min or value>max) ) )
00189                         value = gui_holder->getPropertyValue<double>(property);
00190                 }
00191         else if(sender() == qwtslider) {
00192                 value = qwtslider->value();
00193                 }
00194         else
00195                 value = gui_holder->getPropertyValue<double>(property);
00196 
00197         lineedit->setText(QString("%1").arg(value));
00198         if(orig_holder->hasRange(property))
00199                 qwtslider->setValue(value);
00200         gui_holder->setPropertyValue<double>(property,value);
00201         emit valueChanged(value);
00202         }
00203 
00205 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)
00206         {
00207         value = orig_holder->getPropertyValue<bool>(property);
00208         info = orig_holder->getPropertyInfo(property);
00209 
00210         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00211         //hboxlayout->setSpacing(0);
00212         QLabel *label = new QLabel(QString("<i>bool</i> <b>%1</b>").arg(property),this);
00213         label->setToolTip(info);
00214         hboxlayout->addWidget(label);
00215         hboxlayout->addStretch();
00216         checkbox = new QCheckBox(this);
00217         hboxlayout->addWidget(checkbox);
00218 
00219         gui_holder->addProperty<bool>(property,QVPropertyContainer::outputFlag,value,"");
00220 
00221         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00222 
00223         connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(setValue()));
00224         gui_holder->setPropertyValue<bool>(property,value);
00225         if(value)
00226                 checkbox->setCheckState(Qt::Checked);
00227         else
00228                 checkbox->setCheckState(Qt::Unchecked);
00229         emit valueChanged(value);
00230         }
00231 
00232 void QVBoolParamWidget::setValue()
00233         {
00234         if (checkbox->checkState() == Qt::Unchecked)
00235                 value = false;
00236         else if (checkbox->checkState() == Qt::Checked)
00237                 value = true;
00238 
00239         gui_holder->setPropertyValue<bool>(property,value);
00240         emit valueChanged(value);
00241         }
00242 
00244 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)
00245         {
00246         value = orig_holder->getPropertyValue<QString>(property);
00247         info = orig_holder->getPropertyInfo(property);
00248 
00249         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00250         hboxlayout->setSpacing(0);
00251         QLabel *label = new QLabel(QString("<i>string</i> <b>%1 </b>").arg(property),this);
00252         label->setToolTip(info);
00253         hboxlayout->addWidget(label);
00254         lineedit = new QLineEdit(this);
00255         hboxlayout->addWidget(lineedit);
00256 
00257         lineedit->setText(value);
00258 
00259         gui_holder->addProperty<QString>(property,QVPropertyContainer::outputFlag,value,"");
00260         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00261 
00262         connect(lineedit,SIGNAL(textChanged(QString)),this,SLOT(setValue()));
00263 
00264         gui_holder->setPropertyValue<QString>(property,value);
00265 
00266         emit valueChanged(value);
00267         }
00268 
00269 void QVStringParamWidget::setValue()
00270         {
00271         value = lineedit->text();
00272         gui_holder->setPropertyValue<QString>(property,value);
00273         emit valueChanged(value);
00274         }
00275 
00277 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)
00278         {
00279         value = orig_holder->getPropertyValue<QVIndexedStringList>(property);
00280         info = orig_holder->getPropertyInfo(property);
00281 
00282         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00283         hboxlayout->setSpacing(0);
00284         QLabel *label = new QLabel(QString("<i>stringlist</i> <b>%1</b>").arg(property),this);
00285         label->setToolTip(info);
00286         hboxlayout->addWidget(label);
00287         combobox = new QComboBox(this);
00288         hboxlayout->addWidget(combobox);
00289 
00290         gui_holder->addProperty<QVIndexedStringList>(property,QVPropertyContainer::outputFlag,value,"");
00291         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00292 
00293         connect(combobox,SIGNAL(activated(int)),this,SLOT(setValue()));
00294 
00295         gui_holder->setPropertyValue<QVIndexedStringList>(property,value);
00296 
00297         combobox->addItems(value);
00298         combobox->setCurrentIndex(value.getIndex());
00299         emit valueChanged(value);
00300         }
00301 
00302 void QVStringListParamWidget::setValue()
00303         {
00304         value.setIndex(combobox->currentIndex());
00305         gui_holder->setPropertyValue<QVIndexedStringList>(property,value);
00306         emit valueChanged(value);
00307         }
00308 
00310 QVWorkerTriggerWidget::QVWorkerTriggerWidget(QVWorker *worker, const QString triggername, QWidget *parent): QWidget(parent), worker(worker), triggername(triggername)
00311         {
00312         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00313         toolbutton = new QToolButton(this);
00314         toolbutton->setText(triggername);
00315         hboxlayout->addWidget(new QLabel(QString("<i>trigger</i> <b>%1</b>").arg(triggername)));
00316 hboxlayout->addStretch();
00317         hboxlayout->addWidget(toolbutton);
00318 
00319         connect(toolbutton,SIGNAL(pressed()),this,SLOT(setValue()));
00320         connect(this,SIGNAL(valueChanged(QString)),worker,SLOT(processTrigger(QString)),Qt::QueuedConnection);
00321         }
00322 
00323 void QVWorkerTriggerWidget::setValue()
00324         {
00325         emit valueChanged(triggername);
00326         }
00327 
00328 /*              doublespinbox->setMinimum(min);
00329                 doublespinbox->setMaximum(max);
00330                 int signif=static_cast<int>(round(log(max-min)/log(10)));
00331                 double val=pow(10,signif);
00332                 std::cout << val << " " << signif << std::endl;
00333                 doublespinbox->setSingleStep(val/100);
00334                 if(signif >= 5)
00335                         doublespinbox->setDecimals(0);
00336                 else
00337                         doublespinbox->setDecimals(5-signif);
00338 */
00339 
00341 // -- QVColorParamWidget
00342 QVColorParamWidget::QVColorParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00343         {
00344         const int max = 255, min = 0;
00345         value = orig_holder->getPropertyValue<QColor>(property);
00346         info = orig_holder->getPropertyInfo(property);
00347 
00348         gui_holder->addProperty<QColor>(property,QVPropertyContainer::outputFlag,value,"");
00349         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00350 
00351         lineeditR = new QLineEdit(this);
00352         lineeditR->setFixedWidth(80);
00353         lineeditG = new QLineEdit(this);
00354         lineeditG->setFixedWidth(80);
00355         lineeditB = new QLineEdit(this);
00356         lineeditB->setFixedWidth(80);
00357 
00358         sliderR = new QSlider(Qt::Horizontal,this);
00359         sliderR->setMinimum(min);
00360         sliderR->setMaximum(max);
00361         sliderR->setFixedWidth(150);
00362 
00363         sliderG = new QSlider(Qt::Horizontal,this);
00364         sliderG->setMinimum(min);
00365         sliderG->setMaximum(max);
00366         sliderG->setFixedWidth(150);
00367 
00368         sliderB = new QSlider(Qt::Horizontal,this);
00369         sliderB->setMinimum(min);
00370         sliderB->setMaximum(max);
00371         sliderB->setFixedWidth(150);
00372 
00373         QHBoxLayout *hboxlayout1 = new QHBoxLayout();
00374         QLabel *label = new QLabel(QString("<i>int</i> <b>%1</b>").arg(property));
00375         label->setToolTip(info);
00376         hboxlayout1->addWidget(label);
00377         hboxlayout1->addStretch();
00378         hboxlayout1->addWidget(new QLabel(QString("(%1,%2)").arg(min).arg(max)));
00379 
00380         QHBoxLayout *hboxlayoutR = new QHBoxLayout();
00381         hboxlayoutR->addWidget(new QLabel(QString("R")));
00382         hboxlayoutR->addWidget(lineeditR);
00383         hboxlayoutR->addStretch();
00384         hboxlayoutR->addWidget(sliderR);
00385 
00386         QHBoxLayout *hboxlayoutG = new QHBoxLayout();
00387         hboxlayoutG->addWidget(new QLabel(QString("G")));
00388         hboxlayoutG->addWidget(lineeditG);
00389         hboxlayoutG->addStretch();
00390         hboxlayoutG->addWidget(sliderG);
00391 
00392         QHBoxLayout *hboxlayoutB = new QHBoxLayout();
00393         hboxlayoutB->addWidget(new QLabel(QString("B")));
00394         hboxlayoutB->addWidget(lineeditB);
00395         hboxlayoutB->addStretch();
00396         hboxlayoutB->addWidget(sliderB);
00397 
00398         QVBoxLayout *vboxlayout = new QVBoxLayout(this);
00399         vboxlayout->setSpacing(0);
00400         vboxlayout->addLayout(hboxlayout1);
00401         vboxlayout->addLayout(hboxlayoutR);
00402         vboxlayout->addLayout(hboxlayoutG);
00403         vboxlayout->addLayout(hboxlayoutB);
00404 
00405         sliderR->setValue(value.red());
00406         sliderG->setValue(value.green());
00407         sliderB->setValue(value.blue());
00408         connect(sliderR,SIGNAL(valueChanged(int)),this,SLOT(setValue()));
00409         connect(sliderG,SIGNAL(valueChanged(int)),this,SLOT(setValue()));
00410         connect(sliderB,SIGNAL(valueChanged(int)),this,SLOT(setValue()));
00411 
00412         connect(lineeditR,SIGNAL(editingFinished()),this,SLOT(setValue()));
00413         connect(lineeditG,SIGNAL(editingFinished()),this,SLOT(setValue()));
00414         connect(lineeditB,SIGNAL(editingFinished()),this,SLOT(setValue()));
00415         gui_holder->setPropertyValue<QColor>(property,value);
00416         lineeditR->setText(QString("%1").arg(value.red()));
00417         lineeditG->setText(QString("%1").arg(value.green()));
00418         lineeditB->setText(QString("%1").arg(value.blue()));
00419         emit valueChanged(value);
00420         }
00421 
00422 void QVColorParamWidget::setValue()
00423         {
00424         if(sender() == lineeditR || sender() == lineeditG || sender() == lineeditB)
00425                 value = QColor( lineeditR->text().toInt(), lineeditG->text().toInt(), lineeditB->text().toInt() );
00426         else if(sender() == sliderR || sender() == sliderG || sender() == sliderB)
00427                 value = QColor( sliderR->value(), sliderG->value(), sliderB->value() );
00428         else
00429                 value = gui_holder->getPropertyValue<QColor>(property);
00430 
00431         lineeditR->setText(QString("%1").arg(value.red()));
00432         lineeditG->setText(QString("%1").arg(value.green()));
00433         lineeditB->setText(QString("%1").arg(value.blue()));
00434 
00435         sliderR->setValue(value.red());
00436         sliderG->setValue(value.green());
00437         sliderB->setValue(value.blue());
00438 
00439         std::cout << "Setting color to " << value.red() << ", " << value.green() << ", "  << value.blue()
00440                 << std::endl;  
00441         gui_holder->setPropertyValue<QColor>(property,value);
00442         emit valueChanged(value);
00443         }
00444 
00446 QVSizeParamWidget::QVSizeParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00447         {
00448         value = orig_holder->getPropertyValue<QSize>(property);
00449         
00450         gui_holder->addProperty<QSize>(property,QVPropertyContainer::outputFlag,value);
00451         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00452 
00453         lineWidth = new QLineEdit(this);
00454         lineWidth->setFixedWidth(80);
00455 
00456         lineHeight = new QLineEdit(this);
00457         lineHeight->setFixedWidth(80);
00458 
00459         QHBoxLayout *hboxnamelayout = new QHBoxLayout();
00460         hboxnamelayout->addWidget(new QLabel(QString("<i>QSize</i> <b>%1</b>").arg(property)));
00461 
00462         QHBoxLayout *hboxwidthlayout = new QHBoxLayout();
00463         hboxwidthlayout->addWidget(lineWidth);
00464         hboxwidthlayout->addStretch();
00465         hboxwidthlayout->addWidget(new QLabel(QString("Width")));
00466 
00467         QHBoxLayout *hboxheightlayout = new QHBoxLayout();
00468         hboxheightlayout->addWidget(lineHeight);
00469         hboxheightlayout->addStretch();
00470         hboxheightlayout->addWidget(new QLabel(QString("Height")));
00471 
00472         QVBoxLayout *vboxlayout = new QVBoxLayout(this);
00473         vboxlayout->setSpacing(0);
00474         vboxlayout->addLayout(hboxnamelayout);
00475         vboxlayout->addLayout(hboxwidthlayout);
00476         vboxlayout->addLayout(hboxheightlayout);
00477 
00478         connect(lineWidth,SIGNAL(editingFinished()),this,SLOT(setValue()));
00479         gui_holder->setPropertyValue<QSize>(property,value);
00480         lineWidth->setText(QString("%1").arg(value.width()));
00481         lineHeight->setText(QString("%1").arg(value.height()));
00482         emit valueChanged(value);
00483         }
00484 
00485 void QVSizeParamWidget::setValue()
00486         {
00487         if(sender() == lineWidth ||sender() == lineHeight)
00488                 {
00489                 bool ok1, ok2;
00490                 value = QSize(lineWidth->text().toInt(&ok1), lineHeight->text().toInt(&ok2));
00491                 if(not ok1 || not ok2)
00492                         value = gui_holder->getPropertyValue<QSize>(property);
00493                 }
00494         else
00495                 value = gui_holder->getPropertyValue<QSize>(property);
00496 
00497         lineWidth->setText(QString("%1").arg(value.width()));
00498         lineHeight->setText(QString("%1").arg(value.height()));
00499         gui_holder->setPropertyValue<QSize>(property,value);
00500         emit valueChanged(value);
00501         }
00502 
00504 
00505 QVPointParamWidget::QVPointParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00506         {
00507         value = orig_holder->getPropertyValue<QPoint>(property);
00508         
00509         gui_holder->addProperty<QPoint>(property,QVPropertyContainer::outputFlag,value);
00510         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00511 
00512         lineX = new QLineEdit(this);
00513         lineX->setFixedWidth(80);
00514 
00515         lineY = new QLineEdit(this);
00516         lineY->setFixedWidth(80);
00517 
00518         QHBoxLayout *hboxnamelayout = new QHBoxLayout();
00519         hboxnamelayout->addWidget(new QLabel(QString("<i>QPoint</i> <b>%1</b>").arg(property)));
00520 
00521         QHBoxLayout *hboxwidthlayout = new QHBoxLayout();
00522         hboxwidthlayout->addWidget(lineX);
00523         hboxwidthlayout->addStretch();
00524         hboxwidthlayout->addWidget(new QLabel(QString("x")));
00525 
00526         QHBoxLayout *hboxheightlayout = new QHBoxLayout();
00527         hboxheightlayout->addWidget(lineY);
00528         hboxheightlayout->addStretch();
00529         hboxheightlayout->addWidget(new QLabel(QString("y")));
00530 
00531         QVBoxLayout *vboxlayout = new QVBoxLayout(this);
00532         vboxlayout->setSpacing(0);
00533         vboxlayout->addLayout(hboxnamelayout);
00534         vboxlayout->addLayout(hboxwidthlayout);
00535         vboxlayout->addLayout(hboxheightlayout);
00536 
00537         connect(lineX,SIGNAL(editingFinished()),this,SLOT(setValue()));
00538         gui_holder->setPropertyValue<QPoint>(property,value);
00539         lineX->setText(QString("%1").arg(value.x()));
00540         lineY->setText(QString("%1").arg(value.y()));
00541         emit valueChanged(value);
00542         }
00543 
00544 void QVPointParamWidget::setValue()
00545         {
00546         if(sender() == lineX ||sender() == lineY)
00547                 {
00548                 bool ok1, ok2;
00549                 value = QPoint(lineX->text().toInt(&ok1), lineY->text().toInt(&ok2));
00550                 if(not ok1 || not ok2)
00551                         value = gui_holder->getPropertyValue<QPoint>(property);
00552                 }
00553         else
00554                 value = gui_holder->getPropertyValue<QPoint>(property);
00555 
00556         lineX->setText(QString("%1").arg(value.x()));
00557         lineY->setText(QString("%1").arg(value.y()));
00558         gui_holder->setPropertyValue<QPoint>(property,value);
00559         emit valueChanged(value);
00560         }
00561 
00562 
00564 QVIppiMaskSizeParamWidget::QVIppiMaskSizeParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00565         {
00566         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00567         hboxlayout->setSpacing(0);
00568         QLabel *label = new QLabel(QString("<i>IppiMaskSize</i> <b>%1</b>").arg(property),this);
00569         hboxlayout->addWidget(label);
00570         combobox = new QComboBox(this);
00571         hboxlayout->addWidget(combobox);
00572 
00573         value = orig_holder->getPropertyValue<IppiMaskSize>(property);
00574 
00575         gui_holder->addProperty<IppiMaskSize>(property,QVPropertyContainer::outputFlag,value);
00576         gui_holder->setPropertyValue<IppiMaskSize>(property,value);
00577 
00578         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00579 
00580         connect(combobox,SIGNAL(activated(int)),this,SLOT(setValue()));
00581 
00582         QVIndexedStringList ippiMaskSizes;
00583         ippiMaskSizes.append("ippMskSize3x1");
00584         ippiMaskSizes.append("ippMskSize5x1");
00585         ippiMaskSizes.append("ippMskSize1x3");
00586         ippiMaskSizes.append("ippMskSize3x3");
00587         ippiMaskSizes.append("ippMskSize1x5");
00588         ippiMaskSizes.append("ippMskSize5x5");
00589         combobox->addItems(ippiMaskSizes);
00590 
00591         combobox->setCurrentIndex(
00592                         (value==ippMskSize3x1)? 0:
00593                         (value==ippMskSize5x1)? 1:
00594                         (value==ippMskSize1x3)? 2:
00595                         (value==ippMskSize3x3)? 3:
00596                         (value==ippMskSize1x5)? 4:
00597                         /*(value==ippMskSize5x5)?*/ 5);
00598 
00599         emit valueChanged(value);
00600         }
00601 
00602 void QVIppiMaskSizeParamWidget::setValue()
00603         {
00604         value = (combobox->currentIndex()==0)? ippMskSize3x1:
00605                 (combobox->currentIndex()==1)? ippMskSize5x1:
00606                 (combobox->currentIndex()==2)? ippMskSize1x3:
00607                 (combobox->currentIndex()==3)? ippMskSize3x3:
00608                 (combobox->currentIndex()==4)? ippMskSize1x5:
00609                 /*(combobox->currentIndex()==0)?*/ ippMskSize5x5;
00610 
00611         gui_holder->setPropertyValue<IppiMaskSize>(property,value);
00612         emit valueChanged(value);
00613         }
00614 
00615 QVIppCmpOpParamWidget::QVIppCmpOpParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00616         {
00617         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00618         hboxlayout->setSpacing(0);
00619         QLabel *label = new QLabel(QString("<i>IppiCmpOp</i> <b>%1</b>").arg(property),this);
00620         hboxlayout->addWidget(label);
00621         combobox = new QComboBox(this);
00622         hboxlayout->addWidget(combobox);
00623 
00624         value = orig_holder->getPropertyValue<IppCmpOp>(property);
00625 
00626         gui_holder->addProperty<IppCmpOp>(property,QVPropertyContainer::outputFlag,value);
00627         gui_holder->setPropertyValue<IppCmpOp>(property,value);
00628 
00629         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00630 
00631         connect(combobox,SIGNAL(activated(int)),this,SLOT(setValue()));
00632 
00633         QVIndexedStringList ippCmpOp;
00634         ippCmpOp.append("ippCmpLess");
00635         ippCmpOp.append("ippCmpLessEq");
00636         ippCmpOp.append("ippCmpEq");
00637         ippCmpOp.append("ippCmpGreaterEq");
00638         ippCmpOp.append("ippCmpGreater");
00639 
00640         combobox->addItems(ippCmpOp);
00641         combobox->setCurrentIndex(
00642                         (value==ippCmpLess)? 0:
00643                         (value==ippCmpLessEq)? 1:
00644                         (value==ippCmpEq)? 2:
00645                         (value==ippCmpGreaterEq)? 3:
00646                         /*(value==ippCmpGreater?*/ 4);
00647                         
00648         emit valueChanged(value);
00649         }
00650 
00651 void QVIppCmpOpParamWidget::setValue()
00652         {
00653         value = (combobox->currentIndex()==1)? ippCmpLess:
00654                 (combobox->currentIndex()==2)? ippCmpLessEq:
00655                 (combobox->currentIndex()==3)? ippCmpEq:
00656                 (combobox->currentIndex()==4)? ippCmpGreaterEq:
00657                 /*(combobox->currentIndex()==1)?*/ ippCmpGreater;
00658 
00659         gui_holder->setPropertyValue<IppCmpOp>(property,value);
00660         emit valueChanged(value);
00661         }
00662 
00663 
00665 
00666 QVIppRoundModeParamWidget::QVIppRoundModeParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00667         {
00668         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00669         hboxlayout->setSpacing(0);
00670         QLabel *label = new QLabel(QString("<i>IppRoundMode</i> <b>%1</b>").arg(property),this);
00671         hboxlayout->addWidget(label);
00672         combobox = new QComboBox(this);
00673         hboxlayout->addWidget(combobox);
00674 
00675         value = orig_holder->getPropertyValue<IppRoundMode>(property);
00676 
00677         gui_holder->addProperty<IppRoundMode>(property,QVPropertyContainer::outputFlag,value);
00678         gui_holder->setPropertyValue<IppRoundMode>(property,value);
00679 
00680         gui_holder->linkProperty(property,orig_holder,property,QVPropertyContainer::AsynchronousLink);
00681 
00682         connect(combobox,SIGNAL(activated(int)),this,SLOT(setValue()));
00683 
00684         QVIndexedStringList ippRoundMode;
00685         ippRoundMode.append("ippRndZero");
00686         ippRoundMode.append("ippRndNear");
00687         ippRoundMode.append("ippRndFinancial");
00688 
00689         combobox->addItems(ippRoundMode);
00690         combobox->setCurrentIndex(
00691                         (value==ippRndZero)? 0:
00692                         (value==ippRndNear)? 1:
00693                         /*(value==ippRndFinancial)?*/ 2);
00694                         
00695         emit valueChanged(value);
00696         }
00697 
00698 void QVIppRoundModeParamWidget::setValue()
00699         {
00700         value = (combobox->currentIndex()==1)? ippRndZero:
00701                 (combobox->currentIndex()==2)? ippRndNear:
00702                 /*(combobox->currentIndex()==3)?*/ ippRndFinancial;
00703 
00704         gui_holder->setPropertyValue<IppRoundMode>(property,value);
00705         emit valueChanged(value);
00706         }
00707 
00709 
00710 
00711 
00712 QVOutputIntParamWidget::QVOutputIntParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00713         {
00714         value = orig_holder->getPropertyValue<int>(property);
00715         info = orig_holder->getPropertyInfo(property);
00716 
00717         gui_holder->addProperty<int>(property,QVPropertyContainer::inputFlag,value,"");
00718         _orig_holder->linkProperty(property,_gui_holder,property,QVPropertyContainer::AsynchronousLink);
00719 
00720         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00721         label = new QLabel(QString("<i>int</i> <b>%1: %2</b>").arg(property).arg(value));
00722         label->setToolTip(info);
00723         hboxlayout->addWidget(label);
00724         hboxlayout->addStretch();
00725 
00726         gui_holder->setPropertyValue<int>(property,value);
00727         }
00728 
00729 void QVOutputIntParamWidget::update()
00730         {
00731         value = gui_holder->getPropertyValue<int>(property);
00732         label->setText(QString("<i>int</i> <b>%1: %2</b>").arg(property).arg(value));
00733         }
00734 
00735 QVOutputDoubleParamWidget::QVOutputDoubleParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00736         {
00737         value = orig_holder->getPropertyValue<double>(property);
00738         info = orig_holder->getPropertyInfo(property);
00739 
00740         gui_holder->addProperty<double>(property,QVPropertyContainer::inputFlag,value,"");
00741         _orig_holder->linkProperty(property,_gui_holder,property,QVPropertyContainer::AsynchronousLink);
00742 
00743         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00744         label = new QLabel(QString("<i>double</i> <b>%1: %2</b>").arg(property).arg(value));
00745         label->setToolTip(info);
00746         hboxlayout->addWidget(label);
00747         hboxlayout->addStretch();
00748 
00749         gui_holder->setPropertyValue<double>(property,value);
00750         }
00751 
00752 void QVOutputDoubleParamWidget::update()
00753         {
00754         value = gui_holder->getPropertyValue<double>(property);
00755         label->setText(QString("<i>double</i> <b>%1: %2</b>").arg(property).arg(value));
00756         }
00757 
00758 QVOutputBoolParamWidget::QVOutputBoolParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00759         {
00760         value = orig_holder->getPropertyValue<bool>(property);
00761         info = orig_holder->getPropertyInfo(property);
00762 
00763         gui_holder->addProperty<bool>(property,QVPropertyContainer::inputFlag,value,"");
00764         _orig_holder->linkProperty(property,_gui_holder,property,QVPropertyContainer::AsynchronousLink);
00765 
00766         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00767         if (value) {
00768                 label = new QLabel(QString("<i>bool</i> <b>%1: TRUE</b>").arg(property));
00769                 label->setToolTip(info);
00770                 }
00771         else {
00772                 label = new QLabel(QString("<i>bool</i> <b>%1: FALSE</b>").arg(property));
00773                 label->setToolTip(info);
00774                 }
00775         hboxlayout->addWidget(label);
00776         hboxlayout->addStretch();
00777 
00778         gui_holder->setPropertyValue<bool>(property,value);
00779         }
00780 
00781 void QVOutputBoolParamWidget::update()
00782         {
00783         value = gui_holder->getPropertyValue<bool>(property);
00784         if (value) {
00785                 label = new QLabel(QString("<i>bool</i> <b>%1: TRUE</b>").arg(property));
00786                 label->setToolTip(info);
00787                 }
00788         else {
00789                 label = new QLabel(QString("<i>bool</i> <b>%1: FALSE</b>").arg(property));
00790                 label->setToolTip(info);
00791                 }
00792         }
00793 
00794 QVOutputStringParamWidget::QVOutputStringParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00795         {
00796         value = orig_holder->getPropertyValue<QString>(property);
00797         info = orig_holder->getPropertyInfo(property);
00798 
00799         gui_holder->addProperty<QString>(property,QVPropertyContainer::inputFlag,value,"");
00800         _orig_holder->linkProperty(property,_gui_holder,property,QVPropertyContainer::AsynchronousLink);
00801 
00802         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00803         label = new QLabel(QString("<i>string</i> <b>%1: %2</b>").arg(property).arg(value));
00804         label->setToolTip(info);
00805         hboxlayout->addWidget(label);
00806         hboxlayout->addStretch();
00807 
00808         gui_holder->setPropertyValue<QString>(property,value);
00809         }
00810 
00811 void QVOutputStringParamWidget::update()
00812         {
00813         value = gui_holder->getPropertyValue<QString>(property);
00814         label->setText(QString("<i>string</i> <b>%1: %2</b>").arg(property).arg(value));
00815         }
00816 
00817 QVOutputStringListParamWidget::QVOutputStringListParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00818         {
00819         value = orig_holder->getPropertyValue<QVIndexedStringList>(property);
00820         info = orig_holder->getPropertyInfo(property);
00821 
00822         gui_holder->addProperty<QVIndexedStringList>(property,QVPropertyContainer::inputFlag,value,"");
00823         _orig_holder->linkProperty(property,_gui_holder,property,QVPropertyContainer::AsynchronousLink);
00824 
00825         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00826         label = new QLabel(QString("<i>indexed string list</i> <b>%1: %2</b>").arg(property).arg(value.getCurrent()));
00827         label->setToolTip(info);
00828         hboxlayout->addWidget(label);
00829         hboxlayout->addStretch();
00830 
00831         gui_holder->setPropertyValue<QVIndexedStringList>(property,value);
00832         }
00833 
00834 void QVOutputStringListParamWidget::update()
00835         {
00836         value = gui_holder->getPropertyValue<QVIndexedStringList>(property);
00837         label->setText(QString("<i>indexed string list</i> <b>%1: %2</b>").arg(property).arg(value.getCurrent()));
00838         }
00839 
00840 QVOutputColorParamWidget::QVOutputColorParamWidget(QVPropertyContainer *_orig_holder, QVPropertyContainer *_gui_holder, const QString _property, QWidget *parent): QWidget(parent), orig_holder(_orig_holder), gui_holder(_gui_holder), property(_property)
00841         {
00842         value = orig_holder->getPropertyValue<QColor>(property);
00843         info = orig_holder->getPropertyInfo(property);
00844 
00845         gui_holder->addProperty<QColor>(property,QVPropertyContainer::inputFlag,value,"");
00846         _orig_holder->linkProperty(property,_gui_holder,property,QVPropertyContainer::AsynchronousLink);
00847 
00848         QHBoxLayout *hboxlayout = new QHBoxLayout(this);
00849         label = new QLabel(QString("<i>color</i> <b>%1: R = %2 G = %3 B = %4</b>").arg(property).arg(value.red()).arg(value.green()).arg(value.blue()));
00850         label->setToolTip(info);
00851         hboxlayout->addWidget(label);
00852         hboxlayout->addStretch();
00853 
00854         gui_holder->setPropertyValue<QColor>(property,value);
00855         }
00856 
00857 void QVOutputColorParamWidget::update()
00858         {
00859         value = gui_holder->getPropertyValue<QColor>(property);
00860         label->setText(QString("<i>color</i> <b>%1: R = %2 G = %3 B = %4</b>").arg(property).arg(value.red()).arg(value.green()).arg(value.blue()));
00861         }



QVision framework. PARP research group, copyright 2007, 2008.