00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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;
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;
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