examples/qvdesigner0.2/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 
00057         QString getName() const { return name; }
00058         QString getType() const { return type; }
00059         void setName(QString _name) { name = _name; }
00060         void setType(QString _type) { type = _type; }
00061         virtual QString propName(int point) const = 0; // devuelve el nombre de la propiedad seƱalada por point
00062 
00063     QRectF boundingRect() const;
00064     QPainterPath shape() const;
00065     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) = 0;
00066         virtual QPointF scenePointPos(int point) const = 0;
00067         virtual QPointF scenePointPos(QString name, bool in) const = 0;
00068         virtual void updateLinksPos() = 0;
00069 
00070 protected:
00071     virtual QRectF outlineRect() const = 0;
00072     virtual int roundness(double size) const = 0;
00073         virtual int pointAt(QPointF pos) const = 0;
00074         void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00075 
00076     QList<Link *> myInLinks;
00077         QList<Link *> myOutLinks;
00078 
00079     QString myText;
00080     QColor myTextColor;
00081     QColor myBackgroundColor;
00082     QColor myOutlineColor;
00083 
00084         QString name;
00085         QString type;
00086 };
00087 
00088 #endif
00089 #endif