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... | |
Router * | router (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 PolyLine & | route (void) const |
Returns a reference to the current route for the connector. More... | |
PolyLine & | displayRoute (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< Point > | routingCheckpoints (void) const |
Returns the current set of routing checkpoints for this connector. More... | |
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.
Avoid::ConnRef::ConnRef | ( | Router * | router, |
const unsigned int | id = 0 |
||
) |
Constructs a connector with no endpoints specified.
[in] | router | The router scene to place the connector into. |
[in] | id | A 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.
[in] | router | The router scene to place the connector into. |
[in] | id | A unique positive integer ID for the connector. |
[in] | src | The source endpoint of the connector. |
[in] | dst | The 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.
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.
unsigned int Avoid::ConnRef::id | ( | void | ) | const |
Returns the ID of this 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.
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().
Router * Avoid::ConnRef::router | ( | void | ) | const |
Returns a pointer to the router scene this connector is in.
std::vector< Point > Avoid::ConnRef::routingCheckpoints | ( | void | ) | const |
Returns the current set of routing checkpoints for this connector.
ConnType Avoid::ConnRef::routingType | ( | void | ) | const |
Returns the type of routing performed for this connector.
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.
[in] | cb | A pointer to the callback function. |
[in] | ptr | A 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.
[in] | dstPoint | New destination endpoint for the connector. |
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.
[in] | srcPoint | New source endpoint for the connector. |
[in] | dstPoint | New 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.
[in] | checkpoints | An 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.
type | The 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.
[in] | srcPoint | New 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.