TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes
Tinkercell::ConnectionGraphicsItem Class Reference

A graphics nodes item that draws connection between two or more nodes and the arrow heads at the ends. More...

#include <ConnectionGraphicsItem.h>

Collaboration diagram for Tinkercell::ConnectionGraphicsItem:
Collaboration graph
[legend]

List of all members.

Classes

class  ControlPoint
 A control point with a pointer to a ConnectionGraphicsItem. More...
class  CurveSegment
 A set of control points and two arrow heads. More...

Public Types

enum  LineType { line, bezier }
 line or beizier More...
enum  { Type = UserType + 5 }
 for enabling dynamic_cast More...

Public Member Functions

 ConnectionGraphicsItem (QGraphicsItem *parent=0)
 ConnectionGraphicsItem (const QList< NodeGraphicsItem * > &, const QList< NodeGraphicsItem * > &, QGraphicsItem *parent=0)
 ConnectionGraphicsItem (const ConnectionGraphicsItem &copy)
virtual ConnectionGraphicsItemoperator= (const ConnectionGraphicsItem &copy)
virtual ConnectionGraphicsItemcopyPoints (const ConnectionGraphicsItem &copy)
virtual ConnectionGraphicsItemclone () const
 make a copy of this connection item
virtual bool isValid ()
 returns the bounding rectangle for this reaction figure
virtual ItemHandlehandle () const
 get the handle of this connection
virtual void setHandle (ItemHandle *)
 set the handle of this connection
virtual QList< ControlPoint * > controlPoints (bool includeEnds=false) const
 list of pointers to all the control points
virtual QList< QGraphicsItem * > controlPointsAsGraphicsItems (bool includeEnds=false) const
 list of pointers to all the control points
virtual QPainterPath shape () const
 gets a path that represents this reaction
virtual void setPath (const QPainterPath &path)
 set the path for this connection
virtual void clear (bool all=false)
 Clear all shapes and control points.
virtual void refresh (bool arrows=true)
 refresh the path if any controlpoints have moved
virtual void setPen (QPen pen, bool permanently=false)
 set the color and line width for drawing this connection
virtual QPen pen () const
 get the pen currently being used to draw this connection
virtual void setControlPointsVisible (bool visible=true)
 set visibility of control points
void showControlPoints ()
 show control points. same as setControlPointsVisible(true)
void hideControlPoints ()
 hide control points. same as setControlPointsVisible(false)
virtual bool isModifier () const
 check is this connection represents a modifier, i.e. points to the centerRegion of another connection
virtual QList< NodeGraphicsItem * > nodes () const
 get all nodes that are connected
virtual QList< NodeGraphicsItem * > nodesWithArrows () const
 get all nodes that have an arrow pointing to them
virtual QList< NodeGraphicsItem * > nodesWithoutArrows () const
 get all nodes that do NOT have an arrow pointing to them
virtual QList< NodeGraphicsItem * > nodesDisconnected () const
 get all nodes that are not directle connected to the main connection, such as modifier nodes
virtual QList< QGraphicsItem * > nodesAsGraphicsItems () const
 get all nodes that are connected
virtual QList< ArrowHeadItem * > arrowHeads () const
 get all the arrowHeads associated with the nodes. The order is the same order as nodes(), so values can be 0
virtual QList< QGraphicsItem * > arrowHeadsAsGraphicsItems () const
 get all the arrowHeads associated with the nodes The order is the same order as nodes(), so values can be 0
virtual QList< ArrowHeadItem * > modifierArrowHeads () const
 get all the arrowHeads NOT associated with the nodes
virtual NodeGraphicsItemnodeAt (int index) const
 get the node that connected to the particular path
virtual int indexOf (QGraphicsItem *node) const
 get the index of the node
virtual void replaceNodeAt (int, NodeGraphicsItem *)
 replace the node at the particular position with a new node
virtual void replaceNode (NodeGraphicsItem *, NodeGraphicsItem *)
 replace one node in the reaction with another
virtual ArrowHeadItemarrowAt (int index) const
 get the arrow head at the particular index
virtual ArrowHeadItemmodifierArrowAt (int index) const
 get the modifier arrow head at the particular index
virtual ~ConnectionGraphicsItem ()
virtual qreal slopeAtPoint (const QPointF &point)
 get slope at the given point (or closest point)
