umbrello/umbrello
#include <associationline.h>
Public Types | |
enum | LayoutType { Direct = 1, Orthogonal, Polyline, Spline } |
Public Member Functions | |
AssociationLine (AssociationWidget *association) | |
virtual | ~AssociationLine () |
QRectF | boundingRect () const |
QBrush | brush () const |
void | calculateInitialEndPoints () |
void | cleanup () |
int | closestPointIndex (const QPointF &point, qreal delta=Delta) const |
int | closestSegmentIndex (const QPointF &point, qreal delta=Delta) const |
int | count () const |
void | dumpPoints () |
QPointF | endPoint () const |
void | hoverEnterEvent (QGraphicsSceneHoverEvent *event) |
void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) |
void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) |
void | insertPoint (int index, const QPointF &point) |
bool | isEndPointIndex (int index) const |
bool | isEndSegmentIndex (int index) const |
LayoutType | layout () const |
bool | loadFromXMI (QDomElement &qElement) |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) |
void | optimizeLinePoints () |
virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
QPainterPath | path () const |
QPen | pen () const |
QPointF | point (int index) const |
void | reconstructSymbols () |
void | removePoint (int index) |
void | saveToXMI (QDomDocument &qDoc, QDomElement &qElement) |
bool | setEndPoints (const QPointF &start, const QPointF &end) |
void | setLayout (LayoutType layout) |
bool | setPoint (int index, const QPointF &point) |
QPainterPath | shape () const |
QPointF | startPoint () const |
Static Public Member Functions | |
static LayoutType | fromString (const QString &layout) |
static QString | toString (LayoutType layout) |
Detailed Description
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!
Definition at line 105 of file associationline.h.
Member Enumeration Documentation
Enumerator | |
---|---|
Direct | |
Orthogonal | |
Polyline | |
Spline |
Definition at line 110 of file associationline.h.
Constructor & Destructor Documentation
|
explicit |
Constructor.
Constructs an AssociationLine item with its parent being parent.
Definition at line 38 of file associationline.cpp.
|
virtual |
Destructor.
Definition at line 59 of file associationline.cpp.
Member Function Documentation
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.
Definition at line 715 of file associationline.cpp.
QBrush AssociationLine::brush | ( | ) | const |
Returns the type of brush to use depending on the type of Association.
Definition at line 375 of file associationline.cpp.
void AssociationLine::calculateInitialEndPoints | ( | ) |
This method simply ensures presence of two points and adds the needed points for self associations.
Definition at line 413 of file associationline.cpp.
void AssociationLine::cleanup | ( | ) |
Removes all the points and signals a geometry update.
Definition at line 145 of file associationline.cpp.
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.
Definition at line 185 of file associationline.cpp.
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.
- Return values
-
Index of the line segment closest to the point passed. -1 If no line segment is closer to passed in point.
Definition at line 211 of file associationline.cpp.
int AssociationLine::count | ( | ) | const |
Returns the amount of POINTS on the line.
Includes start and end points.
- Returns
- number of points in the AssociationLine
Definition at line 137 of file associationline.cpp.
void AssociationLine::dumpPoints | ( | ) |
Debug helper method to write out the points.
Definition at line 284 of file associationline.cpp.
QPointF AssociationLine::endPoint | ( | ) | const |
Shortcut for end point.
Definition at line 105 of file associationline.cpp.
|
static |
Convert string to enum LayoutType.
Definition at line 746 of file associationline.cpp.
void AssociationLine::hoverEnterEvent | ( | QGraphicsSceneHoverEvent * | event | ) |
Calculates the "to be highlighted" point and segment indicies and updates if necessary.
Definition at line 1050 of file associationline.cpp.
void AssociationLine::hoverLeaveEvent | ( | QGraphicsSceneHoverEvent * | event | ) |
Reset active indicies and updates.
Definition at line 1096 of file associationline.cpp.
void AssociationLine::hoverMoveEvent | ( | QGraphicsSceneHoverEvent * | event | ) |
Calculates the "to be highlighted" point and segment indicies and updates if necessary.
Definition at line 1074 of file associationline.cpp.
void AssociationLine::insertPoint | ( | int | index, |
const QPointF & | point | ||
) |
Inserts the passed in point at the index passed in and recalculates the bounding rect.
Definition at line 114 of file associationline.cpp.
bool AssociationLine::isEndPointIndex | ( | int | index | ) | const |
Retval True If point at index is start or end.
Definition at line 235 of file associationline.cpp.
bool AssociationLine::isEndSegmentIndex | ( | int | index | ) | const |
Retval True If segment at index is start or end.
Definition at line 246 of file associationline.cpp.
AssociationLine::LayoutType AssociationLine::layout | ( | ) | const |
Return the layout type of the association line.
- Returns
- the currently used layout
Definition at line 761 of file associationline.cpp.
bool AssociationLine::loadFromXMI | ( | QDomElement & | qElement | ) |
Loads AssociationLine information saved in qElement XMI element.
Definition at line 295 of file associationline.cpp.
void AssociationLine::mouseMoveEvent | ( | QGraphicsSceneMouseEvent * | event | ) |
Moves the point or line if active.
Definition at line 1020 of file associationline.cpp.
void AssociationLine::mousePressEvent | ( | QGraphicsSceneMouseEvent * | event | ) |
Determines the active point or segment, the latter being given more priority.
Definition at line 996 of file associationline.cpp.
void AssociationLine::mouseReleaseEvent | ( | QGraphicsSceneMouseEvent * | event | ) |
Reset active indices and also push undo command.
Definition at line 1038 of file associationline.cpp.
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.
Definition at line 161 of file associationline.cpp.
|
virtual |
Reimplemented from QGraphicsItem::paint.
Draws the AssociationLine and also takes care of highlighting active point or line.
Definition at line 891 of file associationline.cpp.
QPainterPath AssociationLine::path | ( | ) | const |
- Returns
- The path of the AssociationLine.
Definition at line 679 of file associationline.cpp.
QPen AssociationLine::pen | ( | ) | const |
Returns the type of pen to use depending on the type of Association.
Definition at line 393 of file associationline.cpp.
QPointF AssociationLine::point | ( | int | index | ) | const |
Returns the point at the point index.
- Returns
- point at given index
Definition at line 67 of file associationline.cpp.
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.
Definition at line 452 of file associationline.cpp.
void AssociationLine::removePoint | ( | int | index | ) |
Removes the point at index passed in.
- See also
- removeNonEndPoint
Definition at line 125 of file associationline.cpp.
void AssociationLine::saveToXMI | ( | QDomDocument & | qDoc, |
QDomElement & | qElement | ||
) |
Saves association line information into XMI element named "linepath".
- Note
- Stored as linepath for backwared compatibility
Definition at line 348 of file associationline.cpp.
bool AssociationLine::setEndPoints | ( | const QPointF & | start, |
const QPointF & | end | ||
) |
Sets the start and end points.
Definition at line 258 of file associationline.cpp.
void AssociationLine::setLayout | ( | LayoutType | layout | ) |
Set the layout type of the association line.
- Parameters
-
layout the desired layout to set
Definition at line 770 of file associationline.cpp.
bool AssociationLine::setPoint | ( | int | index, |
const QPointF & | point | ||
) |
Sets the point value at given index to point.
Definition at line 79 of file associationline.cpp.
QPainterPath AssociationLine::shape | ( | ) | const |
- Returns
- The shape of the AssociationLine.
Definition at line 727 of file associationline.cpp.
QPointF AssociationLine::startPoint | ( | ) | const |
Shortcut for point(0).
Definition at line 97 of file associationline.cpp.
|
static |
Convert enum LayoutType to string.
Definition at line 738 of file associationline.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:06:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.