examples/qvdesigner0.2/facade/designergui.h

00001 /*
00002  *      Copyright (C) 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 
00021 
00022 #ifndef DESIGNERGUI_H
00023 #define DESIGNERGUI_H
00024 
00025 #include <QObject>
00026 #include <QList>
00027 #include <QString>
00028 #include <QMap>
00029 #include "qvgui/qvgui.h"
00030 #include "itemproperties.h"
00031 #include "itemfactory.h"
00032 #include "slate/slatewindow.h"
00033 
00034 #ifndef DOXYGEN_IGNORE_THIS
00035 
00036 class QVPropertyContainer;
00037 class QVPropertyContainerChange;
00038 
00039 
00040 // Clase que se encargará de hacer de intermediario entre la vista y el modelo (el slate y la QVAplication)
00041 class DesignerGUI: QObject, QVGUI
00042 {
00043         Q_OBJECT
00044         
00045         public:
00046                 DesignerGUI();
00047 
00049 
00051                 virtual void init();
00052         
00054                 void show();
00055 
00056 
00058 
00059                 // devuelve la lista de Items disponibles en el sistema, cada uno de estos items es un elemento del diseño de los programas de QVision
00060                 QList<QString> getItemTypes() const;
00061         
00062                 // devuelve la lista de Items de entrada disponibles en el sistema, cada uno de estos items es un elemento del diseño de los programas de QVision
00063                 QList<QString> getInputItemTypes() const;
00064         
00065                 // devuelve la lista de Items intermedios disponibles en el sistema, cada uno de estos items es un elemento del diseño de los programas de QVision
00066                 QList<QString> getMiddleItemTypes() const;
00067         
00068                 // devuelve la lista de Items de salida disponibles en el sistema, cada uno de estos items es un elemento del diseño de los programas de QVision
00069                 QList<QString> getOutputItemTypes() const;
00070 
00071 
00073 
00074                 // crea y registra un item, del tipo especificado y nombre concreto, en el sistema
00075                 bool addItem(const QString type, const QString name);
00076         
00077                 // crea y registra un link entre dos items del sistema
00078                 bool addLink(const QString fromName, const QString fromProp, const QString toName, const QString toProp, const bool synchronous);
00079 
00080                 // borra y desregistra un item
00081                 bool delItem(const QString name);
00082         
00083                 // borra y desregistra un link
00084                 bool delLink(const QString fromName, const QString fromProp, const QString toName, const QString toProp);
00085 
00086                 // establece el valor de la propiedad de un item del sistema
00087                 template <class Type> bool setProperty(const QString fromName, const QString fromProp, const Type &value);
00088 
00089                 void showProperties(const QString itemName);
00090 
00092 
00093                 // lanza un sistema como el compuesto en la pizarra
00094                 void run();
00095         
00096                 // para el sistema lanzado
00097                 void stop();
00098 
00099         public slots:
00100                 void quit();
00101                 void processChange(QVPropertyContainerChange change);
00102 
00103         private:
00104                 bool createDialog(const QString itemName);
00105 
00106                 ItemFactory factory;
00107                 SlateWindow slate;
00108 
00109                 QMap<QString, QVPropertyContainer *> containers;
00110                 QMap<QString, QDialog *> dialogs;
00111 
00112                         class CreatedLink
00113                                 {
00114                                 public:
00115                                         CreatedLink(const QString _fromName, const QString _fromProp, const QString _toName, const QString _toProp, const bool _synchronous):
00116                                                 fromName(_fromName), fromProp(_fromProp), toName(_toName), toProp(_toProp), synchronous(_synchronous) { }
00117 
00118                                         QString fromName, fromProp, toName, toProp;
00119                                         bool synchronous;
00120                                 };
00121 
00122                         class CreatedItem
00123                                 {
00124                                 public:
00125                                         CreatedItem(const QString _type, const QString _name): type(_type), name(_name) { }
00126 
00127                                         QString type, name;
00128                                 };
00129 
00130                 QMap<QString, CreatedLink> createdLinks; // the key is "fromName[fromProp] => toName[toProp]"   (realmente necesaria???)
00131                 QMap<QString, CreatedItem> createdItems;
00132 };
00133 
00134 #endif
00135 
00136 #endif
00137