PARP Research Group University of Murcia, Spain


src/qvgui/qvparamsinspectorwidget.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 #include <qvgui/qvparamsinspectorwidget.h>
00027 #include <QLabel>
00028 
00029 #include <QVWorker>
00030 #include <QVIndexedStringList>
00031 
00032 QVParamsInspectorWidget::QVParamsInspectorWidget(QVPropertyContainer *holder, QWidget *parent):
00033         QWidget(parent), QVPropertyContainer("QVParamsInspectorWidget for " + holder->getName())
00034         {
00035         //setGeometry(QRect(10, 20, 200, 0));
00036         inputWidget = new QWidget(this);
00037         outputWidget = new QWidget(this);
00038         inputVboxLayout = new QVBoxLayout(inputWidget);
00039         outputVboxLayout = new QVBoxLayout(outputWidget);
00040         inputVboxLayout->setSpacing(0);
00041         outputVboxLayout->setSpacing(0);
00042 
00043         tabWidget = new QTabWidget(this);
00044         tabWidget->addTab(inputWidget, "input properties");
00045         tabWidget->addTab(outputWidget, "output properties");
00046 
00047         vboxLayout = new QVBoxLayout(this);
00048         vboxLayout->setSpacing(0);
00049         vboxLayout->addWidget(tabWidget);
00050 
00051 
00052         QVWorker *worker;
00053         if((worker = dynamic_cast<QVWorker*>(holder)) != NULL)
00054                 foreach(QString property, worker->getTriggerList())
00055                         inputVboxLayout->addWidget(new QVWorkerTriggerWidget(worker, property, this));
00056 
00057         bool haveInputWidgets = false;
00058         bool haveOutputWidgets = false;
00059         foreach(QString property, holder->getPropertyList()) {
00060                 if(not holder->isLinkedInput(property) && holder->isInput(property) && not holder->isGUIInvisible(property)) {
00061                         if(holder->isType<int>(property)) // if the property is int.
00062                                 {
00063                                 QVIntParamWidget *int_widget = new QVIntParamWidget(holder,this,property);
00064                                 inputVboxLayout->addWidget(int_widget);
00065                                 haveInputWidgets = true;
00066                                 writeOutputProperties();
00067                                 connect(int_widget,SIGNAL(valueChanged(int)),this,SLOT(somePropertyChanged()));
00068                                 }
00069                         else if(holder->isType<double>(property)) // if the property is double.
00070                                 {
00071                                 QVDoubleParamWidget *double_widget = new QVDoubleParamWidget(holder,this,property);
00072                                 inputVboxLayout->addWidget(double_widget);
00073                                 haveInputWidgets = true;
00074                                 writeOutputProperties();
00075                                 connect(double_widget,SIGNAL(valueChanged(double)),this,SLOT(somePropertyChanged()));
00076                                 }
00077                         else if(holder->isType<bool>(property)) // if the property is bool.
00078                                 {
00079                                 QVBoolParamWidget *bool_widget = new QVBoolParamWidget(holder,this,property);
00080                                 inputVboxLayout->addWidget(bool_widget);
00081                                 haveInputWidgets = true;
00082                                 writeOutputProperties();
00083                                 connect(bool_widget,SIGNAL(valueChanged(bool)),this,SLOT(somePropertyChanged()));
00084                                 }
00085                         else if(holder->isType<QString>(property)) // if the property is QString.
00086                                 {
00087                                 QVStringParamWidget *st_widget = new QVStringParamWidget(holder,this,property);
00088                                 inputVboxLayout->addWidget(st_widget);
00089                                 haveInputWidgets = true;
00090                                 writeOutputProperties();
00091                                 connect(st_widget,SIGNAL(valueChanged(QString)),this,SLOT(somePropertyChanged()));
00092                                 }
00093                         else if(holder->isType<QVIndexedStringList>(property)) // if the property is QVIndexedStringList.
00094                                 {
00095                                 QVStringListParamWidget *sl_widget = new QVStringListParamWidget(holder,this,property);
00096                                 inputVboxLayout->addWidget(sl_widget);
00097                                 haveInputWidgets = true;
00098                                 writeOutputProperties();
00099                                 connect(sl_widget,SIGNAL(valueChanged(QVIndexedStringList)),this,SLOT(somePropertyChanged()));
00100                                 }
00101                         else if(holder->isType<QColor>(property)) // if the property is QColor
00102                                 {
00103                                 QVColorParamWidget *sl_widget = new QVColorParamWidget(holder,this,property);
00104                                 inputVboxLayout->addWidget(sl_widget);
00105                                 haveInputWidgets = true;
00106                                 writeOutputProperties();
00107                                 connect(sl_widget,SIGNAL(valueChanged(QColor)),this,SLOT(somePropertyChanged()));
00108                                 }
00109                         else if(holder->isType<QSize>(property)) // if the property is QSize
00110                                 {
00111                                 QVSizeParamWidget *sl_widget = new QVSizeParamWidget(holder,this,property);
00112                                 inputVboxLayout->addWidget(sl_widget);
00113                                 haveInputWidgets = true;
00114                                 writeOutputProperties();
00115                                 connect(sl_widget,SIGNAL(valueChanged(QSize)),this,SLOT(somePropertyChanged()));
00116                                 }
00117                         else if(holder->isType<QPoint>(property)) // if the property is QPoint
00118                                 {
00119                                 QVPointParamWidget *sl_widget = new QVPointParamWidget(holder,this,property);
00120                                 inputVboxLayout->addWidget(sl_widget);
00121                                 haveInputWidgets = true;
00122                                 writeOutputProperties();
00123                                 connect(sl_widget,SIGNAL(valueChanged(QPoint)),this,SLOT(somePropertyChanged()));
00124                                 }
00125 
00126                         else if(holder->isType<IppiMaskSize>(property)) // if the property is IppiMaskSize
00127                                 {
00128                                 QVIppiMaskSizeParamWidget *sl_widget = new QVIppiMaskSizeParamWidget(holder,this,property);
00129                                 inputVboxLayout->addWidget(sl_widget);
00130                                 haveInputWidgets = true;
00131                                 writeOutputProperties();
00132                                 connect(sl_widget,SIGNAL(valueChanged(IppiMaskSize)),this,SLOT(somePropertyChanged()));
00133                                 }
00134                         else if(holder->isType<IppCmpOp>(property)) // if the property is IppCmpOp
00135                                 {
00136                                 QVIppCmpOpParamWidget *sl_widget = new QVIppCmpOpParamWidget(holder,this,property);
00137                                 inputVboxLayout->addWidget(sl_widget);
00138                                 haveInputWidgets = true;
00139                                 writeOutputProperties();
00140                                 connect(sl_widget,SIGNAL(valueChanged(IppCmpOp)),this,SLOT(somePropertyChanged()));
00141                                 }
00142                         else if(holder->isType<IppRoundMode>(property)) // if the property is IppRoundMode
00143                                 {
00144                                 QVIppRoundModeParamWidget *sl_widget = new QVIppRoundModeParamWidget(holder,this,property);
00145                                 inputVboxLayout->addWidget(sl_widget);
00146                                 haveInputWidgets = true;
00147                                 writeOutputProperties();
00148                                 connect(sl_widget,SIGNAL(valueChanged(IppRoundMode)),this,SLOT(somePropertyChanged()));
00149                                 }
00150 
00151                 }
00152                 else if(not holder->isLinkedOutput(property) && holder->isOutput(property) && not holder->isGUIInvisible(property)) {
00153                         if(holder->isType<int>(property)) // if the property is int.
00154                                 {
00155                                 QVWorker* worker;
00156                                 if((worker = dynamic_cast<QVWorker*>(holder)) != NULL) {
00157                                         QVOutputIntParamWidget *int_widget = new QVOutputIntParamWidget(worker,this,property);
00158                                         outputVboxLayout->addWidget(int_widget);
00159                                         haveOutputWidgets = true;
00160                                         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(somePropertyUpdate()));
00161                                         connect(worker,SIGNAL(endIteration(uint, int)),int_widget,SLOT(update()));
00162                                         }
00163                                 }
00164                         else if(holder->isType<double>(property)) // if the property is double.
00165                                 {
00166                                 QVWorker* worker;
00167                                 if((worker = dynamic_cast<QVWorker*>(holder)) != NULL) {
00168                                         QVOutputDoubleParamWidget *double_widget = new QVOutputDoubleParamWidget(worker,this,property);
00169                                         outputVboxLayout->addWidget(double_widget);
00170                                         haveOutputWidgets = true;
00171                                         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(somePropertyUpdate()));
00172                                         connect(worker,SIGNAL(endIteration(uint, int)),double_widget,SLOT(update()));
00173                                         }
00174                                 }
00175                         else if(holder->isType<bool>(property)) // if the property is bool.
00176                                 {
00177                                 QVWorker* worker;
00178                                 if((worker = dynamic_cast<QVWorker*>(holder)) != NULL) {
00179                                         QVOutputBoolParamWidget *bool_widget = new QVOutputBoolParamWidget(worker,this,property);
00180                                         outputVboxLayout->addWidget(bool_widget);
00181                                         haveOutputWidgets = true;
00182                                         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(somePropertyUpdate()));
00183                                         connect(worker,SIGNAL(endIteration(uint, int)),bool_widget,SLOT(update()));
00184                                         }
00185                                 }
00186                         else if(holder->isType<QString>(property)) // if the property is QString.
00187                                 {
00188                                 QVWorker* worker;
00189                                 if((worker = dynamic_cast<QVWorker*>(holder)) != NULL) {
00190                                         QVOutputStringParamWidget *st_widget = new QVOutputStringParamWidget(worker,this,property);
00191                                         outputVboxLayout->addWidget(st_widget);
00192                                         haveOutputWidgets = true;
00193                                         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(somePropertyUpdate()));
00194                                         connect(worker,SIGNAL(endIteration(uint, int)),st_widget,SLOT(update()));
00195                                         }
00196                                 }
00197                         else if(holder->isType<QVIndexedStringList>(property)) // if the property is QVIndexedStringList.
00198                                 {
00199                                 QVWorker* worker;
00200                                 if((worker = dynamic_cast<QVWorker*>(holder)) != NULL) {
00201                                         QVOutputStringListParamWidget *sl_widget = new QVOutputStringListParamWidget(worker,this,property);
00202                                         outputVboxLayout->addWidget(sl_widget);
00203                                         haveOutputWidgets = true;
00204                                         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(somePropertyUpdate()));
00205                                         connect(worker,SIGNAL(endIteration(uint, int)),sl_widget,SLOT(update()));
00206                                         }
00207                                 }
00208                         else if(holder->isType<QColor>(property)) // if the property is QColor
00209                                 {
00210                                 QVWorker* worker;
00211                                 if((worker = dynamic_cast<QVWorker*>(holder)) != NULL) {
00212                                         QVOutputColorParamWidget *sl_widget = new QVOutputColorParamWidget(worker,this,property);
00213                                         outputVboxLayout->addWidget(sl_widget);
00214                                         haveOutputWidgets = true;
00215                                         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(somePropertyUpdate()));
00216                                         connect(worker,SIGNAL(endIteration(uint, int)),sl_widget,SLOT(update()));
00217                                         }
00218                                 }
00219                 }
00220         }
00221 
00222         if (!haveInputWidgets) inputVboxLayout->addWidget(new QLabel("\n\tThis container has no\n\teditable input properties."));
00223         if (!haveOutputWidgets) outputVboxLayout->addWidget(new QLabel("\n\tThis container has no\n\tvisible output properties."));
00224 
00225         inputVboxLayout->addStretch();
00226         }
00227 
00228 void QVParamsInspectorWidget::somePropertyChanged()
00229         {
00230         writeOutputProperties();
00231         }
00232 
00233 void QVParamsInspectorWidget::somePropertyUpdate()
00234         {
00235         readInputProperties();
00236         }



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