#include <graphicsedge.h>

+ Inheritance diagram for GraphicsEdge:
+ Collaboration diagram for GraphicsEdge:

Public Types

enum  { Type = UserType + 2 }
 

Public Slots

void adjust ()
 Leaves some empty space (offset) from node - make the edge weight appear on the centre of the edge. More...
 

Public Member Functions

 GraphicsEdge (GraphicsWidget *, GraphicsNode *, GraphicsNode *, const float &weight, const QString &label, const QString &color, const Qt::PenStyle &style, const int &type, const bool &drawArrows, const bool &bezier, const bool &weightNumbers=false, const bool &highlighting=true)
 
 ~GraphicsEdge ()
 
int type () const
 
GraphicsNodesourceNode () const
 
void setSourceNode (GraphicsNode *node)
 
GraphicsNodetargetNode () const
 
void setTargetNode (GraphicsNode *node)
 
int sourceNodeNumber ()
 
int targetNodeNumber ()
 
void setSourceNodeSize (const int &size)
 Called from graphicsNode to update edge offset from source node (i.e. when node size changes) More...
 
void setTargetNodeSize (const int &size)
 Called from graphicsNode to update edge offset from target node (i.e. when node size changes) More...
 
void setMinimumOffsetFromNode (const int &offset)
 Updates Minimum Offset From Node and calls adjust to update the edge. More...
 
void removeRefs ()
 
void setWeight (const float &w)
 Called from MW when user wants to change an edge's weight. Updates both the width and the weightNumber. More...
 
float weight () const
 Returns the weight/value of this edge. More...
 
void addWeightNumber ()
 
void setWeightNumberVisibility (const bool &toggle)
 Toggles visibility of weight numbers. More...
 
void setLabel (const QString &label)
 Called from MW when user wants to change an edge's label. More...
 
QString label () const
 
void addLabel ()
 
void setLabelVisibility (const bool &toggle)
 
void showArrows (const bool &)
 
void setDirectionType (const int &dirType=0)
 Changes the direction type of edge A -> B. More...
 
int directionType ()
 returns the direction type of this edge More...
 
float width () const
 Returns the width of the edge as a function of edge weight. More...
 
QPen pen () const
 GraphicsEdge::pen. More...
 
void setState (const int &state)
 GraphicsEdge::setState. More...
 
void setStyle (const Qt::PenStyle &style)
 
Qt::PenStyle style () const
 
void setColor (const QString &str)
 
QString color () const
 
QString colorToPajek ()
 Called from Graph::graphSaveToPajekFormat() More...
 
void setHighlighted (const bool &flag)
 Called from GraphicsNode to change the edge state and highlight it. This is done, when the user hovers over the node. More...
 
void setHighlighting (const bool &toggle)
 Toggles edge highlighting on or off. More...
 
QPainterPath shape () const
 Returns the shape of this edge as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions. The default implementation calls boundingRect() to return a simple rectangular shape, but we reimplement it to return a more accurate shape for non-rectangular items. More...
 

Protected Member Functions

QRectF boundingRect () const
 Defines the outer bounds of the edge as a rectangle; All painting will be restricted to inside the edge's bounding rect. Qt uses this bounding rect to determine whether the edge requires redrawing. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 GraphicsEdge::paint. More...
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 
void mousePressEvent (QGraphicsSceneMouseEvent *event)
 handles the events of a click on an edge More...
 

Private Attributes

GraphicsWidgetgraphicsWidget
 
GraphicsNodesource
 
GraphicsNodetarget
 
QPainterPath m_path
 
QPainterPath * m_path_up
 
QPainterPath * m_path_down
 
QPainterPath * m_path_shape
 
QPointF sourcePoint
 
QPointF targetPoint
 
qreal m_arrowSize
 
qreal m_minOffsetFromNode
 
qreal m_offsetFromTargetNode
 
qreal m_offsetFromSourceNode
 
Qt::PenStyle m_style
 
int m_state
 
GraphicsEdgeWeightweightNumber
 
GraphicsEdgeLabeledgeLabel
 
QString m_color
 
QString m_colorNegative
 
QString m_label
 
float m_weight
 
int tox1
 
int tox2
 
int toy1
 
int toy2
 
int size
 
int sourceOrigSize
 
int targetOrigSize
 
int m_edgeDirType
 
double rad
 
double theta
 
double theta1
 
double theta2
 
qreal angle
 
qreal line_length
 
qreal line_dx
 
qreal line_dy
 
bool m_Bezier
 
bool m_drawArrows
 
bool m_drawWeightNumber
 
bool m_drawLabel
 
bool m_hoverHighlighting
 
bool m_isClicked
 

Member Enumeration Documentation

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

GraphicsEdge::GraphicsEdge ( GraphicsWidget gw,
GraphicsNode from,
GraphicsNode to,
const float &  weight,
const QString &  label,
const QString &  color,
const Qt::PenStyle &  style,
const int &  type,
const bool &  drawArrows,
const bool &  bezier,
const bool &  weightNumbers = false,
const bool &  highlighting = true 
)
GraphicsEdge::~GraphicsEdge ( )

Member Function Documentation

void GraphicsEdge::addLabel ( )
void GraphicsEdge::addWeightNumber ( )
void GraphicsEdge::adjust ( )
slot

Leaves some empty space (offset) from node - make the edge weight appear on the centre of the edge.

QRectF GraphicsEdge::boundingRect ( ) const
protected

Defines the outer bounds of the edge as a rectangle; All painting will be restricted to inside the edge's bounding rect. Qt uses this bounding rect to determine whether the edge requires redrawing.

