Krita Source Code Documentation
Loading...
Searching...
No Matches
KisToolSelectMagnetic.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Kuntal Majumder <hellozee@disroot.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KIS_TOOL_SELECT_MAGNETIC_H_
8#define KIS_TOOL_SELECT_MAGNETIC_H_
9
10#include <QPoint>
14#include <kis_icon.h>
15#include "KisMagneticWorker.h"
16
17class QPainterPath;
18
20{
21 Q_OBJECT
22
23public:
25 ~KisToolSelectMagnetic() override = default;
26 void beginPrimaryAction(KoPointerEvent *event) override;
27 void continuePrimaryAction(KoPointerEvent *event) override;
28 void endPrimaryAction(KoPointerEvent *event) override;
29 void paint(QPainter& gc, const KoViewConverter &converter) override;
30
31 //void beginPrimaryDoubleClickAction(KoPointerEvent *event) override;
32
33 void keyPressEvent(QKeyEvent *event) override;
34 void keyReleaseEvent(QKeyEvent *event) override;
35
36 void mouseMoveEvent(KoPointerEvent *event) override;
37
38 void resetCursorStyle() override;
39 void requestStrokeEnd() override;
40 void requestStrokeCancellation() override;
41 QWidget *createOptionWidget() override;
42
43Q_SIGNALS:
45
46public Q_SLOTS:
47 void deactivate() override;
48 void activate(const QSet<KoShape *> &shapes) override;
49 void undoPoints();
50 void slotSetFilterRadius(qreal);
51 void slotSetThreshold(int);
52 void slotSetSearchRadius(int);
53 void slotSetAnchorGap(int);
54 void slotCalculateEdge();
55
56protected:
58
59private:
61 void updateFeedback();
64 void updatePaintPath();
65 void resetVariables();
66 void drawAnchors(QPainter &gc);
67 void checkIfAnchorIsSelected(QPointF pt);
68 vQPointF computeEdgeWrapper(QPoint a, QPoint b);
69 void reEvaluatePoints();
70 void calculateCheckPoints(vQPointF points);
73 int updateInitialAnchorBounds(QPoint pt);
74
75 QPainterPath m_paintPath;
78 bool m_continuedMode {false};
81 bool m_complete {false};
82 bool m_selected {false};
83 bool m_finished {false};
84 QScopedPointer<KisMagneticWorker> m_worker;
85 int m_threshold {70};
88 int m_anchorGap {30};
89 qreal m_filterRadius {3.0};
91 KConfigGroup m_configGroup;
94};
95
97{
98public:
100 : KisSelectionToolFactoryBase("KisToolSelectMagnetic")
101 {
102 setToolTip(i18n("Magnetic Selection Tool"));
104 setIconName(koIconNameCStr("tool_magnetic_selection"));
105 setPriority(8);
107 }
108
110
112 {
113 return new KisToolSelectMagnetic(canvas);
114 }
115
117 {
120
121 actions << actionRegistry->makeQAction("undo_polygon_selection", this);
122
123 return actions;
124 }
125};
126
127
128#endif // __selecttoolmagnetic_h__
QAction * makeQAction(const QString &name, QObject *parent=0)
static KisActionRegistry * instance()
QList< QAction * > createActionsImpl() override
createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a va...
KisSelectionToolConfigWidgetHelper m_widgetHelper
QList< QAction * > createActionsImpl() override
createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a va...
KoToolBase * createTool(KoCanvasBase *canvas) override
QVector< QPoint > m_anchorPoints
void continuePrimaryAction(KoPointerEvent *event) override
int updateInitialAnchorBounds(QPoint pt)
void keyReleaseEvent(QKeyEvent *event) override
QWidget * createOptionWidget() override
~KisToolSelectMagnetic() override=default
QVector< QPointF > m_points
QScopedPointer< KisMagneticWorker > m_worker
void paint(QPainter &gc, const KoViewConverter &converter) override
void calculateCheckPoints(vQPointF points)
void activate(const QSet< KoShape * > &shapes) override
KisSignalCompressor m_mouseHoverCompressor
void checkIfAnchorIsSelected(QPointF pt)
void keyPressEvent(QKeyEvent *event) override
void setButtonsEnabled(bool)
QVector< vQPointF > m_pointCollection
vQPointF computeEdgeWrapper(QPoint a, QPoint b)
void mouseMoveEvent(KoPointerEvent *event) override
void endPrimaryAction(KoPointerEvent *event) override
KisToolSelectMagnetic(KoCanvasBase *canvas)
void requestStrokeCancellation() override
void beginPrimaryAction(KoPointerEvent *event) override
void setSection(const QString &section)
void setActivationShapeId(const QString &activationShapeId)
void setIconName(const char *iconName)
void setToolTip(const QString &tooltip)
void setPriority(int newPriority)
#define koIconNameCStr(name)
Definition kis_icon.h:28
static const QString KRITA_TOOL_ACTIVATION_ID
Definition kis_tool.h:37
static const QString Select
Tools that select pixels.
KisCanvas2 * canvas