Krita Source Code Documentation
Loading...
Searching...
No Matches
TwoPointAssistant.cc
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
3 * SPDX-FileCopyrightText: 2010 Geoffry Song <goffrie@gmail.com>
4 * SPDX-FileCopyrightText: 2021 Nabil Maghfur Usman <nmaghfurusman@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8
9#include "TwoPointAssistant.h"
10#include "kis_debug.h"
11#include <klocalizedstring.h>
12
13#include <QPainter>
14#include <QPainterPath>
15#include <QLinearGradient>
16#include <QTransform>
17
18#include <kis_canvas2.h>
20#include <kis_algebra_2d.h>
21#include <kis_dom_utils.h>
22#include <math.h>
23#include <cmath>
24#include <QtCore/qmath.h>
25#include <kis_assert.h>
27
30 , KisPaintingAssistant("two point", i18n("Two point assistant"))
31{
32}
33
34TwoPointAssistant::TwoPointAssistant(const TwoPointAssistant &rhs, QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap)
35 : KisAbstractPerspectiveGrid(rhs.parent())
36 , KisPaintingAssistant(rhs, handleMap)
37 , m_canvas(rhs.m_canvas)
38 , m_snapLine(rhs.m_snapLine)
39 , m_gridDensity(rhs.m_gridDensity)
40 , m_useVertical(rhs.m_useVertical)
41 , m_lastUsedPoint(rhs.m_lastUsedPoint)
42{
43}
44
45KisPaintingAssistantSP TwoPointAssistant::clone(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap) const
46{
47 return KisPaintingAssistantSP(new TwoPointAssistant(*this, handleMap));
48}
49
50QPointF TwoPointAssistant::project(const QPointF& point, const QPointF& strokeBegin, const bool snapToAny, qreal moveThreshold)
51{
52 Q_ASSERT(isAssistantComplete());
53
54 QPointF best_pt = point;
55 double best_dist = DBL_MAX;
56 QList<int> possibleHandles;
57
58 // must be above or equal to 0;
59 // if useVertical, then last used point must be below 3, because 2 means vertical
60 // and it's the last possible point here (sanity check)
61 // if !useVertical, then it must be below 2, because 2 means vertical
62 bool isLastUsedPointCorrectNow = m_lastUsedPoint >= 0 && (m_useVertical ? m_lastUsedPoint < 3 : m_lastUsedPoint < 2);
63
64 if (isLocal() && handles().size() == 5) {
65 // here we can just return since we don't want to do anything
66 // so we're returning a NaN
67 // but only if we don't have a point/axes it was already using
68
69 QRectF rect = getLocalRect();
70 bool insideLocalRect = rect.contains(point);
71 if (!insideLocalRect && (!isLastUsedPointCorrectNow || !m_hasBeenInsideLocalRect)) {
72 return QPointF(qQNaN(), qQNaN());
73 } else if (insideLocalRect) {
75 }
76 }
77
78 if (!isLastUsedPointCorrectNow && KisAlgebra2D::norm(point - strokeBegin) < moveThreshold) {
79 return strokeBegin;
80 }
81
82 if (!snapToAny && isLastUsedPointCorrectNow) {
83 possibleHandles = QList<int>({m_lastUsedPoint});
84 } else {
85 if (m_useVertical) {
86 possibleHandles = QList<int>({0, 1, 2});
87 } else {
88 possibleHandles = QList<int>({0, 1});
89 }
90 }
91
92 Q_FOREACH (int vpIndex, possibleHandles) {
93 QPointF vp = *handles()[vpIndex];
94 double dist = 0;
95 QPointF pt = QPointF();
96 QLineF snapLine = QLineF();
97
98 // TODO: Would be a good idea to generalize this whole routine
99 // in KisAlgebra2d, as it's all lifted from the vanishing
100 // point assistant and parallel ruler assistant, and by
101 // extension the perspective assistant...
102 qreal dx = point.x() - strokeBegin.x();
103 qreal dy = point.y() - strokeBegin.y();
104
105 if (vp != *handles()[2]) {
106 snapLine = QLineF(vp, strokeBegin);
107 } else {
108 QLineF vertical = QLineF(*handles()[0],*handles()[1]).normalVector();
109 snapLine = QLineF(vertical.p1(), vertical.p2());
110 QPointF translation = (vertical.p1()-strokeBegin)*-1.0;
111 snapLine = snapLine.translated(translation);
112 }
113
114 dx = snapLine.dx();
115 dy = snapLine.dy();
116
117 const qreal dx2 = dx * dx;
118 const qreal dy2 = dy * dy;
119 const qreal invsqrlen = 1.0 / (dx2 + dy2);
120
121 pt = QPointF(dx2 * point.x() + dy2 * snapLine.x1() + dx * dy * (point.y() - snapLine.y1()),
122 dx2 * snapLine.y1() + dy2 * point.y() + dx * dy * (point.x() - snapLine.x1()));
123
124 pt *= invsqrlen;
125 dist = qAbs(pt.x() - point.x()) + qAbs(pt.y() - point.y());
126
127 if (dist < best_dist) {
128 best_pt = pt;
129 best_dist = dist;
130 m_lastUsedPoint = vpIndex;
131 }
132 }
133
134 return best_pt;
135}
136
143
144QPointF TwoPointAssistant::adjustPosition(const QPointF& pt, const QPointF& strokeBegin, const bool snapToAny, qreal moveThresholdPt)
145{
146 return project(pt, strokeBegin, snapToAny, moveThresholdPt);
147}
148
149void TwoPointAssistant::adjustLine(QPointF &point, QPointF &strokeBegin)
150{
151 QPointF p = project(point, strokeBegin, true, 0.0);
152 point = p;
153}
154
155void TwoPointAssistant::drawAssistant(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter* converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool cached, KisCanvas2* canvas, bool assistantVisible, bool previewVisible)
156{
157 Q_UNUSED(updateRect);
158 Q_UNUSED(cached);
159 gc.save();
160 gc.resetTransform();
161
162 const QColor canvasAssistantColor = displayRenderInterface->convertColorToDisplayColorSpace(KoColor(effectiveAssistantColor(), KoColorSpaceRegistry::instance()->rgb8()));
163
164 const QTransform initialTransform = converter->documentToWidgetTransform();
165 bool isEditing = false;
166 bool showLocal = isLocal() && handles().size() == 5;
167
168 if (canvas) {
169 isEditing = canvas->paintingAssistantsDecoration()->isEditingAssistants();
170 }
171
172 if (isEditing) {
173 Q_FOREACH (const QPointF* handle, handles()) {
174 QPointF h = initialTransform.map(*handle);
175 QRectF ellipse = QRectF(QPointF(h.x() -15, h.y() -15), QSizeF(30, 30));
176
177 QPainterPath pathCenter;
178 pathCenter.addEllipse(ellipse);
179 drawPath(gc, pathCenter, displayRenderInterface, isSnappingActive());
180
181 // Draw circle to represent center of vision
182 if (handles().length() == 3 && handle == handles()[2]) {
183 const QLineF horizon = QLineF(*handles()[0],*handles()[1]);
184 QLineF normal = horizon.normalVector();
185 normal.translate(*handles()[2]-normal.p1());
186 QPointF cov = horizon.center();
187 normal.intersects(horizon,&cov);
188 const QPointF center = initialTransform.map(cov);
189 QRectF center_ellipse = QRectF(QPointF(center.x() -15, center.y() -15), QSizeF(30, 30));
190 QPainterPath pathCenter;
191 pathCenter.addEllipse(center_ellipse);
192 drawPath(gc, pathCenter, displayRenderInterface, isSnappingActive());
193 }
194 }
195
196 if (handles().size() <= 2) {
197 QPainterPath path;
198 int tempDensity = m_gridDensity * 10; // the vanishing point density seems visibly more dense, hence let's make it less dense
199 QRect viewport = gc.viewport();
200
201 for (int i = 0; i < handles().size(); i++) {
202 const QPointF p = initialTransform.map(*handles()[i]);
203 for (int currentAngle=0; currentAngle <= 180; currentAngle = currentAngle + tempDensity) {
204
205 // determine the correct angle based on the iteration
206 float xPos = cos(currentAngle * M_PI / 180);
207 float yPos = sin(currentAngle * M_PI / 180);
208 float length = 100;
209 QPointF unit = QPointF(length*xPos, length*yPos);
210
211 // find point
212 QLineF snapLine = QLineF(p, p + unit);
213 if (KisAlgebra2D::intersectLineRect(snapLine, viewport, false)) {
214 // make a line from VP center to edge of canvas with that angle
215
216 path.moveTo(snapLine.p1());
217 path.lineTo(snapLine.p2());
218 }
219
220 QLineF snapLine2 = QLineF(p, p - unit);
221 if (KisAlgebra2D::intersectLineRect(snapLine2, viewport, false)) {
222 // make a line from VP center to edge of canvas with that angle
223
224 path.moveTo(snapLine2.p1());
225 path.lineTo(snapLine2.p2());
226 }
227
228
229 }
230
231 drawPreview(gc, path, displayRenderInterface);//and we draw the preview.
232
233 }
234 }
235
236 }
237
238 if (handles().size() >= 2) {
239 QPointF mousePos = effectiveBrushPosition(converter, canvas);
240 const QPointF p1 = *handles()[0];
241 const QPointF p2 = *handles()[1];
242 const QRect viewport= gc.viewport();
243
244 const QPolygonF localPoly = (isLocal() && handles().size() == 5) ? initialTransform.map(QPolygonF(getLocalRect())) : QPolygonF();
245 const QPolygonF viewportAndLocalPoly = !localPoly.isEmpty() ? QPolygonF(QRectF(viewport)).intersected(localPoly) : QRectF(viewport);
246
247
248 QPainterPath path;
249 QPainterPath previewPath; // part of the preview, instead of the assistant itself
250
251 // draw the horizon
252 if (assistantVisible == true || isEditing == true) {
253 QLineF horizonLine = initialTransform.map(QLineF(p1,p2));
254 KisAlgebra2D::cropLineToConvexPolygon(horizonLine, viewportAndLocalPoly, true, true);
255 path.moveTo(horizonLine.p1());
256 path.lineTo(horizonLine.p2());
257 }
258
259 // draw the VP-->mousePos lines
260 if (isEditing == false && previewVisible == true && isSnappingActive() == true) {
261 // draw the line vp <-> mouse even outside of the local rectangle
262 // but only if the mouse pos is inside the rectangle
263 QLineF snapMouse1 = QLineF(initialTransform.map(p1), mousePos);
264 QLineF snapMouse2 = QLineF(initialTransform.map(p2), mousePos);
265 KisAlgebra2D::cropLineToConvexPolygon(snapMouse1, viewportAndLocalPoly, false, true);
266 KisAlgebra2D::cropLineToConvexPolygon(snapMouse2, viewportAndLocalPoly, false, true);
267 previewPath.moveTo(snapMouse1.p1());
268 previewPath.lineTo(snapMouse1.p2());
269 previewPath.moveTo(snapMouse2.p1());
270 previewPath.lineTo(snapMouse2.p2());
271 }
272
273 // draw the side handle bars
274 if (isEditing == true && !sideHandles().isEmpty()) {
275 path.moveTo(initialTransform.map(p1));
276 path.lineTo(initialTransform.map(*sideHandles()[0]));
277 path.lineTo(initialTransform.map(*sideHandles()[1]));
278 path.moveTo(initialTransform.map(p2));
279 path.lineTo(initialTransform.map(*sideHandles()[2]));
280 path.lineTo(initialTransform.map(*sideHandles()[3]));
281 path.moveTo(initialTransform.map(p1));
282 path.lineTo(initialTransform.map(*sideHandles()[4]));
283 path.lineTo(initialTransform.map(*sideHandles()[5]));
284 path.moveTo(initialTransform.map(p2));
285 path.lineTo(initialTransform.map(*sideHandles()[6]));
286 path.lineTo(initialTransform.map(*sideHandles()[7]));
287 }
288
289 // draw the local rectangle
290 if (showLocal && assistantVisible) {
291 QPointF p1 = *handles()[(int)LocalFirstHandle];
292 QPointF p3 = *handles()[(int)LocalSecondHandle];
293 QPointF p2 = QPointF(p1.x(), p3.y());
294 QPointF p4 = QPointF(p3.x(), p1.y());
295
296 path.moveTo(initialTransform.map(p1));
297
298 path.lineTo(initialTransform.map(p2));
299 path.lineTo(initialTransform.map(p3));
300 path.lineTo(initialTransform.map(p4));
301 path.lineTo(initialTransform.map(p1));
302 }
303
304
305 drawPreview(gc,previewPath, displayRenderInterface);
306 drawPath(gc, path, displayRenderInterface, isSnappingActive());
307
308 if (handles().size() >= 3 && isSnappingActive()) {
309 path = QPainterPath(); // clear
310 const QPointF p3 = *handles()[2];
311
312 qreal size = 0;
313 const QTransform t = localTransform(p1,p2,p3,&size);
314 const QTransform inv = t.inverted();
315 const QPointF vp_a = t.map(p1);
316 const QPointF vp_b = t.map(p2);
317
318 if ((vp_a.x() < 0 && vp_b.x() > 0) ||
319 (vp_a.x() > 0 && vp_b.x() < 0)) {
320 if (m_useVertical) {
321 // Draw vertical line, but only if the center is between both VPs
322 QLineF vertical = initialTransform.map(inv.map(QLineF::fromPolar(1,90)));
323 if (!isEditing) vertical.translate(mousePos - vertical.p1());
324 KisAlgebra2D::cropLineToConvexPolygon(vertical, viewportAndLocalPoly, true, true);
325 if (previewVisible) {
326 path.moveTo(vertical.p1());
327 path.lineTo(vertical.p2());
328 }
329
330 if (assistantVisible) {
331 // Display a notch to represent the center of vision
332 path.moveTo(initialTransform.map(inv.map(QPointF(0,-10))));
333 path.lineTo(initialTransform.map(inv.map(QPointF(0,10))));
334 }
335 drawPreview(gc,path, displayRenderInterface);
336 path = QPainterPath(); // clear
337 }
338 }
339
340 const QPointF upper = QPointF(0, size);
341 const QPointF lower = QPointF(0, -size);
342
343 // Set up the fading effect for the grid lines
344 // Needed so the grid density doesn't look distracting
345 QColor color = canvasAssistantColor;
346 QGradient fade = QLinearGradient(initialTransform.map(inv.map(upper)),
347 initialTransform.map(inv.map(lower)));
348 color.setAlphaF(0);
349 fade.setColorAt(0.4, canvasAssistantColor);
350 fade.setColorAt(0.5, color);
351 fade.setColorAt(0.6, canvasAssistantColor);
352 const QPen pen = gc.pen();
353 const QBrush new_brush = QBrush(fade);
354 int width = 1;
355 const QPen new_pen = QPen(new_brush, width, pen.style());
356 gc.setPen(new_pen);
357
358 const QList<QPointF> station_points = {upper, lower};
359 const QList<QPointF> vanishing_points = {vp_a, vp_b};
360
361 // Draw grid lines above and below the horizon
362 Q_FOREACH (const QPointF sp, station_points) {
363
364 // Draw grid lines towards each vanishing point
365 Q_FOREACH (const QPointF vp, vanishing_points) {
366
367 // Interval between each grid line, uses grid density specified by user
368 const qreal initial_angle = QLineF(sp, vp).angle();
369 const qreal interval = size*m_gridDensity / cos((initial_angle - 90) * M_PI/180);
370 const QPointF translation = QPointF(interval, 0);
371
372 // Draw grid lines originating from both the left and right of the central vertical line
373 Q_FOREACH (const int dir, QList<int>({-1, 1})) {
374
375 // Limit at 300 grid lines per direction, reasonable even for m_gridDensity=0.1;
376 for (int i = 0; i <= 300; i++) {
377 const QLineF gridline = QLineF(sp + translation * i * dir, vp);
378
379 // Don't bother drawing lines that are nearly parallel to horizon
380 const qreal angle = gridline.angle();
381 if (angle < 0.25 || angle > 359.75 || (angle < 180.25 && angle > 179.75)) {
382 break;
383 }
384
385 QLineF drawn_gridline = initialTransform.map(inv.map(gridline));
386 KisAlgebra2D::cropLineToConvexPolygon(drawn_gridline, viewportAndLocalPoly, true, false);
387
388 if (assistantVisible || isEditing == true) {
389 path.moveTo(drawn_gridline.p2());
390 path.lineTo(drawn_gridline.p1());
391 }
392 }
393 }
394 }
395 }
396 gc.drawPath(path);
397 }
398 }
399
400 gc.restore();
401 //KisPaintingAssistant::drawAssistant(gc, updateRect, converter, cached, canvas, assistantVisible, previewVisible);
402}
403
404void TwoPointAssistant::drawCache(QPainter& gc, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool assistantVisible)
405{
406 Q_UNUSED(gc);
407 Q_UNUSED(converter);
408 Q_UNUSED(assistantVisible);
409 Q_UNUSED(displayRenderInterface);
410 if (!m_canvas || !isAssistantComplete()) {
411 return;
412 }
413
414 if (assistantVisible == false || m_canvas->paintingAssistantsDecoration()->isEditingAssistants()) {
415 return;
416 }
417}
418
420{
421 if (handles().size() > LocalFirstHandle) {
422 return handles().at(LocalFirstHandle);
423 } else {
424 return nullptr;
425 }
426}
427
429{
430 if (handles().size() > LocalSecondHandle) {
431 return handles().at(LocalSecondHandle);
432 } else {
433 return nullptr;
434 }
435}
436
438{
439 int centerOfVisionHandle = 2;
440 if (handles().size() > centerOfVisionHandle) {
441 return *handles().at(centerOfVisionHandle);
442 } else if (handles().size() > 0) {
444 return *handles().at(0);
445 } else {
446 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(false, QPointF(0, 0));
447 return QPointF(0, 0);
448 }
449}
450
452{
453 m_gridDensity = density;
454}
455
460
465
467{
468 return m_gridDensity;
469}
470
471QTransform TwoPointAssistant::localTransform(QPointF vp_a, QPointF vp_b, QPointF pt_c, qreal* size) const
472{
473 QTransform t = QTransform();
474 t.rotate(QLineF(vp_a, vp_b).angle());
475 // Translate in the rotated frame: the third handle defines x = 0,
476 // while the vanishing points define the horizon at y = 0.
477 t *= QTransform::fromTranslate(-t.map(pt_c).x(), -t.map(vp_a).y());
478 // For orthogonal vanishing directions the cone radius is the geometric
479 // mean of the distances from the center of vision to the two VPs.
480 *size = std::sqrt(-t.map(vp_a).x() * t.map(vp_b).x());
481
482 return t;
483}
484
486{
487 return handles().size() >= numHandles();
488}
489
491{
492 return true;
493}
494
495bool TwoPointAssistant::localPerspectiveData(const QPointF &point, QPointF *localPoint, qreal *size) const
496{
497 if (!isAssistantComplete()) {
498 return false;
499 }
500
501 const QPointF vpA = *handles()[FirstHandle];
502 const QPointF vpB = *handles()[SecondHandle];
503 const QPointF center = *handles()[VerticalHandle];
504
505 qreal localSize = 0.0;
506 const QTransform transform = localTransform(vpA, vpB, center, &localSize);
507
508 if (!std::isfinite(localSize) || localSize <= 0.0) {
509 return false;
510 }
511
512 const QPointF mappedVpA = transform.map(vpA);
513 const QPointF mappedVpB = transform.map(vpB);
514 if (!std::isfinite(mappedVpA.y()) || !std::isfinite(mappedVpB.y())) {
515 return false;
516 }
517
518 if (localPoint) {
519 *localPoint = transform.map(point);
520 }
521 if (size) {
522 *size = localSize;
523 }
524
525 return true;
526}
527
528bool TwoPointAssistant::contains(const QPointF &point) const
529{
530 QPointF localPoint;
531 qreal size = 0.0;
532
533 if (!localPerspectiveData(point, &localPoint, &size)) {
534 return false;
535 }
536
537 if (isLocal() && handles().size() == numHandles() && !getLocalRect().contains(point)) {
538 return false;
539 }
540
541 const qreal distanceToHorizon = qAbs(localPoint.y());
542 // Rotation can move a point on the inclusive boundary just outside it.
543 return distanceToHorizon <= size || qFuzzyCompare(distanceToHorizon, size);
544}
545
546qreal TwoPointAssistant::distance(const QPointF &point) const
547{
548 QPointF localPoint;
549 qreal size = 0.0;
550
551 if (!localPerspectiveData(point, &localPoint, &size)) {
552 return 1.0;
553 }
554
555 return qBound<qreal>(0.0, qAbs(localPoint.y()) / size, 1.0);
556}
557
559{
560 return isSnappingActive();
561}
562
563void TwoPointAssistant::saveCustomXml(QXmlStreamWriter* xml)
564{
565 xml->writeStartElement("gridDensity");
566 xml->writeAttribute("value", KisDomUtils::toString( this->gridDensity()));
567 xml->writeEndElement();
568 xml->writeStartElement("useVertical");
569 xml->writeAttribute("value", KisDomUtils::toString( (int)this->useVertical()));
570 xml->writeEndElement();
571 xml->writeStartElement("isLocal");
572 xml->writeAttribute("value", KisDomUtils::toString( (int)this->isLocal()));
573 xml->writeEndElement();
574
575}
576
577bool TwoPointAssistant::loadCustomXml(QXmlStreamReader* xml)
578{
579 if (xml && xml->name() == "gridDensity") {
580 this->setGridDensity((float)KisDomUtils::toDouble(xml->attributes().value("value").toString()));
581 }
582 if (xml && xml->name() == "useVertical") {
583 this->setUseVertical((bool)KisDomUtils::toInt(xml->attributes().value("value").toString()));
584 }
585 if (xml && xml->name() == "isLocal") {
586 this->setLocal((bool)KisDomUtils::toInt(xml->attributes().value("value").toString()));
587 }
588 return true;
589}
590
594
598
600{
601 return "two point";
602}
603
605{
606 return i18n("2 Point Perspective");
607}
608
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
float value(const T *src, size_t ch)
const Params2D p
QPointF p2
QPointF p3
QPointF p1
KisPaintingAssistantsDecorationSP paintingAssistantsDecoration() const
QPointF effectiveBrushPosition(const KisCoordinatesConverter *converter, KisCanvas2 *canvas) const
Query the effective brush position to be used for preview lines. This is intended to be used for pain...
void drawPreview(QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface)
virtual void transform(const QTransform &transform)
QRectF getLocalRect() const
getLocalRect The function deals with local handles not being topLeft and bottomRight gracefully and r...
const QList< KisPaintingAssistantHandleSP > & sideHandles() const
void drawPath(QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface, bool drawActive=true, QPen startingPen=QPen())
void setLocal(bool value)
setLocal
const QList< KisPaintingAssistantHandleSP > & handles() const
virtual QColor convertColorToDisplayColorSpace(const KoColor color) const =0
convertColorToDisplayColorSpace
QString name() const override
QString id() const override
KisPaintingAssistant * createPaintingAssistant() const override
KisPaintingAssistantSP clone(QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > &handleMap) const override
void drawAssistant(QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool cached=true, KisCanvas2 *canvas=nullptr, bool assistantVisible=true, bool previewVisible=true) override
QTransform localTransform(QPointF vp_a, QPointF vp_b, QPointF pt_c, qreal *size) const
void setGridDensity(double density)
void setUseVertical(bool value)
KisPaintingAssistantHandleSP secondLocalHandle() const override
secondLocalHandle Note: this doesn't guarantee it will be the bottomRight corner! For that,...
qreal distance(const QPointF &point) const override
bool localPerspectiveData(const QPointF &point, QPointF *localPoint, qreal *size) const
void endStroke() override
void saveCustomXml(QXmlStreamWriter *xml) override
QPointF adjustPosition(const QPointF &point, const QPointF &strokeBegin, const bool snapToAny, qreal moveThresholdPt) override
bool loadCustomXml(QXmlStreamReader *xml) override
QPointF getDefaultEditorPosition() const override
bool contains(const QPointF &point) const override
void drawCache(QPainter &gc, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool assistantVisible=true) override
performance layer where the graphics can be drawn from a cache instead of generated every render upda...
QPointF project(const QPointF &pt, const QPointF &strokeBegin, const bool snapToAny, qreal moveThreshold)
void adjustLine(QPointF &point, QPointF &strokeBegin) override
bool isActive() const override
bool canBeLocal() const override
canBeLocal
int numHandles() const override
bool isAssistantComplete() const override
KisPaintingAssistantHandleSP firstLocalHandle() const override
firstLocalHandle Note: this doesn't guarantee it will be the topleft corner! For that,...
static bool qFuzzyCompare(half p1, half p2)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define M_PI
Definition kis_global.h:111
QSharedPointer< KisPaintingAssistant > KisPaintingAssistantSP
Definition kis_types.h:189
void cropLineToConvexPolygon(QLineF &line, const QPolygonF polygon, bool extendFirst, bool extendSecond)
qreal norm(const T &a)
bool intersectLineRect(QLineF &line, const QRect rect, bool extend)
double toDouble(const QString &str, bool *ok=nullptr)
int toInt(const QString &str, bool *ok=nullptr)
QString toString(const QString &value)
static KoColorSpaceRegistry * instance()