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() 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) 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 getDimexo() const;
133  double getDimexe() const;
134  double getDimasz() const;
135  double getDimgap() const;
136  double getDimtxt() const;
137  bool useArchTick() const;
138  bool hasCustomTextPosition() const;
139  void setCustomTextPosition(bool on);
140 
142  return lineSpacingStyle;
143  }
144 
145  double getLineSpacingFactor() const {
146  return lineSpacingFactor;
147  }
148 
149  double getTextAngle() const {
150  return textAngle;
151  }
152 
153  QList<QSharedPointer<RShape> > getDimensionLineShapes(
154  const RVector& p1, const RVector& p2,
155  bool arrow1, bool arrow2) const;
156  virtual QList<QSharedPointer<RShape> > getArrow(
157  const RVector& position, double direction) const;
158  RTextData& getTextData() const;
159  void initTextData() const;
160  virtual void updateTextData() const;
161  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
162  virtual double getMeasuredValue() const { return 0.0; }
163  virtual QString getAutoLabel() const { return ""; }
164  QString formatLabel(double distance) const;
165  QString formatAngleLabel(double textAngle) const;
166  //virtual void updateFromTextPosition() = 0;
167 
168  virtual void update() const;
169 
170 protected:
193  QString text;
195  QString upperTolerance;
197  QString lowerTolerance;
199  QString fontName;
200 
201  mutable double defaultAngle;
203  double textAngle;
204 
205  double linearFactor;
206 
207  mutable bool dirty;
209  mutable RBox boundingBox;
210  mutable double dimLineLength;
211 
213  mutable bool autoTextPos;
214 };
215 
218 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
219 
220 #endif