4 #include "rs_entitycontainer.h"
7 * Holds the data that is common to all dimension entities.
9 class RS_DimensionData: public RS_Flags
13 * Default constructor. Leaves the data object uninitialized.
18 * Constructor with initialisation.
20 * @param definitionPoint Definition point.
21 * @param middleOfText Middle point of dimension text.
22 * @param valign Vertical alignment.
23 * @param halign Horizontal alignment.
24 * @param lineSpacingStyle Line spacing style.
25 * @param lineSpacingFactor Line spacing factor.
26 * @param text Text string entered explicitly by user or null
27 * or "<>" for the actual measurement or " " (one blank space).
28 * for supressing the text.
29 * @param style Dimension style name.
30 * @param angle Rotation angle of dimension text away from
31 * default orientation.
33 RS_DimensionData(const Vector& definitionPoint,
34 const Vector& middleOfText,
37 RS2::TextLineSpacingStyle lineSpacingStyle,
38 double lineSpacingFactor,
43 this->definitionPoint = definitionPoint;
44 this->middleOfText = middleOfText;
45 this->valign = valign;
46 this->halign = halign;
47 this->lineSpacingStyle = lineSpacingStyle;
48 this->lineSpacingFactor = lineSpacingFactor;
54 friend class RS_Dimension;
55 friend class RS_DimAligned;
56 friend class RS_DimLinear;
57 friend class RS_ActionDimAligned;
58 friend class RS_ActionDimLinear;
60 friend std::ostream & operator<<(std::ostream & os, const RS_DimensionData & dd)
62 os << "(" << dd.definitionPoint << ")";
67 /** Definition point */
68 Vector definitionPoint;
69 /** Middle point of dimension text */
71 /** Vertical alignment */
73 /** Horizontal alignment */
75 /** Line spacing style */
76 RS2::TextLineSpacingStyle lineSpacingStyle;
77 /** Line spacing factor */
78 double lineSpacingFactor;
80 * Text string entered explicitly by user or null
81 * or "<>" for the actual measurement or " " (one blank space)
82 * for supressing the text.
85 /** Dimension style name */
87 /** Rotation angle of dimension text away from default orientation */
92 * Abstract base class for dimension entity classes.
94 * @author Andrew Mustun
96 class RS_Dimension: public RS_EntityContainer
99 RS_Dimension(RS_EntityContainer * parent, const RS_DimensionData & d);
100 virtual ~RS_Dimension();
102 RS_DimensionData getData() const;
103 Vector getNearestRef(const Vector & coord, double * dist);
104 Vector getNearestSelectedRef(const Vector & coord, double * dist);
105 QString getLabel(bool resolve = true);
106 void setLabel(const QString & l);
109 * Needs to be implemented by the dimension class to return the
110 * measurement of the dimension (e.g. 10.5 or 15'14").
112 virtual QString getMeasuredLabel() = 0;
115 * Must be overwritten by implementing dimension entity class
116 * to update the subentities which make up the dimension entity.
118 virtual void update(bool autoText = false) = 0;
120 void updateCreateDimensionLine(const Vector & p1, const Vector & p2,
121 bool arrow1 = true, bool arrow2 = true, bool autoText = false);
122 Vector getDefinitionPoint();
123 Vector getMiddleOfText();
124 RS2::VAlign getVAlign();
125 RS2::HAlign getHAlign();
126 RS2::TextLineSpacingStyle getLineSpacingStyle();
127 double getLineSpacingFactor();
131 double getArrowSize();
132 double getExtensionLineExtension();
133 double getExtensionLineOffset();
134 double getDimensionLineGap();
135 double getTextHeight();
136 double getGraphicVariable(const QString& key, double defMM, int code);
137 virtual double getLength();
138 virtual void move(Vector offset);
139 virtual void rotate(Vector center, double angle);
140 virtual void scale(Vector center, Vector factor);
141 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
144 /** Data common to all dimension entities. */
145 RS_DimensionData data;