nodeeditor_doxy
|
00001 #ifndef NODE_H 00002 #define NODE_H 00003 00004 #include <QGraphicsItem> 00005 #include <QList> 00006 #include <QLabel> 00007 00008 #include "NodeItem.h" 00009 #include "nodeconnection.h" 00010 00011 //class Edge; 00012 //class GraphWidget; 00013 QT_BEGIN_NAMESPACE 00014 class QGraphicsSceneMouseEvent; 00015 QT_END_NAMESPACE 00016 00017 class NodeItem; 00018 class NodeConnection; 00019 00020 class NodeConnector : public QGraphicsItem 00021 { 00022 public: 00023 enum { Type = UserType + 666 + 6 }; 00024 int type() const 00025 { return Type;} 00026 enum ConnectorType { In=1, Out=2, InOut=3 }; 00027 ConnectorType connectorType() const 00028 { return mConnectorType; } 00029 void setConnectorType(ConnectorType c) { 00030 mConnectorType = c; 00031 } 00032 00033 enum ConnectorAlignment { None=0, Left=1, Right=2, Bottom=3, Top=4 }; 00034 ConnectorAlignment connectorAlignment() const { 00035 return mConnectorAlignment; 00036 } 00037 void setConnectorAlignment(ConnectorAlignment alignment) { 00038 mConnectorAlignment = alignment; 00039 } 00040 00041 bool singleConnection() const { return mSingleConnection; } 00042 void setSingleConnection(bool singleConnection) { 00043 mSingleConnection = singleConnection; 00044 } 00045 00046 bool selfConnections() const { return mSelfConnections; } 00047 void setSelfConnections(bool selfConnections) { 00048 mSelfConnections = selfConnections; 00049 } 00050 00051 00052 NodeConnector(NodeItem *parent, QGraphicsScene *scene, /*QLabel*/QWidget* widget, ConnectorType con = In, const ConnectorAlignment connectorAlignment = ConnectorAlignment::Left, const bool singleConnection = false, const bool disableWidgetOnConnection = false, const int radius = 7, const bool selfConnections = false); 00053 virtual ~NodeConnector(); 00054 /* 00055 void addEdge(Edge *edge); 00056 QList<Edge *> edges() const; 00057 00058 enum { Type = UserType + 1 }; 00059 int type() const { return Type; } 00060 00061 void calculateForces(); 00062 bool advance(); 00063 */ 00064 QRectF boundingRect() const; 00065 QPainterPath shape() const; 00066 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 00067 00068 //dw 00069 void updatePosition(); 00070 //void updatePositionGeometry(); 00071 void addConnection(NodeConnection *arrow); 00072 void deleteConnection(NodeConnection *arrow); 00073 void deleteConnections(); 00074 void removeConnection(NodeConnection *arrow); 00075 00076 void setHighlight(bool highlight); 00077 00078 //private: 00079 int mRadius; 00080 ConnectorType mConnectorType; 00081 NodeItem *parent; 00082 QWidget* mWidget; 00083 //QWidget* label; 00084 //bool right; 00085 ConnectorAlignment mConnectorAlignment; 00086 QList<NodeConnection *> arrows; 00087 QColor darkColor; 00088 bool highlight; 00089 bool mSingleConnection; 00090 bool mSelfConnections; 00091 bool mDisableWidgetOnConnection; 00092 00093 //ugly, but node ctor is called after wiget is removed, but delete of connector would otherwise activate label widget 00094 void removeWidget(); 00095 00096 void update(const QRectF & rect = QRectF()); 00097 00098 protected: 00099 //QVariant itemChange(GraphicsItemChange change, const QVariant &value); 00100 00101 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00102 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 00103 //void mouseOverEvent(QGraphicsSceneMouseEvent *event); 00104 //void enterEvent ( QEvent * event ); 00105 00106 private: 00107 00108 void debugPaint(QPainter *painter); 00109 00110 00111 }; 00112 00113 #endif