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

#include <SpiralShape.h>

+ Inheritance diagram for SpiralShape:

Public Types

enum  SpiralType { Curve = 0 , Line = 1 }
 the possible spiral types More...
 
- 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...
 

Public Member Functions

bool clockWise () const
 
KoShapecloneShape () const override
 creates a deep copy of the shape or shape's subtree
 
qreal fade () const
 Returns the actual fade parameter.
 
QPointF normalize () override
 Normalizes the path data.
 
QString pathShapeId () const override
 reimplemented
 
void setClockWise (bool clockwise)
 
void setFade (qreal fade)
 
void setSize (const QSizeF &newSize) override
 reimplemented from KoShape
 
void setType (SpiralType type)
 
 SpiralShape ()
 
SpiralType type () const
 Returns the actual spiral type.
 
 ~SpiralShape () 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.
 
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.
 
 ~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.
 
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.
 
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)
 
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 createPath (const QSizeF &size)
 
void moveHandleAction (int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier) override
 Updates the internal state of a KoParameterShape.
 
 SpiralShape (const SpiralShape &rhs)
 
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 Member Functions

void updateAngleHandles ()
 
void updateKindHandle ()
 

Private Attributes

QPointF m_center
 
bool m_clockwise
 
qreal m_fade
 
qreal m_kindAngle
 
KoSubpath m_points
 
QPointF m_radii
 
SpiralType m_type
 

Additional Inherited Members

- 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

This class adds support for the spiral shape.

Definition at line 18 of file SpiralShape.h.

Member Enumeration Documentation

◆ SpiralType

the possible spiral types

Enumerator
Curve 

spiral uses curves

Line 

spiral uses lines

Definition at line 22 of file SpiralShape.h.

22 {
23 Curve = 0,
24 Line = 1
25 };
@ Line
spiral uses lines
Definition SpiralShape.h:24
@ Curve
spiral uses curves
Definition SpiralShape.h:23

Constructor & Destructor Documentation

◆ SpiralShape() [1/2]

SpiralShape::SpiralShape ( )

Definition at line 19 of file SpiralShape.cpp.

20 : m_fade(.9)
22 , m_radii(100.0, 100.0)
23 , m_type(Curve)
24 , m_clockwise(true)
25{
26 //m_handles.push_back(QPointF(50, 0));
27 //m_handles.push_back(QPointF(50, 50));
28 //m_handles.push_back(QPointF(0, 50));
29 createPath(QSizeF(m_radii.x(), m_radii.y()));
30}
qreal m_kindAngle
Definition SpiralShape.h:73
SpiralType m_type
Definition SpiralShape.h:79
bool m_clockwise
Definition SpiralShape.h:81
QPointF m_radii
Definition SpiralShape.h:77
void createPath(const QSizeF &size)
#define M_PI
Definition kis_global.h:111

References createPath(), and m_radii.

◆ ~SpiralShape()

SpiralShape::~SpiralShape ( )
override

Definition at line 49 of file SpiralShape.cpp.

50{
51}

◆ SpiralShape() [2/2]

SpiralShape::SpiralShape ( const SpiralShape & rhs)
protected

Definition at line 32 of file SpiralShape.cpp.

33 : KoParameterShape(rhs),
34 m_fade(rhs.m_fade),
36 m_center(rhs.m_center),
37 m_radii(rhs.m_radii),
38 m_type(rhs.m_type),
40
41{
42 Q_FOREACH(KoPathPoint *point, rhs.m_points) {
43 KIS_ASSERT_RECOVER(point) { continue; }
44 m_points << new KoPathPoint(*point, this);
45 }
46}
A KoPathPoint represents a point in a path.
QPointF m_center
Definition SpiralShape.h:75
KoSubpath m_points
Definition SpiralShape.h:83
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55

References KIS_ASSERT_RECOVER, and m_points.

Member Function Documentation

◆ clockWise()

bool SpiralShape::clockWise ( ) const

Definition at line 273 of file SpiralShape.cpp.

274{
275 return m_clockwise;
276}

References m_clockwise.

◆ cloneShape()

KoShape * SpiralShape::cloneShape ( ) const
overridevirtual

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

Returns
a cloned shape

Reimplemented from KoPathShape.

Definition at line 53 of file SpiralShape.cpp.

54{
55 return new SpiralShape(*this);
56}

References SpiralShape().

◆ createPath()

void SpiralShape::createPath ( const QSizeF & size)
protected

Definition at line 176 of file SpiralShape.cpp.

177{
178 Q_UNUSED(size);
179 clear();
180 QPointF center = QPointF(m_radii.x() / 2.0, m_radii.y() / 2.0);
181 //moveTo(QPointF(size.width(), m_radii.y()));
182 qreal adv_ang = (m_clockwise ? -1.0 : 1.0) * M_PI_2;
183 // radius of first segment is non-faded radius:
184 qreal m_radius = m_radii.x() / 2.0;
185 qreal r = m_radius;
186
187 QPointF oldP(center.x(), (m_clockwise ? -1.0 : 1.0) * m_radius + center.y());
188 QPointF newP;
189 QPointF newCenter(center);
190 moveTo(oldP);
191 uint m_segments = 10;
192 //m_handles[0] = oldP;
193
194 for (uint i = 0; i < m_segments; ++i) {
195 newP.setX(r * cos(adv_ang * (i + 2)) + newCenter.x());
196 newP.setY(r * sin(adv_ang * (i + 2)) + newCenter.y());
197
198 if (m_type == Curve) {
199 qreal rx = qAbs(oldP.x() - newP.x());
200 qreal ry = qAbs(oldP.y() - newP.y());
201 if (m_clockwise) {
202 arcTo(rx, ry, ((i + 1) % 4) * 90, 90);
203 } else {
204 arcTo(rx, ry, 360 - ((i + 1) % 4) * 90, -90);
205 }
206 } else {
207 lineTo(newP);
208 }
209
210 newCenter += (newP - newCenter) * (1.0 - m_fade);
211 oldP = newP;
212 r *= m_fade;
213 }
214 //m_handles[1] = QPointF(center.x(), (m_clockwise ? -1.0 : 1.0) * m_radius + center.y());
215 m_points = *subpaths()[0];
216
218}
unsigned int uint
const KoSubpathList & subpaths() const
KoPathPoint * lineTo(const QPointF &p)
Adds a new line segment.
QSizeF size() const override
reimplemented
void notifyPointsChanged()
KoPathPoint * moveTo(const QPointF &p)
Starts a new Subpath.
KoPathPoint * arcTo(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle)
Add an arc.
void clear()
Removes all subpaths and their points from the path.

References KoPathShape::arcTo(), KoPathShape::clear(), Curve, KoPathShape::lineTo(), m_clockwise, m_fade, m_points, m_radii, m_type, KoPathShape::moveTo(), KoPathShape::notifyPointsChanged(), KoPathShape::size(), and KoPathShape::subpaths().

◆ fade()

qreal SpiralShape::fade ( ) const

Returns the actual fade parameter.

Definition at line 268 of file SpiralShape.cpp.

269{
270 return m_fade;
271}

References m_fade.

◆ moveHandleAction()

void SpiralShape::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 75 of file SpiralShape.cpp.

76{
77 Q_UNUSED(handleId);
78 Q_UNUSED(point);
79 Q_UNUSED(modifiers);
80#if 0
81 QPointF p(point);
82
83 QPointF diff(m_center - point);
84 diff.setX(-diff.x());
85 qreal angle = 0;
86 if (diff.x() == 0) {
87 angle = (diff.y() < 0 ? 270 : 90) * M_PI / 180.0;
88 } else {
89 diff.setY(diff.y() * m_radii.x() / m_radii.y());
90 angle = atan(diff.y() / diff.x());
91 if (angle < 0) {
92 angle = M_PI + angle;
93 }
94 if (diff.y() < 0) {
95 angle += M_PI;
96 }
97 }
98
99 switch (handleId) {
100 case 0:
101 p = QPointF(m_center + QPointF(cos(angle) * m_radii.x(), -sin(angle) * m_radii.y()));
102 m_handles[handleId] = p;
104 break;
105 case 1:
106 p = QPointF(m_center + QPointF(cos(angle) * m_radii.x(), -sin(angle) * m_radii.y()));
107 m_handles[handleId] = p;
109 break;
110 case 2: {
111 QList<QPointF> kindHandlePositions;
112 kindHandlePositions.push_back(QPointF(m_center + QPointF(cos(m_kindAngle) * m_radii.x(), -sin(m_kindAngle) * m_radii.y())));
113 kindHandlePositions.push_back(m_center);
114 kindHandlePositions.push_back((m_handles[0] + m_handles[1]) / 2.0);
115
116 QPointF diff = m_center * 2.0;
117 int handlePos = 0;
118 for (int i = 0; i < kindHandlePositions.size(); ++i) {
119 QPointF pointDiff(p - kindHandlePositions[i]);
120 if (i == 0 || qAbs(pointDiff.x()) + qAbs(pointDiff.y()) < qAbs(diff.x()) + qAbs(diff.y())) {
121 diff = pointDiff;
122 handlePos = i;
123 }
124 }
125 m_handles[handleId] = kindHandlePositions[handlePos];
126 m_type = SpiralType(handlePos);
127 } break;
128 }
129#endif
130}
const Params2D p
void updateKindHandle()
SpiralType
the possible spiral types
Definition SpiralShape.h:22