virtual ControlPointcenterPoint () const
 the center point (if one exists)
virtual QPointF centerLocation () const
 the center point (if one exists)
virtual QRectF boundingRect () const
 bounding rect
virtual QRectF sceneBoundingRect () const
 scene bounding rect
virtual int type () const
 for enabling dynamic_cast

Static Public Member Functions

static ConnectionGraphicsItemcast (QGraphicsItem *)
 cast a graphics item to a connection graphics item using qgraphicsitem_cast
static QList
< ConnectionGraphicsItem * > 
cast (const QList< QGraphicsItem * > &)
 cast a list of graphics item to a list of connection graphics items using qgraphicsitem_cast
static ConnectionGraphicsItemtopLevelConnectionItem (QGraphicsItem *item, bool includeControlPoints=false)
 gets the connection graphics item from its child item

Public Attributes

QString name
 just a name used identifying the connection
QString className
 used for checking type before static casts
QPen defaultPen
 permanent pen for this control point
QString groupID
 for identifying which scene this item belongs in
LineType lineType
 type of line for this reaction - line or beizier
QList< CurveSegmentcurveSegments
 vector of vector of control point
qreal arrowHeadDistance
 distance from arrow head to the item that it is connected to
bool controlPointsVisible
 indicates whether to show lines around the curves
QSizeF centerRegion
 a rectangle that sits at the center of the connector
ArrowHeadItemcenterRegionItem
 the image on the rectangle that sits at the center of the connector

Static Public Attributes

static const QString CLASSNAME = QString("ConnectionGraphicsItem")
 used for checking type before static casts
static QString DefaultMiddleItemFile
 used to initialize the middle item for a connection
static QString DefaultArrowHeadFile
 used to initialize the arrow heads for a connection
static const int numLineTypes = 2
 number of different type of shapes available

Protected Member Functions

virtual void refreshBoundaryPath ()
 update the boundary path
virtual void adjustEndPoints (bool arrows=true)
 adjust the end control points so that they point straight

Protected Attributes

ItemHandleitemHandle
 Tinkercell object that this drawable belongs in.
QGraphicsPathItem * boundaryPathItem
 path for drawing the boundary region
QGraphicsPathItem * outerPathItem
 path of the outline (usually white)
QGraphicsPathItem * mainPathItem
 path of the main curve
QPainterPath pathShape
 path of the selection region of the entire connection
QRectF pathBoundingRect
 the boundary rectangle for this path. It is recomputed during each refresh.

Detailed Description

A graphics nodes item that draws connection between two or more nodes and the arrow heads at the ends.

Definition at line 99 of file ConnectionGraphicsItem.h.


Member Enumeration Documentation

anonymous enum

for enabling dynamic_cast

Enumerator:
Type 

Definition at line 326 of file ConnectionGraphicsItem.h.

line or beizier

Enumerator:
line 
bezier 

Definition at line 155 of file ConnectionGraphicsItem.h.


Constructor & Destructor Documentation

Tinkercell::ConnectionGraphicsItem::ConnectionGraphicsItem ( QGraphicsItem *  parent = 0)

Constructor: does nothing

Constructor: initialize everything

Definition at line 150 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

Tinkercell::ConnectionGraphicsItem::ConnectionGraphicsItem ( const QList< NodeGraphicsItem * > &  from,
const QList< NodeGraphicsItem * > &  to,
QGraphicsItem *  parent = 0 
)

Constructor: constructs linear curve segments with arrow heads on the second set of nodes

Parameters:
QList<NodeGraphicsItem*>list of nodes to connect from (no arrow heads)
QList<NodeGraphicsItem*>list of nodes to connect to (have arrow heads)

Definition at line 1924 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Tinkercell::ConnectionGraphicsItem::ConnectionGraphicsItem ( const ConnectionGraphicsItem copy)

Copy Constructor: copies handle but not control points

Copy Constructor: deep copy of all pointers

Definition at line 192 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Tinkercell::ConnectionGraphicsItem::~ConnectionGraphicsItem ( ) [virtual]

Destructor: deletes all control points

Destructor: deletes all shapes and control points

Definition at line 485 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:


Member Function Documentation

