Krita Source Code Documentation
Loading...
Searching...
No Matches
KisToolBasicBrushBase.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Deif Lou <ginoba@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KISTOOLBASICBRUSHBASE_H
8#define KISTOOLBASICBRUSHBASE_H
9
10#include <kis_tool_shape.h>
11#include <kis_cursor.h>
12
14
16{
17 Q_OBJECT
18
19public:
24
26 ToolType type,
27 const QCursor & cursor=KisCursor::loadWithSize("tool_outline_selection_cursor.svg", 32, 32, 5, 5));
28 ~KisToolBasicBrushBase() override;
29
30 void mouseMoveEvent(KoPointerEvent *event) override;
31 void beginPrimaryAction(KoPointerEvent *event) override;
32 void continuePrimaryAction(KoPointerEvent *event) override;
33 void endPrimaryAction(KoPointerEvent *event) override;
39 void paint(QPainter& gc, const KoViewConverter &converter) override;
40
41 qreal pressureToCurve(qreal pressure);
42
43public Q_SLOTS:
44 void activate(const QSet<KoShape*> &shapes) override;
45 void deactivate() override;
46 void setPreviewColor(const QColor &color);
47
48protected:
49 virtual void finishStroke(const QPainterPath& stroke) = 0;
50 KisOptimizedBrushOutline getOutlinePath(const QPointF &documentPos,
51 const KoPointerEvent *event,
52 KisPaintOpSettings::OutlineMode outlineMode) override;
53
54protected Q_SLOTS:
55 void updateSettings();
56 void resetCursorStyle() override;
57private Q_SLOTS:
58 void updatePreviewColor();
59
60private:
61 static constexpr int levelOfPressureResolution = 1024;
62 static constexpr int feedbackLineWidth{2};
63
64 QPainterPath m_path;
66 qreal m_lastPressure {1.0};
68
73
78
80
82
83 QPainterPath generateSegment(const QPointF &point1, qreal radius1, const QPointF &point2, qreal radius2) const;
84 void update(const QRectF &strokeSegmentRect);
85};
86
87#endif
static QCursor loadWithSize(const QString &cursorName, int width, int height, int hotspotX=-1, int hotspotY=-1)
void update(const QRectF &strokeSegmentRect)
void continueAlternateAction(KoPointerEvent *event, AlternateAction action) override
qreal pressureToCurve(qreal pressure)
KisOptimizedBrushOutline getOutlinePath(const QPointF &documentPos, const KoPointerEvent *event, KisPaintOpSettings::OutlineMode outlineMode) override
void beginAlternateAction(KoPointerEvent *event, AlternateAction action) override
void endPrimaryAction(KoPointerEvent *event) override
virtual void finishStroke(const QPainterPath &stroke)=0
QPainterPath generateSegment(const QPointF &point1, qreal radius1, const QPointF &point2, qreal radius2) const
void deactivateAlternateAction(AlternateAction action) override
KisToolBasicBrushBase(KoCanvasBase *canvas, ToolType type, const QCursor &cursor=KisCursor::loadWithSize("tool_outline_selection_cursor.svg", 32, 32, 5, 5))
static constexpr int levelOfPressureResolution
void activate(const QSet< KoShape * > &shapes) override
void mouseMoveEvent(KoPointerEvent *event) override
KoColorDisplayRendererInterface * m_displayRenderer
void setPreviewColor(const QColor &color)
void paint(QPainter &gc, const KoViewConverter &converter) override
void endAlternateAction(KoPointerEvent *event, AlternateAction action) override
QVector< qreal > m_pressureSamples
void beginPrimaryAction(KoPointerEvent *event) override
void continuePrimaryAction(KoPointerEvent *event) override
void activateAlternateAction(AlternateAction action) override
static constexpr int feedbackLineWidth
QAction * action(const QString &name) const
OutlineStyle
Definition kis_global.h:53
@ OUTLINE_FULL
Definition kis_global.h:56
QCursor cursor
Definition kis_tool.cc:64
AlternateAction
Definition kis_tool.h:134
KisCanvas2 * canvas