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("QVDefaultGUI");
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         leftvboxlayout->setSpacing(0);
00083         leftvboxlayout->setMargin(0);
00084         hboxlayout->addWidget(leftwidget);
00085         groupboxlayout = new QVBoxLayout(qgroupbox);
00086         groupboxlayout->addWidget(toolbox);
00087         hboxlayout->addWidget(qgroupbox);
00088         setLayout(hboxlayout);
00089         }
00090 
00091 void QVDefaultGUI::closeEvent(QCloseEvent *event)
00092         {
00093         Q_UNUSED(event);
00094         qvApp->deregisterGUI();
00095         emit closed();
00096         }
00097 
00098 void QVDefaultGUI::add(QVWorker * worker)
00099         {
00100         // Adding params
00101         QVParamsInspectorWidget *qvparamsinspectorwidget;
00102         qvparamsinspectorwidget = new QVParamsInspectorWidget(worker,this);
00103         toolbox->addItem(qvparamsinspectorwidget,worker->getName());
00104         qvparamsinspectorwidget->updateGeometry();
00105 
00106         // Adding worker interface small
00107         QVWorkerInterfaceSmall *workerWidget = new QVWorkerInterfaceSmall(worker);
00108         leftvboxlayout->addWidget(workerWidget);
00109         }
00110 
00111 void QVDefaultGUI::add(QVCamera *camera)
00112         {
00113         QVCameraWidgetSmall *cameraWidget = new QVCameraWidgetSmall(camera);
00114         leftvboxlayout->addWidget(cameraWidget);
00115         }
00116