PARP Research Group University of Murcia, Spain


src/qvgui/qvdefaultgui.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. 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 <QVApplication>
00026 #include <QVImageCanvas>
00027 
00028 #include <qvgui/qvdefaultgui.h>
00029 #include <qvgui/qvparamsinspectorwidget.h>
00030 #include <qvgui/qvcamerawidgetsmall.h>
00031 #include <qvgui/qvworkerinterfacesmall.h>
00032 
00033 QVDefaultGUI::QVDefaultGUI(QWidget *parent): QWidget(parent), qvimagecanvaslist()
00034         {
00035         qDebug() << "QVDefaultGUI::QVDefaultGUI()";
00036         if (qvApp == NULL)
00037                 {
00038                 QString str =   "QVDefaultGUI::QVDefaultGUI(): the QVDefaultGUI cannot be created before the QVApplication instance. Aborting now.";
00039                 std::cerr << qPrintable(str) << std::endl;
00040                 exit(1);
00041                 }
00042         // if its a --help call, do nothing
00043         if (qvApp->forHelp()) return;
00044 
00045         connect(this,SIGNAL(closed()),qvApp,SLOT(quit()));
00046 
00047         hboxlayout = new QHBoxLayout();
00048         leftwidget = new QWidget();
00049         qgroupbox = new QGroupBox("Workers input");
00050         leftvboxlayout = new QVBoxLayout(leftwidget);
00051         toolbox = new QToolBox(this);
00052 
00053         setWindowTitle("QVision default GUI");
00054         qvApp->registerGUI(this);
00055 
00056         qDebug() << "QVDefaultGUI::QVDefaultGUI() <~ return";
00057         }
00058 
00059 QVDefaultGUI::~QVDefaultGUI()
00060         {
00061         QListIterator<QVImageCanvas*> i(qvimagecanvaslist);
00062         while (i.hasNext())
00063         delete(i.next());
00064         }
00065 
00066 void QVDefaultGUI::init()
00067         {
00068         foreach(QVPropertyContainer* qvp, qvApp->getQVPropertyContainers())
00069                 {
00070                 QVWorker* worker;
00071                 if((worker = dynamic_cast<QVWorker*>(qvp)) != NULL)
00072                         add(worker);
00073                 }
00074         leftvboxlayout->addStretch();
00075         foreach(QVPropertyContainer* qvp, qvApp->getQVPropertyContainers())
00076                 {
00077                 QVCamera* camera;
00078                 if((camera = dynamic_cast<QVCamera*>(qvp)) != NULL)
00079                         add(camera);
00080                 }
00081 
00082         foreach(QVPropertyContainer* qvp, qvApp->getQVPropertyContainers())
00083                 {
00084                 QVImageCanvas *imageCanvas;
00085                 if((imageCanvas = dynamic_cast<QVImageCanvas*>(qvp)) != NULL)
00086                         add(imageCanvas);
00087                 }
00088 
00089         leftvboxlayout->setSpacing(0);
00090         leftvboxlayout->setMargin(0);
00091         hboxlayout->addWidget(leftwidget);
00092         groupboxlayout = new QVBoxLayout(qgroupbox);
00093         groupboxlayout->addWidget(toolbox);
00094         hboxlayout->addWidget(qgroupbox);
00095         setLayout(hboxlayout);
00096         }
00097 
00098 void QVDefaultGUI::closeEvent(QCloseEvent *event)
00099         {
00100         Q_UNUSED(event);
00101         qvApp->deregisterGUI();
00102         emit closed();
00103         }
00104 
00105 void QVDefaultGUI::add(QVWorker * worker)
00106         {
00107         // Adding params
00108         QVParamsInspectorWidget *qvparamsinspectorwidget;
00109         qvparamsinspectorwidget = new QVParamsInspectorWidget(worker,this);
00110         toolbox->addItem(qvparamsinspectorwidget,worker->getName());
00111         qvparamsinspectorwidget->updateGeometry();
00112 
00113         // Adding worker interface small
00114         QVWorkerInterfaceSmall *workerWidget = new QVWorkerInterfaceSmall(worker);
00115         leftvboxlayout->addWidget(workerWidget);
00116         }
00117 
00118 void QVDefaultGUI::add(QVCamera *camera)
00119         {
00120         QVCameraWidgetSmall *cameraWidget = new QVCameraWidgetSmall(camera);
00121         leftvboxlayout->addWidget(cameraWidget);
00122         }
00123 
00124 void QVDefaultGUI::add(QVImageCanvas *imageCanvas)
00125         {
00126         // Adding params
00127         QVParamsInspectorWidget *qvparamsinspectorwidget;
00128         qvparamsinspectorwidget = new QVParamsInspectorWidget(imageCanvas,this);
00129         toolbox->addItem(qvparamsinspectorwidget, imageCanvas->getName());
00130         qvparamsinspectorwidget->updateGeometry();
00131         }
00132 



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