0023654: Problem with displaying vertices in OCC view after closing all OCC views...
[occt.git] / src / Graphic3d / Graphic3d_StructureManager.cdl
1 -- Created on: 1991-09-05
2 -- Created by: NW,JPB,CAL
3 -- Copyright (c) 1991-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
21 --              11/97 ; CAL : gestion du GraphicClear
22 --              05/98 ; CAL : gestion du GraphicConnect et Disconnect
23
24 deferred class StructureManager from Graphic3d inherits TShared
25
26         ---Version:
27
28         ---Purpose: This class allows the definition of a manager to
29         --          which the graphic objects are associated.
30         --          It allows them to be globally manipulated.
31         --          It defines the global attributes.
32         --  Keywords: Structure, Structure Manager, Update Mode,
33         --     Destroy, Highlight, Visible, Detectable
34
35         ---Warning:
36         ---References:
37
38 uses
39
40         Array2OfReal            from TColStd,
41         SequenceOfInteger       from TColStd,
42
43         GenId                   from Aspect,
44         TypeOfHighlightMethod   from Aspect,
45         TypeOfUpdate            from Aspect,
46
47         DataStructureManager    from Graphic3d,
48         AspectFillArea3d        from Graphic3d,
49         AspectLine3d            from Graphic3d,
50         AspectMarker3d          from Graphic3d,
51         AspectText3d            from Graphic3d,
52         Structure               from Graphic3d,
53         MapOfStructure          from Graphic3d,
54         SequenceOfStructure     from Graphic3d,
55     GraphicDriver    from Graphic3d
56
57 raises
58
59         InitialisationError     from Graphic3d
60
61 is
62
63         Initialize ( theDriver: GraphicDriver from Graphic3d )
64         ---Level: Public
65         ---Purpose: Initialises the ViewManager.
66         --  Currently creating of more than 100 viewer instances 
67         --  is not supported and leads to InitializationError and 
68         --  initialisation failure.
69         --  This limitation might be addressed in some future OCCT releases.   
70         --  Warning: Raises InitialisationError if the initialisation
71         --          of the ViewManager failed.
72         raises InitialisationError from Graphic3d;
73         -- if the initialisation of the ViewManager failed.
74
75         Destroy ( me     : mutable )
76                 is virtual;
77         ---Level: Public
78         ---Purpose: Deletes the manager <me>.
79         ---C++: alias ~
80
81         ---------------------------------------------------
82         -- Category: Methods to modify the class definition
83         ---------------------------------------------------
84
85         SetPrimitivesAspect ( me        : mutable;
86                               CTX       : AspectLine3d from Graphic3d )
87                 is static;
88         ---Level: Public
89         ---Purpose: Modifies the default attributes for lines
90         --          in the visualiser.
91         ---Category: Methods to modify the class definition
92
93         SetPrimitivesAspect ( me        : mutable;
94                               CTX       : AspectFillArea3d from Graphic3d)
95                 is static;
96         ---Level: Public
97         ---Purpose: Modifies the default attributes for faces
98         --          in the visualiser.
99         ---Category: Methods to modify the class definition
100
101         SetPrimitivesAspect ( me        : mutable;
102                               CTX       : AspectText3d from Graphic3d )
103                 is static;
104         ---Level: Public
105         ---Purpose: Modifies the default attributes for text
106         --          in the visualiser.
107         ---Category: Methods to modify the class definition
108
109         SetPrimitivesAspect ( me        : mutable;
110                               CTX       : AspectMarker3d from Graphic3d)
111                 is static;
112         ---Level: Public
113         ---Purpose: Modifies the default attributes for markers
114         --          in the visualiser.
115         ---Category: Methods to modify the class definition
116
117         ---------------------------------------------------
118         -- Summary of Dynamic Operations and Update Mode --
119         --                                               --
120         -- Use SetUpdateMode  to control when changes to --
121         -- the display are made.                         --
122         --                                               --
123         -- Use one of the  following functions to update --
124         -- one or more views :                           --
125         --                                               --
126         --      Update all views of the viewer :         --
127         --      Visual3d_ViewManager::Update ()          --
128         --                                               --
129         --      Update one view of the viewer            --
130         --      Visual3d_View::Update ()                 --
131         --                                               --
132         -- Use one of the  following functions to update --
133         -- the entire display :                          --
134         --                                               --
135         --      Redraw all structures in all views :     --
136         --      Visual3d_ViewManager::Redraw ()          --
137         --                                               --
138         --      Redraw all structures in one view :      --
139         --      Visual3d_View::Redraw ()                 --
140         ---------------------------------------------------
141
142         SetUpdateMode ( me      : mutable;
143                         AType   : TypeOfUpdate from Aspect )
144                 is static;
145         ---Level: Public
146         ---Purpose: Modifies the screen update mode.
147         --
148         --          TOU_ASAP    as soon as possible
149         --          TOU_WAIT    on demand (with the Update function)
150         --  Note : Dynamic Operations and Update Mode
151         -- Use SetUpdateMode to control when changes to
152         -- the display are made.   Use one of the   following
153         -- functions to update one or more views:
154         -- -   Update all views of the viewer:   Visual3d_ViewManager::Update ()
155         -- -   Update one view of the viewer:   Visual3d_View::Update () Use one of
156         --   the   following functions to update the entire display:
157         -- -   Redraw all structures in all views:   Visual3d_ViewManager::Redraw ()
158         -- -   Redraw all structures in one view:   Visual3d_View::Redraw ()  Update)
159
160         Update ( me )
161                 is deferred;
162         ---Purpose: Updates screen in function of modifications of
163         --          the structures.
164         -- Warning: Not necessary if the update mode is TOU_ASAP.
165
166         ---------------------------------------------
167         -- Category: Inquire methods, MapOfStructure
168         ---------------------------------------------
169
170         DisplayedStructures ( me; SG: in out MapOfStructure  from Graphic3d)
171                 is static;
172         ---Level: Internal
173         ---Purpose: Returns the set of structures displayed in
174         --          visualiser <me>.
175         ---Category: Inquire methods, MapOfStructure
176
177         NumberOfDisplayedStructures ( me )
178                 returns Integer from Standard
179                 is static protected;
180         ---Level: Internal
181         ---Purpose: Returns the number of structures displayed in
182         --          visualiser <me>.
183
184         --DisplayedStructure ( me;
185                 --           AnIndex    : Integer from Standard )
186                 --returns Structure from Graphic3d
187                 --is static protected;
188         ---Level: Internal
189         ---Purpose: Returns the structure displayed in visualiser <me>.
190
191         HighlightedStructures ( me; SG: in out MapOfStructure from Graphic3d )
192                 is static;
193         ---Level: Internal
194         ---Purpose: Returns the set of highlighted structures
195         --          in a visualiser <me>.
196         ---Category: Inquire methods, MapOfStructure
197
198         PickStructures ( me; SG: in out MapOfStructure from Graphic3d )
199                 is static;
200         ---Level: Internal
201         ---Purpose: Returns the set of detectable structures
202         --          in a visualiser <me>.
203         ---Category: Inquire methods, MapOfStructure
204
205         ----------------------------
206         -- Category: Inquire methods
207         ----------------------------
208
209         FillArea3dAspect ( me )
210                 returns AspectFillArea3d from Graphic3d
211                 is static;
212         ---Level: Public
213         ---Purpose: Returns the values of the current default attributes.
214         ---Category: Inquire methods
215
216         Limit ( myclass )
217                 returns Integer from Standard;
218         ---Level: Internal
219         ---Purpose: Returns maximum number of managers defineable.
220         ---Category: Inquire methods
221
222         Line3dAspect ( me )
223                 returns AspectLine3d from Graphic3d
224                 is static;
225         ---Level: Public
226         ---Purpose: Returns the values of the current default attributes.
227         ---Category: Inquire methods
228
229         Marker3dAspect ( me )
230                 returns AspectMarker3d from Graphic3d
231                 is static;
232         ---Level: Public
233         ---Purpose: Returns the values of the current default attributes.
234         ---Category: Inquire methods
235
236         MinMaxValues ( me;
237                        XMin, YMin, ZMin : out Real from Standard;
238                        XMax, YMax, ZMax : out Real from Standard )
239                 is static;
240         ---Level: Public
241         ---Purpose: Returns the coordinates of the boundary box of all
242         --          structures displayed in the manager <me>.
243         ---Category: Inquire methods
244
245         PrimitivesAspect ( me;
246                            CTXL : out AspectLine3d from Graphic3d;
247                            CTXT : out AspectText3d from Graphic3d;
248                            CTXM : out AspectMarker3d from Graphic3d;
249                            CTXF : out AspectFillArea3d from Graphic3d )
250                 is static;
251         ---Level: Public
252         ---Purpose: Returns the values of the current default attributes.
253         ---Category: Inquire methods
254
255         Text3dAspect ( me )
256                 returns AspectText3d from Graphic3d
257                 is static;
258         ---Level: Public
259         ---Purpose: Returns the values of the current default attributes.
260         ---Category: Inquire methods
261
262         UpdateMode ( me )
263                 returns TypeOfUpdate from Aspect
264                 is static;
265         ---Level: Public
266         ---Purpose: Returns the screen update mode.
267         --
268         --          TOU_ASAP    as soon as possible
269         --          TOU_WAIT    on demand (Update)
270         --
271         ---Category: Inquire methods
272
273         ----------------------------
274         -- Category: Private methods
275         ----------------------------
276
277         ChangeDisplayPriority ( me              : mutable;
278                                 AStructure      : Structure from Graphic3d;
279                                 OldPriority     : Integer from Standard;
280                                 NewPriority     : Integer from Standard )
281                 is deferred;
282         ---Level: Internal
283         ---Purpose: Changes the display priority of the structure <AStructure>.
284         ---Category: Private methods
285
286         ChangeZLayer ( me           : mutable;
287                        theStructure : Structure from Graphic3d;
288                        theLayerId   : Integer from Standard )
289            is deferred;
290         ---Purpose: Change Z layer for structure. The z layer mechanism allows
291         -- to display structures in higher layers in overlay of structures in
292         -- lower layers.
293
294         GetZLayer ( me;
295                     theStructure : Structure from Graphic3d )
296            returns Integer from Standard is deferred;
297         ---Purpose: Get Z layer ID assigned to structure. If the structure
298         -- has no layer ID (deleted from graphic driver), the method returns -1.
299
300         AddZLayer ( me : mutable;
301                     theLayerId : in out Integer from Standard )
302            returns Boolean from Standard is deferred;
303         ---Purpose: Add a new top-level Z layer and get its ID as
304         -- <theLayerId> value. The method returns Standard_False if the layer
305         -- can not be created. The z layer mechanism allows to display
306         -- structures in higher layers in overlay of structures in lower layers.
307
308         RemoveZLayer ( me : mutable;
309                        theLayerId : Integer from Standard )
310            returns Boolean from Standard is deferred;
311         ---Purpose: Remove Z layer with ID <theLayerId>. Method returns
312         -- Standard_False if the layer can not be removed or doesn't exists.
313         -- By default, there is always a default bottom-level layer that can't
314         -- be removed.
315
316         GetAllZLayers ( me;
317                         theLayerSeq : out SequenceOfInteger from TColStd )
318            is deferred;
319         ---Purpose: Return all Z layer ids in sequence ordered by level
320         -- from lowest layer to highest. The first layer ID in sequence is
321         -- the default layer that can't be removed.
322
323         CurrentId ( myclass )
324                 returns Integer from Standard;
325         ---Level: Internal
326         ---Purpose: Returns a current identifier available.
327         ---Category: Private methods
328
329         ReCompute ( me          : mutable;
330                     AStructure  : Structure from Graphic3d )
331                 is deferred;
332         ---Level: Advanced
333         ---Purpose: Forces a new construction of the structure <AStructure>
334         --          if <AStructure> is displayed and TOS_COMPUTED.
335         ---Category: Private methods
336
337         ReCompute ( me          : mutable;
338                     AStructure  : Structure from Graphic3d;
339                     AProjector  : DataStructureManager from Graphic3d )
340                 is deferred;
341         ---Level: Advanced
342         ---Purpose: Forces a new construction of the structure <AStructure>
343         --          if <AStructure> is displayed in <AProjector> and TOS_COMPUTED.
344         ---Category: Private methods
345
346         Detectable ( me         : mutable;
347                      AStructure : Structure from Graphic3d )
348                 is static private;
349         ---Level: Internal
350         ---Purpose: Sets detectable the structure <AStructure>.
351         ---Category: Private methods
352
353         Clear ( me              : mutable;
354                 AStructure      : Structure from Graphic3d;
355                 WithDestruction : Boolean from Standard )
356                 is deferred;
357         ---Level: Internal
358         ---Purpose: Clears the structure <AStructure>.
359         ---Category: Private methods
360
361         Connect ( me            : mutable;
362                   AMother       : Structure from Graphic3d;
363                   ADaughter     : Structure from Graphic3d )
364                 is deferred;
365         ---Level: Internal
366         ---Purpose: Connects the structures <AMother> and <ADaughter>.
367         ---Category: Private methods
368
369         Disconnect ( me         : mutable;
370                      AMother    : Structure from Graphic3d;
371                      ADaughter  : Structure from Graphic3d )
372                 is deferred;
373         ---Level: Internal
374         ---Purpose: Disconnects the structures <AMother> and <ADaughter>.
375         ---Category: Private methods
376
377         Display ( me            : mutable;
378                   AStructure    : Structure from Graphic3d )
379                 is deferred;
380         ---Level: Internal
381         ---Purpose: Display the structure <AStructure>.
382         ---Category: Private methods
383
384         Erase ( me              : mutable;
385                 AStructure      : Structure from Graphic3d )
386                 is deferred;
387         ---Level: Internal
388         ---Purpose: Erases the structure <AStructure>.
389         ---Category: Private methods
390
391         Highlight ( me          : mutable;
392                     AStructure  : Structure from Graphic3d;
393                     AMethod     : TypeOfHighlightMethod from Aspect )
394                 is deferred;
395         ---Level: Internal
396         ---Purpose: Highlights the structure <AStructure>.
397         ---Category: Private methods
398
399         SetTransform ( me               : mutable;
400                        AStructure       : Structure from Graphic3d;
401                        ATrsf            : Array2OfReal from TColStd )
402                 is deferred;
403         ---Level: Internal
404         ---Purpose: Transforms the structure <AStructure>.
405         ---Category: Private methods
406
407         GraphicDriver ( me )
408                 returns GraphicDriver from Graphic3d;
409         ---Level: Internal
410         ---Purpose: Returns the graphic driver of <me>.
411         ---Category: Private methods
412   ---C++: return const &
413
414         Identification ( me )
415                 returns Integer from Standard
416                 is virtual;
417         ---Level: Internal
418         ---Purpose: Returns the identification number of the manager.
419         ---Category: Private methods
420
421         Identification ( me;
422                          AId    : Integer from Standard )
423                 returns Structure from Graphic3d
424                 is virtual;
425         ---Level: Internal
426         ---Purpose: Returns the structure with the identification number <AId>.
427         ---Warning: Returns a null structure if the identification number
428         --          is not a structure identifier.
429         ---Category: Private methods
430
431         NewIdentification ( me  : mutable )
432                 returns Integer from Standard
433                 is static private;
434         ---Level: Internal
435         ---Purpose: Returns a new identification number for a new structure
436         --          in the manager.
437         ---Category: Private methods
438
439         Remove ( me     : mutable;
440                  AnId   : Integer from Standard )
441                 is static private;
442         ---Level: Internal
443         ---Purpose: Frees the identifieur <AnId>.
444         ---Category: Private methods
445
446         Undetectable ( me               : mutable;
447                        AStructure       : Structure from Graphic3d )
448                 is static private;
449         ---Level: Internal
450         ---Purpose: Sets no detectable the structure <AStructure>.
451         ---Category: Private methods
452
453         UnHighlight ( me                : mutable )
454                 is deferred;
455         ---Level: Internal
456         ---Purpose: Suppresses the highlighting on all the structures in <me>.
457         ---Category: Private methods
458
459         UnHighlight ( me                : mutable;
460                       AStructure        : Structure from Graphic3d )
461                 is deferred;
462         ---Level: Internal
463         ---Purpose: Suppress the highlighting on the structure <AStructure>.
464         ---Category: Private methods
465
466   ReComputeStructures (me: mutable);
467   -- Purpose: Recomputes all displayed structures. Used to recompute GL
468   -- resources after the last view has been closed without removing objects.
469
470 --\f
471
472 fields
473
474 --
475 -- Class        :       Graphic3d_StructureManager
476 --
477 -- Purpose      :       Declaration of variables specific to managers
478 --
479 -- Reminder     :       A manager manipulates a group of structures
480
481         -- the identifier of the manager
482         MyId                    :       Integer from Standard is protected;
483
484         -- the update display mode
485         MyUpdateMode            :       TypeOfUpdate from Aspect is protected;
486
487         -- the different contexts for primitives
488         MyAspectLine3d          :       AspectLine3d from Graphic3d
489                                                                 is protected;
490         MyAspectText3d          :       AspectText3d from Graphic3d
491                                                                 is protected;
492         MyAspectMarker3d        :       AspectMarker3d from Graphic3d
493                                                                 is protected;
494         MyAspectFillArea3d      :       AspectFillArea3d from Graphic3d
495                                                                 is protected;
496
497         -- the displayed structures
498         MyDisplayedStructure    :       MapOfStructure from Graphic3d
499                                                                 is protected;
500
501         -- the highlighted structures
502         MyHighlightedStructure  :       MapOfStructure from Graphic3d
503                                                                 is protected;
504
505         -- the pickable structures
506         MyPickStructure         :       MapOfStructure from Graphic3d
507                                                                 is protected;
508
509         -- the structure identifier generator
510         MyStructGenId           :       GenId from Aspect is protected;
511
512
513         MyGraphicDriver         :       GraphicDriver from Graphic3d is protected;
514
515 friends
516
517         class Structure from Graphic3d
518
519 end StructureManager;