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