Code Documentation 3.1
Social Network Visualizer
|
#include <graphicsnode.h>
Public Types | |
enum | { Type = UserType + 1 } |
Signals | |
void | nodeClicked (GraphicsNode *) |
Public Member Functions | |
GraphicsNode (GraphicsWidget *gw, const int &num, const int &size, const QString &color, const QString &shape, const QString &iconPath, const bool &showNumbers, const bool &numbersInside, const QString &numberColor, const int &numberSize, const int &numDistance, const bool &showLabels, const QString &label, const QString &labelColor, const int &labelSize, const int &labelDistance, const bool &edgeHighlighting, QPointF p) | |
Constructs a new node object (which is a graphics item) | |
~GraphicsNode () | |
int | type () const |
QRectF | boundingRect () const |
Returns the bounding rectangle of the node. | |
QPainterPath | shape () const |
Returns the shape of the node as a path in local coordinates. | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
Does the actual painting using the QPainterPath created by the setShape() | |
int | nodeNumber () |
void | addInEdge (GraphicsEdge *edge) |
Adds an inbound edge to this node. | |
void | removeInEdge (GraphicsEdge *) |
Removes the inbound edge from this node. | |
void | addOutEdge (GraphicsEdge *edge) |
Adds a outbound edge to this node. | |
void | removeOutEdge (GraphicsEdge *) |
Removes an outbound edge from this node. | |
void | setSize (const int &) |
Changes the size of the node. | |
int | size () const |
Returns the esoteric size of the node. | |
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 our painter (see paint()). | |
QString | nodeShape () |
void | setColor (const QString &colorName) |
Changes the color of the node. The new color name can be in one of these formats: | |
void | setColor (QColor color) |
Changes the color of the node (overloaded) | |
QString | color () |
Returns the node color in the format "#RRGGBB". | |
void | addLabel () |
Creates a graphics label to this node. | |
GraphicsNodeLabel * | label () |
Returns the graphics label of the node. | |
void | deleteLabel () |
Deletes the graphics label of this node. | |
void | setLabelVisibility (const bool &toggle) |
Toggles the visibiity of the node label. | |
void | setLabelSize (const int &size) |
Sets the size of the node label. | |
void | setLabelText (const QString &label) |
Sets the label of this node. | |
void | setLabelColor (const QString &color) |
Sets the color of the node label. | |
QString | labelText () |
Returns the label of the node. | |
void | setLabelDistance (const int &distance) |
Sets the distance of the label from the node. | |
void | addNumber () |
Adds a graphics number to the node. | |
GraphicsNodeNumber * | number () |
Returns the graphics node number. | |
void | deleteNumber () |
Deletes the graphics node number. | |
void | setNumberVisibility (const bool &toggle) |
Toggles the visibility of graphics node number. | |
void | setNumberInside (const bool &toggle) |
Toggles displaying node number inside the node. | |
void | setNumberSize (const int &size) |
GraphicsNode::setNumberSize. | |
void | setNumberDistance (const int &distance) |
GraphicsNode::setNumberDistance. | |
void | setNumberColor (const QString &color) |
GraphicsNode::setNumberColor. | |
void | setEdgeHighLighting (const bool &toggle) |
** | |
Protected Member Functions | |
QVariant | itemChange (GraphicsItemChange change, const QVariant &value) |
Called when the node changes, i.e. moves, becomes disabled or changes its visibility Propagates the changes to connected elements, i.e. edges, numbers, etc. Checks if the node is inside the scene. | |
Private Attributes | |
GraphicsWidget * | graphicsWidget |
QPainterPath | m_path |
QPointF | newPos |
QPolygonF * | m_poly_t |
int | m_num |
int | m_size |
int | m_size_orig |
int | m_state |
int | m_numSize |
int | m_labelSize |
int | m_numberDistance |
int | m_labelDistance |
QString | m_shape |
QString | m_iconPath |
QString | m_numColor |
QColor | m_col |
QColor | m_col_orig |
QColor | m_col_outline |
QString | m_labelText |
QString | m_labelColor |
bool | m_hasNumber |
bool | m_hasLabel |
bool | m_hasNumberInside |
bool | m_edgeHighLighting |
list< GraphicsEdge * > | inEdgeList |
list< GraphicsEdge * > | outEdgeList |
GraphicsNodeLabel * | m_label |
GraphicsNodeNumber * | m_number |
This is actually a container-class. Contains the graphical objects called Nodes, which are displayed as triangles, boxes, circles, etc, on the GraphicsWidget. Each node "knows" the others with which she is connected.
GraphicsNode::GraphicsNode | ( | GraphicsWidget * | gw, |
const int & | num, | ||
const int & | size, | ||
const QString & | color, | ||
const QString & | shape, | ||
const QString & | iconPath, | ||
const bool & | showNumbers, | ||
const bool & | numbersInside, | ||
const QString & | numberColor, | ||
const int & | numberSize, | ||
const int & | numDistance, | ||
const bool & | showLabels, | ||
const QString & | label, | ||
const QString & | labelColor, | ||
const int & | labelSize, | ||
const int & | labelDistance, | ||
const bool & | edgeHighlighting, | ||
QPointF | p | ||
) |
Constructs a new node object (which is a graphics item)
gw | |
num | |
size | |
color | |
shape | |
iconPath | |
showNumbers | |
numbersInside | |
numberColor | |
numberSize | |
numDistance | |
showLabels | |
label | |
labelColor | |
labelSize | |
labelDistance | |
edgeHighlighting | |
p |
GraphicsNode::~GraphicsNode | ( | ) |
void GraphicsNode::addInEdge | ( | GraphicsEdge * | edge | ) |
Adds an inbound edge to this node.
Called from a new connected in-link to acknowloedge itself to this node.
edge |
void GraphicsNode::addLabel | ( | ) |
Creates a graphics label to this node.
void GraphicsNode::addNumber | ( | ) |
Adds a graphics number to the node.
void GraphicsNode::addOutEdge | ( | GraphicsEdge * | edge | ) |
Adds a outbound edge to this node.
Called from the edge itself.
edge |
QRectF GraphicsNode::boundingRect | ( | ) | const |
Returns the bounding rectangle of the node.
The bounding rectangle is the area where all painting will take place.
QString GraphicsNode::color | ( | ) |
Returns the node color in the format "#RRGGBB".
void GraphicsNode::deleteLabel | ( | ) |
Deletes the graphics label of this node.
void GraphicsNode::deleteNumber | ( | ) |
Deletes the graphics node number.
|
protected |
Called when the node changes, i.e. moves, becomes disabled or changes its visibility Propagates the changes to connected elements, i.e. edges, numbers, etc. Checks if the node is inside the scene.
change | |
value |
GraphicsNodeLabel * GraphicsNode::label | ( | ) |
Returns the graphics label of the node.
QString GraphicsNode::labelText | ( | ) |
Returns the label of the node.
|
signal |
|
inline |
|
inline |
GraphicsNodeNumber * GraphicsNode::number | ( | ) |
Returns the graphics node number.
void GraphicsNode::paint | ( | QPainter * | painter, |
const QStyleOptionGraphicsItem * | option, | ||
QWidget * | widget | ||
) |
Does the actual painting using the QPainterPath created by the setShape()
Called by GraphicsView and GraphicsNode methods in every update()
painter | |
option |
void GraphicsNode::removeInEdge | ( | GraphicsEdge * | edge | ) |
Removes the inbound edge from this node.
link |
void GraphicsNode::removeOutEdge | ( | GraphicsEdge * | edge | ) |
Removes an outbound edge from this node.
edge |
void GraphicsNode::setColor | ( | const QString & | colorName | ) |
Changes the color of the node. The new color name can be in one of these formats:
colorStr |
void GraphicsNode::setColor | ( | QColor | color | ) |
Changes the color of the node (overloaded)
Also used when the user searches for a node
color |
void GraphicsNode::setEdgeHighLighting | ( | const bool & | toggle | ) |
**
**
void GraphicsNode::setLabelColor | ( | const QString & | color | ) |
Sets the color of the node label.
color |
void GraphicsNode::setLabelDistance | ( | const int & | distance | ) |
Sets the distance of the label from the node.
distance |
void GraphicsNode::setLabelSize | ( | const int & | size | ) |
Sets the size of the node label.
size |
void GraphicsNode::setLabelText | ( | const QString & | label | ) |
Sets the label of this node.
label |
void GraphicsNode::setLabelVisibility | ( | const bool & | toggle | ) |
Toggles the visibiity of the node label.
toggle |
void GraphicsNode::setNumberColor | ( | const QString & | color | ) |
color |
void GraphicsNode::setNumberDistance | ( | const int & | distance | ) |
GraphicsNode::setNumberDistance.
distance |
void GraphicsNode::setNumberInside | ( | const bool & | toggle | ) |
Toggles displaying node number inside the node.
toggle |
void GraphicsNode::setNumberSize | ( | const int & | size | ) |
size |
void GraphicsNode::setNumberVisibility | ( | const bool & | toggle | ) |
Toggles the visibility of graphics node number.
toggle |
void GraphicsNode::setShape | ( | const QString | shape, |
const QString & | iconPath = QString() |
||
) |
Sets the shape of the node and prepares the corresponding QPainterPath m_path which will be drawn by our painter (see paint()).
The only exception is when the shape is 'custom'. In that case, the painter will paint a pixmap with the custom node icon (loaded from iconPath). However, even in that case we are still creating a QPainterPath, because this is needed by QGraphicsNode::shape() function which is responsible for collision detection and needs to return a path with an accurate outline of the item's shape. Called every time the user needs to change the shape of an node.
shape | |
iconPath |
void GraphicsNode::setSize | ( | const int & | size | ) |
Changes the size of the node.
size |
QPainterPath GraphicsNode::shape | ( | ) | const |
Returns the shape of the node as a path in local coordinates.
The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions. We could ommit reimplementing this and have the default QGraphicsItem::shape() return a simple rectangular shape through boundingRect() but we opt to return an accurate outline of the item's shape.
int GraphicsNode::size | ( | ) | const |
Returns the esoteric size of the node.
|
inline |
|
private |
|
private |
Lists of elements attached to this node
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |