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() const;
134 
135  void setDimScale(double f) {
136  dimScale = 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 getDimscale() const;
154  double getDimexo() const;
155  double getDimexe() const;
156  double getDimasz() const;
157  double getDimgap() const;
158  double getDimtxt() const;
159  bool useArchTick() const;
160  bool hasCustomTextPosition() const;
161  void setCustomTextPosition(bool on);
162 
164  return lineSpacingStyle;
165  }
166 
167  double getLineSpacingFactor() const {
168  return lineSpacingFactor;
169  }
170 
171  double getTextAngle() const {
172  return textAngle;
173  }
174 
175  QList<QSharedPointer<RShape> > getDimensionLineShapes(
176  const RVector& p1, const RVector& p2,
177  bool arrow1, bool arrow2) const;
178  virtual QList<QSharedPointer<RShape> > getArrow(
179  const RVector& position, double direction) const;
180  RTextData& getTextData() const;
181  void initTextData() const;
182  virtual void updateTextData() const;
183  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
184  virtual double getMeasuredValue() const { return 0.0; }
185  virtual QString getAutoLabel() const { return ""; }
186  QString formatLabel(double distance) const;
187  QString formatAngleLabel(double textAngle) const;
188  //virtual void updateFromTextPosition() = 0;
189 
190  virtual void update() const;
191 
192  QSharedPointer<RBlockReferenceEntity> getDimensionBlockReference() const;
193  bool hasDimensionBlockReference() const;
194 
195 protected:
218  QString text;
220  QString upperTolerance;
222  QString lowerTolerance;
224  QString fontName;
226  mutable QString dimBlockName;
227 
228  mutable double defaultAngle;
230  double textAngle;
231 
232  double linearFactor;
233  double dimScale;
234 
235  mutable bool dirty;
237  mutable RBox boundingBox;
238  mutable double dimLineLength;
239 
241  mutable bool autoTextPos;
242 };
243 
246 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
247 
248 #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:235
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:220
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:185
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:204
void setUpperTolerance(const QString &t)
Definition: RDimensionData.h:82
VAlign
Vertical alignments.
Definition: RS.h:161
QString lowerTolerance
Lower tolerance limit.
Definition: RDimensionData.h:222
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:241
bool isSane() const
Definition: RVector.cpp:67
double defaultAngle
Definition: RDimensionData.h:228
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:218
QString getDimBlockName() const
Definition: RDimensionData.h:121
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:261
void setTextPosition(const RVector &p)
Definition: RDimensionData.h:90
RS::VAlign valign
Vertical alignment.
Definition: RDimensionData.h:206
void setDimBlockName(const QString &bn)
Definition: RDimensionData.h:116
RVector textPositionCenter
Middle point of dimension text.
Definition: RDimensionData.h:199
RBox boundingBox
Definition: RDimensionData.h:237
QString getMeasurement(bool resolveAutoMeasurement=true) const
Definition: RDimensionEntity.h:118
QString fontName
Dimension font name.
Definition: RDimensionData.h:224
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:208
virtual double getMeasuredValue() const
Definition: RDimensionData.h:184
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:230
QString dimBlockName
Dimension appearance is defined in this block.
Definition: RDimensionData.h:226
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 dimScale
Definition: RDimensionData.h:233
double lineSpacingFactor
Line spacing factor.
Definition: RDimensionData.h:212
double getLineSpacingFactor() const
Definition: RDimensionData.h:167
#define RMAXDOUBLE
Definition: RMath.h:63
RVector definitionPoint
Definition point.
Definition: RDimensionData.h:197
RS::TextLineSpacingStyle lineSpacingStyle
Line spacing style.
Definition: RDimensionData.h:210
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:163
double getDimScale() const
Definition: RDimensionEntity.h:170
double dimLineLength
Definition: RDimensionData.h:238
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:236
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:171
RTextData getTextData() const
Definition: RDimensionEntity.h:122
double linearFactor
Definition: RDimensionData.h:232
RDocument * document
Definition: RObject.h:271