36 m_cornerCount(rhs.m_cornerCount),
37 m_radius(rhs.m_radius),
38 m_angles(rhs.m_angles),
41 m_roundness(rhs.m_roundness),
42 m_center(rhs.m_center),
43 m_convex(rhs.m_convex)
127 if (modifiers & Qt::ShiftModifier) {
128 QPointF handle =
handles()[handleId];
129 QPointF tangentVector = point - handle;
130 qreal
distance = sqrt(tangentVector.x() * tangentVector.x() + tangentVector.y() * tangentVector.y());
131 QPointF radialVector = handle -
m_center;
133 qreal moveDirection = radialVector.x() * tangentVector.y() - radialVector.y() * tangentVector.x();
135 float snapDistance = 3.0;
142 if (modifiers & Qt::ControlModifier) {
148 QPointF distVector = point -
m_center;
152 m_radius[handleId] = sqrt(distVector.x() * distVector.x() + distVector.y() * distVector.y());
154 qreal angle = atan2(distVector.y(), distVector.x());
158 qreal diffAngle = angle -
m_angles[handleId];
160 if (handleId ==
tip) {
165 if (modifiers & Qt::ControlModifier) {
185 uint cornerType = i % 2;
189 qreal radian =
static_cast<qreal
>((i + 1) * radianStep) +
m_angles[cornerType];
192 points[index]->setPoint(
m_center + cornerPoint);
197 QPointF tangentVector(cornerPoint.y() /
m_radius[cornerType], -cornerPoint.x() /
m_radius[cornerType]);
198 points[index]->setControlPoint2(points[index]->point() -
m_roundness[cornerType] * tangentVector);
199 points[index]->setControlPoint1(points[index]->point() +
m_roundness[cornerType] * tangentVector);
201 points[index]->removeControlPoint1();
202 points[index]->removeControlPoint2();
232 int currentPointCount =
subpaths()[0]->count();
233 if (currentPointCount > requiredPointCount) {
234 for (
int i = 0; i < currentPointCount - requiredPointCount; ++i) {
238 }
else if (requiredPointCount > currentPointCount) {
239 for (
int i = 0; i < requiredPointCount - currentPointCount; ++i) {
263 QPointF center(0, 0);
266 center += points[i]->point();
268 center += points[2 * i]->point();
287 return M_PI_2 - 2 * radianStep;
qreal distance(const QPointF &p1, const QPointF &p2)
QList< KoPathPoint * > KoSubpath
a KoSubpath contains a path from a moveTo until a close or a new moveTo
QPointF normalize() override
Normalizes the path data.
QList< QPointF > handles
the handles that the user can grab and change
void setSize(const QSizeF &size) override
reimplemented from KoShape
void setHandles(const QList< QPointF > &handles)
A KoPathPoint represents a point in a path.
@ StartSubpath
it starts a new subpath by a moveTo command
@ CloseSubpath
it closes a subpath (only applicable on StartSubpath and StopSubpath)
@ StopSubpath
it stops a subpath (last point of subpath)
const KoSubpathList & subpaths() const
QTransform resizeMatrix(const QSizeF &newSize) const
QSizeF size() const override
reimplemented
void notifyPointsChanged()
void clear()
Removes all subpaths and their points from the path.
QString pathShapeId() const override
reimplemented
uint cornerCount() const
Returns the number of corners.
qreal m_zoomY
scaling in y
bool m_convex
controls if the star is convex
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)
uint m_cornerCount
number of corners
QPointF starCenter() const
std::array< qreal, 2 > m_radius
the different radii
void setCornerCount(uint cornerCount)
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
double defaultAngleRadian() const
Returns the default offset angle in radian.
void setTipRadius(qreal tipRadius)
KoShape * cloneShape() const override
creates a deep copy of the shape or shape's subtree
void setTipRoundness(qreal tipRoundness)
qreal baseRadius() const
Returns the base radius.
void createPoints(int requiredPointCount)
recreates the path points when the corner count or convexity changes
qreal tipRadius() const
Returns the tip radius.
std::array< qreal, 2 > m_roundness
the roundness at the handles
std::array< qreal, 2 > m_angles
the offset angles
void updatePath(const QSizeF &size) override
Update the path of the parameter shape.
void setBaseRoundness(qreal baseRoundness)
void setConvex(bool convex)
QPointF m_center
the star center point