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  double getLinearFactor() const {
111  return linearFactor;
112  }
113 
114  void setLinearFactor(double f) {
115  linearFactor = f;
116  }
117 
118  double getDimScale() const;
119 
120  void setDimScale(double f) {
121  dimScale = f;
122  }
123 
124  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
125  virtual bool intersectsWith(const RShape& shape) const;
126 
127  virtual QList<RVector> getReferencePoints(
129 
130  virtual bool moveReferencePoint(const RVector& referencePoint,
131  const RVector& targetPoint);
132 
133  virtual bool move(const RVector& offset);
134  virtual bool rotate(double rotation, const RVector& center);
135  virtual bool scale(const RVector& scaleFactors, const RVector& center);
136  virtual bool mirror(const RLine& axis);
137 
138  //double getDimscale() const;
139  double getDimexo() const;
140  double getDimexe() const;
141  double getDimasz() const;
142  double getDimgap() const;
143  double getDimtxt() const;
144  bool useArchTick() const;
145  bool hasCustomTextPosition() const;
146  void setCustomTextPosition(bool on);
147 
149  return lineSpacingStyle;
150  }
151 
152  double getLineSpacingFactor() const {
153  return lineSpacingFactor;
154  }
155 
156  double getTextAngle() const {
157  return textAngle;
158  }
159 
160  QList<QSharedPointer<RShape> > getDimensionLineShapes(
161  const RVector& p1, const RVector& p2,
162  bool arrow1, bool arrow2) const;
163  virtual QList<QSharedPointer<RShape> > getArrow(
164  const RVector& position, double direction) const;
165  RTextData& getTextData() const;
166  void initTextData() const;
167  virtual void updateTextData() const;
168  virtual QString getMeasurement(bool resolveAutoMeasurement = true) const;
169  virtual double getMeasuredValue() const { return 0.0; }
170  virtual QString getAutoLabel() const { return ""; }
171  QString formatLabel(double distance) const;
172  QString formatAngleLabel(double textAngle) const;
173  //virtual void updateFromTextPosition() = 0;
174 
175  virtual void update() const;
176 
177 protected:
200  QString text;
202  QString upperTolerance;
204  QString lowerTolerance;
206  QString fontName;
207 
208  mutable double defaultAngle;
210  double textAngle;
211 
212  double linearFactor;
213  double dimScale;
214 
215  mutable bool dirty;
217  mutable RBox boundingBox;
218  mutable double dimLineLength;
219 
221  mutable bool autoTextPos;
222 };
223 
226 Q_DECLARE_METATYPE(QSharedPointer<RDimensionData>)
227 
228 #endif
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:64
RVector getTextPosition() const
Definition: RDimensionData.h:92
bool dirty
Definition: RDimensionData.h:215
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:477
QString upperTolerance
Upper tolerance limit.
Definition: RDimensionData.h:202
TextLineSpacingStyle
Line spacing style for texts.
Definition: RS.h:176
virtual QString getAutoLabel() const
Definition: RDimensionData.h:170
#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:186
void setUpperTolerance(const QString &t)
Definition: RDimensionData.h:78
VAlign
Vertical alignments.
Definition: RS.h:145
QString lowerTolerance
Lower tolerance limit.
Definition: RDimensionData.h:204
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:443
bool autoTextPos
True if the textPosition should be automatically calculated.
Definition: RDimensionData.h:221
double defaultAngle
Definition: RDimensionData.h:208
double getLinearFactor() const
Definition: RDimensionData.h:110
QString text
Text string entered explicitly by user or null or "<>" for the actual measurement or " " (one blank s...
Definition: RDimensionData.h:200
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:216
void setTextPosition(const RVector &p)
Definition: RDimensionData.h:86
RS::VAlign valign
Vertical alignment.
Definition: RDimensionData.h:188
RVector textPositionCenter
Middle point of dimension text.
Definition: RDimensionData.h:181
RBox boundingBox
Definition: RDimensionData.h:217
QString getMeasurement(bool resolveAutoMeasurement=true) const
Definition: RDimensionEntity.h:124
QString fontName
Dimension font name.
Definition: RDimensionData.h:206
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RTextData.h:37
virtual bool isValid() const
Definition: RDimensionEntity.h:104
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:390
void setText(const QString &t)
Definition: RDimensionData.h:69
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:118
RS::HAlign halign
Horizontal alignment.
Definition: RDimensionData.h:190
virtual double getMeasuredValue() const
Definition: RDimensionData.h:169
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:463
double textAngle
Rotation angle of dimension text away from default orientation.
Definition: RDimensionData.h:210
QString getFontName() const
Definition: RDimensionData.h:106
void setLinearFactor(double f)
Definition: RDimensionData.h:114
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:230
virtual QList< RVector > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:63
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-2015 by Andrew Mustun.
Definition: RDimensionData.h:38
bool hasCustomTextPosition() const
Definition: RDimensionEntity.h:148
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:453
double dimScale
Definition: RDimensionData.h:213
double lineSpacingFactor
Line spacing factor.
Definition: RDimensionData.h:194
double getLineSpacingFactor() const
Definition: RDimensionData.h:152
#define RMAXDOUBLE
Definition: RMath.h:50
RVector definitionPoint
Definition point.
Definition: RDimensionData.h:179
RS::TextLineSpacingStyle lineSpacingStyle
Line spacing style.
Definition: RDimensionData.h:192
Low-level mathematical representation of a line.
Definition: RLine.h:42
Definition: RS.h:119
RS::TextLineSpacingStyle getLineSpacingStyle() const
Definition: RDimensionData.h:148
double getDimScale() const
Definition: RDimensionEntity.h:176
double dimLineLength
Definition: RDimensionData.h:218
void setDimScale(double f)
Definition: RDimensionData.h:120
HAlign
Horizontal alignments.
Definition: RS.h:155
Interface for geometrical shape classes.
Definition: RShape.h:52
RTextData textData
Definition: RDimensionData.h:216
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:320
static const RVector invalid
invalid vector
Definition: RVector.h:279
void setCustomTextPosition(bool on)
Definition: RDimensionEntity.h:152
double getTextAngle() const
Definition: RDimensionData.h:156
RTextData getTextData() const
Definition: RDimensionEntity.h:128
double linearFactor
Definition: RDimensionData.h:212
RDocument * document
Definition: RObject.h:251