Module implementing a canvas widget for an association between two widgets.
AssociationWidget | Class implementing a canvas widget for an association between two widgets. |
None |
Class implementing a canvas widget for an association between two widgets.
The association is drawn as an arrow starting at the first widget and ending at the second.
AssociationWidget | Constructor |
calculateEndingPoints_center | Method to calculate the ending points of the association widget. |
calculateEndingPoints_rectangle | Method to calculate the ending points of the association widget. |
findIntersection | Method to calculate the intersection point of two lines. |
findPointRegion | Method to find out, which region of rectangle rect contains the point (PosX, PosY) and returns the region number. |
findRectIntersectionPoint | Method to find the intersetion point of a line with a rectangle. |
unassociate | Method to unassociate from the widgets. |
updateEndPoint | Method to update an endpoint. |
widgetMoved | Method to recalculate the association after a widget was moved. |
Constructor
Method to calculate the ending points of the association widget.
The ending points are calculated from the centers of the two associated widgets.
Method to calculate the ending points of the association widget.
The ending points are calculate by the following method.
For each Widget the diagram is divided in four Regions by its diagonals as indicated below
\ Region 2 / \ / |--------| | \ / | | \ / | | \/ | Region 1 | /\ | Region 3 | / \ | | / \ | |--------| / \ / Region 4 \
Each diagonal is defined by two corners of the bounding rectangle
To calculate the start point we have to find out in which region (defined by widgetA's diagonals) is widgetB's TopLeft corner (lets call it region M) after that the start point will be the middle point of rectangle's side contained in region M.
To calculate the end point we repeat the above but in the opposite direction (from widgetB to widgetA)
Method to calculate the intersection point of two lines.
The first line is determined by the points p1 and p2, the second line by p3 and p4. If the intersection point is not contained in the segment p1p2, then it returns (-1, -1).
For the function's internal calculations remember:
QT coordinates start with the point (0,0) as the topleft corner
and x-values increase from left to right and y-values increase
from top to bottom; it means the visible area is quadrant I in
the regular XY coordinate system
Quadrant II | Quadrant I -----------------|----------------- Quadrant III | Quadrant IV
In order for the linear function calculations to work in this method we must switch x and y values (x values become y values and viceversa)
Method to find out, which region of rectangle rect contains the point (PosX, PosY) and returns the region number.
Method to find the intersetion point of a line with a rectangle.
Method to unassociate from the widgets.
Method to update an endpoint.
Method to recalculate the association after a widget was moved.