umbrello 2.39.1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
|
#include <associationline.h>
Static Public Member Functions | |
static QString | toString (Uml::LayoutType::Enum layout) |
static Uml::LayoutType::Enum | fromString (const QString &layout) |
Private Member Functions | |
void | setStartSymbol (Symbol::SymbolType symbolType) |
void | setEndSymbol (Symbol::SymbolType symbolType) |
void | createSubsetSymbol () |
void | removeSubsetSymbol () |
void | createCollaborationLine () |
void | removeCollaborationLine () |
void | alignSymbols () |
void | createSplinePoints () |
Static Private Member Functions | |
static QPainterPath | createBezierCurve (QVector< QPointF > points) |
static QPainterPath | createOrthogonalPath (QVector< QPointF > points) |
Private Attributes | |
AssociationWidget * | m_associationWidget |
association widget which this line represents | |
QVector< QPointF > | m_points |
points representing the association line | |
int | m_activePointIndex |
index of active point which can be dragged to modify association line | |
int | m_activeSegmentIndex |
index of active segment | |
Symbol * | m_startSymbol |
symbol drawn at the end of "first" line segment | |
Symbol * | m_endSymbol |
symbol drawn at the end of "last" line segment | |
Symbol * | m_subsetSymbol |
subset symbol | |
QGraphicsLineItem * | m_collaborationLineItem |
parallel arrow line drawn in case of collaboration message | |
Symbol * | m_collaborationLineHead |
arrow head drawn at end of m_collaborationLineItem | |
Uml::LayoutType::Enum | m_layout |
QPen | m_pen |
pen used to draw an association line | |
bool | m_autoLayoutSpline |
qreal | m_c1dx {0.0} |
qreal | m_c1dy {0.0} |
qreal | m_c2dx {0.0} |
qreal | m_c2dy {0.0} |
Static Private Attributes | |
static const qreal | Delta = 5 |
default delta for fuzzy recognition of points closer to point | |
static const qreal | SelectedPointDiameter = 4 |
radius of circles drawn to show "selection" | |
static const qreal | SelfAssociationMinimumHeight = 30 |
minimum height for self association's loop | |
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.
|
explicit |
Constructor. Constructs an AssociationLine item slaved to the given AssociationWidget.
|
virtual |
Destructor.
|
private |
This method aligns both the "start" and "end" symbols to the current angles of the "first" and the "last" line segment respectively.
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.
QBrush AssociationLine::brush | ( | ) | const |
Returns the type of brush to use depending on the type of Association.
void AssociationLine::calculateInitialEndPoints | ( | ) |
This method simply ensures presence of two points and adds the needed points for self associations.
void AssociationLine::cleanup | ( | ) |
Removes all the points and signals a geometry update.
Return index of point closer a given delta.
point | The point which is to be tested for closeness. |
delta | The distance the point should be closer to. |
Index | of the first line point closer to the point passed. |
-1 | If no line point is closer to passed in point. |
Return index of closest segment.
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. |
int AssociationLine::count | ( | ) | const |
Returns the amount of POINTS on the line. Includes start and end points.
|
staticprivate |
Returns a Bézier path from given points.
points | points which define the Bézier curve |
|
private |
Constructs the open arrow symbol and arrow line, that would represent Collaboration line.
|
staticprivate |
Returns an orthogonal path constructed of vertical and horizontal segments through the given points.
points | base points for the path |
|
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.
|
private |
Constructs a new subset symbol.
void AssociationLine::dumpPoints | ( | ) |
Debug helper method to write out the points.
bool AssociationLine::enableAutoLayout | ( | ) |
QPointF AssociationLine::endPoint | ( | ) | const |
Shortcut for end point.
|
static |
Convert string to enum LayoutType.
void AssociationLine::hoverEnterEvent | ( | QGraphicsSceneHoverEvent * | event | ) |
Calculates the "to be highlighted" point and segment indices and updates if necessary.
void AssociationLine::hoverLeaveEvent | ( | QGraphicsSceneHoverEvent * | event | ) |
Reset active indices and updates.
void AssociationLine::hoverMoveEvent | ( | QGraphicsSceneHoverEvent * | event | ) |
Calculates the "to be highlighted" point and segment indices and updates if necessary.
Inserts the passed in point at the index passed in and recalculates the bounding rect.
bool AssociationLine::isAutoLayouted | ( | ) | const |
Retval True If point at index is start or end.
Retval True If segment at index is start or end.
Uml::LayoutType::Enum AssociationLine::layout | ( | ) | const |
Return the layout type of the association line.
bool AssociationLine::loadFromXMI | ( | QDomElement & | qElement | ) |
Loads AssociationLine information saved in qElement XMI element.
void AssociationLine::mouseMoveEvent | ( | QGraphicsSceneMouseEvent * | event | ) |
Moves the point or line if active.
void AssociationLine::mousePressEvent | ( | QGraphicsSceneMouseEvent * | event | ) |
Determines the active point or segment, the latter being given more priority.
void AssociationLine::mouseReleaseEvent | ( | QGraphicsSceneMouseEvent * | event | ) |
Reset active indices and also push undo command.
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.
|
virtual |
Reimplemented from QGraphicsItem::paint. Draws the AssociationLine and also takes care of highlighting active point or line.
QPainterPath AssociationLine::path | ( | ) | const |
QPen AssociationLine::pen | ( | ) | const |
Returns the pen used for drawing.
Returns the point at the point index.
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.
|
private |
Removes collaboration line by deleting the head and line item.
Removes the point at index passed in.
|
private |
Removes the subset symbol if it existed by deleting appropriate items.
void AssociationLine::saveToXMI | ( | QXmlStreamWriter & | writer | ) |
Saves association line information into XMI element named "linepath".
Sets the start and end points.
|
private |
Sets the Symbol to appear at the last line segment to symbol.
If symbol == Symbol::None , then it deletes the symbol item.
void AssociationLine::setLayout | ( | Uml::LayoutType::Enum | layout | ) |
Set the layout type of the association line.
layout | the desired layout to set |
Sets the point value at given index to point.
|
private |
Sets the Symbol to appear at the first line segment to symbol.
If symbol == Symbol::None , then it deletes the symbol item.
QPainterPath AssociationLine::shape | ( | ) | const |
QPointF AssociationLine::startPoint | ( | ) | const |
Shortcut for point(0).
|
static |
Convert enum LayoutType to string.
void AssociationLine::updatePenStyle | ( | ) |
Update pen style depending on the association type of the related AssociationWidget instance.
default delta for fuzzy recognition of points closer to point
|
private |
index of active point which can be dragged to modify association line
|
private |
index of active segment
|
private |
association widget which this line represents
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
arrow head drawn at end of m_collaborationLineItem
|
private |
parallel arrow line drawn in case of collaboration message
|
private |
symbol drawn at the end of "last" line segment
|
private |
|
private |
pen used to draw an association line
|
private |
points representing the association line
|
private |
symbol drawn at the end of "first" line segment
|
private |
subset symbol
radius of circles drawn to show "selection"
minimum height for self association's loop