QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RRefPoint.h
Go to the documentation of this file.
1#ifndef RREFPOINT_H
2#define RREFPOINT_H
3
4#include "../core_global.h"
5
6#include <QFlags>
7#include <QList>
8
9#include "RVector.h"
10
19public:
20 enum Flag {
21 NoFlags = 0x000,
22 Secondary = 0x001,
23 Tertiary = 0x002,
24 Center = 0x004,
25 Ignore = 0x008,
26 Start = 0x010,
27 End = 0x020,
28 Arrow = 0x040,
29 Selected = 0x080
30 };
31 Q_DECLARE_FLAGS(Flags, Flag)
32
33 static QList<RVector> toVectorList(const QList<RRefPoint>& list) {
34 QList<RVector> ret;
35 for (int i=0; i<list.length(); i++) {
36 ret.append(list.at(i));
37 }
38 return ret;
39 }
40
41 static QList<RRefPoint> toRefPointList(const QList<RVector>& list, RRefPoint::Flags flags = RRefPoint::NoFlags) {
42 QList<RRefPoint> ret;
43 for (int i=0; i<list.length(); i++) {
44 ret.append(RRefPoint(list.at(i), flags));
45 }
46 return ret;
47 }
48
50 RRefPoint(const RVector& v, RRefPoint::Flags f) : RVector(v), flags(f) {}
51 RRefPoint(const RVector& v) : RVector(v) {}
52 RRefPoint(double vx, double vy, double vz = 0.0, bool valid_in = true) : RVector(vx, vy, vz, valid_in) {}
53
54 bool isSecondary() const {
55 return getFlag(RRefPoint::Secondary);
56 }
57 void setSecondary(bool on) {
58 setFlag(RRefPoint::Secondary, on);
59 }
60
61 bool isTertiary() const {
62 return getFlag(RRefPoint::Tertiary);
63 }
64 void setTertiary(bool on) {
65 setFlag(RRefPoint::Tertiary, on);
66 }
67
68 bool isIgnore() const {
69 return getFlag(RRefPoint::Ignore);
70 }
71
72 void setIgnore(bool on) {
73 setFlag(RRefPoint::Ignore, on);
74 }
75
76 bool isCenter() const {
77 return getFlag(RRefPoint::Center);
78 }
79
80 void setCenter(bool on) {
81 setFlag(RRefPoint::Center, on);
82 }
83
84 bool isStart() const {
85 return getFlag(RRefPoint::Start);
86 }
87
88 void setStart(bool on) {
89 setFlag(RRefPoint::Start, on);
90 }
91
92 bool isEnd() const {
93 return getFlag(RRefPoint::End);
94 }
95
96 void setEnd(bool on) {
97 setFlag(RRefPoint::End, on);
98 }
99
100 bool isArrow() const {
101 return getFlag(RRefPoint::Arrow);
102 }
103
104 void setArrow(bool on) {
105 setFlag(RRefPoint::Arrow, on);
106 }
107
108 bool isSelected() const {
109 return getFlag(RRefPoint::Selected);
110 }
111
112 void setSelected(bool on) {
113 setFlag(RRefPoint::Selected, on);
114 }
115
116 void setFlag(RRefPoint::Flag flag, bool on) {
117 if (on) {
118 flags |= flag;
119 } else {
120 flags &= ~flag;
121 }
122 }
123
124 bool getFlag(RRefPoint::Flag flag) const {
125 return (flags & flag) == flag;
126 }
127
128 RRefPoint::Flags getFlags() const {
129 return flags;
130 }
131
132 void setFlags(RRefPoint::Flags f) {
133 flags = f;
134 }
135
136private:
137 Flags flags;
138};
139
140QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RRefPoint& v);
141
142Q_DECLARE_METATYPE(QList<RRefPoint>)
143Q_DECLARE_METATYPE(QList<RRefPoint>*)
144typedef QMultiMap<int, RRefPoint> _RMapIntRefPoint;
151Q_DECLARE_METATYPE(QFlags<RRefPoint::Flag>)
152Q_DECLARE_METATYPE(QFlags<RRefPoint::Flag>*)
153
154#endif
Q_DECLARE_METATYPE(RMath *)
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RRefPoint &v)
Definition RRefPoint.cpp:5
QMultiMap< int, RRefPoint > _RMapIntRefPoint
Definition RRefPoint.h:144
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Represents a reference point of an entity.
Definition RRefPoint.h:18
bool isTertiary() const
Definition RRefPoint.h:61
RRefPoint()
Definition RRefPoint.h:49
bool isEnd() const
Definition RRefPoint.h:92
void setIgnore(bool on)
Definition RRefPoint.h:72
void setSecondary(bool on)
Definition RRefPoint.h:57
Flags flags
Definition RRefPoint.h:137
void setEnd(bool on)
Definition RRefPoint.h:96
void setFlag(RRefPoint::Flag flag, bool on)
Definition RRefPoint.h:116
void setTertiary(bool on)
Definition RRefPoint.h:64
bool isStart() const
Definition RRefPoint.h:84
Flag
Definition RRefPoint.h:20
@ Ignore
Ignore reference point for drag and drop.
Definition RRefPoint.h:25
@ Selected
Reference point is selected.
Definition RRefPoint.h:29
@ Start
Reference point is a start point.
Definition RRefPoint.h:26
@ Center
Reference point is a center point.
Definition RRefPoint.h:24
@ End
Reference point is a start point.
Definition RRefPoint.h:27
@ Arrow
Reference point is a dimension arrow.
Definition RRefPoint.h:28
@ Tertiary
Tertiary reference point (typically shown with different color)
Definition RRefPoint.h:23
@ Secondary
Secondary reference point (typically shown with different color)
Definition RRefPoint.h:22
@ NoFlags
Definition RRefPoint.h:21
void setCenter(bool on)
Definition RRefPoint.h:80
void setSelected(bool on)
Definition RRefPoint.h:112
bool isSelected() const
Definition RRefPoint.h:108
bool getFlag(RRefPoint::Flag flag) const
Definition RRefPoint.h:124
void setStart(bool on)
Definition RRefPoint.h:88
static QList< RRefPoint > toRefPointList(const QList< RVector > &list, RRefPoint::Flags flags=RRefPoint::NoFlags)
Definition RRefPoint.h:41
void setArrow(bool on)
Definition RRefPoint.h:104
RRefPoint(const RVector &v)
Definition RRefPoint.h:51
RRefPoint(double vx, double vy, double vz=0.0, bool valid_in=true)
Definition RRefPoint.h:52
bool isArrow() const
Definition RRefPoint.h:100
bool isSecondary() const
Definition RRefPoint.h:54
void setFlags(RRefPoint::Flags f)
Definition RRefPoint.h:132
RRefPoint::Flags getFlags() const
Definition RRefPoint.h:128
bool isCenter() const
Definition RRefPoint.h:76
RRefPoint(const RVector &v, RRefPoint::Flags f)
Definition RRefPoint.h:50
bool isIgnore() const
Definition RRefPoint.h:68
Represents a 3d vector (x/y/z).
Definition RVector.h:47
#define QCADCORE_EXPORT
Definition core_global.h:10
#define const
Definition zconf.h:156