0024428: Implementation of LGPL license
[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
9 -- under the terms of the GNU Lesser General Public 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 --   GG  : BUC60688 25/05/00 Add SetSensitivity() methods
25 --   GG  : IMP150501 Remove oboslete method DragTo
26 --              (See AIS_InteractiveContext)
27 --   ZSV : IMP160701 Add InitDetected(),MoreDetected(),NextDetected(),
28 --                       DetectedCurrentShape(),DetectedCurrentObject()
29 --                       methods
30
31
32 class LocalContext from AIS inherits TShared from MMgt
33
34         ---Purpose: Defines a specific context  for selection.      
35         --          It becomes possible to:
36         --          +  Load  InteractiveObjects  with   a mode   to be
37         --          activated +  associate InteractiveObjects   with a
38         --          set of  temporary   selectable Objects....   +   +
39         --          activate StandardMode  of selection  for  Entities
40         --          inheriting  BasicShape  from  AIS (Selection    Of
41         --          vertices, edges,   wires,faces...  + Add   Filters
42         --          acting on detected owners of sensitive primitives
43         --          
44         --          
45         --          -     automatically    highlight   shapes   and
46         --          InteractiveObjects  (highlight of  detected shape +
47         --          highlight of detected selectable...
48         --          
49
50 uses
51     AsciiString               from TCollection,
52     ListOfInteger             from TColStd,
53     SequenceOfInteger         from TColStd,
54     MapOfTransient            from TColStd,
55     Array1OfPnt2d             from TColgp,
56     NameOfColor               from Quantity,
57     ShapeEnum                 from TopAbs,    
58     Shape                     from TopoDS,
59     View                      from V3d,
60     PresentationManager3d     from PrsMgr,
61     Projector                 from Select3D,
62     IndexedMapOfOwner         from SelectMgr,
63     EntityOwner               from SelectMgr,
64     OrFilter                  from SelectMgr,
65     Filter                    from SelectMgr,
66     SelectionManager          from SelectMgr,
67     SelectableObject          from SelectMgr ,
68     ListOfFilter              from SelectMgr,
69     BRepOwner                 from StdSelect,
70     ViewerSelector3d          from StdSelect,
71     SensitivityMode           from StdSelect,
72     InteractiveContext        from AIS,
73     ClearMode                 from AIS,
74     InteractiveObject         from AIS,
75     Shape                     from AIS,
76     DataMapOfSelStat          from AIS,
77     LocalStatus               from AIS, 
78     StatusOfPick              from AIS,
79     StatusOfDetection         from AIS,
80     SequenceOfInteractive     from AIS
81
82 is
83
84     Create returns mutable LocalContext from AIS;
85     
86
87     Create (aCtx                : InteractiveContext from AIS;
88             anIndex             : Integer from Standard;
89             LoadDisplayed       : Boolean from Standard=Standard_True;
90             AcceptStandardModes : Boolean from Standard=Standard_True;
91             AcceptErase         : Boolean from Standard= Standard_False;
92             UseBothViewers      : Boolean from Standard= Standard_False)
93             returns mutable LocalContext from AIS;
94     ---Purpose: Constructor By Default, the  displayed objects are 
95     --          automatically loaded.
96
97
98     AcceptErase(me:mutable;aStatus : Boolean from Standard);
99     ---C++: inline
100     ---Purpose: authorize or not others contexts to erase
101     --          temporary displayed objects here;
102
103     AcceptErase(me) returns Boolean from Standard;
104     ---C++: inline
105
106     SetContext(me:mutable;aCtx:InteractiveContext from AIS);
107     
108     SelectionName(me) returns AsciiString from TCollection;
109     ---C++: inline
110     ---C++: return const&
111
112
113     Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
114
115     HasSameProjector(me;aPrj:Projector from Select3D)
116     returns Boolean from Standard;
117     ---Purpose: compares the current projector of the localContext
118     --          with <aPrj>
119     --          returns True if the projectors are identical.
120     --          (no need to update projection of selection primitives
121     --          when closing the local context)....
122
123     Reactivate(me:mutable);
124     ---Purpose: to be called when a upper local context was closed...
125     --          useful to put pack the right projector...
126
127                             ---Category: LOAD AND PREPARE 
128                             --           - INTERACTIVE   OBJECTS...
129                             --           - FILTERS
130                             --           - STANDARD MODES OF ACTIVATION
131
132
133
134
135     Display(me               : mutable;
136             anInteractive    : InteractiveObject from AIS;
137             DisplayMode      : Integer from Standard = 0;
138             AllowShapeDecomposition: Boolean from Standard = Standard_True; 
139             ActivationMode : Integer from Standard = 0)
140     returns Boolean from Standard;
141     ---Purpose: returns true if done...
142
143     Load(me             : mutable;
144          anInteractive   : InteractiveObject from AIS;
145          AllowShapeDecomposition: Boolean from Standard = Standard_True; 
146          ActivationMode : Integer from Standard = 0)
147     returns Boolean from Standard;
148     ---Purpose: loads <anInteractive> with nodisplay...
149     --          returns true if done
150     
151     Erase(me: mutable;
152           anInteractive   : InteractiveObject from AIS)
153     returns Boolean from Standard;
154     ---Purpose: returns true if done...
155           
156          
157     Remove(me          : mutable;
158            aSelectable : InteractiveObject from AIS)
159     returns Boolean from Standard;
160
161           
162     ClearPrs (me             : mutable;
163               anInteractive  : InteractiveObject from AIS;
164               aMode          : Integer from Standard)
165     returns Boolean from Standard;
166           
167     SetShapeDecomposition(me            : mutable;
168                           aStoredObject : InteractiveObject from  AIS; 
169                           aStatus       : Boolean  from  Standard); 
170     ---Purpose: allows  or  forbids   the   shape  decomposition  into
171     --          Activated Standard   Mode  for   <aStoredObject> 
172     --          does nothing if the object doesn't inherits 
173     --          BasicShape from AIS
174     
175     
176     Clear(me:mutable;atype: ClearMode from AIS = AIS_CM_All);
177     ---Purpose: according to <atype>  , clears the  different parts of
178     --          the selector (filters, modeof activation, objects...)
179  
180
181
182
183     ActivateMode (me         : mutable; 
184                   aSelectable: InteractiveObject from AIS; 
185                   aMode      : Integer from Standard );
186     ---Purpose: optional : activation of a mode which is not 0 for a selectable...
187                       
188     DeactivateMode(me         : mutable; 
189                   aSelectable: InteractiveObject from AIS; 
190                   aMode      : Integer from Standard );
191     Deactivate(me         : mutable; 
192                   aSelectable: InteractiveObject from AIS);
193
194     ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
195     ---Purpose: decomposition of shapes into <aType>
196    
197     
198     DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
199
200     StandardModes(me) returns ListOfInteger from TColStd;
201     ---C++: return const &
202     ---C++: inline
203
204
205
206     AddFilter(me:mutable;aFilter:Filter from SelectMgr);
207
208     RemoveFilter(me:mutable;aFilter:     Filter from SelectMgr);
209
210     
211     ListOfFilter(me) returns ListOfFilter from SelectMgr;
212     ---C++: return const &
213     ---C++: inline
214
215     Filter(me) returns any OrFilter from SelectMgr;
216     ---C++: return const &
217     ---C++: inline
218     
219
220     SetAutomaticHilight(me:mutable ; aStatus:Boolean) ;
221     ---Purpose: if <aStatus> = True , the shapes or subshapes detected
222     --          by the selector will be automatically hilighted in the
223     --          main viewer.
224     --          Else the user has to manage the detected shape outside the
225     --          Shape Selector....
226     ---C++: inline
227
228
229
230     AutomaticHilight(me) returns Boolean;
231     ---C++: inline
232
233
234
235                     ---Category: THE SELECTION PROCESS
236
237
238     MoveTo(me:mutable;Xpix,Ypix : Integer from Standard;
239                          aview : View from V3d)
240     returns StatusOfDetection from AIS;
241
242
243     HasNextDetected(me) returns Boolean from Standard;
244     ---C++: inline
245     ---Purpose: returns True if more than one entity
246     --          was detected at the last Mouse position.
247     
248     HilightNextDetected(me:mutable;aView:View from V3d)
249     returns Integer from Standard;
250     ---Purpose: returns True if  last detected. the next detected will
251     --          be first one (endless loop)
252
253     HilightPreviousDetected(me:mutable;aView:View from V3d)
254     returns Integer from Standard;
255
256     
257     UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
258     ---Purpose: returns True if something was done...
259
260     Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
261     returns StatusOfPick from AIS;
262     ---Purpose: returns the number of selected
263     
264     ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
265     returns StatusOfPick from AIS;
266
267     Select(me                      : mutable;
268            XPMin,YPMin,XPMax,YPMax : Integer from Standard;
269            aView                   : View from V3d;
270            updateviewer            : Boolean from Standard = Standard_True)
271     returns StatusOfPick from AIS;
272
273
274     ShiftSelect(me                      : mutable;
275                 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
276                 aView                   : View from V3d;
277                 updateviewer            : Boolean from Standard = Standard_True)
278     returns StatusOfPick from AIS;
279
280     Select(me                      : mutable;
281            Polyline                : Array1OfPnt2d from TColgp;
282            aView                   : View from V3d;
283            updateviewer            : Boolean from Standard = Standard_True)
284     returns StatusOfPick from AIS;
285
286     ShiftSelect(me                      : mutable;
287                 Polyline                : Array1OfPnt2d from TColgp;
288                 aView                   : View from V3d;
289                 updateviewer            : Boolean from Standard = Standard_True)
290     returns StatusOfPick from AIS;
291
292     HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
293     
294     UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
295
296
297     UpdateSelected     (me           : mutable;
298                         updateviewer : Boolean from Standard = Standard_True); 
299
300     UpdateSelected     (me           : mutable;
301                         anobj        : InteractiveObject from AIS;
302                         updateviewer : Boolean from Standard = Standard_True); 
303     ---Purpose: Part of advanced selection highlighting mechanism.
304     --          If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
305     --          otherwise calls anobj->HilightSelected(). This method can be used to avoid
306     --          redrawing the whole selection belonging to several Selectable Objects.
307         
308
309     SetSelected(me           : mutable;
310                 anobj        : InteractiveObject from AIS;
311                 updateviewer : Boolean from Standard=Standard_True);
312     ---Purpose: useful  to  update selection with objects  coming from
313     --          Collector or stack
314
315     AddOrRemoveSelected(me           : mutable;
316                         anobj        : InteractiveObject from AIS;
317                         updateviewer : Boolean from Standard=Standard_True);
318     ---Purpose: useful  to  update selection with objects  coming from
319     --          Collector or stack
320     AddOrRemoveSelected(me           : mutable;
321                         aShape       : Shape from TopoDS;
322                         updateviewer : Boolean from Standard=Standard_True);
323
324     AddOrRemoveSelected(me           : mutable;
325                         Ownr         : EntityOwner from SelectMgr;
326                         updateviewer : Boolean from Standard=Standard_True);
327
328
329
330     ClearSelected(me:mutable;updateviewer : Boolean from Standard=Standard_True);
331     ---Purpose: 
332
333                     
334                     ---Category: GET THE DETECTED
335
336
337     HasDetected     (me) returns Boolean from Standard;
338     ---C++: inline
339
340     InitDetected(me: mutable);
341     MoreDetected(me) returns Boolean from Standard;
342     NextDetected(me: mutable);
343     DetectedCurrentShape(me) returns Shape from TopoDS;
344     ---C++: return const &
345     DetectedCurrentObject(me) returns InteractiveObject from AIS;
346
347     HasDetectedShape(me) returns Boolean from Standard;
348     DetectedShape   (me) returns Shape from TopoDS;
349     ---C++: return const &
350     DetectedInteractive(me) returns InteractiveObject from AIS;
351     DetectedOwner   (me) returns EntityOwner from SelectMgr;
352
353
354                     ---Category: GET THE SELECTED
355
356     InitSelected     (me: mutable);
357     MoreSelected(me) returns Boolean from Standard;
358     NextSelected(me:mutable);
359     HasShape(me) returns Boolean from Standard;
360     ---Purpose: returns TRUE if the detected entity is a shape
361     --          coming from a Decomposition of an element.
362     SelectedShape(me) returns Shape from TopoDS;
363     ---C++: return const &
364
365     SelectedOwner(me) returns EntityOwner from SelectMgr;
366     IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean  from  Standard;
367     IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
368     SelectedInteractive(me) returns InteractiveObject from AIS;
369     HasApplicative (me) returns Boolean from Standard;
370     ---Purpose: returns TRUE if an interactive element
371     --          was associated with the current picked entity.
372     SelectedApplicative(me) returns any Transient from Standard;
373     ---C++: return const &
374
375
376
377
378
379
380                   ---Category: Management Of Temporary Attributes
381
382     SetDisplayPriority(me      : mutable;
383                        anObject: InteractiveObject from AIS;
384                        Prior   : Integer from Standard);
385
386     SetZLayer( me         : mutable;
387                theIObj    : InteractiveObject from AIS;
388                theLayerId : Integer from Standard );
389     ---Purpose: Set Z layer id for interactive object. The layer can be
390     -- specified for displayed object only. The Z layers can be used to display
391     -- temporarily presentations of some object in front of the other objects
392     -- in the scene. The ids for Z layers are generated by V3d_Viewer.
393     -- Note that Z layers differ from under-/overlayer in V3d_View:
394     -- under-/overlayer are intended for specific 2D drawings that appear
395     -- behind/in front of all 3D presentations, while SetZLayer() method
396     -- applies to regular 3D presentations and does not imply any specific
397     -- drawing methods.
398
399     GetZLayer( me;
400                theIObj : InteractiveObject from AIS )
401       returns Integer from Standard;
402     ---Purpose: Get Z layer id set for displayed interactive object.
403     -- If the object doesn't exists in context or has no computed presentations,
404     -- the method returns -1.
405
406     DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
407     returns Integer from Standard;
408
409     IsIn(me;anObject : InteractiveObject from AIS)
410     returns Boolean from Standard;
411
412
413     IsDisplayed(me;anObject : InteractiveObject from AIS)
414     returns Boolean from Standard;
415
416     IsDisplayed(me;anObject : InteractiveObject from AIS;
417                 aMode : Integer from Standard)
418     returns Boolean from Standard;
419
420     SelectionModes(me;anObject:InteractiveObject from AIS)
421     returns ListOfInteger from TColStd;
422     ---C++: return const &
423
424     SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS ); 
425  
426     SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS ); 
427     
428     Hilight(me: mutable; anObject  : InteractiveObject from AIS);
429
430     Hilight(me:mutable; anObject  : InteractiveObject from AIS;aCol:NameOfColor  from  Quantity);
431
432     Unhilight(me:mutable; anObject : InteractiveObject from AIS);
433
434     IsHilighted(me;anObject : InteractiveObject from AIS)
435     returns Boolean from Standard;
436
437     IsHilighted(me;
438                 anObject  : InteractiveObject from AIS;
439                 WithColor : out Boolean from Standard;
440                 HiCol     : out NameOfColor from Quantity)
441     returns Boolean from Standard;
442     
443     SetSensitivityMode(me    : mutable;
444                        aMode : SensitivityMode from StdSelect) is static;
445     ---Level: Public
446     ---Purpose: Sets the selection sensitivity mode. SM_WINDOW mode
447     -- uses the specified pixel tolerance to compute the sensitivity
448     -- value, SM_VIEW mode allows to define the sensitivity manually.
449
450     SensitivityMode(me) returns SensitivityMode from StdSelect;
451     ---Level: Public
452     ---Purpose: Returns the selection sensitivity mode.
453
454     SetSensitivity(me:mutable;
455                         aPrecision: Real from Standard);
456     ---Level: Public
457     ---Purpose: Define the current selection sensitivity for
458     --          this local context according to the view size.
459     
460     Sensitivity (me) returns Real from Standard;
461     ---Level: Public 
462     ---Purpose: Returns the selection sensitivity value.
463
464     SetPixelTolerance(me:mutable;
465                         aPrecision: Integer from Standard = 2);
466     ---Level: Public
467     ---Purpose: Define the current selection sensitivity for
468     --          this local context according to the view size.
469
470     PixelTolerance(me) returns Integer from Standard;
471     ---Level: Public 
472     ---Purpose: Returns the pixel tolerance.
473
474                         ---Category: IMMEDIATE MODE
475
476
477     BeginImmediateDraw (me:mutable)  returns Boolean from Standard;
478     ---Purpose: initializes the list of presentations to be displayed
479     --          returns False if No Local COnte
480
481     ImmediateAdd (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
482     returns Boolean from Standard;
483     ---Purpose: returns True if <anIObj> has been stored in the list.
484
485     ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
486     returns Boolean from Standard;
487     ---Purpose: returns True if <anIObj> has been removed from the list.
488
489     EndImmediateDraw(me:mutable;aView : View from V3d;DoubleBuf:Boolean from Standard=Standard_False)
490     returns Boolean from Standard;
491     ---Purpose: returns True if the immediate display has been done.
492
493     IsImmediateModeOn(me) returns Boolean from Standard;
494             
495                             ---Category: INTERNAL METHODS;
496
497     UpdateConversion(me:mutable);
498
499     UpdateSort(me:mutable);
500
501
502
503     Status(me) returns AsciiString from TCollection is private;
504     
505     Status(me;anObject : InteractiveObject from AIS)
506     returns any LocalStatus from AIS is private;
507     ---C++: return const&
508
509
510
511     LoadContextObjects(me:mutable);
512
513     UnloadContextObjects(me:mutable);
514
515     Process(me       : mutable;
516             anObject : SelectableObject from SelectMgr;
517             WithProj: Boolean from Standard = Standard_True) is static private;
518
519     Process(me:mutable;
520             WithProj: Boolean from Standard = Standard_True) is static private;
521     
522
523     ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
524             WithProj: Boolean from Standard = Standard_True)  is  static  private;
525
526     ManageDetected(me:mutable;
527                    aPickOwner : EntityOwner from SelectMgr;
528                    aview      : View  from  V3d) is static  private;
529
530     DetectedIndex(me:mutable) returns Integer from Standard is static private;
531     ---C++: inline
532     ---Purpose: returns 0  if the detected entity was Not FilterOK...
533   
534     Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview:   View from V3d) is static  private; 
535     
536     
537     Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from  V3d) is static  private;
538
539   
540     ClearObjects(me:mutable) is static private;
541
542     ClearDetected(me:mutable) is static private;
543
544     IsDecompositionOn(me) returns Boolean from Standard is static private;
545     
546     IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
547
548     IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
549     
550     IsValidIndex(me;anIndex:Integer from Standard) 
551     returns Boolean from Standard is static private;    
552     ---C++: inline
553     
554     ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
555     returns Boolean from Standard is static private;
556
557
558     DisplayAreas(me:mutable;aviou:View from V3d);
559     
560     ClearAreas (me:mutable;
561                 aView: View from V3d) is static;
562     ---Level: Internal 
563
564     HasFilters(me;aType:ShapeEnum from TopAbs) 
565     returns Boolean from Standard is private;
566     
567     DisplaySensitive(me:mutable;aView : View from V3d) is static; 
568     
569     ClearSensitive(me:mutable;aView:View from V3d) is static;
570
571
572         
573     MainSelector(me) returns any ViewerSelector3d from StdSelect;
574     ---C++: inline
575     ---C++: return const&
576
577
578     HilightTriangle(me:mutable;Rank:Integer from Standard;aViou:View from V3d) is static private;
579     ---Level: Internal 
580
581
582     FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
583     returns EntityOwner from SelectMgr;
584
585     FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
586     returns EntityOwner from SelectMgr;
587
588
589
590 fields
591
592     myCTX                              : InteractiveContext from AIS;
593     myLoadDisplayed,myAcceptStdMode    : Boolean from Standard;
594     myAcceptErase                      : Boolean from Standard;        
595
596     mySM               : SelectionManager      from SelectMgr;
597     myMainVS           : ViewerSelector3d      from StdSelect;
598     myMainPM           : PresentationManager3d from PrsMgr;
599     mySelName          : AsciiString           from TCollection;
600     myCollVS           : ViewerSelector3d      from StdSelect;
601     
602             -- The Objects and their attributes...
603     
604     myActiveObjects  : DataMapOfSelStat    from AIS;  
605     
606     
607             -- The  Filters...
608         
609     myFilters              : OrFilter      from SelectMgr;
610     myListOfStandardMode   : ListOfInteger from TColStd;
611
612     -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
613     myStdFilters : Filter from SelectMgr [9]; --internal mgt
614  
615             -- Selection Process
616
617     myAutoHilight  : Boolean                   from Standard;
618     myMapOfOwner   : IndexedMapOfOwner         from SelectMgr;
619     mylastindex    : Integer                   from Standard;
620     mylastgood     : Integer                   from Standard;
621     myCurrentOwner : Integer                   from Standard;          
622
623
624     myDetectedSeq  : SequenceOfInteger from TColStd;
625     myCurDetected  : Integer from Standard;
626
627    -- the detected objects.
628     myAISDetectedSeq : SequenceOfInteractive from AIS;
629     myAISCurDetected : Integer from Standard;
630     -- This variables is used by following functions:
631     -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
632     
633 friends 
634
635     KeepTemporary from  InteractiveContext from AIS(me:mutable;anIObj:InteractiveObject from AIS;WhichMode  :  Integer  from  Standard  =  -1) 
636
637 end LocalContext;
638
639
640
641
642