1 -- Created on: 1996-09-04
2 -- Created by: Robert COUBLANC
3 -- Copyright (c) 1996-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
21 -- Modified May 20th 98 :
22 -- Modification in Management of selected entities
23 -- Now we store the selected entity Owner in AIS_Selection.
24 -- (no more links with Session...)
25 -- Modifications in Management of hilight of detected entities
26 -- VTN 23/11/99 BUC60614 Avoid to crash because
27 -- myStdFilters array is too short.
28 -- GG : BUC60688 25/05/00 Add SetSensitivity() methods
29 -- GG : IMP150501 Remove oboslete method DragTo
30 -- (See AIS_InteractiveContext)
31 -- ZSV : IMP160701 Add InitDetected(),MoreDetected(),NextDetected(),
32 -- DetectedCurrentShape(),DetectedCurrentObject()
36 class LocalContext from AIS inherits TShared from MMgt
38 ---Purpose: Defines a specific context for selection.
39 -- It becomes possible to:
40 -- + Load InteractiveObjects with a mode to be
41 -- activated + associate InteractiveObjects with a
42 -- set of temporary selectable Objects.... + +
43 -- activate StandardMode of selection for Entities
44 -- inheriting BasicShape from AIS (Selection Of
45 -- vertices, edges, wires,faces... + Add Filters
46 -- acting on detected owners of sensitive primitives
49 -- - automatically highlight shapes and
50 -- InteractiveObjects (highlight of detected shape +
51 -- highlight of detected selectable...
55 AsciiString from TCollection,
56 ListOfInteger from TColStd,
57 SequenceOfInteger from TColStd,
58 MapOfTransient from TColStd,
59 Array1OfPnt2d from TColgp,
60 NameOfColor from Quantity,
61 ShapeEnum from TopAbs,
64 PresentationManager3d from PrsMgr,
65 Projector from Select3D,
66 IndexedMapOfOwner from SelectMgr,
67 EntityOwner from SelectMgr,
68 OrFilter from SelectMgr,
69 Filter from SelectMgr,
70 SelectionManager from SelectMgr,
71 SelectableObject from SelectMgr ,
72 ListOfFilter from SelectMgr,
73 BRepOwner from StdSelect,
74 ViewerSelector3d from StdSelect,
75 InteractiveContext from AIS,
77 InteractiveObject from AIS,
79 DataMapOfSelStat from AIS,
81 StatusOfPick from AIS,
82 StatusOfDetection from AIS,
83 SequenceOfInteractive from AIS
87 Create returns mutable LocalContext from AIS;
90 Create (aCtx : InteractiveContext from AIS;
91 anIndex : Integer from Standard;
92 LoadDisplayed : Boolean from Standard=Standard_True;
93 AcceptStandardModes : Boolean from Standard=Standard_True;
94 AcceptErase : Boolean from Standard= Standard_False;
95 UseBothViewers : Boolean from Standard= Standard_False)
96 returns mutable LocalContext from AIS;
97 ---Purpose: Constructor By Default, the displayed objects are
98 -- automatically loaded.
101 AcceptErase(me:mutable;aStatus : Boolean from Standard);
103 ---Purpose: authorize or not others contexts to erase
104 -- temporary displayed objects here;
106 AcceptErase(me) returns Boolean from Standard;
109 SetContext(me:mutable;aCtx:InteractiveContext from AIS);
111 SelectionName(me) returns AsciiString from TCollection;
113 ---C++: return const&
116 Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
118 HasSameProjector(me;aPrj:Projector from Select3D)
119 returns Boolean from Standard;
120 ---Purpose: compares the current projector of the localContext
122 -- returns True if the projectors are identical.
123 -- (no need to update projection of selection primitives
124 -- when closing the local context)....
126 Reactivate(me:mutable);
127 ---Purpose: to be called when a upper local context was closed...
128 -- useful to put pack the right projector...
130 ---Category: LOAD AND PREPARE
131 -- - INTERACTIVE OBJECTS...
133 -- - STANDARD MODES OF ACTIVATION
138 Display(me : mutable;
139 anInteractive : InteractiveObject from AIS;
140 DisplayMode : Integer from Standard = 0;
141 AllowShapeDecomposition: Boolean from Standard = Standard_True;
142 ActivationMode : Integer from Standard = 0)
143 returns Boolean from Standard;
144 ---Purpose: returns true if done...
147 anInteractive : InteractiveObject from AIS;
148 AllowShapeDecomposition: Boolean from Standard = Standard_True;
149 ActivationMode : Integer from Standard = 0)
150 returns Boolean from Standard;
151 ---Purpose: loads <anInteractive> with nodisplay...
152 -- returns true if done
155 anInteractive : InteractiveObject from AIS)
156 returns Boolean from Standard;
157 ---Purpose: returns true if done...
161 aSelectable : InteractiveObject from AIS)
162 returns Boolean from Standard;
165 ClearPrs (me : mutable;
166 anInteractive : InteractiveObject from AIS;
167 aMode : Integer from Standard)
168 returns Boolean from Standard;
170 SetShapeDecomposition(me : mutable;
171 aStoredObject : InteractiveObject from AIS;
172 aStatus : Boolean from Standard);
173 ---Purpose: allows or forbids the shape decomposition into
174 -- Activated Standard Mode for <aStoredObject>
175 -- does nothing if the object doesn't inherits
176 -- BasicShape from AIS
179 Clear(me:mutable;atype: ClearMode from AIS = AIS_CM_All);
180 ---Purpose: according to <atype> , clears the different parts of
181 -- the selector (filters, modeof activation, objects...)
186 ActivateMode (me : mutable;
187 aSelectable: InteractiveObject from AIS;
188 aMode : Integer from Standard );
189 ---Purpose: optional : activation of a mode which is not 0 for a selectable...
191 DeactivateMode(me : mutable;
192 aSelectable: InteractiveObject from AIS;
193 aMode : Integer from Standard );
194 Deactivate(me : mutable;
195 aSelectable: InteractiveObject from AIS);
197 ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
198 ---Purpose: decomposition of shapes into <aType>
201 DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
203 StandardModes(me) returns ListOfInteger from TColStd;
204 ---C++: return const &
209 AddFilter(me:mutable;aFilter:Filter from SelectMgr);
211 RemoveFilter(me:mutable;aFilter: Filter from SelectMgr);
214 ListOfFilter(me) returns ListOfFilter from SelectMgr;
215 ---C++: return const &
218 Filter(me) returns any OrFilter from SelectMgr;
219 ---C++: return const &
223 SetAutomaticHilight(me:mutable ; aStatus:Boolean) ;
224 ---Purpose: if <aStatus> = True , the shapes or subshapes detected
225 -- by the selector will be automatically hilighted in the
227 -- Else the user has to manage the detected shape outside the
228 -- Shape Selector....
233 AutomaticHilight(me) returns Boolean;
238 ---Category: THE SELECTION PROCESS
241 MoveTo(me:mutable;Xpix,Ypix : Integer from Standard;
242 aview : View from V3d)
243 returns StatusOfDetection from AIS;
246 HasNextDetected(me) returns Boolean from Standard;
248 ---Purpose: returns True if more than one entity
249 -- was detected at the last Mouse position.
251 HilightNextDetected(me:mutable;aView:View from V3d)
252 returns Integer from Standard;
253 ---Purpose: returns True if last detected. the next detected will
254 -- be first one (endless loop)
256 HilightPreviousDetected(me:mutable;aView:View from V3d)
257 returns Integer from Standard;
260 UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
261 ---Purpose: returns True if something was done...
263 Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
264 returns StatusOfPick from AIS;
265 ---Purpose: returns the number of selected
267 ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
268 returns StatusOfPick from AIS;
271 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
272 aView : View from V3d;
273 updateviewer : Boolean from Standard = Standard_True)
274 returns StatusOfPick from AIS;
277 ShiftSelect(me : mutable;
278 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
279 aView : View from V3d;
280 updateviewer : Boolean from Standard = Standard_True)
281 returns StatusOfPick from AIS;
284 Polyline : Array1OfPnt2d from TColgp;
285 aView : View from V3d;
286 updateviewer : Boolean from Standard = Standard_True)
287 returns StatusOfPick from AIS;
289 ShiftSelect(me : mutable;
290 Polyline : Array1OfPnt2d from TColgp;
291 aView : View from V3d;
292 updateviewer : Boolean from Standard = Standard_True)
293 returns StatusOfPick from AIS;
295 HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
297 UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
300 UpdateSelected (me : mutable;
301 updateviewer : Boolean from Standard = Standard_True);
303 UpdateSelected (me : mutable;
304 anobj : InteractiveObject from AIS;
305 updateviewer : Boolean from Standard = Standard_True);
306 ---Purpose: Part of advanced selection highlighting mechanism.
307 -- If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
308 -- otherwise calls anobj->HilightSelected(). This method can be used to avoid
309 -- redrawing the whole selection belonging to several Selectable Objects.
312 SetSelected(me : mutable;
313 anobj : InteractiveObject from AIS;
314 updateviewer : Boolean from Standard=Standard_True);
315 ---Purpose: useful to update selection with objects coming from
316 -- Collector or stack
318 AddOrRemoveSelected(me : mutable;
319 anobj : InteractiveObject from AIS;
320 updateviewer : Boolean from Standard=Standard_True);
321 ---Purpose: useful to update selection with objects coming from
322 -- Collector or stack
323 AddOrRemoveSelected(me : mutable;
324 aShape : Shape from TopoDS;
325 updateviewer : Boolean from Standard=Standard_True);
327 AddOrRemoveSelected(me : mutable;
328 Ownr : EntityOwner from SelectMgr;
329 updateviewer : Boolean from Standard=Standard_True);
333 ClearSelected(me:mutable;updateviewer : Boolean from Standard=Standard_True);
337 ---Category: GET THE DETECTED
340 HasDetected (me) returns Boolean from Standard;
343 InitDetected(me: mutable);
344 MoreDetected(me) returns Boolean from Standard;
345 NextDetected(me: mutable);
346 DetectedCurrentShape(me) returns Shape from TopoDS;
347 ---C++: return const &
348 DetectedCurrentObject(me) returns InteractiveObject from AIS;
350 HasDetectedShape(me) returns Boolean from Standard;
351 DetectedShape (me) returns Shape from TopoDS;
352 ---C++: return const &
353 DetectedInteractive(me) returns InteractiveObject from AIS;
354 DetectedOwner (me) returns EntityOwner from SelectMgr;
357 ---Category: GET THE SELECTED
359 InitSelected (me: mutable);
360 MoreSelected(me) returns Boolean from Standard;
361 NextSelected(me:mutable);
362 HasShape(me) returns Boolean from Standard;
363 ---Purpose: returns TRUE if the detected entity is a shape
364 -- coming from a Decomposition of an element.
365 SelectedShape(me) returns Shape from TopoDS;
366 ---C++: return const &
368 SelectedOwner(me) returns EntityOwner from SelectMgr;
369 IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard;
370 IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
371 SelectedInteractive(me) returns InteractiveObject from AIS;
372 HasApplicative (me) returns Boolean from Standard;
373 ---Purpose: returns TRUE if an interactive element
374 -- was associated with the current picked entity.
375 SelectedApplicative(me) returns any Transient from Standard;
376 ---C++: return const &
383 ---Category: Management Of Temporary Attributes
385 SetDisplayPriority(me : mutable;
386 anObject: InteractiveObject from AIS;
387 Prior : Integer from Standard);
389 SetZLayer( me : mutable;
390 theIObj : InteractiveObject from AIS;
391 theLayerId : Integer from Standard );
392 ---Purpose: Set Z layer id for interactive object. The layer can be
393 -- specified for displayed object only. The Z layers can be used to display
394 -- temporarily presentations of some object in front of the other objects
395 -- in the scene. The ids for Z layers are generated by V3d_Viewer.
396 -- Note that Z layers differ from under-/overlayer in V3d_View:
397 -- under-/overlayer are intended for specific 2D drawings that appear
398 -- behind/in front of all 3D presentations, while SetZLayer() method
399 -- applies to regular 3D presentations and does not imply any specific
403 theIObj : InteractiveObject from AIS )
404 returns Integer from Standard;
405 ---Purpose: Get Z layer id set for displayed interactive object.
406 -- If the object doesn't exists in context or has no computed presentations,
407 -- the method returns -1.
409 DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
410 returns Integer from Standard;
412 IsIn(me;anObject : InteractiveObject from AIS)
413 returns Boolean from Standard;
416 IsDisplayed(me;anObject : InteractiveObject from AIS)
417 returns Boolean from Standard;
419 IsDisplayed(me;anObject : InteractiveObject from AIS;
420 aMode : Integer from Standard)
421 returns Boolean from Standard;
423 SelectionModes(me;anObject:InteractiveObject from AIS)
424 returns ListOfInteger from TColStd;
425 ---C++: return const &
427 SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS );
429 SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS );
431 Hilight(me: mutable; anObject : InteractiveObject from AIS);
433 Hilight(me:mutable; anObject : InteractiveObject from AIS;aCol:NameOfColor from Quantity);
435 Unhilight(me:mutable; anObject : InteractiveObject from AIS);
437 IsHilighted(me;anObject : InteractiveObject from AIS)
438 returns Boolean from Standard;
441 anObject : InteractiveObject from AIS;
442 WithColor : out Boolean from Standard;
443 HiCol : out NameOfColor from Quantity)
444 returns Boolean from Standard;
446 SetSensitivity(me:mutable;
447 aPrecision: Real from Standard);
449 ---Purpose: Define the current selection sensitivity for
450 -- this local context according to the view size.
452 SetSensitivity(me:mutable;
453 aPrecision: Integer from Standard = 2);
455 ---Purpose: Define the current selection sensitivity for
456 -- this local context according to the view size.
458 ---Category: IMMEDIATE MODE
461 BeginImmediateDraw (me:mutable) returns Boolean from Standard;
462 ---Purpose: initializes the list of presentations to be displayed
463 -- returns False if No Local COnte
465 ImmediateAdd (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
466 returns Boolean from Standard;
467 ---Purpose: returns True if <anIObj> has been stored in the list.
469 ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
470 returns Boolean from Standard;
471 ---Purpose: returns True if <anIObj> has been removed from the list.
473 EndImmediateDraw(me:mutable;aView : View from V3d;DoubleBuf:Boolean from Standard=Standard_False)
474 returns Boolean from Standard;
475 ---Purpose: returns True if the immediate display has been done.
477 IsImmediateModeOn(me) returns Boolean from Standard;
479 ---Category: INTERNAL METHODS;
481 UpdateConversion(me:mutable);
483 UpdateSort(me:mutable);
487 Status(me) returns AsciiString from TCollection is private;
489 Status(me;anObject : InteractiveObject from AIS)
490 returns any LocalStatus from AIS is private;
491 ---C++: return const&
495 LoadContextObjects(me:mutable);
497 UnloadContextObjects(me:mutable);
499 Process(me : mutable;
500 anObject : SelectableObject from SelectMgr;
501 WithProj: Boolean from Standard = Standard_True) is static private;
504 WithProj: Boolean from Standard = Standard_True) is static private;
507 ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
508 WithProj: Boolean from Standard = Standard_True) is static private;
510 ManageDetected(me:mutable;
511 aPickOwner : EntityOwner from SelectMgr;
512 aview : View from V3d) is static private;
514 DetectedIndex(me:mutable) returns Integer from Standard is static private;
516 ---Purpose: returns 0 if the detected entity was Not FilterOK...
518 Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview: View from V3d) is static private;
521 Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from V3d) is static private;
524 ClearObjects(me:mutable) is static private;
526 ClearDetected(me:mutable) is static private;
528 IsDecompositionOn(me) returns Boolean from Standard is static private;
530 IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
532 IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
534 IsValidIndex(me;anIndex:Integer from Standard)
535 returns Boolean from Standard is static private;
538 ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
539 returns Boolean from Standard is static private;
542 DisplayAreas(me:mutable;aviou:View from V3d);
544 ClearAreas (me:mutable;
545 aView: View from V3d) is static;
548 HasFilters(me;aType:ShapeEnum from TopAbs)
549 returns Boolean from Standard is private;
551 DisplaySensitive(me:mutable;aView : View from V3d) is static;
553 ClearSensitive(me:mutable;aView:View from V3d) is static;
557 MainSelector(me) returns any ViewerSelector3d from StdSelect;
559 ---C++: return const&
562 HilightTriangle(me:mutable;Rank:Integer from Standard;aViou:View from V3d) is static private;
566 FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
567 returns EntityOwner from SelectMgr;
569 FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
570 returns EntityOwner from SelectMgr;
576 myCTX : InteractiveContext from AIS;
577 myLoadDisplayed,myAcceptStdMode : Boolean from Standard;
578 myAcceptErase : Boolean from Standard;
580 mySM : SelectionManager from SelectMgr;
581 myMainVS : ViewerSelector3d from StdSelect;
582 myMainPM : PresentationManager3d from PrsMgr;
583 mySelName : AsciiString from TCollection;
584 myCollVS : ViewerSelector3d from StdSelect;
586 -- The Objects and their attributes...
588 myActiveObjects : DataMapOfSelStat from AIS;
593 myFilters : OrFilter from SelectMgr;
594 myListOfStandardMode : ListOfInteger from TColStd;
596 -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
597 myStdFilters : Filter from SelectMgr [9]; --internal mgt
601 myAutoHilight : Boolean from Standard;
602 myMapOfOwner : IndexedMapOfOwner from SelectMgr;
603 mylastindex : Integer from Standard;
604 mylastgood : Integer from Standard;
605 myCurrentOwner : Integer from Standard;
608 myDetectedSeq : SequenceOfInteger from TColStd;
609 myCurDetected : Integer from Standard;
611 -- the detected objects.
612 myAISDetectedSeq : SequenceOfInteractive from AIS;
613 myAISCurDetected : Integer from Standard;
614 -- This variables is used by following functions:
615 -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
619 KeepTemporary from InteractiveContext from AIS(me:mutable;anIObj:InteractiveObject from AIS;WhichMode : Integer from Standard = -1)