#include <graphicsnode.h>

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

Public Types

enum  { Type = UserType + 1 }
 

Signals

void nodeClicked (GraphicsNode *)
 
void startEdge (GraphicsNode *)
 
void adjustOutEdge ()
 
void adjustInEdge ()
 
void removeOutEdge ()
 
void removeInEdge ()
 

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)
 
 ~GraphicsNode ()
 
int type () const
 
QRectF boundingRect () const
 Returns the bounding rectangle of the node: The rectangle where all painting will take place. More...
 
QPainterPath 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. More...
 
void 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() More...
 
int nodeNumber ()
 
void addInLink (GraphicsEdge *edge)
 GraphicsNode::addInLink Called from a new connected in-link to acknowloedge itself to this node. More...
 
void deleteInLink (GraphicsEdge *)
 
void addOutLink (GraphicsEdge *edge)
 
void deleteOutLink (GraphicsEdge *)
 
void setSize (const int &)
 
int size () const
 Returns the esoteric size of the node. Used by GraphicsEdge::GraphicsEdge() 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 in GraphicsNode::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. More...
 
QString nodeShape ()
 
void setColor (const QString &colorStr)
 Changes the color of the node. More...
 
void setColor (QColor color)
 Changes the color of the node (overloaded) Also used when the user searches for a node. More...
 
QString color ()
 
void addLabel ()
 
GraphicsNodeLabellabel ()
 
void deleteLabel ()
 
void setLabelVisibility (const bool &toggle)
 
void setLabelSize (const int &size)
 
void setLabelText (const QString &label)
 
void setLabelColor (const QString &color)
 
QString labelText ()
 GraphicsNode::labelText. More...
 
void setLabelDistance (const int &distance)
 GraphicsNode::setLabelDistance. More...
 
void addNumber ()
 
GraphicsNodeNumbernumber ()
 
void deleteNumber ()
 
void setNumberVisibility (const bool &toggle)
 
void setNumberInside (const bool &toggle)
 
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)
 ‍** handles the events of a click on a node *‍/ 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_size
 
int m_size_orig
 
int m_state
 
int m_numSize
 
int m_labelSize
 
int m_numberDistance
 
int m_labelDistance
 
int m_num
 
QString m_shape
 
QString m_iconPath
 
QString m_col_str
 
QString m_numColor
 
QString m_labelText
 
QString m_labelColor
 
QColor m_col
 
QColor m_col_orig
 
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 
)

◆ ~GraphicsNode()

GraphicsNode::~GraphicsNode ( )

Member Function Documentation

◆ addInLink()

void GraphicsNode::addInLink ( GraphicsEdge edge)

GraphicsNode::addInLink Called from a new connected in-link to acknowloedge itself to this node.

Parameters
edge

◆ addLabel()

void GraphicsNode::addLabel ( )

◆ addNumber()

void GraphicsNode::addNumber ( )

◆ addOutLink()

void GraphicsNode::addOutLink ( GraphicsEdge edge)

◆ adjustInEdge

void GraphicsNode::adjustInEdge ( )
signal

◆ adjustOutEdge

void GraphicsNode::adjustOutEdge ( )
signal

◆ boundingRect()

QRectF GraphicsNode::boundingRect ( ) const

Returns the bounding rectangle of the node: The rectangle where all painting will take place.

Returns

◆ color()

QString GraphicsNode::color ( )

◆ deleteInLink()

void GraphicsNode::deleteInLink ( GraphicsEdge link)

◆ deleteLabel()

void GraphicsNode::deleteLabel ( )

◆ deleteNumber()

void GraphicsNode::deleteNumber ( )

◆ deleteOutLink()

void GraphicsNode::deleteOutLink ( GraphicsEdge link)

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

◆ labelText()

QString GraphicsNode::labelText ( )

GraphicsNode::labelText.

Returns
QString

◆ nodeClicked

void GraphicsNode::nodeClicked ( GraphicsNode )
signal

◆ nodeNumber()

int GraphicsNode::nodeNumber ( )
inline

◆ nodeShape()

QString GraphicsNode::nodeShape ( )
inline

◆ number()

GraphicsNodeNumber * GraphicsNode::number ( )

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

◆ removeOutEdge

void GraphicsNode::removeOutEdge ( )
signal

◆ setColor() [1/2]

void GraphicsNode::setColor ( const QString &  colorStr)

Changes the color of the node.

Parameters
colorstring

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

‍** handles the events of a click on a node *‍/

‍** ‍**

◆ setLabelColor()

void GraphicsNode::setLabelColor ( const QString &  color)

◆ setLabelDistance()

void GraphicsNode::setLabelDistance ( const int &  distance)

GraphicsNode::setLabelDistance.

Parameters
distance

◆ setLabelSize()

void GraphicsNode::setLabelSize ( const int &  size)

◆ setLabelText()

void GraphicsNode::setLabelText ( const QString &  label)

◆ setLabelVisibility()

void GraphicsNode::setLabelVisibility ( const bool &  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)

◆ setNumberSize()

void GraphicsNode::setNumberSize ( const int &  size)

GraphicsNode::setNumberSize.

Parameters
size

◆ setNumberVisibility()

void GraphicsNode::setNumberVisibility ( const bool &  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 in GraphicsNode::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

◆ setSize()

void GraphicsNode::setSize ( const int &  size)

Sets the size of the node

◆ 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. Used by GraphicsEdge::GraphicsEdge()

Returns

◆ startEdge

void GraphicsNode::startEdge ( GraphicsNode )
signal

◆ 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_str

QString GraphicsNode::m_col_str
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: