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 RBox getBoundingBox(bool ignoreEmpty=false) const;
57 
58  virtual bool isValid() const;
59 
60  virtual 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  void setDimBlockName(const QString& bn) {
111  dimBlockName = bn;
112  //update();
113  }
114 
115  QString getDimBlockName() const {
116  return dimBlockName;
117  }
118 
119  double getLinearFactor() const {
120  return linearFactor;
121  }
122 
123  void setLinearFactor(double f) {
124  linearFactor = f;
125  }
126 
127  double getDimScale() const;
128 
129  void setDimScale(double f) {
130  dimScale = f;
131  update();
132  }
133 
134  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
135  virtual bool intersectsWith(const RShape& shape) const;
136 
137  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
138 
139  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
140 
141  virtual bool move(const RVector& offset);
142  virtual bool rotate(double rotation, const RVector& center);
143  virtual bool scale(const RVector& scaleFactors, const RVector& center);
144  virtual void scaleVisualProperties(double scaleFactor);
145  virtual bool mirror(const RLine& axis);
146 
147  //double getDimscale() const;
148  double getDimexo() const;
149  double getDimexe() const;
150  double getDimasz() const;
151  double getDimgap() const;
152  double getDimtxt() const;
153  bool useArchTick() const;
154  bool hasCustomTextPosition() const;
155  void setCustomTextPosition(bool on);
156 
158  return lineSpacingStyle;
159  }
160 
161  double getLineSpacingFactor() const {
162  return lineSpacingFactor;
163  }
164 
165  double getTextAngle() const {
166  return textAngle;
167  }
168 
169  QList<QSharedPointer<RShape> > getDimensionLineShapes(
170  const RVector& p1, const RVector& p2,
171  bool arrow1, bool arrow2) const;
172  virtual QList<QSharedPointer<RShape> > getArrow(
173  const RVector& position, double direction) const;
174  RTextData& getTextData() const;
175  void initTextData() const;
176  virtual void updateTextData() const;
177  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
178  virtual double getMeasuredValue() const { return 0.0; }
179  virtual QString getAutoLabel() const { return ""; }
180  QString formatLabel(double distance) const;
181  QString formatAngleLabel(double textAngle) const;
182  //virtual void updateFromTextPosition() = 0;
183 
184  virtual void update() const;
185 
186  QSharedPointer<RBlockReferenceEntity> getDimensionBlockReference() const;
187  bool hasDimensionBlockReference() const;
188 
189 protected:
212  QString text;
214  QString upperTolerance;
216  QString lowerTolerance;
218  QString fontName;
220  mutable QString dimBlockName;
221 
222  mutable double defaultAngle;
224  double textAngle;
225 
226  double linearFactor;
227  double dimScale;
228 
229  mutable bool dirty;
231  mutable RBox boundingBox;
232  mutable double dimLineLength;
233 
235  mutable bool autoTextPos;
236 };
237 
240 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
241 
242 #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:92
bool dirty
Definition: RDimensionData.h:229
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:534
QString upperTolerance
Upper tolerance limit.
Definition: RDimensionData.h:214
TextLineSpacingStyle
Line spacing style for texts.
Definition: RS.h:192
virtual QString getAutoLabel() const
Definition: RDimensionData.h:179
#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:198
void setUpperTolerance(const QString &t)
Definition: RDimensionData.h:78
VAlign
Vertical alignments.
Definition: RS.h:161
QString lowerTolerance
Lower tolerance limit.
Definition: RDimensionData.h:216
RVector getDefinitionPoint() const
Definition: RDimensionData.h:65
virtual void setDefinitionPoint(const RVector &p)
Definition: RDimensionData.h:60
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:494
bool autoTextPos
True if the textPosition should be automatically calculated.
Definition: RDimensionData.h:235
double defaultAngle
Definition: RDimensionData.h:222
double getLinearFactor() const
Definition: RDimensionData.h:119
QString text
Text string entered explicitly by user or null or "<>" for the actual measurement or " " (one blank s...
Definition: RDimensionData.h:212
QString getDimBlockName() const
Definition: RDimensionData.h:115
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:248
void setTextPosition(const RVector &p)
Definition: RDimensionData.h:86
RS::VAlign valign
Vertical alignment.
Definition: RDimensionData.h:200
void setDimBlockName(const QString &bn)
Definition: RDimensionData.h:110
RVector textPositionCenter
Middle point of dimension text.
Definition: RDimensionData.h:193
RBox boundingBox
Definition: RDimensionData.h:231
QString getMeasurement(bool resolveAutoMeasurement=true) const
Definition: RDimensionEntity.h:126
QString fontName
Dimension font name.
Definition: RDimensionData.h:218
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RTextData.h:37
virtual bool isValid() const
Definition: RDimensionEntity.h:106
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:426
void setText(const QString &t)
Definition: RDimensionData.h:69
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:131
RS::HAlign halign
Horizontal alignment.
Definition: RDimensionData.h:202
virtual double getMeasuredValue() const
Definition: RDimensionData.h:178
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:514
double textAngle
Rotation angle of dimension text away from default orientation.
Definition: RDimensionData.h:224
QString dimBlockName
Dimension appearance is defined in this block.
Definition: RDimensionData.h:220
QString getFontName() const
Definition: RDimensionData.h:106
void setLinearFactor(double f)
Definition: RDimensionData.h:123
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:262
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-2016 by Andrew Mustun.
Definition: RDimensionData.h:38
bool hasCustomTextPosition() const
Definition: RDimensionEntity.h:150
QString getText() const
Definition: RDimensionData.h:74
void setLowerTolerance(const QString &t)
Definition: RDimensionData.h:82
void setFontName(const QString &fn)
Definition: RDimensionData.h:101
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:504
double dimScale
Definition: RDimensionData.h:227
double lineSpacingFactor
Line spacing factor.
Definition: RDimensionData.h:206
double getLineSpacingFactor() const
Definition: RDimensionData.h:161
#define RMAXDOUBLE
Definition: RMath.h:63
RVector definitionPoint
Definition point.
Definition: RDimensionData.h:191
RS::TextLineSpacingStyle lineSpacingStyle
Line spacing style.
Definition: RDimensionData.h:204
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:157
double getDimScale() const
Definition: RDimensionEntity.h:178
double dimLineLength
Definition: RDimensionData.h:232
void setDimScale(double f)
Definition: RDimensionData.h:129
HAlign
Horizontal alignments.
Definition: RS.h:171
Interface for geometrical shape classes.
Definition: RShape.h:52
RTextData textData
Definition: RDimensionData.h:230
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:360
static const RVector invalid
invalid vector
Definition: RVector.h:313
bool hasDimensionBlockReference() const
Definition: RDimensionEntity.h:190
virtual void scaleVisualProperties(double scaleFactor)
Definition: REntityData.cpp:528
void setCustomTextPosition(bool on)
Definition: RDimensionEntity.h:154
double getTextAngle() const
Definition: RDimensionData.h:165
RTextData getTextData() const
Definition: RDimensionEntity.h:130
double linearFactor
Definition: RDimensionData.h:226
RDocument * document
Definition: RObject.h:271