void Tinkercell::ConnectionGraphicsItem::adjustEndPoints ( bool  arrowTransform = true) [protected, virtual]

adjust the end control points so that they point straight

Parameters:
booladjust arrow transformations
void
Returns:
void

Definition at line 653 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

ArrowHeadItem * Tinkercell::ConnectionGraphicsItem::arrowAt ( int  index) const [virtual]

get the arrow head at the particular index

find the arrow head at the particular index

Parameters:
indexless than size of curveSegments
Returns:
node item or 0

Definition at line 1662 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< ArrowHeadItem * > Tinkercell::ConnectionGraphicsItem::arrowHeads ( ) const [virtual]

get all the arrowHeads associated with the nodes. The order is the same order as nodes(), so values can be 0

get all the arrow heads in the same order as nodes

Returns:
node item list

Definition at line 1511 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< QGraphicsItem * > Tinkercell::ConnectionGraphicsItem::arrowHeadsAsGraphicsItems ( ) const [virtual]

get all the arrowHeads associated with the nodes The order is the same order as nodes(), so values can be 0

get all the arrow heads in the same order as nodes

Returns:
arrow item list
node item list

Definition at line 1535 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QRectF Tinkercell::ConnectionGraphicsItem::boundingRect ( ) const [virtual]

bounding rect

Definition at line 1296 of file ConnectionGraphicsItem.cpp.

QList< ConnectionGraphicsItem * > Tinkercell::ConnectionGraphicsItem::cast ( const QList< QGraphicsItem * > &  list) [static]

cast a list of graphics item to a list of connection graphics items using qgraphicsitem_cast

Parameters:
QList<QGraphicsItem*>graphics items
Returns:
QList<ConnectionGraphicsItem*> can be empty if no cast is invalid

Definition at line 1913 of file ConnectionGraphicsItem.cpp.

ConnectionGraphicsItem * Tinkercell::ConnectionGraphicsItem::cast ( QGraphicsItem *  q) [static]

cast a graphics item to a connection graphics item using qgraphicsitem_cast

Parameters:
QGraphicsItem*graphics item
Returns:
ConnectionGraphicsItem* can be 0 if the cast is invalid

Definition at line 1906 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QPointF Tinkercell::ConnectionGraphicsItem::centerLocation ( ) const [virtual]

the center point (if one exists)

the center location

Definition at line 604 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

ConnectionGraphicsItem::ControlPoint * Tinkercell::ConnectionGraphicsItem::centerPoint ( ) const [virtual]

the center point (if one exists)

Definition at line 585 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::clear ( bool  all = false) [virtual]

Clear all shapes and control points.

Parameters:
void
Returns:
void

Definition at line 1162 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

ConnectionGraphicsItem * Tinkercell::ConnectionGraphicsItem::clone ( ) const [virtual]

make a copy of this connection item

make a copy of this item

Definition at line 308 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< ConnectionGraphicsItem::ControlPoint * > Tinkercell::ConnectionGraphicsItem::controlPoints ( bool  includeEnds = false) const [virtual]

list of pointers to all the control points

Definition at line 1308 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

QList< QGraphicsItem * > Tinkercell::ConnectionGraphicsItem::controlPointsAsGraphicsItems ( bool  includeEnds = false) const [virtual]

list of pointers to all the control points

Definition at line 1322 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

ConnectionGraphicsItem & Tinkercell::ConnectionGraphicsItem::copyPoints ( const ConnectionGraphicsItem copy) [virtual]

operator =: copy just the control point positions and pen

Definition at line 464 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

ItemHandle * Tinkercell::ConnectionGraphicsItem::handle ( ) const [virtual]

get the handle of this connection

Definition at line 33 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::hideControlPoints ( )

hide control points. same as setControlPointsVisible(false)

Returns:
void

Definition at line 1290 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

int Tinkercell::ConnectionGraphicsItem::indexOf ( QGraphicsItem *  target) const [virtual]

get the index of the node

find the index of the node

Parameters:
nodein this connection
Returns:
index, -1 if node not found

Definition at line 1621 of file ConnectionGraphicsItem.cpp.

bool Tinkercell::ConnectionGraphicsItem::isModifier ( ) const [virtual]

check is this connection represents a modifier, i.e. points to the centerRegion of another connection

Returns:
boolean

