0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Graphic2d / Graphic2d_Buffer.cdl
CommitLineData
b311480e 1-- Created by: s: CAL, GG
2-- Copyright (c) 1995-1999 Matra Datavision
3-- Copyright (c) 1999-2012 OPEN CASCADE SAS
4--
5-- The content of this file is subject to the Open CASCADE Technology Public
6-- License Version 6.5 (the "License"). You may not use the content of this file
7-- except in compliance with the License. Please obtain a copy of the License
8-- at http://www.opencascade.org and read it completely before using this file.
9--
10-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
7fd59977 12--
b311480e 13-- The Original Code and all software distributed under the License is
14-- distributed on an "AS IS" basis, without warranty of any kind, and the
15-- Initial Developer hereby disclaims all such warranties, including without
16-- limitation, any warranties of merchantability, fitness for a particular
17-- purpose or non-infringement. Please see the License for the specific terms
18-- and conditions governing the rights and limitations under the License.
19
20
7fd59977 21
22class Buffer from Graphic2d inherits TShared from MMgt
23
24 ---Purpose: This class constructs a 2D graphic buffer in a view. It
25 -- manages a set of graphic objects and/or primitives.
26 -- To draw the buffer, the following elements are required:
27 -- - the override color
28 -- - the font
29 -- - a solid line type
30 -- - thickness of 1 pixel.
31 -- With this category , the user can drag the geometry
32 -- stored in the buffer without changing the fixed
33 -- background. This mechanism is reserved for the
34 -- special driver Aspect_WindowDriver: if no other
35 -- driver has been defined, nothing will be drawn. Both
36 -- this driver and view mapping are used to draw the buffer.
37 -- Warning
38 -- - This class manages dragging only. It does not
39 -- manage "sketching" or "rubberbanding". For example:
40 -- - There is no empty constructor for this
41 -- primitive. Therefore we must create a primitive
42 -- in a dummy object simply to add this primitive to the buffer.
43 -- - There is no Buffer->Add (anArrayOfPoints)
44 -- method. Therefor it is not possible to add
45 -- shapes to the buffer.
46 -- - There are no Polyline->ChangeApoint () nor
47 -- Circle->ChangeRadius () methods. Therefore
48 -- we must call the primitive's destructor to modify
49 -- the definition of one primitive in a buffer.
50 -- - The Graphic2d_Image class is a primitive. For
51 -- this class, we replace the definition of the image
52 -- with a rectangle with the same size and the same position.
53 -- - You can add or remove primitives to the buffer
54 -- after creating and displaying it again.
55
56
57
58uses
59 PlaneAngle from Quantity,
60 Factor from Quantity,
61 Length from Quantity,
62
63 View from Graphic2d,
64 Drawer from Graphic2d,
65 ViewPtr from Graphic2d,
66 Primitive from Graphic2d,
67 SequenceOfPrimitives from Graphic2d,
68 GraphicObject from Graphic2d,
69 SequenceOfGraphicObject from Graphic2d,
70 ViewMapping from Graphic2d,
71 WindowDriver from Aspect,
72 TypeOfDrawMode from Aspect
73
74is
75 -------------------------
76 -- Category: Constructors
77 -------------------------
78
79 Create (aView: View from Graphic2d;
80 aPivotX, aPivotY: Length from Quantity;
81 aWidthIndex: Integer from Standard = 0;
82 aColorIndex: Integer from Standard = 0;
83 aFontIndex: Integer from Standard = 0;
84 aDrawMode: TypeOfDrawMode from Aspect = Aspect_TODM_REPLACE)
85 returns mutable Buffer from Graphic2d;
86 ---Purpose: Creates an empty graphic buffer in the view <aView>.
87 -- A graphic buffer manages a set of graphic objects
88 -- and/or primitives.
89 -- A buffer color and font index can be defined,
90 -- in place of the default overrideColor or systemFont.
91 -- When the drawmode is REPLACE the buffer is drawn with
92 -- the right color and background drawing is used for
93 -- restoring it at Erase() time.
94 -- When the drawmode is XOR the buffer is drawn or erase
95 -- with an optimal color depending of the background color
96 -- but some side effects can appears depending of
97 -- background drawing pixels values.
98 ---Category: Constructors
99
100 ------------------------
101 -- Category: Destructors
102 ------------------------
103
104 Destroy (me: mutable)
105 is static;
106 ---Level: Public
107 ---Purpose: Deletes the graphic buffer <me>.
108 ---C++: alias ~
109 ---Category: Destructors
110
111 ---------------------------------------------------------
112 -- Category: Methods to manage the contents of the buffer
113 ---------------------------------------------------------
114
115 Add (me: mutable; anObject: GraphicObject from Graphic2d)
116 is static;
117 ---Level: Public
118 ---Purpose: Adds the graphic object <anObject> in the graphic
119 -- buffer <me>.
120 ---Category: Methods to manage the contents of the buffer
121
122 Add (me: mutable; aPrimitive: Primitive from Graphic2d)
123 is static;
124 ---Level: Public
125 ---Purpose: Adds the primitive <aPrimitive> in the graphic
126 -- buffer <me>.
127 ---Category: Methods to manage the contents of the buffer
128
129 Remove (me: mutable; anObject: GraphicObject from Graphic2d)
130 is static;
131 ---Level: Public
132 ---Purpose: Removes the object <anObject> from the graphic
133 -- buffer <me>.
134 ---Category: Methods to manage the contents of the buffer
135
136 Remove (me: mutable; aPrimitive: Primitive from Graphic2d)
137 is static;
138 ---Level: Public
139 ---Purpose: Removes the primitive <aPrimitive> from the graphic
140 -- buffer <me>.
141 ---Category: Methods to manage the contents of the buffer
142
143 Clear (me: mutable)
144 is static;
145 ---Level: Public
146 ---Purpose: Clears the graphic buffer <me>.
147 -- Removes all the primitives from the graphic buffer <me>.
148 ---Category: Methods to manage the contents of the buffer
149--\f
150 ---------------------------------------------------------
151 -- Category: Methods to manage the attributes of the buffer
152 ---------------------------------------------------------
153
154 SetAttrib(me : mutable;
155 aWidthIndex: Integer from Standard;
156 aColorIndex: Integer from Standard;
157 aFontIndex: Integer from Standard;
158 aDrawMode: TypeOfDrawMode from Aspect) is static;
159 ---Level: Public
160 ---Purpose: Updates the default buffer color with a new
161 -- color index defines in the user ColorMap.
162 -- Update the default buffer font with a new
163 -- font index defines in the user FontMap.
164 -- Update the default buffer drawmode with
165 -- REPLACE or XOR .
166 -- You can specify the width index
167 -- - -1 draw all lines with the largest width
168 -- defined in the buffer <me>
169 -- - 0 draw all lines with the default width
170 -- defined in the driver (1 pixel)
171 -- - draw all lines with the specified width
172 -- <aWidthIndex>
173 -- You can specify the color index
174 -- - -1 draw all primitives with the color of
175 -- the first primitive color defined in the buffer.
176 -- - 0 draw all primitives with the default color.
177 -- You can specify the font index
178 -- - -1 draw all text primitives with the font of
179 -- the first primitive text defined in the buffer.
180 -- - 0 draw all text primitives with the default font.
181 -- Warning: The buffer is redisplayed again if it was posted.
182 ---Category: Methods to manage the attributes of the buffer
183
184 SetPivot(me : mutable;
185 aPivotX, aPivotY: Length from Quantity)
186 is static;
187 ---Level: Public
188 ---Purpose: Updates the buffer pivot position.
189 -- Warning: The buffer is redisplayed again if it was posted.
190 ---Category: Methods to manage the position of the buffer
191
192 SetPivot(me : mutable)
193 is static;
194 ---Level: Public
195 ---Purpose: Updates the buffer pivot position with the actual position.
196 ---Category: Methods to manage the position of the buffer
197
198--\f
199 ---------------------------------------------------------
200 -- Category: Methods to manage the position of the buffer
201 ---------------------------------------------------------
202
203 Move (me: mutable;
204 aDeltaX,aDeltaY: Length from Quantity)
205 is static;
206 ---Level: Public
207 ---Purpose: Moves the graphic buffer <me> at the specified
208 -- position. The new position of the buffer is :
209 -- (<aPivotX> + <aDeltaX>, <aPivotY> + <aDeltaY>)
210 ---Category: Methods to manage the position of the buffer
211
212 Rotate (me: mutable;
213 anAngle: PlaneAngle from Quantity)
214 is static;
215 ---Level: Public
216 ---Purpose: Rotates the graphic buffer <me> with the specified
217 -- absolute counter clockwise angle from the pivot X axis.
218 ---Category: Methods to manage the position of the buffer
219
220 Scale (me: mutable;
221 aFactor: Factor from Quantity)
222 is static;
223 ---Level: Public
224 ---Purpose: Scales the graphic buffer <me> with the specified
225 -- absolute scale factor from the pivot point.
226 ---Category: Methods to manage the position of the buffer
227
228 ----------------------------
229 -- Category: Inquire methods
230 ----------------------------
231
232 View (me)
233 returns mutable View from Graphic2d is static;
234 ---Level: Public
235 ---Purpose: Returns the view which manages the graphic buffer <me>.
236 ---Category: Inquire methods
237
238 IsEmpty (me)
239 returns Boolean from Standard
240 is static;
241 ---Level: Public
242 ---Purpose: Returns Standard_True if the graphic buffer <me>
243 -- is empty, Standard_False if not.
244 ---Category: Inquire methods
245
246 IsIn (me; aPrimitive: Primitive from Graphic2d)
247 returns Boolean from Standard
248 is static;
249 ---Level: Public
250 ---Purpose: Returns Standard_True if the primitive <aPrimitive>
251 -- is in the graphic buffer <me>, Standard_False if not.
252 ---Category: Inquire methods
253
254 IsIn (me; anObject: GraphicObject from Graphic2d)
255 returns Boolean from Standard
256 is static;
257 ---Level: Public
258 ---Purpose: Returns Standard_True if the graphic object <anObject>
259 -- is in the graphic buffer <me>, Standard_False if not.
260 ---Category: Inquire methods
261
262 ---------------------------------------------
263 -- Category: Methods to manage the visibility
264 ---------------------------------------------
265
266 Post (me: mutable)
267 is static;
268 ---Level: Public
269 ---Purpose: Post the graphic buffer in the current View driver
270 -- and display it.
271 -- Warning: The view driver must be defined and of type WindowDriver
272 -- or nothing is drawn .
273 ---Category: Methods to manage the visibility
274
275 Post (me: mutable;
276 aDriver: WindowDriver from Aspect;
277 aViewMapping: ViewMapping from Graphic2d;
278 aXPosition, aYPosition: Real from Standard;
279 aScale: Real from Standard)
280 is static;
281 ---Level: Public
282 ---Purpose: Post the graphic buffer in a View driver and display it.
283 ---Category: Methods to manage the visibility
284
285 UnPost (me: mutable)
286 is static;
287 ---Level: Public
288 ---Purpose: Unpost the graphic buffer from the view and erase it.
289 ---Category: Methods to manage the visibility
290
291 IsPosted (me)
292 returns Boolean from Standard
293 is static;
294 ---Level: Public
295 ---Purpose: Returns Standard_True if the graphic buffer <me>
296 -- is posted in the view, Standard_False if not.
297 ---Category: Methods to manage the visibility
298
299 IsPosted (me;
300 aDriver: WindowDriver from Aspect)
301 returns Boolean from Standard
302 is static private;
303 ---Level: Public
304 ---Purpose: Returns Standard_True if the graphic buffer <me>
305 -- is posted in the view with the driver <aDriver>,
306 -- Standard_False if not.
307 ---Category: Private methods
308
309 -------------------------------------------------------------
310 -- Category: Inquiries to retrieve the position of the buffer
311 -------------------------------------------------------------
312
313 Angle (me)
314 returns PlaneAngle from Quantity is static;
315 ---Level: Public
316 ---Purpose: Returns the value of the rotation angle of the
317 -- graphic buffer <me>.
318 ---Category: Inquire methods
319
320 Scale (me)
321 returns Factor from Quantity is static;
322 ---Level: Public
323 ---Purpose: Returns the value of the scale factor of the
324 -- graphic buffer <me>.
325 ---Category: Inquire methods
326
327 Xpivot (me)
328 returns Length from Quantity is static;
329 ---Level: Public
330 ---Purpose: Returns the actual value of the X pivot point.
331 -- of the graphic buffer <me>.
332 ---Category: Inquire methods
333
334 Ypivot (me)
335 returns Length from Quantity is static;
336 ---Level: Public
337 ---Purpose: Returns the actual value of the Y pivot point.
338 -- of the graphic buffer <me>.
339 ---Category: Inquire methods
340
341 ----------------------------
342 -- Category: Private methods
343 ----------------------------
344
345 Draw (me : mutable) is static private;
346 ---Level: Internal
347 ---Purpose: Update the internal buffer with new primitives
348 -- if any and draw it at screen.
349 ---Category: Private methods
350
351 Erase (me : mutable) is static private;
352 ---Level: Internal
353 ---Purpose: Erase the internal buffer from the screen.
354 ---Category: Private methods
355
356 ReLoad (me : mutable;
357 ResetPosition: Boolean from Standard = Standard_True)
358 is static private;
359 ---Level: Internal
360 ---Purpose: Erase and Reload the internal graphic buffer before
361 -- drawing to the current drawer.
362 -- Keep the actual position if <ResetPosition> is FALSE.
363 ---Category: Private methods
364
365 MaxWidth (me; theWidth: out Length from Quantity;
366 theIndex: out Integer from Standard)
367 returns Boolean from Standard is static private;
368 ---Level: Internal
369 ---Purpose: Returns Standard_True if the buffer contains
370 -- lines and the maximum width of the lines in the
371 -- buffer <me>
372 ---Category: Private methods
373
374fields
375 myBufferId: Integer from Standard;
376 myBufferIsPosted: Boolean from Standard;
377 myDriver: WindowDriver from Aspect;
378 myPivotX: ShortReal from Standard;
379 myPivotY: ShortReal from Standard;
380 myWidthIndex: Integer from Standard;
381 myColorIndex: Integer from Standard;
382 myFontIndex: Integer from Standard;
383 myDrawMode: TypeOfDrawMode from Aspect;
384 myPView: ViewPtr from Graphic2d;
385 myPrimitives: SequenceOfPrimitives from Graphic2d;
386 myObjects: SequenceOfGraphicObject from Graphic2d;
387
388friends
389
390 class View from Graphic2d
391
392end Buffer from Graphic2d;