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

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

#include <connector.h>

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 ()
 Destuctor.
 
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 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< Point > &checkpoints)
 Allows the user to specify a set of checkpoints that this connector will route via. More...
 
std::vector< PointroutingCheckpoints (void) const
 Returns the current set of routing checkpoints for this connector. 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

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

Constructs a connector with no endpoints specified.

Parameters
[in]routerThe router scene to place the connector into.
[in]idA unique positive integer ID for the connector.

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.

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

Constructs a connector with endpoints specified.

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.

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.

Member Function Documentation

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 may also have post-processing applied to the route, such as curved corners or nudging.

Returns
The PolyLine display route for the connector.
unsigned int Avoid::ConnRef::id ( void  ) const

Returns the ID of this connector.

Returns
The ID of the connector.
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.
const PolyLine & Avoid::ConnRef::route ( void  ) const

Returns a reference to the current route for the connector.

This is a "raw" version of the route, where each line segment in the route may be made up of multiple collinear line segments. It will also not have post-processing (like curved corners) applied to it. The simplified route for display can be obtained by calling displayRoute().

Returns
The PolyLine route for the connector.
Note
You can obtain a modified version of this poly-line route with curved corners added by calling PolyLine::curvedPolyline().
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.
std::vector< Point > Avoid::ConnRef::routingCheckpoints ( void  ) const

Returns the current set of routing checkpoints for this connector.

Returns
The ordered list of Points that this connecotr will route via.
ConnType Avoid::ConnRef::routingType ( void  ) const

Returns the type of routing performed for this connector.

Returns
The type of routing performed.
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.
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.
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.
void Avoid::ConnRef::setRoutingCheckpoints ( const std::vector< Point > &  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 points that the connector will attempt to route via.
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.
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.
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 JunctioRef and ConnRef.

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