Adaptagrams
Public Member Functions | Static Public Member Functions | List of all members
dialect::Edge Class Reference

The Edge class represents edges in a graph. More...

#include <graphs.h>

Collaboration diagram for dialect::Edge:
Collaboration graph

Public Member Functions

Edgeoperator= (const dialect::Edge &)=default
 Copy-assignment operator.
 
 ~Edge (void)=default
 Destructor.
 
id_type id (void) const
 Access the unique ID of this instance. More...
 
Node_SP getOtherEnd (const dialect::Node &end1) const
 Get the opposite endpt, from a given one. More...
 
Node_SP getSourceEnd (void) const
 Get read-only access to the Node at the source end of this Edge.
 
Node_SP getTargetEnd (void) const
 Get read-only access to the Node at the target end of this Edge.
 
std::pair< id_type, id_type > getEndIds (void) const
 Get a pair {srcID, tgtID} giving the IDs of the source and target Nodes.
 
void setGraph (Graph &graph)
 Tell the Edge which Graph it belongs to. More...
 
void sever (void)
 "Sever" this Edge, i.e. remove it from the Nodes to which it is attached.
 
BoundingBox getBoundingBox (void) const
 Get the bounding box for the edge, including its end points and route points.
 
void addRoutePoint (double x, double y)
 Add a point to the route.
 
void setRoute (std::vector< Avoid::Point > route)
 Set (overwriting) the entire route.
 
std::vector< Avoid::PointgetRoute (void) const
 Get a copy of the Edge's route member. May be empty. More...
 
std::vector< Avoid::PointgetRoutePoints (void) const
 Get route points. More...
 
std::string writeRouteTglf (void) const
 Write TGLF to represent the route for this Edge. More...
 
std::pair< Avoid::ConnEnd, Avoid::ConnEndmakeLibavoidConnEnds (Avoid::ConnDirFlags srcDirs=Avoid::ConnDirAll, Avoid::ConnDirFlags tgtDirs=Avoid::ConnDirAll)
 Build and return a pair of libavoid ConnEnds to represent the endpoints of this Edge.
 
void setBendNodes (Nodes bends)
 Set the bend nodes. These should be Nodes representing the bend points in the Edge's route.
 
void addBendNode (Node_SP bn)
 Add a single bend node.
 
Nodes getBendNodes (void)
 Access the Edge's bend nodes.
 
bool hasBendNodes (void)
 Check whether this Edge has any bend nodes.
 
void rotate90cw (void)
 Rotate the connector route 90 degrees clockwise.
 
void rotate90acw (void)
 Rotate the connector route 90 degrees anticlockwise.
 
void rotate180 (void)
 Rotate the connector route 180 degrees.
 
void translate (double dx, double dy)
 Translate the connector route by a given amount in each dimension. More...
 
void clearRouteAndBends (void)
 Clear the connector route and drop all bend nodes.
 
void buildRouteFromBends (void)
 Build a connector route based on the bend nodes.
 
std::string writeSvg (void) const
 Write SVG to represent this Edge. More...
 
std::string writePolylineConnectorData (void) const
 Write the data for a polyline SVG path for this Edge's connector route.
 
std::string writeRoundedOrthoConnectorData (void) const
 Write the data for an orthogonal SVG path for this Edge's connector route, using rounded bends.
 

Static Public Member Functions

static Edge_SP allocate (const Node_SP &src, const Node_SP &tgt)
 Factory function. More...
 

Detailed Description

The Edge class represents edges in a graph.

Member Function Documentation

◆ allocate()

Edge_SP Edge::allocate ( const Node_SP &  src,
const Node_SP &  tgt 
)
static

Factory function.

We make all constructors private and offer a factory function instead, in order to ensure that instances are allocated on the heap, and always come with a shared ptr control block.

Returns
A shared_ptr to Node (Node_SP).

Referenced by dialect::Graph::addEdge(), dialect::Graph::cloneNode(), and dialect::Chain::takeShapeBasedConfiguration().

Here is the caller graph for this function:

◆ getOtherEnd()

Node_SP Edge::getOtherEnd ( const dialect::Node end1) const

Get the opposite endpt, from a given one.

Parameters
[in]end1A Node lying at one end of this Edge.
Returns
The Node_SP lying at the other end.

References dialect::Node::id().

Referenced by dialect::Node::removeEdge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoute()

std::vector<Avoid::Point> dialect::Edge::getRoute ( void  ) const
inline

Get a copy of the Edge's route member. May be empty.

Note
If you are interested in drawing a connector, see the getRoutePoints method.
See also
getRoutePoints

◆ getRoutePoints()

vector< Point > Edge::getRoutePoints ( void  ) const

Get route points.

Note
This method returns the points that form the route you would draw for this edge. If the m_route vector is nonempty, a copy is returned. Otherwise you get a vector of two points: the centre of the source Node, and the centre of the target Node.
See also
getRoute

Referenced by writePolylineConnectorData(), writeRoundedOrthoConnectorData(), and writeSvg().

Here is the caller graph for this function:

◆ id()

id_type dialect::Edge::id ( void  ) const
inline

Access the unique ID of this instance.

Returns
The ID.

Referenced by dialect::Node::removeEdge(), and dialect::Graph::severEdge().

Here is the caller graph for this function:

◆ setGraph()

void dialect::Edge::setGraph ( Graph graph)
inline

Tell the Edge which Graph it belongs to.

Parameters
[in]graphThe Graph to which the Edge is to belong.

◆ translate()

void Edge::translate ( double  dx,
double  dy 
)

Translate the connector route by a given amount in each dimension.

Parameters
[in]dxThe amount by which to translate in the x-dimension.
[in]dyThe amount by which to translate in the y-dimension.

◆ writeRouteTglf()

string Edge::writeRouteTglf ( void  ) const

Write TGLF to represent the route for this Edge.

Returns
A string containing the TGLF.

◆ writeSvg()

string Edge::writeSvg ( void  ) const

Write SVG to represent this Edge.

Returns
A string containing the SVG.

References getRoutePoints(), writePolylineConnectorData(), and writeRoundedOrthoConnectorData().

Here is the call graph for this function:

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