QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RSnapAuto.h
Go to the documentation of this file.
1
20#ifndef RSNAPAUTO_H
21#define RSNAPAUTO_H
22
23#include "snap_global.h"
24
25#include <QFlags>
26
27#include "RSnap.h"
28
29class RMouseEvent;
30class RGraphicsView;
31
40public:
41 enum Mode {
42 None = 0x0000,
43 Intersections = 0x0001,
44 EndPoints = 0x0002,
45 MiddlePoints = 0x0004,
46 CenterPoints = 0x0008,
47 PerpendicularPoints = 0x0010,
48 TangentialPoints = 0x0020,
49 ReferencePoints = 0x0040,
50 GridPoints = 0x0080,
51 PointsOnEntity = 0x0100,
52 FreePositioning = 0x0200
53 };
54 Q_DECLARE_FLAGS(Modes, Mode)
55
56public:
57 RSnapAuto() : RSnap(RSnap::Unknown) {}
58 virtual ~RSnapAuto() {}
59
60 virtual RVector snap(
61 const RVector& position,
62 RGraphicsView& view,
63 double range=RNANDOUBLE
64 );
65
66 static void init(bool force = false);
67
68 static RSnapAuto::Modes getModes() {
69 return modes;
70 }
71 static void setModes(RSnapAuto::Modes m) {
72 modes = m;
73 }
74
75 static void setMode(RSnapAuto::Mode mode, bool on) {
76 if (on) {
77 modes |= mode;
78 } else {
79 modes &= ~mode;
80 }
81 }
82
83 static bool getMode(RSnapAuto::Mode mode) {
84 return (modes & mode) == mode;
85 }
86
87 static void setIntersections(bool on) {
88 setMode(Intersections, on);
89 }
90 static bool getIntersections() {
91 return getMode(Intersections);
92 }
93
94 static void setEndPoints(bool on) {
95 setMode(EndPoints, on);
96 }
97 static bool getEndPoints() {
98 return getMode(EndPoints);
99 }
100
101 static void setMiddlePoints(bool on) {
102 setMode(MiddlePoints, on);
103 }
104 static bool getMiddlePoints() {
105 return getMode(MiddlePoints);
106 }
107
108 static void setCenterPoints(bool on) {
109 setMode(CenterPoints, on);
110 }
111 static bool getCenterPoints() {
112 return getMode(CenterPoints);
113 }
114
115 static void setPerpendicular(bool on) {
116 setMode(PerpendicularPoints, on);
117 }
118 static bool getPerpendicular() {
119 return getMode(PerpendicularPoints);
120 }
121
122 static void setTangential(bool on) {
123 setMode(TangentialPoints, on);
124 }
125 static bool getTangential() {
126 return getMode(TangentialPoints);
127 }
128
129 static void setReferencePoints(bool on) {
130 setMode(ReferencePoints, on);
131 }
132 static bool getReferencePoints() {
133 return getMode(ReferencePoints);
134 }
135
136 static void setGridPoints(bool on) {
137 setMode(GridPoints, on);
138 }
139 static bool getGridPoints() {
140 return getMode(GridPoints);
141 }
142
143 static void setPointsOnEntity(bool on) {
144 setMode(PointsOnEntity, on);
145 }
146 static bool getPointsOnEntity() {
147 return getMode(PointsOnEntity);
148 }
149
150 static void setFreePositioning(bool on) {
151 setMode(FreePositioning, on);
152 }
153 static bool getFreePositioning() {
154 return getMode(FreePositioning);
155 }
156
157// static bool getGridPoints() {
158// return gridPoints;
159// }
160
161// static void setGridPoints(bool on) {
162// gridPoints = on;
163// }
164
165// static bool getFreePositioning() {
166// return freePositioning;
167// }
168
169// static void setFreePositioning(bool on) {
170// freePositioning = on;
171// }
172
173 virtual void reset() {
174 status = RSnap::Unknown;
175 }
176
177private:
178 static bool initialized;
179
180 static Modes modes;
181
182// static bool intersections;
183// static bool endPoints;
184// static bool middlePoints;
185// static bool centerPoints;
186// static bool perpendicular;
187// static bool tangential;
188// static bool referencePoints;
189// static bool gridPoints;
190// static bool pointsOnEntity;
191// static bool freePositioning;
192};
193
194Q_DECLARE_OPERATORS_FOR_FLAGS(RSnapAuto::Modes)
198
199#endif
void init(void basePath)
Definition AddBlockInit.js:2
#define RNANDOUBLE
Definition RMath.h:74
Q_DECLARE_METATYPE(RMath *)
Graphics view.
Definition RGraphicsView.h:67
A mouse event for a graphics scene.
Definition RMouseEvent.h:42
Auto snapper implementation.
Definition RSnapAuto.h:39
static bool getPerpendicular()
Definition RSnapAuto.h:118
static void setReferencePoints(bool on)
Definition RSnapAuto.h:129
static void setIntersections(bool on)
Definition RSnapAuto.h:87
virtual ~RSnapAuto()
Definition RSnapAuto.h:58
Mode
Definition RSnapAuto.h:41
static void setCenterPoints(bool on)
Definition RSnapAuto.h:108
static void setFreePositioning(bool on)
Definition RSnapAuto.h:150
static bool getFreePositioning()
Definition RSnapAuto.h:153
static void setGridPoints(bool on)
Definition RSnapAuto.h:136
static void setMiddlePoints(bool on)
Definition RSnapAuto.h:101
static Modes modes
Definition RSnapAuto.h:180
static bool getIntersections()
Definition RSnapAuto.h:90
static bool getPointsOnEntity()
Definition RSnapAuto.h:146
static void setMode(RSnapAuto::Mode mode, bool on)
Definition RSnapAuto.h:75
static bool getEndPoints()
Definition RSnapAuto.h:97
static void setTangential(bool on)
Definition RSnapAuto.h:122
static RSnapAuto::Modes getModes()
Definition RSnapAuto.h:68
static void setPerpendicular(bool on)
Definition RSnapAuto.h:115
virtual void reset()
Definition RSnapAuto.h:173
static void setEndPoints(bool on)
Definition RSnapAuto.h:94
static void setModes(RSnapAuto::Modes m)
Definition RSnapAuto.h:71
static void setPointsOnEntity(bool on)
Definition RSnapAuto.h:143
static bool getMode(RSnapAuto::Mode mode)
Definition RSnapAuto.h:83
static bool getMiddlePoints()
Definition RSnapAuto.h:104
static bool getReferencePoints()
Definition RSnapAuto.h:132
RSnapAuto()
Definition RSnapAuto.h:57
static bool getGridPoints()
Definition RSnapAuto.h:139
static bool getTangential()
Definition RSnapAuto.h:125
static bool getCenterPoints()
Definition RSnapAuto.h:111
static bool initialized
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RSnapAuto.h:178
Abstract base class for all grid and object snap implementations.
Definition RSnap.h:43
virtual RVector snap(const RVector &position, RGraphicsView &view, double range=RNANDOUBLE)
Definition RSnap.h:75
@ Unknown
Definition RSnap.h:50
Represents a 3d vector (x/y/z).
Definition RVector.h:47
#define QCADSNAP_EXPORT
Definition snap_global.h:10