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.
25 class LocalContext from AIS inherits TShared from MMgt
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
38 -- - automatically highlight shapes and
39 -- InteractiveObjects (highlight of detected shape +
40 -- highlight of detected selectable...
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,
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,
66 InteractiveObject from AIS,
68 DataMapOfSelStat from AIS,
70 StatusOfPick from AIS,
71 StatusOfDetection from AIS,
72 SequenceOfInteractive from AIS
76 Create returns LocalContext from AIS;
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.
90 AcceptErase(me:mutable;aStatus : Boolean from Standard);
92 ---Purpose: authorize or not others contexts to erase
93 -- temporary displayed objects here;
95 AcceptErase(me) returns Boolean from Standard;
98 SetContext(me:mutable;aCtx:InteractiveContext from AIS);
100 SelectionName(me) returns AsciiString from TCollection;
102 ---C++: return const&
105 Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
107 Reactivate(me:mutable);
108 ---Purpose: to be called when a upper local context was closed...
109 -- useful to put pack the right projector...
111 ---Category: LOAD AND PREPARE
112 -- - INTERACTIVE OBJECTS...
114 -- - STANDARD MODES OF ACTIVATION
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...
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
136 anInteractive : InteractiveObject from AIS)
137 returns Boolean from Standard;
138 ---Purpose: returns true if done...
142 aSelectable : InteractiveObject from AIS)
143 returns Boolean from Standard;
146 ClearPrs (me : mutable;
147 anInteractive : InteractiveObject from AIS;
148 aMode : Integer from Standard)
149 returns Boolean from Standard;
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
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...)
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...
172 DeactivateMode(me : mutable;
173 aSelectable: InteractiveObject from AIS;
174 aMode : Integer from Standard );
175 Deactivate(me : mutable;
176 aSelectable: InteractiveObject from AIS);
178 ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
179 ---Purpose: decomposition of shapes into <aType>
182 DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
184 StandardModes(me) returns ListOfInteger from TColStd;
185 ---C++: return const &
190 AddFilter(me:mutable;aFilter:Filter from SelectMgr);
192 RemoveFilter(me:mutable;aFilter: Filter from SelectMgr);
195 ListOfFilter(me) returns ListOfFilter from SelectMgr;
196 ---C++: return const &
199 Filter(me) returns any OrFilter from SelectMgr;
200 ---C++: return const &
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
208 -- Else the user has to manage the detected shape outside the
209 -- Shape Selector....
214 AutomaticHilight(me) returns Boolean;
217 ---Category: THE SELECTION PROCESS
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;
226 HasNextDetected(me) returns Boolean from Standard;
228 ---Purpose: returns True if more than one entity
229 -- was detected at the last Mouse position.
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)
238 HilightPreviousDetected (me : mutable;
239 theView : View from V3d;
240 theToRedrawImmediate : Boolean from Standard)
241 returns Integer from Standard;
243 UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
244 ---Purpose: returns True if something was done...
246 Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
247 returns StatusOfPick from AIS;
248 ---Purpose: returns the number of selected
250 ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
251 returns StatusOfPick from AIS;
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;
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;
267 Polyline : Array1OfPnt2d from TColgp;
268 aView : View from V3d;
269 updateviewer : Boolean from Standard = Standard_True)
270 returns StatusOfPick from AIS;
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;
278 HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
280 UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
283 UpdateSelected (me : mutable;
284 updateviewer : Boolean from Standard = Standard_True);
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.
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
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);
310 AddOrRemoveSelected(me : mutable;
311 theOwner : EntityOwner from SelectMgr;
312 toUpdateViewer : Boolean from Standard = Standard_True);
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.
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.
331 ---Category: GET THE DETECTED
333 HasDetected (me) returns Boolean from Standard;
336 InitDetected(me: mutable);
338 -- Initialization for iteration through mouse-detected objects in local context.
340 MoreDetected(me) returns Boolean from Standard;
342 -- @return true if there is more mouse-detected objects after the current one
343 -- during iteration through mouse-detected interactive objects.
345 NextDetected(me: mutable);
347 -- Gets next current object during iteration through mouse-detected
348 -- interactive objects.
350 DetectedCurrentShape(me) returns Shape from TopoDS;
351 ---C++: return const &
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.
356 DetectedCurrentObject(me) returns InteractiveObject from AIS;
358 -- @return current mouse-detected interactive object or null object if there is no current detected.
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;
367 ---Category: GET THE SELECTED
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;
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 &
397 ---Category: Management Of Temporary Attributes
399 SetDisplayPriority(me : mutable;
400 anObject: InteractiveObject from AIS;
401 Prior : Integer from Standard);
403 DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
404 returns Integer from Standard;
406 IsIn(me;anObject : InteractiveObject from AIS)
407 returns Boolean from Standard;
410 IsDisplayed(me;anObject : InteractiveObject from AIS)
411 returns Boolean from Standard;
413 IsDisplayed(me;anObject : InteractiveObject from AIS;
414 aMode : Integer from Standard)
415 returns Boolean from Standard;
417 SelectionModes(me;anObject:InteractiveObject from AIS)
418 returns ListOfInteger from TColStd;
419 ---C++: return const &
421 SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS );
423 SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS );
425 Hilight(me: mutable; anObject : InteractiveObject from AIS);
427 Hilight(me:mutable; anObject : InteractiveObject from AIS;aCol:NameOfColor from Quantity);
429 Unhilight(me:mutable; anObject : InteractiveObject from AIS);
431 IsHilighted(me;anObject : InteractiveObject from AIS)
432 returns Boolean from Standard;
435 anObject : InteractiveObject from AIS;
436 WithColor : out Boolean from Standard;
437 HiCol : out NameOfColor from Quantity)
438 returns Boolean from Standard;
440 SetPixelTolerance(me:mutable;
441 aPrecision: Real from Standard = 2);
443 ---Purpose: Define the current selection sensitivity for
444 -- this local context according to the view size.
446 PixelTolerance(me) returns Real from Standard;
448 ---Purpose: Returns the pixel tolerance.
450 ---Category: IMMEDIATE MODE
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.
458 ClearImmediateDraw (me : mutable) is virtual;
459 ---Purpose: Resets the transient list of presentations previously displayed in immediate mode.
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.
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.
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.
476 ---Category: INTERNAL METHODS;
479 Status(me) returns AsciiString from TCollection;
481 Status(me;anObject : InteractiveObject from AIS)
482 returns any LocalStatus from AIS;
483 ---C++: return const&
487 LoadContextObjects(me:mutable);
489 UnloadContextObjects(me:mutable);
491 Process(me : mutable;
492 anObject : SelectableObject from SelectMgr) is static private;
494 Process(me:mutable) is static private;
497 ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr) is static private;
499 manageDetected (me : mutable;
500 thePickOwner : EntityOwner from SelectMgr;
501 theView : View from V3d;
502 theToRedrawImmediate : Boolean from Standard) is static private;
504 DetectedIndex(me:mutable) returns Integer from Standard is static private;
506 ---Purpose: returns 0 if the detected entity was Not FilterOK...
508 Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview: View from V3d) is static private;
511 Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from V3d) is static private;
514 ClearObjects(me:mutable) is static private;
516 ClearDetected(me:mutable) is static private;
518 IsDecompositionOn(me) returns Boolean from Standard is static private;
520 IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
522 IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
524 IsValidIndex(me;anIndex:Integer from Standard)
525 returns Boolean from Standard is static private;
528 ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
529 returns Boolean from Standard is static private;
531 HasFilters(me;aType:ShapeEnum from TopAbs)
532 returns Boolean from Standard is private;
534 DisplaySensitive(me:mutable;aView : View from V3d) is static;
536 ClearSensitive(me:mutable;aView:View from V3d) is static;
538 MainSelector(me) returns ViewerSelector3d from StdSelect;
540 ---C++: return const&
542 FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
543 returns EntityOwner from SelectMgr;
545 FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
546 returns EntityOwner from SelectMgr;
552 myCTX : InteractiveContext from AIS;
553 myLoadDisplayed,myAcceptStdMode : Boolean from Standard;
554 myAcceptErase : Boolean from Standard;
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;
562 -- The Objects and their attributes...
564 myActiveObjects : DataMapOfSelStat from AIS;
569 myFilters : OrFilter from SelectMgr;
570 myListOfStandardMode : ListOfInteger from TColStd;
572 -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
573 myStdFilters : Filter from SelectMgr [9]; --internal mgt
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;
584 myDetectedSeq : SequenceOfInteger from TColStd;
585 myCurDetected : Integer from Standard;
587 -- The detected objects.
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().