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
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 -- 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()
32 class LocalContext from AIS inherits TShared from MMgt
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
45 -- - automatically highlight shapes and
46 -- InteractiveObjects (highlight of detected shape +
47 -- highlight of detected selectable...
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,
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,
74 InteractiveObject from AIS,
76 DataMapOfSelStat from AIS,
78 StatusOfPick from AIS,
79 StatusOfDetection from AIS,
80 SequenceOfInteractive from AIS
84 Create returns LocalContext from AIS;
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 LocalContext from AIS;
94 ---Purpose: Constructor By Default, the displayed objects are
95 -- automatically loaded.
98 AcceptErase(me:mutable;aStatus : Boolean from Standard);
100 ---Purpose: authorize or not others contexts to erase
101 -- temporary displayed objects here;
103 AcceptErase(me) returns Boolean from Standard;
106 SetContext(me:mutable;aCtx:InteractiveContext from AIS);
108 SelectionName(me) returns AsciiString from TCollection;
110 ---C++: return const&
113 Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
115 HasSameProjector(me;aPrj:Projector from Select3D)
116 returns Boolean from Standard;
117 ---Purpose: compares the current projector of the localContext
119 -- returns True if the projectors are identical.
120 -- (no need to update projection of selection primitives
121 -- when closing the local context)....
123 Reactivate(me:mutable);
124 ---Purpose: to be called when a upper local context was closed...
125 -- useful to put pack the right projector...
127 ---Category: LOAD AND PREPARE
128 -- - INTERACTIVE OBJECTS...
130 -- - STANDARD MODES OF ACTIVATION
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...
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
152 anInteractive : InteractiveObject from AIS)
153 returns Boolean from Standard;
154 ---Purpose: returns true if done...
158 aSelectable : InteractiveObject from AIS)
159 returns Boolean from Standard;
162 ClearPrs (me : mutable;
163 anInteractive : InteractiveObject from AIS;
164 aMode : Integer from Standard)
165 returns Boolean from Standard;
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
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...)
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...
188 DeactivateMode(me : mutable;
189 aSelectable: InteractiveObject from AIS;
190 aMode : Integer from Standard );
191 Deactivate(me : mutable;
192 aSelectable: InteractiveObject from AIS);
194 ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
195 ---Purpose: decomposition of shapes into <aType>
198 DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
200 StandardModes(me) returns ListOfInteger from TColStd;
201 ---C++: return const &
206 AddFilter(me:mutable;aFilter:Filter from SelectMgr);
208 RemoveFilter(me:mutable;aFilter: Filter from SelectMgr);
211 ListOfFilter(me) returns ListOfFilter from SelectMgr;
212 ---C++: return const &
215 Filter(me) returns any OrFilter from SelectMgr;
216 ---C++: return const &
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
224 -- Else the user has to manage the detected shape outside the
225 -- Shape Selector....
230 AutomaticHilight(me) returns Boolean;
233 ---Category: THE SELECTION PROCESS
235 MoveTo (me : mutable;
236 theXpix, theYpix : Integer from Standard;
237 theView : View from V3d;
238 theToRedrawImmediate : Boolean from Standard)
239 returns StatusOfDetection from AIS;
242 HasNextDetected(me) returns Boolean from Standard;
244 ---Purpose: returns True if more than one entity
245 -- was detected at the last Mouse position.
247 HilightNextDetected (me : mutable;
248 theView : View from V3d;
249 theToRedrawImmediate : Boolean from Standard)
250 returns Integer from Standard;
251 ---Purpose: returns True if last detected. the next detected will
252 -- be first one (endless loop)
254 HilightPreviousDetected (me : mutable;
255 theView : View from V3d;
256 theToRedrawImmediate : Boolean from Standard)
257 returns Integer from Standard;
259 UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
260 ---Purpose: returns True if something was done...
262 Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
263 returns StatusOfPick from AIS;
264 ---Purpose: returns the number of selected
266 ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
267 returns StatusOfPick from AIS;
270 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
271 aView : View from V3d;
272 updateviewer : Boolean from Standard = Standard_True)
273 returns StatusOfPick from AIS;
276 ShiftSelect(me : mutable;
277 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
278 aView : View from V3d;
279 updateviewer : Boolean from Standard = Standard_True)
280 returns StatusOfPick from AIS;
283 Polyline : Array1OfPnt2d from TColgp;
284 aView : View from V3d;
285 updateviewer : Boolean from Standard = Standard_True)
286 returns StatusOfPick from AIS;
288 ShiftSelect(me : mutable;
289 Polyline : Array1OfPnt2d from TColgp;
290 aView : View from V3d;
291 updateviewer : Boolean from Standard = Standard_True)
292 returns StatusOfPick from AIS;
294 HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
296 UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
299 UpdateSelected (me : mutable;
300 updateviewer : Boolean from Standard = Standard_True);
302 UpdateSelected (me : mutable;
303 anobj : InteractiveObject from AIS;
304 updateviewer : Boolean from Standard = Standard_True);
305 ---Purpose: Part of advanced selection highlighting mechanism.
306 -- If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
307 -- otherwise calls anobj->HilightSelected(). This method can be used to avoid
308 -- redrawing the whole selection belonging to several Selectable Objects.
311 SetSelected(me : mutable;
312 anobj : InteractiveObject from AIS;
313 updateviewer : Boolean from Standard=Standard_True);
314 ---Purpose: useful to update selection with objects coming from
315 -- Collector or stack
317 AddOrRemoveSelected(me : mutable;
318 anobj : InteractiveObject from AIS;
319 updateviewer : Boolean from Standard=Standard_True);
320 ---Purpose: useful to update selection with objects coming from
321 -- Collector or stack
322 AddOrRemoveSelected(me : mutable;
323 aShape : Shape from TopoDS;
324 updateviewer : Boolean from Standard=Standard_True);
326 AddOrRemoveSelected(me : mutable;
327 Ownr : EntityOwner from SelectMgr;
328 updateviewer : Boolean from Standard=Standard_True);
332 ClearSelected(me:mutable;updateviewer : Boolean from Standard=Standard_True);
336 ---Category: GET THE DETECTED
339 HasDetected (me) returns Boolean from Standard;
342 InitDetected(me: mutable);
343 MoreDetected(me) returns Boolean from Standard;
344 NextDetected(me: mutable);
345 DetectedCurrentShape(me) returns Shape from TopoDS;
346 ---C++: return const &
347 DetectedCurrentObject(me) returns InteractiveObject from AIS;
349 HasDetectedShape(me) returns Boolean from Standard;
350 DetectedShape (me) returns Shape from TopoDS;
351 ---C++: return const &
352 DetectedInteractive(me) returns InteractiveObject from AIS;
353 DetectedOwner (me) returns EntityOwner from SelectMgr;
356 ---Category: GET THE SELECTED
358 InitSelected (me: mutable);
359 MoreSelected(me) returns Boolean from Standard;
360 NextSelected(me:mutable);
361 HasShape(me) returns Boolean from Standard;
362 ---Purpose: returns TRUE if the detected entity is a shape
363 -- coming from a Decomposition of an element.
364 SelectedShape(me) returns Shape from TopoDS;
365 ---C++: return const &
367 SelectedOwner(me) returns EntityOwner from SelectMgr;
368 IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard;
369 IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
370 SelectedInteractive(me) returns InteractiveObject from AIS;
371 HasApplicative (me) returns Boolean from Standard;
372 ---Purpose: returns TRUE if an interactive element
373 -- was associated with the current picked entity.
374 SelectedApplicative(me) returns any Transient from Standard;
375 ---C++: return const &
382 ---Category: Management Of Temporary Attributes
384 SetDisplayPriority(me : mutable;
385 anObject: InteractiveObject from AIS;
386 Prior : Integer from Standard);
388 SetZLayer( me : mutable;
389 theIObj : InteractiveObject from AIS;
390 theLayerId : Integer from Standard );
391 ---Purpose: Set Z layer id for interactive object. The layer can be
392 -- specified for displayed object only. The Z layers can be used to display
393 -- temporarily presentations of some object in front of the other objects
394 -- in the scene. The ids for Z layers are generated by V3d_Viewer.
395 -- Note that Z layers differ from under-/overlayer in V3d_View:
396 -- under-/overlayer are intended for specific 2D drawings that appear
397 -- behind/in front of all 3D presentations, while SetZLayer() method
398 -- applies to regular 3D presentations and does not imply any specific
402 theIObj : InteractiveObject from AIS )
403 returns Integer from Standard;
404 ---Purpose: Get Z layer id set for displayed interactive object.
405 -- If the object doesn't exists in context or has no computed presentations,
406 -- the method returns -1.
408 DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
409 returns Integer from Standard;
411 IsIn(me;anObject : InteractiveObject from AIS)
412 returns Boolean from Standard;
415 IsDisplayed(me;anObject : InteractiveObject from AIS)
416 returns Boolean from Standard;
418 IsDisplayed(me;anObject : InteractiveObject from AIS;
419 aMode : Integer from Standard)
420 returns Boolean from Standard;
422 SelectionModes(me;anObject:InteractiveObject from AIS)
423 returns ListOfInteger from TColStd;
424 ---C++: return const &
426 SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS );
428 SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS );
430 Hilight(me: mutable; anObject : InteractiveObject from AIS);
432 Hilight(me:mutable; anObject : InteractiveObject from AIS;aCol:NameOfColor from Quantity);
434 Unhilight(me:mutable; anObject : InteractiveObject from AIS);
436 IsHilighted(me;anObject : InteractiveObject from AIS)
437 returns Boolean from Standard;
440 anObject : InteractiveObject from AIS;
441 WithColor : out Boolean from Standard;
442 HiCol : out NameOfColor from Quantity)
443 returns Boolean from Standard;
445 SetSensitivityMode(me : mutable;
446 aMode : SensitivityMode from StdSelect) is static;
448 ---Purpose: Sets the selection sensitivity mode. SM_WINDOW mode
449 -- uses the specified pixel tolerance to compute the sensitivity
450 -- value, SM_VIEW mode allows to define the sensitivity manually.
452 SensitivityMode(me) returns SensitivityMode from StdSelect;
454 ---Purpose: Returns the selection sensitivity mode.
456 SetSensitivity(me:mutable;
457 aPrecision: Real from Standard);
459 ---Purpose: Define the current selection sensitivity for
460 -- this local context according to the view size.
462 Sensitivity (me) returns Real from Standard;
464 ---Purpose: Returns the selection sensitivity value.
466 SetPixelTolerance(me:mutable;
467 aPrecision: Integer from Standard = 2);
469 ---Purpose: Define the current selection sensitivity for
470 -- this local context according to the view size.
472 PixelTolerance(me) returns Integer from Standard;
474 ---Purpose: Returns the pixel tolerance.
476 ---Category: IMMEDIATE MODE
479 BeginImmediateDraw (me : mutable)
480 returns Boolean from Standard;
481 ---Purpose: Resets the transient list of presentations previously displayed in immediate mode
482 -- and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls.
484 ClearImmediateDraw (me : mutable) is virtual;
485 ---Purpose: Resets the transient list of presentations previously displayed in immediate mode.
487 ImmediateAdd (me : mutable;
488 theObj : InteractiveObject from AIS;
489 theMode : Integer from Standard = 0)
490 returns Boolean from Standard;
491 ---Purpose: Stores presentation theMode of object theObj in the transient list of presentations to be displayed in immediate mode.
492 -- Will be taken in account in EndImmediateDraw method.
494 EndImmediateDraw (me : mutable;
495 theView : View from V3d)
496 returns Boolean from Standard;
497 ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background.
499 IsImmediateModeOn (me) returns Boolean from Standard;
500 ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode.
502 ---Category: INTERNAL METHODS;
504 UpdateConversion(me:mutable);
506 UpdateSort(me:mutable);
510 Status(me) returns AsciiString from TCollection is private;
512 Status(me;anObject : InteractiveObject from AIS)
513 returns any LocalStatus from AIS is private;
514 ---C++: return const&
518 LoadContextObjects(me:mutable);
520 UnloadContextObjects(me:mutable);
522 Process(me : mutable;
523 anObject : SelectableObject from SelectMgr;
524 WithProj: Boolean from Standard = Standard_True) is static private;
527 WithProj: Boolean from Standard = Standard_True) is static private;
530 ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
531 WithProj: Boolean from Standard = Standard_True) is static private;
533 manageDetected (me : mutable;
534 thePickOwner : EntityOwner from SelectMgr;
535 theView : View from V3d;
536 theToRedrawImmediate : Boolean from Standard) is static private;
538 DetectedIndex(me:mutable) returns Integer from Standard is static private;
540 ---Purpose: returns 0 if the detected entity was Not FilterOK...
542 Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview: View from V3d) is static private;
545 Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from V3d) is static private;
548 ClearObjects(me:mutable) is static private;
550 ClearDetected(me:mutable) is static private;
552 IsDecompositionOn(me) returns Boolean from Standard is static private;
554 IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
556 IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
558 IsValidIndex(me;anIndex:Integer from Standard)
559 returns Boolean from Standard is static private;
562 ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
563 returns Boolean from Standard is static private;
566 DisplayAreas(me:mutable;aviou:View from V3d);
568 ClearAreas (me:mutable;
569 aView: View from V3d) is static;
572 HasFilters(me;aType:ShapeEnum from TopAbs)
573 returns Boolean from Standard is private;
575 DisplaySensitive(me:mutable;aView : View from V3d) is static;
577 ClearSensitive(me:mutable;aView:View from V3d) is static;
579 MainSelector(me) returns any ViewerSelector3d from StdSelect;
581 ---C++: return const&
583 FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
584 returns EntityOwner from SelectMgr;
586 FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
587 returns EntityOwner from SelectMgr;
593 myCTX : InteractiveContext from AIS;
594 myLoadDisplayed,myAcceptStdMode : Boolean from Standard;
595 myAcceptErase : Boolean from Standard;
597 mySM : SelectionManager from SelectMgr;
598 myMainVS : ViewerSelector3d from StdSelect;
599 myMainPM : PresentationManager3d from PrsMgr;
600 mySelName : AsciiString from TCollection;
601 myCollVS : ViewerSelector3d from StdSelect;
603 -- The Objects and their attributes...
605 myActiveObjects : DataMapOfSelStat from AIS;
610 myFilters : OrFilter from SelectMgr;
611 myListOfStandardMode : ListOfInteger from TColStd;
613 -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
614 myStdFilters : Filter from SelectMgr [9]; --internal mgt
618 myAutoHilight : Boolean from Standard;
619 myMapOfOwner : IndexedMapOfOwner from SelectMgr;
620 mylastindex : Integer from Standard;
621 mylastgood : Integer from Standard;
622 myCurrentOwner : Integer from Standard;
625 myDetectedSeq : SequenceOfInteger from TColStd;
626 myCurDetected : Integer from Standard;
628 -- the detected objects.
629 myAISDetectedSeq : SequenceOfInteractive from AIS;
630 myAISCurDetected : Integer from Standard;
631 -- This variables is used by following functions:
632 -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
636 KeepTemporary from InteractiveContext from AIS(me:mutable;anIObj:InteractiveObject from AIS;WhichMode : Integer from Standard = -1)