Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_tool_freehand_helper.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_TOOL_FREEHAND_HELPER_H
8#define __KIS_TOOL_FREEHAND_HELPER_H
9
10#include <QObject>
11#include <QVector>
12
13#include "kis_types.h"
14#include "kritaui_export.h"
16#include "kis_default_bounds.h"
19#include "kundo2magicstring.h"
20
21
22class KoPointerEvent;
27class KisPaintOp;
29
30
31class KRITAUI_EXPORT KisToolFreehandHelper : public QObject
32{
33 Q_OBJECT
34
35public:
36
38 KoCanvasResourceProvider *resourceManager,
39 const KUndo2MagicString &transactionText = KUndo2MagicString(),
40 KisSmoothingOptions *smoothingOptions = 0);
41 ~KisToolFreehandHelper() override;
42
43 void setSmoothness(KisSmoothingOptionsSP smoothingOptions);
44 KisSmoothingOptionsSP smoothingOptions() const;
45
46 bool isRunning() const;
47
48 void cursorMoved(const QPointF &cursorPos);
49
60 void initPaint(KoPointerEvent *event,
61 const QPointF &pixelCoords,
62 KisImageWSP image,
63 KisNodeSP currentNode,
64 KisStrokesFacade *strokesFacade,
65 KisNodeSP overrideNode = 0,
67 void paintEvent(KoPointerEvent *event );
68 void endPaint();
69
70 KisOptimizedBrushOutline paintOpOutline(const QPointF &savedCursorPos,
71 const KoPointerEvent *event,
72 const KisPaintOpSettingsSP globalSettings,
74
75Q_SIGNALS:
83
84protected:
85 void cancelPaint();
86 int elapsedStrokeTime() const;
87
88 void initPaintImpl(qreal startAngle,
89 const KisPaintInformation &pi,
90 KoCanvasResourceProvider *resourceManager,
91 KisImageWSP image,
92 KisNodeSP node,
93 KisStrokesFacade *strokesFacade,
94 KisNodeSP overrideNode = 0,
96
97 KoCanvasResourceProvider *resourceManager() const;
98
99protected:
100
101 virtual void createPainters(QVector<KisFreehandStrokeInfo*> &strokeInfos,
102 const KisDistanceInformation &startDist);
103
104 // lo-level methods for painting primitives
105
106 void paintAt(int strokeInfoId, const KisPaintInformation &pi);
107
108 void paintLine(int strokeInfoId,
109 const KisPaintInformation &pi1,
110 const KisPaintInformation &pi2);
111
112 void paintBezierCurve(int strokeInfoId,
113 const KisPaintInformation &pi1,
114 const QPointF &control1,
115 const QPointF &control2,
116 const KisPaintInformation &pi2);
117
118 // hi-level methods for painting primitives
119
120 virtual void paintAt(const KisPaintInformation &pi);
121
122 virtual void paintLine(const KisPaintInformation &pi1,
123 const KisPaintInformation &pi2);
124
125 virtual void paintBezierCurve(const KisPaintInformation &pi1,
126 const QPointF &control1,
127 const QPointF &control2,
128 const KisPaintInformation &pi2);
129
130private:
131 void paint(KisPaintInformation &info );
132 void paintBezierSegment(KisPaintInformation pi1, KisPaintInformation pi2,
133 QPointF tangent1, QPointF tangent2
134 );
135
136 void stabilizerStart(KisPaintInformation firstPaintInfo);
137 void stabilizerEnd();
138 KisPaintInformation getStabilizedPaintInfo(const QQueue<KisPaintInformation> &queue,
139 const KisPaintInformation &lastPaintInfo);
140 int computeAirbrushTimerInterval() const;
141
142 qreal currentZoom() const;
143 qreal currentPhysicalZoom() const;
144
145private Q_SLOTS:
146 void finishStroke();
147 void doAirbrushing();
148 void stabilizerPollAndPaint();
149 void slotSmoothingTypeChanged();
150
151private:
152 struct Private;
153 Private * const m_d;
154};
155
156#endif /* __KIS_TOOL_FREEHAND_HELPER_H */
void requestExplicitUpdateOutline()
#define bounds(x, a, b)
static void paintBezierCurve(KisPaintOp *paintOp, const KisPaintInformation &pi1, const KisVector2D &control1, const KisVector2D &control2, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)