Krita Source Code Documentation
Loading...
Searching...
No Matches
EnhancedPathShape Class Reference

#include <EnhancedPathShape.h>

+ Inheritance diagram for EnhancedPathShape:

Public Member Functions

void addCommand (const QString &command)
 Add command for instance "M 0 0".
 
void addFormula (const QString &name, const QString &formula)
 Add formula with given name and textual representation.
 
void addHandle (const QMap< QString, QVariant > &handle)
 Add a single handle with format: x y minX maxX minY maxY.
 
void addModifiers (const QString &modifiers)
 Add modifiers with format: modifier0 modifier1 modifier2 ...
 
KoShapecloneShape () const override
 creates a deep copy of the shape or shape's subtree
 
 EnhancedPathShape (const QRect &viewBox)
 
qreal evaluateConstantOrReference (const QString &val)
 
qreal evaluateReference (const QString &reference)
 
void modifyReference (const QString &reference, qreal value)
 
QPointF normalize () override
 Normalizes the path data.
 
EnhancedPathParameterparameter (const QString &text)
 Returns parameter from given textual representation.
 
void setMirrorHorizontally (bool mirrorHorizontally)
 Sets if the shape is to be mirrored horizontally before applying any other transformations.
 
void setMirrorVertically (bool mirrorVertically)
 Sets if the shape is to be mirrored vertically before applying any other transformations.
 
void setPathStretchPointX (qreal pathStretchPointX)
 
void setPathStretchPointY (qreal pathStretchPointY)
 
void setSize (const QSizeF &newSize) override
 Resize the shape.
 
QPointF shapeToViewbox (const QPointF &point) const
 Converts from shape coordinates to viewbox coordinates.
 
QRect viewBox () const
 Returns the viewbox of the enhanced path shape.
 
 ~EnhancedPathShape () override
 
- Public Member Functions inherited from KoParameterShape
int handleCount () const
 return the number of handles set on the shape
 
int handleIdAt (const QRectF &rect) const
 Get the id of the handle within the given rect.
 
QPointF handlePosition (int handleId) const
 Get the handle position.
 
bool isParametricShape () const
 Check if object is a parametric shape.
 
 KoParameterShape ()
 
void moveHandle (int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
 Move handle to point.
 
QPointF normalize () override
 Normalizes the path data.
 
void paintHandle (KisHandlePainterHelper &handlesHelper, int handleId)
 Paint the given handles.
 
void paintHandles (KisHandlePainterHelper &handlesHelper)
 Paint the handles.
 
 Private ()
 
 Private (const KoParameterShape::Private &rhs)
 
void setParametricShape (bool parametric)
 Set if the shape can be modified using parameters.
 
void setSize (const QSizeF &size) override
 reimplemented from KoShape
 
 ~KoParameterShape () override
 
virtual ~Private ()=default
 
- Public Member Functions inherited from KoPathShape
bool addSubpath (KoSubpath *subpath, int subpathIndex)
 Adds a subpath at the given index to the path.
 
KoPathPointarcTo (qreal rx, qreal ry, qreal startAngle, qreal sweepAngle)
 Add an arc.
 
bool autoFillMarkers () const
 
QRectF boundingRect () const override
 reimplemented
 
bool breakAfter (const KoPathPointIndex &pointIndex)
 Breaks the path after the point index.
 
void clear ()
 Removes all subpaths and their points from the path.
 
KoShapecloneShape () const override
 creates a deep copy of the shape or shape's subtree
 
void close ()
 Closes the current subpath.
 
void closeMerge ()
 Closes the current subpath.
 
KoPathPointIndex closeSubpath (const KoPathPointIndex &pointIndex)
 Close a open subpath.
 
int combine (KoPathShape *path)
 Combines two path shapes by appending the data of the specified path.
 
KoPathPointcurveTo (const QPointF &c, const QPointF &p)
 Adds a new quadratic Bezier curve segment.
 
KoPathPointcurveTo (const QPointF &c1, const QPointF &c2, const QPointF &p)
 Adds a new cubic Bezier curve segment.
 
Qt::FillRule fillRule () const
 Returns the fill rule for the path object.
 
bool hasMarkers () const
 
bool hitTest (const QPointF &position) const override
 reimplemented
 
bool insertPoint (KoPathPoint *point, const KoPathPointIndex &pointIndex)
 Inserts a new point into the given subpath at the specified position.
 
bool isClosedSubpath (int subpathIndex) const
 Checks if a subpath is closed.
 
bool join (int subpathIndex)
 Joins the given subpath with the following one.
 
 KoPathShape ()
 constructor
 
KoPathPointlineTo (const QPointF &p)
 Adds a new line segment.
 
void loadNodeTypes (const QString &nodeTypes)
 Loads node types.
 
KoMarkermarker (KoFlake::MarkerPosition pos) const
 
bool moveSubpath (int oldSubpathIndex, int newSubpathIndex)
 Moves the position of a subpath within a path.
 
KoPathPointmoveTo (const QPointF &p)
 Starts a new Subpath.
 
QString nodeTypes () const
 Saves the node types.
 
KoPathPointIndex openSubpath (const KoPathPointIndex &pointIndex)
 Opens a closed subpath.
 
QPainterPath outline () const override
 reimplemented
 
QRectF outlineRect () const override
 reimplemented
 
void paint (QPainter &painter) const override
 reimplemented
 
virtual void paintPoints (KisHandlePainterHelper &handlesHelper)
 
KoPathPointIndex pathPointIndex (const KoPathPoint *point) const
 Returns the path point index of a given path point.
 
virtual QString pathShapeId () const
 
QPainterPath pathStroke (const QPen &pen) const
 
KoPathPointpointByIndex (const KoPathPointIndex &pointIndex) const
 Returns the path point specified by a path point index.
 
int pointCount () const
 Returns the number of points in the path.
 
QList< KoPathPoint * > pointsAt (const QRectF &rect, const bool useControlPoints=false) const
 Returns the path points within the given rectangle.
 
void recommendPointSelectionChange (const QList< KoPathPointIndex > &newSelection)
 
KoPathPointremovePoint (const KoPathPointIndex &pointIndex)
 Removes a point from the path.
 
KoSubpathremoveSubpath (int subpathIndex)
 Removes subpath from the path.
 
bool reverseSubpath (int subpathIndex)
 Reverse subpath.
 
KoPathSegment segmentByIndex (const KoPathPointIndex &pointIndex) const
 Returns the segment specified by a path point index.
 
QList< KoPathSegmentsegmentsAt (const QRectF &rect) const
 Returns the list of path segments within the given rectangle.
 
bool separate (QList< KoPathShape * > &separatedPaths)
 Creates separate path shapes, one for each existing subpath.
 
void setAutoFillMarkers (bool value)
 
void setFillRule (Qt::FillRule fillRule)
 Sets the fill rule to be used for painting the background.
 
void setMarker (KoMarker *marker, KoFlake::MarkerPosition pos)
 
void setSize (const QSizeF &size) override
 
QSizeF size () const override
 reimplemented
 
int subpathCount () const
 Returns the number of subpaths in the path.
 
int subpathPointCount (int subpathIndex) const
 Returns the number of points in a subpath.
 
QString toString (const QTransform &matrix=QTransform()) const
 Returns a odf/svg string representation of the path data with the given matrix applied.
 
 ~KoPathShape () override
 
- Public Member Functions inherited from KoTosContainer
KoShapecreateTextShape (KoDocumentResourceManager *documentResources=0)
 
 KoTosContainer ()
 
virtual bool loadText (const QDomElement &element)
 
void paintComponent (QPainter &painter) const override
 Paint the component Implement this method to allow the shape to paint itself, just like the KoShape::paint() method does.
 
ResizeBehavior resizeBehavior () const
 
void setPlainText (const QString &text)
 
void setResizeBehavior (ResizeBehavior resizeBehavior)
 
void setRunThrough (short int runThrough) override
 
void setTextAlignment (Qt::Alignment alignment)
 
Qt::Alignment textAlignment () const
 
 ~KoTosContainer () override
 
- Public Member Functions inherited from KoShapeContainer
void addShape (KoShape *shape)
 
bool inheritsTransform (const KoShape *shape) const
 
bool isClipped (const KoShape *child) const
 
 KoShapeContainer (KoShapeContainerModel *model=0)
 
KoShapeContainerModelmodel () const
 
void paint (QPainter &painter) const override
 reimplemented
 
 Private (const Private &rhs, KoShapeContainer *q)
 
 Private (KoShapeContainer *q)
 
void removeShape (KoShape *shape)
 
void setClipped (const KoShape *child, bool clipping)
 
void setInheritsTransform (const KoShape *shape, bool inherit)
 
int shapeCount () const
 
ShapeInterfaceshapeInterface ()
 
QList< KoShape * > shapes () const
 
virtual void update () const
 
void update () const override
 reimplemented
 
 ~KoShapeContainer () override
 
- Public Member Functions inherited from KoShape
QRectF absoluteOutlineRect () const
 
QPointF absolutePosition (KoFlake::AnchorPosition anchor=KoFlake::Center) const
 
QTransform absoluteTransformation () const
 
bool addDependee (KoShape *shape)
 
QString additionalAttribute (const QString &name) const
 
void addShapeChangeListener (ShapeChangeListener *listener)
 
KoShapeAnchoranchor () const
 
void applyAbsoluteTransformation (const QTransform &matrix)
 
void applyTransformation (const QTransform &matrix)
 
virtual QSharedPointer< KoShapeBackgroundbackground () const
 
virtual ChildZOrderPolicy childZOrderPolicy ()
 
KoClipMaskclipMask () const
 Returns the currently set clip mask or 0 if there is no clip mask set.
 
KoClipPathclipPath () const
 Returns the currently set clip path or 0 if there is no clip path set.
 
KoShapecloneShapeAndBakeAbsoluteTransform () const
 creates a deep copy of the shape/shapes tree and bakes the absolute transform of this into the resulting shape.
 
void copySettings (const KoShape *shape)
 
QList< KoShape * > dependees () const
 Returns list of shapes depending on this shape.
 
QPointF documentToShape (const QPointF &point) const
 Transforms point from document coordinates to shape coordinates.
 
QRectF documentToShape (const QRectF &rect) const
 Transform rect from document coordinates to shape coordinates.
 
KoFilterEffectStackfilterEffectStack () const
 
bool hasAdditionalAttribute (const QString &name) const
 
bool hasCommonParent (const KoShape *shape) const
 
bool hasDependee (KoShape *shape) const
 Returns if the given shape is dependent on this shape.
 
virtual bool hasTransparency () const
 
QString hyperLink () const
 
bool inheritBackground () const
 inheritBackground shows if the shape inherits background from its parent
 
bool inheritPaintOrder () const
 inheritPaintOrder
 
bool inheritsTransformFromAny (const QList< KoShape * > ancestorsInQuestion) const
 inheritsTransformFromAny checks if the shape inherits transformation from any of the shapes listed in ancestorsInQuestion. The inheritance is checked in recursive way.
 
bool inheritStroke () const
 inheritStroke shows if the shape inherits the stroke from its parent
 
bool isContentProtected () const
 
bool isGeometryProtected () const
 
bool isPrintable () const
 
bool isSelectable () const
 
virtual bool isShapeEditable (bool recursive=true) const
 checks recursively if the shape or one of its parents is not visible or locked
 
bool isVisible (bool recursive=true) const
 
bool keepAspectRatio () const
 
 KoShape ()
 Constructor.
 
qreal minimumHeight () const
 
QString name () const
 
void notifyChanged ()
 
virtual void paintMarkers (QPainter &painter) const
 paintStroke paints the shape's markers
 
virtual QVector< PaintOrderpaintOrder () const
 paintOrder
 
virtual void paintStroke (QPainter &painter) const
 paintStroke paints the shape's stroked outline
 
KoShapeContainerparent () const
 
QPointF position () const
 Get the position of the shape in pt.
 
void removeAdditionalAttribute (const QString &name)
 
void removeAdditionalStyleAttribute (const char *name)
 
void removeDependee (KoShape *shape)
 
void removeShapeChangeListener (ShapeChangeListener *listener)
 
void rotate (qreal angle)
 Rotate the shape (relative)
 
qreal rotation () const
 
int runThrough () const
 
void scale (qreal sx, qreal sy)
 Scale the shape using the zero-point which is the top-left corner.
 
void setAbsolutePosition (const QPointF &newPosition, KoFlake::AnchorPosition anchor=KoFlake::Center)
 
void setAdditionalAttribute (const QString &name, const QString &value)
 
void setAdditionalStyleAttribute (const char *name, const QString &value)
 
void setAnchor (KoShapeAnchor *anchor)
 
virtual void setBackground (QSharedPointer< KoShapeBackground > background)
 
void setClipMask (KoClipMask *clipMask)
 Sets a new clip mask, removing the old one. The mask is owned by the shape.
 
void setClipPath (KoClipPath *clipPath)
 Sets a new clip path, removing the old one.
 
void setContentProtected (bool protect)
 
void setFilterEffectStack (KoFilterEffectStack *filterEffectStack)
 Sets the new filter effect stack, removing the old one.
 
void setGeometryProtected (bool on)
 
void setHyperLink (const QString &hyperLink)
 
void setInheritBackground (bool value)
 setInheritBackground marks a shape as inheriting the background from the parent shape. NOTE: The currently selected background is destroyed.
 
void setInheritPaintOrder (bool value)
 setInheritPaintOrder set inherit paint order.
 
void setInheritStroke (bool value)
 setInheritStroke marks a shape as inheriting the stroke from the parent shape. NOTE: The currently selected stroke is destroyed.
 
void setKeepAspectRatio (bool keepAspect)
 
void setMinimumHeight (qreal height)
 
void setName (const QString &name)
 
virtual void setPaintOrder (PaintOrder first, PaintOrder second)
 setPaintOrder set the paint order. As there's only three entries in any given paintorder, you only need to have the first and second entry to set it.
 
void setParent (KoShapeContainer *parent)
 
virtual void setPosition (const QPointF &position)
 Set the position of the shape in pt.
 
void setPrintable (bool on)
 
virtual void setResolution (qreal xRes, qreal yRes)
 
void setSelectable (bool selectable)
 
void setShadow (KoShapeShadow *shadow)
 Sets the new shadow, removing the old one.
 
void setShapeId (const QString &id)
 
virtual void setStroke (KoShapeStrokeModelSP stroke)
 
void setTextRunAroundContour (TextRunAroundContour contour)
 
void setTextRunAroundDistanceBottom (qreal distance)
 
void setTextRunAroundDistanceLeft (qreal distance)
 
void setTextRunAroundDistanceRight (qreal distance)
 
void setTextRunAroundDistanceTop (qreal distance)
 
void setTextRunAroundSide (TextRunAroundSide side, RunThroughLevel runThrough=Background)
 
void setTextRunAroundThreshold (qreal threshold)
 
void setToolDelegates (const QSet< KoShape * > &delegates)
 
void setTransformation (const QTransform &matrix)
 
void setTransparency (qreal transparency)
 
void setUserData (KoShapeUserData *userData)
 
void setVisible (bool on)
 
void setZIndex (qint16 zIndex)
 
KoShapeShadowshadow () const
 Returns the currently set shadow or 0 if there is no shadow set.
 
virtual QPainterPath shadowOutline () const
 
QString shapeId () const
 
QPointF shapeToDocument (const QPointF &point) const
 Transforms point from shape coordinates to document coordinates.
 
QRectF shapeToDocument (const QRectF &rect) const
 Transforms rect from shape coordinates to document coordinates.
 
void shear (qreal sx, qreal sy)
 Shear the shape The shape will be sheared using the zero-point which is the top-left corner.
 
virtual KoSnapData snapData () const
 Returns additional snap data the shape wants to have snapping to.
 
virtual KoShapeStrokeModelSP stroke () const
 
KoInsets strokeInsets () const
 
TextRunAroundContour textRunAroundContour () const
 
qreal textRunAroundDistanceBottom () const
 
qreal textRunAroundDistanceLeft () const
 
qreal textRunAroundDistanceRight () const
 
qreal textRunAroundDistanceTop () const
 
TextRunAroundSide textRunAroundSide () const
 
qreal textRunAroundThreshold () const
 
QSet< KoShape * > toolDelegates () const
 
QTransform transformation () const
 Returns the shapes local transformation matrix.
 
qreal transparency (bool recursive=false) const
 
virtual void updateAbsolute (const QRectF &rect) const
 
KoShapeUserDatauserData () const
 
virtual void waitUntilReady (bool asynchronous=true) const
 
qint16 zIndex () const
 
virtual ~KoShape ()
 Destructor.
 

Protected Member Functions

void moveHandleAction (int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier) override
 Updates the internal state of a KoParameterShape.
 
void shapeChanged (ChangeType type, KoShape *shape=0) override
 
void updatePath (const QSizeF &size) override
 Update the path of the parameter shape.
 
- Protected Member Functions inherited from KoParameterShape
QList< QPointF > handles () const
 
 KoParameterShape (const KoParameterShape &rhs)
 constructor
 
void setHandles (const QList< QPointF > &handles)
 
- Protected Member Functions inherited from KoPathShape
int arcToCurve (qreal rx, qreal ry, qreal startAngle, qreal sweepAngle, const QPointF &offset, QPointF *curvePoints) const
 Add an arc.
 
 KoPathShape (const KoPathShape &rhs)
 
void map (const QTransform &matrix)
 
void notifyPointsChanged ()
 
QTransform resizeMatrix (const QSizeF &newSize) const
 
KoSubpathListsubpaths ()
 XXX: refactor this using setter?
 
const KoSubpathListsubpaths () const
 
- Protected Member Functions inherited from KoTosContainer
 KoTosContainer (const KoTosContainer &rhs)
 
QRectF preferredTextRect () const
 
void setPreferredTextRect (const QRectF &rect)
 
void shapeChanged (ChangeType type, KoShape *shape=0) override
 
KoShapetextShape () const
 
- Protected Member Functions inherited from KoShapeContainer
 KoShapeContainer (const KoShapeContainer &rhs)
 
void setModel (KoShapeContainerModel *model)
 
void setModelInit (KoShapeContainerModel *model)
 
virtual void shapeCountChanged ()
 
- Protected Member Functions inherited from KoShape
 KoShape (const KoShape &rhs)
 
QList< ShapeChangeListener * > listeners () const
 
void setSizeImpl (const QSizeF &size) const
 
void shapeChangedPriv (KoShape::ChangeType type)
 
QTransform transform () const
 return the current matrix that contains the rotation/scale/position of this shape
 

Private Types

typedef QMap< QString, EnhancedPathFormula * > FormulaStore
 
typedef QList< qreal > ModifierStore
 
typedef QMap< QString, EnhancedPathParameter * > ParameterStore
 

Private Member Functions

void addCommand (const QString &command, bool triggerUpdate)
 Adds a new command.
 
void enableResultCache (bool enable)
 Enables caching results.
 
 EnhancedPathShape (const EnhancedPathShape &rhs)
 
void evaluateHandles ()
 
void parsePathData (const QString &data)
 parses the enhanced path data
 
void reset ()
 
void updateTextArea ()
 Updates the size and position of an optionally existing text-on-shape text area.
 
bool useStretchPoints (const QSizeF &size, qreal &scale)
 

Private Attributes

bool m_cacheResults
 indicates if result cache is enabled
 
QList< EnhancedPathCommand * > m_commands
 the commands creating the outline
 
QList< EnhancedPathHandle * > m_enhancedHandles
 the handles for modifying the shape
 
FormulaStore m_formulae
 the formulae
 
bool m_mirrorHorizontally
 whether or not the shape is to be mirrored horizontally before transforming it
 
QTransform m_mirrorMatrix
 matrix to used for mirroring
 
bool m_mirrorVertically
 whether or not the shape is to be mirrored vertically before transforming it
 
ModifierStore m_modifiers
 the modifier values
 
ParameterStore m_parameters
 the shared parameters
 
qreal m_pathStretchPointX
 draw:path-stretchpoint-x attribute
 
qreal m_pathStretchPointY
 draw:path-stretchpoint-y attribute
 
QHash< QString, qreal > m_resultCache
 cache for intermediate results used when evaluating path
 
QStringList m_textArea
 
QRectF m_viewBound
 the bounding box of the path in viewbox coordinates
 
QRect m_viewBox
 the viewbox rectangle
 
QPointF m_viewBoxOffset
 
QTransform m_viewMatrix
 matrix to convert from viewbox coordinates to shape coordinates
 

Additional Inherited Members

- Public Types inherited from KoTosContainer
enum  ResizeBehavior { TextFollowsSize , FollowTextSize , IndependentSizes , TextFollowsPreferredTextRect }
 different kinds of resizing behavior to determine how to treat text overflow More...
 
- Public Types inherited from KoShape
enum  ChangeType {
  PositionChanged , RotationChanged , ScaleChanged , ShearChanged ,
  SizeChanged , GenericMatrixChange , KeepAspectRatioChange , ParentChanged ,
  Deleted , StrokeChanged , BackgroundChanged , ShadowChanged ,
  BorderChanged , ParameterChanged , ContentChanged , TextRunAroundChanged ,
  ChildChanged , ConnectionPointChanged , ClipPathChanged , ClipMaskChanged ,
  TransparencyChanged
}
 Used by shapeChanged() to select which change was made. More...
 
enum  ChildZOrderPolicy { ChildZDefault , ChildZParentChild = ChildZDefault , ChildZPassThrough }
 Used by compareShapeZIndex() to order shapes. More...
 
enum  PaintOrder { Fill , Stroke , Markers }
 
enum  RunThroughLevel { Background , Foreground }
 
enum  TextRunAroundContour { ContourBox , ContourFull , ContourOutside }
 The behavior text should do when intersecting this shape. More...
 
enum  TextRunAroundSide {
  BiggestRunAroundSide , LeftRunAroundSide , RightRunAroundSide , EnoughRunAroundSide ,
  BothRunAroundSide , NoRunAround , RunThrough
}
 The behavior text should do when intersecting this shape. More...
 
- Static Public Member Functions inherited from KoPathShape
static KoPathShapecreateShapeFromPainterPath (const QPainterPath &path)
 Creates path shape from given QPainterPath.
 
- Static Public Member Functions inherited from KoShape
static QRectF absoluteOutlineRect (const QList< KoShape * > &shapes)
 
static QRectF boundingRect (const QList< KoShape * > &shapes)
 
static bool compareShapeZIndex (KoShape *s1, KoShape *s2)
 
static KisHandlePainterHelper createHandlePainterHelperDocument (QPainter *painter, KoShape *shape, qreal handleRadius, int decorationThickness)
 
static KisHandlePainterHelper createHandlePainterHelperView (QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
 
static QVector< PaintOrderdefaultPaintOrder ()
 default paint order as per SVG specification
 
static QList< KoShape * > linearizeSubtree (const QList< KoShape * > &shapes)
 
static QList< KoShape * > linearizeSubtreeSorted (const QList< KoShape * > &shapes)
 
- Public Attributes inherited from KoParameterShape
QList< QPointF > handles
 the handles that the user can grab and change
 
bool parametric
 
- Public Attributes inherited from KoShapeContainer
KoShapeContainerModelmodel
 
KoShapeContainer::ShapeInterface shapeInterface
 
- Static Public Attributes inherited from KoShape
static const qint16 maxZIndex = std::numeric_limits<qint16>::max()
 
static const qint16 minZIndex = std::numeric_limits<qint16>::min()
 

Detailed Description

An enhanced shape is a custom shape which can be defined by enhanced geometry data. The data consists of a list of commands like moveto, lineto, curveto, etc. which are used to create the outline of the shape. The coordinates or parameters of the commands can be constant values, named variables (identifiers), modifiers, functions or formulae.

Definition at line 37 of file EnhancedPathShape.h.

Member Typedef Documentation

◆ FormulaStore

typedef QMap<QString, EnhancedPathFormula *> EnhancedPathShape::FormulaStore
private

Definition at line 145 of file EnhancedPathShape.h.

◆ ModifierStore

typedef QList<qreal> EnhancedPathShape::ModifierStore
private

Definition at line 146 of file EnhancedPathShape.h.

◆ ParameterStore

typedef QMap<QString, EnhancedPathParameter *> EnhancedPathShape::ParameterStore
private

Definition at line 147 of file EnhancedPathShape.h.

Constructor & Destructor Documentation

◆ EnhancedPathShape() [1/2]

EnhancedPathShape::EnhancedPathShape ( const QRect & viewBox)

Definition at line 28 of file EnhancedPathShape.cpp.

30 , m_viewBoxOffset(0.0, 0.0)
31 , m_mirrorVertically(false)
35 , m_cacheResults(false)
36{
37}
bool m_cacheResults
indicates if result cache is enabled
bool m_mirrorHorizontally
whether or not the shape is to be mirrored horizontally before transforming it
qreal m_pathStretchPointX
draw:path-stretchpoint-x attribute
bool m_mirrorVertically
whether or not the shape is to be mirrored vertically before transforming it
QRect m_viewBox
the viewbox rectangle
QRect viewBox() const
Returns the viewbox of the enhanced path shape.
qreal m_pathStretchPointY
draw:path-stretchpoint-y attribute

◆ ~EnhancedPathShape()

EnhancedPathShape::~EnhancedPathShape ( )
override

Definition at line 61 of file EnhancedPathShape.cpp.

62{
63 reset();
64}

References reset().

◆ EnhancedPathShape() [2/2]

EnhancedPathShape::EnhancedPathShape ( const EnhancedPathShape & rhs)
private

Definition at line 39 of file EnhancedPathShape.cpp.

40 : KoParameterShape(rhs),
58{
59}
ParameterStore m_parameters
the shared parameters
QList< EnhancedPathHandle * > m_enhancedHandles
the handles for modifying the shape
FormulaStore m_formulae
the formulae
QRectF m_viewBound
the bounding box of the path in viewbox coordinates
QTransform m_mirrorMatrix
matrix to used for mirroring
QList< EnhancedPathCommand * > m_commands
the commands creating the outline
QTransform m_viewMatrix
matrix to convert from viewbox coordinates to shape coordinates
ModifierStore m_modifiers
the modifier values
QHash< QString, qreal > m_resultCache
cache for intermediate results used when evaluating path

Member Function Documentation

◆ addCommand() [1/2]

void EnhancedPathShape::addCommand ( const QString & command)

Add command for instance "M 0 0".

Definition at line 370 of file EnhancedPathShape.cpp.

371{
372 addCommand(command, true);
373}
void addCommand(const QString &command)
Add command for instance "M 0 0".

References addCommand().

◆ addCommand() [2/2]

void EnhancedPathShape::addCommand ( const QString & command,
bool triggerUpdate )
private

Adds a new command.

Definition at line 375 of file EnhancedPathShape.cpp.

376{
377 QString commandStr = command.simplified();
378 if (commandStr.isEmpty()) {
379 return;
380 }
381
382 // the first character is the command
383 EnhancedPathCommand *cmd = new EnhancedPathCommand(commandStr[0], this);
384
385 // strip command char
386 commandStr = commandStr.mid(1).simplified();
387
388 // now parse the command parameters
389 if (!commandStr.isEmpty()) {
390 QStringList tokens = commandStr.split(' ');
391 for (int i = 0; i < tokens.count(); ++i) {
392 cmd->addParameter(parameter(tokens[i]));
393 }
394 }
395 m_commands.append(cmd);
396
397 if (triggerUpdate) {
398 updatePath(size());
399 }
400}
void addParameter(EnhancedPathParameter *parameter)
Adds a new parameter to the command.
void updatePath(const QSizeF &size) override
Update the path of the parameter shape.
EnhancedPathParameter * parameter(const QString &text)
Returns parameter from given textual representation.
QSizeF size() const override
reimplemented

References EnhancedPathCommand::addParameter(), m_commands, parameter(), KoPathShape::size(), and updatePath().

◆ addFormula()

void EnhancedPathShape::addFormula ( const QString & name,
const QString & formula )

Add formula with given name and textual representation.

Definition at line 297 of file EnhancedPathShape.cpp.

298{
299 if (name.isEmpty() || formula.isEmpty()) {
300 return;
301 }
302
303 m_formulae[name] = new EnhancedPathFormula(formula, this);
304}
QString name() const
Definition KoShape.cpp:1150

References m_formulae, and KoShape::name().

◆ addHandle()

void EnhancedPathShape::addHandle ( const QMap< QString, QVariant > & handle)

Add a single handle with format: x y minX maxX minY maxY.

Definition at line 306 of file EnhancedPathShape.cpp.

307{
308 if (handle.isEmpty()) {
309 return;
310 }
311
312 if (!handle.contains("draw:handle-position")) {
313 return;
314 }
315 QVariant position = handle.value("draw:handle-position");
316
317 QStringList tokens = position.toString().simplified().split(' ');
318 if (tokens.count() < 2) {
319 return;
320 }
321
322 EnhancedPathHandle *newHandle = new EnhancedPathHandle(this);
323 newHandle->setPosition(parameter(tokens[0]), parameter(tokens[1]));
324
325 // check if we have a polar handle
326 if (handle.contains("draw:handle-polar")) {
327 QVariant polar = handle.value("draw:handle-polar");
328 QStringList tokens = polar.toString().simplified().split(' ');
329 if (tokens.count() == 2) {
330 newHandle->setPolarCenter(parameter(tokens[0]), parameter(tokens[1]));
331
332 QVariant minRadius = handle.value("draw:handle-radius-range-minimum");
333 QVariant maxRadius = handle.value("draw:handle-radius-range-maximum");
334 if (minRadius.isValid() && maxRadius.isValid()) {
335 newHandle->setRadiusRange(parameter(minRadius.toString()), parameter(maxRadius.toString()));
336 }
337 }
338 } else {
339 QVariant minX = handle.value("draw:handle-range-x-minimum");
340 QVariant maxX = handle.value("draw:handle-range-x-maximum");
341 if (minX.isValid() && maxX.isValid()) {
342 newHandle->setRangeX(parameter(minX.toString()), parameter(maxX.toString()));
343 }
344
345 QVariant minY = handle.value("draw:handle-range-y-minimum");
346 QVariant maxY = handle.value("draw:handle-range-y-maximum");
347 if (minY.isValid() && maxY.isValid()) {
348 newHandle->setRangeY(parameter(minY.toString()), parameter(maxY.toString()));
349 }
350 }
351
352 m_enhancedHandles.append(newHandle);
353
355}
void setPolarCenter(EnhancedPathParameter *polarX, EnhancedPathParameter *polarY)
void setPosition(EnhancedPathParameter *positionX, EnhancedPathParameter *positionY)
void setRangeX(EnhancedPathParameter *minX, EnhancedPathParameter *maxX)
void setRangeY(EnhancedPathParameter *minY, EnhancedPathParameter *maxY)
void setRadiusRange(EnhancedPathParameter *minRadius, EnhancedPathParameter *maxRadius)
QPointF position() const
Get the position of the shape in pt.
Definition KoShape.cpp:825

References evaluateHandles(), m_enhancedHandles, parameter(), KoShape::position(), EnhancedPathHandle::setPolarCenter(), EnhancedPathHandle::setPosition(), EnhancedPathHandle::setRadiusRange(), EnhancedPathHandle::setRangeX(), and EnhancedPathHandle::setRangeY().

◆ addModifiers()

void EnhancedPathShape::addModifiers ( const QString & modifiers)

Add modifiers with format: modifier0 modifier1 modifier2 ...

Definition at line 357 of file EnhancedPathShape.cpp.

358{
359 if (modifiers.isEmpty()) {
360 return;
361 }
362
363 QStringList tokens = modifiers.simplified().split(' ');
364 int tokenCount = tokens.count();
365 for (int i = 0; i < tokenCount; ++i) {
366 m_modifiers.append(tokens[i].toDouble());
367 }
368}
double toDouble(const quint8 *data, int channelpos)

References m_modifiers, and toDouble().

◆ cloneShape()

KoShape * EnhancedPathShape::cloneShape ( ) const
overridevirtual

creates a deep copy of the shape or shape's subtree

Returns
a cloned shape

Reimplemented from KoShape.

Definition at line 66 of file EnhancedPathShape.cpp.

67{
68 return new EnhancedPathShape(*this);
69}
EnhancedPathShape(const QRect &viewBox)

References EnhancedPathShape().

◆ enableResultCache()

void EnhancedPathShape::enableResultCache ( bool enable)
private

Enables caching results.

Definition at line 524 of file EnhancedPathShape.cpp.

525{
526 m_resultCache.clear();
527 m_cacheResults = enable;
528}

References m_cacheResults, and m_resultCache.

◆ evaluateConstantOrReference()

qreal EnhancedPathShape::evaluateConstantOrReference ( const QString & val)

Evaluates the given constant or reference to a identifier, modifier or formula.

Parameters
valthe value to evaluate
Returns
the result of the evaluation

Definition at line 237 of file EnhancedPathShape.cpp.

238{
239 bool ok = true;
240 qreal res = val.toDouble(&ok);
241 if (ok) {
242 return res;
243 }
244 return evaluateReference(val);
245}
qreal evaluateReference(const QString &reference)

References evaluateReference().

◆ evaluateHandles()

void EnhancedPathShape::evaluateHandles ( )
private

Definition at line 175 of file EnhancedPathShape.cpp.

176{
177 const int handleCount = m_enhancedHandles.count();
179 for (int i = 0; i < handleCount; ++i) {
180 handles.append(m_enhancedHandles[i]->position());
181 }
183}
QList< QPointF > handles
the handles that the user can grab and change
int handleCount() const
return the number of handles set on the shape
void setHandles(const QList< QPointF > &handles)

References KoParameterShape::handleCount(), KoParameterShape::handles, m_enhancedHandles, KoShape::position(), and KoParameterShape::setHandles().

◆ evaluateReference()

qreal EnhancedPathShape::evaluateReference ( const QString & reference)

Evaluates the given reference to a identifier, modifier or formula.

Parameters
referencethe reference to evaluate
Returns
the result of the evaluation

Definition at line 190 of file EnhancedPathShape.cpp.

191{
192 if (reference.isEmpty()) {
193 return 0.0;
194 }
195
196 const char c = reference[0].toLatin1();
197
198 qreal res = 0.0;
199
200 switch (c) {
201 // referenced modifier
202 case '$': {
203 bool success = false;
204 int modifierIndex = reference.mid(1).toInt(&success);
205 res = m_modifiers.value(modifierIndex);
206 break;
207 }
208 // referenced formula
209 case '?': {
210 QString fname = reference.mid(1);
211 if (m_cacheResults && m_resultCache.contains(fname)) {
212 res = m_resultCache.value(fname);
213 } else {
214 FormulaStore::const_iterator formulaIt = m_formulae.constFind(fname);
215 if (formulaIt != m_formulae.constEnd()) {
216 EnhancedPathFormula *formula = formulaIt.value();
217 if (formula) {
218 res = formula->evaluate();
219 if (m_cacheResults) {
220 m_resultCache.insert(fname, res);
221 }
222 }
223 }
224 }
225 break;
226 }
227 // maybe an identifier ?
228 default:
229 EnhancedPathNamedParameter p(reference, this);
230 res = p.evaluate();
231 break;
232 }
233
234 return res;
235}
const Params2D p
A named parameter, one that refers to a variable of the path.

References EnhancedPathFormula::evaluate(), m_cacheResults, m_formulae, m_modifiers, m_resultCache, and p.

◆ modifyReference()

void EnhancedPathShape::modifyReference ( const QString & reference,
qreal value )

Attempts to modify a given reference.

Only modifiers can me modified, others silently ignore the attempt.

Parameters
referencethe reference to modify
valuethe new value

Definition at line 247 of file EnhancedPathShape.cpp.

248{
249 if (reference.isEmpty()) {
250 return;
251 }
252
253 const char c = reference[0].toLatin1();
254
255 if (c == '$') {
256 bool success = false;
257 int modifierIndex = reference.mid(1).toInt(&success);
258 if (modifierIndex >= 0 && modifierIndex < m_modifiers.count()) {
259 m_modifiers[modifierIndex] = value;
260 }
261 }
262}
float value(const T *src, size_t ch)

References m_modifiers, and value().

◆ moveHandleAction()

void EnhancedPathShape::moveHandleAction ( int handleId,
const QPointF & point,
Qt::KeyboardModifiers modifiers = Qt::NoModifier )
overrideprotectedvirtual

Updates the internal state of a KoParameterShape.

This method is called from moveHandle.

Parameters
handleIdof the handle
pointto move the handle to in shape coordinates
modifiersused during move to point

Implements KoParameterShape.

Definition at line 89 of file EnhancedPathShape.cpp.

90{
91 Q_UNUSED(modifiers);
92 EnhancedPathHandle *handle = m_enhancedHandles[ handleId ];
93 if (handle) {
94 handle->changePosition(shapeToViewbox(point));
95 }
96}
void changePosition(const QPointF &position)
QPointF shapeToViewbox(const QPointF &point) const
Converts from shape coordinates to viewbox coordinates.

References EnhancedPathHandle::changePosition(), m_enhancedHandles, and shapeToViewbox().

◆ normalize()

QPointF EnhancedPathShape::normalize ( )
overridevirtual

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 from KoPathShape.

Definition at line 161 of file EnhancedPathShape.cpp.

162{
163 QPointF offset = KoParameterShape::normalize();
164
165 m_viewBoxOffset -= offset;
166
167 return offset;
168}
QPointF normalize() override
Normalizes the path data.

References m_viewBoxOffset, and KoParameterShape::normalize().

◆ parameter()

EnhancedPathParameter * EnhancedPathShape::parameter ( const QString & text)

Returns parameter from given textual representation.

Definition at line 264 of file EnhancedPathShape.cpp.

265{
266 Q_ASSERT(! text.isEmpty());
267
268 ParameterStore::const_iterator parameterIt = m_parameters.constFind(text);
269 if (parameterIt != m_parameters.constEnd()) {
270 return parameterIt.value();
271 } else {
273 const char c = text[0].toLatin1();
274 if (c == '$' || c == '?') {
276 } else {
277 bool success = false;
278 qreal constant = text.toDouble(&success);
279 if (success) {
280 parameter = new EnhancedPathConstantParameter(constant, this);
281 } else {
283 if (identifier != IdentifierUnknown) {
284 parameter = new EnhancedPathNamedParameter(identifier, this);
285 }
286 }
287 }
288
289 if (parameter) {
290 m_parameters[text] = parameter;
291 }
292
293 return parameter;
294 }
295}
Identifier
the different possible identifiers, taken from the odf spec
@ IdentifierUnknown
unknown identifier
A constant parameter, a fixed value (i.e. 5, 11.3, -7)
static Identifier identifierFromString(const QString &text)
Returns identifier type from given string.
The abstract parameter class.
A referencing parameter, one that references another formula or a modifier.

References EnhancedPathNamedParameter::identifierFromString(), IdentifierUnknown, m_parameters, and parameter().

◆ parsePathData()

void EnhancedPathShape::parsePathData ( const QString & data)
private

parses the enhanced path data

Definition at line 449 of file EnhancedPathShape.cpp.

450{
451 if (data.isEmpty()) {
452 return;
453 }
454
455 int start = -1;
456 bool separator = true;
457 for (int i = 0; i < data.length(); ++i) {
458 QChar ch = data.at(i);
459 ushort uni_ch = ch.unicode();
460 if (separator && (uni_ch == 'M' || uni_ch == 'L'
461 || uni_ch == 'C' || uni_ch == 'Z'
462 || uni_ch == 'N' || uni_ch == 'F'
463 || uni_ch == 'S' || uni_ch == 'T'
464 || uni_ch == 'U' || uni_ch == 'A'
465 || uni_ch == 'B' || uni_ch == 'W'
466 || uni_ch == 'V' || uni_ch == 'X'
467 || uni_ch == 'Y' || uni_ch == 'Q')) {
468 if (start != -1) { // process last chars
469 addCommand(data.mid(start, i - start), false);
470 }
471 start = i;
472 }
473 separator = ch.isSpace();
474 }
475 if (start < data.length()) {
476 addCommand(data.mid(start));
477 }
478 if (start != -1) {
479 updatePath(size());
480 }
481}

References addCommand(), KoPathShape::size(), and updatePath().

◆ reset()

void EnhancedPathShape::reset ( )
private

Definition at line 71 of file EnhancedPathShape.cpp.

72{
73 qDeleteAll(m_commands);
74 m_commands.clear();
75 qDeleteAll(m_enhancedHandles);
76 m_enhancedHandles.clear();
78 qDeleteAll(m_formulae);
79 m_formulae.clear();
80 qDeleteAll(m_parameters);
81 m_parameters.clear();
82 m_modifiers.clear();
83 m_viewMatrix.reset();
84 m_viewBoxOffset = QPointF();
85 clear();
86 m_textArea.clear();
87}
void clear()
Removes all subpaths and their points from the path.

References KoPathShape::clear(), m_commands, m_enhancedHandles, m_formulae, m_modifiers, m_parameters, m_textArea, m_viewBoxOffset, m_viewMatrix, and KoParameterShape::setHandles().

◆ setMirrorHorizontally()

void EnhancedPathShape::setMirrorHorizontally ( bool mirrorHorizontally)

Sets if the shape is to be mirrored horizontally before applying any other transformations.

Definition at line 483 of file EnhancedPathShape.cpp.

484{
485 if (m_mirrorHorizontally != mirrorHorizontally) {
486 m_mirrorHorizontally = mirrorHorizontally;
487 updatePath(size());
488 }
489
490}

References m_mirrorHorizontally, KoPathShape::size(), and updatePath().

◆ setMirrorVertically()

void EnhancedPathShape::setMirrorVertically ( bool mirrorVertically)

Sets if the shape is to be mirrored vertically before applying any other transformations.

Definition at line 492 of file EnhancedPathShape.cpp.

493{
494 if (m_mirrorVertically != mirrorVertically) {
495 m_mirrorVertically = mirrorVertically;
496 updatePath(size());
497 }
498}

References m_mirrorVertically, KoPathShape::size(), and updatePath().

◆ setPathStretchPointX()

void EnhancedPathShape::setPathStretchPointX ( qreal pathStretchPointX)

Definition at line 530 of file EnhancedPathShape.cpp.

531{
532 if (m_pathStretchPointX != pathStretchPointX) {
533 m_pathStretchPointX = pathStretchPointX;
534 }
535
536}

References m_pathStretchPointX.

◆ setPathStretchPointY()

void EnhancedPathShape::setPathStretchPointY ( qreal pathStretchPointY)

Definition at line 538 of file EnhancedPathShape.cpp.

539{
540 if (m_pathStretchPointY != pathStretchPointY) {
541 m_pathStretchPointY = pathStretchPointY;
542 }
543
544}

References m_pathStretchPointY.

◆ setSize()

void EnhancedPathShape::setSize ( const QSizeF & size)
overridevirtual

Resize the shape.

Parameters
sizethe new size of the shape. This is different from scaling as scaling is a so called secondary operation which is comparable to zooming in instead of changing the size of the basic shape. Easiest example of this difference is that using this method will not distort the size of pattern-fills and strokes.

Reimplemented from KoShape.

Definition at line 145 of file EnhancedPathShape.cpp.

146{
147 // handle offset
149
150 // calculate scaling factors from viewbox size to shape size
151 qreal xScale = m_viewBound.width() == 0 ? 1 : newSize.width() / m_viewBound.width();
152 qreal yScale = m_viewBound.height() == 0 ? 1 : newSize.height() / m_viewBound.height();
153
154 // create view matrix, take mirroring into account
155 m_viewMatrix.reset();
156 m_viewMatrix.scale(xScale, yScale);
157
158 updatePath(newSize);
159}
void setSize(const QSizeF &size) override
reimplemented from KoShape

References m_viewBound, m_viewMatrix, KoParameterShape::setSize(), and updatePath().

◆ shapeChanged()

void EnhancedPathShape::shapeChanged ( ChangeType type,
KoShape * shape = 0 )
overrideprotectedvirtual

A hook that allows inheriting classes to do something after a KoShape property changed This is called whenever the shape, position rotation or scale properties were altered.

Parameters
typean indicator which type was changed.
shapethe shape.

Reimplemented from KoShape.

Definition at line 500 of file EnhancedPathShape.cpp.

501{
503
504 if (!shape || shape == this) {
505 if (type == ParentChanged || type == ParameterChanged) {
507 }
508 }
509}
void updateTextArea()
Updates the size and position of an optionally existing text-on-shape text area.
virtual void shapeChanged(ChangeType type, KoShape *shape=0)
Definition KoShape.cpp:1253
@ ParentChanged
used after a setParent()
Definition KoShape.h:103
@ ParameterChanged
the shapes parameter has changed (KoParameterShape only)
Definition KoShape.h:109

References KoShape::ParameterChanged, KoShape::ParentChanged, KoShape::shapeChanged(), and updateTextArea().

◆ shapeToViewbox()

QPointF EnhancedPathShape::shapeToViewbox ( const QPointF & point) const

Converts from shape coordinates to viewbox coordinates.

Definition at line 170 of file EnhancedPathShape.cpp.

171{
172 return (m_mirrorMatrix * m_viewMatrix).inverted().map(point - m_viewBoxOffset);
173}

References m_mirrorMatrix, m_viewBoxOffset, and m_viewMatrix.

◆ updatePath()

void EnhancedPathShape::updatePath ( const QSizeF & size)
overrideprotectedvirtual

Update the path of the parameter shape.

Parameters
sizeof the shape

Implements KoParameterShape.

Definition at line 98 of file EnhancedPathShape.cpp.

99{
100 if (isParametricShape()) {
101 clear();
102 enableResultCache(true);
103
104 foreach (EnhancedPathCommand *cmd, m_commands) {
105 cmd->execute();
106 }
107
108 enableResultCache(false);
109
110 qreal stretchPointsScale = 1;
111 bool isStretched = useStretchPoints(size, stretchPointsScale);
112 m_viewBound = outline().boundingRect();
113 m_mirrorMatrix.reset();
114 m_mirrorMatrix.translate(m_viewBound.center().x(), m_viewBound.center().y());
116 m_mirrorMatrix.translate(-m_viewBound.center().x(), -m_viewBound.center().y());
117 QTransform matrix(1.0, 0.0, 0.0, 1.0, m_viewBoxOffset.x(), m_viewBoxOffset.y());
118
119 // if stretch points are set than stretch the path manually
120 if (isStretched) {
121 //if the path was stretched manually the stretch matrix is not more valid
122 //and it has to be recalculated so that stretching in x and y direction is the same
123 matrix.scale(stretchPointsScale, stretchPointsScale);
124 matrix = m_mirrorMatrix * matrix;
125 } else {
126 matrix = m_mirrorMatrix * m_viewMatrix * matrix;
127 }
128 foreach (KoSubpath *subpath, subpaths()) {
129 foreach (KoPathPoint *point, *subpath) {
130 point->map(matrix);
131 }
132 }
133
134 const int handleCount = m_enhancedHandles.count();
136 for (int i = 0; i < handleCount; ++i) {
137 handles.append(matrix.map(m_enhancedHandles[i]->position()));
138 }
140
141 normalize();
142 }
143}
bool execute()
Executes the command on the specified path shape.
bool useStretchPoints(const QSizeF &size, qreal &scale)
QPointF normalize() override
Normalizes the path data.
void enableResultCache(bool enable)
Enables caching results.
bool isParametricShape() const
Check if object is a parametric shape.
A KoPathPoint represents a point in a path.
void map(const QTransform &matrix)
apply matrix on the point
const KoSubpathList & subpaths() const
QPainterPath outline() const override
reimplemented

References KoPathShape::clear(), enableResultCache(), EnhancedPathCommand::execute(), KoParameterShape::handleCount(), KoParameterShape::handles, KoParameterShape::isParametricShape(), m_commands, m_enhancedHandles, m_mirrorHorizontally, m_mirrorMatrix, m_mirrorVertically, m_viewBound, m_viewBoxOffset, m_viewMatrix, KoPathPoint::map(), normalize(), KoPathShape::outline(), KoParameterShape::setHandles(), KoPathShape::size(), KoPathShape::subpaths(), and useStretchPoints().

◆ updateTextArea()

void EnhancedPathShape::updateTextArea ( )
private

Updates the size and position of an optionally existing text-on-shape text area.

Definition at line 511 of file EnhancedPathShape.cpp.

512{
513 if (m_textArea.size() >= 4) {
514 QRectF r = m_viewBox;
519 r = m_viewMatrix.mapRect(r).translated(m_viewBoxOffset);
521 }
522}
qreal evaluateConstantOrReference(const QString &val)
void setPreferredTextRect(const QRectF &rect)

References evaluateConstantOrReference(), m_textArea, m_viewBox, m_viewBoxOffset, m_viewMatrix, and KoTosContainer::setPreferredTextRect().

◆ useStretchPoints()

bool EnhancedPathShape::useStretchPoints ( const QSizeF & size,
qreal & scale )
private

Definition at line 402 of file EnhancedPathShape.cpp.

403{
404 bool retval = false;
405 if (m_pathStretchPointX != -1 && m_pathStretchPointY != -1) {
406 qreal scaleX = size.width();
407 qreal scaleY = size.height();
408 if (qreal(m_viewBox.width()) / m_viewBox.height() < qreal(scaleX) / scaleY) {
409 qreal deltaX = (scaleX * m_viewBox.height()) / scaleY - m_viewBox.width();
410 foreach (KoSubpath *subpath, subpaths()) {
411 foreach (KoPathPoint *currPoint, *subpath) {
412 if (currPoint->point().x() >= m_pathStretchPointX &&
413 currPoint->controlPoint1().x() >= m_pathStretchPointX &&
414 currPoint->controlPoint2().x() >= m_pathStretchPointX) {
415 currPoint->setPoint(QPointF(currPoint->point().x() + deltaX, currPoint->point().y()));
416 currPoint->setControlPoint1(QPointF(currPoint->controlPoint1().x() + deltaX,
417 currPoint->controlPoint1().y()));
418 currPoint->setControlPoint2(QPointF(currPoint->controlPoint2().x() + deltaX,
419 currPoint->controlPoint2().y()));
420 retval = true;
421 }
422 }
423 }
424 scale = scaleY / m_viewBox.height();
425 } else if (qreal(m_viewBox.width()) / m_viewBox.height() > qreal(scaleX) / scaleY) {
426 qreal deltaY = (m_viewBox.width() * scaleY) / scaleX - m_viewBox.height();
427 foreach (KoSubpath *subpath, subpaths()) {
428 foreach (KoPathPoint *currPoint, *subpath) {
429 if (currPoint->point().y() >= m_pathStretchPointY &&
430 currPoint->controlPoint1().y() >= m_pathStretchPointY &&
431 currPoint->controlPoint2().y() >= m_pathStretchPointY) {
432 currPoint->setPoint(QPointF(currPoint->point().x(), currPoint->point().y() + deltaY));
433 currPoint->setControlPoint1(QPointF(currPoint->controlPoint1().x(),
434 currPoint->controlPoint1().y() + deltaY));
435 currPoint->setControlPoint2(QPointF(currPoint->controlPoint2().x(),
436 currPoint->controlPoint2().y() + deltaY));
437 retval = true;
438 }
439 }
440 }
441 scale = scaleX / m_viewBox.width();
442 }
443
445 }
446 return retval;
447}
void setControlPoint1(const QPointF &point)
Set the control point 1.
QPointF point
void setControlPoint2(const QPointF &point)
Set the control point 2.
QPointF controlPoint1
void setPoint(const QPointF &point)
alter the point
QPointF controlPoint2
void notifyPointsChanged()
void scale(qreal sx, qreal sy)
Scale the shape using the zero-point which is the top-left corner.
Definition KoShape.cpp:237

References KoPathPoint::controlPoint1, KoPathPoint::controlPoint2, m_pathStretchPointX, m_pathStretchPointY, m_viewBox, KoPathShape::notifyPointsChanged(), KoPathPoint::point, KoShape::scale(), KoPathPoint::setControlPoint1(), KoPathPoint::setControlPoint2(), KoPathPoint::setPoint(), KoPathShape::size(), and KoPathShape::subpaths().

◆ viewBox()

QRect EnhancedPathShape::viewBox ( ) const

Returns the viewbox of the enhanced path shape.

Definition at line 185 of file EnhancedPathShape.cpp.

186{
187 return m_viewBox;
188}

References m_viewBox.

Member Data Documentation

◆ m_cacheResults

bool EnhancedPathShape::m_cacheResults
private

indicates if result cache is enabled

Definition at line 165 of file EnhancedPathShape.h.

◆ m_commands

QList<EnhancedPathCommand *> EnhancedPathShape::m_commands
private

the commands creating the outline

Definition at line 155 of file EnhancedPathShape.h.

◆ m_enhancedHandles

QList<EnhancedPathHandle *> EnhancedPathShape::m_enhancedHandles
private

the handles for modifying the shape

Definition at line 156 of file EnhancedPathShape.h.

◆ m_formulae

FormulaStore EnhancedPathShape::m_formulae
private

the formulae

Definition at line 157 of file EnhancedPathShape.h.

◆ m_mirrorHorizontally

bool EnhancedPathShape::m_mirrorHorizontally
private

whether or not the shape is to be mirrored horizontally before transforming it

Definition at line 161 of file EnhancedPathShape.h.

◆ m_mirrorMatrix

QTransform EnhancedPathShape::m_mirrorMatrix
private

matrix to used for mirroring

Definition at line 152 of file EnhancedPathShape.h.

◆ m_mirrorVertically

bool EnhancedPathShape::m_mirrorVertically
private

whether or not the shape is to be mirrored vertically before transforming it

Definition at line 160 of file EnhancedPathShape.h.

◆ m_modifiers

ModifierStore EnhancedPathShape::m_modifiers
private

the modifier values

Definition at line 158 of file EnhancedPathShape.h.

◆ m_parameters

ParameterStore EnhancedPathShape::m_parameters
private

the shared parameters

Definition at line 159 of file EnhancedPathShape.h.

◆ m_pathStretchPointX

qreal EnhancedPathShape::m_pathStretchPointX
private

draw:path-stretchpoint-x attribute

Definition at line 162 of file EnhancedPathShape.h.

◆ m_pathStretchPointY

qreal EnhancedPathShape::m_pathStretchPointY
private

draw:path-stretchpoint-y attribute

Definition at line 163 of file EnhancedPathShape.h.

◆ m_resultCache

QHash<QString, qreal> EnhancedPathShape::m_resultCache
private

cache for intermediate results used when evaluating path

Definition at line 164 of file EnhancedPathShape.h.

◆ m_textArea

QStringList EnhancedPathShape::m_textArea
private

Definition at line 154 of file EnhancedPathShape.h.

◆ m_viewBound

QRectF EnhancedPathShape::m_viewBound
private

the bounding box of the path in viewbox coordinates

Definition at line 150 of file EnhancedPathShape.h.

◆ m_viewBox

QRect EnhancedPathShape::m_viewBox
private

the viewbox rectangle

Definition at line 149 of file EnhancedPathShape.h.

◆ m_viewBoxOffset

QPointF EnhancedPathShape::m_viewBoxOffset
private

Definition at line 153 of file EnhancedPathShape.h.

◆ m_viewMatrix

QTransform EnhancedPathShape::m_viewMatrix
private

matrix to convert from viewbox coordinates to shape coordinates

Definition at line 151 of file EnhancedPathShape.h.


The documentation for this class was generated from the following files: