Code Documentation 3.1
Social Network Visualizer
Loading...
Searching...
No Matches
graphicsnode.h
Go to the documentation of this file.
1
17#ifndef GRAPHICSNODE_H
18#define GRAPHICSNODE_H
19
20
21#include <QGraphicsItem>
22#include <QObject>
23#include <QPolygon>
24
25class GraphicsWidget;
26class QGraphicsSceneMouseEvent;
27class GraphicsEdge;
30
31using namespace std;
32
33static const int TypeNode = QGraphicsItem::UserType+1;
34static const int ZValueNode = 100;
35static const int ZValueNodeHighlighted = 110;
36
37
38
45//
46
47class GraphicsNode : public QObject, public QGraphicsItem {
48 Q_OBJECT
49 Q_INTERFACES (QGraphicsItem)
50
51public:
52
54 const int &num,
55 const int &size,
56 const QString &color,
57 const QString &shape,
58 const QString &iconPath,
59 const bool &showNumbers,
60 const bool &numbersInside,
61 const QString &numberColor,
62 const int &numberSize,
63 const int &numDistance,
64 const bool &showLabels,
65 const QString &label,
66 const QString &labelColor,
67 const int &labelSize,
68 const int &labelDistance,
69 const bool &edgeHighlighting,
70 QPointF p
71 );
72
74
75 enum { Type = UserType + 1 };
76 int type() const { return Type; }
77
78 QRectF boundingRect() const;
79 QPainterPath shape() const;
80 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
81
82 int nodeNumber() {return m_num;}
83
84 void addInEdge( GraphicsEdge *edge ) ;
86 void addOutEdge( GraphicsEdge *edge ) ;
88
89 void setSize(const int &);
90 int size() const;
91
92 void setShape (const QString, const QString &iconPath=QString());
93 QString nodeShape() {return m_shape;}
94
95 void setColor(const QString &colorName);
96 void setColor(QColor color);
97 QString color ();
98
99 void addLabel();
101 void deleteLabel();
102 void setLabelVisibility(const bool &toggle);
103 void setLabelSize(const int &size);
104 void setLabelText ( const QString &label) ;
105 void setLabelColor (const QString &color) ;
106 QString labelText();
107 void setLabelDistance(const int &distance);
108
109 void addNumber () ;
111 void deleteNumber();
112 void setNumberVisibility(const bool &toggle);
113 void setNumberInside(const bool &toggle);
114 void setNumberSize(const int &size);
115 void setNumberDistance(const int &distance);
116 void setNumberColor(const QString &color);
117
118 void setEdgeHighLighting(const bool &toggle) ;
119
120
121protected:
122
123 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
124// void mousePressEvent(QGraphicsSceneMouseEvent *event);
125// void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
126// void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
127// void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
128
129signals:
130
132
133
134private:
135
137 QPainterPath m_path;
138 QPointF newPos;
139 QPolygonF *m_poly_t;
140 int m_num;
148 QString m_numColor;
154 list<GraphicsEdge*> inEdgeList, outEdgeList;
157};
158
159#endif
Definition graphicsedge.h:49
Definition graphicsnodelabel.h:26
Definition graphicsnodenumber.h:27
Definition graphicsnode.h:47
void nodeClicked(GraphicsNode *)
@ Type
Definition graphicsnode.h:75
void addInEdge(GraphicsEdge *edge)
Adds an inbound edge to this node.
Definition graphicsnode.cpp:557
QColor m_col_orig
Definition graphicsnode.h:149
void setLabelText(const QString &label)
Sets the label of this node.
Definition graphicsnode.cpp:645
QPainterPath shape() const
Returns the shape of the node as a path in local coordinates.
Definition graphicsnode.cpp:340
void addNumber()
Adds a graphics number to the node.
Definition graphicsnode.cpp:740
QString labelText()
Returns the label of the node.
Definition graphicsnode.cpp:662
GraphicsWidget * graphicsWidget
Definition graphicsnode.h:136
QString nodeShape()
Definition graphicsnode.h:93
void setEdgeHighLighting(const bool &toggle)
‍**
Definition graphicsnode.cpp:546
~GraphicsNode()
Definition graphicsnode.cpp:872
void setNumberColor(const QString &color)
GraphicsNode::setNumberColor.
Definition graphicsnode.cpp:837
void removeInEdge(GraphicsEdge *)
Removes the inbound edge from this node.
Definition graphicsnode.cpp:567
void setLabelDistance(const int &distance)
Sets the distance of the label from the node.
Definition graphicsnode.cpp:725
int size() const
Returns the esoteric size of the node.
Definition graphicsnode.cpp:210
int m_labelSize
Definition graphicsnode.h:144
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Called when the node changes, i.e. moves, becomes disabled or changes its visibility Propagates the c...
Definition graphicsnode.cpp:441
QString m_iconPath
Definition graphicsnode.h:147
int m_labelDistance
Definition graphicsnode.h:146
int m_size_orig
Definition graphicsnode.h:141
GraphicsNodeLabel * label()
Returns the graphics label of the node.
Definition graphicsnode.cpp:618
bool m_edgeHighLighting
Definition graphicsnode.h:152
void removeOutEdge(GraphicsEdge *)
Removes an outbound edge from this node.
Definition graphicsnode.cpp:593
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Does the actual painting using the QPainterPath created by the setShape()
Definition graphicsnode.cpp:368
void setLabelColor(const QString &color)
Sets the color of the node label.
Definition graphicsnode.cpp:671
void addLabel()
Creates a graphics label to this node.
Definition graphicsnode.cpp:605
int m_state
Definition graphicsnode.h:142
QString m_labelText
Definition graphicsnode.h:151
void setNumberVisibility(const bool &toggle)
Toggles the visibility of graphics node number.
Definition graphicsnode.cpp:776
QRectF boundingRect() const
Returns the bounding rectangle of the node.
Definition graphicsnode.cpp:352
QPolygonF * m_poly_t
Definition graphicsnode.h:139
QString m_shape
Definition graphicsnode.h:147
void deleteNumber()
Deletes the graphics node number.
Definition graphicsnode.cpp:763
void setNumberDistance(const int &distance)
GraphicsNode::setNumberDistance.
Definition graphicsnode.cpp:854
GraphicsNodeNumber * number()
Returns the graphics node number.
Definition graphicsnode.cpp:755
int m_num
Definition graphicsnode.h:140
void setLabelSize(const int &size)
Sets the size of the node label.
Definition graphicsnode.cpp:710
void setNumberSize(const int &size)
GraphicsNode::setNumberSize.
Definition graphicsnode.cpp:818
bool m_hasNumber
Definition graphicsnode.h:152
int m_numSize
Definition graphicsnode.h:143
QColor m_col_outline
Definition graphicsnode.h:150
void setNumberInside(const bool &toggle)
Toggles displaying node number inside the node.
Definition graphicsnode.cpp:800
QString color()
Returns the node color in the format "#RRGGBB".
Definition graphicsnode.cpp:175
void setSize(const int &)
Changes the size of the node.
Definition graphicsnode.cpp:186
QString m_labelColor
Definition graphicsnode.h:151
void setShape(const QString, const QString &iconPath=QString())
Sets the shape of the node and prepares the corresponding QPainterPath m_path which will be drawn by ...
Definition graphicsnode.cpp:231
list< GraphicsEdge * > outEdgeList
Definition graphicsnode.h:154
GraphicsNodeNumber * m_number
Definition graphicsnode.h:156
QPointF newPos
Definition graphicsnode.h:138
int type() const
Definition graphicsnode.h:76
void setLabelVisibility(const bool &toggle)
Toggles the visibiity of the node label.
Definition graphicsnode.cpp:687
QPainterPath m_path
Definition graphicsnode.h:137
bool m_hasLabel
Definition graphicsnode.h:152
void setColor(const QString &colorName)
Changes the color of the node. The new color name can be in one of these formats:
Definition graphicsnode.cpp:145
QColor m_col
Definition graphicsnode.h:149
list< GraphicsEdge * > inEdgeList
Definition graphicsnode.h:154
GraphicsNodeLabel * m_label
Definition graphicsnode.h:155
void addOutEdge(GraphicsEdge *edge)
Adds a outbound edge to this node.
Definition graphicsnode.cpp:582
QString m_numColor
Definition graphicsnode.h:148
bool m_hasNumberInside
Definition graphicsnode.h:152
int nodeNumber()
Definition graphicsnode.h:82
void deleteLabel()
Deletes the graphics label of this node.
Definition graphicsnode.cpp:629
int m_numberDistance
Definition graphicsnode.h:145
int m_size
Definition graphicsnode.h:141
Definition graphicswidget.h:42
static const int TypeNode
Definition graphicsnode.h:33
static const int ZValueNodeHighlighted
Definition graphicsnode.h:35
static const int ZValueNode
Definition graphicsnode.h:34