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

#include <FisheyePointAssistant.h>

+ Inheritance diagram for FisheyePointAssistant:

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
 
 FisheyePointAssistant ()
 
QPointF getDefaultEditorPosition () const override
 
bool isAssistantComplete () const override
 
int numHandles () const 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
 
virtual bool canBeLocal () const
 canBeLocal
 
KisPaintingAssistantHandleSP closestCornerHandleFromPoint (QPointF point)
 
void copySharedData (KisPaintingAssistantSP assistant)
 
void drawError (QPainter &painter, const QPainterPath &path)
 
void drawPath (QPainter &painter, const QPainterPath &path, bool drawActive=true)
 
void drawPreview (QPainter &painter, const QPainterPath &path)
 
void drawX (QPainter &painter, const QPointF &pt)
 
QPointF editorWidgetOffset ()
 
QColor effectiveAssistantColor () const
 
virtual void endStroke ()
 
void findPerspectiveAssistantHandleLocation ()
 
virtual QPointF getEditorPosition () const
 
QList< KisPaintingAssistantHandleSPhandles ()
 
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 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< KisPaintingAssistantHandleSPsideHandles ()
 
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, bool cached=true, KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true) override
 
void drawCache (QPainter &gc, const KisCoordinatesConverter *converter, 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

 FisheyePointAssistant (const FisheyePointAssistant &rhs, QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > &handleMap)
 
QPointF project (const QPointF &pt, const QPointF &strokeBegin)
 

Private Attributes

Ellipse e
 
Ellipse extraE
 

Additional Inherited Members

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

Detailed Description

Definition at line 19 of file FisheyePointAssistant.h.

Constructor & Destructor Documentation

◆ FisheyePointAssistant() [1/2]

FisheyePointAssistant::FisheyePointAssistant ( )

Definition at line 27 of file FisheyePointAssistant.cc.

28 : KisPaintingAssistant("fisheye-point", i18n("Fish Eye Point assistant"))
29{
30}
KisPaintingAssistant(const QString &id, const QString &name)

◆ FisheyePointAssistant() [2/2]

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

Definition at line 32 of file FisheyePointAssistant.cc.

33 : KisPaintingAssistant(rhs, handleMap)
34 , e(rhs.e)
35 , extraE(rhs.extraE)
36{
37}

Member Function Documentation

◆ adjustLine()

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

Implements KisPaintingAssistant.

Definition at line 74 of file FisheyePointAssistant.cc.

75{
76 point = QPointF();
77 strokeBegin = QPointF();
78}

◆ adjustPosition()

QPointF FisheyePointAssistant::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 69 of file FisheyePointAssistant.cc.

70{
71 return project(pt, strokeBegin);
72}
QPointF project(const QPointF &pt, const QPointF &strokeBegin)

References project().

◆ boundingRect()

QRect FisheyePointAssistant::boundingRect ( ) const
overrideprotectedvirtual

Reimplemented from KisPaintingAssistant.

Definition at line 169 of file FisheyePointAssistant.cc.

170{
171 if (!isAssistantComplete()) {
173 }
174
175 if (e.set(*handles()[0], *handles()[1], *handles()[2])) {
176 return e.boundingRect().adjusted(-(e.semiMajor()*2), -2, (e.semiMajor()*2), 2).toAlignedRect();
177 } else {
178 return QRect();
179 }
180}
qreal semiMajor() const
Definition Ellipse.h:33
bool set(const QPointF &m1, const QPointF &m2, const QPointF &p)
Definition Ellipse.cc:23
QRectF boundingRect() const
Definition Ellipse.cc:62
bool isAssistantComplete() const override
virtual QRect boundingRect() const
const QList< KisPaintingAssistantHandleSP > & handles() const

References KisPaintingAssistant::boundingRect(), Ellipse::boundingRect(), e, KisPaintingAssistant::handles(), isAssistantComplete(), Ellipse::semiMajor(), and Ellipse::set().

◆ clone()

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

Implements KisPaintingAssistant.

Definition at line 39 of file FisheyePointAssistant.cc.

40{
41 return KisPaintingAssistantSP(new FisheyePointAssistant(*this, handleMap));
42}
QSharedPointer< KisPaintingAssistant > KisPaintingAssistantSP
Definition kis_types.h:189

References FisheyePointAssistant().

◆ drawAssistant()

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

Reimplemented from KisPaintingAssistant.

Definition at line 80 of file FisheyePointAssistant.cc.

81{
82 gc.save();
83 gc.resetTransform();
84
85 if (isSnappingActive() && previewVisible == true ) {
86
88
89 QTransform initialTransform = converter->documentToWidgetTransform();
90
91 if (e.set(*handles()[0], *handles()[1], *handles()[2])) {
92 QPointF mousePos = effectiveBrushPosition(converter, canvas);
93 if (extraE.set(*handles()[0], *handles()[1], initialTransform.inverted().map(mousePos))){
94 gc.setTransform(initialTransform);
95 gc.setTransform(e.getInverse(), true);
96 QPainterPath path;
97 // Draw the ellipse
98 path.addEllipse(QPointF(0, 0), extraE.semiMajor(), extraE.semiMinor());
99 drawPreview(gc, path);
100 }
101 QLineF radius(*handles()[1], *handles()[0]);
102 radius.setAngle(fmod(radius.angle()+180.0,360.0));
103 if (extraE.set(radius.p1(), radius.p2(), initialTransform.inverted().map(mousePos))){
104 gc.setTransform(initialTransform);
105 gc.setTransform(extraE.getInverse(), true);
106 QPainterPath path;
107 // Draw the ellipse
108 path.addEllipse(QPointF(0, 0), extraE.semiMajor(), extraE.semiMinor());
109 drawPreview(gc, path);
110 }
111 QLineF radius2(*handles()[0], *handles()[1]);
112 radius2.setAngle(fmod(radius2.angle()+180.0,360.0));
113 if (extraE.set(radius2.p1(), radius2.p2(), initialTransform.inverted().map(mousePos))){
114 gc.setTransform(initialTransform);
115 gc.setTransform(extraE.getInverse(), true);
116 QPainterPath path;
117 // Draw the ellipse
118 path.addEllipse(QPointF(0, 0), extraE.semiMajor(), extraE.semiMinor());
119 drawPreview(gc, path);
120 }
121
122 }
123 }
124 }
125 gc.restore();
126
127 KisPaintingAssistant::drawAssistant(gc, updateRect, converter, cached, canvas, assistantVisible, previewVisible);
128
129}
const QTransform & getInverse() const
Definition Ellipse.h:32
qreal semiMinor() const
Definition Ellipse.h:34
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)
virtual void drawAssistant(QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, bool cached, KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true)

References KisCoordinatesConverter::documentToWidgetTransform(), KisPaintingAssistant::drawAssistant(), KisPaintingAssistant::drawPreview(), e, KisPaintingAssistant::effectiveBrushPosition(), extraE, Ellipse::getInverse(), KisPaintingAssistant::handles(), isAssistantComplete(), KisPaintingAssistant::isSnappingActive(), Ellipse::semiMajor(), Ellipse::semiMinor(), and Ellipse::set().

◆ drawCache()

void FisheyePointAssistant::drawCache ( QPainter & gc,
const KisCoordinatesConverter * converter,
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 131 of file FisheyePointAssistant.cc.

132{
133 if (assistantVisible == false){
134 return;
135 }
136
137 QTransform initialTransform = converter->documentToWidgetTransform();
138
139 if (handles().size() == 2) {
140 // just draw the axis
141 gc.setTransform(initialTransform);
142 QPainterPath path;
143 path.moveTo(*handles()[0]);
144 path.lineTo(*handles()[1]);
145 drawPath(gc, path, isSnappingActive());
146 return;
147 }
148 if (e.set(*handles()[0], *handles()[1], *handles()[2])) {
149 // valid ellipse
150
151 gc.setTransform(initialTransform);
152 gc.setTransform(e.getInverse(), true);
153 QPainterPath path;
154 //path.moveTo(QPointF(-e.semiMajor(), -e.semiMinor())); path.lineTo(QPointF(e.semiMajor(), -e.semiMinor()));
155 path.moveTo(QPointF(-e.semiMajor(), -e.semiMinor())); path.lineTo(QPointF(-e.semiMajor(), e.semiMinor()));
156 //path.moveTo(QPointF(-e.semiMajor(), e.semiMinor())); path.lineTo(QPointF(e.semiMajor(), e.semiMinor()));
157 path.moveTo(QPointF(e.semiMajor(), -e.semiMinor())); path.lineTo(QPointF(e.semiMajor(), e.semiMinor()));
158 path.moveTo(QPointF(-(e.semiMajor()*3), -e.semiMinor())); path.lineTo(QPointF(-(e.semiMajor()*3), e.semiMinor()));
159 path.moveTo(QPointF((e.semiMajor()*3), -e.semiMinor())); path.lineTo(QPointF((e.semiMajor()*3), e.semiMinor()));
160 path.moveTo(QPointF(-e.semiMajor(), 0)); path.lineTo(QPointF(e.semiMajor(), 0));
161 //path.moveTo(QPointF(0, -e.semiMinor())); path.lineTo(QPointF(0, e.semiMinor()));
162 // Draw the ellipse
163 path.addEllipse(QPointF(0, 0), e.semiMajor(), e.semiMinor());
164 drawPath(gc, path, isSnappingActive());
165 }
166
167}
void drawPath(QPainter &painter, const QPainterPath &path, bool drawActive=true)
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References KisCoordinatesConverter::documentToWidgetTransform(), KisPaintingAssistant::drawPath(), e, Ellipse::getInverse(), KisPaintingAssistant::handles(), KisPaintingAssistant::isSnappingActive(), Ellipse::semiMajor(), Ellipse::semiMinor(), and Ellipse::set().

◆ getDefaultEditorPosition()

QPointF FisheyePointAssistant::getDefaultEditorPosition ( ) const
overridevirtual

Implements KisPaintingAssistant.

Definition at line 182 of file FisheyePointAssistant.cc.

183{
184 return (*handles()[0] + *handles()[1]) * 0.5;
185}

References KisPaintingAssistant::handles().

◆ isAssistantComplete()

bool FisheyePointAssistant::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 187 of file FisheyePointAssistant.cc.

188{
189 return handles().size() >= 3;
190}

References KisPaintingAssistant::handles().

◆ numHandles()

int FisheyePointAssistant::numHandles ( ) const
inlineoverridevirtual

Implements KisPaintingAssistant.

Definition at line 29 of file FisheyePointAssistant.h.

29{ return 3; }

◆ project()

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

Definition at line 44 of file FisheyePointAssistant.cc.

45{
46 const static QPointF nullPoint(std::numeric_limits<qreal>::quiet_NaN(), std::numeric_limits<qreal>::quiet_NaN());
47 Q_ASSERT(isAssistantComplete());
48 e.set(*handles()[0], *handles()[1], *handles()[2]);
49
50 //set the extrapolation ellipse.
51 if (e.set(*handles()[0], *handles()[1], *handles()[2])){
52 QLineF radius(*handles()[1], *handles()[0]);
53 radius.setAngle(fmod(radius.angle()+180.0,360.0));
54 QLineF radius2(*handles()[0], *handles()[1]);
55 radius2.setAngle(fmod(radius2.angle()+180.0,360.0));
56 if ( extraE.set(*handles()[0], *handles()[1],strokeBegin ) ) {
57 return extraE.project(pt);
58 } else if (extraE.set(radius.p1(), radius.p2(),strokeBegin)) {
59 return extraE.project(pt);
60 } else if (extraE.set(radius2.p1(), radius2.p2(),strokeBegin)){
61 return extraE.project(pt);
62 }
63 }
64
65 return nullPoint;
66
67}
QPointF project(const QPointF &) const
Definition Ellipse.cc:39

References e, extraE, KisPaintingAssistant::handles(), isAssistantComplete(), Ellipse::project(), and Ellipse::set().

Member Data Documentation

◆ e

Ellipse FisheyePointAssistant::e
mutableprivate

Definition at line 40 of file FisheyePointAssistant.h.

◆ extraE

Ellipse FisheyePointAssistant::extraE
mutableprivate

Definition at line 41 of file FisheyePointAssistant.h.


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