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

The ShapeRef class represents a shape object. More...

#include <shape.h>

Inherits Avoid::Obstacle.

Collaboration diagram for Avoid::ShapeRef:
Collaboration graph

Public Member Functions

 ShapeRef (Router *router, Polygon &poly, const unsigned int id=0)
 Shape reference constructor. More...
 
virtual ~ShapeRef ()
 Shape reference destructor. More...
 
const Polygonpolygon (void) const
 Returns a reference to the polygon boundary of this shape. More...
 
void transformConnectionPinPositions (ShapeTransformationType transform)
 Adjusts all of the shape's connection pin positions and visibility directions for a given transformation type. More...
 

Detailed Description

The ShapeRef class represents a shape object.

Shapes are obstacles that connectors must be routed around. They can be placed into a Router scene and can be repositioned or resized (via Router::moveShape()).

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

Constructor & Destructor Documentation

◆ ShapeRef()

Avoid::ShapeRef::ShapeRef ( Router router,
Polygon poly,
const unsigned int  id = 0 
)

Shape reference constructor.

Creates a shape object reference, and adds it to the router scene. This shape will be considered to be an obstacle. This will cause connectors intersecting the newly added shape to be marked as needing to be rerouted.

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

The shape can be moved with Router::moveShape() and removed from the scene and freed with Router::deleteShape().

The poly argument will usually be the boundary of the shape in your application with additional buffer of several pixels on each side. Specifying such a buffer results in connectors leaving a small amount of space around shapes, rather than touching them on the corners or edges.

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 shape into.
[in]polyA Polygon representing the boundary of the shape.
[in]idOptionally, a positive integer ID unique among all objects.

◆ ~ShapeRef()

Avoid::ShapeRef::~ShapeRef ( )
virtual

Shape reference destructor.

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

Member Function Documentation

◆ polygon()

const Polygon & Avoid::ShapeRef::polygon ( void  ) const

Returns a reference to the polygon boundary of this shape.

Returns
A reference to the polygon boundary of the shape.

Referenced by Avoid::Router::moveShape(), Avoid::ShapeConnectionPin::position(), and transformConnectionPinPositions().

Here is the caller graph for this function:

◆ transformConnectionPinPositions()

void Avoid::ShapeRef::transformConnectionPinPositions ( ShapeTransformationType  transform)

Adjusts all of the shape's connection pin positions and visibility directions for a given transformation type.

Parameters
[in]transformA ShapeTransformationType specifying the type of transform to be applied to all connection pins for the shape.

References Avoid::ConnDirAll, Avoid::ConnDirDown, Avoid::ConnDirLeft, Avoid::ConnDirRight, Avoid::ConnDirUp, Avoid::PolygonInterface::offsetBoundingBox(), polygon(), Avoid::TransformationType_CW180, Avoid::TransformationType_CW270, Avoid::TransformationType_CW90, Avoid::TransformationType_FlipX, and Avoid::TransformationType_FlipY.

Here is the call graph for this function:

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