#include <graphicsnode.h>

+ Inheritance diagram for GraphicsNode:
+ Collaboration diagram for GraphicsNode:

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) More...
 
 ~GraphicsNode ()
 
int type () const
 
QRectF boundingRect () const
 Returns the bounding rectangle of the node. More...
 
QPainterPath shape () const
 Returns the shape of the node as a path in local coordinates. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Does the actual painting using the QPainterPath created by the setShape() More...
 
int nodeNumber ()
 
void addInEdge (GraphicsEdge *edge)
 Adds an inbound edge to this node. More...
 
void removeInEdge (GraphicsEdge *)
 Removes the inbound edge from this node. More...
 
void addOutEdge (GraphicsEdge *edge)
 Adds a outbound edge to this node. More...
 
void removeOutEdge (GraphicsEdge *)
 Removes an outbound edge from this node. More...
 
void setSize (const int &)
 Changes the size of the node. More...
 
int size () const
 Returns the esoteric size of the node. More...
 
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()). More...
 
QString nodeShape ()
 
void setColor (const QString &colorName)
 Changes the color of the node. The new color name can be in one of these formats: More...
 
void setColor (QColor color)
 Changes the color of the node (overloaded) More...
 
QString color ()
 Returns the node color in the format "#RRGGBB". More...
 
void addLabel ()
 Creates a graphics label to this node. More...
 
GraphicsNodeLabellabel ()
 Returns the graphics label of the node. More...
 
void deleteLabel ()
 Deletes the graphics label of this node. More...
 
void setLabelVisibility (const bool &toggle)
 Toggles the visibiity of the node label. More...
 
void setLabelSize (const int &size)
 Sets the size of the node label. More...
 
void setLabelText (const QString &label)
 Sets the label of this node. More...
 
void setLabelColor (const QString &color)
 Sets the color of the node label. More...
 
QString labelText ()
 Returns the label of the node. More...
 
void setLabelDistance (const int &distance)
 Sets the distance of the label from the node. More...
 
void addNumber ()
 Adds a graphics number to the node. More...
 
GraphicsNodeNumbernumber ()
 Returns the graphics node number. More...
 
void deleteNumber ()
 Deletes the graphics node number. More...
 
void setNumberVisibility (const bool &toggle)
 Toggles the visibility of graphics node number. More...
 
void setNumberInside (const bool &toggle)
 Toggles displaying node number inside the node. More...
 
void setNumberSize (const int &size)
 GraphicsNode::setNumberSize. More...
 
void setNumberDistance (const int &distance)
 GraphicsNode::setNumberDistance. More...
 
void setNumberColor (const QString &color)
 GraphicsNode::setNumberColor. More...
 
void setEdgeHighLighting (const bool &toggle)
 ‍** More...
 

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. More...
 

Private Attributes

GraphicsWidgetgraphicsWidget
 
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
 
GraphicsNodeLabelm_label
 
GraphicsNodeNumberm_number
 

Detailed Description

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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

◆ GraphicsNode()

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)

Parameters
gw
num
size
color
shape
iconPath
showNumbers
numbersInside
numberColor
numberSize
numDistance
showLabels
label
labelColor
labelSize
labelDistance
edgeHighlighting
p

◆ ~GraphicsNode()

GraphicsNode::~GraphicsNode ( )

Member Function Documentation

◆ addInEdge()

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.

Parameters
edge

◆ addLabel()

void GraphicsNode::addLabel ( )

Creates a graphics label to this node.

◆ addNumber()

void GraphicsNode::addNumber ( )

Adds a graphics number to the node.

◆ addOutEdge()

void GraphicsNode::addOutEdge ( GraphicsEdge edge)

Adds a outbound edge to this node.

Called from the edge itself.

Parameters
edge

◆ boundingRect()

QRectF GraphicsNode::boundingRect ( ) const

Returns the bounding rectangle of the node.

The bounding rectangle is the area where all painting will take place.

Returns

◆ color()

QString GraphicsNode::color ( )

Returns the node color in the format "#RRGGBB".

Returns
QString

◆ deleteLabel()

void GraphicsNode::deleteLabel ( )

Deletes the graphics label of this node.

◆ deleteNumber()

void GraphicsNode::deleteNumber ( )

Deletes the graphics node number.

◆ itemChange()

QVariant GraphicsNode::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
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.

Parameters
change
value
Returns

◆ label()

GraphicsNodeLabel * GraphicsNode::label ( )

Returns the graphics label of the node.

Returns

◆ labelText()

QString GraphicsNode::labelText ( )

Returns the label of the node.

Returns
QString

◆ nodeClicked

void GraphicsNode::nodeClicked ( GraphicsNode )
signal

◆ nodeNumber()

int GraphicsNode::nodeNumber ( )
inline

◆ nodeShape()

QString GraphicsNode::nodeShape ( )
inline

◆ number()

GraphicsNodeNumber * GraphicsNode::number ( )

Returns the graphics node number.

Returns

◆ paint()

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()

Parameters
painter
option

◆ removeInEdge()

void GraphicsNode::removeInEdge ( GraphicsEdge edge)

Removes the inbound edge from this node.

Parameters
link

◆ removeOutEdge()

