Adaptagrams
Public Member Functions | List of all members
Avoid::ConnRef Class Reference

The ConnRef class represents a connector object. More...

#include <connector.h>

Collaboration diagram for Avoid::ConnRef:
Collaboration graph

Public Member Functions

 ConnRef (Router *router, const unsigned int id=0)
 Constructs a connector with no endpoints specified. More...
 
 ConnRef (Router *router, const ConnEnd &src, const ConnEnd &dst, const unsigned int id=0)
 Constructs a connector with endpoints specified. More...
 
 ~ConnRef ()
 Connector reference destuctor. More...
 
void setEndpoints (const ConnEnd &srcPoint, const ConnEnd &dstPoint)
 Sets both a new source and destination endpoint for this connector. More...
 
void setSourceEndpoint (const ConnEnd &srcPoint)
 Sets just a new source endpoint for this connector. More...
 
void setDestEndpoint (const ConnEnd &dstPoint)
 Sets just a new destination endpoint for this connector. More...
 
unsigned int id (void) const
 Returns the ID of this connector. More...
 
Routerrouter (void) const
 Returns a pointer to the router scene this connector is in. More...
 
bool needsRepaint (void) const
 Returns an indication of whether this connector has a new route and thus needs to be repainted. More...
 
const PolyLineroute (void) const
 Returns a reference to the current raw "debug" route for the connector. More...
 
PolyLinedisplayRoute (void)
 Returns a reference to the current display version of the route for the connector. More...
 
void setCallback (void(*cb)(void *), void *ptr)
 Sets a callback function that will called to indicate that the connector needs rerouting. More...
 
ConnType routingType (void) const
 Returns the type of routing performed for this connector. More...
 
void setRoutingType (ConnType type)
 Sets the type of routing to be performed for this connector. More...
 
std::pair< JunctionRef *, ConnRef * > splitAtSegment (const size_t segmentN)
 Splits a connector in the centre of the segmentNth segment and creates a junction point there as well as a second connector. More...
 
void setRoutingCheckpoints (const std::vector< Checkpoint > &checkpoints)
 Allows the user to specify a set of checkpoints that this connector will route via. More...
 
std::vector< CheckpointroutingCheckpoints (void) const
 Returns the current set of routing checkpoints for this connector. More...
 
std::pair< ConnEnd, ConnEndendpointConnEnds (void) const
 Returns ConnEnds specifying what this connector is attached to. More...
 
void setFixedRoute (const PolyLine &route)
 Sets a fixed user-specified route for this connector. More...
 
void setFixedExistingRoute (void)
 Sets a fixed existing route for this connector. More...
 
bool hasFixedRoute (void) const
 Returns whether the connector route is marked as fixed. More...
 
void clearFixedRoute (void)
 Returns the connector to being automatically routed if it was marked as fixed. More...
 

Detailed Description

The ConnRef class represents a connector object.

Connectors are a (possible multi-segment) line between two points. They are routed intelligently so as not to overlap any of the shape objects in the Router scene.

Routing penalties can be applied, resulting in more aesthetically pleasing connector paths with fewer segments or less severe bend-points.

You can set a function to be called when the connector has been rerouted and needs to be redrawn. Alternatively, you can query the connector's needsRepaint() function to determine this manually.

Usually, it is expected that you would create a ConnRef for each connector in your diagram and keep that reference in your own connector class.

Constructor & Destructor Documentation

◆ ConnRef() [1/2]

Avoid::ConnRef::ConnRef ( Router router,
const unsigned int  id = 0 
)

Constructs a connector with no endpoints specified.

The constructor requires a valid Router instance. This router will take ownership of the connector. Hence, you should not call the destructor yourself, but should instead call Router::deleteConnector() and the router instance will remove and then free the connector's memory.

Note
Regarding IDs: You can let libavoid manually handle IDs by not specifying them. Alternatively, you can specify all IDs yourself, but you must be careful to makes sure that each object in the scene (shape, connector, cluster, etc) is given a unique, positive ID. This uniqueness is checked if assertions are enabled, but if not and there are clashes then strange things can happen.
Parameters
[in]routerThe router scene to place the connector into.
[in]idOptionally, a positive integer ID unique among all objects.

References Avoid::Polygon::clear().

Referenced by splitAtSegment().

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

◆ ConnRef() [2/2]

Avoid::ConnRef::ConnRef ( Router router,
const ConnEnd src,
const ConnEnd dst,
const unsigned int  id = 0 
)

Constructs a connector with endpoints specified.