Definition at line 1365 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Tinkercell::ConnectionGraphicsItem::isValid ( ) [virtual]

returns the bounding rectangle for this reaction figure

checks that this is a valid drawable

paint method. Call's parent's after drawing boundary true

checks that this is a valid drawable

Definition at line 493 of file ConnectionGraphicsItem.cpp.

ArrowHeadItem * Tinkercell::ConnectionGraphicsItem::modifierArrowAt ( int  index) const [virtual]

get the modifier arrow head at the particular index

find the modifier arrow head at the particular index

Parameters:
indexless than size of curveSegments
Returns:
node item or 0

Definition at line 1710 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

QList< ArrowHeadItem * > Tinkercell::ConnectionGraphicsItem::modifierArrowHeads ( ) const [virtual]

get all the arrowHeads NOT associated with the nodes

find all the modifier arrow heads in the same order as nodes

Returns:
graphics item list
node item list

Definition at line 1559 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

NodeGraphicsItem * Tinkercell::ConnectionGraphicsItem::nodeAt ( int  index) const [virtual]

get the node that connected to the particular path

find the node that connected to the particular path

Parameters:
indexless than size of curveSegments
Returns:
node item or 0

Definition at line 1584 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< NodeGraphicsItem * > Tinkercell::ConnectionGraphicsItem::nodes ( ) const [virtual]

get all nodes that are connected

find all the nodes that are connected

Returns:
node item list
node item list or 0

Definition at line 1394 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< QGraphicsItem * > Tinkercell::ConnectionGraphicsItem::nodesAsGraphicsItems ( ) const [virtual]

get all nodes that are connected

find all the nodes that are connected

Returns:
graphics item list
node item list or 0

Definition at line 1487 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

QList< NodeGraphicsItem * > Tinkercell::ConnectionGraphicsItem::nodesDisconnected ( ) const [virtual]

get all nodes that are not directle connected to the main connection, such as modifier nodes

find all the nodes that are connected

Returns:
node item list
node item list or 0

Definition at line 1467 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< NodeGraphicsItem * > Tinkercell::ConnectionGraphicsItem::nodesWithArrows ( ) const [virtual]

get all nodes that have an arrow pointing to them

find all the nodes that are connected

Returns:
node item list
node item list or 0

Definition at line 1419 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QList< NodeGraphicsItem * > Tinkercell::ConnectionGraphicsItem::nodesWithoutArrows ( ) const [virtual]

get all nodes that do NOT have an arrow pointing to them

find all the nodes that are connected

Returns:
node item list
node item list or 0

Definition at line 1443 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

ConnectionGraphicsItem & Tinkercell::ConnectionGraphicsItem::operator= ( const ConnectionGraphicsItem copy) [virtual]

operator =: remove everything from original connection and copy everything from the given connection

operator =: copy just the control point positions and pen

Definition at line 316 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

QPen Tinkercell::ConnectionGraphicsItem::pen ( ) const [virtual]

get the pen currently being used to draw this connection

Returns:
QPen pen

Definition at line 426 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::refresh ( bool  arrowTransform = true) [virtual]

refresh the path if any controlpoints have moved

Parameters:
booltranform arrow heads
Returns:
void
Parameters:
void
Returns:
void

Definition at line 945 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::refreshBoundaryPath ( ) [protected, virtual]

update the boundary path

Definition at line 1133 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::replaceNode ( NodeGraphicsItem oldNode,
NodeGraphicsItem newNode 
) [virtual]

replace one node in the reaction with another

Parameters:
targetnode to replace
newnode
Returns:
void

Definition at line 1720 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::replaceNodeAt ( int  index,
NodeGraphicsItem nodeItem 
) [virtual]

replace the node at the particular position with a new node

Parameters:
indexwhere to insert the new node
newnode
Returns:
void

Definition at line 1736 of file ConnectionGraphicsItem.cpp.

QRectF Tinkercell::ConnectionGraphicsItem::sceneBoundingRect ( ) const [virtual]

scene bounding rect

Definition at line 1302 of file ConnectionGraphicsItem.cpp.

void Tinkercell::ConnectionGraphicsItem::setControlPointsVisible ( bool  visible = true) [virtual]

set visibility of control points

Parameters:
visible= true, invisible = false
Returns:
void

