Krita Source Code Documentation
Loading...
Searching...
No Matches
KoParameterShape Class Referenceabstract

#include <KoParameterShape.h>

+ Inheritance diagram for KoParameterShape:

Public Member Functions

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.
 

Public Attributes

QList< QPointF > handles
 the handles that the user can grab and change
 
bool parametric
 
- Public Attributes inherited from KoShapeContainer
KoShapeContainerModelmodel
 
KoShapeContainer::ShapeInterface shapeInterface
 

Protected Member Functions

QList< QPointF > handles () const
 
 KoParameterShape (const KoParameterShape &rhs)
 constructor
 
virtual void moveHandleAction (int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier)=0
 Updates the internal state of a KoParameterShape.
 
void setHandles (const QList< QPointF > &handles)
 
virtual void updatePath (const QSizeF &size)=0
 Update the path of the parameter shape.
 
- 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 Attributes

QSharedDataPointer< Privated
 

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)
 
- 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

KoParameterShape is the base class for all parametric shapes in flake. Parametric shapes are those whose appearance can be completely defined by a few numerical parameters. Rectangle, ellipse and star are examples of parametric shapes. In flake, these shape parameters can be manipulated visually by means of control points. These control points can be moved with the mouse on the canvas which changes the shapes parameter values and hence the shapes appearance in realtime. KoParameterShape is derived from the KoPathShape class that means by changing the shape parameters, the underlying path is manipulated. A parametric shape can be converted into a path shape by simply calling the setModified method. This makes the path tool know that it can handle the shape like a path shape, so that modifying the single path points is possible.

Definition at line 34 of file KoParameterShape.h.

Constructor & Destructor Documentation

◆ KoParameterShape() [1/2]

KoParameterShape::KoParameterShape ( )

Definition at line 29 of file KoParameterShape.cpp.

30 : KoPathShape()
31 , d(new Private)
32{
33}
QSharedDataPointer< Private > d
KoPathShape()
constructor

◆ ~KoParameterShape()

KoParameterShape::~KoParameterShape ( )
override

Definition at line 41 of file KoParameterShape.cpp.

42{
43}

◆ KoParameterShape() [2/2]

KoParameterShape::KoParameterShape ( const KoParameterShape & rhs)
protected

constructor

Definition at line 35 of file KoParameterShape.cpp.

36 : KoPathShape(rhs)
37 , d(rhs.d)
38{
39}

◆ ~Private()

virtual KoParameterShape::~Private ( )
virtualdefault

Reimplemented from KoShapeContainer.

Member Function Documentation

◆ handleCount()

int KoParameterShape::handleCount ( ) const

return the number of handles set on the shape

Definition at line 151 of file KoParameterShape.cpp.

152{
153
154 return d->handles.count();
155}

References d.

◆ handleIdAt()

int KoParameterShape::handleIdAt ( const QRectF & rect) const

Get the id of the handle within the given rect.

Parameters
rectthe rect in shape coordinates
Returns
id of the found handle or -1 if none was found

Definition at line 62 of file KoParameterShape.cpp.

63{
64
65 int handle = -1;
66
67 for (int i = 0; i < d->handles.size(); ++i) {
68 if (rect.contains(d->handles.at(i))) {
69 handle = i;
70 break;
71 }
72 }
73 return handle;
74}

References d.

◆ handlePosition()

QPointF KoParameterShape::handlePosition ( int handleId) const

Get the handle position.

Parameters
handleIdthe id of the handle for which to get the position in shape coordinates

Definition at line 76 of file KoParameterShape.cpp.

77{
78
79 return d->handles.value(handleId);
80}

References d.

◆ handles()

QList< QPointF > KoParameterShape::handles ( ) const
protected

Get the handle positions for manipulating the parameters.

See also
setHandles, handleCount()

◆ isParametricShape()

bool KoParameterShape::isParametricShape ( ) const

Check if object is a parametric shape.

It is no longer a parametric shape when the path was manipulated

Returns
true if it is a parametric shape, false otherwise

Definition at line 124 of file KoParameterShape.cpp.

125{
126
127 return d->parametric;
128}

References d.

◆ moveHandle()

void KoParameterShape::moveHandle ( int handleId,
const QPointF & point,
Qt::KeyboardModifiers modifiers = Qt::NoModifier )

Move handle to point.

This method calls moveHandleAction. Overload moveHandleAction to get the behaviour you want. After that updatePath and a repaint is called.

Parameters
handleIdthe id of the handle to move
pointthe point to move the handle to in document coordinates
modifiersthe keyboard modifiers used during moving the handle

Definition at line 45 of file KoParameterShape.cpp.

46{
47
48 if (handleId >= d->handles.size()) {
49 warnFlake << "handleId out of bounds";
50 return;
51 }
52
53 update();
54 // function to do special stuff
55 moveHandleAction(handleId, documentToShape(point), modifiers);
56
58 update();
59}
#define warnFlake
Definition FlakeDebug.h:16
virtual void moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier)=0
Updates the internal state of a KoParameterShape.
virtual void updatePath(const QSizeF &size)=0
Update the path of the parameter shape.
QSizeF size() const override
reimplemented
void update() const override
reimplemented
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
Definition KoShape.cpp:1211

