Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSnapGuide.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2008-2009 Jan Hambrecht <jaham@gmx.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KOSNAPGUIDE_H
8#define KOSNAPGUIDE_H
9
10#include "kritaflake_export.h"
11
12#include <QScopedPointer>
13#include <QList>
14#include <Qt>
15
16class KoSnapStrategy;
17class KoShape;
18class KoPathPoint;
19class KoViewConverter;
20class KoCanvasBase;
21class QPainter;
22class QPointF;
23class QRectF;
24
44class KRITAFLAKE_EXPORT KoSnapGuide
45{
46public:
49 {
50 OrthogonalSnapping = 1,
51 NodeSnapping = 2,
52 ExtensionSnapping = 4,
53 IntersectionSnapping = 8,
54 GridSnapping = 0x10,
55 BoundingBoxSnapping = 0x20,
56 GuideLineSnapping = 0x40,
57 DocumentBoundsSnapping = 0x80,
58 DocumentCenterSnapping = 0x100,
59 CustomSnapping = 0x200,
60 PixelSnapping = 0x400
61 };
62 Q_DECLARE_FLAGS(Strategies, Strategy)
63
64
65 explicit KoSnapGuide(KoCanvasBase *canvas);
66
67 virtual ~KoSnapGuide();
68
70 QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers);
71
72 QPointF snap(const QPointF &mousePosition, const QPointF &dragOffset, Qt::KeyboardModifiers modifiers);
73
75 void paint(QPainter &painter, const KoViewConverter &converter);
76
78 QRectF boundingRect();
79
81 void setAdditionalEditedShape(KoShape *shape);
82
85
86 void enableSnapStrategy(Strategy type, bool value);
87 bool isStrategyEnabled(Strategy type) const;
88
90 void enableSnapStrategies(Strategies strategies);
91
93 KoSnapGuide::Strategies enabledSnapStrategies() const;
94
101 bool addCustomSnapStrategy(KoSnapStrategy *customStrategy);
102
108 void overrideSnapStrategy(Strategy type, KoSnapStrategy *strategy);
109
111 void enableSnapping(bool on);
112
114 bool isSnapping() const;
115
117 void setSnapDistance(int distance);
118
120 int snapDistance() const;
121
124
126 void setIgnoredPathPoints(const QList<KoPathPoint*> &ignoredPoints);
127
129 QList<KoPathPoint*> ignoredPathPoints() const;
130
132 void setIgnoredShapes(const QList<KoShape*> &ignoredShapes);
133
136
138 void reset();
139
140private:
141 class Private;
142 const QScopedPointer<Private> d;
143};
144
145Q_DECLARE_OPERATORS_FOR_FLAGS(KoSnapGuide::Strategies)
146
147#endif // KOSNAPGUIDE_H
float value(const T *src, size_t ch)
Q_DECLARE_FLAGS(KisUpdaterContextSnapshotEx, KisUpdaterContextSnapshotExTag)
qreal distance(const QPointF &p1, const QPointF &p2)
A KoPathPoint represents a point in a path.
KoShape * additionalEditedShape() const
returns the extra shapes to use
const QScopedPointer< Private > d
Strategy
the different possible snap Strategies
Definition KoSnapGuide.h:49
int snapDistance() const
returns the snap distance in pixels
QList< KoShape * > ignoredShapes() const
Returns list of ignored shapes.
KoCanvasBase * canvas() const
returns the canvas the snap guide is working on
Q_DECLARE_OPERATORS_FOR_FLAGS(KisBaseRectsWalker::SubtreeVisitFlags)