Krita Source Code Documentation
Loading...
Searching...
No Matches
KarbonCalligraphyTool.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2008 Fela Winkelmolen <fela.kde@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KARBONCALLIGRAPHYTOOL_H
8#define KARBONCALLIGRAPHYTOOL_H
9
10#include <KoToolBase.h>
11#include <KoPathShape.h>
12#include <QPainterPath>
13#include <QPointer>
14
16
17class KoPathShape;
19
21{
22 Q_OBJECT
23public:
25 ~KarbonCalligraphyTool() override;
26
27 void paint(QPainter &painter, const KoViewConverter &converter) override;
28
29 void mousePressEvent(KoPointerEvent *event) override;
30 void mouseMoveEvent(KoPointerEvent *event) override;
31 void mouseReleaseEvent(KoPointerEvent *event) override;
32
34
36
37 void activate(const QSet<KoShape *> &shapes) override;
38 void deactivate() override;
39
40Q_SIGNALS:
42
43private Q_SLOTS:
44 void setUsePath(bool usePath);
45 void setUsePressure(bool usePressure);
46 void setUseAngle(bool useAngle);
47 void setStrokeWidth(double width);
48 void setThinning(double thinning);
49 void setAngle(int angle); // set the angle in degrees
50 void setFixation(double fixation);
51 void setCaps(double caps);
52 void setMass(double mass); // set the mass in user friendly format
53 void setDrag(double drag);
54
55 void updateSelectedPath();
56
57private:
58 void addPoint(KoPointerEvent *event);
59 // auxiliary function that sets m_angle
60 void setAngle(KoPointerEvent *event);
61 // auxiliary functions to calculate the dynamic parameters
62 // returns the new point and sets speed to the speed
63 QPointF calculateNewPoint(const QPointF &mousePos, QPointF *speed);
64 qreal calculateWidth(qreal pressure);
65 qreal calculateAngle(const QPointF &oldSpeed, const QPointF &newSpeed);
66
67 QPointF m_lastPoint;
69
70 // used to determine if the device supports tilt
72
73 bool m_usePath; // follow selected path
74 bool m_usePressure; // use tablet pressure
75 bool m_useAngle; // use tablet angle
78 qreal m_customAngle; // angle set by the user
79 qreal m_angle; // angle to use, may use the device angle, in radians!!!
82 qreal m_caps;
83 qreal m_mass; // in raw format (not user friendly)
84 qreal m_drag; // from 0.0 to 1.0
85
91
94
95 // dynamic parameters
96 QPointF m_speed; // used as a vector
97
99};
100
101#endif // KARBONCALLIGRAPHYTOOL_H
KarbonCalligraphicShape * m_shape
void setUseAngle(bool useAngle)
KarbonCalligraphyTool(KoCanvasBase *canvas)
qreal calculateAngle(const QPointF &oldSpeed, const QPointF &newSpeed)
void setStrokeWidth(double width)
KarbonCalligraphyOptionWidget * m_widget
void addPoint(KoPointerEvent *event)
void mouseReleaseEvent(KoPointerEvent *event) override
void mouseMoveEvent(KoPointerEvent *event) override
void mousePressEvent(KoPointerEvent *event) override
void setThinning(double thinning)
void activate(const QSet< KoShape * > &shapes) override
void pathSelectedChanged(bool selection)
QPointF calculateNewPoint(const QPointF &mousePos, QPointF *speed)
QList< QPointer< QWidget > > createOptionWidgets() override
KisPopupWidgetInterface * popupWidget() override
void setUsePressure(bool usePressure)
void paint(QPainter &painter, const KoViewConverter &converter) override
void setFixation(double fixation)
qreal calculateWidth(qreal pressure)
The PopupWidgetInterface abstract class defines the basic interface that will be used by all popup wi...
The position of a path point within a path shape.
Definition KoPathShape.h:63
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
virtual KoToolSelection * selection()