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 Projector from Select3D,
55 IndexedMapOfOwner from SelectMgr,
56 EntityOwner from SelectMgr,
57 OrFilter from SelectMgr,
58 Filter from SelectMgr,
59 SelectionManager from SelectMgr,
60 SelectableObject from SelectMgr ,
61 ListOfFilter from SelectMgr,
62 BRepOwner from StdSelect,
63 ViewerSelector3d from StdSelect,
64 SensitivityMode from StdSelect,
65 InteractiveContext from AIS,
67 InteractiveObject from AIS,
69 DataMapOfSelStat from AIS,
71 StatusOfPick from AIS,
72 StatusOfDetection from AIS,
73 SequenceOfInteractive from AIS
77 Create returns LocalContext from AIS;
80 Create (aCtx : InteractiveContext from AIS;
81 anIndex : Integer from Standard;
82 LoadDisplayed : Boolean from Standard=Standard_True;
83 AcceptStandardModes : Boolean from Standard=Standard_True;
84 AcceptErase : Boolean from Standard= Standard_False;
85 UseBothViewers : Boolean from Standard= Standard_False)
86 returns LocalContext from AIS;
87 ---Purpose: Constructor By Default, the displayed objects are
88 -- automatically loaded.
91 AcceptErase(me:mutable;aStatus : Boolean from Standard);
93 ---Purpose: authorize or not others contexts to erase
94 -- temporary displayed objects here;
96 AcceptErase(me) returns Boolean from Standard;
99 SetContext(me:mutable;aCtx:InteractiveContext from AIS);
101 SelectionName(me) returns AsciiString from TCollection;
103 ---C++: return const&
106 Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
108 HasSameProjector(me;aPrj:Projector from Select3D)
109 returns Boolean from Standard;
110 ---Purpose: compares the current projector of the localContext
112 -- returns True if the projectors are identical.
113 -- (no need to update projection of selection primitives
114 -- when closing the local context)....
116 Reactivate(me:mutable);
117 ---Purpose: to be called when a upper local context was closed...
118 -- useful to put pack the right projector...
120 ---Category: LOAD AND PREPARE
121 -- - INTERACTIVE OBJECTS...
123 -- - STANDARD MODES OF ACTIVATION
128 Display(me : mutable;
129 anInteractive : InteractiveObject from AIS;
130 DisplayMode : Integer from Standard = 0;
131 AllowShapeDecomposition: Boolean from Standard = Standard_True;
132 ActivationMode : Integer from Standard = 0)
133 returns Boolean from Standard;
134 ---Purpose: returns true if done...
137 anInteractive : InteractiveObject from AIS;
138 AllowShapeDecomposition: Boolean from Standard = Standard_True;
139 ActivationMode : Integer from Standard = 0)
140 returns Boolean from Standard;
141 ---Purpose: loads <anInteractive> with nodisplay...
142 -- returns true if done
145 anInteractive : InteractiveObject from AIS)
146 returns Boolean from Standard;
147 ---Purpose: returns true if done...
151 aSelectable : InteractiveObject from AIS)
152 returns Boolean from Standard;
155 ClearPrs (me : mutable;
156 anInteractive : InteractiveObject from AIS;
157 aMode : Integer from Standard)
158 returns Boolean from Standard;
160 SetShapeDecomposition(me : mutable;
161 aStoredObject : InteractiveObject from AIS;
162 aStatus : Boolean from Standard);
163 ---Purpose: allows or forbids the shape decomposition into
164 -- Activated Standard Mode for <aStoredObject>
165 -- does nothing if the object doesn't inherits
166 -- BasicShape from AIS
169 Clear(me:mutable;atype: ClearMode from AIS = AIS_CM_All);
170 ---Purpose: according to <atype> , clears the different parts of
171 -- the selector (filters, modeof activation, objects...)
176 ActivateMode (me : mutable;
177 aSelectable: InteractiveObject from AIS;
178 aMode : Integer from Standard );
179 ---Purpose: optional : activation of a mode which is not 0 for a selectable...
181 DeactivateMode(me : mutable;
182 aSelectable: InteractiveObject from AIS;
183 aMode : Integer from Standard );
184 Deactivate(me : mutable;
185 aSelectable: InteractiveObject from AIS);
187 ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
188 ---Purpose: decomposition of shapes into <aType>
191 DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
193 StandardModes(me) returns ListOfInteger from TColStd;
194 ---C++: return const &
199 AddFilter(me:mutable;aFilter:Filter from SelectMgr);
201 RemoveFilter(me:mutable;aFilter: Filter from SelectMgr);
204 ListOfFilter(me) returns ListOfFilter from SelectMgr;
205 ---C++: return const &
208 Filter(me) returns any OrFilter from SelectMgr;
209 ---C++: return const &
213 SetAutomaticHilight(me:mutable ; aStatus:Boolean) ;
214 ---Purpose: if <aStatus> = True , the shapes or subshapes detected
215 -- by the selector will be automatically hilighted in the
217 -- Else the user has to manage the detected shape outside the
218 -- Shape Selector....
223 AutomaticHilight(me) returns Boolean;
226 ---Category: THE SELECTION PROCESS
228 MoveTo (me : mutable;
229 theXpix, theYpix : Integer from Standard;
230 theView : View from V3d;
231 theToRedrawImmediate : Boolean from Standard)
232 returns StatusOfDetection from AIS;
235 HasNextDetected(me) returns Boolean from Standard;
237 ---Purpose: returns True if more than one entity
238 -- was detected at the last Mouse position.
240 HilightNextDetected (me : mutable;
241 theView : View from V3d;
242 theToRedrawImmediate : Boolean from Standard)
243 returns Integer from Standard;
244 ---Purpose: returns True if last detected. the next detected will
245 -- be first one (endless loop)
247 HilightPreviousDetected (me : mutable;
248 theView : View from V3d;
249 theToRedrawImmediate : Boolean from Standard)
250 returns Integer from Standard;
252 UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
253 ---Purpose: returns True if something was done...
255 Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
256 returns StatusOfPick from AIS;
257 ---Purpose: returns the number of selected
259 ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
260 returns StatusOfPick from AIS;
263 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
264 aView : View from V3d;
265 updateviewer : Boolean from Standard = Standard_True)
266 returns StatusOfPick from AIS;
269 ShiftSelect(me : mutable;
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 Polyline : Array1OfPnt2d from TColgp;
277 aView : View from V3d;
278 updateviewer : Boolean from Standard = Standard_True)
279 returns StatusOfPick from AIS;
281 ShiftSelect(me : mutable;
282 Polyline : Array1OfPnt2d from TColgp;
283 aView : View from V3d;
284 updateviewer : Boolean from Standard = Standard_True)
285 returns StatusOfPick from AIS;
287 HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
289 UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
292 UpdateSelected (me : mutable;
293 updateviewer : Boolean from Standard = Standard_True);
295 UpdateSelected (me : mutable;
296 anobj : InteractiveObject from AIS;
297 updateviewer : Boolean from Standard = Standard_True);
298 ---Purpose: Part of advanced selection highlighting mechanism.
299 -- If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
300 -- otherwise calls anobj->HilightSelected(). This method can be used to avoid
301 -- redrawing the whole selection belonging to several Selectable Objects.
304 SetSelected(me : mutable;
305 anobj : InteractiveObject from AIS;
306 updateviewer : Boolean from Standard=Standard_True);
307 ---Purpose: useful to update selection with objects coming from
308 -- Collector or stack
310 AddOrRemoveSelected(me : mutable;
311 anobj : InteractiveObject from AIS;
312 updateviewer : Boolean from Standard=Standard_True);
313 ---Purpose: useful to update selection with objects coming from
314 -- Collector or stack
315 AddOrRemoveSelected(me : mutable;
316 aShape : Shape from TopoDS;
317 updateviewer : Boolean from Standard=Standard_True);
319 AddOrRemoveSelected(me : mutable;
320 theOwner : EntityOwner from SelectMgr;
321 toUpdateViewer : Boolean from Standard = Standard_True);
323 ClearSelected (me : mutable;
324 toUpdateViewer : Boolean from Standard = Standard_True);
325 ---Purpose: Clears local context selection.
326 -- @param toUpdateViewer [in] if TRUE the viewer will be updated.
328 ClearOutdatedSelection (me : mutable;
329 theIO : InteractiveObject from AIS;
330 toClearDeactivated : Boolean from Standard);
331 ---Purpose: Clears outdated selection and detection of owners for the
332 -- interactive object. Use this method if selection structures
333 -- of the interactive object have changed. The method unhilights
334 -- and removes outdated entity owners from lists of selected
335 -- and detected owners.
336 -- @param theIO [in] the interactive object.
337 -- @param toClearDeactivated [in] pass TRUE to treat deactivated
338 -- entity owners as 'outdated' when clearing the selection.
340 ---Category: GET THE DETECTED
342 HasDetected (me) returns Boolean from Standard;
345 InitDetected(me: mutable);
347 -- Initialization for iteration through mouse-detected objects in local context.
349 MoreDetected(me) returns Boolean from Standard;
351 -- @return true if there is more mouse-detected objects after the current one
352 -- during iteration through mouse-detected interactive objects.
354 NextDetected(me: mutable);
356 -- Gets next current object during iteration through mouse-detected
357 -- interactive objects.
359 DetectedCurrentShape(me) returns Shape from TopoDS;
360 ---C++: return const &
362 -- @return current mouse-detected shape or empty (null) shape, if current interactive object
363 -- is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
365 DetectedCurrentObject(me) returns InteractiveObject from AIS;
367 -- @return current mouse-detected interactive object or null object if there is no current detected.
369 HasDetectedShape(me) returns Boolean from Standard;
370 DetectedShape (me) returns Shape from TopoDS;
371 ---C++: return const &
372 DetectedInteractive(me) returns InteractiveObject from AIS;
373 DetectedOwner (me) returns EntityOwner from SelectMgr;
376 ---Category: GET THE SELECTED
378 InitSelected (me: mutable);
379 MoreSelected(me) returns Boolean from Standard;
380 NextSelected(me:mutable);
381 HasShape(me) returns Boolean from Standard;
382 ---Purpose: returns TRUE if the detected entity is a shape
383 -- coming from a Decomposition of an element.
384 HasSelectedShape(me) returns Boolean from Standard;
385 ---Purpose: returns true if current selection is not empty
386 -- and the owner of selected object contains a shape.
387 -- This method does not take into account decomposition
388 -- status of detected shape.
389 SelectedShape(me) returns Shape from TopoDS;
391 SelectedOwner(me) returns EntityOwner from SelectMgr;
392 IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard;
393 IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
394 SelectedInteractive(me) returns InteractiveObject from AIS;
395 HasApplicative (me) returns Boolean from Standard;
396 ---Purpose: returns TRUE if an interactive element
397 -- was associated with the current picked entity.
398 SelectedApplicative(me) returns any Transient from Standard;
399 ---C++: return const &
406 ---Category: Management Of Temporary Attributes
408 SetDisplayPriority(me : mutable;
409 anObject: InteractiveObject from AIS;
410 Prior : Integer from Standard);
412 DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
413 returns Integer from Standard;
415 IsIn(me;anObject : InteractiveObject from AIS)
416 returns Boolean from Standard;
419 IsDisplayed(me;anObject : InteractiveObject from AIS)
420 returns Boolean from Standard;
422 IsDisplayed(me;anObject : InteractiveObject from AIS;
423 aMode : Integer from Standard)
424 returns Boolean from Standard;
426 SelectionModes(me;anObject:InteractiveObject from AIS)
427 returns ListOfInteger from TColStd;
428 ---C++: return const &
430 SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS );
432 SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS );
434 Hilight(me: mutable; anObject : InteractiveObject from AIS);
436 Hilight(me:mutable; anObject : InteractiveObject from AIS;aCol:NameOfColor from Quantity);
438 Unhilight(me:mutable; anObject : InteractiveObject from AIS);
440 IsHilighted(me;anObject : InteractiveObject from AIS)
441 returns Boolean from Standard;
444 anObject : InteractiveObject from AIS;
445 WithColor : out Boolean from Standard;
446 HiCol : out NameOfColor from Quantity)
447 returns Boolean from Standard;
449 SetSensitivityMode(me : mutable;
450 aMode : SensitivityMode from StdSelect) is static;
452 ---Purpose: Sets the selection sensitivity mode. SM_WINDOW mode
453 -- uses the specified pixel tolerance to compute the sensitivity
454 -- value, SM_VIEW mode allows to define the sensitivity manually.
456 SensitivityMode(me) returns SensitivityMode from StdSelect;
458 ---Purpose: Returns the selection sensitivity mode.
460 SetSensitivity(me:mutable;
461 aPrecision: Real from Standard);
463 ---Purpose: Define the current selection sensitivity for
464 -- this local context according to the view size.
466 Sensitivity (me) returns Real from Standard;
468 ---Purpose: Returns the selection sensitivity value.
470 SetPixelTolerance(me:mutable;
471 aPrecision: Integer from Standard = 2);
473 ---Purpose: Define the current selection sensitivity for
474 -- this local context according to the view size.
476 PixelTolerance(me) returns Integer from Standard;
478 ---Purpose: Returns the pixel tolerance.
480 ---Category: IMMEDIATE MODE
483 BeginImmediateDraw (me : mutable)
484 returns Boolean from Standard;
485 ---Purpose: Resets the transient list of presentations previously displayed in immediate mode
486 -- and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls.
488 ClearImmediateDraw (me : mutable) is virtual;
489 ---Purpose: Resets the transient list of presentations previously displayed in immediate mode.
491 ImmediateAdd (me : mutable;
492 theObj : InteractiveObject from AIS;
493 theMode : Integer from Standard = 0)
494 returns Boolean from Standard;
495 ---Purpose: Stores presentation theMode of object theObj in the transient list of presentations to be displayed in immediate mode.
496 -- Will be taken in account in EndImmediateDraw method.
498 EndImmediateDraw (me : mutable;
499 theView : View from V3d)
500 returns Boolean from Standard;
501 ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background.
503 IsImmediateModeOn (me) returns Boolean from Standard;
504 ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode.
506 ---Category: INTERNAL METHODS;
508 UpdateConversion(me:mutable);
510 UpdateSort(me:mutable);
514 Status(me) returns AsciiString from TCollection is private;
516 Status(me;anObject : InteractiveObject from AIS)
517 returns any LocalStatus from AIS is private;
518 ---C++: return const&
522 LoadContextObjects(me:mutable);
524 UnloadContextObjects(me:mutable);
526 Process(me : mutable;
527 anObject : SelectableObject from SelectMgr;
528 WithProj: Boolean from Standard = Standard_True) is static private;
531 WithProj: Boolean from Standard = Standard_True) is static private;
534 ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
535 WithProj: Boolean from Standard = Standard_True) is static private;
537 manageDetected (me : mutable;
538 thePickOwner : EntityOwner from SelectMgr;
539 theView : View from V3d;
540 theToRedrawImmediate : Boolean from Standard) is static private;
542 DetectedIndex(me:mutable) returns Integer from Standard is static private;
544 ---Purpose: returns 0 if the detected entity was Not FilterOK...
546 Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview: View from V3d) is static private;
549 Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from V3d) is static private;
552 ClearObjects(me:mutable) is static private;
554 ClearDetected(me:mutable) is static private;
556 IsDecompositionOn(me) returns Boolean from Standard is static private;
558 IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
560 IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
562 IsValidIndex(me;anIndex:Integer from Standard)
563 returns Boolean from Standard is static private;
566 ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
567 returns Boolean from Standard is static private;
570 DisplayAreas(me:mutable;aviou:View from V3d);
572 ClearAreas (me:mutable;
573 aView: View from V3d) is static;
576 HasFilters(me;aType:ShapeEnum from TopAbs)
577 returns Boolean from Standard is private;
579 DisplaySensitive(me:mutable;aView : View from V3d) is static;
581 ClearSensitive(me:mutable;aView:View from V3d) is static;
583 MainSelector(me) returns any ViewerSelector3d from StdSelect;
585 ---C++: return const&
587 FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
588 returns EntityOwner from SelectMgr;
590 FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
591 returns EntityOwner from SelectMgr;
597 myCTX : InteractiveContext from AIS;
598 myLoadDisplayed,myAcceptStdMode : Boolean from Standard;
599 myAcceptErase : Boolean from Standard;
601 mySM : SelectionManager from SelectMgr;
602 myMainVS : ViewerSelector3d from StdSelect;
603 myMainPM : PresentationManager3d from PrsMgr;
604 mySelName : AsciiString from TCollection;
605 myCollVS : ViewerSelector3d from StdSelect;
607 -- The Objects and their attributes...
609 myActiveObjects : DataMapOfSelStat from AIS;
614 myFilters : OrFilter from SelectMgr;
615 myListOfStandardMode : ListOfInteger from TColStd;
617 -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
618 myStdFilters : Filter from SelectMgr [9]; --internal mgt
622 myAutoHilight : Boolean from Standard;
623 myMapOfOwner : IndexedMapOfOwner from SelectMgr;
624 mylastindex : Integer from Standard;
625 mylastgood : Integer from Standard;
626 myCurrentOwner : Integer from Standard;
629 myDetectedSeq : SequenceOfInteger from TColStd;
630 myCurDetected : Integer from Standard;
632 -- The detected objects.
634 myAISDetectedSeq : SequenceOfInteractive from AIS;
635 -- the sequence of detected interative objects.
636 myAISCurDetected : Integer from Standard;
637 -- current detected interactive object.
638 -- This variable is used by following functions:
639 -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
643 KeepTemporary from InteractiveContext from AIS(me:mutable;anIObj:InteractiveObject from AIS;WhichMode : Integer from Standard = -1)