QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RDimensionData.h
Go to the documentation of this file.
1 
20 #ifndef RDIMENSIONDATA_H
21 #define RDIMENSIONDATA_H
22 
23 #include "entity_global.h"
24 
25 #include "RDocument.h"
26 #include "REntityData.h"
27 #include "RTextData.h"
28 #include "RVector.h"
29 
39  friend class RDimensionEntity;
40 
41 protected:
43 
44 public:
46  RDimensionData(const RVector& definitionPoint,
47  const RVector& textPositionCenter,
48  RS::VAlign valign,
49  RS::HAlign halign,
50  RS::TextLineSpacingStyle lineSpacingStyle,
51  double lineSpacingFactor,
52  const QString& text,
53  const QString& fontName,
54  double textAngle);
55 
56  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
57 
58  virtual bool isValid() const;
59 
60  void setDefinitionPoint(const RVector& p) {
61  definitionPoint = p;
62  update();
63  }
64 
66  return definitionPoint;
67  }
68 
69  void setText(const QString& t) {
70  text = t;
71  update();
72  }
73 
74  QString getText() const {
75  return text;
76  }
77 
78  void setUpperTolerance(const QString& t) {
79  upperTolerance = t;
80  }
81 
82  void setLowerTolerance(const QString& t) {
83  lowerTolerance = t;
84  }
85 
86  void setTextPosition(const RVector& p) {
87  textPositionCenter = p;
88  textPositionSide = RVector::invalid;
89  update();
90  }
91 
93  if (textPositionSide.isValid()) {
94  return textPositionSide;
95  }
96  else {
97  return textPositionCenter;
98  }
99  }
100 
101  void setFontName(const QString& fn) {
102  fontName = fn;
103  update();
104  }
105 
106  QString getFontName() const {
107  return fontName;
108  }
109 
110  double getLinearFactor() const {
111  return linearFactor;
112  }
113 
114  void setLinearFactor(double f) {
115  linearFactor = f;
116  }
117 
118  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
119  virtual bool intersectsWith(const RShape& shape) const;
120 
121  virtual QList<RVector> getReferencePoints(
123 
124  virtual bool moveReferencePoint(const RVector& referencePoint,
125  const RVector& targetPoint);
126 
127  virtual bool move(const RVector& offset);
128  virtual bool rotate(double rotation, const RVector& center);
129  virtual bool scale(const RVector& scaleFactors, const RVector& center);
130  virtual bool mirror(const RLine& axis);
131 
132  double getDimscale() const;
133  double getDimexo() const;
134  double getDimexe() const;
135  double getDimasz() const;
136  double getDimgap() const;
137  double getDimtxt() const;
138  bool useArchTick() const;
139  bool hasCustomTextPosition() const;
140  void setCustomTextPosition(bool on);
141 
143  return lineSpacingStyle;
144  }
145 
146  double getLineSpacingFactor() const {
147  return lineSpacingFactor;
148  }
149 
150  double getTextAngle() const {
151  return textAngle;
152  }
153 
154  QList<QSharedPointer<RShape> > getDimensionLineShapes(
155  const RVector& p1, const RVector& p2,
156  bool arrow1, bool arrow2) const;
157  virtual QList<QSharedPointer<RShape> > getArrow(
158  const RVector& position, double direction) const;
159  RTextData& getTextData() const;
160  void initTextData() const;
161  virtual void updateTextData() const;
162  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
163  virtual double getMeasuredValue() const { return 0.0; }
164  virtual QString getAutoLabel() const { return ""; }
165  QString formatLabel(double distance) const;
166  QString formatAngleLabel(double textAngle) const;
167  //virtual void updateFromTextPosition() = 0;
168 
169  virtual void update() const;
170 
171 protected:
194  QString text;
196  QString upperTolerance;
198  QString lowerTolerance;
200  QString fontName;
201 
202  mutable double defaultAngle;
204  double textAngle;
205 
206  double linearFactor;
207 
208  mutable bool dirty;
210  mutable RBox boundingBox;
211  mutable double dimLineLength;
212 
214  mutable bool autoTextPos;
215 };
216 
219 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
220 
221 #endif