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 hasSpaceForArrows() const;
154 
155  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
156  virtual bool intersectsWith(const RShape& shape) const;
157 
158  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
159 
160  virtual bool clickReferencePoint(const RVector& referencePoint);
161  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
162 
163  virtual bool move(const RVector& offset);
164  virtual bool rotate(double rotation, const RVector& center);
165  virtual bool scale(const RVector& scaleFactors, const RVector& center);
166  virtual void scaleVisualProperties(double scaleFactor);
167  virtual bool mirror(const RLine& axis);
168 
169  double getDimexo() const;
170  double getDimexe() const;
171  double getDimasz() const;
172  double getDimgap() const;
173  double getDimtxt() const;
174  bool useArchTick() const;
175  bool hasCustomTextPosition() const;
176  void setCustomTextPosition(bool on);
177 
179  return lineSpacingStyle;
180  }
181 
182  double getLineSpacingFactor() const {
183  return lineSpacingFactor;
184  }
185 
186  double getTextAngle() const {
187  return textAngle;
188  }
189 
190  QList<QSharedPointer<RShape> > getDimensionLineShapes(
191  const RVector& p1, const RVector& p2,
192  bool arrow1, bool arrow2) const;
193  virtual QList<QSharedPointer<RShape> > getArrow(
194  const RVector& position, double direction) const;
195  RTextData& getTextData() const;
196  void initTextData() const;
197  virtual void updateTextData() const;
198  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
199  virtual double getMeasuredValue() const { return 0.0; }
200  virtual QString getAutoLabel() const { return ""; }
201  QString formatLabel(double distance) const;
202  QString formatAngleLabel(double textAngle) const;
203  //virtual void updateFromTextPosition() = 0;
204 
205  virtual void update() const;
206 
207  QSharedPointer<RBlockReferenceEntity> getDimensionBlockReference() const;
208  bool hasDimensionBlockReference() const;
209 
210 protected:
233  QString text;
235  QString upperTolerance;
237  QString lowerTolerance;
239  QString fontName;
241  mutable QString dimBlockName;
242 
243  mutable double defaultAngle;
245  double textAngle;
246 
247  double linearFactor;
251 
252  mutable bool dirty;
254  mutable RBox boundingBox;
255  mutable double dimLineLength;
258 
260  mutable bool autoTextPos;
261 };
262 
265 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
266 
267 #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:252
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:580
QString upperTolerance
Upper tolerance limit.
Definition: RDimensionData.h:235
TextLineSpacingStyle
Line spacing style for texts.
Definition: RS.h:195
virtual bool isSane() const
Definition: REntityData.h:100
virtual QString getAutoLabel() const
Definition: RDimensionData.h:200
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:219
void setUpperTolerance(const QString &t)
Definition: RDimensionData.h:82
VAlign
Vertical alignments.
Definition: RS.h:164
QString lowerTolerance
Lower tolerance limit.
Definition: RDimensionData.h:237
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:540
bool autoTextPos
True if the textPosition should be automatically calculated.
Definition: RDimensionData.h:260
bool isSane() const
Definition: RVector.cpp:67
double defaultAngle
Definition: RDimensionData.h:243
double getLinearFactor() const
Definition: RDimensionData.h:125
void setArrow2Flipped(bool on)
Definition: RDimensionData.h:149
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:233
QString getDimBlockName() const
Definition: RDimensionData.h:121
double dimScaleOverride
Definition: RDimensionData.h:248
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:172
void setTextPosition(const RVector &p)
Definition: RDimensionData.h:90
RS::VAlign valign
Vertical alignment.
Definition: RDimensionData.h:221
void setDimBlockName(const QString &bn)
Definition: RDimensionData.h:116
RVector textPositionCenter
Middle point of dimension text.
Definition: RDimensionData.h:214
RBox boundingBox
Definition: RDimensionData.h:254
QString getMeasurement(bool resolveAutoMeasurement=true) const
Definition: RDimensionEntity.h:120
QString fontName
Dimension font name.
Definition: RDimensionData.h:239
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:134
RS::HAlign halign
Horizontal alignment.
Definition: RDimensionData.h:223
RVector arrow2Pos
Definition: RDimensionData.h:257
virtual double getMeasuredValue() const
Definition: RDimensionData.h:199
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:560
double textAngle
Rotation angle of dimension text away from default orientation.
Definition: RDimensionData.h:245
QString dimBlockName
Dimension appearance is defined in this block.
Definition: RDimensionData.h:241
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:256
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-2018 by Andrew Mustun.
Definition: RDimensionData.h:38
bool hasCustomTextPosition() const
Definition: RDimensionEntity.h:144
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:550
void setArrow1Flipped(bool on)
Definition: RDimensionData.h:143
double lineSpacingFactor
Line spacing factor.
Definition: RDimensionData.h:227
double getLineSpacingFactor() const
Definition: RDimensionData.h:182
#define RMAXDOUBLE
Definition: RMath.h:63
RVector definitionPoint
Definition point.
Definition: RDimensionData.h:212
bool arrow2Flipped
Definition: RDimensionData.h:250
RS::TextLineSpacingStyle lineSpacingStyle
Line spacing style.
Definition: RDimensionData.h:225
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:135
RS::TextLineSpacingStyle getLineSpacingStyle() const
Definition: RDimensionData.h:178
double dimLineLength
Definition: RDimensionData.h:255
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:249
HAlign
Horizontal alignments.
Definition: RS.h:174
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual bool isValid() const
Definition: REntityData.h:97
RTextData textData
Definition: RDimensionData.h:253
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:184
virtual void scaleVisualProperties(double scaleFactor)
Definition: REntityData.cpp:574
void setCustomTextPosition(bool on)
Definition: RDimensionEntity.h:148
bool isArrow1Flipped() const
Definition: RDimensionData.h:140
double getTextAngle() const
Definition: RDimensionData.h:186
RTextData getTextData() const
Definition: RDimensionEntity.h:124
double linearFactor
Definition: RDimensionData.h:247
RDocument * document
Definition: RObject.h:308