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

Generated on Thu Mar 13 19:18:16 2008 for QVision by  doxygen 1.5.3