References m_center, m_kindAngle, M_PI, m_radii, m_type, p, and updateKindHandle().

◆ normalize()

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

Definition at line 66 of file SpiralShape.cpp.

67{
68 QPointF offset(KoParameterShape::normalize());
69 QTransform matrix;
70 matrix.translate(-offset.x(), -offset.y());
71 m_center = matrix.map(m_center);
72 return offset;
73}
QPointF normalize() override
Normalizes the path data.

References m_center, and KoParameterShape::normalize().

◆ pathShapeId()

QString SpiralShape::pathShapeId ( ) const
overridevirtual

reimplemented

Reimplemented from KoPathShape.

Definition at line 286 of file SpiralShape.cpp.

287{
288 return SpiralShapeId;
289}
#define SpiralShapeId
Definition SpiralShape.h:12

References SpiralShapeId.

◆ setClockWise()

void SpiralShape::setClockWise ( bool clockwise)

Definition at line 278 of file SpiralShape.cpp.

279{
282 //updateAngleHandles();
283 updatePath(size());
284}
void updatePath(const QSizeF &size) override
Update the path of the parameter shape.
bool clockWise() const

References clockWise(), m_clockwise, KoPathShape::size(), updateKindHandle(), and updatePath().

◆ setFade()

void SpiralShape::setFade ( qreal fade)

Sets the fade parameter of the spiral.

Parameters
anglethe new start angle in degree

Definition at line 260 of file SpiralShape.cpp.

261{
262 m_fade = fade;
264 //updateAngleHandles();
265 updatePath(size());
266}
qreal fade() const
Returns the actual fade parameter.

References fade(), m_fade, KoPathShape::size(), updateKindHandle(), and updatePath().

◆ setSize()

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

reimplemented from KoShape

Reimplemented from KoParameterShape.

Definition at line 58 of file SpiralShape.cpp.

59{
60 QTransform matrix(resizeMatrix(newSize));
61 m_center = matrix.map(m_center);
62 m_radii = matrix.map(m_radii);
64}
void setSize(const QSizeF &size) override
reimplemented from KoShape
QTransform resizeMatrix(const QSizeF &newSize) const

References m_center, m_radii, KoPathShape::resizeMatrix(), and KoParameterShape::setSize().

◆ setType()

void SpiralShape::setType ( SpiralType type)

Sets the type of the spiral.

Parameters
typethe new spiral type

Definition at line 248 of file SpiralShape.cpp.

249{
250 m_type = type;
252 updatePath(size());
253}
SpiralType type() const
Returns the actual spiral type.

References m_type, KoPathShape::size(), type(), updateKindHandle(), and updatePath().

◆ type()

SpiralShape::SpiralType SpiralShape::type ( ) const

Returns the actual spiral type.

Definition at line 255 of file SpiralShape.cpp.

256{
257 return m_type;
258}

References m_type.

◆ updateAngleHandles()

void SpiralShape::updateAngleHandles ( )
private

Definition at line 240 of file SpiralShape.cpp.

241{
242// qreal startRadian = m_startAngle * M_PI / 180.0;
243// qreal endRadian = m_endAngle * M_PI / 180.0;
244// m_handles[0] = m_center + QPointF(cos(startRadian) * m_radii.x(), -sin(startRadian) * m_radii.y());
245// m_handles[1] = m_center + QPointF(cos(endRadian) * m_radii.x(), -sin(endRadian) * m_radii.y());
246}

