Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathTool.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006-2012 Jan Hambrecht <jaham@gmx.net>
3 * SPDX-FileCopyrightText: 2006, 2007 Thorsten Zachmann <zachmann@kde.org>
4 * SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org>
5 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
6 *
7 * SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9
10#ifndef KOPATHTOOL_H
11#define KOPATHTOOL_H
12
13#include "KoPathShape.h"
14#include "KoToolBase.h"
15#include "KoPathToolSelection.h"
17#include <QList>
18#include <QCursor>
21
22class QActionGroup;
23class QButtonGroup;
24class KoCanvasBase;
28class KUndo2Command;
29
30class QMenu;
31
32
35class KRITAFLAKE_EXPORT KoPathTool : public KoToolBase
36{
37 Q_OBJECT
38public:
39 explicit KoPathTool(KoCanvasBase *canvas);
40 ~KoPathTool() override;
41
42 void paint(QPainter &painter, const KoViewConverter &converter) override;
43 void repaintDecorations() override;
44 QRectF decorationsRect() const override;
45 void mousePressEvent(KoPointerEvent *event) override;
46 void mouseMoveEvent(KoPointerEvent *event) override;
47 void mouseReleaseEvent(KoPointerEvent *event) override;
48 void keyPressEvent(QKeyEvent *event) override;
49 void keyReleaseEvent(QKeyEvent *event) override;
50 void mouseDoubleClickEvent(KoPointerEvent *event) override;
51 void activate(const QSet<KoShape*> &shapes) override;
52 void deactivate() override;
53 void deleteSelection() override;
54 KoToolSelection* selection() override;
55 void requestUndoDuringStroke() override;
56 void requestStrokeCancellation() override;
57 void requestStrokeEnd() override;
58 void explicitUserStrokeEndRequest() override;
59
60 bool selectAll() override;
61 void deselect() override;
62
63 QMenu* popupActionsMenu() override;
64
65 // for KoPathToolSelection
66 void notifyPathPointsChanged(KoPathShape *shape);
67
68public Q_SLOTS:
69 void canvasResourceChanged(int key, const QVariant & res) override;
70
71Q_SIGNALS:
72 void typeChanged(int types);
74
75protected:
78
79private:
80 struct PathSegment;
81
82 void updateOptionsWidget();
83 PathSegment* segmentAtPoint(const QPointF &point);
84
85private Q_SLOTS:
86 void pointTypeChangedCorner();
87 void pointTypeChangedSmooth();
88 void pointTypeChangedSymmetric();
89 void pointTypeChanged(KoPathPointTypeCommand::PointType type);
90 void insertPoints();
91 void removePoints();
92 void segmentToLine();
93 void segmentToCurve();
94 void convertToPath();
95 void joinPoints();
96 void mergePoints();
97 void breakAtPoint();
98 void breakAtSegment();
99 void breakAtSelection();
100 void pointSelectionChanged();
101 void updateActions();
102 void pointToLine();
103 void pointToCurve();
104 void slotSelectionChanged();
105
106private:
107 void clearActivePointSelectionReferences();
108 void initializeWithShapes(const QList<KoShape*> shapes);
109 KUndo2Command* createPointToCurveCommand(const QList<KoPathPointData> &points);
110 void mergePointsImpl(bool doJoin);
111
112protected:
115
116private:
117 QScopedPointer<KoPathToolHandle> m_activeHandle;
118 QPointF m_lastPoint;
119 QScopedPointer<PathSegment> m_activeSegment;
120
121 // make a friend so that it can test private member/methods
122 friend class TestPathTool;
123
124 QScopedPointer<KoInteractionStrategy> m_currentStrategy;
125
142 QScopedPointer<QMenu> m_contextMenu;
145
146 Q_DECLARE_PRIVATE(KoToolBase)
147};
148
149#endif
PointType
The type of the point.
The position of a path point within a path shape.
Definition KoPathShape.h:63
Handle the selection of points.
QAction * m_actionJoinSegment
Definition KoPathTool.h:138
QScopedPointer< KoInteractionStrategy > m_currentStrategy
the rubber selection strategy
Definition KoPathTool.h:124
QCursor m_selectCursor
Definition KoPathTool.h:114
QAction * m_actionCurvePoint
Definition KoPathTool.h:129
QAction * m_actionLinePoint
Definition KoPathTool.h:130
QAction * m_actionRemovePoint
Definition KoPathTool.h:134
KoPathToolSelection m_pointSelection
the point selection
Definition KoPathTool.h:113
QAction * m_actionLineSegment
Definition KoPathTool.h:131
QScopedPointer< QMenu > m_contextMenu
Definition KoPathTool.h:142
QAction * m_actionPathPointSymmetric
Definition KoPathTool.h:128
QScopedPointer< PathSegment > m_activeSegment
Definition KoPathTool.h:119
QAction * m_actionBreakSegment
Definition KoPathTool.h:136
QAction * m_actionAddPoint
Definition KoPathTool.h:133
void singleShapeChanged(KoPathShape *path)
KisSignalAutoConnectionsStore m_canvasConnections
Definition KoPathTool.h:143
QAction * m_actionPathPointSmooth
Definition KoPathTool.h:127
QPointF m_lastPoint
needed for interaction strategy
Definition KoPathTool.h:118
QAction * m_actionCurveSegment
Definition KoPathTool.h:132
QCursor m_moveCursor
Definition KoPathTool.h:141
QAction * m_actionMergePoints
Definition KoPathTool.h:139
QScopedPointer< KoPathToolHandle > m_activeHandle
the currently active handle
Definition KoPathTool.h:117
KoShapeFillResourceConnector m_shapeFillResourceConnector
Definition KoPathTool.h:144
QAction * m_actionBreakPoint
Definition KoPathTool.h:135
QAction * m_actionConvertToPath
Definition KoPathTool.h:140
QAction * m_actionPathPointCorner
Definition KoPathTool.h:126
void typeChanged(int types)
QAction * m_actionBreakSelection
Definition KoPathTool.h:137
virtual void deleteSelection()
virtual void requestUndoDuringStroke()
virtual void requestStrokeCancellation()
virtual QList< QPointer< QWidget > > createOptionWidgets()
virtual void keyReleaseEvent(QKeyEvent *event)
virtual void mousePressEvent(KoPointerEvent *event)=0
virtual KoToolSelection * selection()
virtual void deselect()
deselect the tool should clear the selection if it has one.
virtual void repaintDecorations()
virtual void mouseMoveEvent(KoPointerEvent *event)=0
virtual void activate(const QSet< KoShape * > &shapes)
virtual void canvasResourceChanged(int key, const QVariant &res)
virtual void mouseReleaseEvent(KoPointerEvent *event)=0
virtual void keyPressEvent(QKeyEvent *event)
virtual bool selectAll()
selectAll select all data the tool can select.
virtual void deactivate()
virtual QMenu * popupActionsMenu()
Definition KoToolBase.h:334
virtual QRectF decorationsRect() const
virtual void mouseDoubleClickEvent(KoPointerEvent *event)
virtual void requestStrokeEnd()
virtual void paint(QPainter &painter, const KoViewConverter &converter)=0
virtual void explicitUserStrokeEndRequest()
explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any eq...