Definition at line 1248 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::setHandle ( ItemHandle handle) [virtual]

set the handle of this connection

Definition at line 38 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::setPath ( const QPainterPath &  path) [virtual]

set the path for this connection

Parameters:
QPainterPathpath
Returns:
void

Definition at line 442 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ConnectionGraphicsItem::setPen ( QPen  pen,
bool  permanently = false 
) [virtual]

set the color and line width for drawing this connection

Parameters:
QPenpen
boolalso set the default pen?
Returns:
void

Definition at line 434 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QPainterPath Tinkercell::ConnectionGraphicsItem::shape ( ) const [virtual]

gets a path that represents this reaction

gets a path that is constructed by uniting all the shape paths

Definition at line 579 of file ConnectionGraphicsItem.cpp.

void Tinkercell::ConnectionGraphicsItem::showControlPoints ( )

show control points. same as setControlPointsVisible(true)

Returns:
void

Definition at line 1285 of file ConnectionGraphicsItem.cpp.

Here is the call graph for this function:

qreal Tinkercell::ConnectionGraphicsItem::slopeAtPoint ( const QPointF &  point) [virtual]

get slope at the given point (or closest point)

find slope at the given point (or closest point)

Definition at line 1224 of file ConnectionGraphicsItem.cpp.

ConnectionGraphicsItem * Tinkercell::ConnectionGraphicsItem::topLevelConnectionItem ( QGraphicsItem *  item,
bool  includeControlPoints = false 
) [static]

gets the connection graphics item from its child item

Parameters:
QGraphicsItem*the target item
boolusing true here will return the connection item for a control point, otherwise control points are ignored

Definition at line 1337 of file ConnectionGraphicsItem.cpp.

Here is the caller graph for this function:

virtual int Tinkercell::ConnectionGraphicsItem::type ( ) const [inline, virtual]

for enabling dynamic_cast

Definition at line 328 of file ConnectionGraphicsItem.h.


Member Data Documentation

distance from arrow head to the item that it is connected to

Definition at line 217 of file ConnectionGraphicsItem.h.

path for drawing the boundary region

Definition at line 337 of file ConnectionGraphicsItem.h.

a rectangle that sits at the center of the connector

Definition at line 318 of file ConnectionGraphicsItem.h.

the image on the rectangle that sits at the center of the connector

Definition at line 320 of file ConnectionGraphicsItem.h.

const QString Tinkercell::ConnectionGraphicsItem::CLASSNAME = QString("ConnectionGraphicsItem") [static]

used for checking type before static casts

Definition at line 113 of file ConnectionGraphicsItem.h.

used for checking type before static casts

Definition at line 121 of file ConnectionGraphicsItem.h.

indicates whether to show lines around the curves

Definition at line 312 of file ConnectionGraphicsItem.h.

vector of vector of control point

Definition at line 215 of file ConnectionGraphicsItem.h.

used to initialize the arrow heads for a connection

Definition at line 117 of file ConnectionGraphicsItem.h.

used to initialize the middle item for a connection

Definition at line 115 of file ConnectionGraphicsItem.h.

permanent pen for this control point

Definition at line 123 of file ConnectionGraphicsItem.h.

for identifying which scene this item belongs in

Definition at line 153 of file ConnectionGraphicsItem.h.

Tinkercell object that this drawable belongs in.

Definition at line 335 of file ConnectionGraphicsItem.h.

type of line for this reaction - line or beizier

Definition at line 158 of file ConnectionGraphicsItem.h.

QGraphicsPathItem* Tinkercell::ConnectionGraphicsItem::mainPathItem [protected]

path of the main curve

Definition at line 341 of file ConnectionGraphicsItem.h.

just a name used identifying the connection

Definition at line 119 of file ConnectionGraphicsItem.h.

number of different type of shapes available

Definition at line 151 of file ConnectionGraphicsItem.h.

QGraphicsPathItem* Tinkercell::ConnectionGraphicsItem::outerPathItem [protected]

path of the outline (usually white)

Definition at line 339 of file ConnectionGraphicsItem.h.

the boundary rectangle for this path. It is recomputed during each refresh.

Definition at line 345 of file ConnectionGraphicsItem.h.

path of the selection region of the entire connection

Definition at line 343 of file ConnectionGraphicsItem.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines