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

#include <PerspectiveEllipseAssistant.h>

+ Inheritance diagram for PerspectiveEllipseAssistant:

Classes

class  Private
 

Public Member Functions

void adjustLine (QPointF &point, QPointF &strokeBegin) override
 
QPointF adjustPosition (const QPointF &point, const QPointF &strokeBegin, const bool snapToAny, qreal moveThresholdPt) override
 
KisPaintingAssistantSP clone (QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > &handleMap) const override
 
bool contains (const QPointF &point) const override
 
qreal distance (const QPointF &point) const override
 
QPointF getDefaultEditorPosition () const override
 
bool isActive () const override
 
bool isAssistantComplete () const override
 
int numHandles () const override
 
 PerspectiveEllipseAssistant (QObject *parent=0)
 
 ~PerspectiveEllipseAssistant ()
 
- Public Member Functions inherited from KisAbstractPerspectiveGrid
 KisAbstractPerspectiveGrid (QObject *parent=0)
 
 ~KisAbstractPerspectiveGrid () override
 
- Public Member Functions inherited from KisPaintingAssistant
void addHandle (KisPaintingAssistantHandleSP handle, HandleType type)
 
bool areTwoPointsClose (const QPointF &pointOne, const QPointF &pointTwo)
 
QColor assistantCustomColor ()
 
KisPaintingAssistantHandleSP bottomLeft ()
 
const KisPaintingAssistantHandleSP bottomLeft () const
 
KisPaintingAssistantHandleSP bottomMiddle ()
 
const KisPaintingAssistantHandleSP bottomMiddle () const
 
KisPaintingAssistantHandleSP bottomRight ()
 
const KisPaintingAssistantHandleSP bottomRight () const
 
int brushPriority () const
 
virtual bool canBeLocal () const
 canBeLocal
 
KisPaintingAssistantHandleSP closestCornerHandleFromPoint (QPointF point)
 
void copySharedData (KisPaintingAssistantSP assistant)
 
void drawError (QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface)
 
void drawPath (QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface, bool drawActive=true, QPen startingPen=QPen())
 
void drawPreview (QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface)
 
void drawX (QPainter &painter, const QPointF &pt, const KoColorDisplayRendererInterface *displayRenderInterface)
 
QPointF editorWidgetOffset ()
 
QColor effectiveAssistantColor () const
 
virtual void endStroke ()
 
void findPerspectiveAssistantHandleLocation ()
 
virtual QPointF getEditorPosition () const
 
QList< KisPaintingAssistantHandleSP > handles ()
 
const QList< KisPaintingAssistantHandleSP > & handles () const
 
const QString & id () const
 
bool isDuplicating ()
 isDuplicating
 
bool isLocal () const
 isLocal
 
bool isLocked ()
 isLocked
 
bool isSnappingActive () const
 
 KisPaintingAssistant (const QString &id, const QString &name)
 
KisPaintingAssistantHandleSP leftMiddle ()
 
const KisPaintingAssistantHandleSP leftMiddle () const
 
virtual bool loadCustomXml (QXmlStreamReader *xml)
 
void loadXml (KoStore *store, QMap< int, KisPaintingAssistantHandleSP > &handleMap, QString path)
 
const QString & name () const
 
KisPaintingAssistantHandleSP oppHandleOne ()
 
void replaceHandle (KisPaintingAssistantHandleSP _handle, KisPaintingAssistantHandleSP _with)
 
KisPaintingAssistantHandleSP rightMiddle ()
 
const KisPaintingAssistantHandleSP rightMiddle () const
 
virtual void saveCustomXml (QXmlStreamWriter *xml)
 
QByteArray saveXml (QMap< KisPaintingAssistantHandleSP, int > &handleMap)
 
void saveXmlList (QDomDocument &doc, QDomElement &assistantsElement, int count)
 
virtual void setAdjustedBrushPosition (const QPointF position)
 
void setAssistantCustomColor (QColor color)
 
void setAssistantGlobalColorCache (const QColor &color)
 
void setBrushPriority (int priority)
 
void setDecorationThickness (int thickness)
 
void setDuplicating (bool value)
 setDuplicating
 
void setEditorWidgetOffset (QPointF offset)
 
virtual void setFollowBrushPosition (bool follow)
 
void setLocal (bool value)
 setLocal
 
void setLocked (bool value)
 setLocked
 
void setSnappingActive (bool set)
 
void setUseCustomColor (bool useCustomColor)
 
QList< KisPaintingAssistantHandleSP > sideHandles ()
 
const QList< KisPaintingAssistantHandleSP > & sideHandles () const
 
KisPaintingAssistantHandleSP topLeft ()
 
const KisPaintingAssistantHandleSP topLeft () const
 
KisPaintingAssistantHandleSP topMiddle ()
 
const KisPaintingAssistantHandleSP topMiddle () const
 
KisPaintingAssistantHandleSP topRight ()
 
const KisPaintingAssistantHandleSP topRight () const
 
virtual void transform (const QTransform &transform)
 
void uncache ()
 
bool useCustomColor ()
 
QPointF viewportConstrainedEditorPosition (const KisCoordinatesConverter *converter, const QSize editorSize)
 
virtual ~KisPaintingAssistant ()
 

Protected Member Functions

QRect boundingRect () const override
 
void drawAssistant (QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool cached, KisCanvas2 *canvas, bool assistantVisible=true, bool previewVisible=true) 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 update
 
- Protected Member Functions inherited from KisPaintingAssistant
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 painting the dynamic preview lines for assistants that feature them. Affected by setAdjustedBrushPosition() and setFollowBrushPosition().
 
virtual KisPaintingAssistantHandleSP firstLocalHandle () const
 firstLocalHandle Note: this doesn't guarantee it will be the topleft corner! For that, use getLocalRect().topLeft() The only purpose of those functions to exist is to be able to put getLocalRect() function in the KisPaintingAssistant instead of reimplementing it in every specific assistant.
 
QRectF getLocalRect () const
 getLocalRect The function deals with local handles not being topLeft and bottomRight gracefully and returns a correct rectangle. Thanks to that the user can place handles in a "wrong" order or move them around but the local rectangle will still be correct.
 
void initHandles (QList< KisPaintingAssistantHandleSP > _handles)
 
 KisPaintingAssistant (const KisPaintingAssistant &rhs, QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > &handleMap)
 
QPointF pixelToView (const QPoint pixelCoords) const
 
virtual KisPaintingAssistantHandleSP secondLocalHandle () const
 secondLocalHandle Note: this doesn't guarantee it will be the bottomRight corner! For that, use getLocalRect().bottomRight() (and remember that for QRect bottomRight() works differently than for QRectF, so don't convert to QRect before accessing the corner)
 

Private Member Functions

bool getTransform (QPolygonF &polyOut, QTransform &transformOut)
 
bool isEllipseValid ()
 
 PerspectiveEllipseAssistant (const PerspectiveEllipseAssistant &rhs, QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > &handleMap)
 
QPointF project (const QPointF &pt, const QPointF &strokeBegin)
 
void updateCache ()
 

Private Attributes

QScopedPointer< Private > d
 

Additional Inherited Members

- Static Public Member Functions inherited from KisPaintingAssistant
static QList< KisPaintingAssistantSP > cloneAssistantList (const QList< KisPaintingAssistantSP > &list)
 
static double norm2 (const QPointF &p)
 
- Protected Attributes inherited from KisPaintingAssistant
QList< KisPaintingAssistantHandleSP > m_handles
 
bool m_hasBeenInsideLocalRect {false}
 

Detailed Description

Definition at line 13 of file PerspectiveEllipseAssistant.h.

Constructor & Destructor Documentation

◆ PerspectiveEllipseAssistant() [1/2]

PerspectiveEllipseAssistant::PerspectiveEllipseAssistant ( QObject * parent = 0)

Definition at line 330 of file PerspectiveEllipseAssistant.cc.

332 , KisPaintingAssistant("perspective ellipse", i18n("Perspective Ellipse assistant"))
333 , d(new Private())
334{
335
336}
KisPaintingAssistant(const QString &id, const QString &name)

◆ ~PerspectiveEllipseAssistant()

PerspectiveEllipseAssistant::~PerspectiveEllipseAssistant ( )

Definition at line 338 of file PerspectiveEllipseAssistant.cc.

338{}

◆ PerspectiveEllipseAssistant() [2/2]

PerspectiveEllipseAssistant::PerspectiveEllipseAssistant ( const PerspectiveEllipseAssistant & rhs,
QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > & handleMap )
explicitprivate

Definition at line 340 of file PerspectiveEllipseAssistant.cc.

341 : KisAbstractPerspectiveGrid(rhs.parent())
342 , KisPaintingAssistant(rhs, handleMap)
343 , d(new Private())
344{
345 updateCache();
346}

References updateCache().

Member Function Documentation

◆ adjustLine()

void PerspectiveEllipseAssistant::adjustLine ( QPointF & point,
QPointF & strokeBegin )
overridevirtual

Implements KisPaintingAssistant.

Definition at line 368 of file PerspectiveEllipseAssistant.cc.

369{
370 point = QPointF();
371 strokeBegin = QPointF();
372}

◆ adjustPosition()

QPointF PerspectiveEllipseAssistant::adjustPosition ( const QPointF & point,
const QPointF & strokeBegin,
const bool snapToAny,
qreal moveThresholdPt )
overridevirtual

Adjust the position given in parameter.

Parameters
pointthe coordinates in point in the document reference
strokeBeginthe coordinates of the beginning of the stroke
snapToAnybecause now assistants can be composited out of multiple inside assistants. snapToAny true means that you can use any of the inside assistant, while it being false means you should use the last used one. The logic determining when it happens (first stroke etc.) is in the decoration, so those two options are enough.
moveThresholdPtthe threshold for the "move" of the cursor measured in pt (usually equals to 2px in screen coordinates converted to pt)

Implements KisPaintingAssistant.

Definition at line 363 of file PerspectiveEllipseAssistant.cc.

364{
365 return project(pt, strokeBegin);
366}
QPointF project(const QPointF &pt, const QPointF &strokeBegin)

References project().

◆ boundingRect()

QRect PerspectiveEllipseAssistant::boundingRect ( ) const
overrideprotectedvirtual

Reimplemented from KisPaintingAssistant.

Definition at line 513 of file PerspectiveEllipseAssistant.cc.

514{
515 if (!isAssistantComplete()) {
517 }
518
519 if (d->ellipseInPolygon.setSimpleEllipseVertices(d->simpleEllipse)) {
520 return d->simpleEllipse.boundingRect().adjusted(-2, -2, 2, 2).toAlignedRect();
521 } else {
522 return QRect();
523 }
524}
virtual QRect boundingRect() const

References KisPaintingAssistant::boundingRect(), d, and isAssistantComplete().

◆ clone()

KisPaintingAssistantSP PerspectiveEllipseAssistant::clone ( QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > & handleMap) const
overridevirtual

Implements KisPaintingAssistant.

Definition at line 348 of file PerspectiveEllipseAssistant.cc.

349{
350 return KisPaintingAssistantSP(new PerspectiveEllipseAssistant(*this, handleMap));
351}
QSharedPointer< KisPaintingAssistant > KisPaintingAssistantSP
Definition kis_types.h:189

References PerspectiveEllipseAssistant().

◆ contains()

bool PerspectiveEllipseAssistant::contains ( const QPointF & point) const
overridevirtual

Implements KisAbstractPerspectiveGrid.

Definition at line 589 of file PerspectiveEllipseAssistant.cc.

590{
591
592 QPolygonF poly;
594 return poly.containsPoint(point, Qt::OddEvenFill);
595}
const QList< KisPaintingAssistantHandleSP > & handles() const
static bool getTetragon(const QList< KisPaintingAssistantHandleSP > &handles, bool isAssistantComplete, QPolygonF &outPolygon)

References PerspectiveBasedAssistantHelper::getTetragon(), KisPaintingAssistant::handles(), and isAssistantComplete().

◆ distance()

qreal PerspectiveEllipseAssistant::distance ( const QPointF & pt) const
overridevirtual

Returns the reciprocal of the distance from the given point to the 'observer', in the range [0, 1] where 0 = infinite distance and 1 = closest.

Implements KisAbstractPerspectiveGrid.

Definition at line 597 of file PerspectiveEllipseAssistant.cc.

