Krita Source Code Documentation
Loading...
Searching...
No Matches
StarShape.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2006-2008 Jan Hambrecht <jaham@gmx.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KOSTARSHAPE_H
8#define KOSTARSHAPE_H
9
10#include <array>
11#include <KoParameterShape.h>
12
13#define StarShapeId "StarShape"
14
23{
24public:
25 StarShape();
26 ~StarShape() override;
27
28 KoShape* cloneShape() const override;
29
41
43 uint cornerCount() const;
44
50 void setBaseRadius(qreal baseRadius);
51
53 qreal baseRadius() const;
54
59 void setTipRadius(qreal tipRadius);
60
62 qreal tipRadius() const;
63
71 void setBaseRoundness(qreal baseRoundness);
72
80 void setTipRoundness(qreal tipRoundness);
81
86 void setConvex(bool convex);
87
89 bool convex() const;
90
97 QPointF starCenter() const;
98
100 void setSize(const QSizeF &newSize) override;
102 QString pathShapeId() const override;
103
104protected:
105 StarShape(const StarShape &rhs);
106
107 void moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers = Qt::NoModifier) override;
108 void updatePath(const QSizeF &size) override;
110 void createPoints(int requiredPointCount);
111
112private:
114 QPointF computeCenter() const;
115
117 double defaultAngleRadian() const;
118
120 enum Handles { tip = 0, base = 1 };
121
123 std::array<qreal, 2> m_radius;
124 std::array<qreal, 2> m_angles;
125 qreal m_zoomX;
126 qreal m_zoomY;
127 std::array<qreal, 2> m_roundness;
128 QPointF m_center;
129 bool m_convex;
130};
131
132#endif /* KOSTARSHAPE_H */
133
unsigned int uint
QSizeF size() const override
reimplemented
QString pathShapeId() const override
reimplemented
uint cornerCount() const
Returns the number of corners.
Definition StarShape.cpp:70
qreal m_zoomY
scaling in y
Definition StarShape.h:126
bool m_convex
controls if the star is convex
Definition StarShape.h:129
~StarShape() override
Definition StarShape.cpp:47
void moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier) override
Updates the internal state of a KoParameterShape.
void setSize(const QSizeF &newSize) override
reimplemented
void setBaseRadius(qreal baseRadius)
Definition StarShape.cpp:75
uint m_cornerCount
number of corners
Definition StarShape.h:122
QPointF starCenter() const
Handles
the handle types
Definition StarShape.h:120
std::array< qreal, 2 > m_radius
the different radii
Definition StarShape.h:123
void setCornerCount(uint cornerCount)
Definition StarShape.cpp:57
QPointF computeCenter() const
Computes the star center point from the inner points.
bool convex() const
Returns if the star represents a regular polygon.
qreal m_zoomX
scaling in x
Definition StarShape.h:125
double defaultAngleRadian() const
Returns the default offset angle in radian.
void setTipRadius(qreal tipRadius)
Definition StarShape.cpp:86
KoShape * cloneShape() const override
creates a deep copy of the shape or shape's subtree
Definition StarShape.cpp:51
void setTipRoundness(qreal tipRoundness)
qreal baseRadius() const
Returns the base radius.
Definition StarShape.cpp:81
void createPoints(int requiredPointCount)
recreates the path points when the corner count or convexity changes
qreal tipRadius() const
Returns the tip radius.
Definition StarShape.cpp:92
std::array< qreal, 2 > m_roundness
the roundness at the handles
Definition StarShape.h:127
std::array< qreal, 2 > m_angles
the offset angles
Definition StarShape.h:124
void updatePath(const QSizeF &size) override
Update the path of the parameter shape.
void setBaseRoundness(qreal baseRoundness)
Definition StarShape.cpp:97
void setConvex(bool convex)
QPointF m_center
the star center point
Definition StarShape.h:128