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_DataMapOfIOStatus.hxx>
21 #include <AIS_DisplayMode.hxx>
22 #include <AIS_DisplayStatus.hxx>
23 #include <AIS_KindOfInteractive.hxx>
24 #include <AIS_ListOfInteractive.hxx>
25 #include <AIS_Selection.hxx>
26 #include <AIS_SelectionModesConcurrency.hxx>
27 #include <AIS_SelectionScheme.hxx>
28 #include <AIS_StatusOfDetection.hxx>
29 #include <AIS_StatusOfPick.hxx>
30 #include <AIS_TypeOfIso.hxx>
31 #include <Aspect_TypeOfFacingModel.hxx>
32 #include <Graphic3d_Vec2.hxx>
33 #include <Prs3d_Drawer.hxx>
34 #include <Prs3d_TypeOfHighlight.hxx>
35 #include <PrsMgr_PresentationManager.hxx>
36 #include <SelectMgr_AndOrFilter.hxx>
37 #include <SelectMgr_IndexedMapOfOwner.hxx>
38 #include <SelectMgr_ListOfFilter.hxx>
39 #include <SelectMgr_PickingStrategy.hxx>
40 #include <SelectMgr_SelectionManager.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>
50 class TopLoc_Location;
51 class TCollection_ExtendedString;
52 class Prs3d_LineAspect;
53 class Prs3d_BasicAspect;
55 class SelectMgr_Filter;
57 //! The Interactive Context allows you to manage graphic behavior and selection of Interactive Objects in one or more viewers.
58 //! Class methods make this highly transparent.
59 //! It is essential to remember that an Interactive Object which is already known by the Interactive Context must be modified using Context methods.
60 //! You can only directly call the methods available for an Interactive Object if it has not been loaded into an Interactive Context.
62 //! Each selectable object must specify the selection mode that is
63 //! responsible for selection of object as a whole (global selection mode).
64 //! Interactive context itself supports decomposed object selection with selection filters support.
65 //! By default, global selection mode is equal to 0, but it might be redefined if needed.
66 class AIS_InteractiveContext : public Standard_Transient
68 DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
69 public: //! @name object display management
71 //! Constructs the interactive context object defined by the principal viewer MainViewer.
72 Standard_EXPORT AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer);
75 Standard_EXPORT virtual ~AIS_InteractiveContext();
77 //! Returns the display status of the entity anIobj.
78 //! This will be one of the following:
79 //! - AIS_DS_Displayed displayed in main viewer
80 //! - AIS_DS_Erased hidden in main viewer
81 //! - AIS_DS_Temporary temporarily displayed
82 //! - AIS_DS_None nowhere displayed.
83 Standard_EXPORT PrsMgr_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const;
85 //! Returns the status of the Interactive Context for the view of the Interactive Object.
86 Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const;
88 //! Returns true if Object is displayed in the interactive context.
89 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const;
91 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer aMode) const;
93 //! Enable or disable automatic activation of default selection mode while displaying the object.
94 void SetAutoActivateSelection (const Standard_Boolean theIsAuto) { myIsAutoActivateSelMode = theIsAuto; }
96 //! Manages displaying the new object should also automatically activate default selection mode; TRUE by default.
97 Standard_Boolean GetAutoActivateSelection() const { return myIsAutoActivateSelMode; }
99 //! Displays the object in this Context using default Display Mode.
100 //! This will be the object's default display mode, if there is one. Otherwise, it will be the context mode.
101 //! The Interactive Object's default selection mode is activated if GetAutoActivateSelection() is TRUE. In general, this is 0.
102 Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj,
103 const Standard_Boolean theToUpdateViewer);
105 //! Sets status, display mode and selection mode for specified Object
106 //! If theSelectionMode equals -1, theIObj will not be activated: it will be displayed but will not be selectable.
107 Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj,
108 const Standard_Integer theDispMode,
109 const Standard_Integer theSelectionMode,
110 const Standard_Boolean theToUpdateViewer,
111 const PrsMgr_DisplayStatus theDispStatus = PrsMgr_DisplayStatus_None);
113 //! Allows you to load the Interactive Object with a given selection mode,
114 //! and/or with the desired decomposition option, whether the object is visualized or not.
115 //! The loaded objects will be selectable but displayable in highlighting only when detected by the Selector.
116 Standard_EXPORT void Load (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theSelectionMode = -1);
118 //! Hides the object. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
119 //! To show hidden objects, use Display().
120 Standard_EXPORT void Erase (const Handle(AIS_InteractiveObject)& theIObj,
121 const Standard_Boolean theToUpdateViewer);
123 //! Hides all objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
124 //! To show all hidden objects, use DisplayAll().
125 Standard_EXPORT void EraseAll (const Standard_Boolean theToUpdateViewer);
127 //! Displays all hidden objects.
128 Standard_EXPORT void DisplayAll (const Standard_Boolean theToUpdateViewer);
130 //! Hides selected objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
131 //! To show hidden objects, use Display().
132 Standard_EXPORT void EraseSelected (const Standard_Boolean theToUpdateViewer);
134 //! Displays current objects.
135 Standard_EXPORT void DisplaySelected (const Standard_Boolean theToUpdateViewer);
137 //! Empties the graphic presentation of the mode indexed by aMode.
138 //! Warning! Removes theIObj. theIObj is still active if it was previously activated.
139 void ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
140 const Standard_Integer theMode,
141 const Standard_Boolean theToUpdateViewer) { ClearGlobalPrs (theIObj, theMode, theToUpdateViewer); }
143 //! Removes Object from every viewer.
144 Standard_EXPORT void Remove (const Handle(AIS_InteractiveObject)& theIObj,
145 const Standard_Boolean theToUpdateViewer);
147 //! Removes all the objects from Context.
148 Standard_EXPORT void RemoveAll (const Standard_Boolean theToUpdateViewer);
150 //! Recomputes the seen parts presentation of the Object.
151 //! If theAllModes equals true, all presentations are present in the object even if unseen.
152 Standard_EXPORT void Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
153 const Standard_Boolean theToUpdateViewer,
154 const Standard_Boolean theAllModes = Standard_False);
156 //! Recomputes the Prs/Selection of displayed objects of a given type and a given signature.
157 //! if signature = -1 doesn't take signature criterion.
158 Standard_EXPORT void Redisplay (const AIS_KindOfInteractive theTypeOfObject,
159 const Standard_Integer theSignature,
160 const Standard_Boolean theToUpdateViewer);
162 //! Recomputes the displayed presentations, flags the others.
163 //! Doesn't update presentations.
164 Standard_EXPORT void RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
165 const Standard_Boolean theToUpdateViewer,
166 const Standard_Boolean theAllModes = Standard_False);
168 //! Recomputes the active selections, flags the others.
169 //! Doesn't update presentations.
170 Standard_EXPORT void RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& anIObj);
172 //! Updates displayed interactive object by checking and recomputing its flagged as "to be recomputed" presentation and selection structures.
173 //! This method does not force any recomputation on its own.
174 //! The method recomputes selections even if they are loaded without activation in particular selector.
175 Standard_EXPORT void Update (const Handle(AIS_InteractiveObject)& theIObj,
176 const Standard_Boolean theUpdateViewer);
178 public: //! @name highlighting management
180 //! Returns default highlight style settings (could be overridden by PrsMgr_PresentableObject).
182 //! Tip: although highlighting style is defined by Prs3d_Drawer,
183 //! only a small set of properties derived from it's base class Graphic3d_PresentationAttributes will be actually used in most cases.
185 //! Default highlight style for all types is Aspect_TOHM_COLOR. Other defaults:
186 //! - Prs3d_TypeOfHighlight_Dynamic
187 //! * Color: Quantity_NOC_CYAN1;
188 //! * Layer: Graphic3d_ZLayerId_Top,
189 //! object highlighting is drawn on top of main scene within Immediate Layers,
190 //! so that V3d_View::RedrawImmediate() will be enough to see update;
191 //! - Prs3d_TypeOfHighlight_LocalDynamic
192 //! * Color: Quantity_NOC_CYAN1;
193 //! * Layer: Graphic3d_ZLayerId_Topmost,
194 //! object parts highlighting is drawn on top of main scene within Immediate Layers
195 //! with depth cleared (even overlapped geometry will be revealed);
196 //! - Prs3d_TypeOfHighlight_Selected
197 //! * Color: Quantity_NOC_GRAY80;
198 //! * Layer: Graphic3d_ZLayerId_UNKNOWN,
199 //! object highlighting is drawn on top of main scene within the same layer
200 //! as object itself (e.g. Graphic3d_ZLayerId_Default by default) and increased priority.
202 //! @param[in] theStyleType highlight style to modify
203 //! @return drawer associated to specified highlight type
205 //! @sa MoveTo() using Prs3d_TypeOfHighlight_Dynamic and Prs3d_TypeOfHighlight_LocalDynamic types
206 //! @sa SelectDetected() using Prs3d_TypeOfHighlight_Selected and Prs3d_TypeOfHighlight_LocalSelected types
207 //! @sa PrsMgr_PresentableObject::DynamicHilightAttributes() overriding Prs3d_TypeOfHighlight_Dynamic and Prs3d_TypeOfHighlight_LocalDynamic defaults on object level
208 //! @sa PrsMgr_PresentableObject::HilightAttributes() overriding Prs3d_TypeOfHighlight_Selected and Prs3d_TypeOfHighlight_LocalSelected defaults on object level
209 const Handle(Prs3d_Drawer)& HighlightStyle (const Prs3d_TypeOfHighlight theStyleType) const { return myStyles[theStyleType]; }
211 //! Setup highlight style settings.
212 //! Tip: it is better modifying existing style returned by method HighlightStyle()
213 //! instead of creating a new Prs3d_Drawer to avoid unexpected results due misconfiguration.
215 //! If a new highlight style is created, its presentation Zlayer should be checked,
216 //! otherwise highlighting might not work as expected.
217 void SetHighlightStyle (const Prs3d_TypeOfHighlight theStyleType,
218 const Handle(Prs3d_Drawer)& theStyle)
220 myStyles[theStyleType] = theStyle;
221 if (theStyleType == Prs3d_TypeOfHighlight_None)
223 myDefaultDrawer = theStyle;
227 //! Returns current dynamic highlight style settings corresponding to Prs3d_TypeOfHighlight_Dynamic.
228 //! This is just a short-cut to HighlightStyle(Prs3d_TypeOfHighlight_Dynamic).
229 const Handle(Prs3d_Drawer)& HighlightStyle() const
231 return myStyles[Prs3d_TypeOfHighlight_Dynamic];
234 //! Setup the style of dynamic highlighting corrsponding to Prs3d_TypeOfHighlight_Selected.
235 //! This is just a short-cut to SetHighlightStyle(Prs3d_TypeOfHighlight_Dynamic,theStyle).
236 void SetHighlightStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle; }
238 //! Returns current selection style settings corrsponding to Prs3d_TypeOfHighlight_Selected.
239 //! This is just a short-cut to HighlightStyle(Prs3d_TypeOfHighlight_Selected).
240 const Handle(Prs3d_Drawer)& SelectionStyle() const
242 return myStyles[Prs3d_TypeOfHighlight_Selected];
245 //! Setup the style of selection highlighting.
246 //! This is just a short-cut to SetHighlightStyle(Prs3d_TypeOfHighlight_Selected,theStyle).
247 void SetSelectionStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Selected] = theStyle; }
249 //! Returns highlight style of the object if it is marked as highlighted via global status
250 //! @param theObj [in] the object to check
251 Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObj,
252 Handle(Prs3d_Drawer)& theStyle) const;
254 //! Returns highlight style of the owner if it is selected
255 //! @param theOwner [in] the owner to check
256 Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
257 Handle(Prs3d_Drawer)& theStyle) const;
259 //! Returns true if the object is marked as highlighted via its global status
260 //! @param theObj [in] the object to check
261 Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const;
263 //! Returns true if the owner is marked as selected
264 //! @param theOwner [in] the owner to check
265 Standard_EXPORT Standard_Boolean IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const;
267 //! Changes the color of all the lines of the object in view.
268 Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& theObj,
269 const Handle(Prs3d_Drawer)& theStyle,
270 const Standard_Boolean theToUpdateViewer);
272 //! Removes hilighting from the Object.
273 Standard_EXPORT void Unhilight (const Handle(AIS_InteractiveObject)& theIObj,
274 const Standard_Boolean theToUpdateViewer);
276 public: //! @name object presence management (View affinity, Layer, Priority)
278 //! Returns the display priority of the Object.
279 Standard_EXPORT Graphic3d_DisplayPriority DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const;
281 //! Sets the display priority of the seen parts presentation of the Object.
282 Standard_EXPORT void SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
283 const Graphic3d_DisplayPriority thePriority);
285 Standard_DEPRECATED("Deprecated since OCCT7.7, Graphic3d_DisplayPriority should be passed instead of integer number to SetDisplayPriority()")
286 void SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
287 const Standard_Integer thePriority) { SetDisplayPriority (theIObj, (Graphic3d_DisplayPriority )thePriority); }
289 //! Get Z layer id set for displayed interactive object.
290 Standard_EXPORT Graphic3d_ZLayerId GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const;
292 //! Set Z layer id for interactive object.
293 //! The Z layers can be used to display temporarily presentations of some object in front of the other objects in the scene.
294 //! The ids for Z layers are generated by V3d_Viewer.
295 Standard_EXPORT void SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, const Graphic3d_ZLayerId theLayerId);
297 //! Setup object visibility in specified view.
298 //! Has no effect if object is not displayed in this context.
299 Standard_EXPORT void SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisible);
301 public: //! @name Display Mode management
303 //! Returns the Display Mode setting to be used by default.
304 Standard_Integer DisplayMode() const { return myDefaultDrawer->DisplayMode(); }
306 //! Sets the display mode of seen Interactive Objects (which have no overridden Display Mode).
307 Standard_EXPORT void SetDisplayMode (const Standard_Integer theMode,
308 const Standard_Boolean theToUpdateViewer);
310 //! Sets the display mode of seen Interactive Objects.
311 //! theMode provides the display mode index of the entity theIObj.
312 Standard_EXPORT void SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
313 const Standard_Integer theMode,
314 const Standard_Boolean theToUpdateViewer);
316 //! Unsets the display mode of seen Interactive Objects.
317 Standard_EXPORT void UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
318 const Standard_Boolean theToUpdateViewer);
320 public: //! @name object local transformation management
322 //! Puts the location on the initial graphic representation and the selection for the Object.
323 Standard_EXPORT void SetLocation (const Handle(AIS_InteractiveObject)& theObject, const TopLoc_Location& theLocation);
325 //! Puts the Object back into its initial position.
326 Standard_EXPORT void ResetLocation (const Handle(AIS_InteractiveObject)& theObject);
328 //! Returns true if the Object has a location.
329 Standard_EXPORT Standard_Boolean HasLocation (const Handle(AIS_InteractiveObject)& theObject) const;
331 //! Returns the location of the Object.
332 Standard_EXPORT TopLoc_Location Location (const Handle(AIS_InteractiveObject)& theObject) const;
334 //! Sets transform persistence.
335 Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
336 const Handle(Graphic3d_TransformPers)& theTrsfPers);
338 public: //! @name mouse picking logic (detection and dynamic highlighting of entities under cursor)
340 //! Setup pixel tolerance for MoveTo() operation.
342 Standard_EXPORT void SetPixelTolerance (const Standard_Integer thePrecision = 2);
344 //! Returns the pixel tolerance, default is 2.
345 //! Pixel Tolerance extends sensitivity within MoveTo() operation (picking by point)
346 //! and can be adjusted by application based on user input precision (e.g. screen pixel density, input device precision, etc.).
347 Standard_EXPORT Standard_Integer PixelTolerance() const;
349 //! Allows to manage sensitivity of a particular selection of interactive object theObject
350 //! and changes previous sensitivity value of all sensitive entities in selection with theMode
351 //! to the given theNewSensitivity.
352 Standard_EXPORT void SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject,
353 const Standard_Integer theMode,
354 const Standard_Integer theNewSensitivity);
356 //! Returns last active View (argument of MoveTo()/Select() methods).
357 Standard_EXPORT Handle(V3d_View) LastActiveView() const;
359 //! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
360 //! This is done by the view theView passing this position to the main viewer and updating it.
361 //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
362 //! @sa PickingStrategy()
363 //! @sa HighlightStyle() defining default dynamic highlight styles of detected owners
364 //! (Prs3d_TypeOfHighlight_Dynamic and Prs3d_TypeOfHighlight_LocalDynamic)
365 //! @sa PrsMgr_PresentableObject::DynamicHilightAttributes() defining per-object dynamic highlight style of detected owners (overrides defaults)
366 Standard_EXPORT AIS_StatusOfDetection MoveTo (const Standard_Integer theXPix,
367 const Standard_Integer theYPix,
368 const Handle(V3d_View)& theView,
369 const Standard_Boolean theToRedrawOnUpdate);
371 //! Relays axis theAxis to the interactive context selectors.
372 //! This is done by the view theView passing this axis to the main viewer and updating it.
373 //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
374 //! @sa PickingStrategy()
375 Standard_EXPORT AIS_StatusOfDetection MoveTo (const gp_Ax1& theAxis,
376 const Handle(V3d_View)& theView,
377 const Standard_Boolean theToRedrawOnUpdate);
379 //! Clears the list of entities detected by MoveTo() and resets dynamic highlighting.
380 //! @param theToRedrawImmediate if TRUE, the main Viewer will be redrawn on update
381 //! @return TRUE if viewer needs to be updated (e.g. there were actually dynamically highlighted entities)
382 Standard_EXPORT Standard_Boolean ClearDetected (Standard_Boolean theToRedrawImmediate = Standard_False);
384 //! Returns true if there is a mouse-detected entity in context.
385 //! @sa DetectedOwner(), HasNextDetected(), HilightPreviousDetected(), HilightNextDetected().
386 Standard_Boolean HasDetected() const { return !myLastPicked.IsNull(); }
388 //! Returns the owner of the detected sensitive primitive which is currently dynamically highlighted.
389 //! WARNING! This method is irrelevant to InitDetected()/MoreDetected()/NextDetected().
390 //! @sa HasDetected(), HasNextDetected(), HilightPreviousDetected(), HilightNextDetected().
391 const Handle(SelectMgr_EntityOwner)& DetectedOwner() const { return myLastPicked; }
393 //! Returns the interactive objects last detected in context.
394 //! In general this is just a wrapper for Handle(AIS_InteractiveObject)::DownCast(DetectedOwner()->Selectable()).
395 //! @sa DetectedOwner()
396 Handle(AIS_InteractiveObject) DetectedInteractive() const { return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); }
398 //! Returns true if there is a detected shape in local context.
399 //! @sa HasDetected(), DetectedShape()
400 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
401 Standard_EXPORT Standard_Boolean HasDetectedShape() const;
403 //! Returns the shape detected in local context.
404 //! @sa DetectedOwner()
405 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
406 Standard_EXPORT const TopoDS_Shape& DetectedShape() const;
408 //! returns True if other entities were detected in the last mouse detection
409 //! @sa HilightPreviousDetected(), HilightNextDetected().
410 Standard_Boolean HasNextDetected() const { return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper(); }
412 //! If more than 1 object is detected by the selector, only the "best" owner is hilighted at the mouse position.
413 //! This Method allows the user to hilight one after another the other detected entities.
414 //! If The method select is called, the selected entity will be the hilighted one!
415 //! WARNING: Loop Method. When all the detected entities have been hilighted, the next call will hilight the first one again.
416 //! @return the Rank of hilighted entity
417 //! @sa HasNextDetected(), HilightPreviousDetected().
418 Standard_EXPORT Standard_Integer HilightNextDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True);
420 //! Same as previous methods in reverse direction.
421 //! @sa HasNextDetected(), HilightNextDetected().
422 Standard_EXPORT Standard_Integer HilightPreviousDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True);
424 public: //! @name iteration through detected entities
426 //! Initialization for iteration through mouse-detected objects in
427 //! interactive context or in local context if it is opened.
428 //! @sa DetectedCurrentOwner(), MoreDetected(), NextDetected().
431 if (!myDetectedSeq.IsEmpty())
433 myCurDetected = myDetectedSeq.Lower();
437 //! Return TRUE if there is more mouse-detected objects after the current one
438 //! during iteration through mouse-detected interactive objects.
439 //! @sa DetectedCurrentOwner(), InitDetected(), NextDetected().
440 Standard_Boolean MoreDetected() const { return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper(); }
442 //! Gets next current object during iteration through mouse-detected interactive objects.
443 //! @sa DetectedCurrentOwner(), InitDetected(), MoreDetected().
444 void NextDetected() { ++myCurDetected; }
446 //! Returns the owner from detected list pointed by current iterator position.
447 //! WARNING! This method is irrelevant to DetectedOwner() which returns last picked Owner regardless of iterator position!
448 //! @sa InitDetected(), MoreDetected(), NextDetected().
449 Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedCurrentOwner() const;
451 public: //! @name Selection management
453 //! Adds object in the selection.
454 Standard_EXPORT AIS_StatusOfPick AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
456 //! Adds object in the selection.
457 AIS_StatusOfPick AddSelect (const Handle(AIS_InteractiveObject)& theObject)
459 return AddSelect (theObject->GlobalSelOwner());
462 //! Selects objects within the bounding rectangle.
463 //! Viewer should be explicitly redrawn after selection.
464 //! @param thePntMin [in] rectangle lower point (in pixels)
465 //! @param thePntMax [in] rectangle upper point (in pixels)
466 //! @param theView [in] active view where rectangle is defined
467 //! @param theSelScheme [in] selection scheme
468 //! @return picking status
469 //! @sa StdSelect_ViewerSelector3d::AllowOverlapDetection()
470 Standard_EXPORT AIS_StatusOfPick SelectRectangle (const Graphic3d_Vec2i& thePntMin,
471 const Graphic3d_Vec2i& thePntMax,
472 const Handle(V3d_View)& theView,
473 const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
475 //! Select everything found in the polygon defined by bounding polyline.
476 //! Viewer should be explicitly redrawn after selection.
477 //! @param thePolyline [in] polyline defining polygon bounds (in pixels)
478 //! @param theView [in] active view where polyline is defined
479 //! @param theSelScheme [in] selection scheme
480 //! @return picking status
481 Standard_EXPORT AIS_StatusOfPick SelectPolygon (const TColgp_Array1OfPnt2d& thePolyline,
482 const Handle(V3d_View)& theView,
483 const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
485 //! Selects the topmost object picked by the point in the view,
486 //! Viewer should be explicitly redrawn after selection.
487 //! @param thePnt [in] point pixel coordinates within the view
488 //! @param theView [in] active view where point is defined
489 //! @param theSelScheme [in] selection scheme
490 //! @return picking status
491 Standard_EXPORT AIS_StatusOfPick SelectPoint (const Graphic3d_Vec2i& thePnt,
492 const Handle(V3d_View)& theView,
493 const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
495 //! Select and hilights the previous detected via AIS_InteractiveContext::MoveTo() method;
496 //! unhilights the previous picked.
497 //! Viewer should be explicitly redrawn after selection.
498 //! @param theSelScheme [in] selection scheme
499 //! @return picking status
501 //! @sa HighlightStyle() defining default highlight styles of selected owners (Prs3d_TypeOfHighlight_Selected and Prs3d_TypeOfHighlight_LocalSelected)
502 //! @sa PrsMgr_PresentableObject::HilightAttributes() defining per-object highlight style of selected owners (overrides defaults)
503 Standard_EXPORT AIS_StatusOfPick SelectDetected (const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
505 //! Returns bounding box of selected objects.
506 Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
508 //! Sets list of owner selected/deselected using specified selection scheme.
509 //! @param theOwners owners to change selection state
510 //! @param theSelScheme selection scheme
511 //! @return picking status
512 Standard_EXPORT AIS_StatusOfPick Select (const AIS_NArray1OfEntityOwner& theOwners,
513 const AIS_SelectionScheme theSelScheme);
515 //! Fits the view correspondingly to the bounds of selected objects.
516 //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
517 Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
518 const Standard_Real theMargin,
519 const Standard_Boolean theToUpdate);
521 //! Fits the view correspondingly to the bounds of selected objects.
522 //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
523 Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView);
525 //! Return value specified whether selected object must be hilighted when mouse cursor is moved above it
527 Standard_Boolean ToHilightSelected() const { return myToHilightSelected; }
529 //! Specify whether selected object must be hilighted when mouse cursor is moved above it (in MoveTo method).
530 //! By default this value is false and selected object is not hilighted in this case.
532 void SetToHilightSelected (const Standard_Boolean toHilight) { myToHilightSelected = toHilight; }
534 //! Returns true if the automatic highlight mode is active; TRUE by default.
535 //! @sa MoveTo(), Select(), HilightWithColor(), Unhilight()
536 Standard_Boolean AutomaticHilight() const { return myAutoHilight; }
538 //! Sets the highlighting status of detected and selected entities.
539 //! This function allows you to disconnect the automatic mode.
541 //! MoveTo() will fill the list of detected entities
542 //! and Select() will set selected state to detected objects regardless of this flag,
543 //! but with disabled AutomaticHiligh() their highlighting state will be left unaffected,
544 //! so that application will be able performing custom highlighting in a different way, if needed.
546 //! This API should be distinguished from SelectMgr_SelectableObject::SetAutoHilight()
547 //! that is used to implement custom highlighting logic for a specific interactive object class.
549 //! @sa MoveTo(), Select(), HilightWithColor(), Unhilight()
550 void SetAutomaticHilight (Standard_Boolean theStatus) { myAutoHilight = theStatus; }
552 //! Unhighlights previously selected owners and marks them as not selected.
553 //! Marks owner given as selected and highlights it.
554 //! Performs selection filters check.
555 Standard_EXPORT void SetSelected (const Handle(SelectMgr_EntityOwner)& theOwners,
556 const Standard_Boolean theToUpdateViewer);
558 //! Puts the interactive object aniObj in the list of selected objects.
559 //! Performs selection filters check.
560 Standard_EXPORT void SetSelected (const Handle(AIS_InteractiveObject)& theObject,
561 const Standard_Boolean theToUpdateViewer);
563 //! Allows to highlight or unhighlight the owner given depending on its selection status
564 Standard_EXPORT void AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
565 const Standard_Boolean theToUpdateViewer);
567 //! Updates Selected state of specified owner without calling HilightSelected().
568 //! Has no effect if Selected state is not changed, and redirects to AddOrRemoveSelected() otherwise.
569 //! @param theOwner owner object to set selected state
570 //! @param theIsSelected new selected state
571 //! @return TRUE if Selected state has been changed
572 Standard_EXPORT Standard_Boolean SetSelectedState (const Handle(SelectMgr_EntityOwner)& theOwner,
573 const Standard_Boolean theIsSelected);
575 //! Highlights selected objects.
576 Standard_EXPORT void HilightSelected (const Standard_Boolean theToUpdateViewer);
578 //! Removes highlighting from selected objects.
579 Standard_EXPORT void UnhilightSelected (const Standard_Boolean theToUpdateViewer);
581 //! Updates the list of selected objects:
582 //! i.e. highlights the newly selected ones and unhighlights previously selected objects.
583 //! @sa HilightSelected().
584 void UpdateSelected (Standard_Boolean theToUpdateViewer) { HilightSelected (theToUpdateViewer); }
586 //! Empties previous selected objects in order to get the selected objects detected by the selector using UpdateSelected.
587 Standard_EXPORT void ClearSelected (const Standard_Boolean theToUpdateViewer);
589 //! Allows to highlight or unhighlight the owner given depending on its selection status
590 Standard_EXPORT void AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
591 const Standard_Boolean theToUpdateViewer);
593 //! Returns true is the owner given is selected
594 Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const { return !theOwner.IsNull() && theOwner->IsSelected(); }
596 //! Returns true is the object given is selected
597 Standard_EXPORT Standard_Boolean IsSelected (const Handle(AIS_InteractiveObject)& theObj) const;
599 //! Returns the first selected object in the list of current selected.
600 Standard_EXPORT Handle(AIS_InteractiveObject) FirstSelectedObject() const;
602 //! Count a number of selected entities using InitSelected()+MoreSelected()+NextSelected() iterator.
603 //! @sa SelectedOwner(), InitSelected(), MoreSelected(), NextSelected().
604 Standard_Integer NbSelected() { return mySelection->Extent(); }
606 //! Initializes a scan of the selected objects.
607 //! @sa SelectedOwner(), MoreSelected(), NextSelected().
608 void InitSelected() { mySelection->Init(); }
610 //! Returns true if there is another object found by the scan of the list of selected objects.
611 //! @sa SelectedOwner(), InitSelected(), NextSelected().
612 Standard_Boolean MoreSelected() const { return mySelection->More(); }
614 //! Continues the scan to the next object in the list of selected objects.
615 //! @sa SelectedOwner(), InitSelected(), MoreSelected().
616 void NextSelected() { mySelection->Next(); }
618 //! Returns the owner of the selected entity.
619 //! @sa InitSelected(), MoreSelected(), NextSelected().
620 Handle(SelectMgr_EntityOwner) SelectedOwner() const
622 return !mySelection->More()
623 ? Handle(SelectMgr_EntityOwner)()
624 : mySelection->Value();
627 //! Return Handle(AIS_InteractiveObject)::DownCast (SelectedOwner()->Selectable()).
628 //! @sa SelectedOwner().
629 Handle(AIS_InteractiveObject) SelectedInteractive() const
631 return !mySelection->More()
632 ? Handle(AIS_InteractiveObject)()
633 : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
636 //! Returns TRUE if the interactive context has a shape selected.
637 //! @sa SelectedShape().
638 Standard_EXPORT Standard_Boolean HasSelectedShape() const;
640 //! Returns the selected shape.
641 //! Basically it is just a shape returned stored by StdSelect_BRepOwner with graphic transformation being applied:
643 //! const Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (SelectedOwner());
644 //! TopoDS_Shape aSelShape = aBRepOwner->Shape();
645 //! TopoDS_Shape aLocatedShape = aSelShape.Located (aBRepOwner->Location() * aSelShape.Location());
647 //! @sa SelectedOwner(), HasSelectedShape().
648 Standard_EXPORT TopoDS_Shape SelectedShape() const;
650 //! Returns SelectedInteractive()->HasOwner().
651 //! @sa SelectedOwner().
652 Standard_Boolean HasApplicative() const { return SelectedInteractive()->HasOwner(); }
654 //! Returns SelectedInteractive()->GetOwner().
655 //! @sa SelectedOwner().
656 Handle(Standard_Transient) Applicative() const { return SelectedInteractive()->GetOwner(); }
658 public: //! @name immediate mode rendering
660 //! initializes the list of presentations to be displayed
661 //! returns False if no local context is opened.
662 Standard_EXPORT Standard_Boolean BeginImmediateDraw();
664 //! returns True if <anIObj> has been stored in the list.
665 Standard_EXPORT Standard_Boolean ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0);
667 //! returns True if the immediate display has been done.
668 Standard_EXPORT Standard_Boolean EndImmediateDraw (const Handle(V3d_View)& theView);
670 //! Uses the First Active View of Main Viewer!
671 //! returns True if the immediate display has been done.
672 Standard_EXPORT Standard_Boolean EndImmediateDraw();
674 Standard_EXPORT Standard_Boolean IsImmediateModeOn() const;
676 //! Redraws immediate structures in all views of the viewer given taking into account its visibility.
677 void RedrawImmediate (const Handle(V3d_Viewer)& theViewer) { myMainPM->RedrawImmediate (theViewer); }
679 public: //! @name management of active Selection Modes
681 //! Activates or deactivates the selection mode for specified object.
682 //! Has no effect if selection mode was already active/deactivated.
683 //! @param theObj object to activate/deactivate selection mode
684 //! @param theMode selection mode to activate/deactivate;
685 //! deactivation of -1 selection mode will effectively deactivate all selection modes;
686 //! activation of -1 selection mode with AIS_SelectionModesConcurrency_Single
687 //! will deactivate all selection modes, and will has no effect otherwise
688 //! @param theToActivate activation/deactivation flag
689 //! @param theConcurrency specifies how to handle already activated selection modes;
690 //! default value (AIS_SelectionModesConcurrency_Multiple) means active selection modes should be left as is,
691 //! AIS_SelectionModesConcurrency_Single can be used if only one selection mode is expected to be active
692 //! and AIS_SelectionModesConcurrency_GlobalOrLocal can be used if either AIS_InteractiveObject::GlobalSelectionMode()
693 //! or any combination of Local selection modes is acceptable;
694 //! this value is considered only if theToActivate set to TRUE
695 //! @param theIsForce when set to TRUE, the display status will be ignored while activating selection mode
696 Standard_EXPORT void SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
697 const Standard_Integer theMode,
698 const Standard_Boolean theToActivate,
699 const AIS_SelectionModesConcurrency theConcurrency = AIS_SelectionModesConcurrency_Multiple,
700 const Standard_Boolean theIsForce = Standard_False);
702 //! Activates the selection mode aMode whose index is given, for the given interactive entity anIobj.
703 void Activate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0, const Standard_Boolean theIsForce = Standard_False)
705 SetSelectionModeActive (theObj, theMode, Standard_True, AIS_SelectionModesConcurrency_GlobalOrLocal, theIsForce);
708 //! Activates the given selection mode for the all displayed objects.
709 Standard_EXPORT void Activate (const Standard_Integer theMode,
710 const Standard_Boolean theIsForce = Standard_False);
712 //! Deactivates all the activated selection modes of an object.
713 void Deactivate (const Handle(AIS_InteractiveObject)& theObj)
715 SetSelectionModeActive (theObj, -1, Standard_False, AIS_SelectionModesConcurrency_Single);
718 //! Deactivates all the activated selection modes of the interactive object anIobj with a given selection mode aMode.
719 void Deactivate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode)
721 SetSelectionModeActive (theObj, theMode, Standard_False);
724 //! Deactivates the given selection mode for all displayed objects.
725 Standard_EXPORT void Deactivate (const Standard_Integer theMode);
727 //! Deactivates all the activated selection mode at all displayed objects.
728 Standard_EXPORT void Deactivate();
730 //! Returns the list of activated selection modes.
731 Standard_EXPORT void ActivatedModes (const Handle(AIS_InteractiveObject)& anIobj, TColStd_ListOfInteger& theList) const;
733 //! Returns a collection containing all entity owners created for the interactive object in specified selection mode (in all active modes if the Mode == -1)
734 Standard_EXPORT void EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
735 const Handle(AIS_InteractiveObject)& theIObj,
736 const Standard_Integer theMode = -1) const;
738 public: //! @name Selection Filters management
740 //! @return the context selection filter type.
741 SelectMgr_FilterType FilterType() const { return myFilters->FilterType(); }
743 //! Sets the context selection filter type.
744 //! SelectMgr_TypeFilter_OR selection filter is used by default.
745 //! @param theFilterType the filter type.
746 void SetFilterType (const SelectMgr_FilterType theFilterType)
747 { myFilters->SetFilterType (theFilterType); }
749 //! Returns the list of filters active in a local context.
750 const SelectMgr_ListOfFilter& Filters() const { return myFilters->StoredFilters(); }
752 //! @return the context selection global context filter.
753 const Handle(SelectMgr_AndOrFilter)& GlobalFilter() const { return myFilters; }
755 //! Allows you to add the filter.
756 void AddFilter (const Handle(SelectMgr_Filter)& theFilter) { myFilters->Add (theFilter); }
758 //! Removes a filter from context.
759 void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter) { myFilters->Remove (theFilter); }
761 //! Remove all filters from context.
762 void RemoveFilters() { myFilters->Clear(); }
764 //! Return picking strategy; SelectMgr_PickingStrategy_FirstAcceptable by default.
765 //! @sa MoveTo(), Filters()
766 SelectMgr_PickingStrategy PickingStrategy() const { return myPickingStrategy; }
768 //! Setup picking strategy - which entities detected by picking line will be accepted, considering Selection Filters.
769 //! By default (SelectMgr_PickingStrategy_FirstAcceptable), Selection Filters reduce the list of entities
770 //! so that the context accepts topmost in remaining.
772 //! This means that entities behind non-selectable (by filters) parts can be picked by user.
773 //! If this behavior is undesirable, and user wants that non-selectable (by filters) parts
774 //! should remain an obstacle for picking, SelectMgr_PickingStrategy_OnlyTopmost can be set instead.
776 //! Notice, that since Selection Manager operates only objects registered in it,
777 //! SelectMgr_PickingStrategy_OnlyTopmost will NOT prevent picking entities behind
778 //! visible by unregistered in Selection Manager presentations (e.g. deactivated).
779 //! Hence, SelectMgr_PickingStrategy_OnlyTopmost changes behavior only with Selection Filters enabled.
780 void SetPickingStrategy (const SelectMgr_PickingStrategy theStrategy)
782 myPickingStrategy = theStrategy;
785 public: //! @name common properties
787 //! Returns the default attribute manager.
788 //! This contains all the color and line attributes which can be used by interactive objects which do not have their own attributes.
789 const Handle(Prs3d_Drawer)& DefaultDrawer() const { return myDefaultDrawer; }
791 //! Sets the default attribute manager; should be set at context creation time.
792 //! Warning - this setter doesn't update links to the default drawer of already displayed objects!
793 void SetDefaultDrawer (const Handle(Prs3d_Drawer)& theDrawer)
795 myDefaultDrawer = theDrawer;
796 myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
799 //! Returns the current viewer.
800 const Handle(V3d_Viewer)& CurrentViewer() const { return myMainVwr; }
802 const Handle(SelectMgr_SelectionManager)& SelectionManager() const { return mgrSelector; }
804 const Handle(PrsMgr_PresentationManager)& MainPrsMgr() const { return myMainPM; }
806 const Handle(StdSelect_ViewerSelector3d)& MainSelector() const { return mgrSelector->Selector(); }
808 //! Updates the current viewer.
809 Standard_EXPORT void UpdateCurrentViewer();
811 //! Returns the list of displayed objects of a particular Type WhichKind and Signature WhichSignature.
812 //! By Default, WhichSignature equals -1. This means that there is a check on type only.
813 Standard_EXPORT void DisplayedObjects (AIS_ListOfInteractive& aListOfIO) const;
815 //! gives the list of displayed objects of a particular Type and signature.
816 //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
817 Standard_EXPORT void DisplayedObjects (const AIS_KindOfInteractive theWhichKind, const Standard_Integer theWhichSignature, AIS_ListOfInteractive& theListOfIO) const;
819 //! Returns the list theListOfIO of erased objects (hidden objects) particular Type WhichKind and Signature WhichSignature.
820 //! By Default, WhichSignature equals 1. This means that there is a check on type only.
821 Standard_EXPORT void ErasedObjects (AIS_ListOfInteractive& theListOfIO) const;
823 //! gives the list of erased objects (hidden objects)
824 //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
825 Standard_EXPORT void ErasedObjects (const AIS_KindOfInteractive theWhichKind, const Standard_Integer theWhichSignature, AIS_ListOfInteractive& theListOfIO) const;
827 //! Returns the list theListOfIO of objects with indicated display status particular Type WhichKind and Signature WhichSignature.
828 //! By Default, WhichSignature equals 1. This means that there is a check on type only.
829 Standard_EXPORT void ObjectsByDisplayStatus (const PrsMgr_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const;
831 //! gives the list of objects with indicated display status
832 //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
833 Standard_EXPORT void ObjectsByDisplayStatus (const AIS_KindOfInteractive WhichKind,
834 const Standard_Integer WhichSignature,
835 const PrsMgr_DisplayStatus theStatus,
836 AIS_ListOfInteractive& theListOfIO) const;
838 //! fills <aListOfIO> with objects of a particular Type and Signature with no consideration of display status.
839 //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
840 //! if <WhichKind> = AIS_KindOfInteractive_None and <WhichSignature> = -1, all the objects are put into the list.
841 Standard_EXPORT void ObjectsInside (AIS_ListOfInteractive& aListOfIO,
842 const AIS_KindOfInteractive WhichKind = AIS_KindOfInteractive_None,
843 const Standard_Integer WhichSignature = -1) const;
845 //! Create iterator through all objects registered in context.
846 AIS_DataMapIteratorOfDataMapOfIOStatus ObjectIterator() const
848 return AIS_DataMapIteratorOfDataMapOfIOStatus (myObjects);
851 //! Rebuilds 1st level of BVH selection forcibly
852 Standard_EXPORT void RebuildSelectionStructs();
854 //! Disconnects theObjToDisconnect from theAssembly and removes dependent selection structures
855 Standard_EXPORT void Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, const Handle(AIS_InteractiveObject)& theObjToDisconnect = NULL);
857 //! Query objects visible or hidden in specified view due to affinity mask.
858 Standard_EXPORT void ObjectsForView (AIS_ListOfInteractive& theListOfIO,
859 const Handle(V3d_View)& theView,
860 const Standard_Boolean theIsVisibleInView,
861 const PrsMgr_DisplayStatus theStatus = PrsMgr_DisplayStatus_None) const;
863 //! Return rotation gravity point.
864 Standard_EXPORT virtual gp_Pnt GravityPoint (const Handle(V3d_View)& theView) const;
866 public: //! @name debug visualization
868 //! Visualization of sensitives - for debugging purposes!
869 Standard_EXPORT void DisplayActiveSensitive (const Handle(V3d_View)& aView);
871 //! Clear visualization of sensitives.
872 Standard_EXPORT void ClearActiveSensitive (const Handle(V3d_View)& aView);
874 //! Visualization of sensitives - for debugging purposes!
875 Standard_EXPORT void DisplayActiveSensitive (const Handle(AIS_InteractiveObject)& anObject, const Handle(V3d_View)& aView);
877 public: //! @name common object display attributes
879 //! Sets the graphic attributes of the interactive object, such as visualization mode, color, and material.
880 Standard_EXPORT void SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
881 const Handle(Prs3d_Drawer)& theDrawer,
882 const Standard_Boolean theToUpdateViewer);
884 //! Removes the settings for local attributes of the Object and returns to defaults.
885 Standard_EXPORT void UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
886 const Standard_Boolean theToUpdateViewer);
888 //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE.
889 //! This mean that attributes is applying both on the front and back face.
890 Standard_EXPORT void SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& aniobj, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE);
892 //! Returns true if a view of the Interactive Object has color.
893 Standard_EXPORT Standard_Boolean HasColor (const Handle(AIS_InteractiveObject)& aniobj) const;
895 //! Returns the color of the Object in the interactive context.
896 Standard_EXPORT void Color (const Handle(AIS_InteractiveObject)& aniobj, Quantity_Color& acolor) const;
898 //! Sets the color of the selected entity.
899 Standard_EXPORT void SetColor (const Handle(AIS_InteractiveObject)& theIObj,
900 const Quantity_Color& theColor,
901 const Standard_Boolean theToUpdateViewer);
903 //! Removes the color selection for the selected entity.
904 Standard_EXPORT void UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
905 const Standard_Boolean theToUpdateViewer);
907 //! Returns the width of the Interactive Object in the interactive context.
908 Standard_EXPORT virtual Standard_Real Width (const Handle(AIS_InteractiveObject)& aniobj) const;
910 //! Sets the width of the Object.
911 Standard_EXPORT virtual void SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
912 const Standard_Real theValue,
913 const Standard_Boolean theToUpdateViewer);
915 //! Removes the width setting of the Object.
916 Standard_EXPORT virtual void UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
917 const Standard_Boolean theToUpdateViewer);
919 //! Provides the type of material setting for the view of the Object.
920 Standard_EXPORT void SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
921 const Graphic3d_MaterialAspect& theMaterial,
922 const Standard_Boolean theToUpdateViewer);
924 //! Removes the type of material setting for viewing the Object.
925 Standard_EXPORT void UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
926 const Standard_Boolean theToUpdateViewer);
928 //! Provides the transparency settings for viewing the Object.
929 //! The transparency value aValue may be between 0.0, opaque, and 1.0, fully transparent.
930 Standard_EXPORT void SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
931 const Standard_Real theValue,
932 const Standard_Boolean theToUpdateViewer);
934 //! Removes the transparency settings for viewing the Object.
935 Standard_EXPORT void UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
936 const Standard_Boolean theToUpdateViewer);
938 //! Sets up polygon offsets for the given AIS_InteractiveObject.
939 //! It simply calls AIS_InteractiveObject::SetPolygonOffsets().
940 Standard_EXPORT void SetPolygonOffsets (const Handle(AIS_InteractiveObject)& theIObj,
941 const Standard_Integer theMode,
942 const Standard_ShortReal theFactor,
943 const Standard_ShortReal theUnits,
944 const Standard_Boolean theToUpdateViewer);
946 //! Simply calls AIS_InteractiveObject::HasPolygonOffsets().
947 Standard_EXPORT Standard_Boolean HasPolygonOffsets (const Handle(AIS_InteractiveObject)& anObj) const;
949 //! Retrieves current polygon offsets settings for Object.
950 Standard_EXPORT void PolygonOffsets (const Handle(AIS_InteractiveObject)& anObj, Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
952 public: //! @name trihedron display attributes
954 //! Sets the size aSize of the trihedron.
955 //! Is used to change the default value 100 mm for display of trihedra.
956 //! Use of this function in one of your own interactive objects requires a call to the Compute function of the new class.
957 //! This will recalculate the presentation for every trihedron displayed.
958 Standard_EXPORT void SetTrihedronSize (const Standard_Real theSize,
959 const Standard_Boolean theToUpdateViewer);
961 //! returns the current value of trihedron size.
962 Standard_EXPORT Standard_Real TrihedronSize() const;
964 public: //! @name plane display attributes
966 //! Sets the plane size defined by the length in the X direction XSize and that in the Y direction YSize.
967 Standard_EXPORT void SetPlaneSize (const Standard_Real theSizeX,
968 const Standard_Real theSizeY,
969 const Standard_Boolean theToUpdateViewer);
971 //! Sets the plane size aSize.
972 Standard_EXPORT void SetPlaneSize (const Standard_Real theSize,
973 const Standard_Boolean theToUpdateViewer);
975 //! Returns true if the length in the X direction XSize is the same as that in the Y direction YSize.
976 Standard_EXPORT Standard_Boolean PlaneSize (Standard_Real& XSize, Standard_Real& YSize) const;
978 public: //! @name tessellation deviation properties for automatic triangulation
980 //! Sets the deviation coefficient theCoefficient.
981 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
982 //! A Deviation coefficient is used in the shading display mode.
983 //! The shape is seen decomposed into triangles.
984 //! These are used to calculate reflection of light from the surface of the object.
985 //! The triangles are formed from chords of the curves in the shape.
986 //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
987 //! If this limit is reached, a new triangle is begun.
988 //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
989 //! The default value is 0.001.
990 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
991 //! This deviation will be: SizeOfObject * DeviationCoefficient.
992 Standard_EXPORT void SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
993 const Standard_Real theCoefficient,
994 const Standard_Boolean theToUpdateViewer);
996 Standard_EXPORT void SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
997 const Standard_Real theAngle,
998 const Standard_Boolean theToUpdateViewer);
1000 //! Calls the AIS_Shape SetAngleAndDeviation to set both Angle and Deviation coefficients
1001 Standard_EXPORT void SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1002 const Standard_Real theAngle,
1003 const Standard_Boolean theToUpdateViewer);
1005 //! Sets the deviation coefficient theCoefficient.
1006 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
1007 //! A Deviation coefficient is used in the shading display mode.
1008 //! The shape is seen decomposed into triangles.
1009 //! These are used to calculate reflection of light from the surface of the object.
1010 //! The triangles are formed from chords of the curves in the shape.
1011 //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
1012 //! If this limit is reached, a new triangle is begun.
1013 //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
1014 //! The default value is 0.001.
1015 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
1016 //! This deviation will be: SizeOfObject * DeviationCoefficient.
1017 void SetDeviationCoefficient (const Standard_Real theCoefficient) { myDefaultDrawer->SetDeviationCoefficient (theCoefficient); }
1019 //! Returns the deviation coefficient.
1020 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
1021 //! A Deviation coefficient is used in the shading display mode.
1022 //! The shape is seen decomposed into triangles.
1023 //! These are used to calculate reflection of light from the surface of the object.
1024 //! The triangles are formed from chords of the curves in the shape.
1025 //! The deviation coefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
1026 //! If this limit is reached, a new triangle is begun.
1027 //! This deviation is absolute and is set through Prs3d_Drawer::SetMaximalChordialDeviation.
1028 //! The default value is 0.001.
1029 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
1030 //! This deviation will be: SizeOfObject * DeviationCoefficient.
1031 Standard_Real DeviationCoefficient() const { return myDefaultDrawer->DeviationCoefficient(); }
1033 //! default 20 degrees
1034 void SetDeviationAngle (const Standard_Real theAngle) { myDefaultDrawer->SetDeviationAngle (theAngle); }
1036 Standard_Real DeviationAngle() const { return myDefaultDrawer->DeviationAngle(); }
1038 public: //! @name HLR (Hidden Line Removal) display attributes
1040 //! Initializes hidden line aspect in the default drawing tool, or Drawer.
1041 //! The default values are:
1042 //! Color: Quantity_NOC_YELLOW
1043 //! Type of line: Aspect_TOL_DASH
1045 const Handle(Prs3d_LineAspect)& HiddenLineAspect() const { return myDefaultDrawer->HiddenLineAspect(); }
1047 //! Sets the hidden line aspect anAspect.
1048 //! Aspect defines display attributes for hidden lines in HLR projections.
1049 void SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const { myDefaultDrawer->SetHiddenLineAspect (theAspect); }
1051 //! returns Standard_True if the hidden lines are to be drawn.
1052 //! By default the hidden lines are not drawn.
1053 Standard_Boolean DrawHiddenLine() const { return myDefaultDrawer->DrawHiddenLine(); }
1055 void EnableDrawHiddenLine() const { myDefaultDrawer->EnableDrawHiddenLine(); }
1057 void DisableDrawHiddenLine() const { myDefaultDrawer->DisableDrawHiddenLine(); }
1059 public: //! @name iso-line display attributes
1061 //! Sets the number of U and V isoparameters displayed.
1062 Standard_EXPORT void SetIsoNumber (const Standard_Integer NbIsos, const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1064 //! Returns the number of U and V isoparameters displayed.
1065 Standard_EXPORT Standard_Integer IsoNumber (const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1067 //! Returns True if drawing isoparameters on planes is enabled.
1068 void IsoOnPlane (const Standard_Boolean theToSwitchOn) { myDefaultDrawer->SetIsoOnPlane (theToSwitchOn); }
1070 //! Returns True if drawing isoparameters on planes is enabled.
1071 //! if <forUIsos> = False,
1072 Standard_Boolean IsoOnPlane() const { return myDefaultDrawer->IsoOnPlane(); }
1074 //! Enables or disables on-triangulation build for isolines for a particular object.
1075 //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given.
1076 Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theIsEnabled,
1077 const Handle(AIS_InteractiveObject)& theObject);
1079 //! Enables or disables on-triangulation build for isolines for default drawer.
1080 //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given.
1081 void IsoOnTriangulation (const Standard_Boolean theToSwitchOn) { myDefaultDrawer->SetIsoOnTriangulation (theToSwitchOn); }
1083 //! Returns true if drawing isolines on triangulation algorithm is enabled.
1084 Standard_Boolean IsoOnTriangulation() const { return myDefaultDrawer->IsoOnTriangulation(); }
1086 //! @name obsolete methods
1089 Standard_DEPRECATED("Deprecated method Display() with obsolete argument theToAllowDecomposition")
1090 void Display (const Handle(AIS_InteractiveObject)& theIObj,
1091 const Standard_Integer theDispMode,
1092 const Standard_Integer theSelectionMode,
1093 const Standard_Boolean theToUpdateViewer,
1094 const Standard_Boolean theToAllowDecomposition,
1095 const PrsMgr_DisplayStatus theDispStatus = PrsMgr_DisplayStatus_None)
1097 (void )theToAllowDecomposition;
1098 Display (theIObj, theDispMode, theSelectionMode, theToUpdateViewer, theDispStatus);
1101 Standard_DEPRECATED("Deprecated method Load() with obsolete last argument theToAllowDecomposition")
1102 void Load (const Handle(AIS_InteractiveObject)& theObj, Standard_Integer theSelectionMode, Standard_Boolean ) { Load (theObj, theSelectionMode); }
1104 //! Updates the display in the viewer to take dynamic detection into account.
1105 //! On dynamic detection by the mouse cursor, sensitive primitives are highlighted.
1106 //! The highlight color of entities detected by mouse movement is white by default.
1107 Standard_DEPRECATED("Deprecated method Hilight()")
1108 void Hilight (const Handle(AIS_InteractiveObject)& theObj,
1109 const Standard_Boolean theIsToUpdateViewer)
1111 return HilightWithColor (theObj, myStyles[Prs3d_TypeOfHighlight_Dynamic], theIsToUpdateViewer);
1114 //! Sets the graphic basic aspect to the current presentation of ALL selected objects.
1115 Standard_DEPRECATED ("Deprecated method - presentation attributes should be assigned directly to object")
1116 Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
1117 const Standard_Boolean theToUpdateViewer);
1119 //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
1120 //! The objects detected are passed to the main viewer, which is then updated.
1121 Standard_DEPRECATED("This method is deprecated - SelectRectangle() taking AIS_SelectionScheme_Replace should be called instead")
1122 Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
1123 const Standard_Integer theYPMin,
1124 const Standard_Integer theXPMax,
1125 const Standard_Integer theYPMax,
1126 const Handle(V3d_View)& theView,
1127 const Standard_Boolean theToUpdateViewer);
1129 //! polyline selection; clears the previous picked list
1130 Standard_DEPRECATED("This method is deprecated - SelectPolygon() taking AIS_SelectionScheme_Replace should be called instead")
1131 Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
1132 const Handle(V3d_View)& theView,
1133 const Standard_Boolean theToUpdateViewer);
1135 //! Stores and hilights the previous detected; Unhilights the previous picked.
1137 Standard_DEPRECATED("This method is deprecated - SelectDetected() taking AIS_SelectionScheme_Replace should be called instead")
1138 Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean theToUpdateViewer);
1140 //! Adds the last detected to the list of previous picked.
1141 //! If the last detected was already declared as picked, removes it from the Picked List.
1143 Standard_DEPRECATED("This method is deprecated - SelectDetected() taking AIS_SelectionScheme_XOR should be called instead")
1144 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean theToUpdateViewer);
1146 //! Adds the last detected to the list of previous picked.
1147 //! If the last detected was already declared as picked, removes it from the Picked List.
1148 Standard_DEPRECATED("This method is deprecated - SelectPolygon() taking AIS_SelectionScheme_XOR should be called instead")
1149 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
1150 const Handle(V3d_View)& theView,
1151 const Standard_Boolean theToUpdateViewer);
1153 //! Rectangle of selection; adds new detected entities into the picked list,
1154 //! removes the detected entities that were already stored.
1155 Standard_DEPRECATED("This method is deprecated - SelectRectangle() taking AIS_SelectionScheme_XOR should be called instead")
1156 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Integer theXPMin,
1157 const Standard_Integer theYPMin,
1158 const Standard_Integer theXPMax,
1159 const Standard_Integer theYPMax,
1160 const Handle(V3d_View)& theView,
1161 const Standard_Boolean theToUpdateViewer);
1165 //! Updates the view of the current object in open context.
1166 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1167 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1168 void SetCurrentObject (const Handle(AIS_InteractiveObject)& theIObj,
1169 const Standard_Boolean theToUpdateViewer) { SetSelected (theIObj, theToUpdateViewer); }
1171 //! Allows to add or remove the object given to the list of current and highlight/unhighlight it correspondingly.
1172 //! Is valid for global context only; for local context use method AddOrRemoveSelected.
1173 //! Since this method makes sense only for neutral point selection of a whole object,
1174 //! if 0 selection of the object is empty this method simply does nothing.
1175 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1176 void AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
1177 const Standard_Boolean theIsToUpdateViewer) { AddOrRemoveSelected (theObj, theIsToUpdateViewer); }
1179 //! Updates the list of current objects, i.e. hilights new current objects, removes hilighting from former current objects.
1180 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1181 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1182 void UpdateCurrent() { UpdateSelected (Standard_True); }
1184 //! Returns true if there is a non-null interactive object in Neutral Point.
1185 //! Objects selected when there is no open local context are called current objects;
1186 //! 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_Boolean IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const { return IsSelected (theObject); }
1190 //! Initializes a scan of the current selected objects in Neutral Point.
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 void InitCurrent() { InitSelected(); }
1195 //! Returns true if there is another object found by the scan of the list of current objects.
1196 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1197 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1198 Standard_Boolean MoreCurrent() const { return MoreSelected(); }
1200 //! Continues the scan to the next object in the list of current objects.
1201 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1202 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1203 void NextCurrent() { NextSelected(); }
1205 //! Returns the current interactive object.
1206 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1207 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1208 Handle(AIS_InteractiveObject) Current() const { return SelectedInteractive(); }
1210 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1211 Standard_Integer NbCurrents() { return NbSelected(); }
1213 //! Highlights current objects.
1214 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1215 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1216 void HilightCurrents (const Standard_Boolean theToUpdateViewer) { HilightSelected (theToUpdateViewer); }
1218 //! Removes highlighting from current objects.
1219 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1220 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1221 void UnhilightCurrents (const Standard_Boolean theToUpdateViewer) { UnhilightSelected (theToUpdateViewer); }
1223 //! Empties previous current objects in order to get the current objects detected by the selector using UpdateCurrent.
1224 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1225 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1226 void ClearCurrents (const Standard_Boolean theToUpdateViewer) { ClearSelected (theToUpdateViewer); }
1228 //! @return current mouse-detected shape or empty (null) shape, if current interactive object
1229 //! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
1230 //! @sa DetectedCurrentOwner(), InitDetected(), MoreDetected(), NextDetected().
1231 Standard_DEPRECATED ("Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
1232 Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const;
1234 //! @return current mouse-detected interactive object or null object, if there is no currently detected interactives
1235 //! @sa DetectedCurrentOwner(), InitDetected(), MoreDetected(), NextDetected().
1236 Standard_DEPRECATED ("Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
1237 Standard_EXPORT Handle(AIS_InteractiveObject) DetectedCurrentObject() const;
1239 public: //! @name sub-intensity management (deprecated)
1241 //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight,
1242 //! but without actual selection (e.g., global status and owner's selection state will not be updated).
1243 //! The method returns the color of such highlighting.
1244 //! By default, it is Quantity_NOC_GRAY40.
1245 const Quantity_Color& SubIntensityColor() const
1247 return myStyles[Prs3d_TypeOfHighlight_SubIntensity]->Color();
1250 //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight,
1251 //! but without actual selection (e.g., global status and owner's selection state will not be updated).
1252 //! The method sets up the color for such highlighting.
1253 //! By default, this is Quantity_NOC_GRAY40.
1254 void SetSubIntensityColor (const Quantity_Color& theColor)
1256 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetColor (theColor);
1259 //! Highlights, and removes highlights from, the displayed object which is displayed at Neutral Point with subintensity color.
1260 //! Available only for active local context.
1261 //! There is no effect if there is no local context.
1262 //! If a local context is open, the presentation of the Interactive Object activates the selection mode.
1263 Standard_EXPORT void SubIntensityOn (const Handle(AIS_InteractiveObject)& theIObj,
1264 const Standard_Boolean theToUpdateViewer);
1266 //! Removes the subintensity option for the entity.
1267 //! If a local context is open, the presentation of the Interactive Object activates the selection mode.
1268 Standard_EXPORT void SubIntensityOff (const Handle(AIS_InteractiveObject)& theIObj,
1269 const Standard_Boolean theToUpdateViewer);
1271 //! Returns selection instance
1272 const Handle(AIS_Selection)& Selection() const { return mySelection; }
1274 //! Sets selection instance to manipulate a container of selected owners
1275 //! @param theSelection an instance of the selection
1276 void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; }
1278 //! Dumps the content of me into the stream
1279 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
1281 protected: //! @name internal methods
1283 Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
1285 Standard_EXPORT void EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
1286 const Standard_Boolean theToUpdateViewer);
1288 Standard_EXPORT void ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
1289 const Standard_Boolean theToUpdateViewer);
1291 Standard_EXPORT void ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theObj,
1292 const Standard_Integer theMode,
1293 const Standard_Boolean theToUpdateViewer);
1295 Standard_EXPORT void InitAttributes();
1297 //! Highlights detected objects.
1298 //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to update view.
1299 Standard_EXPORT AIS_StatusOfDetection moveTo (const Handle(V3d_View)& theView,
1300 const Standard_Boolean theToRedrawOnUpdate);
1302 //! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
1303 Standard_EXPORT void unselectOwners (const Handle(AIS_InteractiveObject)& theObject);
1305 //! Helper function that highlights the owner given with <theStyle> without
1306 //! performing AutoHighlight checks, e.g. is used for dynamic highlight.
1307 Standard_EXPORT void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
1308 const Handle(V3d_Viewer)& theViewer = NULL);
1310 //! Helper function that highlights the owner given with <theStyle> with check
1311 //! for AutoHighlight, e.g. is used for selection.
1312 Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
1314 //! Helper function that highlights the owners with check for AutoHighlight, e.g. is used for selection.
1315 //! @param theOwners [in] list of owners to highlight
1316 //! @param theStyle [in] highlight style to apply or NULL to apply selection style
1317 Standard_EXPORT void highlightOwners (const AIS_NListOfEntityOwner& theOwners,
1318 const Handle(Prs3d_Drawer)& theStyle);
1320 //! Helper function that highlights global owner of the object given with <theStyle> with check
1321 //! for AutoHighlight, e.g. is used for selection.
1322 //! If global owner is null, it simply highlights the whole object
1323 Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
1324 const Handle(Prs3d_Drawer)& theStyle,
1325 const Standard_Integer theDispMode);
1327 //! Helper function that unhighlights all owners that are stored in current AIS_Selection.
1328 //! The function updates global status and selection state of owner and interactive object.
1329 //! If the parameter <theIsToHilightSubIntensity> is set to true, interactive objects with sub-intensity
1330 //! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
1331 Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
1333 //! Helper function that unhighlights the owners with check
1334 //! for AutoHighlight, e.g. is used for selection.
1335 Standard_EXPORT void unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
1336 const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
1338 //! Helper function that unhighlights global selection owner of given interactive.
1339 //! The function does not perform any updates of global or owner status
1340 Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj);
1342 //! Helper function that turns on sub-intensity in global status and highlights
1343 //! given objects with sub-intensity color
1344 //! @param theObject [in] the object. If NULL is given, than sub-intensity will be turned on for
1345 //! all inveractive objects of the context
1346 //! @param theDispMode [in] display mode. If -1 is given, sub-intensity will be turned on for
1347 //! all display modes in global status's list of modes
1348 //! @param theIsDisplayedOnly [in] is true if sub-intensity should be applied only to objects with
1349 //! status AIS_DS_Displayed
1350 Standard_EXPORT void turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject = NULL,
1351 const Standard_Integer theDispMode = -1,
1352 const Standard_Boolean theIsDisplayedOnly = Standard_True) const;
1354 //! Helper function that highlights the object with sub-intensity color without any checks
1355 //! @param theObject [in] the object that will be highlighted
1356 //! @param theMode [in] display mode
1357 Standard_EXPORT void highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
1358 const Standard_Integer theMode) const;
1360 //! Helper function that highlights the owner with sub-intensity color without any checks
1361 //! @param theOwner [in] the owner that will be highlighted
1362 //! @param theMode [in] display mode
1363 Standard_EXPORT void highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
1364 const Standard_Integer theMode) const;
1366 //! Helper function that returns correct dynamic highlight style for the object:
1367 //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1368 //! dynamic highlight style of interactive context will be returned.
1369 //! @param theObj [in] the object to check
1370 const Handle(Prs3d_Drawer)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj,
1371 const Handle(SelectMgr_EntityOwner)& theOwner) const
1373 const Handle(Prs3d_Drawer)& aHiDrawer = theObj->DynamicHilightAttributes();
1374 if (!aHiDrawer.IsNull())
1379 return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalDynamic : Prs3d_TypeOfHighlight_Dynamic];
1382 //! Return TRUE if highlight style of owner requires full viewer redraw.
1383 Standard_EXPORT Standard_Boolean isSlowHiStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
1384 const Handle(V3d_Viewer)& theViewer) const;
1386 //! Helper function that returns correct selection style for the object:
1387 //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1388 //! selection style of interactive context will be returned.
1389 //! @param theObj [in] the object to check
1390 const Handle(Prs3d_Drawer)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj,
1391 const Handle(SelectMgr_EntityOwner)& theOwner) const
1393 const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes();
1394 if (!aHiDrawer.IsNull())
1399 return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalSelected : Prs3d_TypeOfHighlight_Selected];
1402 //! Assign the context to the object or throw exception if object was already assigned to another context.
1403 Standard_EXPORT void setContextToObject (const Handle(AIS_InteractiveObject)& theObj);
1405 //! Return display mode for highlighting.
1406 Standard_Integer getHilightMode (const Handle(AIS_InteractiveObject)& theObj,
1407 const Handle(Prs3d_Drawer)& theStyle,
1408 const Standard_Integer theDispMode) const
1410 if (!theStyle.IsNull()
1411 && theStyle->DisplayMode() != -1
1412 && theObj->AcceptDisplayMode (theStyle->DisplayMode()))
1414 return theStyle->DisplayMode();
1416 else if (theDispMode != -1)
1420 else if (theObj->HasDisplayMode())
1422 return theObj->DisplayMode();
1424 return myDefaultDrawer->DisplayMode();
1427 //! Removes dynamic highlight draw
1428 void clearDynamicHighlight() const
1430 if (myLastPicked.IsNull())
1433 myLastPicked->Selectable()->ClearDynamicHighlight (myMainPM);
1436 //! Bind/Unbind status to object and its children
1437 //! @param[in] theIObj the object to change status
1438 //! @param[in] theStatus status, if NULL, unbind object
1439 Standard_EXPORT void setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj,
1440 const PrsMgr_DisplayStatus theStatus,
1441 const Standard_Integer theDispyMode,
1442 const Standard_Integer theSelectionMode);
1444 protected: //! @name internal fields
1446 AIS_DataMapOfIOStatus myObjects;
1447 Handle(SelectMgr_SelectionManager) mgrSelector;
1448 Handle(PrsMgr_PresentationManager) myMainPM;
1449 Handle(V3d_Viewer) myMainVwr;
1450 V3d_View* myLastActiveView;
1451 Handle(SelectMgr_EntityOwner) myLastPicked;
1452 Standard_Boolean myToHilightSelected;
1453 Handle(AIS_Selection) mySelection;
1454 Handle(SelectMgr_AndOrFilter) myFilters; //!< context filter (the content active filters
1455 //! can be applied with AND or OR operation)
1456 Handle(Prs3d_Drawer) myDefaultDrawer;
1457 Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB];
1458 TColStd_SequenceOfInteger myDetectedSeq;
1459 Standard_Integer myCurDetected;
1460 Standard_Integer myCurHighlighted;
1461 SelectMgr_PickingStrategy myPickingStrategy; //!< picking strategy to be applied within MoveTo()
1462 Standard_Boolean myAutoHilight;
1463 Standard_Boolean myIsAutoActivateSelMode;
1467 DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient)
1469 #endif // _AIS_InteractiveContext_HeaderFile