QCAD
Open Source 2D CAD
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 RS::EntityType getType() const {
57  return RS::EntityDimension;
58  }
59  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
60 
61  virtual bool isValid() const;
62  virtual bool isSane() const;
63 
64  virtual void setDefinitionPoint(const RVector& p) {
65  definitionPoint = p;
66  update();
67  }
68 
70  return definitionPoint;
71  }
72 
73  void setText(const QString& t) {
74  text = t;
75  update();
76  }
77 
78  QString getText() const {
79  return text;
80  }
81 
82  void setUpperTolerance(const QString& t) {
83  upperTolerance = t;
84  }
85 
86  void setLowerTolerance(const QString& t) {
87  lowerTolerance = t;
88  }
89 
90  void setTextPosition(const RVector& p) {
91  if (p.isSane()) {
92  textPositionCenter = p;
93  }
94  textPositionSide = RVector::invalid;
95  update();
96  }
97 
99  if (textPositionSide.isValid()) {
100  return textPositionSide;
101  }
102  else {
103  return textPositionCenter;
104  }
105  }
106 
107  void setFontName(const QString& fn) {
108  fontName = fn;
109  update();
110  }
111 
112  QString getFontName() const {
113  return fontName;
114  }
115 
116  void setDimBlockName(const QString& bn) {
117  dimBlockName = bn;
118  //update();
119  }
120 
121  QString getDimBlockName() const {
122  return dimBlockName;
123  }
124 
125  double getLinearFactor() const {
126  return linearFactor;
127  }
128 
129  void setLinearFactor(double f) {
130  linearFactor = f;
131  }
132 
133  double getDimScale(bool fromDocument=true) const;
134 
135  void setDimScale(double f) {
136  dimScaleOverride = f;
137  update();
138  }
139 
140  bool isArrow1Flipped() const {
141  return arrow1Flipped;
142  }
143  void setArrow1Flipped(bool on) {
144  arrow1Flipped = on;
145  }
146  bool isArrow2Flipped() const {
147  return arrow2Flipped;
148  }
149  void setArrow2Flipped(bool on) {
150  arrow2Flipped = on;
151  }
152 
153  bool isExtLineFix() const {
154  return extLineFix;
155  }
156  void setExtLineFix(bool on) {
157  extLineFix = on;
158  }
159 
160  double getExtLineFixLength() const {
161  return extLineFixLength;
162  }
163  void setExtLineFixLength(double v) {
164  extLineFixLength = v;
165  }
166 
167  void adjustExtensionLineFixLength(RLine& extLine1, RLine& extLine2, bool addDimExe = true) const;
168 
169  bool hasSpaceForArrows() const;
170 
171  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
172  virtual bool intersectsWith(const RShape& shape) const;
173 
174  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
175 
176  virtual bool clickReferencePoint(const RVector& referencePoint);
177  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
178 
179  virtual bool move(const RVector& offset);
180  virtual bool rotate(double rotation, const RVector& center);
181  virtual bool scale(const RVector& scaleFactors, const RVector& center);
182  virtual void scaleVisualProperties(double scaleFactor);
183  virtual bool mirror(const RLine& axis);
184 
185  double getDimexo() const;
186  double getDimexe() const;
187  double getDimasz() const;
188  double getDimgap() const;
189  double getDimtxt() const;
190  bool useArchTick() const;
191  bool hasCustomTextPosition() const;
192  void setCustomTextPosition(bool on);
193 
195  return lineSpacingStyle;
196  }
197 
198  double getLineSpacingFactor() const {
199  return lineSpacingFactor;
200  }
201 
202  double getTextAngle() const {
203  return textAngle;
204  }
205 
206  QList<QSharedPointer<RShape> > getDimensionLineShapes(
207  const RVector& p1, const RVector& p2,
208  bool arrow1, bool arrow2) const;
209  virtual QList<QSharedPointer<RShape> > getArrow(
210  const RVector& position, double direction) const;
211  RTextData& getTextData() const;
212  void initTextData() const;
213  virtual void updateTextData() const;
214  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
215  virtual double getMeasuredValue() const { return 0.0; }
216  virtual QString getAutoLabel() const { return ""; }
217  QString formatLabel(double distance) const;
218  QString formatAngleLabel(double textAngle) const;
219  //virtual void updateFromTextPosition() = 0;
220 
221  virtual void update() const;
222 
223  QSharedPointer<RBlockReferenceEntity> getDimensionBlockReference() const;
224  bool hasDimensionBlockReference() const;
225 
226 protected:
249  QString text;
251  QString upperTolerance;
253  QString lowerTolerance;
255  QString fontName;
257  mutable QString dimBlockName;
258 
259  mutable double defaultAngle;
261  double textAngle;
262 
263  double linearFactor;
267 
270 
271  mutable bool dirty;
273  mutable RBox boundingBox;
274  mutable double dimLineLength;
277 
279  mutable bool autoTextPos;
280 };
281 
284 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
285 
286 #endif
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:65
RVector getTextPosition() const
Definition: RDimensionData.h:98
bool dirty
Definition: RDimensionData.h:271
virtual RS::EntityType getType() const
Definition: RDimensionData.h:56
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
Base class for dimension entity classes.
Definition: RDimensionEntity.h:38
virtual bool mirror(const RLine &axis)
Definition: REntityData.cpp:582
QString upperTolerance
Upper tolerance limit.
Definition: RDimensionData.h:251
TextLineSpacingStyle
Line spacing style for texts.
Definition: RS.h:244
virtual bool isSane() const
Definition: REntityData.h:100
virtual QString getAutoLabel() const
Definition: RDimensionData.h:216
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:125
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
RVector textPositionSide
Middle point of dimension text when automatically moved to the side for lack of space.
Definition: RDimensionData.h:235
void setUpperTolerance(const QString &t)
Definition: RDimensionData.h:82
VAlign
Vertical alignments.
Definition: RS.h:213
bool extLineFix
Definition: RDimensionData.h:268
QString lowerTolerance
Lower tolerance limit.
Definition: RDimensionData.h:253
RVector getDefinitionPoint() const
Definition: RDimensionData.h:69
virtual void setDefinitionPoint(const RVector &p)
Definition: RDimensionData.h:64
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:542
bool autoTextPos
True if the textPosition should be automatically calculated.
Definition: RDimensionData.h:279
bool isSane() const
Definition: RVector.cpp:67
double defaultAngle
Definition: RDimensionData.h:259
double getLinearFactor() const
Definition: RDimensionData.h:125
void setArrow2Flipped(bool on)
Definition: RDimensionData.h:149
Any Dimension.
Definition: RS.h:157
QString text
Text string entered explicitly by user or null or "<>" for the actual measurement or " " (one blank s...
Definition: RDimensionData.h:249
QString getDimBlockName() const
Definition: RDimensionData.h:121
double dimScaleOverride
Definition: RDimensionData.h:264
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:284
double getDimScale(bool fromDocument=true) const
Definition: RDimensionEntity.h:175
void setTextPosition(const RVector &p)
Definition: RDimensionData.h:90
RS::VAlign valign
Vertical alignment.
Definition: RDimensionData.h:237
void setDimBlockName(const QString &bn)
Definition: RDimensionData.h:116
RVector textPositionCenter
Middle point of dimension text.
Definition: RDimensionData.h:230
RBox boundingBox
Definition: RDimensionData.h:273
QString getMeasurement(bool resolveAutoMeasurement=true) const
Definition: RDimensionEntity.h:123
QString fontName
Dimension font name.
Definition: RDimensionData.h:255
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RTextData.h:37
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:470
void setText(const QString &t)
Definition: RDimensionData.h:73
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:183
RS::HAlign halign
Horizontal alignment.
Definition: RDimensionData.h:239
RVector arrow2Pos
Definition: RDimensionData.h:276
virtual double getMeasuredValue() const
Definition: RDimensionData.h:215
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:562
double textAngle
Rotation angle of dimension text away from default orientation.
Definition: RDimensionData.h:261
double extLineFixLength
Definition: RDimensionData.h:269
QString dimBlockName
Dimension appearance is defined in this block.
Definition: RDimensionData.h:257
QString getFontName() const
Definition: RDimensionData.h:112
void setLinearFactor(double f)
Definition: RDimensionData.h:129
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:298
RVector arrow1Pos
Definition: RDimensionData.h:275
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint)=0
Moves the given reference point to the given target point or does nothing if this entity has no refer...
Q_DECLARE_METATYPE(RMath *)
double getExtLineFixLength() const
Definition: RDimensionData.h:160
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RDimensionData.h:38
bool hasCustomTextPosition() const
Definition: RDimensionEntity.h:147
QString getText() const
Definition: RDimensionData.h:78
void setLowerTolerance(const QString &t)
Definition: RDimensionData.h:86
void setFontName(const QString &fn)
Definition: RDimensionData.h:107
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:552
void setArrow1Flipped(bool on)
Definition: RDimensionData.h:143
double lineSpacingFactor
Line spacing factor.
Definition: RDimensionData.h:243
double getLineSpacingFactor() const
Definition: RDimensionData.h:198
#define RMAXDOUBLE
Definition: RMath.h:63
RVector definitionPoint
Definition point.
Definition: RDimensionData.h:228
bool arrow2Flipped
Definition: RDimensionData.h:266
RS::TextLineSpacingStyle lineSpacingStyle
Line spacing style.
Definition: RDimensionData.h:241
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
Low-level mathematical representation of a line.
Definition: RLine.h:41
Definition: RS.h:184
RS::TextLineSpacingStyle getLineSpacingStyle() const
Definition: RDimensionData.h:194
double dimLineLength
Definition: RDimensionData.h:274
void setDimScale(double f)
Definition: RDimensionData.h:135
bool isArrow2Flipped() const
Definition: RDimensionData.h:146
virtual bool clickReferencePoint(const RVector &referencePoint)
Called when user clicks a reference point.
Definition: REntityData.h:359
bool arrow1Flipped
Definition: RDimensionData.h:265
HAlign
Horizontal alignments.
Definition: RS.h:223
void setExtLineFixLength(double v)
Definition: RDimensionData.h:163
Interface for geometrical shape classes.
Definition: RShape.h:52
void setExtLineFix(bool on)
Definition: RDimensionData.h:156
virtual bool isValid() const
Definition: REntityData.h:97
RTextData textData
Definition: RDimensionData.h:272
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:390
static const RVector invalid
invalid vector
Definition: RVector.h:322
bool hasDimensionBlockReference() const
Definition: RDimensionEntity.h:187
virtual void scaleVisualProperties(double scaleFactor)
Definition: REntityData.cpp:576
void setCustomTextPosition(bool on)
Definition: RDimensionEntity.h:151
bool isArrow1Flipped() const
Definition: RDimensionData.h:140
double getTextAngle() const
Definition: RDimensionData.h:202
RTextData getTextData() const
Definition: RDimensionEntity.h:127
double linearFactor
Definition: RDimensionData.h:263
bool isExtLineFix() const
Definition: RDimensionData.h:153
RDocument * document
Definition: RObject.h:306