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;
25
45class KRITAFLAKE_EXPORT KoSnapGuide
46{
47public:
50 {
51 OrthogonalSnapping = 1,
52 NodeSnapping = 2,
53 ExtensionSnapping = 4,
54 IntersectionSnapping = 8,
55 GridSnapping = 0x10,
56 BoundingBoxSnapping = 0x20,
57 GuideLineSnapping = 0x40,
58 DocumentBoundsSnapping = 0x80,
59 DocumentCenterSnapping = 0x100,
60 CustomSnapping = 0x200,
61 PixelSnapping = 0x400
62 };
63 Q_DECLARE_FLAGS(Strategies, Strategy)
64
65
66 explicit KoSnapGuide(KoCanvasBase *canvas);
67
68 virtual ~KoSnapGuide();
69
71 QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers);
72
73 QPointF snap(const QPointF &mousePosition, const QPointF &dragOffset, Qt::KeyboardModifiers modifiers);
74
76 void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRenderer);
77
79 QRectF boundingRect();
80
82 void setAdditionalEditedShape(KoShape *shape);
83
86
87 void enableSnapStrategy(Strategy type, bool value);
88 bool isStrategyEnabled(Strategy type) const;
89
91 void enableSnapStrategies(Strategies strategies);
92
94 KoSnapGuide::Strategies enabledSnapStrategies() const;
95
102 bool addCustomSnapStrategy(KoSnapStrategy *customStrategy);
103
109 void overrideSnapStrategy(Strategy type, KoSnapStrategy *strategy);
110
112 void enableSnapping(bool on);
113
115 bool isSnapping() const;
116
118 void setSnapDistance(int distance);
119
121 int snapDistance() const;
122
125
127 void setIgnoredPathPoints(const QList<KoPathPoint*> &ignoredPoints);
128
130 QList<KoPathPoint*> ignoredPathPoints() const;
131
133 void setIgnoredShapes(const QList<KoShape*> &ignoredShapes);
134
137
139 void reset();
140
141private:
142 class Private;
143 const QScopedPointer<Private> d;
144};
145
146Q_DECLARE_OPERATORS_FOR_FLAGS(KoSnapGuide::Strategies)
147
148#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:50
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)