Krita Source Code Documentation
Loading...
Searching...
No Matches
VanishingPointAssistant.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: 2014 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
5 * SPDX-FileCopyrightText: 2017 Scott Petrovic <scottpetrovic@gmail.com>
6 *
7 * SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9
10#ifndef _VANISHINGPOINT_ASSISTANT_H_
11#define _VANISHINGPOINT_ASSISTANT_H_
12
14#include <QObject>
15#include <QLineF>
16/* Design:
17 *The idea behind the vanishing point ruler is that in a perspective deformed landscape, a set of parallel
18 *lines al share a single vanishing point.
19 *Therefore, a perspective can contain an theoretical infinite of vanishing points.
20 *It's a pity if we only allowed an artist to access 1, 2 or 3 of these at any given time, as other
21 *solutions for perspective tools do.
22 *Hence a vanishing point ruler.
23 *
24 *This ruler is relatively simple compared to the other perspective ruler:
25 *It has only one vanishing point that is required to draw.
26 *However, it does have it's own weaknesses in how to determine onto which of these infinite rulers to snap.
27 *Furthermore, it has four extra handles for adding a perspective ruler to a preexisting perspective.
28 */
29//class VanishingPoint;
30
32{
33public:
35
41
42 KisPaintingAssistantSP clone(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap) const override;
43 QPointF adjustPosition(const QPointF& point, const QPointF& strokeBegin, bool snapToAny, qreal moveThresholdPt) override;
44 void adjustLine(QPointF &point, QPointF& strokeBegin) override;
45 QPointF getDefaultEditorPosition() const override;
46 int numHandles() const override { return isLocal() ? 3 : 1; }
47
50
51 bool isAssistantComplete() const override;
52 bool canBeLocal() const override;
53
54 void saveCustomXml(QXmlStreamWriter* xml) override;
55 bool loadCustomXml(QXmlStreamReader* xml) override;
56
57protected:
58 void drawAssistant(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter* converter, bool cached = true,KisCanvas2* canvas=nullptr, bool assistantVisible=true, bool previewVisible=true) override;
59 void drawCache(QPainter& gc, const KisCoordinatesConverter *converter, bool assistantVisible=true) override;
60
63
64private:
65
66
67 QPointF project(const QPointF& pt, const QPointF& strokeBegin, qreal moveThresholdPt);
68 explicit VanishingPointAssistant(const VanishingPointAssistant &rhs, QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap);
69
70 KisCanvas2 *m_canvas {nullptr};
71
73};
74
76{
77public:
80 QString id() const override;
81 QString name() const override;
83};
84
85#endif
float value(const T *src, size_t ch)
KisPaintingAssistant * createPaintingAssistant() 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
QPointF project(const QPointF &pt, const QPointF &strokeBegin, qreal moveThresholdPt)
QPointF getDefaultEditorPosition() const override
void setReferenceLineDensity(float value)
void saveCustomXml(QXmlStreamWriter *xml) override
int numHandles() const override
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...
void adjustLine(QPointF &point, QPointF &strokeBegin) override
bool isAssistantComplete() const override
bool loadCustomXml(QXmlStreamReader *xml) override
QPointF adjustPosition(const QPointF &point, const QPointF &strokeBegin, bool snapToAny, qreal moveThresholdPt) override
KisPaintingAssistantHandleSP firstLocalHandle() const override
firstLocalHandle Note: this doesn't guarantee it will be the topleft corner! For that,...
bool canBeLocal() const override
canBeLocal
KisPaintingAssistantSP clone(QMap< KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP > &handleMap) const override