#include <associationline.h>
A convenience class that encapsulates geometry management, handles mouse and hover events, embeds and aligns symbols and finally draws the lines and points. Context menu events are handled in AssociationWidget.
This class is infact a draw and event handling proxy for AssociationWidget.
- Note
- m_activePointIndex and m_activeSegmentIndex can't be active at same time!
- Author
- Gopala Krishna
-
Andi Fischer Bugs and comments to uml-d.nosp@m.evel.nosp@m.@list.nosp@m.s.sf.nosp@m..net or https://bugs.kde.org
◆ AssociationLine()
◆ ~AssociationLine()
AssociationLine::~AssociationLine |
( |
| ) |
|
|
virtual |
◆ addPoint()
void AssociationLine::addPoint |
( |
const QPointF & |
point | ) |
|
◆ alignSymbols()
void AssociationLine::alignSymbols |
( |
| ) |
|
|
private |
This method aligns both the "start" and "end" symbols to the current angles of the "first" and the "last" line segment respectively.
◆ boundingRect()
QRectF AssociationLine::boundingRect |
( |
| ) |
const |
The points are used for the bounding rect. The reason is, that for splines the control points are further away from the path.
- Returns
- The bounding rectangle for the AssociationLine.
◆ brush()
QBrush AssociationLine::brush |
( |
| ) |
const |
Returns the type of brush to use depending on the type of Association.
◆ calculateInitialEndPoints()
void AssociationLine::calculateInitialEndPoints |
( |
| ) |
|
This method simply ensures presence of two points and adds the needed points for self associations.
◆ cleanup()
void AssociationLine::cleanup |
( |
| ) |
|
Removes all the points and signals a geometry update.
◆ closestPointIndex()
int AssociationLine::closestPointIndex |
( |
const QPointF & |
point, |
|
|
qreal |
delta = Delta |
|
) |
| const |
Return index of point closer a given delta.
- Parameters
-
point | The point which is to be tested for closeness. |
delta | The distance the point should be closer to. |
- Return values
-
Index | of the first line point closer to the point passed. |
-1 | If no line point is closer to passed in point. |
◆ closestSegmentIndex()
int AssociationLine::closestSegmentIndex |
( |
const QPointF & |
point, |
|
|
qreal |
delta = Delta |
|
) |
| const |
Return index of closest segment.
- Parameters
-
point | The point which is to be tested for closeness. |
delta | The distance in pixels that the point may be removed from a segment but is still considered to be on the segment. |
- Returns
- Index of the line segment closest to the point passed; -1 if no line segment is closer to passed in point.
◆ count()
int AssociationLine::count |
( |
| ) |
const |
Returns the amount of POINTS on the line. Includes start and end points.
- Returns
- number of points in the AssociationLine
◆ createBezierCurve()
QPainterPath AssociationLine::createBezierCurve |
( |
QVector< QPointF > |
points | ) |
|
|
staticprivate |
Returns a Bézier path from given points.
- Parameters
-
points | points which define the Bézier curve |
- Returns
- cubic Bézier spline
◆ createCollaborationLine()
void AssociationLine::createCollaborationLine |
( |
| ) |
|
|
private |
Constructs the open arrow symbol and arrow line, that would represent Collaboration line.
◆ createOrthogonalPath()
QPainterPath AssociationLine::createOrthogonalPath |
( |
QVector< QPointF > |
points | ) |
|
|
staticprivate |
Returns an orthogonal path constructed of vertical and horizontal segments through the given points.
- Parameters
-
points | base points for the path |
- Returns
- orthogonal path
◆ createSplinePoints()
void AssociationLine::createSplinePoints |
( |
| ) |
|
|
private |
For a cubic Bezier curve at least four points are needed. If there are less, the missing points will be created. Note: Implementation is only for two points.
◆ createSubsetSymbol()
void AssociationLine::createSubsetSymbol |
( |
| ) |
|
|
private |
Constructs a new subset symbol.
◆ dumpPoints()
void AssociationLine::dumpPoints |
( |
| ) |
|
Debug helper method to write out the points.
◆ enableAutoLayout()
bool AssociationLine::enableAutoLayout |
( |
| ) |
|
◆ endPoint()
QPointF AssociationLine::endPoint |
( |
| ) |
const |
◆ fromString()
Convert string to enum LayoutType.
◆ hoverEnterEvent()
void AssociationLine::hoverEnterEvent |
( |
QGraphicsSceneHoverEvent * |
event | ) |
|
Calculates the "to be highlighted" point and segment indices and updates if necessary.
◆ hoverLeaveEvent()
void AssociationLine::hoverLeaveEvent |
( |
QGraphicsSceneHoverEvent * |
event | ) |
|
Reset active indices and updates.
◆ hoverMoveEvent()
void AssociationLine::hoverMoveEvent |
( |
QGraphicsSceneHoverEvent * |
event | ) |
|
Calculates the "to be highlighted" point and segment indices and updates if necessary.
◆ insertPoint()
void AssociationLine::insertPoint |
( |
int |
index, |
|
|
const QPointF & |
point |
|
) |
| |
Inserts the passed in point at the index passed in and recalculates the bounding rect.
◆ isAutoLayouted()
bool AssociationLine::isAutoLayouted |
( |
| ) |
const |
◆ isEndPointIndex()
bool AssociationLine::isEndPointIndex |
( |
int |
index | ) |
const |
Retval True If point at index is start or end.
◆ isEndSegmentIndex()
bool AssociationLine::isEndSegmentIndex |
( |
int |
index | ) |
const |
Retval True If segment at index is start or end.
◆ layout()
Return the layout type of the association line.
- Returns
- the currently used layout
◆ loadFromXMI()
bool AssociationLine::loadFromXMI |
( |
QDomElement & |
qElement | ) |
|
◆ mouseMoveEvent()
void AssociationLine::mouseMoveEvent |
( |
QGraphicsSceneMouseEvent * |
event | ) |
|
Moves the point or line if active.
◆ mousePressEvent()
void AssociationLine::mousePressEvent |
( |
QGraphicsSceneMouseEvent * |
event | ) |
|
Determines the active point or segment, the latter being given more priority.
◆ mouseReleaseEvent()
void AssociationLine::mouseReleaseEvent |
( |
QGraphicsSceneMouseEvent * |
event | ) |
|
Reset active indices and also push undo command.
◆ optimizeLinePoints()
void AssociationLine::optimizeLinePoints |
( |
| ) |
|
This method optimizes the number of points in the AssociationLine. This can be used to reduce the clutter caused due to too many points. TODO: Use delta comparison 'closestPointIndex' instead of exact comparison. TODO: Not used anywhere.
◆ paint()
void AssociationLine::paint |
( |
QPainter * |
painter, |
|
|
const QStyleOptionGraphicsItem * |
option, |
|
|
QWidget * |
widget |
|
) |
| |
|
virtual |
Reimplemented from QGraphicsItem::paint. Draws the AssociationLine and also takes care of highlighting active point or line.
◆ path()
QPainterPath AssociationLine::path |
( |
| ) |
const |
◆ pen()
QPen AssociationLine::pen |
( |
| ) |
const |
Returns the pen used for drawing.
◆ point()
QPointF AssociationLine::point |
( |
int |
index | ) |
const |
Returns the point at the point index.
- Returns
- point at given index
◆ reconstructSymbols()
void AssociationLine::reconstructSymbols |
( |
| ) |
|
This method creates, deletes symbols and collaboration lines based on m_associationWidget->associationType().
Call this method when associationType of m_associationWidget changes.
◆ removeCollaborationLine()
void AssociationLine::removeCollaborationLine |
( |
| ) |
|
|
private |
Removes collaboration line by deleting the head and line item.
◆ removePoint()
void AssociationLine::removePoint |
( |
int |
index | ) |
|
Removes the point at index passed in.
- See also
- removeNonEndPoint
◆ removeSubsetSymbol()
void AssociationLine::removeSubsetSymbol |
( |
| ) |
|
|
private |
Removes the subset symbol if it existed by deleting appropriate items.
◆ saveToXMI()
void AssociationLine::saveToXMI |
( |
QXmlStreamWriter & |
writer | ) |
|
Saves association line information into XMI element named "linepath".
- Note
- Stored as linepath for backward compatibility
◆ setEndPoints()
bool AssociationLine::setEndPoints |
( |
const QPointF & |
start, |
|
|
const QPointF & |
end |
|
) |
| |
Sets the start and end points.
◆ setEndSymbol()
Sets the Symbol to appear at the last line segment to symbol.
If symbol == Symbol::None , then it deletes the symbol item.
◆ setLayout()
Set the layout type of the association line.
- Parameters
-
layout | the desired layout to set |
◆ setPen()
void AssociationLine::setPen |
( |
const QPen & |
pen | ) |
|
◆ setPoint()
bool AssociationLine::setPoint |
( |
int |
index, |
|
|
const QPointF & |
point |
|
) |
| |
Sets the point value at given index to point.
◆ setStartSymbol()
Sets the Symbol to appear at the first line segment to symbol.
If symbol == Symbol::None , then it deletes the symbol item.
◆ shape()
QPainterPath AssociationLine::shape |
( |
| ) |
const |
◆ startPoint()
QPointF AssociationLine::startPoint |
( |
| ) |
const |
◆ toString()
Convert enum LayoutType to string.
◆ updatePenStyle()
void AssociationLine::updatePenStyle |
( |
| ) |
|
Update pen style depending on the association type of the related AssociationWidget instance.
◆ Delta
const qreal AssociationLine::Delta = 5 |
|
staticprivate |
default delta for fuzzy recognition of points closer to point
◆ m_activePointIndex
int AssociationLine::m_activePointIndex |
|
private |
index of active point which can be dragged to modify association line
◆ m_activeSegmentIndex
int AssociationLine::m_activeSegmentIndex |
|
private |
◆ m_associationWidget
association widget which this line represents
◆ m_autoLayoutSpline
bool AssociationLine::m_autoLayoutSpline |
|
private |
◆ m_c1dx
qreal AssociationLine::m_c1dx {0.0} |
|
private |
◆ m_c1dy
qreal AssociationLine::m_c1dy {0.0} |
|
private |
◆ m_c2dx
qreal AssociationLine::m_c2dx {0.0} |
|
private |
◆ m_c2dy
qreal AssociationLine::m_c2dy {0.0} |
|
private |
◆ m_collaborationLineHead
Symbol* AssociationLine::m_collaborationLineHead |
|
private |
arrow head drawn at end of m_collaborationLineItem
◆ m_collaborationLineItem
QGraphicsLineItem* AssociationLine::m_collaborationLineItem |
|
private |
parallel arrow line drawn in case of collaboration message
◆ m_endSymbol
Symbol* AssociationLine::m_endSymbol |
|
private |
symbol drawn at the end of "last" line segment
◆ m_layout
◆ m_pen
QPen AssociationLine::m_pen |
|
private |
pen used to draw an association line
◆ m_points
QVector<QPointF> AssociationLine::m_points |
|
private |
points representing the association line
◆ m_startSymbol
Symbol* AssociationLine::m_startSymbol |
|
private |
symbol drawn at the end of "first" line segment
◆ m_subsetSymbol
Symbol* AssociationLine::m_subsetSymbol |
|
private |
◆ SelectedPointDiameter
const qreal AssociationLine::SelectedPointDiameter = 4 |
|
staticprivate |
radius of circles drawn to show "selection"
◆ SelfAssociationMinimumHeight
const qreal AssociationLine::SelfAssociationMinimumHeight = 30 |
|
staticprivate |
minimum height for self association's loop
The documentation for this class was generated from the following files: