0024023: Revamp the OCCT Handle -- ambiguity
[occt.git] / src / AIS / AIS_LocalContext.cdl
1 -- Created on: 1996-09-04
2 -- Created by: Robert COUBLANC
3 -- Copyright (c) 1996-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
5 --
6 -- This file is part of Open CASCADE Technology software library.
7 --
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.
13 --
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
16
17 -- Modified     May  20th 98  :  
18 --              Modification in Management of selected entities 
19 --              Now we store the selected entity Owner in AIS_Selection.
20 --              (no more links with Session...)
21 --              Modifications in Management of hilight of detected entities
22 --              VTN 23/11/99 BUC60614 Avoid to crash because
23 --              myStdFilters array is too short.
24
25 class LocalContext from AIS inherits TShared from MMgt
26
27         ---Purpose: Defines a specific context  for selection.      
28         --          It becomes possible to:
29         --          +  Load  InteractiveObjects  with   a mode   to be
30         --          activated +  associate InteractiveObjects   with a
31         --          set of  temporary   selectable Objects....   +   +
32         --          activate StandardMode  of selection  for  Entities
33         --          inheriting  BasicShape  from  AIS (Selection    Of
34         --          vertices, edges,   wires,faces...  + Add   Filters
35         --          acting on detected owners of sensitive primitives
36         --          
37         --          
38         --          -     automatically    highlight   shapes   and
39         --          InteractiveObjects  (highlight of  detected shape +
40         --          highlight of detected selectable...
41         --          
42
43 uses
44     AsciiString               from TCollection,
45     ListOfInteger             from TColStd,
46     SequenceOfInteger         from TColStd,
47     MapOfTransient            from TColStd,
48     Array1OfPnt2d             from TColgp,
49     NameOfColor               from Quantity,
50     ShapeEnum                 from TopAbs,    
51     Shape                     from TopoDS,
52     View                      from V3d,
53     PresentationManager3d     from PrsMgr,
54     IndexedMapOfOwner         from SelectMgr,
55     EntityOwner               from SelectMgr,
56     OrFilter                  from SelectMgr,
57     Filter                    from SelectMgr,
58     SelectionManager          from SelectMgr,
59     SelectableObject          from SelectMgr ,
60     ListOfFilter              from SelectMgr,
61     BRepOwner                 from StdSelect,
62     ViewerSelector3d          from StdSelect,
63     SensitivityMode           from StdSelect,
64     InteractiveContext        from AIS,
65     ClearMode                 from AIS,
66     InteractiveObject         from AIS,
67     Shape                     from AIS,
68     DataMapOfSelStat          from AIS,
69     LocalStatus               from AIS, 
70     StatusOfPick              from AIS,
71     StatusOfDetection         from AIS,
72     SequenceOfInteractive     from AIS
73
74 is
75
76     Create returns LocalContext from AIS;
77     
78
79     Create (aCtx                : InteractiveContext from AIS;
80             anIndex             : Integer from Standard;
81             LoadDisplayed       : Boolean from Standard=Standard_True;
82             AcceptStandardModes : Boolean from Standard=Standard_True;
83             AcceptErase         : Boolean from Standard= Standard_False;
84             UseBothViewers      : Boolean from Standard= Standard_False)
85             returns LocalContext from AIS;
86     ---Purpose: Constructor By Default, the  displayed objects are 
87     --          automatically loaded.
88
89
90     AcceptErase(me:mutable;aStatus : Boolean from Standard);
91     ---C++: inline
92     ---Purpose: authorize or not others contexts to erase
93     --          temporary displayed objects here;
94
95     AcceptErase(me) returns Boolean from Standard;
96     ---C++: inline
97
98     SetContext(me:mutable;aCtx:InteractiveContext from AIS);
99     
100     SelectionName(me) returns AsciiString from TCollection;
101     ---C++: inline
102     ---C++: return const&
103
104
105     Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
106
107     Reactivate(me:mutable);
108     ---Purpose: to be called when a upper local context was closed...
109     --          useful to put pack the right projector...
110
111                             ---Category: LOAD AND PREPARE 
112                             --           - INTERACTIVE   OBJECTS...
113                             --           - FILTERS
114                             --           - STANDARD MODES OF ACTIVATION
115
116
117
118
119     Display(me               : mutable;
120             anInteractive    : InteractiveObject from AIS;
121             DisplayMode      : Integer from Standard = 0;
122             AllowShapeDecomposition: Boolean from Standard = Standard_True; 
123             ActivationMode : Integer from Standard = 0)
124     returns Boolean from Standard;
125     ---Purpose: returns true if done...
126
127     Load(me             : mutable;
128          anInteractive   : InteractiveObject from AIS;
129          AllowShapeDecomposition: Boolean from Standard = Standard_True; 
130          ActivationMode : Integer from Standard = 0)
131     returns Boolean from Standard;
132     ---Purpose: loads <anInteractive> with nodisplay...
133     --          returns true if done
134     
135     Erase(me: mutable;
136           anInteractive   : InteractiveObject from AIS)
137     returns Boolean from Standard;
138     ---Purpose: returns true if done...
139           
140          
141     Remove(me          : mutable;
142            aSelectable : InteractiveObject from AIS)
143     returns Boolean from Standard;
144
145           
146     ClearPrs (me             : mutable;
147               anInteractive  : InteractiveObject from AIS;
148               aMode          : Integer from Standard)
149     returns Boolean from Standard;
150           
151     SetShapeDecomposition(me            : mutable;
152                           aStoredObject : InteractiveObject from  AIS; 
153                           aStatus       : Boolean  from  Standard); 
154     ---Purpose: allows  or  forbids   the   shape  decomposition  into
155     --          Activated Standard   Mode  for   <aStoredObject> 
156     --          does nothing if the object doesn't inherits 
157     --          BasicShape from AIS
158     
159     
160     Clear(me:mutable;atype: ClearMode from AIS = AIS_CM_All);
161     ---Purpose: according to <atype>  , clears the  different parts of
162     --          the selector (filters, modeof activation, objects...)
163  
164
165
166
167     ActivateMode (me         : mutable; 
168                   aSelectable: InteractiveObject from AIS; 
169                   aMode      : Integer from Standard );
170     ---Purpose: optional : activation of a mode which is not 0 for a selectable...
171                       
172     DeactivateMode(me         : mutable; 
173                   aSelectable: InteractiveObject from AIS; 
174                   aMode      : Integer from Standard );
175     Deactivate(me         : mutable; 
176                   aSelectable: InteractiveObject from AIS);
177
178     ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
179     ---Purpose: decomposition of shapes into <aType>
180    
181     
182     DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
183
184     StandardModes(me) returns ListOfInteger from TColStd;
185     ---C++: return const &
186     ---C++: inline
187
188
189
190     AddFilter(me:mutable;aFilter:Filter from SelectMgr);
191
192     RemoveFilter(me:mutable;aFilter:     Filter from SelectMgr);
193
194     
195     ListOfFilter(me) returns ListOfFilter from SelectMgr;
196     ---C++: return const &
197     ---C++: inline
198
199     Filter(me) returns any OrFilter from SelectMgr;
200     ---C++: return const &
201     ---C++: inline
202     
203
204     SetAutomaticHilight(me:mutable ; aStatus:Boolean) ;
205     ---Purpose: if <aStatus> = True , the shapes or subshapes detected
206     --          by the selector will be automatically hilighted in the
207     --          main viewer.
208     --          Else the user has to manage the detected shape outside the
209     --          Shape Selector....
210     ---C++: inline
211
212
213
214     AutomaticHilight(me) returns Boolean;
215     ---C++: inline
216
217                     ---Category: THE SELECTION PROCESS
218
219     MoveTo (me                   : mutable;
220             theXpix, theYpix     : Integer from Standard;
221             theView              : View from V3d;
222             theToRedrawImmediate : Boolean from Standard)
223     returns StatusOfDetection from AIS;
224
225
226     HasNextDetected(me) returns Boolean from Standard;
227     ---C++: inline
228     ---Purpose: returns True if more than one entity
229     --          was detected at the last Mouse position.
230     
231     HilightNextDetected (me      : mutable;
232                          theView : View from V3d;
233                          theToRedrawImmediate : Boolean from Standard)
234     returns Integer from Standard;
235     ---Purpose: returns True if  last detected. the next detected will
236     --          be first one (endless loop)
237
238     HilightPreviousDetected (me                   : mutable;
239                              theView              : View from V3d;
240                              theToRedrawImmediate : Boolean from Standard)
241     returns Integer from Standard;
242
243     UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
244     ---Purpose: returns True if something was done...
245
246     Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
247     returns StatusOfPick from AIS;
248     ---Purpose: returns the number of selected
249     
250     ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
251     returns StatusOfPick from AIS;
252
253     Select(me                      : mutable;
254            XPMin,YPMin,XPMax,YPMax : Integer from Standard;
255            aView                   : View from V3d;
256            updateviewer            : Boolean from Standard = Standard_True)
257     returns StatusOfPick from AIS;
258
259
260     ShiftSelect(me                      : mutable;
261                 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
262                 aView                   : View from V3d;
263                 updateviewer            : Boolean from Standard = Standard_True)
264     returns StatusOfPick from AIS;
265
266     Select(me                      : mutable;
267            Polyline                : Array1OfPnt2d from TColgp;
268            aView                   : View from V3d;
269            updateviewer            : Boolean from Standard = Standard_True)
270     returns StatusOfPick from AIS;
271
272     ShiftSelect(me                      : mutable;
273                 Polyline                : Array1OfPnt2d from TColgp;
274                 aView                   : View from V3d;
275                 updateviewer            : Boolean from Standard = Standard_True)
276     returns StatusOfPick from AIS;
277
278     HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
279     
280     UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
281
282
283     UpdateSelected     (me           : mutable;
284                         updateviewer : Boolean from Standard = Standard_True); 
285
286     UpdateSelected     (me           : mutable;
287                         anobj        : InteractiveObject from AIS;
288                         updateviewer : Boolean from Standard = Standard_True); 
289     ---Purpose: Part of advanced selection highlighting mechanism.
290     --          If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
291     --          otherwise calls anobj->HilightSelected(). This method can be used to avoid
292     --          redrawing the whole selection belonging to several Selectable Objects.
293         
294
295     SetSelected(me           : mutable;
296                 anobj        : InteractiveObject from AIS;
297                 updateviewer : Boolean from Standard=Standard_True);
298     ---Purpose: useful  to  update selection with objects  coming from
299     --          Collector or stack
300
301     AddOrRemoveSelected(me           : mutable;
302                         anobj        : InteractiveObject from AIS;
303                         updateviewer : Boolean from Standard=Standard_True);
304     ---Purpose: useful  to  update selection with objects  coming from
305     --          Collector or stack
306     AddOrRemoveSelected(me           : mutable;
307                         aShape       : Shape from TopoDS;
308                         updateviewer : Boolean from Standard=Standard_True);
309
310     AddOrRemoveSelected(me             : mutable;
311                         theOwner       : EntityOwner from SelectMgr;
312                         toUpdateViewer : Boolean from Standard = Standard_True);
313
314     ClearSelected (me             : mutable;
315                    toUpdateViewer : Boolean from Standard = Standard_True);
316     ---Purpose: Clears local context selection.
317     --          @param toUpdateViewer [in] if TRUE the viewer will be updated.
318
319     ClearOutdatedSelection (me                 : mutable;
320                             theIO              : InteractiveObject from AIS;
321                             toClearDeactivated : Boolean from Standard);
322     ---Purpose: Clears outdated selection and detection of owners for the
323     --          interactive object. Use this method if selection structures
324     --          of the interactive object have changed. The method unhilights
325     --          and removes outdated entity owners from lists of selected
326     --          and detected owners.
327     --          @param theIO [in] the interactive object.
328     --          @param toClearDeactivated [in] pass TRUE to treat deactivated
329     --                 entity owners as 'outdated' when clearing the selection.
330
331                     ---Category: GET THE DETECTED
332
333     HasDetected     (me) returns Boolean from Standard;
334     ---C++: inline
335
336     InitDetected(me: mutable);
337     ---Purpose:
338     -- Initialization for iteration through mouse-detected objects in local context.
339
340     MoreDetected(me) returns Boolean from Standard;
341     ---Purpose:
342     -- @return true if there is more mouse-detected objects after the current one
343     -- during iteration through mouse-detected interactive objects.
344
345     NextDetected(me: mutable);
346     ---Purpose:
347     -- Gets next current object during iteration through mouse-detected
348     -- interactive objects.
349
350     DetectedCurrentShape(me) returns Shape from TopoDS;
351     ---C++: return const &
352     ---Purpose:
353     -- @return current mouse-detected shape or empty (null) shape, if current interactive object
354     -- is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
355
356     DetectedCurrentObject(me) returns InteractiveObject from AIS;
357     ---Purpose:
358     -- @return current mouse-detected interactive object or null object if there is no current detected.
359
360     HasDetectedShape(me) returns Boolean from Standard;
361     DetectedShape   (me) returns Shape from TopoDS;
362     ---C++: return const &
363     DetectedInteractive(me) returns InteractiveObject from AIS;
364     DetectedOwner   (me) returns EntityOwner from SelectMgr;
365
366
367                     ---Category: GET THE SELECTED
368
369     InitSelected     (me: mutable);
370     MoreSelected(me) returns Boolean from Standard;
371     NextSelected(me:mutable);
372     HasShape(me) returns Boolean from Standard;
373     ---Purpose: returns TRUE if the detected entity is a shape
374     --          coming from a Decomposition of an element.
375     HasSelectedShape(me) returns Boolean from Standard;
376     ---Purpose: returns true if current selection is not empty
377     --          and the owner of selected object contains a shape.
378     --          This method does not take into account decomposition
379     --          status of detected shape.
380     SelectedShape(me) returns Shape from TopoDS;
381
382     SelectedOwner(me) returns EntityOwner from SelectMgr;
383     IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean  from  Standard;
384     IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
385     SelectedInteractive(me) returns InteractiveObject from AIS;
386     HasApplicative (me) returns Boolean from Standard;
387     ---Purpose: returns TRUE if an interactive element
388     --          was associated with the current picked entity.
389     SelectedApplicative(me) returns any Transient from Standard;
390     ---C++: return const &
391
392
393
394
395
396
397                   ---Category: Management Of Temporary Attributes
398
399     SetDisplayPriority(me      : mutable;
400                        anObject: InteractiveObject from AIS;
401                        Prior   : Integer from Standard);
402
403     DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
404     returns Integer from Standard;
405
406     IsIn(me;anObject : InteractiveObject from AIS)
407     returns Boolean from Standard;
408
409
410     IsDisplayed(me;anObject : InteractiveObject from AIS)
411     returns Boolean from Standard;
412
413     IsDisplayed(me;anObject : InteractiveObject from AIS;
414                 aMode : Integer from Standard)
415     returns Boolean from Standard;
416
417     SelectionModes(me;anObject:InteractiveObject from AIS)
418     returns ListOfInteger from TColStd;
419     ---C++: return const &
420
421     SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS ); 
422  
423     SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS ); 
424     
425     Hilight(me: mutable; anObject  : InteractiveObject from AIS);
426
427     Hilight(me:mutable; anObject  : InteractiveObject from AIS;aCol:NameOfColor  from  Quantity);
428
429     Unhilight(me:mutable; anObject : InteractiveObject from AIS);
430
431     IsHilighted(me;anObject : InteractiveObject from AIS)
432     returns Boolean from Standard;
433
434     IsHilighted(me;
435                 anObject  : InteractiveObject from AIS;
436                 WithColor : out Boolean from Standard;
437                 HiCol     : out NameOfColor from Quantity)
438     returns Boolean from Standard;
439
440     SetPixelTolerance(me:mutable;
441                         aPrecision: Real from Standard = 2);
442     ---Level: Public
443     ---Purpose: Define the current selection sensitivity for
444     --          this local context according to the view size.
445
446     PixelTolerance(me) returns Real from Standard;
447     ---Level: Public 
448     ---Purpose: Returns the pixel tolerance.
449
450                         ---Category: IMMEDIATE MODE
451
452
453     BeginImmediateDraw (me : mutable)
454     returns Boolean from Standard;
455     ---Purpose: Resets the transient list of presentations previously displayed in immediate mode
456     -- and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls.
457
458     ClearImmediateDraw (me : mutable) is virtual;
459     ---Purpose: Resets the transient list of presentations previously displayed in immediate mode.
460
461     ImmediateAdd (me : mutable;
462                   theObj  : InteractiveObject from AIS;
463                   theMode : Integer from Standard = 0)
464     returns Boolean from Standard;
465     ---Purpose: Stores presentation theMode of object theObj in the transient list of presentations to be displayed in immediate mode.
466     -- Will be taken in account in EndImmediateDraw method.
467
468     EndImmediateDraw (me      : mutable;
469                       theView : View from V3d)
470     returns Boolean from Standard;
471     ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background.
472
473     IsImmediateModeOn (me) returns Boolean from Standard;
474     ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode.
475
476                             ---Category: INTERNAL METHODS;
477
478
479     Status(me) returns AsciiString from TCollection;
480     
481     Status(me;anObject : InteractiveObject from AIS)
482     returns any LocalStatus from AIS;
483     ---C++: return const&
484
485
486
487     LoadContextObjects(me:mutable);
488
489     UnloadContextObjects(me:mutable);
490
491     Process(me       : mutable;
492             anObject : SelectableObject from SelectMgr) is static private;
493
494     Process(me:mutable) is static private;
495     
496
497     ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr)  is  static  private;
498
499     manageDetected (me                   : mutable;
500                     thePickOwner         : EntityOwner from SelectMgr;
501                     theView              : View from V3d;
502                     theToRedrawImmediate : Boolean from Standard) is static private;
503
504     DetectedIndex(me:mutable) returns Integer from Standard is static private;
505     ---C++: inline
506     ---Purpose: returns 0  if the detected entity was Not FilterOK...
507   
508     Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview:   View from V3d) is static  private; 
509     
510     
511     Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from  V3d) is static  private;
512
513   
514     ClearObjects(me:mutable) is static private;
515
516     ClearDetected(me:mutable) is static private;
517
518     IsDecompositionOn(me) returns Boolean from Standard is static private;
519     
520     IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
521
522     IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
523     
524     IsValidIndex(me;anIndex:Integer from Standard) 
525     returns Boolean from Standard is static private;    
526     ---C++: inline
527     
528     ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
529     returns Boolean from Standard is static private;
530
531     HasFilters(me;aType:ShapeEnum from TopAbs) 
532     returns Boolean from Standard is private;
533     
534     DisplaySensitive(me:mutable;aView : View from V3d) is static; 
535     
536     ClearSensitive(me:mutable;aView:View from V3d) is static;
537
538     MainSelector(me) returns ViewerSelector3d from StdSelect;
539     ---C++: inline
540     ---C++: return const&
541
542     FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
543     returns EntityOwner from SelectMgr;
544
545     FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
546     returns EntityOwner from SelectMgr;
547
548
549
550 fields
551
552     myCTX                              : InteractiveContext from AIS;
553     myLoadDisplayed,myAcceptStdMode    : Boolean from Standard;
554     myAcceptErase                      : Boolean from Standard;        
555
556     mySM               : SelectionManager      from SelectMgr;
557     myMainVS           : ViewerSelector3d      from StdSelect;
558     myMainPM           : PresentationManager3d from PrsMgr;
559     mySelName          : AsciiString           from TCollection;
560     myCollVS           : ViewerSelector3d      from StdSelect;
561     
562             -- The Objects and their attributes...
563     
564     myActiveObjects  : DataMapOfSelStat    from AIS;  
565     
566     
567             -- The  Filters...
568         
569     myFilters              : OrFilter      from SelectMgr;
570     myListOfStandardMode   : ListOfInteger from TColStd;
571
572     -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
573     myStdFilters : Filter from SelectMgr [9]; --internal mgt
574  
575             -- Selection Process
576
577     myAutoHilight  : Boolean                   from Standard;
578     myMapOfOwner   : IndexedMapOfOwner         from SelectMgr;
579     mylastindex    : Integer                   from Standard;
580     mylastgood     : Integer                   from Standard;
581     myCurrentOwner : Integer                   from Standard;          
582
583
584     myDetectedSeq  : SequenceOfInteger from TColStd;
585     myCurDetected  : Integer from Standard;
586
587    -- The detected objects.
588
589     myAISDetectedSeq : SequenceOfInteractive from AIS;
590     -- the sequence of detected interative objects.
591     myAISCurDetected : Integer from Standard;
592     -- current detected interactive object.
593     -- This variable is used by following functions:
594     -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
595     
596 end LocalContext;
597
598
599
600
601