b311480e |
1 | -- Created on: 1993-06-22 |
2 | -- Created by: Jean Louis FRENKEL, Gerard GRAS |
3 | -- Copyright (c) 1993-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
7fd59977 |
22 | -- Modified: TCL G002A, 28-11-00, new inquire methods GetText() and GetType() |
23 | |
7fd59977 |
24 | |
25 | class Text from Graphic2d inherits Primitive from Graphic2d |
26 | |
27 | ---Version: |
28 | |
29 | ---Purpose: The primitive Text |
30 | |
31 | ---Keywords: Primitive, Text |
32 | ---Warning: |
33 | ---References: |
34 | |
35 | uses |
36 | Drawer from Graphic2d, |
37 | GraphicObject from Graphic2d, |
38 | TypeOfAlignment from Graphic2d, |
39 | PlaneAngle from Quantity, |
40 | Length from Quantity, |
41 | Factor from Quantity, |
42 | ExtendedString from TCollection, |
43 | TypeOfText from Aspect, |
44 | FStream from Aspect, |
45 | IFStream from Aspect |
46 | |
47 | |
48 | |
49 | is |
50 | ------------------------- |
51 | -- Category: Constructors |
52 | ------------------------- |
53 | |
54 | Create (aGraphicObject: GraphicObject from Graphic2d; |
55 | aText: ExtendedString from TCollection; |
56 | X, Y: Real from Standard; |
57 | anAngle: PlaneAngle from Quantity = 0.0; |
58 | aType: TypeOfText from Aspect = Aspect_TOT_SOLID; |
59 | aScale: Factor from Quantity = 1.0) |
60 | returns mutable Text from Graphic2d; |
61 | ---Level: Public |
62 | ---Purpose: Creates a text in a graphic object <aGraphicObject> |
63 | -- The text is <aText>. |
64 | -- The reference point is <X>, <Y>. |
65 | -- The orientation angle is <anAngle>. |
66 | -- The type of text is <aType> and must be one of : |
67 | -- Aspect_TOT_SOLID, |
68 | -- Aspect_TOT_OUTLINE, |
69 | -- The scale factor apply to the original font size, |
70 | -- Angles are measured counterclockwise with 0 radian |
71 | -- at 3 o'clock. |
72 | -- Warning: a text can be orientable,slantable,zoomable or outlinable |
73 | -- only when this options are enable regardless of the graphic driver. |
74 | -- i.e: Xw driver does not,but Xdps or PS driver does. |
75 | ---Category: Constructors |
76 | |
77 | --------------------------------------------------- |
78 | -- Category: Methods to modify the class definition |
79 | --------------------------------------------------- |
80 | |
81 | SetFontIndex (me:mutable; anIndex: Integer from Standard = 0) |
82 | is static; |
83 | ---Level: Public |
84 | ---Purpose: Sets the font index for the text <me>. |
85 | -- Warning: Note that the index 0 can be undefined as a FontMapEntry, |
86 | -- in this case the default system text font is taken. |
87 | |
88 | SetSlant (me: mutable; aSlant: PlaneAngle from Quantity = 0.0) |
89 | is static; |
90 | ---Level: Public |
91 | ---Purpose: Sets the slant angle of the text <me>. |
92 | |
93 | SetZoomable (me: mutable; aFlag: Boolean from Standard = Standard_True) |
94 | is static; |
95 | ---Level: Public |
96 | ---Purpose: The text <me> follows the scale factor of the view |
97 | -- if the flag is Standard_True. |
98 | ---Category: Zoom management |
99 | |
100 | SetOffset (me: mutable; aDx: Real from Standard = 0.0; |
101 | aDy: Real from Standard = 0.0) |
102 | is static; |
103 | ---Level: Public |
104 | ---Purpose: Sets the Device space offset of the text <me>. |
105 | |
106 | SetUnderline (me: mutable; |
107 | isUnderlined: Boolean from Standard = Standard_False) |
108 | is static; |
109 | ---Level: Public |
110 | ---Purpose: Enable/Disable text underline. |
111 | |
112 | SetAlignment (me:mutable; anAlignment: TypeOfAlignment from Graphic2d = |
113 | Graphic2d_TOA_LEFT) |
114 | is static; |
115 | ---Level: Public |
116 | ---Purpose: Sets the text alignment. |
117 | |
118 | Fit (me:mutable; aWidth,aHeight: Length from Quantity; |
119 | Adjust: Boolean from Standard = Standard_True; |
120 | Expand: Boolean from Standard = Standard_True) |
121 | returns Boolean from Standard is virtual; |
122 | ---Level: Public |
123 | ---Purpose: Compute text size depending of a required bounding box, |
124 | -- Adjust the text position depending of the text origine |
125 | -- and base line if "Adjust" is TRUE, |
126 | -- Expand the text when the Width is smaller that the |
127 | -- Fit Width if "Expand" is TRUE. |
128 | -- and returns Standard_True if the current Driver used is |
129 | -- enable to fit the text size. |
130 | -- Warning: The fit computation is apply only if the corresponding |
131 | -- dimension is > 0. |
132 | |
133 | Trunc (me:mutable; aWidth: Length from Quantity) |
134 | returns Boolean from Standard is virtual; |
135 | ---Level: Public |
136 | ---Purpose: Trunc the text when the Width of the text is greater |
137 | -- that the defined Width Max, |
138 | -- and returns Standard_True if the current Driver used is |
139 | -- enable to trunc the text size. |
140 | |
141 | -------------------------- |
142 | -- Category: Draw and Pick |
143 | -------------------------- |
144 | |
145 | Draw (me : mutable; aDrawer: Drawer from Graphic2d) |
146 | is virtual protected; |
147 | ---Level: Internal |
148 | ---Purpose: Draws the text <me>. |
149 | |
150 | Pick (me : mutable; X, Y: ShortReal from Standard; |
151 | aPrecision: ShortReal from Standard; |
152 | aDrawer: Drawer from Graphic2d) |
153 | returns Boolean from Standard |
154 | is virtual protected; |
155 | ---Level: Internal |
156 | ---Purpose: Returns Standard_True if the text <me> is picked, |
157 | -- Standard_False if not. |
158 | |
159 | ---------------------------- |
160 | -- Category: Inquire methods |
161 | ---------------------------- |
162 | |
163 | IsZoomable (me) |
164 | returns Boolean from Standard is static; |
165 | ---Level: Public |
166 | ---Purpose: Returns Standard_True if the Text <me> follows |
167 | -- the scale factor of the view. |
168 | ---Category: Zoom management |
169 | |
170 | IsUnderlined (me) returns Boolean from Standard is static; |
171 | ---Level: Public |
172 | ---Purpose: Returns Standard_True if the Text <me> is underlined. |
173 | |
174 | TextSize (me; aWidth,aHeight: out Length from Quantity) |
175 | returns Boolean from Standard is static; |
176 | ---Level: Public |
177 | ---Purpose: Returns Standard_True if the current Driver used is enabled |
178 | -- to get the right size in the |
179 | -- world size parameter <aWidth>,<aHeight> |
180 | -- depending of the attributes of the text and the current scale |
181 | -- of the view. |
182 | ---Category: Text management |
183 | |
184 | TextSize (me; aWidth,aHeight,anXoffset,anYoffset: out Length from Quantity) |
185 | returns Boolean from Standard is virtual; |
186 | ---Level: Public |
187 | ---Purpose: Returns Standard_True if the current Driver used is enabled |
188 | -- to get the right size and text offsets in the |
189 | -- world size parameter <aWidth>,<aHeight>,<anXoffset>,<anYoffset> |
190 | -- depending of the attributes of the text and the current scale |
191 | -- of the view. |
192 | -- NOTE that the text offsets defines the relative position of the |
193 | -- of the text string origin from the lower left corner of the text |
194 | -- boundary limits. |
195 | ---Category: Text management |
196 | |
197 | Position (me; X,Y: out Length from Quantity) is static; |
198 | ---Level: Public |
199 | ---Purpose: Returns the text position. |
200 | |
201 | Offset (me; X,Y: out Real from Standard) is static; |
202 | ---Level: Public |
203 | ---Purpose: Returns the text Offset. |
204 | |
205 | Slant (me) returns PlaneAngle from Quantity is static; |
206 | ---Level: Public |
207 | ---Purpose: Returns the text slant. |
208 | |
209 | Angle (me) returns PlaneAngle from Quantity is static; |
210 | ---Level: Public |
211 | ---Purpose: Returns the text orientation. |
212 | |
213 | FontIndex (me) returns Integer from Standard is static; |
214 | ---Level: Public |
215 | ---Purpose: Returns the text font index. |
216 | |
217 | Scale (me) returns Factor from Quantity is static; |
218 | ---Level: Public |
219 | ---Purpose: Returns the text scale. |
220 | |
221 | Alignment (me) returns TypeOfAlignment from Graphic2d is static; |
222 | ---Level: Public |
223 | ---Purpose: Returns the text alignment. |
224 | |
225 | GetText( me ) returns ExtendedString from TCollection; |
226 | ---Level: Public |
227 | ---Purpose: Returns the text string |
228 | |
229 | GetType( me ) returns TypeOfText from Aspect; |
230 | ---Level: Public |
231 | ---Purpose: Returns the type text |
232 | |
233 | ---------------------------- |
234 | -- Category: Private methods |
235 | ---------------------------- |
236 | |
237 | ComputeMinMax (me : mutable) |
238 | returns Boolean from Standard is redefined virtual protected; |
239 | ---Level: Internal |
240 | ---Purpose: Computes the MinMax of the text if possible. |
241 | |
242 | ---------------------------------------------------------------------- |
243 | |
244 | Save( me; aFStream: in out FStream from Aspect ) is virtual; |
245 | -- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; |
246 | |
247 | fields |
248 | |
249 | myFontIndex: Integer from Standard is protected; |
250 | |
251 | myX,myDx: ShortReal from Standard is protected; |
252 | myY,myDy: ShortReal from Standard is protected; |
253 | myAngle: ShortReal from Standard is protected; |
254 | myType: TypeOfText from Aspect is protected; |
255 | myText: ExtendedString from TCollection is protected; |
256 | myAdjustFlag: Boolean from Standard is protected; |
257 | |
258 | myDeltax: ShortReal from Standard is protected; |
259 | myDeltay: ShortReal from Standard is protected; |
260 | mySlant: ShortReal from Standard is protected; |
261 | myIsZoomable: Boolean from Standard is protected; |
262 | myIsUnderlined: Boolean from Standard is protected; |
263 | myHScale: Factor from Quantity is protected; |
264 | myWScale: Factor from Quantity is protected; |
265 | myAlignment: TypeOfAlignment from Graphic2d is protected; |
266 | |
267 | end Text from Graphic2d; |