QCAD
Open Source 2D CAD
RRestrictAngleLength.h
Go to the documentation of this file.
1 
20 #ifndef RRESTRICTANGLELENGTH_H
21 #define RRESTRICTANGLELENGTH_H
22 
23 #include "snap_global.h"
24 
25 #include "RSnapRestriction.h"
26 
27 class RDocumentInterface;
28 
38 public:
43  AngleLength
44  };
45 
46  RRestrictAngleLength(RDocumentInterface* documentInterface = NULL) :
47  RSnapRestriction(documentInterface),
48  mode(RRestrictAngleLength::AngleLength),
49  baseAngle(0.0),
50  angle(0.0),
51  baseLength(0.0),
52  length(0.0) {}
53 
54  RRestrictAngleLength(RDocumentInterface* documentInterface, double baseAngle, double angle, double baseLength, double length)
55  : RSnapRestriction(documentInterface),
56  mode(RRestrictAngleLength::AngleLength),
57  baseAngle(baseAngle), angle(angle),
58  baseLength(baseLength), length(length) {}
59 
60  virtual ~RRestrictAngleLength() {}
61 
62  virtual RVector restrictSnap(const RVector& position, const RVector& relativeZero);
63 
64  virtual void setBaseAngle(double a) {
65  baseAngle = a;
66  }
67 
68  virtual void setAngle(double a) {
69  angle = a;
70  }
71 
72  virtual void setBaseLength(double l) {
73  baseLength = l;
74  }
75 
76  virtual void setLength(double l) {
77  length = l;
78  }
79 
80  virtual void setRestrictAngle(bool on) {
81  if (on) {
82  if (mode==None) {
83  mode = Angle;
84  }
85  if (mode==Length) {
86  mode = AngleLength;
87  }
88  }
89  else {
90  if (mode==Angle) {
91  mode = None;
92  }
93  if (mode==AngleLength) {
94  mode = Length;
95  }
96  }
97  }
98 
99  virtual void setRestrictLength(bool on) {
100  if (on) {
101  if (mode==None) {
102  mode = Length;
103  }
104  if (mode==Angle) {
105  mode = AngleLength;
106  }
107  }
108  else {
109  if (mode==Length) {
110  mode = None;
111  }
112  if (mode==AngleLength) {
113  mode = Angle;
114  }
115  }
116  }
117 
118 protected:
120  double baseAngle;
121  double angle;
122  double baseLength;
123  double length;
124 };
125 
128 
129 #endif
RRestrictAngleLength(RDocumentInterface *documentInterface, double baseAngle, double angle, double baseLength, double length)
Definition: RRestrictAngleLength.h:54
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
AngleLengthMode mode
Definition: RRestrictAngleLength.h:119
Abstract base class for all snap restriction implementations.
Definition: RSnapRestriction.h:37
double baseLength
Definition: RRestrictAngleLength.h:122
Angle and length snap restriction implementation.
Definition: RRestrictAngleLength.h:37
virtual RVector restrictSnap(const RVector &position, const RVector &relativeZero)=0
Definition: RRestrictAngleLength.h:41
virtual void setBaseAngle(double a)
Definition: RRestrictAngleLength.h:64
virtual void setLength(double l)
Definition: RRestrictAngleLength.h:76
Definition: RRestrictAngleLength.h:42
Q_DECLARE_METATYPE(RMath *)
RRestrictAngleLength(RDocumentInterface *documentInterface=NULL)
Definition: RRestrictAngleLength.h:46
virtual void setAngle(double a)
Definition: RRestrictAngleLength.h:68
double baseAngle
Definition: RRestrictAngleLength.h:120
double angle
Definition: RRestrictAngleLength.h:121
virtual ~RRestrictAngleLength()
Definition: RRestrictAngleLength.h:60
virtual void setBaseLength(double l)
Definition: RRestrictAngleLength.h:72
double length
Definition: RRestrictAngleLength.h:123
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:84
AngleLengthMode
Definition: RRestrictAngleLength.h:39
#define QCADSNAP_EXPORT
Definition: snap_global.h:10
virtual void setRestrictLength(bool on)
Definition: RRestrictAngleLength.h:99
virtual void setRestrictAngle(bool on)
Definition: RRestrictAngleLength.h:80
Definition: RRestrictAngleLength.h:40