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>
22
23class QActionGroup;
24class QButtonGroup;
25class KoCanvasBase;
29class KUndo2Command;
30
31class QMenu;
32
33
36class KRITAFLAKE_EXPORT KoPathTool : public KoToolBase
37{
38 Q_OBJECT
39public:
40 explicit KoPathTool(KoCanvasBase *canvas);
41 ~KoPathTool() override;
42
43 void paint(QPainter &painter, const KoViewConverter &converter) override;
44 void repaintDecorations() override;
45 QRectF decorationsRect() const override;
46 void mousePressEvent(KoPointerEvent *event) override;
47 void mouseMoveEvent(KoPointerEvent *event) override;
48 void mouseReleaseEvent(KoPointerEvent *event) override;
49 void keyPressEvent(QKeyEvent *event) override;
50 void keyReleaseEvent(QKeyEvent *event) override;
51 void mouseDoubleClickEvent(KoPointerEvent *event) override;
52 void activate(const QSet<KoShape*> &shapes) override;
53 void deactivate() override;
54 void deleteSelection() override;
55 KoToolSelection* selection() override;
56 void requestUndoDuringStroke() override;
57 void requestStrokeCancellation() override;
58 void requestStrokeEnd() override;
59 void explicitUserStrokeEndRequest() override;
60
61 bool selectAll() override;
62 void deselect() override;
63
64 QMenu* popupActionsMenu() override;
65
66 // for KoPathToolSelection
67 void notifyPathPointsChanged(KoPathShape *shape);
68
69public Q_SLOTS:
70 void canvasResourceChanged(int key, const QVariant & res) override;
71
72Q_SIGNALS:
73 void typeChanged(int types);
75
76protected:
79
80private:
81 struct PathSegment;
82
83 void updateOptionsWidget();
84 PathSegment* segmentAtPoint(const QPointF &point);
85
86private Q_SLOTS:
87 void pointTypeChangedCorner();
88 void pointTypeChangedSmooth();
89 void pointTypeChangedSymmetric();
90 void pointTypeChanged(KoPathPointTypeCommand::PointType type);
91 void insertPoints();
92 void removePoints();
93 void segmentToLine();
94 void segmentToCurve();
95 void convertToPath();
96 void joinPoints();
97 void mergePoints();
98 void breakAtPoint();
99 void breakAtSegment();
100 void breakAtSelection();
101 void pointSelectionChanged();
102 void updateActions();
103 void pointToLine();
104 void pointToCurve();
105 void slotSelectionChanged();
106
107private:
108 void clearActivePointSelectionReferences();
109 void initializeWithShapes(const QList<KoShape*> shapes);
110 KUndo2Command* createPointToCurveCommand(const QList<KoPathPointData> &points);
111 void mergePointsImpl(bool doJoin);
112
113protected:
116
117private:
118 QScopedPointer<KoPathToolHandle> m_activeHandle;
119 QPointF m_lastPoint;
120 QScopedPointer<PathSegment> m_activeSegment;
121
122 // make a friend so that it can test private member/methods
123 friend class TestPathTool;
124
125 QScopedPointer<KoInteractionStrategy> m_currentStrategy;
126
143 QScopedPointer<QMenu> m_contextMenu;
144 QScopedPointer<KoSvgTextShapeOutlineHelper> m_textOutlineHelper;
147
148 Q_DECLARE_PRIVATE(KoToolBase)
149};
150
151#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:139
QScopedPointer< KoInteractionStrategy > m_currentStrategy
the rubber selection strategy
Definition KoPathTool.h:125
QCursor m_selectCursor
Definition KoPathTool.h:115
QAction * m_actionCurvePoint
Definition KoPathTool.h:130
QAction * m_actionLinePoint
Definition KoPathTool.h:131
QAction * m_actionRemovePoint
Definition KoPathTool.h:135
KoPathToolSelection m_pointSelection
the point selection
Definition KoPathTool.h:114
QAction * m_actionLineSegment
Definition KoPathTool.h:132
QScopedPointer< QMenu > m_contextMenu
Definition KoPathTool.h:143
QAction * m_actionPathPointSymmetric
Definition KoPathTool.h:129
QScopedPointer< PathSegment > m_activeSegment
Definition KoPathTool.h:120
QScopedPointer< KoSvgTextShapeOutlineHelper > m_textOutlineHelper
Definition KoPathTool.h:144
QAction * m_actionBreakSegment
Definition KoPathTool.h:137
QAction * m_actionAddPoint
Definition KoPathTool.h:134
void singleShapeChanged(KoPathShape *path)
KisSignalAutoConnectionsStore m_canvasConnections
Definition KoPathTool.h:145
QAction * m_actionPathPointSmooth
Definition KoPathTool.h:128
QPointF m_lastPoint
needed for interaction strategy
Definition KoPathTool.h:119
QAction * m_actionCurveSegment
Definition KoPathTool.h:133
QCursor m_moveCursor
Definition KoPathTool.h:142
QAction * m_actionMergePoints
Definition KoPathTool.h:140
QScopedPointer< KoPathToolHandle > m_activeHandle
the currently active handle
Definition KoPathTool.h:118
KoShapeFillResourceConnector m_shapeFillResourceConnector
Definition KoPathTool.h:146
QAction * m_actionBreakPoint
Definition KoPathTool.h:136
QAction * m_actionConvertToPath
Definition KoPathTool.h:141
QAction * m_actionPathPointCorner
Definition KoPathTool.h:127
void typeChanged(int types)
QAction * m_actionBreakSelection
Definition KoPathTool.h:138
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...