1 // Created on: 1996-12-18
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 #ifndef _AIS_InteractiveContext_HeaderFile
18 #define _AIS_InteractiveContext_HeaderFile
20 #include <AIS_DataMapOfILC.hxx>
21 #include <AIS_DataMapOfIOStatus.hxx>
22 #include <AIS_DisplayMode.hxx>
23 #include <AIS_DisplayStatus.hxx>
24 #include <AIS_ClearMode.hxx>
25 #include <AIS_KindOfInteractive.hxx>
26 #include <AIS_ListOfInteractive.hxx>
27 #include <AIS_Selection.hxx>
28 #include <AIS_SelectionModesConcurrency.hxx>
29 #include <AIS_StatusOfDetection.hxx>
30 #include <AIS_StatusOfPick.hxx>
31 #include <AIS_TypeOfIso.hxx>
32 #include <Aspect_TypeOfFacingModel.hxx>
33 #include <Prs3d_Drawer.hxx>
34 #include <Prs3d_TypeOfHighlight.hxx>
35 #include <PrsMgr_PresentationManager3d.hxx>
36 #include <SelectMgr_IndexedMapOfOwner.hxx>
37 #include <SelectMgr_ListOfFilter.hxx>
38 #include <SelectMgr_PickingStrategy.hxx>
39 #include <Standard.hxx>
40 #include <Standard_Type.hxx>
41 #include <StdSelect_ViewerSelector3d.hxx>
42 #include <TCollection_AsciiString.hxx>
43 #include <TColgp_Array1OfPnt2d.hxx>
44 #include <TColStd_ListOfInteger.hxx>
45 #include <TopAbs_ShapeEnum.hxx>
46 #include <Quantity_Color.hxx>
48 class SelectMgr_SelectionManager;
50 class AIS_InteractiveObject;
51 class SelectMgr_OrFilter;
53 class AIS_LocalContext;
54 class TopLoc_Location;
55 class TCollection_ExtendedString;
56 class Prs3d_LineAspect;
57 class Prs3d_BasicAspect;
58 class SelectMgr_EntityOwner;
59 class SelectMgr_Filter;
60 class TCollection_AsciiString;
62 //! The Interactive Context allows you to manage graphic behavior and selection of Interactive Objects in one or more viewers.
63 //! Class methods make this highly transparent.
64 //! It is essential to remember that an Interactive Object which is already known by the Interactive Context must be modified using Context methods.
65 //! You can only directly call the methods available for an Interactive Object if it has not been loaded into an Interactive Context.
67 //! Each selectable object must specify the selection mode that is
68 //! responsible for selection of object as a whole (global selection mode).
69 //! Interactive context itself supports decomposed object selection with selection filters support.
70 //! By default, global selection mode is equal to 0, but it might be redefined if needed.
71 class AIS_InteractiveContext : public Standard_Transient
73 friend class AIS_LocalContext;
74 DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
75 public: //! @name object display management
77 //! Constructs the interactive context object defined by the principal viewer MainViewer.
78 Standard_EXPORT AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer);
81 Standard_EXPORT virtual ~AIS_InteractiveContext();
83 //! Returns the display status of the entity anIobj.
84 //! This will be one of the following:
85 //! - AIS_DS_Displayed displayed in main viewer
86 //! - AIS_DS_Erased hidden in main viewer
87 //! - AIS_DS_Temporary temporarily displayed
88 //! - AIS_DS_None nowhere displayed.
89 Standard_EXPORT AIS_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const;
91 //! Returns the status of the Interactive Context for the view of the Interactive Object.
92 Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const;
94 //! Returns true if Object is displayed in the interactive context.
95 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const;
97 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer aMode) const;
99 //! Enable or disable automatic activation of default selection mode while displaying the object.
100 void SetAutoActivateSelection (const Standard_Boolean theIsAuto) { myIsAutoActivateSelMode = theIsAuto; }
102 //! Manages displaying the new object should also automatically activate default selection mode; TRUE by default.
103 Standard_Boolean GetAutoActivateSelection() const { return myIsAutoActivateSelMode; }
105 //! Displays the object in this Context using default Display Mode.
106 //! This will be the object's default display mode, if there is one. Otherwise, it will be the context mode.
107 //! The Interactive Object's default selection mode is activated if GetAutoActivateSelection() is TRUE. In general, this is 0.
108 Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj,
109 const Standard_Boolean theToUpdateViewer);
111 //! Sets status, display mode and selection mode for specified Object
112 //! If theSelectionMode equals -1, theIObj will not be activated: it will be displayed but will not be selectable.
113 Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj,
114 const Standard_Integer theDispMode,
115 const Standard_Integer theSelectionMode,
116 const Standard_Boolean theToUpdateViewer,
117 const Standard_Boolean theToAllowDecomposition = Standard_True,
118 const AIS_DisplayStatus theDispStatus = AIS_DS_None);
120 //! Allows you to load the Interactive Object with a given selection mode,
121 //! and/or with the desired decomposition option, whether the object is visualized or not.
122 //! If AllowDecomp = Standard_True and, if the interactive object is of the "Shape" type,
123 //! these "standard" selection modes will be automatically activated as a function of the modes present in the Local Context.
124 //! The loaded objects will be selectable but displayable in highlighting only when detected by the Selector.
125 Standard_EXPORT void Load (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer SelectionMode = -1, const Standard_Boolean AllowDecomp = Standard_False);
127 //! Hides the object. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
128 //! To show hidden objects, use Display().
129 Standard_EXPORT void Erase (const Handle(AIS_InteractiveObject)& theIObj,
130 const Standard_Boolean theToUpdateViewer);
132 //! Hides all objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
133 //! To show all hidden objects, use DisplayAll().
134 Standard_EXPORT void EraseAll (const Standard_Boolean theToUpdateViewer);
136 //! Displays all hidden objects.
137 Standard_EXPORT void DisplayAll (const Standard_Boolean theToUpdateViewer);
139 //! Hides selected objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
140 //! To show hidden objects, use Display().
141 Standard_EXPORT void EraseSelected (const Standard_Boolean theToUpdateViewer);
143 //! Displays current objects.
144 Standard_EXPORT void DisplaySelected (const Standard_Boolean theToUpdateViewer);
146 //! Empties the graphic presentation of the mode indexed by aMode.
147 //! Warning! Removes theIObj. theIObj is still active if it was previously activated.
148 Standard_EXPORT void ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
149 const Standard_Integer theMode,
150 const Standard_Boolean theToUpdateViewer);
152 //! Removes Object from every viewer.
153 Standard_EXPORT void Remove (const Handle(AIS_InteractiveObject)& theIObj,
154 const Standard_Boolean theToUpdateViewer);
156 //! Removes all the objects from all opened Local Contexts and from the Neutral Point.
157 Standard_EXPORT void RemoveAll (const Standard_Boolean theToUpdateViewer);
159 //! Recomputes the seen parts presentation of the Object.
160 //! If theAllModes equals true, all presentations are present in the object even if unseen.
161 Standard_EXPORT void Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
162 const Standard_Boolean theToUpdateViewer,
163 const Standard_Boolean theAllModes = Standard_False);
165 //! Recomputes the Prs/Selection of displayed objects of a given type and a given signature.
166 //! if signature = -1 doesn't take signature criterion.
167 Standard_EXPORT void Redisplay (const AIS_KindOfInteractive theTypeOfObject,
168 const Standard_Integer theSignature,
169 const Standard_Boolean theToUpdateViewer);
171 //! Recomputes the displayed presentations, flags the others.
172 //! Doesn't update presentations.
173 Standard_EXPORT void RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
174 const Standard_Boolean theToUpdateViewer,
175 const Standard_Boolean theAllModes = Standard_False);
177 //! Recomputes the active selections, flags the others.
178 //! Doesn't update presentations.
179 Standard_EXPORT void RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& anIObj);
181 //! Updates displayed interactive object by checking and recomputing its flagged as "to be recomputed" presentation and selection structures.
182 //! This method does not force any recomputation on its own.
183 //! The method recomputes selections even if they are loaded without activation in particular selector.
184 Standard_EXPORT void Update (const Handle(AIS_InteractiveObject)& theIObj,
185 const Standard_Boolean theUpdateViewer);
187 public: //! @name highlighting management
189 //! Returns highlight style settings.
190 const Handle(Prs3d_Drawer)& HighlightStyle (const Prs3d_TypeOfHighlight theStyleType) const { return myStyles[theStyleType]; }
192 //! Setup highlight style settings.
193 void SetHighlightStyle (const Prs3d_TypeOfHighlight theStyleType,
194 const Handle(Prs3d_Drawer)& theStyle) { myStyles[theStyleType] = theStyle; }
196 //! Returns current dynamic highlight style settings.
198 //! - the color of dynamic highlight is Quantity_NOC_CYAN1;
199 //! - the presentation for dynamic highlight is completely opaque;
200 //! - the type of highlight is Aspect_TOHM_COLOR.
201 const Handle(Prs3d_Drawer)& HighlightStyle() const
203 return myStyles[Prs3d_TypeOfHighlight_Dynamic];
206 //! Setup the style of dynamic highlighting.
207 void SetHighlightStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle; }
209 //! Returns current selection style settings.
211 //! - the color of selection is Quantity_NOC_GRAY80;
212 //! - the presentation for selection is completely opaque;
213 //! - the type of highlight is Aspect_TOHM_COLOR.
214 const Handle(Prs3d_Drawer)& SelectionStyle() const
216 return myStyles[Prs3d_TypeOfHighlight_Selected];
219 //! Setup the style of selection highlighting.
220 void SetSelectionStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Selected] = theStyle; }
222 //! Returns highlight style of the object if it is marked as highlighted via global status
223 //! @param theObj [in] the object to check
224 Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObj,
225 Handle(Prs3d_Drawer)& theStyle) const;
227 //! Returns highlight style of the owner if it is selected
228 //! @param theOwner [in] the owner to check
229 Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
230 Handle(Prs3d_Drawer)& theStyle) const;
232 //! Returns true if the object is marked as highlighted via its global status
233 //! @param theObj [in] the object to check
234 Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const;
236 //! Returns true if the owner is marked as selected
237 //! @param theOwner [in] the owner to check
238 Standard_EXPORT Standard_Boolean IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const;
240 //! Updates the display in the viewer to take dynamic detection into account.
241 //! On dynamic detection by the mouse cursor, sensitive primitives are highlighted.
242 //! The highlight color of entities detected by mouse movement is white by default.
243 Standard_DEPRECATED("Deprecated method Hilight()")
244 void Hilight (const Handle(AIS_InteractiveObject)& theObj,
245 const Standard_Boolean theIsToUpdateViewer)
247 return HilightWithColor (theObj, myStyles[Prs3d_TypeOfHighlight_Dynamic], theIsToUpdateViewer);
250 //! Changes the color of all the lines of the object in view.
251 Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& theObj,
252 const Handle(Prs3d_Drawer)& theStyle,
253 const Standard_Boolean theToUpdateViewer);
255 //! Removes hilighting from the Object.
256 Standard_EXPORT void Unhilight (const Handle(AIS_InteractiveObject)& theIObj,
257 const Standard_Boolean theToUpdateViewer);
259 public: //! @name object presence management (View affinity, Layer, Priority)
261 //! Returns the display priority of the Object.
262 Standard_EXPORT Standard_Integer DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const;
264 //! Sets the display priority of the seen parts presentation of the Object.
265 Standard_EXPORT void SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Integer thePriority);
267 //! Get Z layer id set for displayed interactive object.
268 Standard_EXPORT Standard_Integer GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const;
270 //! Set Z layer id for interactive object.
271 //! The Z layers can be used to display temporarily presentations of some object in front of the other objects in the scene.
272 //! The ids for Z layers are generated by V3d_Viewer.
273 Standard_EXPORT void SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Integer theLayerId);
275 //! Setup object visibility in specified view.
276 //! Has no effect if object is not displayed in this context.
277 Standard_EXPORT void SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisible);
279 public: //! @name Display Mode management
281 //! Returns the Display Mode setting to be used by default.
282 Standard_Integer DisplayMode() const { return myDefaultDrawer->DisplayMode(); }
284 //! Sets the display mode of seen Interactive Objects (which have no overridden Display Mode).
285 Standard_EXPORT void SetDisplayMode (const Standard_Integer theMode,
286 const Standard_Boolean theToUpdateViewer);
288 //! Sets the display mode of seen Interactive Objects.
289 //! theMode provides the display mode index of the entity theIObj.
290 Standard_EXPORT void SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
291 const Standard_Integer theMode,
292 const Standard_Boolean theToUpdateViewer);
294 //! Unsets the display mode of seen Interactive Objects.
295 Standard_EXPORT void UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
296 const Standard_Boolean theToUpdateViewer);
298 public: //! @name object local transformation management
300 //! Puts the location on the initial graphic representation and the selection for the Object.
301 Standard_EXPORT void SetLocation (const Handle(AIS_InteractiveObject)& theObject, const TopLoc_Location& theLocation);
303 //! Puts the Object back into its initial position.
304 Standard_EXPORT void ResetLocation (const Handle(AIS_InteractiveObject)& theObject);
306 //! Returns true if the Object has a location.
307 Standard_EXPORT Standard_Boolean HasLocation (const Handle(AIS_InteractiveObject)& theObject) const;
309 //! Returns the location of the Object.
310 Standard_EXPORT TopLoc_Location Location (const Handle(AIS_InteractiveObject)& theObject) const;
312 //! Sets transform persistence.
313 Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
314 const Handle(Graphic3d_TransformPers)& theTrsfPers);
316 Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
317 void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj,
318 const Graphic3d_TransModeFlags& theFlag,
319 const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
321 SetTransformPersistence (theObj, Graphic3d_TransformPers::FromDeprecatedParams (theFlag, thePoint));
324 public: //! @name mouse picking logic (detection and dynamic highlighting of entities under cursor)
326 //! Setup pixel tolerance for MoveTo() operation.
328 Standard_EXPORT void SetPixelTolerance (const Standard_Integer thePrecision = 2);
330 //! Returns the pixel tolerance, default is 2.
331 //! Pixel Tolerance extends sensitivity within MoveTo() operation (picking by point)
332 //! and can be adjusted by application based on user input precision (e.g. screen pixel density, input device precision, etc.).
333 Standard_EXPORT Standard_Integer PixelTolerance() const;
335 //! Allows to manage sensitivity of a particular selection of interactive object theObject
336 //! and changes previous sensitivity value of all sensitive entities in selection with theMode
337 //! to the given theNewSensitivity.
338 Standard_EXPORT void SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject,
339 const Standard_Integer theMode,
340 const Standard_Integer theNewSensitivity);
342 //! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
343 //! This is done by the view theView passing this position to the main viewer and updating it.
344 //! Functions in both Neutral Point and local contexts.
345 //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
346 //! @sa PickingStrategy()
347 Standard_EXPORT AIS_StatusOfDetection MoveTo (const Standard_Integer theXPix,
348 const Standard_Integer theYPix,
349 const Handle(V3d_View)& theView,
350 const Standard_Boolean theToRedrawOnUpdate);
352 //! Returns true if there is a mouse-detected entity in context.
353 //! @sa DetectedOwner()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected().
354 Standard_EXPORT Standard_Boolean HasDetected() const;
356 //! Returns the owner of the detected sensitive primitive which is currently dynamically highlighted.
357 //! WARNING! This method is irrelevant to InitDetected()/MoreDetected()/NextDetected().
358 //! @sa HasDetected()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected().
359 Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedOwner() const;
361 //! Returns the interactive objects last detected in context.
362 //! In general this is just a wrapper for Handle(AIS_InteractiveObject)::DownCast(DetectedOwner()->Selectable()).
363 //! @sa DetectedOwner()
364 Standard_EXPORT Handle(AIS_InteractiveObject) DetectedInteractive() const;
366 //! Returns true if there is a detected shape in local context.
367 //! @sa HasDetected()/DetectedShape()
368 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
369 Standard_EXPORT Standard_Boolean HasDetectedShape() const;
371 //! Returns the shape detected in local context.
372 //! @sa DetectedOwner()
373 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
374 Standard_EXPORT const TopoDS_Shape& DetectedShape() const;
376 //! returns True if other entities were detected in the last mouse detection
377 //! @sa HilightPreviousDetected()/HilightNextDetected().
378 Standard_EXPORT Standard_Boolean HasNextDetected() const;
380 //! If more than 1 object is detected by the selector, only the "best" owner is hilighted at the mouse position.
381 //! This Method allows the user to hilight one after another the other detected entities.
382 //! If The method select is called, the selected entity will be the hilighted one!
383 //! WARNING: Loop Method. When all the detected entities have been hilighted, the next call will hilight the first one again.
384 //! @return the Rank of hilighted entity
385 //! @sa HasNextDetected()/HilightPreviousDetected().
386 Standard_EXPORT Standard_Integer HilightNextDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True);
388 //! Same as previous methods in reverse direction.
389 //! @sa HasNextDetected()/HilightNextDetected().
390 Standard_EXPORT Standard_Integer HilightPreviousDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True);
392 public: //! @name iteration through detected entities
394 //! Initialization for iteration through mouse-detected objects in
395 //! interactive context or in local context if it is opened.
396 //! @sa DetectedCurrentOwner()/MoreDetected()/NextDetected().
397 Standard_EXPORT void InitDetected();
399 //! Return TRUE if there is more mouse-detected objects after the current one
400 //! during iteration through mouse-detected interactive objects.
401 //! @sa DetectedCurrentOwner()/InitDetected()/NextDetected().
402 Standard_EXPORT Standard_Boolean MoreDetected() const;
404 //! Gets next current object during iteration through mouse-detected interactive objects.
405 //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected().
406 Standard_EXPORT void NextDetected();
408 //! Returns the owner from detected list pointed by current iterator position.
409 //! WARNING! This method is irrelevant to DetectedOwner() which returns last picked Owner regardless of iterator position!
410 //! @sa InitDetected()/MoreDetected()/NextDetected().
411 Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedCurrentOwner() const;
413 public: //! @name Selection management
415 //! Sets the graphic basic aspect to the current presentation of ALL selected objects.
416 Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
417 const Standard_Boolean theToUpdateViewer);
419 //! Adds object in the selection.
420 Standard_EXPORT AIS_StatusOfPick AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
422 //! Adds object in the selection.
423 AIS_StatusOfPick AddSelect (const Handle(AIS_InteractiveObject)& theObject)
425 return AddSelect (theObject->GlobalSelOwner());
428 //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
429 //! The objects detected are passed to the main viewer, which is then updated.
430 Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
431 const Standard_Integer theYPMin,
432 const Standard_Integer theXPMax,
433 const Standard_Integer theYPMax,
434 const Handle(V3d_View)& theView,
435 const Standard_Boolean theToUpdateViewer);
437 //! polyline selection; clears the previous picked list
438 Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
439 const Handle(V3d_View)& theView,
440 const Standard_Boolean theToUpdateViewer);
442 //! Stores and hilights the previous detected; Unhilights the previous picked.
444 Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean theToUpdateViewer);
446 //! Adds the last detected to the list of previous picked.
447 //! If the last detected was already declared as picked, removes it from the Picked List.
449 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean theToUpdateViewer);
451 //! Adds the last detected to the list of previous picked.
452 //! If the last detected was already declared as picked, removes it from the Picked List.
453 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
454 const Handle(V3d_View)& theView,
455 const Standard_Boolean theToUpdateViewer);
457 //! Rectangle of selection; adds new detected entities into the picked list,
458 //! removes the detected entities that were already stored.
459 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Integer theXPMin,
460 const Standard_Integer theYPMin,
461 const Standard_Integer theXPMax,
462 const Standard_Integer theYPMax,
463 const Handle(V3d_View)& theView,
464 const Standard_Boolean theToUpdateViewer);
466 //! Fits the view correspondingly to the bounds of selected objects.
467 //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
468 Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
469 const Standard_Real theMargin,
470 const Standard_Boolean theToUpdate);
472 //! Fits the view correspondingly to the bounds of selected objects.
473 //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
474 Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView);
476 //! Specify whether selected object must be hilighted when mouse cursor is moved above it (in MoveTo method).
477 //! By default this value is false and selected object is not hilighted in this case.
478 void SetToHilightSelected (const Standard_Boolean toHilight) { myToHilightSelected = toHilight; }
480 //! Return value specified whether selected object must be hilighted when mouse cursor is moved above it
481 Standard_Boolean ToHilightSelected() const { return myToHilightSelected; }
483 //! Unhighlights previously selected owners and marks them as not selected.
484 //! Marks owner given as selected and highlights it.
485 //! Performs selection filters check.
486 Standard_EXPORT void SetSelected (const Handle(SelectMgr_EntityOwner)& theOwners,
487 const Standard_Boolean theToUpdateViewer);
489 //! Puts the interactive object aniObj in the list of selected objects.
490 //! Performs selection filters check.
491 Standard_EXPORT void SetSelected (const Handle(AIS_InteractiveObject)& theObject,
492 const Standard_Boolean theToUpdateViewer);
494 //! Allows to highlight or unhighlight the owner given depending on its selection status
495 Standard_EXPORT void AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
496 const Standard_Boolean theToUpdateViewer);
498 //! Highlights selected objects.
499 Standard_EXPORT void HilightSelected (const Standard_Boolean theToUpdateViewer);
501 //! Removes highlighting from selected objects.
502 Standard_EXPORT void UnhilightSelected (const Standard_Boolean theToUpdateViewer);
504 //! Updates the list of selected objects:
505 //! i.e. highlights the newely selected ones and unhighlights previously selected objects.
506 //! @sa HilightSelected().
507 Standard_EXPORT void UpdateSelected (const Standard_Boolean theToUpdateViewer);
509 //! Empties previous selected objects in order to get the selected objects detected by the selector using UpdateSelected.
510 Standard_EXPORT void ClearSelected (const Standard_Boolean theToUpdateViewer);
512 //! No right to Add a selected Shape (Internal Management of shape Selection).
513 //! A Previous selected shape may only be removed.
514 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
515 Standard_EXPORT void AddOrRemoveSelected (const TopoDS_Shape& theShape,
516 const Standard_Boolean theToUpdateViewer);
518 //! Allows to highlight or unhighlight the owner given depending on its selection status
519 Standard_EXPORT void AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
520 const Standard_Boolean theToUpdateViewer);
522 //! Returns true is the owner given is selected
523 Standard_EXPORT Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const;
525 //! Returns true is the object given is selected
526 Standard_EXPORT Standard_Boolean IsSelected (const Handle(AIS_InteractiveObject)& theObj) const;
528 //! Returns the first selected object in the list of current selected.
529 Standard_EXPORT Handle(AIS_InteractiveObject) FirstSelectedObject();
531 //! Count a number of selected entities using InitSelected()+MoreSelected()+NextSelected() iterator.
532 //! @sa SelectedOwner()/InitSelected()/MoreSelected()/NextSelected().
533 Standard_EXPORT Standard_Integer NbSelected();
535 //! Initializes a scan of the selected objects.
536 //! @sa SelectedOwner()/MoreSelected()/NextSelected().
537 Standard_EXPORT void InitSelected();
539 //! Returns true if there is another object found by the scan of the list of selected objects.
540 //! @sa SelectedOwner()/InitSelected()/NextSelected().
541 Standard_EXPORT Standard_Boolean MoreSelected() const;
543 //! Continues the scan to the next object in the list of selected objects.
544 //! @sa SelectedOwner()/InitSelected()/MoreSelected().
545 Standard_EXPORT void NextSelected();
547 //! Returns the owner of the selected entity.
548 //! @sa InitSelected()/MoreSelected()/NextSelected().
549 Standard_EXPORT Handle(SelectMgr_EntityOwner) SelectedOwner() const;
551 //! Return Handle(AIS_InteractiveObject)::DownCast (SelectedOwner()->Selectable()).
552 //! @sa SelectedOwner().
553 Standard_EXPORT Handle(AIS_InteractiveObject) SelectedInteractive() const;
555 //! Returns TRUE if the interactive context has a shape selected.
556 //! @sa SelectedShape().
557 Standard_EXPORT Standard_Boolean HasSelectedShape() const;
559 //! Returns the selected shape.
560 //! Basically it is just a shape returned stored by StdSelect_BRepOwner with graphic transformation being applied:
562 //! const Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (SelectedOwner());
563 //! TopoDS_Shape aSelShape = aBRepOwner->Shape();
564 //! TopoDS_Shape aLocatedShape = aSelShape.Located (aBRepOwner->Location() * aSelShape.Location());
566 //! @sa SelectedOwner()/HasSelectedShape().
567 Standard_EXPORT TopoDS_Shape SelectedShape() const;
569 //! Returns SelectedInteractive()->HasOwner().
570 //! @sa SelectedOwner().
571 Standard_EXPORT Standard_Boolean HasApplicative() const;
573 //! Returns SelectedInteractive()->GetOwner().
574 //! @sa SelectedOwner().
575 Standard_EXPORT Handle(Standard_Transient) Applicative() const;
577 public: //! @name immediate mode rendering
579 //! initializes the list of presentations to be displayed
580 //! returns False if no local context is opened.
581 Standard_EXPORT Standard_Boolean BeginImmediateDraw();
583 //! returns True if <anIObj> has been stored in the list.
584 Standard_EXPORT Standard_Boolean ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0);
586 //! returns True if the immediate display has been done.
587 Standard_EXPORT Standard_Boolean EndImmediateDraw (const Handle(V3d_View)& theView);
589 //! Uses the First Active View of Main Viewer!
590 //! returns True if the immediate display has been done.
591 Standard_EXPORT Standard_Boolean EndImmediateDraw();
593 Standard_EXPORT Standard_Boolean IsImmediateModeOn() const;
595 //! Redraws immediate structures in all views of the viewer given taking into account its visibility.
596 Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer);
598 public: //! @name management of active Selection Modes
600 //! Activates or deactivates the selection mode for specified object.
601 //! Has no effect if selection mode was already active/deactivated.
602 //! @param theObj object to activate/deactivate selection mode
603 //! @param theMode selection mode to activate/deactivate;
604 //! deactivation of -1 selection mode will effectively deactivate all selection modes;
605 //! activation of -1 selection mode with AIS_SelectionModesConcurrency_Single
606 //! will deactivate all selection modes, and will has no effect otherwise
607 //! @param theToActivate activation/deactivation flag
608 //! @param theConcurrency specifies how to handle already activated selection modes;
609 //! default value (AIS_SelectionModesConcurrency_Multiple) means active selection modes should be left as is,
610 //! AIS_SelectionModesConcurrency_Single can be used if only one selection mode is expected to be active
611 //! and AIS_SelectionModesConcurrency_GlobalOrLocal can be used if either AIS_InteractiveObject::GlobalSelectionMode()
612 //! or any combination of Local selection modes is acceptable;
613 //! this value is considered only if theToActivate set to TRUE
614 //! @param theIsForce when set to TRUE, the display status will be ignored while activating selection mode
615 Standard_EXPORT void SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
616 const Standard_Integer theMode,
617 const Standard_Boolean theToActivate,
618 const AIS_SelectionModesConcurrency theConcurrency = AIS_SelectionModesConcurrency_Multiple,
619 const Standard_Boolean theIsForce = Standard_False);
621 //! Activates the selection mode aMode whose index is given, for the given interactive entity anIobj.
622 void Activate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0, const Standard_Boolean theIsForce = Standard_False)
624 SetSelectionModeActive (theObj, theMode, Standard_True, AIS_SelectionModesConcurrency_GlobalOrLocal, theIsForce);
627 //! Activates the given selection mode for the all displayed objects.
628 Standard_EXPORT void Activate (const Standard_Integer theMode,
629 const Standard_Boolean theIsForce = Standard_False);
631 //! Deactivates all the activated selection modes of an object.
632 void Deactivate (const Handle(AIS_InteractiveObject)& theObj)
634 SetSelectionModeActive (theObj, -1, Standard_False, AIS_SelectionModesConcurrency_Single);
637 //! Deactivates all the activated selection modes of the interactive object anIobj with a given selection mode aMode.
638 void Deactivate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode)
640 SetSelectionModeActive (theObj, theMode, Standard_False);
643 //! Deactivates the given selection mode for all displayed objects.
644 Standard_EXPORT void Deactivate (const Standard_Integer theMode);
646 //! Deactivates all the activated selection mode at all displayed objects.
647 Standard_EXPORT void Deactivate();
649 //! Returns the list of activated selection modes in an open context.
650 Standard_EXPORT void ActivatedModes (const Handle(AIS_InteractiveObject)& anIobj, TColStd_ListOfInteger& theList) const;
652 //! Returns a collection containing all entity owners created for the interactive object in specified selection mode (in all active modes if the Mode == -1)
653 Standard_EXPORT void EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
654 const Handle(AIS_InteractiveObject)& theIObj,
655 const Standard_Integer theMode = -1) const;
657 public: //! @name Selection Filters management
659 //! Returns the list of filters active in a local context.
660 Standard_EXPORT const SelectMgr_ListOfFilter& Filters() const;
662 //! Allows you to add the filter.
663 Standard_EXPORT void AddFilter (const Handle(SelectMgr_Filter)& theFilter);
665 //! Removes a filter from context.
666 Standard_EXPORT void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter);
668 //! Remove all filters from context.
669 Standard_EXPORT void RemoveFilters();
671 //! Return picking strategy; SelectMgr_PickingStrategy_FirstAcceptable by default.
672 //! @sa MoveTo()/Filters()
673 SelectMgr_PickingStrategy PickingStrategy() const { return myPickingStrategy; }
675 //! Setup picking strategy - which entities detected by picking line will be accepted, considering Selection Filters.
676 //! By default (SelectMgr_PickingStrategy_FirstAcceptable), Selection Filters reduce the list of entities
677 //! so that the context accepts topmost in remaining.
679 //! This means that entities behind non-selectable (by filters) parts can be picked by user.
680 //! If this behavior is undesirable, and user wants that non-selectable (by filters) parts
681 //! should remain an obstacle for picking, SelectMgr_PickingStrategy_OnlyTopmost can be set instead.
683 //! Notice, that since Selection Manager operates only objects registered in it,
684 //! SelectMgr_PickingStrategy_OnlyTopmost will NOT prevent picking entities behind
685 //! visible by unregistered in Selection Manager presentations (e.g. deactivated).
686 //! Hence, SelectMgr_PickingStrategy_OnlyTopmost changes behavior only with Selection Filters enabled.
687 void SetPickingStrategy (const SelectMgr_PickingStrategy theStrategy)
689 myPickingStrategy = theStrategy;
692 public: //! @name common properties
694 //! Returns the default attribute manager.
695 //! This contains all the color and line attributes which can be used by interactive objects which do not have their own attributes.
696 const Handle(Prs3d_Drawer)& DefaultDrawer() const { return myDefaultDrawer; }
698 //! Returns the current viewer.
699 const Handle(V3d_Viewer)& CurrentViewer() const { return myMainVwr; }
701 const Handle(SelectMgr_SelectionManager)& SelectionManager() const { return mgrSelector; }
703 const Handle(PrsMgr_PresentationManager3d)& MainPrsMgr() const { return myMainPM; }
705 const Handle(StdSelect_ViewerSelector3d)& MainSelector() const { return myMainSel; }
707 //! Updates the current viewer.
708 Standard_EXPORT void UpdateCurrentViewer();
710 //! Returns the list of displayed objects of a particular Type WhichKind and Signature WhichSignature.
711 //! By Default, WhichSignature equals -1. This means that there is a check on type only.
712 Standard_EXPORT void DisplayedObjects (AIS_ListOfInteractive& aListOfIO, const Standard_Boolean OnlyFromNeutral = Standard_False) const;
714 //! gives the list of displayed objects of a particular Type and signature.
715 //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
716 Standard_EXPORT void DisplayedObjects (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, AIS_ListOfInteractive& aListOfIO, const Standard_Boolean OnlyFromNeutral = Standard_False) const;
718 //! Returns the list theListOfIO of erased objects (hidden objects) particular Type WhichKind and Signature WhichSignature.
719 //! By Default, WhichSignature equals 1. This means that there is a check on type only.
720 Standard_EXPORT void ErasedObjects (AIS_ListOfInteractive& theListOfIO) const;
722 //! gives the list of erased objects (hidden objects)
723 //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
724 Standard_EXPORT void ErasedObjects (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, AIS_ListOfInteractive& theListOfIO) const;
726 //! Returns the list theListOfIO of objects with indicated display status particular Type WhichKind and Signature WhichSignature.
727 //! By Default, WhichSignature equals 1. This means that there is a check on type only.
728 Standard_EXPORT void ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const;
730 //! gives the list of objects with indicated display status
731 //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
732 Standard_EXPORT void ObjectsByDisplayStatus (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, const AIS_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const;
734 //! fills <aListOfIO> with objects of a particular Type and Signature with no consideration of display status.
735 //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
736 //! if <WhichKind> = AIS_KOI_None and <WhichSignature> = -1, all the objects are put into the list.
737 Standard_EXPORT void ObjectsInside (AIS_ListOfInteractive& aListOfIO, const AIS_KindOfInteractive WhichKind = AIS_KOI_None, const Standard_Integer WhichSignature = -1) const;
739 //! Rebuilds 1st level of BVH selection forcibly
740 Standard_EXPORT void RebuildSelectionStructs();
742 //! Disconnects theObjToDisconnect from theAssembly and removes dependent selection structures
743 Standard_EXPORT void Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, const Handle(AIS_InteractiveObject)& theObjToDisconnect = NULL);
745 //! Query objects visible or hidden in specified view due to affinity mask.
746 Standard_EXPORT void ObjectsForView (AIS_ListOfInteractive& theListOfIO, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisibleInView, const AIS_DisplayStatus theStatus = AIS_DS_None) const;
748 //! Clears all the structures which don't belong to objects displayed at neutral point
749 //! only effective when no Local Context is opened...
750 //! returns the number of removed structures from the viewers.
751 Standard_EXPORT Standard_Integer PurgeDisplay();
753 public: //! @name debug visualization
755 //! Visualization of sensitives - for debugging purposes!
756 Standard_EXPORT void DisplayActiveSensitive (const Handle(V3d_View)& aView);
758 //! Clear visualization of sensitives.
759 Standard_EXPORT void ClearActiveSensitive (const Handle(V3d_View)& aView);
761 //! Visualization of sensitives - for debugging purposes!
762 Standard_EXPORT void DisplayActiveSensitive (const Handle(AIS_InteractiveObject)& anObject, const Handle(V3d_View)& aView);
764 public: //! @name common object display attributes
766 //! Sets the graphic attributes of the interactive object, such as visualization mode, color, and material.
767 Standard_EXPORT void SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
768 const Handle(Prs3d_Drawer)& theDrawer,
769 const Standard_Boolean theToUpdateViewer);
771 //! Removes the settings for local attributes of the Object and returns to defaults.
772 Standard_EXPORT void UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
773 const Standard_Boolean theToUpdateViewer);
775 //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE.
776 //! This mean that attributes is applying both on the front and back face.
777 Standard_EXPORT void SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& aniobj, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE);
779 //! Returns true if a view of the Interactive Object has color.
780 Standard_EXPORT Standard_Boolean HasColor (const Handle(AIS_InteractiveObject)& aniobj) const;
782 //! Returns the color of the Object in the interactive context.
783 Standard_EXPORT void Color (const Handle(AIS_InteractiveObject)& aniobj, Quantity_Color& acolor) const;
785 //! Sets the color of the selected entity.
786 Standard_EXPORT void SetColor (const Handle(AIS_InteractiveObject)& theIObj,
787 const Quantity_Color& theColor,
788 const Standard_Boolean theToUpdateViewer);
790 //! Removes the color selection for the selected entity.
791 Standard_EXPORT void UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
792 const Standard_Boolean theToUpdateViewer);
794 //! Returns the width of the Interactive Object in the interactive context.
795 Standard_EXPORT virtual Standard_Real Width (const Handle(AIS_InteractiveObject)& aniobj) const;
797 //! Sets the width of the Object.
798 Standard_EXPORT virtual void SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
799 const Standard_Real theValue,
800 const Standard_Boolean theToUpdateViewer);
802 //! Removes the width setting of the Object.
803 Standard_EXPORT virtual void UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
804 const Standard_Boolean theToUpdateViewer);
806 //! Provides the type of material setting for the view of the Object.
807 Standard_EXPORT void SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
808 const Graphic3d_MaterialAspect& theMaterial,
809 const Standard_Boolean theToUpdateViewer);
811 //! Removes the type of material setting for viewing the Object.
812 Standard_EXPORT void UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
813 const Standard_Boolean theToUpdateViewer);
815 //! Provides the transparency settings for viewing the Object.
816 //! The transparency value aValue may be between 0.0, opaque, and 1.0, fully transparent.
817 Standard_EXPORT void SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
818 const Standard_Real theValue,
819 const Standard_Boolean theToUpdateViewer);
821 //! Removes the transparency settings for viewing the Object.
822 Standard_EXPORT void UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
823 const Standard_Boolean theToUpdateViewer);
825 //! Sets up polygon offsets for the given AIS_InteractiveObject.
826 //! It simply calls AIS_InteractiveObject::SetPolygonOffsets().
827 Standard_EXPORT void SetPolygonOffsets (const Handle(AIS_InteractiveObject)& theIObj,
828 const Standard_Integer theMode,
829 const Standard_ShortReal theFactor,
830 const Standard_ShortReal theUnits,
831 const Standard_Boolean theToUpdateViewer);
833 //! Simply calls AIS_InteractiveObject::HasPolygonOffsets().
834 Standard_EXPORT Standard_Boolean HasPolygonOffsets (const Handle(AIS_InteractiveObject)& anObj) const;
836 //! Retrieves current polygon offsets settings for Object.
837 Standard_EXPORT void PolygonOffsets (const Handle(AIS_InteractiveObject)& anObj, Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
839 public: //! @name trihedron display attributes
841 //! Sets the size aSize of the trihedron.
842 //! Is used to change the default value 100 mm for display of trihedra.
843 //! Use of this function in one of your own interactive objects requires a call to the Compute function of the new class.
844 //! This will recalculate the presentation for every trihedron displayed.
845 Standard_EXPORT void SetTrihedronSize (const Standard_Real theSize,
846 const Standard_Boolean theToUpdateViewer);
848 //! returns the current value of trihedron size.
849 Standard_EXPORT Standard_Real TrihedronSize() const;
851 public: //! @name plane display attributes
853 //! Sets the plane size defined by the length in the X direction XSize and that in the Y direction YSize.
854 Standard_EXPORT void SetPlaneSize (const Standard_Real theSizeX,
855 const Standard_Real theSizeY,
856 const Standard_Boolean theToUpdateViewer);
858 //! Sets the plane size aSize.
859 Standard_EXPORT void SetPlaneSize (const Standard_Real theSize,
860 const Standard_Boolean theToUpdateViewer);
862 //! Returns true if the length in the X direction XSize is the same as that in the Y direction YSize.
863 Standard_EXPORT Standard_Boolean PlaneSize (Standard_Real& XSize, Standard_Real& YSize) const;
865 public: //! @name tessellation deviation properties for automatic triangulation
867 //! Sets the deviation coefficient theCoefficient.
868 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
869 //! A Deviation coefficient is used in the shading display mode.
870 //! The shape is seen decomposed into triangles.
871 //! These are used to calculate reflection of light from the surface of the object.
872 //! The triangles are formed from chords of the curves in the shape.
873 //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
874 //! If this limit is reached, a new triangle is begun.
875 //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
876 //! The default value is 0.001.
877 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
878 //! This deviation will be: SizeOfObject * DeviationCoefficient.
879 Standard_EXPORT void SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
880 const Standard_Real theCoefficient,
881 const Standard_Boolean theToUpdateViewer);
883 Standard_EXPORT void SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
884 const Standard_Real theAngle,
885 const Standard_Boolean theToUpdateViewer);
887 //! Calls the AIS_Shape SetAngleAndDeviation to set both Angle and Deviation coefficients
888 Standard_EXPORT void SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
889 const Standard_Real theAngle,
890 const Standard_Boolean theToUpdateViewer);
893 //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations.
894 //! The Default value is 0.02.
895 Standard_EXPORT void SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
896 const Standard_Real theCoefficient,
897 const Standard_Boolean theToUpdateViewer);
899 Standard_EXPORT void SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
900 const Standard_Real theAngle,
901 const Standard_Boolean theToUpdateViewer);
903 //! Computes a HLRAngle and a HLRDeviationCoefficient by means of the angle anAngle
904 //! and sets the corresponding methods in the default drawing tool with these values.
905 Standard_EXPORT void SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
906 const Standard_Real theAngle,
907 const Standard_Boolean theToUpdateViewer);
909 //! Sets the deviation coefficient theCoefficient.
910 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
911 //! A Deviation coefficient is used in the shading display mode.
912 //! The shape is seen decomposed into triangles.
913 //! These are used to calculate reflection of light from the surface of the object.
914 //! The triangles are formed from chords of the curves in the shape.
915 //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
916 //! If this limit is reached, a new triangle is begun.
917 //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
918 //! The default value is 0.001.
919 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
920 //! This deviation will be: SizeOfObject * DeviationCoefficient.
921 Standard_EXPORT void SetDeviationCoefficient (const Standard_Real theCoefficient);
923 //! Returns the deviation coefficient.
924 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
925 //! A Deviation coefficient is used in the shading display mode.
926 //! The shape is seen decomposed into triangles.
927 //! These are used to calculate reflection of light from the surface of the object.
928 //! The triangles are formed from chords of the curves in the shape.
929 //! The deviation coefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
930 //! If this limit is reached, a new triangle is begun.
931 //! This deviation is absolute and is set through Prs3d_Drawer::SetMaximalChordialDeviation.
932 //! The default value is 0.001.
933 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
934 //! This deviation will be: SizeOfObject * DeviationCoefficient.
935 Standard_EXPORT Standard_Real DeviationCoefficient() const;
937 //! default 12 degrees
938 Standard_EXPORT void SetDeviationAngle (const Standard_Real anAngle);
940 Standard_EXPORT Standard_Real DeviationAngle() const;
942 //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations.
943 //! The Default value is 0.02.
944 Standard_EXPORT void SetHLRDeviationCoefficient (const Standard_Real aCoefficient);
946 //! Returns the real number value of the hidden line removal deviation coefficient.
947 //! A Deviation coefficient is used in the shading display mode.
948 //! The shape is seen decomposed into triangles.
949 //! These are used to calculate reflection of light from the surface of the object.
950 //! The triangles are formed from chords of the curves in the shape.
951 //! The deviation coefficient give the highest value of the angle with which a chord can deviate from a tangent to a curve.
952 //! If this limit is reached, a new triangle is begun.
953 //! To find the hidden lines, hidden line display mode entails recalculation of the view at each different projector perspective.
954 //! Because hidden lines entail calculations of more than usual complexity to decompose them into these triangles,
955 //! a deviation coefficient allowing greater tolerance is used.
956 //! This increases efficiency in calculation.
957 //! The Default value is 0.02.
958 Standard_EXPORT Standard_Real HLRDeviationCoefficient() const;
960 //! Sets the HLR angle.
961 Standard_EXPORT void SetHLRAngle (const Standard_Real theAngle);
963 //! Returns the real number value of the deviation angle in hidden line removal views in this interactive context.
964 //! The default value is 20*PI/180.
965 Standard_EXPORT Standard_Real HLRAngle() const;
967 //! compute with theAngle a HLRAngle and a HLRDeviationCoefficient
968 //! and set them in myHLRAngle and in myHLRDeviationCoefficient of myDefaultDrawer;
969 //! theAngle is in radian; ( 1 deg < angle in deg < 20 deg)
970 Standard_EXPORT void SetHLRAngleAndDeviation (const Standard_Real theAngle);
972 public: //! @name HLR (Hidden Line Removal) display attributes
974 //! Initializes hidden line aspect in the default drawing tool, or Drawer.
975 //! The default values are:
976 //! Color: Quantity_NOC_YELLOW
977 //! Type of line: Aspect_TOL_DASH
979 Standard_EXPORT Handle(Prs3d_LineAspect) HiddenLineAspect() const;
981 //! Sets the hidden line aspect anAspect.
982 //! Aspect defines display attributes for hidden lines in HLR projections.
983 Standard_EXPORT void SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& anAspect) const;
985 //! returns Standard_True if the hidden lines are to be drawn.
986 //! By default the hidden lines are not drawn.
987 Standard_EXPORT Standard_Boolean DrawHiddenLine() const;
989 Standard_EXPORT void EnableDrawHiddenLine() const;
991 Standard_EXPORT void DisableDrawHiddenLine() const;
993 public: //! @name iso-line display attributes
995 //! Sets the number of U and V isoparameters displayed.
996 Standard_EXPORT void SetIsoNumber (const Standard_Integer NbIsos, const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
998 //! Returns the number of U and V isoparameters displayed.
999 Standard_EXPORT Standard_Integer IsoNumber (const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1001 //! Returns True if drawing isoparameters on planes is enabled.
1002 Standard_EXPORT void IsoOnPlane (const Standard_Boolean SwitchOn);
1004 //! Returns True if drawing isoparameters on planes is enabled.
1005 //! if <forUIsos> = False,
1006 Standard_EXPORT Standard_Boolean IsoOnPlane() const;
1008 //! Enables or disables on-triangulation build for isolines for a particular object.
1009 //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given.
1010 Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theIsEnabled,
1011 const Handle(AIS_InteractiveObject)& theObject);
1013 //! Enables or disables on-triangulation build for isolines for default drawer.
1014 //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given.
1015 Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theToSwitchOn);
1017 //! Returns true if drawing isolines on triangulation algorithm is enabled.
1018 Standard_EXPORT Standard_Boolean IsoOnTriangulation() const;
1020 public: //! @name Local Context management (deprecated)
1022 //! Returns true if there is an open context.
1023 Standard_Boolean HasOpenedContext() const { return myCurLocalIndex != 0; }
1025 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1026 Standard_EXPORT Standard_Integer HighestIndex() const;
1028 //! For advanced usage! You should use other (non-internal) methods of class AIS_InteractiveContext without trying to obtain an instance of AIS_LocalContext.
1029 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1030 Handle(AIS_LocalContext) LocalContext() const { return myCurLocalIndex > 0 ? myLocalContexts (myCurLocalIndex) : Handle(AIS_LocalContext)(); }
1032 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1033 Standard_EXPORT Handle(StdSelect_ViewerSelector3d) LocalSelector() const;
1035 //! Opens local contexts and specifies how this is to be done.
1036 //! The options listed above function in the following manner:
1037 //! - UseDisplayedObjects - allows you to load or not load the interactive objects visualized at Neutral Point in the local context which you open.
1038 //! If false, the local context is empty after being opened. If true, the objects at Neutral Point are loaded by their default selection mode.
1039 //! - AllowShapeDecomposition - AIS_Shape allows or prevents decomposition in standard shape location mode of objects at Neutral Point which are type-"privileged".
1040 //! This Flag is only taken into account when UseDisplayedObjects is true.
1041 //! - AcceptEraseOfObjects - authorises other local contexts to erase the interactive objects present in this context. This option is rarely used.
1042 //! - BothViewers - Has no use currently defined.
1043 //! This method returns the index of the created local context.
1044 //! It should be kept and used to close the context.
1045 //! Opening a local context allows you to prepare an environment for temporary presentations and selections which will disappear once the local context is closed.
1046 //! You can open several local contexts, but only the last one will be active.
1047 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1048 Standard_EXPORT Standard_Integer OpenLocalContext (const Standard_Boolean UseDisplayedObjects = Standard_True, const Standard_Boolean AllowShapeDecomposition = Standard_True, const Standard_Boolean AcceptEraseOfObjects = Standard_False, const Standard_Boolean BothViewers = Standard_False);
1050 //! Allows you to close local contexts. For greater security, you should close the context with the index Index given on opening.
1051 //! When you close a local context, the one before, which is still on the stack, reactivates.
1052 //! If none is left, you return to Neutral Point.
1053 //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode;
1054 //! the object is displayed but no viewer will be updated.
1056 //! When the index isn't specified, the current context is closed.
1057 //! This option can be dangerous, as other Interactive Functions can open local contexts without necessarily warning the user.
1058 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1059 Standard_EXPORT void CloseLocalContext (const Standard_Integer theIndex = -1,
1060 const Standard_Boolean theToUpdateViewer = Standard_True);
1062 //! returns -1 if no opened local context.
1063 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1064 Standard_EXPORT Standard_Integer IndexOfCurrentLocal() const;
1066 //! Allows you to close all local contexts at one go and return to Neutral Point.
1067 //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode;
1068 //! the object is displayed but no viewer will be updated.
1069 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1070 Standard_EXPORT void CloseAllContexts (const Standard_Boolean theToUpdateViewer);
1072 //! to be used only with no opened local context..
1073 //! displays and activates objects in their original state before local contexts were opened...
1074 Standard_EXPORT void ResetOriginalState (const Standard_Boolean theToUpdateViewer);
1076 //! clears Objects/Filters/Activated Modes list in the current opened local context.
1077 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1078 Standard_EXPORT void ClearLocalContext (const AIS_ClearMode TheMode = AIS_CM_All);
1080 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1081 Standard_EXPORT void UseDisplayedObjects();
1083 //! when a local Context is opened, one is able to use/not use the displayed objects at neutral point at anytime.
1084 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1085 Standard_EXPORT void NotUseDisplayedObjects();
1087 //! to be Used only with opened local context and
1088 //! if <anIobj> is of type shape...
1089 //! if <aStatus> = True <anIobj> will be sensitive to
1090 //! shape selection modes activation.
1091 //! = False, <anIobj> will not be sensitive any more.
1092 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1093 Standard_EXPORT void SetShapeDecomposition (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Boolean aStatus);
1096 //! Sets the temporary graphic attributes of the entity anObj.
1097 //! These are provided by the attribute manager aDrawer and are valid for a particular local context only.
1098 //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode;
1099 //! the object is displayed but no viewer will be updated.
1100 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1101 Standard_EXPORT void SetTemporaryAttributes (const Handle(AIS_InteractiveObject)& theIObj,
1102 const Handle(Prs3d_Drawer)& theDrawer,
1103 const Standard_Boolean theToUpdateViewer);
1105 //! Provides an alternative to the Display methods when activating specific selection modes.
1106 //! This has the effect of activating the corresponding selection mode aStandardActivation for all objects
1107 //! in Local Context which accept decomposition into sub-shapes.
1108 //! Every new Object which has been loaded into the interactive context and which answers these decomposition criteria
1109 //! is automatically activated according to these modes.
1111 //! If you have opened a local context by loading an object with the default options (<AllowShapeDecomposition >= Standard_True),
1112 //! all objects of the "Shape" type are also activated with the same modes.
1113 //! You can act on the state of these "Standard" objects by using SetShapeDecomposition(Status).
1114 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1115 Standard_EXPORT void ActivateStandardMode (const TopAbs_ShapeEnum aStandardActivation);
1117 //! Provides an alternative to the Display methods when deactivating specific selection modes.
1118 //! This has the effect of deactivating the corresponding selection mode aStandardActivation for all objects
1119 //! in Local Context which accept decomposition into sub-shapes.
1120 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1121 Standard_EXPORT void DeactivateStandardMode (const TopAbs_ShapeEnum aStandardActivation);
1123 //! Returns the list of activated standard selection modes available in a local context.
1124 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1125 Standard_EXPORT const TColStd_ListOfInteger& ActivatedStandardModes() const;
1127 //! returns if possible, the first local context where the object is seen
1128 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1129 Standard_EXPORT Standard_Boolean IsInLocal (const Handle(AIS_InteractiveObject)& anObject, Standard_Integer& TheIndex) const;
1131 //! Sets the highlighting status aStatus of detected and selected entities.
1132 //! Whether you are in Neutral Point or local context, this is automatically managed by the Interactive Context.
1133 //! This function allows you to disconnect the automatic mode.
1134 Standard_EXPORT void SetAutomaticHilight (const Standard_Boolean aStatus);
1136 //! Returns true if the automatic highlight mode is active in an open context.
1137 Standard_EXPORT Standard_Boolean AutomaticHilight() const;
1139 //! Changes the status of a temporary object.
1140 //! It will be kept at the neutral point, i.e. put in the list of displayed objects along with its temporary attributes.
1141 //! These include display mode and selection mode, for example.
1142 //! Returns true if done.
1143 //! inWhichLocal gives the local context in which anIObj is displayed.
1144 //! By default, the index -1 refers to the last Local Context opened.
1145 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1146 Standard_EXPORT Standard_Boolean KeepTemporary (const Handle(AIS_InteractiveObject)& anIObj, const Standard_Integer InWhichLocal = -1);
1150 //! Updates the view of the current object in open context.
1151 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1152 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1153 Standard_EXPORT void SetCurrentObject (const Handle(AIS_InteractiveObject)& theIObj,
1154 const Standard_Boolean theToUpdateViewer);
1156 //! Allows to add or remove the object given to the list of current and highlight/unhighlight it correspondingly.
1157 //! Is valid for global context only; for local context use method AddOrRemoveSelected.
1158 //! Since this method makes sence only for neutral point selection of a whole object,
1159 //! if 0 selection of the object is empty this method simply does nothing.
1160 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1161 Standard_EXPORT void AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
1162 const Standard_Boolean theIsToUpdateViewer);
1164 //! Updates the list of current objects, i.e. hilights new current objects, removes hilighting from former current objects.
1165 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1166 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1167 Standard_EXPORT void UpdateCurrent();
1169 //! Returns true if there is a non-null interactive object in Neutral Point.
1170 //! Objects selected when there is no open local context are called current objects;
1171 //! those selected in open local context, selected objects.
1172 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1173 Standard_EXPORT Standard_Boolean IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const;
1175 //! Initializes a scan of the current selected objects in Neutral Point.
1176 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1177 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1178 Standard_EXPORT void InitCurrent();
1180 //! Returns true if there is another object found by the scan of the list of current objects.
1181 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1182 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1183 Standard_EXPORT Standard_Boolean MoreCurrent() const;
1185 //! Continues the scan to the next object in the list of current objects.
1186 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1187 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1188 Standard_EXPORT void NextCurrent();
1190 //! Returns the current interactive object.
1191 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1192 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1193 Standard_EXPORT Handle(AIS_InteractiveObject) Current() const;
1195 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1196 Standard_EXPORT Standard_Integer NbCurrents();
1198 //! Highlights current objects.
1199 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1200 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1201 Standard_EXPORT void HilightCurrents (const Standard_Boolean theToUpdateViewer);
1203 //! Removes highlighting from current objects.
1204 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1205 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1206 Standard_EXPORT void UnhilightCurrents (const Standard_Boolean theToUpdateViewer);
1208 //! Empties previous current objects in order to get the current objects detected by the selector using UpdateCurrent.
1209 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1210 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1211 Standard_EXPORT void ClearCurrents (const Standard_Boolean theToUpdateViewer);
1213 //! @return current mouse-detected shape or empty (null) shape, if current interactive object
1214 //! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
1215 //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected().
1216 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1217 Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const;
1219 //! @return current mouse-detected interactive object or null object, if there is no currently detected interactives
1220 //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected().
1221 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1222 Standard_EXPORT Handle(AIS_InteractiveObject) DetectedCurrentObject() const;
1224 public: //! @name sub-intensity management (deprecated)
1226 //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight,
1227 //! but without actual selection (e.g., global status and owner's selection state will not be updated).
1228 //! The method returns the color of such highlighting.
1229 //! By default, it is Quantity_NOC_GRAY40.
1230 const Quantity_Color& SubIntensityColor() const
1232 return myStyles[Prs3d_TypeOfHighlight_SubIntensity]->Color();
1235 //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight,
1236 //! but without actual selection (e.g., global status and owner's selection state will not be updated).
1237 //! The method sets up the color for such highlighting.
1238 //! By default, this is Quantity_NOC_GRAY40.
1239 void SetSubIntensityColor (const Quantity_Color& theColor)
1241 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetColor (theColor);
1244 //! Highlights, and removes highlights from, the displayed object which is displayed at Neutral Point with subintensity color.
1245 //! Available only for active local context.
1246 //! There is no effect if there is no local context.
1247 //! If a local context is open, the presentation of the Interactive Object activates the selection mode.
1248 Standard_EXPORT void SubIntensityOn (const Handle(AIS_InteractiveObject)& theIObj,
1249 const Standard_Boolean theToUpdateViewer);
1251 //! Removes the subintensity option for the entity.
1252 //! If a local context is open, the presentation of the Interactive Object activates the selection mode.
1253 Standard_EXPORT void SubIntensityOff (const Handle(AIS_InteractiveObject)& theIObj,
1254 const Standard_Boolean theToUpdateViewer);
1256 //! hilights/unhilights displayed objects which are displayed at neutral state with subintensity color.
1257 //! Available only for active local context.
1258 //! No effect if no local context.
1259 Standard_EXPORT void SubIntensityOn (const Standard_Boolean theToUpdateViewer);
1261 //! Removes subintensity option for all objects.
1262 Standard_EXPORT void SubIntensityOff (const Standard_Boolean theToUpdateViewer);
1264 protected: //! @name internal methods
1266 Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
1268 Standard_EXPORT void EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
1269 const Standard_Boolean theToUpdateViewer);
1271 Standard_EXPORT void ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
1272 const Standard_Boolean theToUpdateViewer);
1274 Standard_EXPORT void ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theObj,
1275 const Standard_Integer theMode,
1276 const Standard_Boolean theToUpdateViewer);
1278 Standard_EXPORT void InitAttributes();
1280 Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
1283 Standard_EXPORT void redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1284 const Standard_Boolean theToUpdateViewer);
1287 Standard_EXPORT void redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1288 const Standard_Boolean theToUpdateViewer);
1290 //! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
1291 Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
1293 //! Helper function that highlights the owner given with <theStyle> without
1294 //! performing AutoHighlight checks, e.g. is used for dynamic highlight.
1295 Standard_EXPORT void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
1296 const Handle(V3d_Viewer)& theViewer = NULL);
1298 //! Helper function that highlights the owner given with <theStyle> with check
1299 //! for AutoHighlight, e.g. is used for selection.
1300 Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
1302 //! Helper function that highlights global owner of the object given with <theStyle> with check
1303 //! for AutoHighlight, e.g. is used for selection.
1304 //! If global owner is null, it simply highlights the whole object
1305 Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
1306 const Handle(Prs3d_Drawer)& theStyle,
1307 const Standard_Integer theDispMode) const;
1309 //! Helper function that unhighlights all owners that are stored in current AIS_Selection.
1310 //! The function updates global status and selection state of owner and interactive object.
1311 //! If the parameter <theIsToHilightSubIntensity> is set to true, interactive objects with sub-intensity
1312 //! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
1313 Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
1315 //! Helper function that unhighlights global selection owner of given interactive.
1316 //! The function does not perform any updates of global or owner status
1317 Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const;
1319 //! Helper function that turns on sub-intensity in global status and highlights
1320 //! given objects with sub-intensity color
1321 //! @param theObject [in] the object. If NULL is given, than sub-intensity will be turned on for
1322 //! all inveractive objects of the context
1323 //! @param theDispMode [in] display mode. If -1 is given, sub-intensity will be turned on for
1324 //! all display modes in global status's list of modes
1325 //! @param theIsDisplayedOnly [in] is true if sub-intensity should be applied only to objects with
1326 //! status AIS_DS_Displayed
1327 Standard_EXPORT void turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject = NULL,
1328 const Standard_Integer theDispMode = -1,
1329 const Standard_Boolean theIsDisplayedOnly = Standard_True) const;
1331 //! Helper function that highlights the object with sub-intensity color without any checks
1332 //! @param theObject [in] the object that will be highlighted
1333 //! @param theMode [in] display mode
1334 Standard_EXPORT void highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
1335 const Standard_Integer theMode) const;
1337 //! Helper function that highlights the owner with sub-intensity color without any checks
1338 //! @param theOwner [in] the owner that will be highlighted
1339 //! @param theMode [in] display mode
1340 Standard_EXPORT void highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
1341 const Standard_Integer theMode) const;
1343 //! Helper function that returns correct dynamic highlight style for the object:
1344 //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1345 //! dynamic highlight style of interactive context will be returned.
1346 //! @param theObj [in] the object to check
1347 const Handle(Prs3d_Drawer)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj,
1348 const Handle(SelectMgr_EntityOwner)& theOwner) const
1350 const Handle(Prs3d_Drawer)& aHiDrawer = theObj->DynamicHilightAttributes();
1351 if (!aHiDrawer.IsNull())
1356 return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalDynamic : Prs3d_TypeOfHighlight_Dynamic];
1359 //! Helper function that returns correct selection style for the object:
1360 //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1361 //! selection style of interactive context will be returned.
1362 //! @param theObj [in] the object to check
1363 const Handle(Prs3d_Drawer)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj,
1364 const Handle(SelectMgr_EntityOwner)& theOwner) const
1366 const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes();
1367 if (!aHiDrawer.IsNull())
1372 return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalSelected : Prs3d_TypeOfHighlight_Selected];
1375 //! Assign the context to the object or throw exception if object was already assigned to another context.
1376 void setContextToObject (const Handle(AIS_InteractiveObject)& theObj)
1378 if (theObj->HasInteractiveContext())
1380 if (theObj->myCTXPtr != this)
1382 throw Standard_ProgramError("AIS_InteractiveContext - object has been already displayed in another context!");
1387 theObj->SetContext (this);
1391 //! Return display mode for highlighting.
1392 Standard_Integer getHilightMode (const Handle(AIS_InteractiveObject)& theObj,
1393 const Handle(Prs3d_Drawer)& theStyle,
1394 const Standard_Integer theDispMode) const
1396 if (!theStyle.IsNull()
1397 && theStyle->DisplayMode() != -1
1398 && theObj->AcceptDisplayMode (theStyle->DisplayMode()))
1400 return theStyle->DisplayMode();
1402 else if (theDispMode != -1)
1406 else if (theObj->HasDisplayMode())
1408 return theObj->DisplayMode();
1410 return myDefaultDrawer->DisplayMode();
1413 //! Removes dynamic highlight draw
1414 void clearDynamicHighlight() const
1416 if (myLastinMain.IsNull())
1419 if (myLastinMain->IsAutoHilight())
1421 myMainPM->ClearImmediateDraw();
1425 myLastinMain->Selectable()->ClearDynamicHighlight (myMainPM);
1429 protected: //! @name internal fields
1431 AIS_DataMapOfIOStatus myObjects;
1432 Handle(SelectMgr_SelectionManager) mgrSelector;
1433 Handle(PrsMgr_PresentationManager3d) myMainPM;
1434 Handle(V3d_Viewer) myMainVwr;
1435 Handle(StdSelect_ViewerSelector3d) myMainSel;
1436 Handle(SelectMgr_EntityOwner) myLastPicked;
1437 Handle(SelectMgr_EntityOwner) myLastinMain;
1438 Standard_Boolean myWasLastMain;
1439 Standard_Boolean myToHilightSelected;
1440 Handle(AIS_Selection) mySelection;
1441 Handle(SelectMgr_OrFilter) myFilters;
1442 Handle(Prs3d_Drawer) myDefaultDrawer;
1443 Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB];
1444 AIS_DataMapOfILC myLocalContexts;
1445 Standard_Integer myCurLocalIndex;
1446 TColStd_SequenceOfInteger myDetectedSeq;
1447 Standard_Integer myCurDetected;
1448 Standard_Integer myCurHighlighted;
1449 SelectMgr_PickingStrategy myPickingStrategy; //!< picking strategy to be applied within MoveTo()
1450 Standard_Boolean myIsAutoActivateSelMode;
1454 DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient)
1456 #endif // _AIS_InteractiveContext_HeaderFile