◆ updateKindHandle()

void SpiralShape::updateKindHandle ( )
private

Definition at line 220 of file SpiralShape.cpp.

221{
222 /*
223 m_kindAngle = (m_startAngle + m_endAngle) * M_PI / 360.0;
224 if (m_startAngle > m_endAngle)
225 {
226 m_kindAngle += M_PI;
227 }
228 switch (m_type)
229 {
230 case Curve:
231 m_handles[2] = m_center + QPointF(cos(m_kindAngle) * m_radii.x(), -sin(m_kindAngle) * m_radii.y());
232 break;
233 case Line:
234 m_handles[2] = m_center;
235 break;
236 }
237 */
238}

◆ updatePath()

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

Update the path of the parameter shape.

Parameters
sizeof the shape

Implements KoParameterShape.

Definition at line 132 of file SpiralShape.cpp.

133{
135 normalize();
136#if 0
137 Q_UNUSED(size);
138 QPointF startpoint(m_handles[0]);
139
140 QPointF curvePoints[12];
141
142 int pointCnt = arcToCurve(m_radii.x(), m_radii.y(), m_startAngle, sweepAngle(), startpoint, curvePoints);
143
144 int cp = 0;
145 m_points[cp]->setPoint(startpoint);
146 m_points[cp]->unsetProperty(KoPathPoint::HasControlPoint1);
147 for (int i = 0; i < pointCnt; i += 3) {
148 m_points[cp]->setControlPoint2(curvePoints[i]);
149 m_points[++cp]->setControlPoint1(curvePoints[i + 1]);
150 m_points[cp]->setPoint(curvePoints[i + 2]);
151 m_points[cp]->unsetProperty(KoPathPoint::HasControlPoint2);
152 }
153 if (m_type == Curve) {
154 m_points[++cp]->setPoint(m_center);
155 m_points[cp]->unsetProperty(KoPathPoint::HasControlPoint1);
156 m_points[cp]->unsetProperty(KoPathPoint::HasControlPoint2);
157 } else if (m_type == Line && m_startAngle == m_endAngle) {
158 m_points[0]->setControlPoint1(m_points[cp]->controlPoint1());
159 m_points[0]->setPoint(m_points[cp]->point());
160 --cp;
161 }
162
163 d->m_subpaths[0]->clear();
164 for (int i = 0; i <= cp; ++i) {
165 if (i < cp || (m_type == Line && m_startAngle != m_endAngle)) {
166 m_points[i]->unsetProperty(KoPathPoint::CloseSubpath);
167 } else {
168 m_points[i]->setProperty(KoPathPoint::CloseSubpath);
169 }
170 d->m_subpaths[0]->push_back(m_points[i]);
171 }
172
173#endif
174}
QSharedDataPointer< Private > d
@ CloseSubpath
it closes a subpath (only applicable on StartSubpath and StopSubpath)
Definition KoPathPoint.h:40
int arcToCurve(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle, const QPointF &offset, QPointF *curvePoints) const
Add an arc.
QPointF normalize() override
Normalizes the path data.

References KoPathShape::arcToCurve(), KoPathPoint::CloseSubpath, createPath(), Curve, KoParameterShape::d, Line, m_center, m_points, m_radii, m_type, normalize(), and KoPathShape::size().

Member Data Documentation

◆ m_center

QPointF SpiralShape::m_center
private

Definition at line 75 of file SpiralShape.h.

◆ m_clockwise

bool SpiralShape::m_clockwise
private

Definition at line 81 of file SpiralShape.h.

◆ m_fade

qreal SpiralShape::m_fade
private

Definition at line 71 of file SpiralShape.h.

◆ m_kindAngle

qreal SpiralShape::m_kindAngle
private

Definition at line 73 of file SpiralShape.h.

◆ m_points

KoSubpath SpiralShape::m_points
private

Definition at line 83 of file SpiralShape.h.

◆ m_radii

QPointF SpiralShape::m_radii
private

Definition at line 77 of file SpiralShape.h.

◆ m_type

SpiralType SpiralShape::m_type
private

Definition at line 79 of file SpiralShape.h.


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