PARP Research Group University of Murcia, Spain


src/qvgui/qvdesigner/slate/itemnode.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 ITEMNODE_H
00023 #define ITEMNODE_H
00024 
00025 #include "node.h"
00026 #include "../facade/itemproperties.h"
00027 
00028 #ifndef DOXYGEN_IGNORE_THIS
00029 
00030 class ItemProperties;
00031 class SlateWindow;
00032 
00033 class ItemNode : public Node
00034 {
00035 
00036 public:
00037     ItemNode(ItemProperties item, QString _name, SlateWindow *wind, QGraphicsItem * parent = 0, QGraphicsScene * scene = 0);
00038     ~ItemNode();
00039 
00040     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00041         QPointF scenePointPos(int point) const;
00042         QPointF scenePointPos(QString name, bool in) const;
00043         int numProps() const;
00044         void updateLinksPos();
00045         QString propName(int point) const; // devuelve el nombre de la propiedad señalada por point
00046         int propPoint(QString name, bool in) const; // devuelve el punto (de entrada o salida) de una propiedad.
00047         int propType(int point) const; // devuelve el tipo de la propiedad señalada por point
00048         void insertProperty(int pos, QString name, int type, bool input, bool output);
00049         void insertProperty(QString name, int type, bool input, bool output);
00050         void removeProperty(QString name);
00051 
00052 protected:
00053         void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
00054         void mousePressEvent(QGraphicsSceneMouseEvent * event);
00055         void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
00056         void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
00057     QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00058 
00059         void markPoint(int point, bool validity);
00060         void unmarkPoint();
00061         bool isValidLink(ItemNode *fromNode, int fromPoint, ItemNode *toNode, int toPoint) const;
00062         void deleteProperty(int pos);
00063 //      void addNewProp(ItemNode *toNode, int toPoint);
00064         void delLastProp();
00065 
00066     QRectF outlineRect() const;
00067     int roundness(double size) const;
00068         int pointAt(QPointF pos) const;
00069         virtual int insertPos() const; // posición en que se quieren insertar las nuevas propiedades, para que sea la última menos el los de los "..."
00070 
00071         ItemProperties itemProp; // propiedades del worker asociado
00072         int numProp; // número de propiedades del worker asociado
00073         SlateWindow *window; // ventana con que se ha creado, para lanzarle las peticiones de creación de links
00074         QRectF outlinerect;
00075 
00076         int clickedPoint; // indica si el último click se ha hecho sobre una de los puntos, y sobre cual
00077         QGraphicsLineItem *line; // linea indicadora del proceso de enlace
00078         int externalMarkedPoint; // punto de otro item sobre el que se está intentando realizar un enlace
00079         ItemNode *externalMarkedItem; // item sobre el que se esa intentando realizar el enlace
00080         int markedPoint; // punto local que se ha seleccionado para colorear por que se está intentando hacer un link sobre el
00081         bool markedValidity; // indoca si el markedPoint es un objetivo correcto, lo que determinará el color usado
00082 
00083         double lineSpacing;
00084 };
00085 
00086 #endif
00087 #endif



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