598{
599 KIS_SAFE_ASSERT_RECOVER_NOOP(d->cacheValid);
601}
static qreal distanceInGrid(const QList< KisPaintingAssistantHandleSP > &handles, bool isAssistantComplete, const QPointF &point)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References d, PerspectiveBasedAssistantHelper::distanceInGrid(), and KIS_SAFE_ASSERT_RECOVER_NOOP.

◆ drawAssistant()

void PerspectiveEllipseAssistant::drawAssistant ( QPainter & gc,
const QRectF & updateRect,
const KisCoordinatesConverter * converter,
const KoColorDisplayRendererInterface * displayRenderInterface,
bool cached,
KisCanvas2 * canvas,
bool assistantVisible = true,
bool previewVisible = true )
overrideprotectedvirtual

Reimplemented from KisPaintingAssistant.

Definition at line 374 of file PerspectiveEllipseAssistant.cc.

375{
376 gc.save();
377 gc.resetTransform();
378
379 bool isEditing = false;
380
381 if (canvas) {
382 isEditing = canvas->paintingAssistantsDecoration()->isEditingAssistants();
383 }
384
385 QTransform initialTransform = converter->documentToWidgetTransform();
386
387 // need to update ellipse cache
388 updateCache();
389
390 QPolygonF poly = d->ellipseInPolygon.polygon;
391 QTransform transform = d->ellipseInPolygon.originalTransform; // unused, but computed for caching purposes
392
393
394 if (isEllipseValid() && assistantVisible==true) {
395 // draw vanishing points
396 if (d->cache.vanishingPoint1) {
397 drawX(gc, initialTransform.map(d->cache.vanishingPoint1.get()), displayRenderInterface);
398 }
399 if (d->cache.vanishingPoint2) {
400 drawX(gc, initialTransform.map(d->cache.vanishingPoint2.get()), displayRenderInterface);
401 }
402 }
403
404 // draw ellipse and axes
405 if (isEllipseValid() && (assistantVisible || previewVisible || isEditing)) { // ensure that you only draw the ellipse if it's valid - otherwise it would just show some outdated one
406 QPointF mousePos = effectiveBrushPosition(converter, canvas);
407 gc.setTransform(initialTransform);
408 gc.setTransform(d->simpleEllipse.getTransform().inverted(), true);
409
410 QPainterPath path;
411 path.addEllipse(QPointF(0.0, 0.0), d->simpleEllipse.semiMajor(), d->simpleEllipse.semiMinor());
412
413 if (assistantVisible || isEditing) {
414 drawPath(gc, path, displayRenderInterface, isSnappingActive());
415 } else if (previewVisible && isSnappingActive() && boundingRect().contains(initialTransform.inverted().map(mousePos.toPoint()), false)) {
416 drawPreview(gc, path, displayRenderInterface);
417 }
418
419 if (isEditing) {
420 QPainterPath axes;
421 axes.moveTo(QPointF(-d->simpleEllipse.semiMajor(), 0));
422 axes.lineTo(QPointF(d->simpleEllipse.semiMajor(), 0));
423
424 axes.moveTo(QPointF(0, -d->simpleEllipse.semiMinor()));
425 axes.lineTo(QPointF(0, d->simpleEllipse.semiMinor()));
426
427 gc.save();
428
429 QPen dotted(Qt::DotLine);
430 // needs dotline
431 drawPath(gc, axes, displayRenderInterface, isSnappingActive(), dotted);
432
433 gc.restore();
434 }
435
436 gc.setTransform(converter->documentToWidgetTransform());
437 gc.setTransform(d->ellipseInPolygon.originalTransform, true);
438
439 // drawing original axes ("lines to touching points")
440 QPointF pt1 = QPointF(0.5, 1.0);
441 QPointF pt2 = QPointF(1.0, 0.5);
442 QPointF pt3 = QPointF(0.5, 0.0);
443 QPointF pt4 = QPointF(0.0, 0.5);
444
445 QPainterPath touchingLine;
446
447 touchingLine.moveTo(pt1);
448 touchingLine.lineTo(pt3);
449
450 touchingLine.moveTo(pt2);
451 touchingLine.lineTo(pt4);
452
453 if (assistantVisible) {
454 drawPath(gc, touchingLine, displayRenderInterface, isSnappingActive());
455 }
456 }
457
458
459 gc.setTransform(converter->documentToWidgetTransform());
460
461 if (assistantVisible || isEditing) {
462 if (!isEllipseValid()) {
463 // color red for an invalid transform, but not for an incomplete one
464 if(isAssistantComplete()) {
465 QPainterPath path;
466 QPolygonF polyAllConnected;
467 // that will create a triangle with a point inside connected to all vertices of the triangle
468 polyAllConnected << *handles()[0] << *handles()[1] << *handles()[2] << *handles()[3] << *handles()[0] << *handles()[2] << *handles()[1] << *handles()[3];
469 path.addPolygon(polyAllConnected);
470 drawError(gc, path, displayRenderInterface);
471 } else {
472 QPainterPath path;
473 path.addPolygon(poly);
474 drawPath(gc, path, displayRenderInterface, isSnappingActive());
475 }
476 } else {
477 gc.setPen(QColor(0, 0, 0, 125));
478 gc.setTransform(transform, true);
479 QPainterPath path;
480 for (int y = 0; y <= 1; ++y)
481 {
482 QLineF line = QLineF(QPointF(0.0, y), QPointF(1.0, y));
483 KisAlgebra2D::cropLineToRect(line, gc.window(), false, false);
484 path.moveTo(line.p1());
485 path.lineTo(line.p2());
486 }
487 for (int x = 0; x <= 1; ++x)
488 {
489 QLineF line = QLineF(QPointF(x, 0.0), QPointF(x, 1.0));
490 KisAlgebra2D::cropLineToRect(line, gc.window(), false, false);
491 path.moveTo(line.p1());
492 path.lineTo(line.p2());
493 }
494
495 drawPath(gc, path, displayRenderInterface, isSnappingActive());
496 }
497 }
498
499 gc.restore();
500 KisPaintingAssistant::drawAssistant(gc, updateRect, converter, displayRenderInterface, cached, canvas, assistantVisible, previewVisible);
501
502}
KisPaintingAssistantsDecorationSP paintingAssistantsDecoration() const
void drawError(QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface)
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)
void drawX(QPainter &painter, const QPointF &pt, const KoColorDisplayRendererInterface *displayRenderInterface)
virtual void transform(const QTransform &transform)
virtual void drawAssistant(QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool cached, KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true)
void drawPath(QPainter &painter, const QPainterPath &path, const KoColorDisplayRendererInterface *displayRenderInterface, bool drawActive=true, QPen startingPen=QPen())
bool contains(const QPointF &point) const override
void cropLineToRect(QLineF &line, const QRect rect, bool extendFirst, bool extendSecond)
Crop line to rect; if it doesn't intersect, just return an empty line (QLineF()).

References boundingRect(), contains(), KisAlgebra2D::cropLineToRect(), d, KisCoordinatesConverter::documentToWidgetTransform(), KisPaintingAssistant::drawAssistant(), KisPaintingAssistant::drawError(), KisPaintingAssistant::drawPath(), KisPaintingAssistant::drawPreview(), KisPaintingAssistant::drawX(), KisPaintingAssistant::effectiveBrushPosition(), KisPaintingAssistant::handles(), isAssistantComplete(), KisPaintingAssistantsDecoration::isEditingAssistants(), isEllipseValid(), KisPaintingAssistant::isSnappingActive(), KisCanvas2::paintingAssistantsDecoration(), KisPaintingAssistant::transform(), and updateCache().

◆ drawCache()

void PerspectiveEllipseAssistant::drawCache ( QPainter & gc,
const KisCoordinatesConverter * converter,
const KoColorDisplayRendererInterface * displayRenderInterface,
bool assistantVisible = true )
overrideprotectedvirtual

performance layer where the graphics can be drawn from a cache instead of generated every render update

Implements KisPaintingAssistant.

Definition at line 505 of file PerspectiveEllipseAssistant.cc.

506{
507 Q_UNUSED(converter);
508 Q_UNUSED(gc);
509 Q_UNUSED(assistantVisible);
510 Q_UNUSED(displayRenderInterface);
511}

◆ getDefaultEditorPosition()

QPointF PerspectiveEllipseAssistant::getDefaultEditorPosition ( ) const
overridevirtual

Implements KisPaintingAssistant.

Definition at line 526 of file PerspectiveEllipseAssistant.cc.

527{
528 QPointF centroid(0, 0);
529 for (int i = 0; i < 4; ++i) {
530 centroid += *handles()[i];
531 }
532
533 return centroid * 0.25;
534}

References KisPaintingAssistant::handles().

◆ getTransform()

bool PerspectiveEllipseAssistant::getTransform ( QPolygonF & polyOut,
QTransform & transformOut )
private

◆ isActive()

bool PerspectiveEllipseAssistant::isActive ( ) const
overridevirtual

Implements KisAbstractPerspectiveGrid.

Definition at line 603 of file PerspectiveEllipseAssistant.cc.

604{
605 return isSnappingActive();
606}

References KisPaintingAssistant::isSnappingActive().

◆ isAssistantComplete()

bool PerspectiveEllipseAssistant::isAssistantComplete ( ) const
overridevirtual

determines if the assistant has enough handles to be considered created new assistants get in a "creation" phase where they are currently being made on the canvas it will return false if we are in the middle of creating the assistant.

Reimplemented from KisPaintingAssistant.

Definition at line 584 of file PerspectiveEllipseAssistant.cc.

585{
586 return handles().size() >= 4;
587}

References KisPaintingAssistant::handles().

◆ isEllipseValid()

bool PerspectiveEllipseAssistant::isEllipseValid ( )
private

Definition at line 536 of file PerspectiveEllipseAssistant.cc.

537{
538 return isAssistantComplete() && d->ellipseInPolygon.isValid();
539}

References d, and isAssistantComplete().

◆ numHandles()

int PerspectiveEllipseAssistant::numHandles ( ) const
inlineoverridevirtual

Implements KisPaintingAssistant.

Definition at line 26 of file PerspectiveEllipseAssistant.h.

26{ return 4; }

◆ project()

QPointF PerspectiveEllipseAssistant::project ( const QPointF & pt,
const QPointF & strokeBegin )
private

Definition at line 353 of file PerspectiveEllipseAssistant.cc.

354{
355 Q_UNUSED(strokeBegin);
356 Q_ASSERT(isAssistantComplete());
357
358 d->ellipseInPolygon.setSimpleEllipseVertices(d->simpleEllipse);
359
360 return d->simpleEllipse.project(pt);
361}

References d, and isAssistantComplete().

◆ updateCache()

void PerspectiveEllipseAssistant::updateCache ( )
private

Definition at line 541 of file PerspectiveEllipseAssistant.cc.

542{
543 // handles -> points -> polygon
544 d->cacheValid = false;
545 // check the cached points, whether they are the same as handles
546 if (d->cachedPoints.size() == handles().size()) {
547 for (int i = 0; i < handles().size(); ++i) {
548 if (d->cachedPoints[i] != *handles()[i]) break;
549 if (i == handles().size() - 1) {
550 // that means the cache is up to date, because the loop was still going
551 d->cacheValid = true;
552 return;
553 }
554 }
555 }
556
557 d->cachedPoints = QVector<QPointF>();
558 for (int i = 0; i < handles().size(); ++i) {
559 d->cachedPoints << *handles()[i];
560 }
561
562
563 QPolygonF poly = QPolygonF(d->cachedPoints);
564
565 if (!PerspectiveBasedAssistantHelper::getTetragon(handles(), isAssistantComplete(), poly)) { // this function changes poly to some "standardized" version, or a triangle when it cannot be achieved
566
567 poly = QPolygonF(d->cachedPoints);
568 poly << d->cachedPoints[0];
569 d->ellipseInPolygon.updateToPolygon(poly);
570 d->cacheValid = true;
571 return;
572 }
573
574 d->ellipseInPolygon.updateToPolygon(poly);
575 if (d->ellipseInPolygon.isValid()) {
576 d->ellipseInPolygon.setSimpleEllipseVertices(d->simpleEllipse);
577 }
578
580 d->cacheValid = true;
581
582}
static void updateCacheData(CacheData &cache, const QPolygonF &poly)
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References d, PerspectiveBasedAssistantHelper::getTetragon(), KisPaintingAssistant::handles(), isAssistantComplete(), and PerspectiveBasedAssistantHelper::updateCacheData().

Member Data Documentation

◆ d

QScopedPointer<Private> PerspectiveEllipseAssistant::d
private

Definition at line 54 of file PerspectiveEllipseAssistant.h.


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