Adaptagrams
|
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 () | |
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... | |
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 raw "debug" 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< Checkpoint > &checkpoints) |
Allows the user to specify a set of checkpoints that this connector will route via. More... | |
std::vector< Checkpoint > | routingCheckpoints (void) const |
Returns the current set of routing checkpoints for this connector. More... | |
std::pair< ConnEnd, ConnEnd > | endpointConnEnds (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... | |
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.
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.
[in] | router | The router scene to place the connector into. |
[in] | id | Optionally, a positive integer ID unique among all objects. |
References Avoid::Polygon::clear().
Referenced by splitAtSegment().
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.
[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. |
References Avoid::Polygon::clear(), and setEndpoints().
Avoid::ConnRef::~ConnRef | ( | ) |
Connector reference destuctor.
Do not call this yourself, instead call Router::deleteConnector(). Ownership of this object belongs to the router scene.
void Avoid::ConnRef::clearFixedRoute | ( | void | ) |
Returns the connector to being automatically routed if it was marked as fixed.
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.
References Avoid::Polygon::empty(), and Avoid::Polygon::simplify().
Referenced by Avoid::Router::outputInstanceToSVG().
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.
bool Avoid::ConnRef::hasFixedRoute | ( | void | ) | const |
Returns whether the connector route is marked as fixed.
unsigned int Avoid::ConnRef::id | ( | void | ) | const |
Returns the ID of this connector.
Referenced by Avoid::Router::outputInstanceToSVG().
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 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().
Referenced by Avoid::Router::outputInstanceToSVG(), and setFixedRoute().
Router * Avoid::ConnRef::router | ( | void | ) | const |
Returns a pointer to the router scene this connector is in.
Referenced by splitAtSegment().
std::vector< Checkpoint > 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. |
Referenced by dialect::LeaflessOrthoRouter::route(), and splitAtSegment().
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. |
Referenced by dialect::RoutingAdapter::addEdges(), ConnRef(), and setFixedRoute().
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.
References Avoid::Polygon::size().
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.
[in] | route | The new fixed route for the connector. |
References Avoid::Polygon::ps, route(), setEndpoints(), Avoid::Polygon::simplify(), and Avoid::Polygon::size().
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.
[in] | checkpoints | An ordered list of Checkpoints that the connector will attempt to route via. |
References Avoid::ConnDirAll.
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. |
Referenced by dialect::LeaflessOrthoRouter::route().
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.
References Avoid::Polygon::at(), ConnRef(), router(), setDestEndpoint(), Avoid::Polygon::size(), and Avoid::Point::x.