PARP Research Group University of Murcia, Spain


src/qvgui/qvdesigner/qvdesignergui.h

00001 /*
00002  *      Copyright (C) 2008, 2009. 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 class QXmlStreamReader;
00030 #include "qvgui/qvgui.h"
00031 #include "facade/itemproperties.h"
00032 #include "facade/itemfactory.h"
00033 #include "slate/slatewindow.h"
00034 #include "slate/informer.h"
00035 
00036 #ifndef DOXYGEN_IGNORE_THIS
00037 
00038 class QVPropertyContainer;
00039 class QVPropertyContainerChange;
00040 
00041 // Clase que se encargará de hacer de intermediario entre la vista y el modelo (el slate y la QVAplication)
00042 class QVDesignerGUI: QObject, QVGUI
00043 {
00044         Q_OBJECT
00045         
00046         public:
00047                 QVDesignerGUI();
00048 
00050 
00052                 virtual void init();
00053         
00055                 void show();
00056 
00057 
00059 
00060                 // 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
00061                 QMap<QString, QList<QString> > getItemTypes() const;
00062         
00063                 // 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
00064                 QMap<QString, QList<QString> > getInputItemTypes() const;
00065         
00066                 // 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
00067                 QMap<QString, QList<QString> > getMiddleItemTypes() const;
00068         
00069                 // 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
00070                 QMap<QString, QList<QString> > getOutputItemTypes() const;
00071 
00072                 QString getCppText() const;
00073 
00074                 QString getXMLText();
00075 
00076                 bool loadXML(QString text);
00077 
00078 
00080 
00081                 // crea y registra un item, del tipo especificado y nombre concreto, en el sistema. Devuelve el id del item (0 si no lo ha creado)
00082                 uint addItem(const QString type, const QString name, uint lastId = 0);
00083         
00084                 // crea y registra un link entre dos items del sistema
00085                 bool addLink(const uint fromId, const QString fromProp, const uint toId, const QString toProp, const bool synchronous, const bool sequential);
00086 
00087                 // borra y desregistra un item
00088                 bool delItem(const uint id);
00089         
00090                 // borra y desregistra un link
00091                 bool delLink(const uint fromId, const QString fromProp, const uint toId, const QString toProp);
00092 
00093                 // establece el valor de la propiedad de un item del sistema
00094                 template <class Type> bool setProperty(const uint fromId, const QString fromProp, const Type &value);
00095 
00096                 bool setName(const uint id, const QString name);
00097 
00098                 void showProperties(const uint id);
00099 
00101 
00102                 // lanza un sistema como el compuesto en la pizarra
00103                 void run();
00104         
00105                 // para el sistema lanzado
00106                 void stop();
00107 
00108         public slots:
00109                 void quit();
00110                 void processChange(QVPropertyContainerChange change);
00111                 void dialogChange(QVPropertyContainerChange change);
00112 
00113         private:
00114                 bool createDialog(const uint itemId);
00115                 void deleteDialog(const uint itemId);
00116                 QString getLinkName(QVPropertyContainerChange change);
00117                 QString getLinkName(QString fromName, QString fromProp, QString toName, QString toProp);
00118                 QString getAbsPropName(QString fromName, QString fromProp);
00119                 void createGroups(QList<GroupInfo> &lastGroups, QMap<uint, uint> &oldId_To_NewId);
00120 
00121                 bool readXMLQVApplication(QXmlStreamReader &xmlReader);
00122                 bool readXMLNodes(QXmlStreamReader &xmlReader);
00123                 bool readXMLNode(QXmlStreamReader &xmlReader);
00124                 bool readXMLProperty(QXmlStreamReader &xmlReader, uint id);
00125                 bool readXMLLinks(QXmlStreamReader &xmlReader);
00126                 bool readXMLAsynchronousLink(QXmlStreamReader &xmlReader);
00127                 bool readXMLSynchronousLink(QXmlStreamReader &xmlReader);
00128                 bool readXMLSequentialLink(QXmlStreamReader &xmlReader);
00129                 bool readXMLGroups(QXmlStreamReader &xmlReader);
00130                 bool readXMLGroup(QXmlStreamReader &xmlReader, QList<GroupInfo> &groupInfos);
00131                 bool readXMLChildNode(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00132                 bool readXMLChildGroup(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00133                 bool readXMLVisibleNodeLink(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00134                 bool readXMLVisibleGroupLink(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00135                 bool readXMLUnknownElement(QXmlStreamReader &xmlReader);
00136 
00137                 ItemFactory factory;
00138                 SlateWindow slate;
00139                 Informer informer;
00140 
00141                 QMap<uint, QVPropertyContainer *> containers;
00142                 QMap<uint, QVPropertyContainer *> initialContainers;
00143                 QMap<uint, QDialog *> dialogs; // el identificador es del container asociado
00144                 QMap<uint, uint> dialogsToContainers; // los containers asociados a los dialogos (id dialogo, id container)
00145 
00146                         class CreatedLink
00147                                 {
00148                                 public:
00149                                         CreatedLink(const uint _fromId, const QString _fromProp, const uint _toId, const QString _toProp, const bool _sync, const bool _sequ):
00150                                                 fromId(_fromId), fromProp(_fromProp), toId(_toId), toProp(_toProp), synchronous(_sync), sequential(_sequ) { }
00151 
00152                                         uint fromId;
00153                                         QString fromProp;
00154                                         uint toId;
00155                                         QString toProp;
00156                                         bool synchronous;
00157                                         bool sequential;
00158                                 };
00159 
00160                         class CreatedItem
00161                                 {
00162                                 public:
00163                                         CreatedItem(): type(""), name(""), id(0) { }
00164                                         CreatedItem(const QString _type, const QString _name, uint _id): type(_type), name(_name), id(_id) { }
00165 
00166                                         QString type, name;
00167                                         uint id;
00168                                 };
00169 
00170                         class PropertyChange
00171                                 {
00172                                 public:
00173                                         PropertyChange(const uint contId, const QString prop, const QVariant val): id(contId), propName(prop), value(val) { }
00174 
00175                                         uint id;
00176                                         QString propName;
00177                                         QVariant value;
00178                                 };
00179 
00180                 QMap<QString, CreatedLink> createdLinks; // the key is "fromName[fromProp] => toName[toProp]"
00181                 QMap<uint, CreatedItem> createdItems;
00182                 QMap<QString, PropertyChange> propertyChanges; // the key is "contName[propName]"
00183 
00184                 QMap<uint, uint> XMLId_To_ContainersId; // para cuando estamos cargando el XML ya que se hace recursivo entre muchas funciones
00185 };
00186 
00187 #endif
00188 
00189 #endif
00190 



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