The constructor requires a valid Router instance. This router will take ownership of the connector. Hence, you should not call the destructor yourself, but should instead call Router::deleteConnector() and the router instance will remove and then free the connector's memory.

If an ID is not specified, then one will be assigned to the shape. If assigning an ID yourself, note that it should be a unique positive integer. Also, IDs are given to all objects in a scene, so the same ID cannot be given to a shape and a connector for example.

Parameters
[in]routerThe router scene to place the connector into.
[in]idA unique positive integer ID for the connector.
[in]srcThe source endpoint of the connector.
[in]dstThe destination endpoint of the connector.

References Avoid::Polygon::clear(), and setEndpoints().

Here is the call graph for this function:

◆ ~ConnRef()

Avoid::ConnRef::~ConnRef ( )

Connector reference destuctor.

Do not call this yourself, instead call Router::deleteConnector(). Ownership of this object belongs to the router scene.

Member Function Documentation

◆ clearFixedRoute()

void Avoid::ConnRef::clearFixedRoute ( void  )

Returns the connector to being automatically routed if it was marked as fixed.

See also
setFixedRoute()

◆ displayRoute()

Polygon & Avoid::ConnRef::displayRoute ( void  )

Returns a reference to the current display version of the route for the connector.

The display version of a route has been simplified to collapse all collinear line segments into single segments. It also has all post-processing applied to the route, including centering, curved corners and nudging apart of overlapping segments.

Returns
The PolyLine display route for the connector.

References Avoid::Polygon::empty(), and Avoid::Polygon::simplify().

Referenced by Avoid::Router::outputInstanceToSVG().

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

◆ endpointConnEnds()

std::pair< ConnEnd, ConnEnd > Avoid::ConnRef::endpointConnEnds ( void  ) const

Returns ConnEnds specifying what this connector is attached to.

This may be useful during hyperedge rerouting. You can check the type and properties of the ConnEnd objects to find out what this connector is attached to. The ConnEnd::type() will be ConnEndEmpty if the connector has not had its endpoints initialised.

Note
If the router is using transactions, you might get unexpected results if you call this after changing objects but before calling Router::processTransaction(). In this case changes to ConnEnds for the connector may be queued and not yet applied, so you will get old (or empty) values.
Returns
A pair of ConnEnd objects specifying what the connector is attached to.

◆ hasFixedRoute()

bool Avoid::ConnRef::hasFixedRoute ( void  ) const

Returns whether the connector route is marked as fixed.

Returns
True if the connector route is fixed, false otherwise.

◆ id()

unsigned int Avoid::ConnRef::id ( void  ) const

Returns the ID of this connector.

Returns
The ID of the connector.

Referenced by Avoid::Router::outputInstanceToSVG().

Here is the caller graph for this function:

◆ needsRepaint()

bool Avoid::ConnRef::needsRepaint ( void  ) const

Returns an indication of whether this connector has a new route and thus needs to be repainted.

If the connector has been rerouted and need repainting, the
displayRoute() method can be called to get a reference to the new route.

Returns
Returns true if the connector requires repainting, or false if it does not.

◆ route()

const PolyLine & Avoid::ConnRef::route ( void  ) const

Returns a reference to the current raw "debug" route for the connector.

This is a raw "debug" shortest path version of the route, where each line segment in the route may be made up of multiple collinear line segments. It also has no post-processing (i.e., centering, nudging apart of overlapping paths, or curving of corners) applied to it. A route to display to the user can be obtained by calling displayRoute().

Returns
The PolyLine route for the connector.

Referenced by Avoid::Router::outputInstanceToSVG(), and setFixedRoute().

Here is the caller graph for this function:

◆ router()

Router * Avoid::ConnRef::router ( void  ) const

Returns a pointer to the router scene this connector is in.

Returns
A pointer to the router scene for this connector.

Referenced by splitAtSegment().

Here is the caller graph for this function:

◆ routingCheckpoints()

std::vector< Checkpoint > Avoid::ConnRef::routingCheckpoints ( void  ) const

Returns the current set of routing checkpoints for this connector.

Returns
The ordered list of Checkpoints that this connector will route via.

◆ routingType()

ConnType Avoid::ConnRef::routingType ( void  ) const

Returns the type of routing performed for this connector.

Returns
The type of routing performed.

◆ setCallback()

void Avoid::ConnRef::setCallback ( void(*)(void *)  cb,
void *  ptr 
)

Sets a callback function that will called to indicate that the connector needs rerouting.

The cb function will be called when shapes are added to, removed from or moved about on the page. The pointer ptr will be passed as an argument to the callback function.

