libs/flake
KoPathShape Class Reference
This is the base for all graphical objects. More...
#include <KoPathShape.h>

Public Member Functions | |
| KoPathShape () | |
| virtual | ~KoPathShape () |
| bool | addSubpath (KoSubpath *subpath, int subpathIndex) |
| KoPathPoint * | arcTo (qreal rx, qreal ry, qreal startAngle, qreal sweepAngle) |
| virtual QRectF | boundingRect () const |
| bool | breakAfter (const KoPathPointIndex &pointIndex) |
| void | clear () |
| void | close () |
| void | closeMerge () |
| KoPathPointIndex | closeSubpath (const KoPathPointIndex &pointIndex) |
| bool | combine (KoPathShape *path) |
| KoPathPoint * | curveTo (const QPointF &c, const QPointF &p) |
| KoPathPoint * | curveTo (const QPointF &c1, const QPointF &c2, const QPointF &p) |
| void | debugPath () |
| Qt::FillRule | fillRule () const |
| virtual bool | hitTest (const QPointF &position) const |
| bool | insertPoint (KoPathPoint *point, const KoPathPointIndex &pointIndex) |
| bool | isClosedSubpath (int subpathIndex) |
| bool | join (int subpathIndex) |
| KoPathPoint * | lineTo (const QPointF &p) |
| virtual bool | loadOdf (const KoXmlElement &element, KoShapeLoadingContext &context) |
| bool | moveSubpath (int oldSubpathIndex, int newSubpathIndex) |
| KoPathPoint * | moveTo (const QPointF &p) |
| virtual QPointF | normalize () |
| KoPathPointIndex | openSubpath (const KoPathPointIndex &pointIndex) |
| virtual QPainterPath | outline () const |
| virtual void | paint (QPainter &painter, const KoViewConverter &converter) |
| virtual void | paintPoints (QPainter &painter, const KoViewConverter &converter, int handleRadius) |
| KoPathPointIndex | pathPointIndex (const KoPathPoint *point) const |
| virtual QString | pathShapeId () const |
| KoPathPoint * | pointByIndex (const KoPathPointIndex &pointIndex) const |
| int | pointCount () const |
| int | pointCountSubpath (int subpathIndex) const |
| QList< KoPathPoint * > | pointsAt (const QRectF &r) |
| KoPathPoint * | removePoint (const KoPathPointIndex &pointIndex) |
| KoSubpath * | removeSubpath (int subpathIndex) |
| bool | reverseSubpath (int subpathIndex) |
| virtual void | saveOdf (KoShapeSavingContext &context) const |
| KoPathSegment | segmentByIndex (const KoPathPointIndex &pointIndex) const |
| QList< KoPathSegment > | segmentsAt (const QRectF &r) |
| bool | separate (QList< KoPathShape * > &separatedPaths) |
| void | setFillRule (Qt::FillRule fillRule) |
| virtual void | setSize (const QSizeF &size) |
| virtual QSizeF | size () const |
| int | subpathCount () const |
| QString | toString (const QMatrix &matrix) const |
Static Public Member Functions | |
| static KoPathShape * | fromQPainterPath (const QPainterPath &path) |
Protected Member Functions | |
| KoPathShape (KoPathShapePrivate &) | |
| void | applyViewboxTransformation (const KoXmlElement &element) |
| int | arcToCurve (qreal rx, qreal ry, qreal startAngle, qreal sweepAngle, const QPointF &offset, QPointF *curvePoints) const |
| QRectF | handleRect (const QPointF &p, qreal radius) const |
| void | loadNodeTypes (const KoXmlElement &element) |
| QRectF | loadOdfViewbox (const KoXmlElement &element) const |
| QString | nodeTypes () const |
| QMatrix | resizeMatrix (const QSizeF &newSize) const |
Protected Attributes | |
| KoSubpathList | m_subpaths |
Detailed Description
This is the base for all graphical objects.
All graphical objects are based on this object e.g. lines, rectangulars, pies and so on.
The KoPathShape uses KoPathPoint's to describe the path of the shape.
Here a short example: 3 points connected by a curveTo's described by the following svg: M 100,200 C 100,100 250,100 250,200 C 250,200 400,300 400,200.
This will be stored in 3 KoPathPoint's as The first point contains in point 100,200 controlPoint2 100,100 The second point contains in point 250,200 controlPoint1 250,100 controlPoint2 250,300 The third point contains in point 400,300 controlPoint1 400,200
Not the segments are stored but the points. Out of the points the segments are generated. See the outline method. The reason for storing it like that is that it is the points that are modified by the user and not the segments.
Definition at line 74 of file KoPathShape.h.
Constructor & Destructor Documentation
| KoPathShape::KoPathShape | ( | ) |
constructor
Definition at line 53 of file KoPathShape.cpp.
| KoPathShape::~KoPathShape | ( | ) | [virtual] |
Definition at line 63 of file KoPathShape.cpp.
| KoPathShape::KoPathShape | ( | KoPathShapePrivate & | dd | ) | [protected] |
constructor
Definition at line 58 of file KoPathShape.cpp.
Member Function Documentation
| bool KoPathShape::addSubpath | ( | KoSubpath * | subpath, | |
| int | subpathIndex | |||
| ) |
Adds a subpath at the given index to the path.
- Parameters:
-
subpath the subpath to add subpathIndex the index at which the new subpath should be inserted
- Returns:
- true on success, false otherwise e.g. subpathIndex out of bounds
Definition at line 991 of file KoPathShape.cpp.
| void KoPathShape::applyViewboxTransformation | ( | const KoXmlElement & | element | ) | [protected] |
Applies the viewbox transformation defined in the given element.
Definition at line 186 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::arcTo | ( | qreal | rx, | |
| qreal | ry, | |||
| qreal | startAngle, | |||
| qreal | sweepAngle | |||
| ) |
Add an arc.
Adds an arc starting at the current point. The arc will be converted to bezier curves.
- Parameters:
-
rx x radius of the ellipse ry y radius of the ellipse startAngle the angle where the arc will be started sweepAngle the length of the angle TODO add param to have angle of the ellipse
- Returns:
- The newly created point
Definition at line 472 of file KoPathShape.cpp.
| int KoPathShape::arcToCurve | ( | qreal | rx, | |
| qreal | ry, | |||
| qreal | startAngle, | |||
| qreal | sweepAngle, | |||
| const QPointF & | offset, | |||
| QPointF * | curvePoints | |||
| ) | const [protected] |
Add an arc.
Adds an arc starting at the current point. The arc will be converted to bezier curves.
- Parameters:
-
rx x radius of the ellipse ry y radius of the ellipse startAngle the angle where the arc will be started sweepAngle the length of the angle TODO add param to have angle of the ellipse offset to the first point in the arc curvePoints a array which take the cuve points, pass a 'QPointF curvePoins[12]';
- Returns:
- number of points created by the curve
Definition at line 494 of file KoPathShape.cpp.
| QRectF KoPathShape::boundingRect | ( | ) | const [virtual] |
| bool KoPathShape::breakAfter | ( | const KoPathPointIndex & | pointIndex | ) |
Breaks the path after the point index.
The new subpath will be behind the one that was broken. The segment between the given point and the one behind will be removed. If you want to split at one point insert first a copy of the point behind it. This does not work when the subpath is closed. Use openSubpath for this. It does not break at the last position of a subpath or if there is only one point in the subpath.
- Parameters:
-
pointIndex index of the point after which the path should be broken
- Returns:
- true if the subpath was broken, otherwise false
Definition at line 827 of file KoPathShape.cpp.
| void KoPathShape::clear | ( | ) |
Removes all subpaths and their points from the path.
Definition at line 212 of file KoPathShape.cpp.
| void KoPathShape::close | ( | ) |
Closes the current subpath.
Definition at line 554 of file KoPathShape.cpp.
| void KoPathShape::closeMerge | ( | ) |
Closes the current subpath.
It tries to merge the last and first point of the subpath to one point and then closes the subpath. If merging is not possible as the two point are to far from each other a close will be done. TODO define a maximum distance between the two points until this is working
Definition at line 562 of file KoPathShape.cpp.
| KoPathPointIndex KoPathShape::closeSubpath | ( | const KoPathPointIndex & | pointIndex | ) |
Close a open subpath.
The subpath is closed be inserting a segment between the start and end point, making the given point the new start point of the subpath.
- Returns:
- the new position of the old first point in the subpath otherwise KoPathPointIndex( -1, -1 )
Definition at line 921 of file KoPathShape.cpp.
| bool KoPathShape::combine | ( | KoPathShape * | path | ) |
Combines two path shapes by appending the data of the specified path.
- Parameters:
-
path the path to combine with
- Returns:
- true if combining was successful, else false
Definition at line 1001 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::curveTo | ( | const QPointF & | c, | |
| const QPointF & | p | |||
| ) |
Adds a new quadratic Bezier curve segment.
Adds a quadratic Bezier curve between the last point and the given point p, using the control point specified by c.
- Parameters:
-
c control point p the endpoint of this curve segment
- Returns:
- The newly created point
Definition at line 458 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::curveTo | ( | const QPointF & | c1, | |
| const QPointF & | c2, | |||
| const QPointF & | p | |||
| ) |
Adds a new cubic Bezier curve segment.
Adds a cubic Bezier curve between the last point and the given point p, using the control points specified by c1 and c2.
- Parameters:
-
c1 control point1 c2 control point2 p the endpoint of this curve segment
- Returns:
- The newly created point
Definition at line 444 of file KoPathShape.cpp.
| void KoPathShape::debugPath | ( | ) |
print debug information about a the points of the path
Definition at line 272 of file KoPathShape.cpp.
| Qt::FillRule KoPathShape::fillRule | ( | ) | const |
Returns the fill rule for the path object.
Definition at line 1236 of file KoPathShape.cpp.
| KoPathShape * KoPathShape::fromQPainterPath | ( | const QPainterPath & | path | ) | [static] |
Creates path shape from given QPainterPath.
Definition at line 1248 of file KoPathShape.cpp.
Definition at line 299 of file KoPathShape.cpp.
| bool KoPathShape::hitTest | ( | const QPointF & | position | ) | const [virtual] |
reimplemented
Reimplemented from KoShape.
Reimplemented in KoConnectionShape.
Definition at line 1276 of file KoPathShape.cpp.
| bool KoPathShape::insertPoint | ( | KoPathPoint * | point, | |
| const KoPathPointIndex & | pointIndex | |||
| ) |
Inserts a new point into the given subpath at the specified position.
This method keeps the subpath closed if it is closed, and open when it was open. So it can change the properties of the point inserted. You might need to update the point before/after to get the desired result e.g. when you insert the point into a curve.
- Parameters:
-
point to insert pointIndex index at which the point should be inserted
- Returns:
- true on success, false when pointIndex is out of bounds
Definition at line 754 of file KoPathShape.cpp.
| bool KoPathShape::isClosedSubpath | ( | int | subpathIndex | ) |
Checks if a subpath is closed.
- Parameters:
-
subpathIndex index of the subpath to check
- Returns:
- true when the subpath is closed, false otherwise
Definition at line 741 of file KoPathShape.cpp.
| bool KoPathShape::join | ( | int | subpathIndex | ) |
Joins the given subpath with the following one.
Joins the given subpath with the following one by inserting a segment between the two subpathes. This does nothing if the specified subpath is the last subpath or one of both subpaths is closed.
- Parameters:
-
subpathIndex index of the subpath being joined with the following subpath
- Returns:
- true if the subpath was joined, otherwise false
Definition at line 852 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::lineTo | ( | const QPointF & | p | ) |
Adds a new line segment.
Adds a straight line between the last point and the given point p.
- Returns:
- the newly created point
Definition at line 432 of file KoPathShape.cpp.
| void KoPathShape::loadNodeTypes | ( | const KoXmlElement & | element | ) | [protected] |
Loads node types.
Definition at line 1207 of file KoPathShape.cpp.
| bool KoPathShape::loadOdf | ( | const KoXmlElement & | element, | |
| KoShapeLoadingContext & | context | |||
| ) | [virtual] |
Load a shape from odf.
- Parameters:
-
context the KoShapeLoadingContext used for loading element element which represents the shape in odf
- Returns:
- false if loading failed
Implements KoShape.
Reimplemented in KoConnectionShape.
Definition at line 80 of file KoPathShape.cpp.
| QRectF KoPathShape::loadOdfViewbox | ( | const KoXmlElement & | element | ) | const [protected] |
Returns the viewbox from the given xml element.
Definition at line 169 of file KoPathShape.cpp.
| bool KoPathShape::moveSubpath | ( | int | oldSubpathIndex, | |
| int | newSubpathIndex | |||
| ) |
Moves the position of a subpath within a path.
- Parameters:
-
oldSubpathIndex old index of the subpath newSubpathIndex new index of the subpath
- Returns:
- true if the subpath was moved, otherwise false e.g. if an index is out of bounds
Definition at line 879 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::moveTo | ( | const QPointF & | p | ) |
Starts a new Subpath.
Moves the pen to p and starts a new subpath.
- Returns:
- the newly created point
Definition at line 423 of file KoPathShape.cpp.
| QString KoPathShape::nodeTypes | ( | ) | const [protected] |
Saves the node types.
This is inspired by inkscape and uses the same mechanism as they do. The only difference is that they use sodipodi:nodeTypes as element and we use koffice:nodeTyes as attribute. This attribute contains of a string which has the node type of each point in it. The following node types exist:
c corner s smooth z symetric
The first point of a path is always of the type c. If the path is closed the type of the first point is saved in the last elemeent E.g. you have a closed path with 2 points in it. The first one (start/end of path) is symetric and the second one is smooth that will result in the nodeType="czs" So if there is a closed sub path the nodeTypes contain one more entry then there are points. That is due to the first and the last pojnt of a closed sub path get merged into one when they are on the same position.
- Returns:
- The node types as string
Definition at line 1173 of file KoPathShape.cpp.
| QPointF KoPathShape::normalize | ( | ) | [virtual] |
Normalizes the path data.
The path points are transformed so that the top-left corner of the bounding rect is at (0,0). This should be called after adding points to the path or changing positions of path points.
- Returns:
- the offset by which the points are moved in shape coordinates.
Reimplemented in KoParameterShape.
Definition at line 570 of file KoPathShape.cpp.
| KoPathPointIndex KoPathShape::openSubpath | ( | const KoPathPointIndex & | pointIndex | ) |
Opens a closed subpath.
The subpath is opened by removing the segment before the given point, making the given point the new start point of the subpath.
- Parameters:
-
pointIndex the index of the point at which to open the closed subpath
- Returns:
- the new position of the old first point in the subpath otherwise KoPathPointIndex( -1, -1 )
Definition at line 895 of file KoPathShape.cpp.
| QPainterPath KoPathShape::outline | ( | ) | const [virtual] |
| void KoPathShape::paint | ( | QPainter & | painter, | |
| const KoViewConverter & | converter | |||
| ) | [virtual] |
reimplemented
Implements KoShape.
Reimplemented in KoConnectionShape.
Definition at line 222 of file KoPathShape.cpp.
| void KoPathShape::paintPoints | ( | QPainter & | painter, | |
| const KoViewConverter & | converter, | |||
| int | handleRadius | |||
| ) | [virtual] |
Definition at line 284 of file KoPathShape.cpp.
| KoPathPointIndex KoPathShape::pathPointIndex | ( | const KoPathPoint * | point | ) | const |
Returns the path point index of a given path point.
- Parameters:
-
point the point for which you want to get the index
- Returns:
- path point index of the point if it exists otherwise KoPathPointIndex( -1, -1 )
Definition at line 670 of file KoPathShape.cpp.
| QString KoPathShape::pathShapeId | ( | ) | const [virtual] |
Returns the specific path shape id.
Path shape derived shapes have a different shape id which link them to their respective shape factories. In most cases they do not have a special tool for editing them. This function returns the specific shape id for finding the shape factory from KoShapeRegistry. The default KoPathShapeId is returned from KoShape::shapeId() so that the generic path editing tool gets activated when the shape is selected.
- Returns:
- the specific shape id
Reimplemented in KoConnectionShape.
Definition at line 1097 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::pointByIndex | ( | const KoPathPointIndex & | pointIndex | ) | const |
Returns the path point specified by a path point index.
- Parameters:
-
pointIndex index of the point to get
- Returns:
- KoPathPoint on success, 0 otherwise e.g. out of bounds
Definition at line 683 of file KoPathShape.cpp.
| int KoPathShape::pointCount | ( | ) | const |
Returns the number of points in the path.
- Returns:
- The number of points in the path
Definition at line 715 of file KoPathShape.cpp.
| int KoPathShape::pointCountSubpath | ( | int | subpathIndex | ) | const |
Returns the number of points in a subpath.
- Returns:
- The number of points in the subpath or -1 if subpath out of bounds
Definition at line 731 of file KoPathShape.cpp.
| QList< KoPathPoint * > KoPathShape::pointsAt | ( | const QRectF & | r | ) |
Returns the path points within the given rectangle.
- Parameters:
-
r the rectangle the requested points are in
- Returns:
- list of points within the rectangle
Definition at line 626 of file KoPathShape.cpp.
| KoPathPoint * KoPathShape::removePoint | ( | const KoPathPointIndex & | pointIndex | ) |
Removes a point from the path.
Note that the ownership of the point will pass to the caller.
- Parameters:
-
pointIndex index of the point which should be removed
- Returns:
- The removed point on success, otherwise 0
Definition at line 794 of file KoPathShape.cpp.
| KoSubpath * KoPathShape::removeSubpath | ( | int | subpathIndex | ) |
Removes subpath from the path.
- Parameters:
-
subpathIndex the index of the subpath to remove
- Returns:
- the removed subpath on succes, 0 otherwise.
Definition at line 981 of file KoPathShape.cpp.
Get the resize matrix.
This makes sure that also if the newSize isNull that there will be a very small size of 0.000001 pixels
Definition at line 402 of file KoPathShape.cpp.
| bool KoPathShape::reverseSubpath | ( | int | subpathIndex | ) |
Reverse subpath.
The last point becomes the first point and the first one becomes the last one.
- Parameters:
-
subpathIndex the index of the subpath to reverse
Definition at line 946 of file KoPathShape.cpp.
| void KoPathShape::saveOdf | ( | KoShapeSavingContext & | context | ) | const [virtual] |
store the shape data as ODF XML.
This is the method that will be called when saving a shape as a described in OpenDocument 9.2 Drawing Shapes.
- See also:
- saveOdfAttributes
Implements KoShape.
Reimplemented in KoConnectionShape.
Definition at line 68 of file KoPathShape.cpp.
| KoPathSegment KoPathShape::segmentByIndex | ( | const KoPathPointIndex & | pointIndex | ) | const |
Returns the segment specified by a path point index.
A semgent is defined by the point index of the first point in the segment. A segment contains the defined point and its following point. If the subpath is closed and the and the pointIndex point to the last point in the subpath, the following point is the first point in the subpath.
- Parameters:
-
pointIndex index of the first point of the segment
- Returns:
- Segment containing both points of the segment or KoPathSegment( 0, 0 ) on error e.g. out of bounds
Definition at line 693 of file KoPathShape.cpp.
| QList< KoPathSegment > KoPathShape::segmentsAt | ( | const QRectF & | r | ) |
Returns the list of path segments within the given rectangle.
- Parameters:
-
r the rectangle the requested segments are in
- Returns:
- list of segments within the rectangle
Definition at line 645 of file KoPathShape.cpp.
| bool KoPathShape::separate | ( | QList< KoPathShape * > & | separatedPaths | ) |
Creates separate path shapes, one for each existing subpath.
- Parameters:
-
separatedPaths the list which contains the separated path shapes
- Returns:
- true if separating the path was successful, false otherwise
Definition at line 1025 of file KoPathShape.cpp.
| void KoPathShape::setFillRule | ( | Qt::FillRule | fillRule | ) |
Sets the fill rule to be used for painting the background.
Definition at line 1242 of file KoPathShape.cpp.
| void KoPathShape::setSize | ( | const QSizeF & | size | ) | [virtual] |
Resize the shape.
This makes sure that the pathshape will not be resized to 0 if the new size is null as that makes it impossible to undo the change.
All functions that overwrite this function should also use the resizeMatrix function to get and use the same data in resizing.
- See also:
- resizeMatrix()
Reimplemented from KoShape.
Reimplemented in KoParameterShape.
Definition at line 394 of file KoPathShape.cpp.
| QSizeF KoPathShape::size | ( | ) | const [virtual] |
| int KoPathShape::subpathCount | ( | ) | const |
Returns the number of subpaths in the path.
- Returns:
- The number of subpaths in the path
Definition at line 726 of file KoPathShape.cpp.
Returns a odf/svg string represenatation of the path data with the given matrix applied.
Definition at line 1102 of file KoPathShape.cpp.
Member Data Documentation
KoSubpathList KoPathShape::m_subpaths [protected] |
Definition at line 535 of file KoPathShape.h.
The documentation for this class was generated from the following files:
