PARP Research Group University of Murcia, Spain


src/qvgui/qvdesigner/slate/node.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 NODE_H
00023 #define NODE_H
00024 
00025 #include <QApplication>
00026 #include <QColor>
00027 #include <QGraphicsItem>
00028 #include <QSet>
00029 
00030 #include "link.h"
00031 
00032 #ifndef DOXYGEN_IGNORE_THIS
00033 
00034 class Node : public QGraphicsItem
00035 {
00036     Q_DECLARE_TR_FUNCTIONS(Node)
00037 
00038 public:
00039     Node(QGraphicsItem * parent = 0, QGraphicsScene * scene = 0);
00040 
00041     void setText(const QString &text);
00042     QString text() const;
00043     void setTextColor(const QColor &color);
00044     QColor textColor() const;
00045     void setOutlineColor(const QColor &color);
00046     QColor outlineColor() const;
00047     void setBackgroundColor(const QColor &color);
00048     QColor backgroundColor() const;
00049 
00050     void addInLink(Link *link);
00051     void addOutLink(Link *link);
00052     void removeLink(Link *link);
00053         QList<Link *> getLinks() const;
00054         QList<Link *> getInLinks() const;
00055         QList<Link *> getOutLinks() const;
00056         int precursors(QList<Node *> tail = QList<Node *>());
00057 
00058         QString getName() const { return name; }
00059         QString getType() const { return type; }
00060         void setName(QString _name) { name = _name; }
00061         void setType(QString _type) { type = _type; }
00062         virtual QString propName(int point) const = 0; // devuelve el nombre de la propiedad seƱalada por point
00063 
00064     QRectF boundingRect() const;
00065     QPainterPath shape() const;
00066     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) = 0;
00067         virtual QPointF scenePointPos(int point) const = 0;
00068         virtual QPointF scenePointPos(QString name, bool in) const = 0;
00069         virtual int propPoint(QString name, bool in) const = 0; // devuelve el punto (de entrada o salida) de una propiedad.
00070         virtual int numProps() const = 0;
00071         virtual void updateLinksPos() = 0;
00072 
00073 protected:
00074     virtual QRectF outlineRect() const = 0;
00075     virtual int roundness(double size) const = 0;
00076         virtual int pointAt(QPointF pos) const = 0;
00077         void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00078 
00079     QList<Link *> myInLinks;
00080         QList<Link *> myOutLinks;
00081 
00082     QString myText;
00083     QColor myTextColor;
00084     QColor myBackgroundColor;
00085     QColor myOutlineColor;
00086 
00087         QString name;
00088         QString type;
00089 };
00090 
00091 #endif
00092 #endif



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