The ShapeConnectionPin class represents a fixed point or "pin" on a shape that can be connected to. More...
#include <connectionpin.h>
Public Member Functions | |
ShapeConnectionPin (ShapeRef *shape, const unsigned int classId, const double xPortionOffset, const double yPortionOffset, const double insideOffset=0.0, const ConnDirFlags visDirs=ConnDirNone) | |
Constructs a ShapeConnectionPin at a specified position on a parent shape. More... | |
ShapeConnectionPin (JunctionRef *junction, const unsigned int classId, const ConnDirFlags visDirs=ConnDirNone) | |
Constructs a ShapeConnectionPin on a JunctionRef. More... | |
void | setConnectionCost (const double cost) |
sets a cost used when selecting whether connectors should be be attached to this connection pin. More... | |
const Point | position (const Polygon &newPoly=Polygon()) const |
Returns the position of this connection pin. More... | |
ConnDirFlags | directions (void) const |
Returns the directions in which this connection pin has visibility. More... | |
void | setExclusive (const bool exclusive) |
Sets whether the pin is exclusive, i.e., only one connector can attach to it. More... | |
The ShapeConnectionPin class represents a fixed point or "pin" on a shape that can be connected to.
Pins have a visibility direction and numeric class ID (e.g., to specify types of pins such as "input" or "output"). They may optionally have a priority which means when routing connectors to a particular class ID then one pin will be selected over another.
Pins have a position that is specified relative to its parent shape. Then the shape is moved or resized, The pin will be automatically moved accordingly.
Pins with a specified direction are exclusive by default, those with visibility in all directions are non-exclusive by default. This behaviour can be changed by calling the ShapeConnectionPin::setExclusive() method.
Avoid::ShapeConnectionPin::ShapeConnectionPin | ( | ShapeRef * | shape, |
const unsigned int | classId, | ||
const double | xPortionOffset, | ||
const double | yPortionOffset, | ||
const double | insideOffset = 0.0 , |
||
const ConnDirFlags | visDirs = ConnDirNone |
||
) |
Constructs a ShapeConnectionPin at a specified position on a parent shape.
Ownership of this ShapeConnectionPin is passed to the parent shape.
The connection point position should be specified as proportion of the shape's total width and height using a floating point value between 0 and 1.
There are some predefined values for specifying the xPortionOffset and yPortionOffset arguments:
Importantly, shape connection pins will be moved automatically when the parent shapes are moved or resized. Attachment for connectors will be chosen based on the classId specified to ConnEnd and these connectors will be subsequently rerouted.
If no value is given for the visDirs argument, then visibility is automatically determined based on the position of the connection point. Points on the shape boundary will have visibility from the shape out of that edge while points in the interior will have visibility in all directions.
The insideOffset argument can be used to set a distance to automatically offset the point within the shape. This is useful for orthogonal routing, where you usually want the connection point to lie inside the shape rather than exactly on its boundary. While you could specify an exact position with xPortionOffset and yPortionOffset, it is usually much easier and more readable to not have to specify the visibility directions manually and to write something like
ShapeConnectionPin(shapeRef, pinClassId, ATTACH_POS_RIGHT, ATTACH_POS_CENTRE, 5);
rather than
ShapeConnectionPin(shapeRef, pinClassId, 1 - 5/shapeWidth, ATTACH_POS_CENTRE, 0, ConnDirRight);
[in] | shape | A pointer to the containing parent shape's ShapeRef. |
[in] | classId | An integer used to mark the class or group of this connection point, used for specifying attachment to ConnEnd. |
[in] | xPortionOffset | The X position within the shape, specified as a proportion of the width between 0 (left) and 1 (right). |
[in] | yPortionOffset | The Y position within the shape, specified as a proportion of the height between 0 (top) and 1 (bottom). |
[in] | insideOffset | A distance to offset the connection point inside the shape if it lies on the boundary. |
[in] | visDirs | One or more Avoid::ConnDirFlag options specifying the directions that this connection point has visibility. |
Avoid::ShapeConnectionPin::ShapeConnectionPin | ( | JunctionRef * | junction, |
const unsigned int | classId, | ||
const ConnDirFlags | visDirs = ConnDirNone |
||
) |
Constructs a ShapeConnectionPin on a JunctionRef.
Ownership of this ShapeConnectionPin is passed to the parent junction.
This will usually be automatically called by the JunctionRef constructor to give the Junction four ShapeConnectionPins, facing up, down, left and right.
[in] | junction | A pointer to the containing parent junction's JunctionRef. |
[in] | classId | An integer used to mark the class or group of this connection point, used for specifying attachment to ConnEnd. |
[in] | visDirs | One or more Avoid::ConnDirFlag options specifying the directions that this connection point has visibility. |
ConnDirFlags Avoid::ShapeConnectionPin::directions | ( | void | ) | const |
Returns the directions in which this connection pin has visibility.
Returns the position of this connection pin.
void Avoid::ShapeConnectionPin::setConnectionCost | ( | const double | cost | ) |
sets a cost used when selecting whether connectors should be be attached to this connection pin.
[in] | cost | A routing cost applied to a route when selecting this connection pin. |
void Avoid::ShapeConnectionPin::setExclusive | ( | const bool | exclusive | ) |
Sets whether the pin is exclusive, i.e., only one connector can attach to it.
[in] | exclusive | A bool representing whether this pin should be exclusive. |