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  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
141  virtual bool intersectsWith(const RShape& shape) const;
142 
143  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
144 
145  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
146 
147  virtual bool move(const RVector& offset);
148  virtual bool rotate(double rotation, const RVector& center);
149  virtual bool scale(const RVector& scaleFactors, const RVector& center);
150  virtual void scaleVisualProperties(double scaleFactor);
151  virtual bool mirror(const RLine& axis);
152 
153  double getDimexo() const;
154  double getDimexe() const;
155  double getDimasz() const;
156  double getDimgap() const;
157  double getDimtxt() const;
158  bool useArchTick() const;
159  bool hasCustomTextPosition() const;
160  void setCustomTextPosition(bool on);
161 
163  return lineSpacingStyle;
164  }
165 
166  double getLineSpacingFactor() const {
167  return lineSpacingFactor;
168  }
169 
170  double getTextAngle() const {
171  return textAngle;
172  }
173 
174  QList<QSharedPointer<RShape> > getDimensionLineShapes(
175  const RVector& p1, const RVector& p2,
176  bool arrow1, bool arrow2) const;
177  virtual QList<QSharedPointer<RShape> > getArrow(
178  const RVector& position, double direction) const;
179  RTextData& getTextData() const;
180  void initTextData() const;
181  virtual void updateTextData() const;
182  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
183  virtual double getMeasuredValue() const { return 0.0; }
184  virtual QString getAutoLabel() const { return ""; }
185  QString formatLabel(double distance) const;
186  QString formatAngleLabel(double textAngle) const;
187  //virtual void updateFromTextPosition() = 0;
188 
189  virtual void update() const;
190 
191  QSharedPointer<RBlockReferenceEntity> getDimensionBlockReference() const;
192  bool hasDimensionBlockReference() const;
193 
194 protected:
217  QString text;
219  QString upperTolerance;
221  QString lowerTolerance;
223  QString fontName;
225  mutable QString dimBlockName;
226 
227  mutable double defaultAngle;
229  double textAngle;
230 
231  double linearFactor;
233 
234  mutable bool dirty;
236  mutable RBox boundingBox;
237  mutable double dimLineLength;
238 
240  mutable bool autoTextPos;
241 };
242 
245 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
246 
247 #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:234
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:547
QString upperTolerance
Upper tolerance limit.
Definition: RDimensionData.h:219
TextLineSpacingStyle
Line spacing style for texts.
Definition: RS.h:192
virtual bool isSane() const
Definition: REntityData.h:93
virtual QString getAutoLabel() const
Definition: RDimensionData.h:184
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
#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:203
void setUpperTolerance(const QString &t)
Definition: RDimensionData.h:82
VAlign
Vertical alignments.
Definition: RS.h:161
QString lowerTolerance
Lower tolerance limit.
Definition: RDimensionData.h:221
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:507
bool autoTextPos
True if the textPosition should be automatically calculated.
Definition: RDimensionData.h:240
bool isSane() const
Definition: RVector.cpp:67
double defaultAngle
Definition: RDimensionData.h:227
double getLinearFactor() const
Definition: RDimensionData.h:125
Any Dimension.
Definition: RS.h:108
QString text
Text string entered explicitly by user or null or "<>" for the actual measurement or " " (one blank s...
Definition: RDimensionData.h:217
QString getDimBlockName() const
Definition: RDimensionData.h:121
double dimScaleOverride
Definition: RDimensionData.h:232
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:261
double getDimScale(bool fromDocument=true) const
Definition: RDimensionEntity.h:170
void setTextPosition(const RVector &p)
Definition: RDimensionData.h:90
RS::VAlign valign
Vertical alignment.
Definition: RDimensionData.h:205
void setDimBlockName(const QString &bn)
Definition: RDimensionData.h:116
RVector textPositionCenter
Middle point of dimension text.
Definition: RDimensionData.h:198
RBox boundingBox
Definition: RDimensionData.h:236
QString getMeasurement(bool resolveAutoMeasurement=true) const
Definition: RDimensionEntity.h:118
QString fontName
Dimension font name.
Definition: RDimensionData.h:223
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RTextData.h:37
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:439
void setText(const QString &t)
Definition: RDimensionData.h:73
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:131
RS::HAlign halign
Horizontal alignment.
Definition: RDimensionData.h:207
virtual double getMeasuredValue() const
Definition: RDimensionData.h:183
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:527
double textAngle
Rotation angle of dimension text away from default orientation.
Definition: RDimensionData.h:229
QString dimBlockName
Dimension appearance is defined in this block.
Definition: RDimensionData.h:225
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: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 *)
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RDimensionData.h:38
bool hasCustomTextPosition() const
Definition: RDimensionEntity.h:142
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:517
double lineSpacingFactor
Line spacing factor.
Definition: RDimensionData.h:211
double getLineSpacingFactor() const
Definition: RDimensionData.h:166
#define RMAXDOUBLE
Definition: RMath.h:63
RVector definitionPoint
Definition point.
Definition: RDimensionData.h:196
RS::TextLineSpacingStyle lineSpacingStyle
Line spacing style.
Definition: RDimensionData.h:209
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:132
RS::TextLineSpacingStyle getLineSpacingStyle() const
Definition: RDimensionData.h:162
double dimLineLength
Definition: RDimensionData.h:237
void setDimScale(double f)
Definition: RDimensionData.h:135
HAlign
Horizontal alignments.
Definition: RS.h:171
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual bool isValid() const
Definition: REntityData.h:90
RTextData textData
Definition: RDimensionData.h:235
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:371
static const RVector invalid
invalid vector
Definition: RVector.h:317
bool hasDimensionBlockReference() const
Definition: RDimensionEntity.h:182
virtual void scaleVisualProperties(double scaleFactor)
Definition: REntityData.cpp:541
void setCustomTextPosition(bool on)
Definition: RDimensionEntity.h:146
double getTextAngle() const
Definition: RDimensionData.h:170
RTextData getTextData() const
Definition: RDimensionEntity.h:122
double linearFactor
Definition: RDimensionData.h:231
RDocument * document
Definition: RObject.h:271