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
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;
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