5 #include "rs_entitycontainer.h"
8 * Holds the data that defines a text entity.
14 * Default constructor. Leaves the data object uninitialized.
19 * Constructor with initialisation.
21 * @param insertionPoint Insertion point
22 * @param height Nominal (initial) text height
23 * @param width Reference rectangle width
24 * @param valign Vertical alignment
25 * @param halign Horizontal alignment
26 * @param drawingDirection Drawing direction
27 * @param lineSpacingStyle Line spacing style
28 * @param lineSpacingFactor Line spacing factor
29 * @param text Text string
30 * @param style Text style name
31 * @param angle Rotation angle
32 * @param updateMode RS2::Update will update the text entity instantly
33 * RS2::NoUpdate will not update the entity. You can update
34 * it later manually using the update() method. This is
35 * often the case since you might want to adjust attributes
36 * after creating a text entity.
38 RS_TextData(const Vector & insertionPoint, double height, double width,
39 RS2::VAlign valign, RS2::HAlign halign, RS2::TextDrawingDirection drawingDirection,
40 RS2::TextLineSpacingStyle lineSpacingStyle, double lineSpacingFactor,
41 const QString& text, const QString & style, double angle,
42 RS2::UpdateMode updateMode = RS2::Update)
44 this->insertionPoint = insertionPoint;
45 this->height = height;
47 this->valign = valign;
48 this->halign = halign;
49 this->drawingDirection = drawingDirection;
50 this->lineSpacingStyle = lineSpacingStyle;
51 this->lineSpacingFactor = lineSpacingFactor;
55 this->updateMode = updateMode;
60 friend std::ostream & operator<<(std::ostream & os, const RS_TextData & td)
62 os << "(" << td.text.toLatin1().data() << ")";
67 /** Insertion point */
68 Vector insertionPoint;
69 /** Nominal (initial) text height */
71 /** Reference rectangle width */
73 /** Vertical alignment */
75 /** Horizontal alignment */
77 /** Drawing direction */
78 RS2::TextDrawingDirection drawingDirection;
79 /** Line spacing style */
80 RS2::TextLineSpacingStyle lineSpacingStyle;
81 /** Line spacing factor */
82 double lineSpacingFactor;
85 /** Text style name */
90 RS2::UpdateMode updateMode;
94 * Class for a text entity.
95 * Please note that text strings can contain special
96 * characters such as %%c for a diameter sign as well as unicode
97 * characters. Line feeds are stored as real line feeds in the string.
99 * @author Andrew Mustun
101 class RS_Text: public RS_EntityContainer
104 RS_Text(RS_EntityContainer * parent, const RS_TextData & d);
107 virtual RS_Entity * clone();
108 virtual RS2::EntityType rtti() const;
109 RS_TextData getData() const;
111 void updateAddLine(RS_EntityContainer * textLine, int lineCounter);
112 int getNumberOfLines();
114 Vector getInsertionPoint();
116 void setHeight(double h);
118 void setAlignment(int a);
120 RS2::VAlign getVAlign();
121 void setVAlign(RS2::VAlign va);
122 RS2::HAlign getHAlign();
123 void setHAlign(RS2::HAlign ha);
124 RS2::TextDrawingDirection getDrawingDirection();
125 RS2::TextLineSpacingStyle getLineSpacingStyle();
126 void setLineSpacingFactor(double f);
127 double getLineSpacingFactor();
128 void setText(const QString & t);
130 void setStyle(const QString & s);
132 void setAngle(double a);
134 double getUsedTextWidth();
135 double getUsedTextHeight();
136 virtual double getLength();
138 virtual VectorSolutions getRefPoints();
139 virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
141 virtual void move(Vector offset);
142 virtual void rotate(Vector center, double angle);
143 virtual void scale(Vector center, Vector factor);
144 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
145 virtual bool hasEndpointsWithinWindow(Vector v1, Vector v2);
146 virtual void stretch(Vector firstCorner, Vector secondCorner, Vector offset);
148 friend std::ostream & operator<<(std::ostream & os, const RS_Text & p);
153 * Text width used by the current contents of this text entity.
154 * This property is updated by the update method.
157 double usedTextWidth;
159 * Text height used by the current contents of this text entity.
160 * This property is updated by the update method.
163 double usedTextHeight;