1 -- Created on: 1991-09-06
2 -- Created by: NW,JPB,CAL
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 deferred class Group from Graphic3d inherits TShared
21 ---Purpose: This class allows the definition of groups
22 -- of primitives inside of graphic objects (presentations).
23 -- A group contains the primitives and attributes
24 -- for which the range is limited to this group.
25 -- The primitives of a group can be globally suppressed.
27 -- There are two main group usage models:
29 -- 1) Non-modifiable, or unbounded, group ('black box').
30 -- Developers can repeat a sequence of
31 -- SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times
32 -- to define arbitrary number of primitive "blocks" each having individual apect values.
33 -- Any modification of such a group is forbidden, as aspects and primitives are mixed
34 -- in memory without any high-level logical structure, and any modification is very likely to result
35 -- in corruption of the group internal data.
36 -- It is necessary to recreate such a group as a whole when some attribute should be changed.
37 -- (for example, in terms of AIS it is necessary to re-Compute() the whole presentation each time).
38 -- 2) Bounded group. Developers should specify the necessary group aspects with help of
39 -- SetGroupPrimitivesAspect() and then add primitives to the group.
40 -- Such a group have simplified organization in memory (a single block of attributes
41 -- followed by a block of primitives) and therefore it can be modified, if it is necessary to
42 -- change parameters of some aspect that has already been set, using methods:
43 -- IsGroupPrimitivesAspectSet() to detect which aspect was set for primitives;
44 -- GroupPrimitivesAspect() to read current aspect values
45 -- and SetGroupPrimitivesAspect() to set new values.
47 -- Developers are strongly recommended to take all the above into account when filling Graphic3d_Group
48 -- with aspects and primitives and choose the group usage model beforehand out of application needs.
55 Array1OfInteger from TColStd,
56 Array1OfReal from TColStd,
57 HArray1OfByte from TColStd,
59 ExtendedString from TCollection,
61 PlaneAngle from Quantity,
63 Array1OfEdge from Aspect,
66 GroupAspect from Graphic3d,
67 AspectLine3d from Graphic3d,
68 AspectMarker3d from Graphic3d,
69 AspectText3d from Graphic3d,
70 AspectFillArea3d from Graphic3d,
71 CAspectLine from Graphic3d,
72 CAspectFillArea from Graphic3d,
73 CAspectMarker from Graphic3d,
74 CAspectText from Graphic3d,
75 CStructurePtr from Graphic3d,
76 HorizontalTextAlignment from Graphic3d,
77 CBitFields4 from Graphic3d,
78 GraphicDriver from Graphic3d,
79 Structure from Graphic3d,
80 StructurePtr from Graphic3d,
81 TextPath from Graphic3d,
82 Vector from Graphic3d,
83 Array1OfVertex from Graphic3d,
84 Array2OfVertex from Graphic3d,
85 Vertex from Graphic3d,
86 VerticalTextAlignment from Graphic3d,
87 ArrayOfPrimitives from Graphic3d,
88 ListOfPArray from Graphic3d,
89 TransModeFlags from Graphic3d,
90 CBounds from Graphic3d,
95 GroupDefinitionError from Graphic3d,
97 OutOfRange from Standard
100 Initialize (theStructure : Structure from Graphic3d)
101 returns mutable Group from Graphic3d;
103 ---Purpose: Creates a group in the structure <AStructure>.
105 ---------------------------------------------------
106 -- Category: Methods to modify the class definition
107 ---------------------------------------------------
109 Clear ( me : mutable;
110 theUpdateStructureMgr : Boolean from Standard = Standard_True )
113 ---Purpose: Supress all primitives and attributes of <me>.
114 -- To clear group without update in Graphic3d_StructureManager
115 -- pass Standard_False as <theUpdateStructureMgr>. This
116 -- used on context and viewer destruction, when the pointer
117 -- to structure manager in Graphic3d_Structure could be
118 -- already released (pointers are used here to avoid handle
120 ---Category: Methods to modify the class definition
122 UpdateAspectLine ( me : mutable;
123 theIsGlobal : Boolean from Standard )
126 UpdateAspectFace ( me : mutable;
127 theIsGlobal : Boolean from Standard )
130 UpdateAspectMarker ( me : mutable;
131 theIsGlobal : Boolean from Standard )
134 UpdateAspectText ( me : mutable;
135 theIsGlobal : Boolean from Standard )
138 Destroy ( me : mutable )
141 ---Purpose: Supress the group <me> in the structure.
142 ---Category: Methods to modify the class definition
145 Remove ( me : mutable )
148 ---Purpose: Supress the group <me> in the structure.
149 -- Warning: No more graphic operations in <me> after this call.
150 ---Category: Methods to modify the class definition
152 --SetTransformPersistence( me : mutable;
153 -- AFlag : TransModeFlags from Graphic3d )
155 ---Purpose: Modifies the current modelling transform persistence (pan, zoom or rotate)
158 --TransformPersistence( me )
159 -- returns TransModeFlags from Graphic3d
161 ---Purpose: Get the current modelling transform persistence (pan, zoom or rotate)
164 SetGroupPrimitivesAspect ( me : mutable )
167 ---Purpose: Removes the context for all the line primitives
169 ---Category: Methods to modify the class definition
171 SetGroupPrimitivesAspect ( me : mutable;
172 CTX : AspectLine3d from Graphic3d )
175 ---Purpose: Modifies the context for all the line primitives
177 ---Category: Methods to modify the class definition
179 SetGroupPrimitivesAspect ( me : mutable;
180 CTX : AspectFillArea3d from Graphic3d )
183 ---Purpose: Modifies the context for all the face primitives
185 ---Category: Methods to modify the class definition
187 SetGroupPrimitivesAspect ( me : mutable;
188 CTX : AspectText3d from Graphic3d )
191 ---Purpose: Modifies the context for all the text primitives
193 ---Category: Methods to modify the class definition
195 SetGroupPrimitivesAspect ( me : mutable;
196 CTX : AspectMarker3d from Graphic3d )
199 ---Purpose: Modifies the context for all the marker primitives
201 ---Category: Methods to modify the class definition
203 SetPrimitivesAspect ( me : mutable;
204 CTX : AspectLine3d from Graphic3d )
207 ---Purpose: Modifies the current context of the group to give
208 -- another aspect for all the line primitives created
209 -- after this call in the group.
210 ---Category: Methods to modify the class definition
212 SetPrimitivesAspect ( me : mutable;
213 CTX : AspectFillArea3d from Graphic3d )
216 ---Purpose: Modifies the current context of the group to give
217 -- another aspect for all the face primitives created
218 -- after this call in the group.
219 ---Category: Methods to modify the class definition
221 SetPrimitivesAspect ( me : mutable;
222 CTX : AspectText3d from Graphic3d )
225 ---Purpose: Modifies the current context of the group to give
226 -- another aspect for all the text primitives created
227 -- after this call in the group.
228 ---Category: Methods to modify the class definition
230 SetPrimitivesAspect ( me : mutable;
231 CTX : AspectMarker3d from Graphic3d )
234 ---Purpose: Modifies the current context of the group to give
235 -- another aspect for all the marker primitives created
236 -- after this call in the group.
237 ---Category: Methods to modify the class definition
239 SetMinMaxValues ( me : mutable;
240 XMin, YMin, ZMin : Real from Standard;
241 XMax, YMax, ZMax : Real from Standard )
244 ---Purpose: Sets the coordinates of the boundary box of the
246 ---Category: Methods to modify the class definition
248 -----------------------------------
249 -- Category: Methods to create Text
250 -----------------------------------
252 --------------------------------------------
253 -- Summary of Texts --
255 -- Text has geometric and nongeometric --
258 -- The geometric text attributes are : --
260 -- Character Height. --
261 -- Character Up Vector. --
263 -- Text Alignment Horizontal. --
264 -- Text Alignment Vertical. --
266 -- The nongeometric text attributes are : --
269 -- Character Spacing. --
270 -- Character Expansion Factor. --
272 --------------------------------------------
275 AText : CString from Standard;
276 APoint : Vertex from Graphic3d;
277 AHeight : Real from Standard;
278 AAngle : PlaneAngle from Quantity;
279 ATp : TextPath from Graphic3d;
280 AHta : HorizontalTextAlignment from Graphic3d;
281 AVta : VerticalTextAlignment from Graphic3d;
282 EvalMinMax : Boolean from Standard = Standard_True )
285 ---Purpose: Creates the string <AText> at position <APoint>.
286 -- The 3D point of attachment is projected. The text is
287 -- written in the plane of projection.
288 -- The attributes are given with respect to the plane of
290 -- AHeight : Height of text.
291 -- (Relative to the Normalized Projection
292 -- Coordinates (NPC) Space).
293 -- AAngle : Orientation of the text
294 -- (with respect to the horizontal).
295 ---Category: Methods to create Text
298 AText : CString from Standard;
299 APoint : Vertex from Graphic3d;
300 AHeight : Real from Standard;
301 EvalMinMax : Boolean from Standard = Standard_True )
304 ---Purpose: Creates the string <AText> at position <APoint>.
305 -- The 3D point of attachment is projected. The text is
306 -- written in the plane of projection.
307 -- The attributes are given with respect to the plane of
309 -- AHeight : Height of text.
310 -- (Relative to the Normalized Projection
311 -- Coordinates (NPC) Space).
312 -- The other attributes have the following default values:
317 ---Category: Methods to create Text
320 AText : ExtendedString from TCollection;
321 APoint : Vertex from Graphic3d;
322 AHeight : Real from Standard;
323 AAngle : PlaneAngle from Quantity;
324 ATp : TextPath from Graphic3d;
325 AHta : HorizontalTextAlignment from Graphic3d;
326 AVta : VerticalTextAlignment from Graphic3d;
327 EvalMinMax : Boolean from Standard = Standard_True )
330 ---Purpose: Creates the string <AText> at position <APoint>.
331 -- The 3D point of attachment is projected. The text is
332 -- written in the plane of projection.
333 -- The attributes are given with respect to the plane of
335 -- AHeight : Height of text.
336 -- (Relative to the Normalized Projection
337 -- Coordinates (NPC) Space).
338 -- AAngle : Orientation of the text
339 -- (with respect to the horizontal).
340 ---Category: Methods to create Text
343 AText : ExtendedString from TCollection;
344 APoint : Vertex from Graphic3d;
345 AHeight : Real from Standard;
346 EvalMinMax : Boolean from Standard = Standard_True )
349 ---Purpose: Creates the string <AText> at position <APoint>.
350 -- The 3D point of attachment is projected. The text is
351 -- written in the plane of projection.
352 -- The attributes are given with respect to the plane of
354 -- AHeight : Height of text.
355 -- (Relative to the Normalized Projection
356 -- Coordinates (NPC) Space).
357 -- The other attributes have the following default values:
362 ---Category: Methods to create Text
364 ---------------------------------------
365 ---Category: Methods to create Triangle
366 ---------------------------------------
368 AddPrimitiveArray( me : mutable;
369 thePrim : ArrayOfPrimitives from Graphic3d;
370 theToEvalMinMax : Boolean from Standard = Standard_True ) is virtual;
372 ---Purpose: Adds an array of primitives for display
374 Marker ( me : mutable;
375 thePoint : Vertex from Graphic3d;
376 theToEvalMinMax : Boolean from Standard = Standard_True )
379 ---Purpose: Creates a primitive array with single marker using AddPrimitiveArray().
381 UserDraw ( me : mutable;
382 theObject : Address from Standard;
383 theToEvalMinMax : Boolean from Standard = Standard_True;
384 theContainsFacet : Boolean from Standard = Standard_False )
387 ---Purpose: Creates a UserDraw primitive using obsolete API.
389 SetStencilTestOptions (me : mutable;
390 theIsEnabled: Boolean from Standard)
392 ---Purpose: sets the stencil test to theIsEnabled state;
394 SetFlippingOptions (me : mutable;
395 theIsEnabled : Boolean from Standard;
396 theRefPlane : Ax2 from gp)
398 ---Purpose: sets the flipping to theIsEnabled state.
400 ----------------------------
401 -- Category: Inquire methods
402 ----------------------------
404 IsGroupPrimitivesAspectSet ( me;
405 theAspect : GroupAspect from Graphic3d )
406 returns Boolean from Standard
409 ---Purpose: Returns TRUE if aspect is set for the group.
410 ---Category: Inquire methods
412 GroupPrimitivesAspect ( me;
413 CTXL : AspectLine3d from Graphic3d;
414 CTXT : AspectText3d from Graphic3d;
415 CTXM : AspectMarker3d from Graphic3d;
416 CTXF : AspectFillArea3d from Graphic3d )
419 ---Purpose: Returns the context of all the primitives of the group.
420 ---Category: Inquire methods
422 PrimitivesAspect ( me;
423 CTXL : AspectLine3d from Graphic3d;
424 CTXT : AspectText3d from Graphic3d;
425 CTXM : AspectMarker3d from Graphic3d;
426 CTXF : AspectFillArea3d from Graphic3d )
429 ---Purpose: Returns the last inserted context in the group <me>
430 -- foreach kind of primitives.
431 ---Category: Inquire methods
434 returns Boolean from Standard
437 ---Purpose: Returns Standard_True if the group <me> contains
438 -- Polygons, Triangles or Quadrangles.
439 ---Category: Inquire methods
442 returns Boolean from Standard
445 ---Purpose: Returns Standard_True if the group <me> is deleted.
446 -- <me> is deleted after the call Remove (me) or the
447 -- associated structure is deleted.
448 ---Category: Inquire methods
451 returns Boolean from Standard
454 ---Purpose: Returns Standard_True if the group <me> is empty.
455 ---Warning: A group is empty if the MinMaxValues method returns :
456 -- XMin = YMin = ZMin = RealFirst ().
457 -- XMax = YMax = ZMax = RealLast ().
458 ---Category: Inquire methods
461 XMin, YMin, ZMin : out Real from Standard;
462 XMax, YMax, ZMax : out Real from Standard )
465 ---Purpose: Returns the coordinates of the boundary box of the
467 ---Warning: If the group <me> is empty then :
468 -- XMin = YMin = ZMin = RealFirst ().
469 -- XMax = YMax = ZMax = RealLast ().
470 ---Category: Inquire methods
473 returns mutable Structure from Graphic3d
476 ---Purpose: Returns the structure containing the group <me>.
477 ---Category: Inquire methods
479 ----------------------------
480 -- Category: Private methods
481 ----------------------------
484 XMin, YMin, ZMin : out Real from Standard;
485 XMax, YMax, ZMax : out Real from Standard )
488 ---Purpose: Returns the extreme coordinates found in the group.
489 ---Warning: If the group <me> is empty then :
490 -- XMin = YMin = ZMin = RealFirst ().
491 -- XMax = YMax = ZMax = RealLast ().
492 ---Category: Private methods
497 ---Purpose: Calls the Update method of the StructureManager which
498 -- contains the associated Structure of the Group <me>.
499 ---Category: Private methods
504 -- Class : Graphic3d_Group
506 -- Purpose : Declaration of variables specific to groups
509 -- Reminder : A group is defined in a structure
510 -- It acts as the smallest editable entity.
512 -- the state of the different contexts for primitives
513 myCBitFields : CBitFields4 from Graphic3d is protected;
515 -- the structure contains the group
516 myStructure : StructurePtr from Graphic3d is protected;
519 myBounds : CBounds from Graphic3d is protected;
521 ContextLine : CAspectLine from Graphic3d is protected;
522 ContextFillArea : CAspectFillArea from Graphic3d is protected;
523 ContextMarker : CAspectMarker from Graphic3d is protected;
524 ContextText : CAspectText from Graphic3d is protected;
526 -- temporary field - to be removed
527 myListOfPArray : ListOfPArray from Graphic3d is protected;
531 class Structure from Graphic3d