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 SensitivityMode from StdSelect,
76 InteractiveContext from AIS,
78 InteractiveObject from AIS,
80 DataMapOfSelStat from AIS,
82 StatusOfPick from AIS,
83 StatusOfDetection from AIS,
84 SequenceOfInteractive from AIS
88 Create returns mutable LocalContext from AIS;
91 Create (aCtx : InteractiveContext from AIS;
92 anIndex : Integer from Standard;
93 LoadDisplayed : Boolean from Standard=Standard_True;
94 AcceptStandardModes : Boolean from Standard=Standard_True;
95 AcceptErase : Boolean from Standard= Standard_False;
96 UseBothViewers : Boolean from Standard= Standard_False)
97 returns mutable LocalContext from AIS;
98 ---Purpose: Constructor By Default, the displayed objects are
99 -- automatically loaded.
102 AcceptErase(me:mutable;aStatus : Boolean from Standard);
104 ---Purpose: authorize or not others contexts to erase
105 -- temporary displayed objects here;
107 AcceptErase(me) returns Boolean from Standard;
110 SetContext(me:mutable;aCtx:InteractiveContext from AIS);
112 SelectionName(me) returns AsciiString from TCollection;
114 ---C++: return const&
117 Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
119 HasSameProjector(me;aPrj:Projector from Select3D)
120 returns Boolean from Standard;
121 ---Purpose: compares the current projector of the localContext
123 -- returns True if the projectors are identical.
124 -- (no need to update projection of selection primitives
125 -- when closing the local context)....
127 Reactivate(me:mutable);
128 ---Purpose: to be called when a upper local context was closed...
129 -- useful to put pack the right projector...
131 ---Category: LOAD AND PREPARE
132 -- - INTERACTIVE OBJECTS...
134 -- - STANDARD MODES OF ACTIVATION
139 Display(me : mutable;
140 anInteractive : InteractiveObject from AIS;
141 DisplayMode : Integer from Standard = 0;
142 AllowShapeDecomposition: Boolean from Standard = Standard_True;
143 ActivationMode : Integer from Standard = 0)
144 returns Boolean from Standard;
145 ---Purpose: returns true if done...
148 anInteractive : InteractiveObject from AIS;
149 AllowShapeDecomposition: Boolean from Standard = Standard_True;
150 ActivationMode : Integer from Standard = 0)
151 returns Boolean from Standard;
152 ---Purpose: loads <anInteractive> with nodisplay...
153 -- returns true if done
156 anInteractive : InteractiveObject from AIS)
157 returns Boolean from Standard;
158 ---Purpose: returns true if done...
162 aSelectable : InteractiveObject from AIS)
163 returns Boolean from Standard;
166 ClearPrs (me : mutable;
167 anInteractive : InteractiveObject from AIS;
168 aMode : Integer from Standard)
169 returns Boolean from Standard;
171 SetShapeDecomposition(me : mutable;
172 aStoredObject : InteractiveObject from AIS;
173 aStatus : Boolean from Standard);
174 ---Purpose: allows or forbids the shape decomposition into
175 -- Activated Standard Mode for <aStoredObject>
176 -- does nothing if the object doesn't inherits
177 -- BasicShape from AIS
180 Clear(me:mutable;atype: ClearMode from AIS = AIS_CM_All);
181 ---Purpose: according to <atype> , clears the different parts of
182 -- the selector (filters, modeof activation, objects...)
187 ActivateMode (me : mutable;
188 aSelectable: InteractiveObject from AIS;
189 aMode : Integer from Standard );
190 ---Purpose: optional : activation of a mode which is not 0 for a selectable...
192 DeactivateMode(me : mutable;
193 aSelectable: InteractiveObject from AIS;
194 aMode : Integer from Standard );
195 Deactivate(me : mutable;
196 aSelectable: InteractiveObject from AIS);
198 ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
199 ---Purpose: decomposition of shapes into <aType>
202 DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
204 StandardModes(me) returns ListOfInteger from TColStd;
205 ---C++: return const &
210 AddFilter(me:mutable;aFilter:Filter from SelectMgr);
212 RemoveFilter(me:mutable;aFilter: Filter from SelectMgr);
215 ListOfFilter(me) returns ListOfFilter from SelectMgr;
216 ---C++: return const &
219 Filter(me) returns any OrFilter from SelectMgr;
220 ---C++: return const &
224 SetAutomaticHilight(me:mutable ; aStatus:Boolean) ;
225 ---Purpose: if <aStatus> = True , the shapes or subshapes detected
226 -- by the selector will be automatically hilighted in the
228 -- Else the user has to manage the detected shape outside the
229 -- Shape Selector....
234 AutomaticHilight(me) returns Boolean;
239 ---Category: THE SELECTION PROCESS
242 MoveTo(me:mutable;Xpix,Ypix : Integer from Standard;
243 aview : View from V3d)
244 returns StatusOfDetection from AIS;
247 HasNextDetected(me) returns Boolean from Standard;
249 ---Purpose: returns True if more than one entity
250 -- was detected at the last Mouse position.
252 HilightNextDetected(me:mutable;aView:View from V3d)
253 returns Integer from Standard;
254 ---Purpose: returns True if last detected. the next detected will
255 -- be first one (endless loop)
257 HilightPreviousDetected(me:mutable;aView:View from V3d)
258 returns Integer from Standard;
261 UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
262 ---Purpose: returns True if something was done...
264 Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
265 returns StatusOfPick from AIS;
266 ---Purpose: returns the number of selected
268 ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
269 returns StatusOfPick from AIS;
272 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
273 aView : View from V3d;
274 updateviewer : Boolean from Standard = Standard_True)
275 returns StatusOfPick from AIS;
278 ShiftSelect(me : mutable;
279 XPMin,YPMin,XPMax,YPMax : Integer from Standard;
280 aView : View from V3d;
281 updateviewer : Boolean from Standard = Standard_True)
282 returns StatusOfPick from AIS;
285 Polyline : Array1OfPnt2d from TColgp;
286 aView : View from V3d;
287 updateviewer : Boolean from Standard = Standard_True)
288 returns StatusOfPick from AIS;
290 ShiftSelect(me : mutable;
291 Polyline : Array1OfPnt2d from TColgp;
292 aView : View from V3d;
293 updateviewer : Boolean from Standard = Standard_True)
294 returns StatusOfPick from AIS;
296 HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
298 UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
301 UpdateSelected (me : mutable;
302 updateviewer : Boolean from Standard = Standard_True);
304 UpdateSelected (me : mutable;
305 anobj : InteractiveObject from AIS;
306 updateviewer : Boolean from Standard = Standard_True);
307 ---Purpose: Part of advanced selection highlighting mechanism.
308 -- If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
309 -- otherwise calls anobj->HilightSelected(). This method can be used to avoid
310 -- redrawing the whole selection belonging to several Selectable Objects.
313 SetSelected(me : mutable;
314 anobj : InteractiveObject from AIS;
315 updateviewer : Boolean from Standard=Standard_True);
316 ---Purpose: useful to update selection with objects coming from
317 -- Collector or stack
319 AddOrRemoveSelected(me : mutable;
320 anobj : InteractiveObject from AIS;
321 updateviewer : Boolean from Standard=Standard_True);
322 ---Purpose: useful to update selection with objects coming from
323 -- Collector or stack
324 AddOrRemoveSelected(me : mutable;
325 aShape : Shape from TopoDS;
326 updateviewer : Boolean from Standard=Standard_True);
328 AddOrRemoveSelected(me : mutable;
329 Ownr : EntityOwner from SelectMgr;
330 updateviewer : Boolean from Standard=Standard_True);
334 ClearSelected(me:mutable;updateviewer : Boolean from Standard=Standard_True);
338 ---Category: GET THE DETECTED
341 HasDetected (me) returns Boolean from Standard;
344 InitDetected(me: mutable);
345 MoreDetected(me) returns Boolean from Standard;
346 NextDetected(me: mutable);
347 DetectedCurrentShape(me) returns Shape from TopoDS;
348 ---C++: return const &
349 DetectedCurrentObject(me) returns InteractiveObject from AIS;
351 HasDetectedShape(me) returns Boolean from Standard;
352 DetectedShape (me) returns Shape from TopoDS;
353 ---C++: return const &
354 DetectedInteractive(me) returns InteractiveObject from AIS;
355 DetectedOwner (me) returns EntityOwner from SelectMgr;
358 ---Category: GET THE SELECTED
360 InitSelected (me: mutable);
361 MoreSelected(me) returns Boolean from Standard;
362 NextSelected(me:mutable);
363 HasShape(me) returns Boolean from Standard;
364 ---Purpose: returns TRUE if the detected entity is a shape
365 -- coming from a Decomposition of an element.
366 SelectedShape(me) returns Shape from TopoDS;
367 ---C++: return const &
369 SelectedOwner(me) returns EntityOwner from SelectMgr;
370 IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard;
371 IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
372 SelectedInteractive(me) returns InteractiveObject from AIS;
373 HasApplicative (me) returns Boolean from Standard;
374 ---Purpose: returns TRUE if an interactive element
375 -- was associated with the current picked entity.
376 SelectedApplicative(me) returns any Transient from Standard;
377 ---C++: return const &
384 ---Category: Management Of Temporary Attributes
386 SetDisplayPriority(me : mutable;
387 anObject: InteractiveObject from AIS;
388 Prior : Integer from Standard);
390 SetZLayer( me : mutable;
391 theIObj : InteractiveObject from AIS;
392 theLayerId : Integer from Standard );
393 ---Purpose: Set Z layer id for interactive object. The layer can be
394 -- specified for displayed object only. The Z layers can be used to display
395 -- temporarily presentations of some object in front of the other objects
396 -- in the scene. The ids for Z layers are generated by V3d_Viewer.
397 -- Note that Z layers differ from under-/overlayer in V3d_View:
398 -- under-/overlayer are intended for specific 2D drawings that appear
399 -- behind/in front of all 3D presentations, while SetZLayer() method
400 -- applies to regular 3D presentations and does not imply any specific
404 theIObj : InteractiveObject from AIS )
405 returns Integer from Standard;
406 ---Purpose: Get Z layer id set for displayed interactive object.
407 -- If the object doesn't exists in context or has no computed presentations,
408 -- the method returns -1.
410 DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
411 returns Integer from Standard;
413 IsIn(me;anObject : InteractiveObject from AIS)
414 returns Boolean from Standard;
417 IsDisplayed(me;anObject : InteractiveObject from AIS)
418 returns Boolean from Standard;
420 IsDisplayed(me;anObject : InteractiveObject from AIS;
421 aMode : Integer from Standard)
422 returns Boolean from Standard;
424 SelectionModes(me;anObject:InteractiveObject from AIS)
425 returns ListOfInteger from TColStd;
426 ---C++: return const &
428 SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS );
430 SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS );
432 Hilight(me: mutable; anObject : InteractiveObject from AIS);
434 Hilight(me:mutable; anObject : InteractiveObject from AIS;aCol:NameOfColor from Quantity);
436 Unhilight(me:mutable; anObject : InteractiveObject from AIS);
438 IsHilighted(me;anObject : InteractiveObject from AIS)
439 returns Boolean from Standard;
442 anObject : InteractiveObject from AIS;
443 WithColor : out Boolean from Standard;
444 HiCol : out NameOfColor from Quantity)
445 returns Boolean from Standard;
447 SetSensitivityMode(me : mutable;
448 aMode : SensitivityMode from StdSelect) is static;
450 ---Purpose: Sets the selection sensitivity mode. SM_WINDOW mode
451 -- uses the specified pixel tolerance to compute the sensitivity
452 -- value, SM_VIEW mode allows to define the sensitivity manually.
454 SensitivityMode(me) returns SensitivityMode from StdSelect;
456 ---Purpose: Returns the selection sensitivity mode.
458 SetSensitivity(me:mutable;
459 aPrecision: Real from Standard);
461 ---Purpose: Define the current selection sensitivity for
462 -- this local context according to the view size.
464 Sensitivity (me) returns Real from Standard;
466 ---Purpose: Returns the selection sensitivity value.
468 SetPixelTolerance(me:mutable;
469 aPrecision: Integer from Standard = 2);
471 ---Purpose: Define the current selection sensitivity for
472 -- this local context according to the view size.
474 PixelTolerance(me) returns Integer from Standard;
476 ---Purpose: Returns the pixel tolerance.
478 ---Category: IMMEDIATE MODE
481 BeginImmediateDraw (me:mutable) returns Boolean from Standard;
482 ---Purpose: initializes the list of presentations to be displayed
483 -- returns False if No Local COnte
485 ImmediateAdd (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
486 returns Boolean from Standard;
487 ---Purpose: returns True if <anIObj> has been stored in the list.
489 ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
490 returns Boolean from Standard;
491 ---Purpose: returns True if <anIObj> has been removed from the list.
493 EndImmediateDraw(me:mutable;aView : View from V3d;DoubleBuf:Boolean from Standard=Standard_False)
494 returns Boolean from Standard;
495 ---Purpose: returns True if the immediate display has been done.
497 IsImmediateModeOn(me) returns Boolean from Standard;
499 ---Category: INTERNAL METHODS;
501 UpdateConversion(me:mutable);
503 UpdateSort(me:mutable);
507 Status(me) returns AsciiString from TCollection is private;
509 Status(me;anObject : InteractiveObject from AIS)
510 returns any LocalStatus from AIS is private;
511 ---C++: return const&
515 LoadContextObjects(me:mutable);
517 UnloadContextObjects(me:mutable);
519 Process(me : mutable;
520 anObject : SelectableObject from SelectMgr;
521 WithProj: Boolean from Standard = Standard_True) is static private;
524 WithProj: Boolean from Standard = Standard_True) is static private;
527 ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
528 WithProj: Boolean from Standard = Standard_True) is static private;
530 ManageDetected(me:mutable;
531 aPickOwner : EntityOwner from SelectMgr;
532 aview : View from V3d) is static private;
534 DetectedIndex(me:mutable) returns Integer from Standard is static private;
536 ---Purpose: returns 0 if the detected entity was Not FilterOK...
538 Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview: View from V3d) is static private;
541 Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from V3d) is static private;
544 ClearObjects(me:mutable) is static private;
546 ClearDetected(me:mutable) is static private;
548 IsDecompositionOn(me) returns Boolean from Standard is static private;
550 IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
552 IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
554 IsValidIndex(me;anIndex:Integer from Standard)
555 returns Boolean from Standard is static private;
558 ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
559 returns Boolean from Standard is static private;
562 DisplayAreas(me:mutable;aviou:View from V3d);
564 ClearAreas (me:mutable;
565 aView: View from V3d) is static;
568 HasFilters(me;aType:ShapeEnum from TopAbs)
569 returns Boolean from Standard is private;
571 DisplaySensitive(me:mutable;aView : View from V3d) is static;
573 ClearSensitive(me:mutable;aView:View from V3d) is static;
577 MainSelector(me) returns any ViewerSelector3d from StdSelect;
579 ---C++: return const&
582 HilightTriangle(me:mutable;Rank:Integer from Standard;aViou:View from V3d) is static private;
586 FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
587 returns EntityOwner from SelectMgr;
589 FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
590 returns EntityOwner from SelectMgr;
596 myCTX : InteractiveContext from AIS;
597 myLoadDisplayed,myAcceptStdMode : Boolean from Standard;
598 myAcceptErase : Boolean from Standard;
600 mySM : SelectionManager from SelectMgr;
601 myMainVS : ViewerSelector3d from StdSelect;
602 myMainPM : PresentationManager3d from PrsMgr;
603 mySelName : AsciiString from TCollection;
604 myCollVS : ViewerSelector3d from StdSelect;
606 -- The Objects and their attributes...
608 myActiveObjects : DataMapOfSelStat from AIS;
613 myFilters : OrFilter from SelectMgr;
614 myListOfStandardMode : ListOfInteger from TColStd;
616 -- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
617 myStdFilters : Filter from SelectMgr [9]; --internal mgt
621 myAutoHilight : Boolean from Standard;
622 myMapOfOwner : IndexedMapOfOwner from SelectMgr;
623 mylastindex : Integer from Standard;
624 mylastgood : Integer from Standard;
625 myCurrentOwner : Integer from Standard;
628 myDetectedSeq : SequenceOfInteger from TColStd;
629 myCurDetected : Integer from Standard;
631 -- the detected objects.
632 myAISDetectedSeq : SequenceOfInteractive from AIS;
633 myAISCurDetected : Integer from Standard;
634 -- This variables is used by following functions:
635 -- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
639 KeepTemporary from InteractiveContext from AIS(me:mutable;anIObj:InteractiveObject from AIS;WhichMode : Integer from Standard = -1)