void GraphicsNode::removeOutEdge ( GraphicsEdge edge)

Removes an outbound edge from this node.

Parameters
edge

◆ setColor() [1/2]

void GraphicsNode::setColor ( const QString &  colorName)

Changes the color of the node. The new color name can be in one of these formats:

  • #RGB (each of R, G, and B is a single hex digit)
  • #RRGGBB
  • #AARRGGBB (Since 5.2)
  • #RRRGGGBBB
  • #RRRRGGGGBBBB
  • A name from the list of colors defined in the list of SVG color keyword names provided by the WWW Consortium; for example, "steelblue" or "gainsboro". These color names work on all platforms. Note that these color names are not the same as defined by the Qt::GlobalColor enums, e.g. "green" and Qt::green does not refer to the same color.
  • transparent - representing the absence of a color.
Parameters
colorStr

◆ setColor() [2/2]

void GraphicsNode::setColor ( QColor  color)

Changes the color of the node (overloaded)

Also used when the user searches for a node

Parameters
color

◆ setEdgeHighLighting()

void GraphicsNode::setEdgeHighLighting ( const bool &  toggle)

‍**

‍**

◆ setLabelColor()

void GraphicsNode::setLabelColor ( const QString &  color)

Sets the color of the node label.

Parameters
color

◆ setLabelDistance()

void GraphicsNode::setLabelDistance ( const int &  distance)

Sets the distance of the label from the node.

Parameters
distance

◆ setLabelSize()

void GraphicsNode::setLabelSize ( const int &  size)

Sets the size of the node label.

Parameters
size

◆ setLabelText()

void GraphicsNode::setLabelText ( const QString &  label)

Sets the label of this node.

Parameters
label

◆ setLabelVisibility()

void GraphicsNode::setLabelVisibility ( const bool &  toggle)

Toggles the visibiity of the node label.

Parameters
toggle

◆ setNumberColor()

void GraphicsNode::setNumberColor ( const QString &  color)

GraphicsNode::setNumberColor.

Parameters
color

◆ setNumberDistance()

void GraphicsNode::setNumberDistance ( const int &  distance)

GraphicsNode::setNumberDistance.

Parameters
distance

◆ setNumberInside()

void GraphicsNode::setNumberInside ( const bool &  toggle)

Toggles displaying node number inside the node.

Parameters
toggle

◆ setNumberSize()

void GraphicsNode::setNumberSize ( const int &  size)

GraphicsNode::setNumberSize.

Parameters
size

◆ setNumberVisibility()

void GraphicsNode::setNumberVisibility ( const bool &  toggle)

Toggles the visibility of graphics node number.

Parameters
toggle

◆ setShape()

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.

Parameters
shape
iconPath

◆ setSize()

void GraphicsNode::setSize ( const int &  size)

Changes the size of the node.

Parameters
size

◆ shape()

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.

Returns

◆ size()

int GraphicsNode::size ( ) const

Returns the esoteric size of the node.

Returns

◆ type()

int GraphicsNode::type ( ) const
inline

Member Data Documentation

◆ graphicsWidget

GraphicsWidget* GraphicsNode::graphicsWidget
private

◆ inEdgeList

list<GraphicsEdge*> GraphicsNode::inEdgeList
private

Lists of elements attached to this node

◆ m_col

QColor GraphicsNode::m_col
private

◆ m_col_orig

QColor GraphicsNode::m_col_orig
private

◆ m_col_outline

QColor GraphicsNode::m_col_outline
private

◆ m_edgeHighLighting

bool GraphicsNode::m_edgeHighLighting
private

◆ m_hasLabel

bool GraphicsNode::m_hasLabel
private

◆ m_hasNumber

bool GraphicsNode::m_hasNumber
private

◆ m_hasNumberInside

bool GraphicsNode::m_hasNumberInside
private

◆ m_iconPath

QString GraphicsNode::m_iconPath
private

◆ m_label

GraphicsNodeLabel* GraphicsNode::m_label
private

◆ m_labelColor

QString GraphicsNode::m_labelColor
private

◆ m_labelDistance

int GraphicsNode::m_labelDistance
private

◆ m_labelSize

int GraphicsNode::m_labelSize
private

◆ m_labelText

QString GraphicsNode::m_labelText
private

◆ m_num

int GraphicsNode::m_num
private

◆ m_number

GraphicsNodeNumber* GraphicsNode::m_number
private

◆ m_numberDistance

int GraphicsNode::m_numberDistance
private

◆ m_numColor

QString GraphicsNode::m_numColor
private

◆ m_numSize

int GraphicsNode::m_numSize
private

◆ m_path

QPainterPath GraphicsNode::m_path
private

◆ m_poly_t

QPolygonF* GraphicsNode::m_poly_t
private

◆ m_shape

QString GraphicsNode::m_shape
private

◆ m_size

int GraphicsNode::m_size
private

◆ m_size_orig

int GraphicsNode::m_size_orig
private

◆ m_state

int GraphicsNode::m_state
private

◆ newPos

QPointF GraphicsNode::newPos
private

◆ outEdgeList

list<GraphicsEdge*> GraphicsNode::outEdgeList
private

The documentation for this class was generated from the following files: