Krita Source Code Documentation
Loading...
Searching...
No Matches
TwoPointAssistant.h
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#ifndef _TWO_POINT_ASSISTANT_H_
10#define _TWO_POINT_ASSISTANT_H_
11
13#include <QObject>
14#include <QLineF>
15#include <QTransform>
16
18{
19public:
20
28
29
31 QPointF adjustPosition(const QPointF& point, const QPointF& strokeBegin, const bool snapToAny, qreal moveThresholdPt) override;
32 void adjustLine(QPointF &point, QPointF& strokeBegin) override;
33 void endStroke() override;
34 KisPaintingAssistantSP clone(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap) const override;
35
36 QPointF getDefaultEditorPosition() const override;
37 int numHandles() const override { return isLocal() ? 5 : 3; }
38
39 void saveCustomXml(QXmlStreamWriter* xml) override;
40 bool loadCustomXml(QXmlStreamReader* xml) override;
41
42 double gridDensity();
43 void setGridDensity(double density);
44
45 /* If true, it means the assistant will have three handles
46 * If false,
47 * */
48 bool useVertical();
49 void setUseVertical(bool value);
50
51 bool isAssistantComplete() const override;
52 bool canBeLocal() const override;
53
54 /* Generate a transform for converting handles into easier local
55 coordinate system that has the following properties:
56 - Rotated so horizon is perfectly horizontal
57 - Translated so 3rd handle is the origin
58 Parameters are the first VP, second VP, a 3rd point which
59 defines the center of vision, and lastly a reference to a size
60 variable which is the radius of the 90 degree cone of vision
61 (useful for computing snapping behaviour and drawing grid
62 lines) */
63 QTransform localTransform(QPointF vp_a, QPointF vp_b, QPointF pt_c, qreal* size);
64
65protected:
66 void drawAssistant(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter* converter, bool cached = true,KisCanvas2* canvas=nullptr, bool assistantVisible=true, bool previewVisible=true) override;
67 void drawCache(QPainter& gc, const KisCoordinatesConverter *converter, bool assistantVisible=true) override;
68
71
72
73private:
74 QPointF project(const QPointF& pt, const QPointF& strokeBegin, const bool snapToAny, qreal moveThreshold);
75 explicit TwoPointAssistant(const TwoPointAssistant &rhs, QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap);
76 KisCanvas2 *m_canvas {nullptr};
77
78 QLineF m_snapLine;
79 double m_gridDensity {1.0};
80 bool m_useVertical {true};
81
82 int m_lastUsedPoint {-1}; // last used vanishing point
83
84};
85
87{
88public:
91 QString id() const override;
92 QString name() const override;
94};
95
96#endif
float value(const T *src, size_t ch)
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, bool cached=true, KisCanvas2 *canvas=nullptr, bool assistantVisible=true, bool previewVisible=true) override
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,...
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 upda...
QTransform localTransform(QPointF vp_a, QPointF vp_b, QPointF pt_c, qreal *size)
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
QPointF project(const QPointF &pt, const QPointF &strokeBegin, const bool snapToAny, qreal moveThreshold)
void adjustLine(QPointF &point, QPointF &strokeBegin) 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,...