References d, KoShape::documentToShape(), moveHandleAction(), KoPathShape::size(), KoShapeContainer::update(), updatePath(), and warnFlake.

◆ moveHandleAction()

virtual void KoParameterShape::moveHandleAction ( int handleId,
const QPointF & point,
Qt::KeyboardModifiers modifiers = Qt::NoModifier )
protectedpure virtual

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

Implemented in EllipseShape, EnhancedPathShape, RectangleShape, SpiralShape, StarShape, and KarbonCalligraphicShape.

◆ normalize()

QPointF KoParameterShape::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.

Reimplemented in SpiralShape.

Definition at line 110 of file KoParameterShape.cpp.

111{
112
113 QPointF offset(KoPathShape::normalize());
114 QTransform matrix;
115 matrix.translate(-offset.x(), -offset.y());
116
117 for (int i = 0; i < d->handles.size(); ++i) {
118 d->handles[i] = matrix.map(d->handles[i]);
119 }
120
121 return offset;
122}
virtual QPointF normalize()
Normalizes the path data.

References d, and KoPathShape::normalize().

◆ paintHandle()

void KoParameterShape::paintHandle ( KisHandlePainterHelper & handlesHelper,
int handleId )

Paint the given handles.

Parameters
handlesHelperthe helper of the handle used for painting
handleIdof the handle which should be repainted

Definition at line 92 of file KoParameterShape.cpp.

93{
94
95 handlesHelper.drawGradientHandle(d->handles[handleId]);
96}
void drawGradientHandle(const QPointF &center, qreal radius)

References d, and KisHandlePainterHelper::drawGradientHandle().

◆ paintHandles()

void KoParameterShape::paintHandles ( KisHandlePainterHelper & handlesHelper)

Paint the handles.

Parameters
handlesHelperthe helper of the handles used for painting
See also
KisHandlePainterHelper

Definition at line 82 of file KoParameterShape.cpp.

83{
84
85
86 QList<QPointF>::const_iterator it(d->handles.constBegin());
87 for (; it != d->handles.constEnd(); ++it) {
88 handlesHelper.drawGradientHandle(*it);
89 }
90}

References d, and KisHandlePainterHelper::drawGradientHandle().

◆ Private() [1/2]

◆ Private() [2/2]

◆ setHandles()

void KoParameterShape::setHandles ( const QList< QPointF > & handles)
protected

Set the new handle positions which are used by the user to manipulate the parameters.

See also
handles(), handleCount()

Definition at line 143 of file KoParameterShape.cpp.

144{
145
146 d->handles = handles;
147
149}
QList< QPointF > handles
the handles that the user can grab and change
void shapeChangedPriv(KoShape::ChangeType type)
Definition KoShape.cpp:132
@ ParameterChanged
the shapes parameter has changed (KoParameterShape only)
Definition KoShape.h:109

References d, handles, KoShape::ParameterChanged, and KoShape::shapeChangedPriv().

◆ setParametricShape()

void KoParameterShape::setParametricShape ( bool parametric)

Set if the shape can be modified using parameters.

After the state is set to false it is no longer possible to work with parameters on this shape.

Parameters
parametricthe new state
See also
isParametricShape

Definition at line 130 of file KoParameterShape.cpp.

131{
132
133 d->parametric = parametric;
134 update();
135}

References d, parametric, and KoShapeContainer::update().

◆ setSize()

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

reimplemented from KoShape

Reimplemented from KoShape.

Reimplemented in SpiralShape, and StarShape.

Definition at line 98 of file KoParameterShape.cpp.

99{
100
101 QTransform matrix(resizeMatrix(newSize));
102
103 for (int i = 0; i < d->handles.size(); ++i) {
104 d->handles[i] = matrix.map(d->handles[i]);
105 }
106
107 KoPathShape::setSize(newSize);
108}
QTransform resizeMatrix(const QSizeF &newSize) const
void setSize(const QSizeF &size) override

References d, KoPathShape::resizeMatrix(), and KoPathShape::setSize().

◆ updatePath()

virtual void KoParameterShape::updatePath ( const QSizeF & size)
protectedpure virtual

Update the path of the parameter shape.

Parameters
sizeof the shape

Implemented in EllipseShape, EnhancedPathShape, RectangleShape, SpiralShape, StarShape, and KarbonCalligraphicShape.

Member Data Documentation

◆ d

QSharedDataPointer<Private> KoParameterShape::d
private

Definition at line 147 of file KoParameterShape.h.

◆ handles

QList< QPointF > KoParameterShape::handles

the handles that the user can grab and change

Definition at line 30 of file KoParameterShape_p.h.

◆ parametric

bool KoParameterShape::parametric

Definition at line 27 of file KoParameterShape_p.h.


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