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 #include "slatewindow.h"
00032 #include "../facade/itemproperties.h"
00033
00034 class ItemProperties;
00035
00036 #ifndef DOXYGEN_IGNORE_THIS
00037
00038 class Node : public QGraphicsItem
00039 {
00040 friend class GroupNode;
00041 Q_DECLARE_TR_FUNCTIONS(Node)
00042
00043 public:
00044 Node(QString _name, SlateWindow *wind, QGraphicsItem * parent = 0, QGraphicsScene * scene = 0);
00045 Node(ItemProperties item, QString _name, uint _id, SlateWindow *wind, QGraphicsItem * parent = 0, QGraphicsScene * scene = 0);
00046 ~Node();
00047
00048 void setText(const QString &text);
00049 QString text() const;
00050 void setTextColor(const QColor &color);
00051 QColor textColor() const;
00052 void setOutlineColor(const QColor &color);
00053 QColor outlineColor() const;
00054 void setBackgroundColor(const QColor &color);
00055 QColor backgroundColor() const;
00056
00057 void addInLink(Link *link);
00058 void addOutLink(Link *link);
00059 virtual void removeLink(Link *link);
00060 QList<Link *> getLinks() const;
00061 QList<Link *> getInLinks() const;
00062 QList<Link *> getOutLinks() const;
00063 int precursors(QList<Node *> tail = QList<Node *>());
00064
00065 QString getName() const { return name; }
00066 QString getType() const { return type; }
00067 void setType(QString _type) { type = _type; }
00068 QRectF boundingRect() const;
00069 QPainterPath shape() const;
00070
00071 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00072 virtual QPointF scenePointPos(int point) const;
00073 virtual QPointF scenePointPos(QString name, bool in) const;
00074 virtual void updateLinksPos();
00075 virtual void setHide(bool hide);
00076 int numProps() const;
00077 QString propName(int point) const;
00078 int propPoint(QString name, bool in) const;
00079 int propType(int point) const;
00080 void insertProperty(int pos, QString name, int type, bool input, bool output);
00081 int insertProperty(QString name, int type, bool input, bool output);
00082 void removeProperty(QString name);
00083 uint getId();
00084 void setName(QString _name);
00085 void prepareHierarchy();
00086 void updateHierarchy();
00087 void publicPrepareGeometryChange();
00088
00089
00090 protected:
00091 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
00092 void mousePressEvent(QGraphicsSceneMouseEvent * event);
00093 void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
00094 void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
00095 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00096 void CorrectTextChange();
00097
00098 void markPoint(int point, bool validity);
00099 void unmarkPoint();
00100 bool isValidLink(Node *fromNode, int fromPoint, Node *toNode, int toPoint) const;
00101 void deleteProperty(int pos);
00102 void delLastProp();
00103
00104 virtual QRectF outlineRect() const;
00105 virtual int roundness(double size) const;
00106 virtual int pointAt(QPointF pos) const;
00107 virtual int insertPos() const;
00108 virtual void validLinkRelease(Node *fromNode, int fromPoint, Node *toNode, int toPoint);
00109 ItemProperties getItemProp() { return itemProp; }
00110
00111 QList<Link *> myInLinks;
00112 QList<Link *> myOutLinks;
00113
00114 QString myText;
00115 QColor myTextColor;
00116 QColor myBackgroundColor;
00117 QColor myOutlineColor;
00118
00119 QString name;
00120 QString type;
00121
00122 ItemProperties itemProp;
00123 int numProp;
00124 SlateWindow *window;
00125 QRectF outlinerect;
00126
00127 int clickedPoint;
00128 QGraphicsLineItem *line;
00129 int externalMarkedPoint;
00130 Node *externalMarkedItem;
00131 int markedPoint;
00132 bool markedValidity;
00133
00134 uint id;
00135
00136 double lineSpacing;
00137 };
00138
00139 #endif
00140 #endif