Parameters
[in]cbA pointer to the callback function.
[in]ptrA generic pointer that will be passed to the callback function.

◆ setDestEndpoint()

void Avoid::ConnRef::setDestEndpoint ( const ConnEnd dstPoint)

Sets just a new destination endpoint for this connector.

If the router is using transactions, then this action will occur the next time Router::processTransaction() is called. See Router::setTransactionUse() for more information.

Parameters
[in]dstPointNew destination endpoint for the connector.

Referenced by dialect::LeaflessOrthoRouter::route(), and splitAtSegment().

Here is the caller graph for this function:

◆ setEndpoints()

void Avoid::ConnRef::setEndpoints ( const ConnEnd srcPoint,
const ConnEnd dstPoint 
)

Sets both a new source and destination endpoint for this connector.

If the router is using transactions, then this action will occur the next time Router::processTransaction() is called. See Router::setTransactionUse() for more information.

Parameters
[in]srcPointNew source endpoint for the connector.
[in]dstPointNew destination endpoint for the connector.

Referenced by dialect::RoutingAdapter::addEdges(), ConnRef(), and setFixedRoute().

Here is the caller graph for this function:

◆ setFixedExistingRoute()

void Avoid::ConnRef::setFixedExistingRoute ( void  )

Sets a fixed existing route for this connector.

libavoid will no longer calculate object-avoiding paths for this connector but instead just return the current exisitng route.
The path of this connector will still be considered for the purpose of nudging and routing other non-fixed connectors.

Note
The endpoints of this connector will remain at their current positions, even while remaining 'attached' to shapes or junctions that move.
See also
setFixedRoute()
clearFixedRoute()

References Avoid::Polygon::size().

Here is the call graph for this function:

◆ setFixedRoute()

void Avoid::ConnRef::setFixedRoute ( const PolyLine route)

Sets a fixed user-specified route for this connector.

libavoid will no longer calculate object-avoiding paths for this connector but instead just return the specified route. The path of this connector will still be considered for the purpose of nudging and routing other non-fixed connectors.

Note
This will reset the endpoints of the connector to the two ends of the given route, which may cause it to become dettached from any shapes or junctions. You can alternatively call setFixedExistingRoute() for connectors with valid routes in hyperedges that you would like to remain attached.
Parameters
[in]routeThe new fixed route for the connector.
See also
setFixedExistingRoute()
clearFixedRoute()

References Avoid::Polygon::ps, route(), setEndpoints(), Avoid::Polygon::simplify(), and Avoid::Polygon::size().

Here is the call graph for this function:

◆ setRoutingCheckpoints()

void Avoid::ConnRef::setRoutingCheckpoints ( const std::vector< Checkpoint > &  checkpoints)

Allows the user to specify a set of checkpoints that this connector will route via.

When routing, the connector will attempt to visit each of the points in the checkpoints list in order. It will route from the source point to the first checkpoint, to the second checkpoint, etc. If a checkpoint is unreachable because it lies inside an obstacle, then that checkpoint will be skipped.

Parameters
[in]checkpointsAn ordered list of Checkpoints that the connector will attempt to route via.

References Avoid::ConnDirAll.

◆ setRoutingType()

void Avoid::ConnRef::setRoutingType ( ConnType  type)

Sets the type of routing to be performed for this connector.

If a call to this method changes the current type of routing being used for the connector, then it will get rerouted during the next processTransaction() call, or immediately if transactions are not being used.

Parameters
typeThe type of routing to be performed.

◆ setSourceEndpoint()

void Avoid::ConnRef::setSourceEndpoint ( const ConnEnd srcPoint)

Sets just a new source endpoint for this connector.

If the router is using transactions, then this action will occur the next time Router::processTransaction() is called. See Router::setTransactionUse() for more information.

Parameters
[in]srcPointNew source endpoint for the connector.

Referenced by dialect::LeaflessOrthoRouter::route().

Here is the caller graph for this function:

◆ splitAtSegment()

std::pair< JunctionRef *, ConnRef * > Avoid::ConnRef::splitAtSegment ( const size_t  segmentN)

Splits a connector in the centre of the segmentNth segment and creates a junction point there as well as a second connector.

The new junction and connector will be automatically added to the router scene. A slight preference will be given to the connectors connecting to the junction in the same orientation the line segment already existed in.

Returns
A pair containing pointers to the new JunctionRef and ConnRef.

References Avoid::Polygon::at(), ConnRef(), router(), setDestEndpoint(), Avoid::Polygon::size(), and Avoid::Point::x.

Here is the call graph for this function:

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