Returns
QString GraphicsEdge::color ( ) const
QString GraphicsEdge::colorToPajek ( )

Called from Graph::graphSaveToPajekFormat()

Returns
int GraphicsEdge::directionType ( )

returns the direction type of this edge

Returns
QVariant GraphicsEdge::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
protected
QString GraphicsEdge::label ( ) const
void GraphicsEdge::mousePressEvent ( QGraphicsSceneMouseEvent *  e)
protected

handles the events of a click on an edge

Parameters
event
void GraphicsEdge::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
protected

GraphicsEdge::paint.

Parameters
painter
option
QPen GraphicsEdge::pen ( ) const
void GraphicsEdge::removeRefs ( )
void GraphicsEdge::setColor ( const QString &  str)
void GraphicsEdge::setDirectionType ( const int &  dirType = 0)

Changes the direction type of edge A -> B.

void GraphicsEdge::setHighlighted ( const bool &  flag)

Called from GraphicsNode to change the edge state and highlight it. This is done, when the user hovers over the node.

Parameters
flag
void GraphicsEdge::setHighlighting ( const bool &  toggle)

Toggles edge highlighting on or off.

Parameters
toggle
void GraphicsEdge::setLabel ( const QString &  label)

Called from MW when user wants to change an edge's label.

Parameters
label
void GraphicsEdge::setLabelVisibility ( const bool &  toggle)
void GraphicsEdge::setMinimumOffsetFromNode ( const int &  offset)

Updates Minimum Offset From Node and calls adjust to update the edge.

Parameters
offset
void GraphicsEdge::setSourceNode ( GraphicsNode node)
void GraphicsEdge::setSourceNodeSize ( const int &  size)

Called from graphicsNode to update edge offset from source node (i.e. when node size changes)

Parameters
offset
void GraphicsEdge::setState ( const int &  state)

GraphicsEdge::setState.

Parameters
state
void GraphicsEdge::setStyle ( const Qt::PenStyle &  style)
void GraphicsEdge::setTargetNode ( GraphicsNode node)
void GraphicsEdge::setTargetNodeSize ( const int &  size)

Called from graphicsNode to update edge offset from target node (i.e. when node size changes)

Parameters
offset
void GraphicsEdge::setWeight ( const float &  w)

Called from MW when user wants to change an edge's weight. Updates both the width and the weightNumber.

Parameters
w
void GraphicsEdge::setWeightNumberVisibility ( const bool &  toggle)

Toggles visibility of weight numbers.

Parameters
toggle
QPainterPath GraphicsEdge::shape ( ) const

Returns the shape of this edge as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions. The default implementation calls boundingRect() to return a simple rectangular shape, but we reimplement it to return a more accurate shape for non-rectangular items.

Returns
QPainterPath
void GraphicsEdge::showArrows ( const bool &  drawArrows)
GraphicsNode * GraphicsEdge::sourceNode ( ) const
int GraphicsEdge::sourceNodeNumber ( )

Returns the source node number

Returns
int
Qt::PenStyle GraphicsEdge::style ( ) const
GraphicsNode * GraphicsEdge::targetNode ( ) const
int GraphicsEdge::targetNodeNumber ( )

Returns the target node number

Returns
int
int GraphicsEdge::type ( ) const
inline
float GraphicsEdge::weight ( ) const

Returns the weight/value of this edge.

Returns
float GraphicsEdge::width ( ) const

Returns the width of the edge as a function of edge weight.

Returns

Member Data Documentation

qreal GraphicsEdge::angle
private
GraphicsEdgeLabel* GraphicsEdge::edgeLabel
private
GraphicsWidget* GraphicsEdge::graphicsWidget
private
qreal GraphicsEdge::line_dx
private
qreal GraphicsEdge::line_dy
private
qreal GraphicsEdge::line_length
private
qreal GraphicsEdge::m_arrowSize
private
bool GraphicsEdge::m_Bezier
private
QString GraphicsEdge::m_color
private
QString GraphicsEdge::m_colorNegative
private
bool GraphicsEdge::m_drawArrows
private
bool GraphicsEdge::m_drawLabel
private
bool GraphicsEdge::m_drawWeightNumber
private
int GraphicsEdge::m_edgeDirType
private
bool GraphicsEdge::m_hoverHighlighting
private
bool GraphicsEdge::m_isClicked
private
QString GraphicsEdge::m_label
private
qreal GraphicsEdge::m_minOffsetFromNode
private
qreal GraphicsEdge::m_offsetFromSourceNode
private
qreal GraphicsEdge::m_offsetFromTargetNode
private
QPainterPath GraphicsEdge::m_path
private
QPainterPath * GraphicsEdge::m_path_down
private
QPainterPath * GraphicsEdge::m_path_shape
private
QPainterPath * GraphicsEdge::m_path_up
private
int GraphicsEdge::m_state
private
Qt::PenStyle GraphicsEdge::m_style
private
float GraphicsEdge::m_weight
private
double GraphicsEdge::rad
private
int GraphicsEdge::size
private
GraphicsNode* GraphicsEdge::source
private
int GraphicsEdge::sourceOrigSize
private
QPointF GraphicsEdge::sourcePoint
private
GraphicsNode * GraphicsEdge::target
private
int GraphicsEdge::targetOrigSize
private
QPointF GraphicsEdge::targetPoint
private
double GraphicsEdge::theta
private
double GraphicsEdge::theta1
private
double GraphicsEdge::theta2
private
int GraphicsEdge::tox1
private
int GraphicsEdge::tox2
private
int GraphicsEdge::toy1
private
int GraphicsEdge::toy2
private
GraphicsEdgeWeight* GraphicsEdge::weightNumber
private

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