21 return qIsNaN(
p.x()) || qIsNaN(
p.y());
28 : shape(0), properties(Normal)
29 , activeControlPoint1(false), activeControlPoint2(false) {}
43 d->point = pathPoint.
d->point;
44 d->controlPoint1 = pathPoint.
d->controlPoint1;
45 d->controlPoint2 = pathPoint.
d->controlPoint2;
46 d->properties = pathPoint.
d->properties;
47 d->activeControlPoint1 = pathPoint.
d->activeControlPoint1;
48 d->activeControlPoint2 = pathPoint.
d->activeControlPoint2;
82 d->shape = rhs.
d->shape;
83 d->point = rhs.
d->point;
84 d->controlPoint1 = rhs.
d->controlPoint1;
85 d->controlPoint2 = rhs.
d->controlPoint2;
86 d->properties = rhs.
d->properties;
87 d->activeControlPoint1 = rhs.
d->activeControlPoint1;
88 d->activeControlPoint2 = rhs.
d->activeControlPoint2;
95 if (
d->point != rhs.
d->point)
97 if (
d->controlPoint1 != rhs.
d->controlPoint1)
99 if (
d->controlPoint2 != rhs.
d->controlPoint2)
101 if (
d->properties != rhs.
d->properties)
103 if (
d->activeControlPoint1 != rhs.
d->activeControlPoint1)
105 if (
d->activeControlPoint2 != rhs.
d->activeControlPoint2)
114 d->shape->notifyChanged();
122 d->activeControlPoint1 =
true;
124 d->shape->notifyChanged();
132 d->activeControlPoint2 =
true;
134 d->shape->notifyChanged();
139 d->activeControlPoint1 =
false;
140 d->properties &= ~IsSmooth;
141 d->properties &= ~IsSymmetric;
143 d->shape->notifyChanged();
148 d->activeControlPoint2 =
false;
149 d->properties &= ~IsSmooth;
150 d->properties &= ~IsSymmetric;
152 d->shape->notifyChanged();
160 d->properties &= ~CloseSubpath;
164 d->properties &= ~IsSmooth;
165 d->properties &= ~IsSymmetric;
169 d->shape->notifyChanged();
181 d->properties &= ~IsSymmetric;
184 d->properties &= ~IsSmooth;
189 d->properties |= property;
193 d->properties &= ~IsSymmetric;
194 d->properties &= ~IsSmooth;
203 d->properties &= ~CloseSubpath;
207 d->properties &= ~CloseSubpath;
211 d->properties &= ~IsSmooth;
212 d->properties &= ~IsSymmetric;
221 d->properties &= ~property;
230 return d->activeControlPoint1;
239 return d->activeControlPoint2;
244 d->point = matrix.map(
d->point);
245 d->controlPoint1 = matrix.map(
d->controlPoint1);
246 d->controlPoint2 = matrix.map(
d->controlPoint2);
249 d->shape->notifyChanged();
258 if (drawControlPoint2) {
262 if (drawControlPoint1) {
278 if (drawControlPoint2) {
283 if (drawControlPoint1) {
297 QRectF
rect(
d->point, QSize(1, 1));
299 QRectF
r1(
d->point, QSize(1, 1));
300 r1.setBottomRight(
d->controlPoint1);
304 QRectF
r2(
d->point, QSize(1, 1));
305 r2.setBottomRight(
d->controlPoint2);
309 return d->shape->shapeToDocument(
rect);
316 std::swap(
d->controlPoint1,
d->controlPoint2);
317 std::swap(
d->activeControlPoint1,
d->activeControlPoint2);
318 PointProperties newProps =
Normal;
324 d->properties = newProps;
349 if (next->activeControlPoint1())
350 t2 = next->controlPoint1() -
point();
352 t2 = next->point() -
point();
356 qreal l1 = sqrt(t1.x() * t1.x() + t1.y() * t1.y());
357 qreal l2 = sqrt(t2.x() * t2.x() + t2.y() * t2.y());
364 qreal scalar = t1.x() * t2.x() + t1.y() * t2.y();
371 return d->properties;
381 return d->controlPoint1;
386 return d->controlPoint2;
static bool qIsNaNPoint(const QPointF &p)
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawHandleSmallCircle(const QPointF ¢er)
void drawHandleRect(const QPointF ¢er, qreal radius)
void drawConnectionLine(const QLineF &line)
void drawGradientHandle(const QPointF ¢er, qreal radius)
void drawHandleCircle(const QPointF ¢er, qreal radius)
A KoPathPoint represents a point in a path.
PointProperties properties
void setProperties(PointProperties properties)
Set the properties of a point.
QRectF boundingRect(bool active=true) const
Get the bounding rect of the point.
void reverse()
Reverses the path point.
void setControlPoint1(const QPointF &point)
Set the control point 1.
void setProperty(PointProperty property)
Sets a single property of a point.
KoPathPoint & operator=(const KoPathPoint &other)
Assignment operator.
bool operator==(const KoPathPoint &other) const
Compare operator.
void setControlPoint2(const QPointF &point)
Set the control point 2.
void removeControlPoint1()
Removes the first control point.
KoPathPoint()
Default constructor.
bool isSmooth(KoPathPoint *previous, KoPathPoint *next) const
void map(const QTransform &matrix)
apply matrix on the point
KoPathShape * parent() const
Get the path shape the point belongs to.
PointProperty
property enum
@ IsSmooth
it is smooth, both control points on a line through the point
@ StartSubpath
it starts a new subpath by a moveTo command
@ Normal
it has no control points
@ IsSymmetric
it is symmetric, like smooth but control points have same distance to point
@ CloseSubpath
it closes a subpath (only applicable on StartSubpath and StopSubpath)
@ StopSubpath
it stops a subpath (last point of subpath)
void setPoint(const QPointF &point)
alter the point
@ ControlPoint2
the second control point
@ ControlPoint1
the first control point
void unsetProperty(PointProperty property)
Removes a property from the point.
~KoPathPoint()
Destructor.
void removeControlPoint2()
Removes the second control point.
void paint(KisHandlePainterHelper &handlesHelper, PointTypes types, bool active=true)
void setParent(KoPathShape *parent)
Sets the parent path shape.
The position of a path point within a path shape.
static bool qFuzzyCompare(half p1, half p2)