src/qvgui/qvgui.cpp

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

Generated on Thu Jul 17 17:23:28 2008 for QVision by  doxygen 1.5.3