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;
61 //! The Interactive Context allows you to manage graphic behavior and selection of Interactive Objects in one or more viewers.
62 //! Class methods make this highly transparent.
63 //! It is essential to remember that an Interactive Object which is already known by the Interactive Context must be modified using Context methods.
64 //! You can only directly call the methods available for an Interactive Object if it has not been loaded into an Interactive Context.
66 //! Each selectable object must specify the selection mode that is
67 //! responsible for selection of object as a whole (global selection mode).
68 //! Interactive context itself supports decomposed object selection with selection filters support.
69 //! By default, global selection mode is equal to 0, but it might be redefined if needed.
70 class AIS_InteractiveContext : public Standard_Transient
72 friend class AIS_LocalContext;
73 DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
74 public: //! @name object display management
76 //! Constructs the interactive context object defined by the principal viewer MainViewer.
77 Standard_EXPORT AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer);
80 Standard_EXPORT virtual ~AIS_InteractiveContext();
82 //! Returns the display status of the entity anIobj.
83 //! This will be one of the following:
84 //! - AIS_DS_Displayed displayed in main viewer
85 //! - AIS_DS_Erased hidden in main viewer
86 //! - AIS_DS_Temporary temporarily displayed
87 //! - AIS_DS_None nowhere displayed.
88 Standard_EXPORT AIS_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const;
90 //! Returns the status of the Interactive Context for the view of the Interactive Object.
91 Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const;
93 //! Returns true if Object is displayed in the interactive context.
94 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const;
96 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer aMode) const;
98 //! Enable or disable automatic activation of default selection mode while displaying the object.
99 void SetAutoActivateSelection (const Standard_Boolean theIsAuto) { myIsAutoActivateSelMode = theIsAuto; }
101 //! Manages displaying the new object should also automatically activate default selection mode; TRUE by default.
102 Standard_Boolean GetAutoActivateSelection() const { return myIsAutoActivateSelMode; }
104 //! Displays the object in this Context using default Display Mode.
105 //! This will be the object's default display mode, if there is one. Otherwise, it will be the context mode.
106 //! The Interactive Object's default selection mode is activated if GetAutoActivateSelection() is TRUE. In general, this is 0.
107 Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj,
108 const Standard_Boolean theToUpdateViewer);
110 //! Sets status, display mode and selection mode for specified Object
111 //! If theSelectionMode equals -1, theIObj will not be activated: it will be displayed but will not be selectable.
112 Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj,
113 const Standard_Integer theDispMode,
114 const Standard_Integer theSelectionMode,
115 const Standard_Boolean theToUpdateViewer,
116 const Standard_Boolean theToAllowDecomposition = Standard_True,
117 const AIS_DisplayStatus theDispStatus = AIS_DS_None);
119 //! Allows you to load the Interactive Object with a given selection mode,
120 //! and/or with the desired decomposition option, whether the object is visualized or not.
121 //! If AllowDecomp = Standard_True and, if the interactive object is of the "Shape" type,
122 //! these "standard" selection modes will be automatically activated as a function of the modes present in the Local Context.
123 //! The loaded objects will be selectable but displayable in highlighting only when detected by the Selector.
124 Standard_EXPORT void Load (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer SelectionMode = -1, const Standard_Boolean AllowDecomp = Standard_False);
126 //! Hides the object. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
127 //! To show hidden objects, use Display().
128 Standard_EXPORT void Erase (const Handle(AIS_InteractiveObject)& theIObj,
129 const Standard_Boolean theToUpdateViewer);
131 //! Hides all objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
132 //! To show all hidden objects, use DisplayAll().
133 Standard_EXPORT void EraseAll (const Standard_Boolean theToUpdateViewer);
135 //! Displays all hidden objects.
136 Standard_EXPORT void DisplayAll (const Standard_Boolean theToUpdateViewer);
138 //! Hides selected objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing.
139 //! To show hidden objects, use Display().
140 Standard_EXPORT void EraseSelected (const Standard_Boolean theToUpdateViewer);
142 //! Displays current objects.
143 Standard_EXPORT void DisplaySelected (const Standard_Boolean theToUpdateViewer);
145 //! Empties the graphic presentation of the mode indexed by aMode.
146 //! Warning! Removes theIObj. theIObj is still active if it was previously activated.
147 Standard_EXPORT void ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
148 const Standard_Integer theMode,
149 const Standard_Boolean theToUpdateViewer);
151 //! Removes Object from every viewer.
152 Standard_EXPORT void Remove (const Handle(AIS_InteractiveObject)& theIObj,
153 const Standard_Boolean theToUpdateViewer);
155 //! Removes all the objects from Context.
156 Standard_EXPORT void RemoveAll (const Standard_Boolean theToUpdateViewer);
158 //! Recomputes the seen parts presentation of the Object.
159 //! If theAllModes equals true, all presentations are present in the object even if unseen.
160 Standard_EXPORT void Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
161 const Standard_Boolean theToUpdateViewer,
162 const Standard_Boolean theAllModes = Standard_False);
164 //! Recomputes the Prs/Selection of displayed objects of a given type and a given signature.
165 //! if signature = -1 doesn't take signature criterion.
166 Standard_EXPORT void Redisplay (const AIS_KindOfInteractive theTypeOfObject,
167 const Standard_Integer theSignature,
168 const Standard_Boolean theToUpdateViewer);
170 //! Recomputes the displayed presentations, flags the others.
171 //! Doesn't update presentations.
172 Standard_EXPORT void RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
173 const Standard_Boolean theToUpdateViewer,
174 const Standard_Boolean theAllModes = Standard_False);
176 //! Recomputes the active selections, flags the others.
177 //! Doesn't update presentations.
178 Standard_EXPORT void RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& anIObj);
180 //! Updates displayed interactive object by checking and recomputing its flagged as "to be recomputed" presentation and selection structures.
181 //! This method does not force any recomputation on its own.
182 //! The method recomputes selections even if they are loaded without activation in particular selector.
183 Standard_EXPORT void Update (const Handle(AIS_InteractiveObject)& theIObj,
184 const Standard_Boolean theUpdateViewer);
186 public: //! @name highlighting management
188 //! Returns highlight style settings.
189 const Handle(Prs3d_Drawer)& HighlightStyle (const Prs3d_TypeOfHighlight theStyleType) const { return myStyles[theStyleType]; }
191 //! Setup highlight style settings.
192 void SetHighlightStyle (const Prs3d_TypeOfHighlight theStyleType,
193 const Handle(Prs3d_Drawer)& theStyle) { myStyles[theStyleType] = theStyle; }
195 //! Returns current dynamic highlight style settings.
197 //! - the color of dynamic highlight is Quantity_NOC_CYAN1;
198 //! - the presentation for dynamic highlight is completely opaque;
199 //! - the type of highlight is Aspect_TOHM_COLOR.
200 const Handle(Prs3d_Drawer)& HighlightStyle() const
202 return myStyles[Prs3d_TypeOfHighlight_Dynamic];
205 //! Setup the style of dynamic highlighting.
206 void SetHighlightStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle; }
208 //! Returns current selection style settings.
210 //! - the color of selection is Quantity_NOC_GRAY80;
211 //! - the presentation for selection is completely opaque;
212 //! - the type of highlight is Aspect_TOHM_COLOR.
213 const Handle(Prs3d_Drawer)& SelectionStyle() const
215 return myStyles[Prs3d_TypeOfHighlight_Selected];
218 //! Setup the style of selection highlighting.
219 void SetSelectionStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Selected] = theStyle; }
221 //! Returns highlight style of the object if it is marked as highlighted via global status
222 //! @param theObj [in] the object to check
223 Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObj,
224 Handle(Prs3d_Drawer)& theStyle) const;
226 //! Returns highlight style of the owner if it is selected
227 //! @param theOwner [in] the owner to check
228 Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
229 Handle(Prs3d_Drawer)& theStyle) const;
231 //! Returns true if the object is marked as highlighted via its global status
232 //! @param theObj [in] the object to check
233 Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const;
235 //! Returns true if the owner is marked as selected
236 //! @param theOwner [in] the owner to check
237 Standard_EXPORT Standard_Boolean IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const;
239 //! Updates the display in the viewer to take dynamic detection into account.
240 //! On dynamic detection by the mouse cursor, sensitive primitives are highlighted.
241 //! The highlight color of entities detected by mouse movement is white by default.
242 Standard_DEPRECATED("Deprecated method Hilight()")
243 void Hilight (const Handle(AIS_InteractiveObject)& theObj,
244 const Standard_Boolean theIsToUpdateViewer)
246 return HilightWithColor (theObj, myStyles[Prs3d_TypeOfHighlight_Dynamic], theIsToUpdateViewer);
249 //! Changes the color of all the lines of the object in view.
250 Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& theObj,
251 const Handle(Prs3d_Drawer)& theStyle,
252 const Standard_Boolean theToUpdateViewer);
254 //! Removes hilighting from the Object.
255 Standard_EXPORT void Unhilight (const Handle(AIS_InteractiveObject)& theIObj,
256 const Standard_Boolean theToUpdateViewer);
258 public: //! @name object presence management (View affinity, Layer, Priority)
260 //! Returns the display priority of the Object.
261 Standard_EXPORT Standard_Integer DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const;
263 //! Sets the display priority of the seen parts presentation of the Object.
264 Standard_EXPORT void SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Integer thePriority);
266 //! Get Z layer id set for displayed interactive object.
267 Standard_EXPORT Graphic3d_ZLayerId GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const;
269 //! Set Z layer id for interactive object.
270 //! The Z layers can be used to display temporarily presentations of some object in front of the other objects in the scene.
271 //! The ids for Z layers are generated by V3d_Viewer.
272 Standard_EXPORT void SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, const Graphic3d_ZLayerId theLayerId);
274 //! Setup object visibility in specified view.
275 //! Has no effect if object is not displayed in this context.
276 Standard_EXPORT void SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisible);
278 public: //! @name Display Mode management
280 //! Returns the Display Mode setting to be used by default.
281 Standard_Integer DisplayMode() const { return myDefaultDrawer->DisplayMode(); }
283 //! Sets the display mode of seen Interactive Objects (which have no overridden Display Mode).
284 Standard_EXPORT void SetDisplayMode (const Standard_Integer theMode,
285 const Standard_Boolean theToUpdateViewer);
287 //! Sets the display mode of seen Interactive Objects.
288 //! theMode provides the display mode index of the entity theIObj.
289 Standard_EXPORT void SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
290 const Standard_Integer theMode,
291 const Standard_Boolean theToUpdateViewer);
293 //! Unsets the display mode of seen Interactive Objects.
294 Standard_EXPORT void UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
295 const Standard_Boolean theToUpdateViewer);
297 public: //! @name object local transformation management
299 //! Puts the location on the initial graphic representation and the selection for the Object.
300 Standard_EXPORT void SetLocation (const Handle(AIS_InteractiveObject)& theObject, const TopLoc_Location& theLocation);
302 //! Puts the Object back into its initial position.
303 Standard_EXPORT void ResetLocation (const Handle(AIS_InteractiveObject)& theObject);
305 //! Returns true if the Object has a location.
306 Standard_EXPORT Standard_Boolean HasLocation (const Handle(AIS_InteractiveObject)& theObject) const;
308 //! Returns the location of the Object.
309 Standard_EXPORT TopLoc_Location Location (const Handle(AIS_InteractiveObject)& theObject) const;
311 //! Sets transform persistence.
312 Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
313 const Handle(Graphic3d_TransformPers)& theTrsfPers);
315 Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
316 void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj,
317 const Graphic3d_TransModeFlags& theFlag,
318 const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
320 SetTransformPersistence (theObj, Graphic3d_TransformPers::FromDeprecatedParams (theFlag, thePoint));
323 public: //! @name mouse picking logic (detection and dynamic highlighting of entities under cursor)
325 //! Setup pixel tolerance for MoveTo() operation.
327 Standard_EXPORT void SetPixelTolerance (const Standard_Integer thePrecision = 2);
329 //! Returns the pixel tolerance, default is 2.
330 //! Pixel Tolerance extends sensitivity within MoveTo() operation (picking by point)
331 //! and can be adjusted by application based on user input precision (e.g. screen pixel density, input device precision, etc.).
332 Standard_EXPORT Standard_Integer PixelTolerance() const;
334 //! Allows to manage sensitivity of a particular selection of interactive object theObject
335 //! and changes previous sensitivity value of all sensitive entities in selection with theMode
336 //! to the given theNewSensitivity.
337 Standard_EXPORT void SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject,
338 const Standard_Integer theMode,
339 const Standard_Integer theNewSensitivity);
341 //! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
342 //! This is done by the view theView passing this position to the main viewer and updating it.
343 //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
344 //! @sa PickingStrategy()
345 Standard_EXPORT AIS_StatusOfDetection MoveTo (const Standard_Integer theXPix,
346 const Standard_Integer theYPix,
347 const Handle(V3d_View)& theView,
348 const Standard_Boolean theToRedrawOnUpdate);
350 //! Clears the list of entities detected by MoveTo() and resets dynamic highlighting.
351 //! @param theToRedrawImmediate if TRUE, the main Viewer will be redrawn on update
352 //! @return TRUE if viewer needs to be updated (e.g. there were actually dynamically highlighted entities)
353 Standard_EXPORT Standard_Boolean ClearDetected (Standard_Boolean theToRedrawImmediate = Standard_False);
355 //! Returns true if there is a mouse-detected entity in context.
356 //! @sa DetectedOwner()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected().
357 Standard_EXPORT Standard_Boolean HasDetected() const;
359 //! Returns the owner of the detected sensitive primitive which is currently dynamically highlighted.
360 //! WARNING! This method is irrelevant to InitDetected()/MoreDetected()/NextDetected().
361 //! @sa HasDetected()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected().
362 Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedOwner() const;
364 //! Returns the interactive objects last detected in context.
365 //! In general this is just a wrapper for Handle(AIS_InteractiveObject)::DownCast(DetectedOwner()->Selectable()).
366 //! @sa DetectedOwner()
367 Standard_EXPORT Handle(AIS_InteractiveObject) DetectedInteractive() const;
369 //! Returns true if there is a detected shape in local context.
370 //! @sa HasDetected()/DetectedShape()
371 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
372 Standard_EXPORT Standard_Boolean HasDetectedShape() const;
374 //! Returns the shape detected in local context.
375 //! @sa DetectedOwner()
376 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
377 Standard_EXPORT const TopoDS_Shape& DetectedShape() const;
379 //! returns True if other entities were detected in the last mouse detection
380 //! @sa HilightPreviousDetected()/HilightNextDetected().
381 Standard_EXPORT Standard_Boolean HasNextDetected() const;
383 //! If more than 1 object is detected by the selector, only the "best" owner is hilighted at the mouse position.
384 //! This Method allows the user to hilight one after another the other detected entities.
385 //! If The method select is called, the selected entity will be the hilighted one!
386 //! WARNING: Loop Method. When all the detected entities have been hilighted, the next call will hilight the first one again.
387 //! @return the Rank of hilighted entity
388 //! @sa HasNextDetected()/HilightPreviousDetected().
389 Standard_EXPORT Standard_Integer HilightNextDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True);
391 //! Same as previous methods in reverse direction.
392 //! @sa HasNextDetected()/HilightNextDetected().
393 Standard_EXPORT Standard_Integer HilightPreviousDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True);
395 public: //! @name iteration through detected entities
397 //! Initialization for iteration through mouse-detected objects in
398 //! interactive context or in local context if it is opened.
399 //! @sa DetectedCurrentOwner()/MoreDetected()/NextDetected().
400 Standard_EXPORT void InitDetected();
402 //! Return TRUE if there is more mouse-detected objects after the current one
403 //! during iteration through mouse-detected interactive objects.
404 //! @sa DetectedCurrentOwner()/InitDetected()/NextDetected().
405 Standard_EXPORT Standard_Boolean MoreDetected() const;
407 //! Gets next current object during iteration through mouse-detected interactive objects.
408 //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected().
409 Standard_EXPORT void NextDetected();
411 //! Returns the owner from detected list pointed by current iterator position.
412 //! WARNING! This method is irrelevant to DetectedOwner() which returns last picked Owner regardless of iterator position!
413 //! @sa InitDetected()/MoreDetected()/NextDetected().
414 Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedCurrentOwner() const;
416 public: //! @name Selection management
418 //! Sets the graphic basic aspect to the current presentation of ALL selected objects.
419 Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
420 const Standard_Boolean theToUpdateViewer);
422 //! Adds object in the selection.
423 Standard_EXPORT AIS_StatusOfPick AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
425 //! Adds object in the selection.
426 AIS_StatusOfPick AddSelect (const Handle(AIS_InteractiveObject)& theObject)
428 return AddSelect (theObject->GlobalSelOwner());
431 //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
432 //! The objects detected are passed to the main viewer, which is then updated.
433 Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
434 const Standard_Integer theYPMin,
435 const Standard_Integer theXPMax,
436 const Standard_Integer theYPMax,
437 const Handle(V3d_View)& theView,
438 const Standard_Boolean theToUpdateViewer);
440 //! polyline selection; clears the previous picked list
441 Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
442 const Handle(V3d_View)& theView,
443 const Standard_Boolean theToUpdateViewer);
445 //! Stores and hilights the previous detected; Unhilights the previous picked.
447 Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean theToUpdateViewer);
449 //! Adds the last detected to the list of previous picked.
450 //! If the last detected was already declared as picked, removes it from the Picked List.
452 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean theToUpdateViewer);
454 //! Adds the last detected to the list of previous picked.
455 //! If the last detected was already declared as picked, removes it from the Picked List.
456 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
457 const Handle(V3d_View)& theView,
458 const Standard_Boolean theToUpdateViewer);
460 //! Rectangle of selection; adds new detected entities into the picked list,
461 //! removes the detected entities that were already stored.
462 Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Integer theXPMin,
463 const Standard_Integer theYPMin,
464 const Standard_Integer theXPMax,
465 const Standard_Integer theYPMax,
466 const Handle(V3d_View)& theView,
467 const Standard_Boolean theToUpdateViewer);
469 //! Fits the view correspondingly to the bounds of selected objects.
470 //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
471 Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
472 const Standard_Real theMargin,
473 const Standard_Boolean theToUpdate);
475 //! Fits the view correspondingly to the bounds of selected objects.
476 //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
477 Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView);
479 //! Specify whether selected object must be hilighted when mouse cursor is moved above it (in MoveTo method).
480 //! By default this value is false and selected object is not hilighted in this case.
481 void SetToHilightSelected (const Standard_Boolean toHilight) { myToHilightSelected = toHilight; }
483 //! Return value specified whether selected object must be hilighted when mouse cursor is moved above it
484 Standard_Boolean ToHilightSelected() const { return myToHilightSelected; }
486 //! Unhighlights previously selected owners and marks them as not selected.
487 //! Marks owner given as selected and highlights it.
488 //! Performs selection filters check.
489 Standard_EXPORT void SetSelected (const Handle(SelectMgr_EntityOwner)& theOwners,
490 const Standard_Boolean theToUpdateViewer);
492 //! Puts the interactive object aniObj in the list of selected objects.
493 //! Performs selection filters check.
494 Standard_EXPORT void SetSelected (const Handle(AIS_InteractiveObject)& theObject,
495 const Standard_Boolean theToUpdateViewer);
497 //! Allows to highlight or unhighlight the owner given depending on its selection status
498 Standard_EXPORT void AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
499 const Standard_Boolean theToUpdateViewer);
501 //! Highlights selected objects.
502 Standard_EXPORT void HilightSelected (const Standard_Boolean theToUpdateViewer);
504 //! Removes highlighting from selected objects.
505 Standard_EXPORT void UnhilightSelected (const Standard_Boolean theToUpdateViewer);
507 //! Updates the list of selected objects:
508 //! i.e. highlights the newly selected ones and unhighlights previously selected objects.
509 //! @sa HilightSelected().
510 Standard_EXPORT void UpdateSelected (const Standard_Boolean theToUpdateViewer);
512 //! Empties previous selected objects in order to get the selected objects detected by the selector using UpdateSelected.
513 Standard_EXPORT void ClearSelected (const Standard_Boolean theToUpdateViewer);
515 //! No right to Add a selected Shape (Internal Management of shape Selection).
516 //! A Previous selected shape may only be removed.
517 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
518 Standard_EXPORT void AddOrRemoveSelected (const TopoDS_Shape& theShape,
519 const Standard_Boolean theToUpdateViewer);
521 //! Allows to highlight or unhighlight the owner given depending on its selection status
522 Standard_EXPORT void AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
523 const Standard_Boolean theToUpdateViewer);
525 //! Returns true is the owner given is selected
526 Standard_EXPORT Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const;
528 //! Returns true is the object given is selected
529 Standard_EXPORT Standard_Boolean IsSelected (const Handle(AIS_InteractiveObject)& theObj) const;
531 //! Returns the first selected object in the list of current selected.
532 Standard_EXPORT Handle(AIS_InteractiveObject) FirstSelectedObject();
534 //! Count a number of selected entities using InitSelected()+MoreSelected()+NextSelected() iterator.
535 //! @sa SelectedOwner()/InitSelected()/MoreSelected()/NextSelected().
536 Standard_EXPORT Standard_Integer NbSelected();
538 //! Initializes a scan of the selected objects.
539 //! @sa SelectedOwner()/MoreSelected()/NextSelected().
540 Standard_EXPORT void InitSelected();
542 //! Returns true if there is another object found by the scan of the list of selected objects.
543 //! @sa SelectedOwner()/InitSelected()/NextSelected().
544 Standard_EXPORT Standard_Boolean MoreSelected() const;
546 //! Continues the scan to the next object in the list of selected objects.
547 //! @sa SelectedOwner()/InitSelected()/MoreSelected().
548 Standard_EXPORT void NextSelected();
550 //! Returns the owner of the selected entity.
551 //! @sa InitSelected()/MoreSelected()/NextSelected().
552 Standard_EXPORT Handle(SelectMgr_EntityOwner) SelectedOwner() const;
554 //! Return Handle(AIS_InteractiveObject)::DownCast (SelectedOwner()->Selectable()).
555 //! @sa SelectedOwner().
556 Standard_EXPORT Handle(AIS_InteractiveObject) SelectedInteractive() const;
558 //! Returns TRUE if the interactive context has a shape selected.
559 //! @sa SelectedShape().
560 Standard_EXPORT Standard_Boolean HasSelectedShape() const;
562 //! Returns the selected shape.
563 //! Basically it is just a shape returned stored by StdSelect_BRepOwner with graphic transformation being applied:
565 //! const Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (SelectedOwner());
566 //! TopoDS_Shape aSelShape = aBRepOwner->Shape();
567 //! TopoDS_Shape aLocatedShape = aSelShape.Located (aBRepOwner->Location() * aSelShape.Location());
569 //! @sa SelectedOwner()/HasSelectedShape().
570 Standard_EXPORT TopoDS_Shape SelectedShape() const;
572 //! Returns SelectedInteractive()->HasOwner().
573 //! @sa SelectedOwner().
574 Standard_EXPORT Standard_Boolean HasApplicative() const;
576 //! Returns SelectedInteractive()->GetOwner().
577 //! @sa SelectedOwner().
578 Standard_EXPORT Handle(Standard_Transient) Applicative() const;
580 public: //! @name immediate mode rendering
582 //! initializes the list of presentations to be displayed
583 //! returns False if no local context is opened.
584 Standard_EXPORT Standard_Boolean BeginImmediateDraw();
586 //! returns True if <anIObj> has been stored in the list.
587 Standard_EXPORT Standard_Boolean ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0);
589 //! returns True if the immediate display has been done.
590 Standard_EXPORT Standard_Boolean EndImmediateDraw (const Handle(V3d_View)& theView);
592 //! Uses the First Active View of Main Viewer!
593 //! returns True if the immediate display has been done.
594 Standard_EXPORT Standard_Boolean EndImmediateDraw();
596 Standard_EXPORT Standard_Boolean IsImmediateModeOn() const;
598 //! Redraws immediate structures in all views of the viewer given taking into account its visibility.
599 Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer);
601 public: //! @name management of active Selection Modes
603 //! Activates or deactivates the selection mode for specified object.
604 //! Has no effect if selection mode was already active/deactivated.
605 //! @param theObj object to activate/deactivate selection mode
606 //! @param theMode selection mode to activate/deactivate;
607 //! deactivation of -1 selection mode will effectively deactivate all selection modes;
608 //! activation of -1 selection mode with AIS_SelectionModesConcurrency_Single
609 //! will deactivate all selection modes, and will has no effect otherwise
610 //! @param theToActivate activation/deactivation flag
611 //! @param theConcurrency specifies how to handle already activated selection modes;
612 //! default value (AIS_SelectionModesConcurrency_Multiple) means active selection modes should be left as is,
613 //! AIS_SelectionModesConcurrency_Single can be used if only one selection mode is expected to be active
614 //! and AIS_SelectionModesConcurrency_GlobalOrLocal can be used if either AIS_InteractiveObject::GlobalSelectionMode()
615 //! or any combination of Local selection modes is acceptable;
616 //! this value is considered only if theToActivate set to TRUE
617 //! @param theIsForce when set to TRUE, the display status will be ignored while activating selection mode
618 Standard_EXPORT void SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
619 const Standard_Integer theMode,
620 const Standard_Boolean theToActivate,
621 const AIS_SelectionModesConcurrency theConcurrency = AIS_SelectionModesConcurrency_Multiple,
622 const Standard_Boolean theIsForce = Standard_False);
624 //! Activates the selection mode aMode whose index is given, for the given interactive entity anIobj.
625 void Activate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0, const Standard_Boolean theIsForce = Standard_False)
627 SetSelectionModeActive (theObj, theMode, Standard_True, AIS_SelectionModesConcurrency_GlobalOrLocal, theIsForce);
630 //! Activates the given selection mode for the all displayed objects.
631 Standard_EXPORT void Activate (const Standard_Integer theMode,
632 const Standard_Boolean theIsForce = Standard_False);
634 //! Deactivates all the activated selection modes of an object.
635 void Deactivate (const Handle(AIS_InteractiveObject)& theObj)
637 SetSelectionModeActive (theObj, -1, Standard_False, AIS_SelectionModesConcurrency_Single);
640 //! Deactivates all the activated selection modes of the interactive object anIobj with a given selection mode aMode.
641 void Deactivate (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode)
643 SetSelectionModeActive (theObj, theMode, Standard_False);
646 //! Deactivates the given selection mode for all displayed objects.
647 Standard_EXPORT void Deactivate (const Standard_Integer theMode);
649 //! Deactivates all the activated selection mode at all displayed objects.
650 Standard_EXPORT void Deactivate();
652 //! Returns the list of activated selection modes.
653 Standard_EXPORT void ActivatedModes (const Handle(AIS_InteractiveObject)& anIobj, TColStd_ListOfInteger& theList) const;
655 //! Returns a collection containing all entity owners created for the interactive object in specified selection mode (in all active modes if the Mode == -1)
656 Standard_EXPORT void EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
657 const Handle(AIS_InteractiveObject)& theIObj,
658 const Standard_Integer theMode = -1) const;
660 public: //! @name Selection Filters management
662 //! Returns the list of filters active in a local context.
663 Standard_EXPORT const SelectMgr_ListOfFilter& Filters() const;
665 //! Allows you to add the filter.
666 Standard_EXPORT void AddFilter (const Handle(SelectMgr_Filter)& theFilter);
668 //! Removes a filter from context.
669 Standard_EXPORT void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter);
671 //! Remove all filters from context.
672 Standard_EXPORT void RemoveFilters();
674 //! Return picking strategy; SelectMgr_PickingStrategy_FirstAcceptable by default.
675 //! @sa MoveTo()/Filters()
676 SelectMgr_PickingStrategy PickingStrategy() const { return myPickingStrategy; }
678 //! Setup picking strategy - which entities detected by picking line will be accepted, considering Selection Filters.
679 //! By default (SelectMgr_PickingStrategy_FirstAcceptable), Selection Filters reduce the list of entities
680 //! so that the context accepts topmost in remaining.
682 //! This means that entities behind non-selectable (by filters) parts can be picked by user.
683 //! If this behavior is undesirable, and user wants that non-selectable (by filters) parts
684 //! should remain an obstacle for picking, SelectMgr_PickingStrategy_OnlyTopmost can be set instead.
686 //! Notice, that since Selection Manager operates only objects registered in it,
687 //! SelectMgr_PickingStrategy_OnlyTopmost will NOT prevent picking entities behind
688 //! visible by unregistered in Selection Manager presentations (e.g. deactivated).
689 //! Hence, SelectMgr_PickingStrategy_OnlyTopmost changes behavior only with Selection Filters enabled.
690 void SetPickingStrategy (const SelectMgr_PickingStrategy theStrategy)
692 myPickingStrategy = theStrategy;
695 public: //! @name common properties
697 //! Returns the default attribute manager.
698 //! This contains all the color and line attributes which can be used by interactive objects which do not have their own attributes.
699 const Handle(Prs3d_Drawer)& DefaultDrawer() const { return myDefaultDrawer; }
701 //! Returns the current viewer.
702 const Handle(V3d_Viewer)& CurrentViewer() const { return myMainVwr; }
704 const Handle(SelectMgr_SelectionManager)& SelectionManager() const { return mgrSelector; }
706 const Handle(PrsMgr_PresentationManager3d)& MainPrsMgr() const { return myMainPM; }
708 const Handle(StdSelect_ViewerSelector3d)& MainSelector() const { return myMainSel; }
710 //! Updates the current viewer.
711 Standard_EXPORT void UpdateCurrentViewer();
713 //! Returns the list of displayed objects of a particular Type WhichKind and Signature WhichSignature.
714 //! By Default, WhichSignature equals -1. This means that there is a check on type only.
715 Standard_EXPORT void DisplayedObjects (AIS_ListOfInteractive& aListOfIO, const Standard_Boolean OnlyFromNeutral = Standard_False) const;
717 //! gives the list of displayed objects of a particular Type and signature.
718 //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
719 Standard_EXPORT void DisplayedObjects (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, AIS_ListOfInteractive& aListOfIO, const Standard_Boolean OnlyFromNeutral = Standard_False) const;
721 //! Returns the list theListOfIO of erased objects (hidden objects) particular Type WhichKind and Signature WhichSignature.
722 //! By Default, WhichSignature equals 1. This means that there is a check on type only.
723 Standard_EXPORT void ErasedObjects (AIS_ListOfInteractive& theListOfIO) const;
725 //! gives the list of erased objects (hidden objects)
726 //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
727 Standard_EXPORT void ErasedObjects (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, AIS_ListOfInteractive& theListOfIO) const;
729 //! Returns the list theListOfIO of objects with indicated display status particular Type WhichKind and Signature WhichSignature.
730 //! By Default, WhichSignature equals 1. This means that there is a check on type only.
731 Standard_EXPORT void ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const;
733 //! gives the list of objects with indicated display status
734 //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
735 Standard_EXPORT void ObjectsByDisplayStatus (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, const AIS_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const;
737 //! fills <aListOfIO> with objects of a particular Type and Signature with no consideration of display status.
738 //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
739 //! if <WhichKind> = AIS_KOI_None and <WhichSignature> = -1, all the objects are put into the list.
740 Standard_EXPORT void ObjectsInside (AIS_ListOfInteractive& aListOfIO, const AIS_KindOfInteractive WhichKind = AIS_KOI_None, const Standard_Integer WhichSignature = -1) const;
742 //! Rebuilds 1st level of BVH selection forcibly
743 Standard_EXPORT void RebuildSelectionStructs();
745 //! Disconnects theObjToDisconnect from theAssembly and removes dependent selection structures
746 Standard_EXPORT void Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, const Handle(AIS_InteractiveObject)& theObjToDisconnect = NULL);
748 //! Query objects visible or hidden in specified view due to affinity mask.
749 Standard_EXPORT void ObjectsForView (AIS_ListOfInteractive& theListOfIO, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisibleInView, const AIS_DisplayStatus theStatus = AIS_DS_None) const;
751 //! Clears all the structures which don't belong to objects displayed at neutral point
752 //! only effective when no Local Context is opened...
753 //! returns the number of removed structures from the viewers.
754 Standard_EXPORT Standard_Integer PurgeDisplay();
756 public: //! @name debug visualization
758 //! Visualization of sensitives - for debugging purposes!
759 Standard_EXPORT void DisplayActiveSensitive (const Handle(V3d_View)& aView);
761 //! Clear visualization of sensitives.
762 Standard_EXPORT void ClearActiveSensitive (const Handle(V3d_View)& aView);
764 //! Visualization of sensitives - for debugging purposes!
765 Standard_EXPORT void DisplayActiveSensitive (const Handle(AIS_InteractiveObject)& anObject, const Handle(V3d_View)& aView);
767 public: //! @name common object display attributes
769 //! Sets the graphic attributes of the interactive object, such as visualization mode, color, and material.
770 Standard_EXPORT void SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
771 const Handle(Prs3d_Drawer)& theDrawer,
772 const Standard_Boolean theToUpdateViewer);
774 //! Removes the settings for local attributes of the Object and returns to defaults.
775 Standard_EXPORT void UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
776 const Standard_Boolean theToUpdateViewer);
778 //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE.
779 //! This mean that attributes is applying both on the front and back face.
780 Standard_EXPORT void SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& aniobj, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE);
782 //! Returns true if a view of the Interactive Object has color.
783 Standard_EXPORT Standard_Boolean HasColor (const Handle(AIS_InteractiveObject)& aniobj) const;
785 //! Returns the color of the Object in the interactive context.
786 Standard_EXPORT void Color (const Handle(AIS_InteractiveObject)& aniobj, Quantity_Color& acolor) const;
788 //! Sets the color of the selected entity.
789 Standard_EXPORT void SetColor (const Handle(AIS_InteractiveObject)& theIObj,
790 const Quantity_Color& theColor,
791 const Standard_Boolean theToUpdateViewer);
793 //! Removes the color selection for the selected entity.
794 Standard_EXPORT void UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
795 const Standard_Boolean theToUpdateViewer);
797 //! Returns the width of the Interactive Object in the interactive context.
798 Standard_EXPORT virtual Standard_Real Width (const Handle(AIS_InteractiveObject)& aniobj) const;
800 //! Sets the width of the Object.
801 Standard_EXPORT virtual void SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
802 const Standard_Real theValue,
803 const Standard_Boolean theToUpdateViewer);
805 //! Removes the width setting of the Object.
806 Standard_EXPORT virtual void UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
807 const Standard_Boolean theToUpdateViewer);
809 //! Provides the type of material setting for the view of the Object.
810 Standard_EXPORT void SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
811 const Graphic3d_MaterialAspect& theMaterial,
812 const Standard_Boolean theToUpdateViewer);
814 //! Removes the type of material setting for viewing the Object.
815 Standard_EXPORT void UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
816 const Standard_Boolean theToUpdateViewer);
818 //! Provides the transparency settings for viewing the Object.
819 //! The transparency value aValue may be between 0.0, opaque, and 1.0, fully transparent.
820 Standard_EXPORT void SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
821 const Standard_Real theValue,
822 const Standard_Boolean theToUpdateViewer);
824 //! Removes the transparency settings for viewing the Object.
825 Standard_EXPORT void UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
826 const Standard_Boolean theToUpdateViewer);
828 //! Sets up polygon offsets for the given AIS_InteractiveObject.
829 //! It simply calls AIS_InteractiveObject::SetPolygonOffsets().
830 Standard_EXPORT void SetPolygonOffsets (const Handle(AIS_InteractiveObject)& theIObj,
831 const Standard_Integer theMode,
832 const Standard_ShortReal theFactor,
833 const Standard_ShortReal theUnits,
834 const Standard_Boolean theToUpdateViewer);
836 //! Simply calls AIS_InteractiveObject::HasPolygonOffsets().
837 Standard_EXPORT Standard_Boolean HasPolygonOffsets (const Handle(AIS_InteractiveObject)& anObj) const;
839 //! Retrieves current polygon offsets settings for Object.
840 Standard_EXPORT void PolygonOffsets (const Handle(AIS_InteractiveObject)& anObj, Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
842 public: //! @name trihedron display attributes
844 //! Sets the size aSize of the trihedron.
845 //! Is used to change the default value 100 mm for display of trihedra.
846 //! Use of this function in one of your own interactive objects requires a call to the Compute function of the new class.
847 //! This will recalculate the presentation for every trihedron displayed.
848 Standard_EXPORT void SetTrihedronSize (const Standard_Real theSize,
849 const Standard_Boolean theToUpdateViewer);
851 //! returns the current value of trihedron size.
852 Standard_EXPORT Standard_Real TrihedronSize() const;
854 public: //! @name plane display attributes
856 //! Sets the plane size defined by the length in the X direction XSize and that in the Y direction YSize.
857 Standard_EXPORT void SetPlaneSize (const Standard_Real theSizeX,
858 const Standard_Real theSizeY,
859 const Standard_Boolean theToUpdateViewer);
861 //! Sets the plane size aSize.
862 Standard_EXPORT void SetPlaneSize (const Standard_Real theSize,
863 const Standard_Boolean theToUpdateViewer);
865 //! Returns true if the length in the X direction XSize is the same as that in the Y direction YSize.
866 Standard_EXPORT Standard_Boolean PlaneSize (Standard_Real& XSize, Standard_Real& YSize) const;
868 public: //! @name tessellation deviation properties for automatic triangulation
870 //! Sets the deviation coefficient theCoefficient.
871 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
872 //! A Deviation coefficient is used in the shading display mode.
873 //! The shape is seen decomposed into triangles.
874 //! These are used to calculate reflection of light from the surface of the object.
875 //! The triangles are formed from chords of the curves in the shape.
876 //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
877 //! If this limit is reached, a new triangle is begun.
878 //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
879 //! The default value is 0.001.
880 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
881 //! This deviation will be: SizeOfObject * DeviationCoefficient.
882 Standard_EXPORT void SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
883 const Standard_Real theCoefficient,
884 const Standard_Boolean theToUpdateViewer);
886 Standard_EXPORT void SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
887 const Standard_Real theAngle,
888 const Standard_Boolean theToUpdateViewer);
890 //! Calls the AIS_Shape SetAngleAndDeviation to set both Angle and Deviation coefficients
891 Standard_EXPORT void SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
892 const Standard_Real theAngle,
893 const Standard_Boolean theToUpdateViewer);
896 //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations.
897 //! The Default value is 0.02.
898 Standard_EXPORT void SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
899 const Standard_Real theCoefficient,
900 const Standard_Boolean theToUpdateViewer);
902 Standard_EXPORT void SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
903 const Standard_Real theAngle,
904 const Standard_Boolean theToUpdateViewer);
906 //! Computes a HLRAngle and a HLRDeviationCoefficient by means of the angle anAngle
907 //! and sets the corresponding methods in the default drawing tool with these values.
908 Standard_EXPORT void SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
909 const Standard_Real theAngle,
910 const Standard_Boolean theToUpdateViewer);
912 //! Sets the deviation coefficient theCoefficient.
913 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
914 //! A Deviation coefficient is used in the shading display mode.
915 //! The shape is seen decomposed into triangles.
916 //! These are used to calculate reflection of light from the surface of the object.
917 //! The triangles are formed from chords of the curves in the shape.
918 //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
919 //! If this limit is reached, a new triangle is begun.
920 //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
921 //! The default value is 0.001.
922 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
923 //! This deviation will be: SizeOfObject * DeviationCoefficient.
924 Standard_EXPORT void SetDeviationCoefficient (const Standard_Real theCoefficient);
926 //! Returns the deviation coefficient.
927 //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
928 //! A Deviation coefficient is used in the shading display mode.
929 //! The shape is seen decomposed into triangles.
930 //! These are used to calculate reflection of light from the surface of the object.
931 //! The triangles are formed from chords of the curves in the shape.
932 //! The deviation coefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve.
933 //! If this limit is reached, a new triangle is begun.
934 //! This deviation is absolute and is set through Prs3d_Drawer::SetMaximalChordialDeviation.
935 //! The default value is 0.001.
936 //! In drawing shapes, however, you are allowed to ask for a relative deviation.
937 //! This deviation will be: SizeOfObject * DeviationCoefficient.
938 Standard_EXPORT Standard_Real DeviationCoefficient() const;
940 //! default 12 degrees
941 Standard_EXPORT void SetDeviationAngle (const Standard_Real anAngle);
943 Standard_EXPORT Standard_Real DeviationAngle() const;
945 //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations.
946 //! The Default value is 0.02.
947 Standard_EXPORT void SetHLRDeviationCoefficient (const Standard_Real aCoefficient);
949 //! Returns the real number value of the hidden line removal deviation coefficient.
950 //! A Deviation coefficient is used in the shading display mode.
951 //! The shape is seen decomposed into triangles.
952 //! These are used to calculate reflection of light from the surface of the object.
953 //! The triangles are formed from chords of the curves in the shape.
954 //! The deviation coefficient give the highest value of the angle with which a chord can deviate from a tangent to a curve.
955 //! If this limit is reached, a new triangle is begun.
956 //! To find the hidden lines, hidden line display mode entails recalculation of the view at each different projector perspective.
957 //! Because hidden lines entail calculations of more than usual complexity to decompose them into these triangles,
958 //! a deviation coefficient allowing greater tolerance is used.
959 //! This increases efficiency in calculation.
960 //! The Default value is 0.02.
961 Standard_EXPORT Standard_Real HLRDeviationCoefficient() const;
963 //! Sets the HLR angle.
964 Standard_EXPORT void SetHLRAngle (const Standard_Real theAngle);
966 //! Returns the real number value of the deviation angle in hidden line removal views in this interactive context.
967 //! The default value is 20*PI/180.
968 Standard_EXPORT Standard_Real HLRAngle() const;
970 //! compute with theAngle a HLRAngle and a HLRDeviationCoefficient
971 //! and set them in myHLRAngle and in myHLRDeviationCoefficient of myDefaultDrawer;
972 //! theAngle is in radian; ( 1 deg < angle in deg < 20 deg)
973 Standard_EXPORT void SetHLRAngleAndDeviation (const Standard_Real theAngle);
975 public: //! @name HLR (Hidden Line Removal) display attributes
977 //! Initializes hidden line aspect in the default drawing tool, or Drawer.
978 //! The default values are:
979 //! Color: Quantity_NOC_YELLOW
980 //! Type of line: Aspect_TOL_DASH
982 Standard_EXPORT Handle(Prs3d_LineAspect) HiddenLineAspect() const;
984 //! Sets the hidden line aspect anAspect.
985 //! Aspect defines display attributes for hidden lines in HLR projections.
986 Standard_EXPORT void SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& anAspect) const;
988 //! returns Standard_True if the hidden lines are to be drawn.
989 //! By default the hidden lines are not drawn.
990 Standard_EXPORT Standard_Boolean DrawHiddenLine() const;
992 Standard_EXPORT void EnableDrawHiddenLine() const;
994 Standard_EXPORT void DisableDrawHiddenLine() const;
996 public: //! @name iso-line display attributes
998 //! Sets the number of U and V isoparameters displayed.
999 Standard_EXPORT void SetIsoNumber (const Standard_Integer NbIsos, const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1001 //! Returns the number of U and V isoparameters displayed.
1002 Standard_EXPORT Standard_Integer IsoNumber (const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1004 //! Returns True if drawing isoparameters on planes is enabled.
1005 Standard_EXPORT void IsoOnPlane (const Standard_Boolean SwitchOn);
1007 //! Returns True if drawing isoparameters on planes is enabled.
1008 //! if <forUIsos> = False,
1009 Standard_EXPORT Standard_Boolean IsoOnPlane() const;
1011 //! Enables or disables on-triangulation build for isolines for a particular object.
1012 //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given.
1013 Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theIsEnabled,
1014 const Handle(AIS_InteractiveObject)& theObject);
1016 //! Enables or disables on-triangulation build for isolines for default drawer.
1017 //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given.
1018 Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theToSwitchOn);
1020 //! Returns true if drawing isolines on triangulation algorithm is enabled.
1021 Standard_EXPORT Standard_Boolean IsoOnTriangulation() const;
1023 public: //! @name Local Context management (deprecated)
1025 //! Returns true if there is an open context.
1026 Standard_Boolean HasOpenedContext() const { return myCurLocalIndex != 0; }
1028 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1029 Standard_EXPORT Standard_Integer HighestIndex() const;
1031 //! For advanced usage! You should use other (non-internal) methods of class AIS_InteractiveContext without trying to obtain an instance of AIS_LocalContext.
1032 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1033 Handle(AIS_LocalContext) LocalContext() const { return myCurLocalIndex > 0 ? myLocalContexts (myCurLocalIndex) : Handle(AIS_LocalContext)(); }
1035 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1036 Standard_EXPORT Handle(StdSelect_ViewerSelector3d) LocalSelector() const;
1038 //! Opens local contexts and specifies how this is to be done.
1039 //! The options listed above function in the following manner:
1040 //! - UseDisplayedObjects - allows you to load or not load the interactive objects visualized at Neutral Point in the local context which you open.
1041 //! If false, the local context is empty after being opened. If true, the objects at Neutral Point are loaded by their default selection mode.
1042 //! - AllowShapeDecomposition - AIS_Shape allows or prevents decomposition in standard shape location mode of objects at Neutral Point which are type-"privileged".
1043 //! This Flag is only taken into account when UseDisplayedObjects is true.
1044 //! - AcceptEraseOfObjects - authorises other local contexts to erase the interactive objects present in this context. This option is rarely used.
1045 //! - BothViewers - Has no use currently defined.
1046 //! This method returns the index of the created local context.
1047 //! It should be kept and used to close the context.
1048 //! Opening a local context allows you to prepare an environment for temporary presentations and selections which will disappear once the local context is closed.
1049 //! You can open several local contexts, but only the last one will be active.
1050 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1051 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);
1053 //! Allows you to close local contexts. For greater security, you should close the context with the index Index given on opening.
1054 //! When you close a local context, the one before, which is still on the stack, reactivates.
1055 //! If none is left, you return to Neutral Point.
1056 //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode;
1057 //! the object is displayed but no viewer will be updated.
1059 //! When the index isn't specified, the current context is closed.
1060 //! This option can be dangerous, as other Interactive Functions can open local contexts without necessarily warning the user.
1061 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1062 Standard_EXPORT void CloseLocalContext (const Standard_Integer theIndex = -1,
1063 const Standard_Boolean theToUpdateViewer = Standard_True);
1065 //! returns -1 if no opened local context.
1066 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1067 Standard_EXPORT Standard_Integer IndexOfCurrentLocal() const;
1069 //! Allows you to close all local contexts at one go and return to Neutral Point.
1070 //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode;
1071 //! the object is displayed but no viewer will be updated.
1072 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1073 Standard_EXPORT void CloseAllContexts (const Standard_Boolean theToUpdateViewer);
1075 //! to be used only with no opened local context..
1076 //! displays and activates objects in their original state before local contexts were opened...
1077 Standard_EXPORT void ResetOriginalState (const Standard_Boolean theToUpdateViewer);
1079 //! clears Objects/Filters/Activated Modes list in the current opened local context.
1080 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1081 Standard_EXPORT void ClearLocalContext (const AIS_ClearMode TheMode = AIS_CM_All);
1083 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1084 Standard_EXPORT void UseDisplayedObjects();
1086 //! when a local Context is opened, one is able to use/not use the displayed objects at neutral point at anytime.
1087 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1088 Standard_EXPORT void NotUseDisplayedObjects();
1090 //! to be Used only with opened local context and
1091 //! if <anIobj> is of type shape...
1092 //! if <aStatus> = True <anIobj> will be sensitive to
1093 //! shape selection modes activation.
1094 //! = False, <anIobj> will not be sensitive any more.
1095 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1096 Standard_EXPORT void SetShapeDecomposition (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Boolean aStatus);
1099 //! Sets the temporary graphic attributes of the entity anObj.
1100 //! These are provided by the attribute manager aDrawer and are valid for a particular local context only.
1101 //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode;
1102 //! the object is displayed but no viewer will be updated.
1103 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1104 Standard_EXPORT void SetTemporaryAttributes (const Handle(AIS_InteractiveObject)& theIObj,
1105 const Handle(Prs3d_Drawer)& theDrawer,
1106 const Standard_Boolean theToUpdateViewer);
1108 //! Provides an alternative to the Display methods when activating specific selection modes.
1109 //! This has the effect of activating the corresponding selection mode aStandardActivation for all objects
1110 //! in Local Context which accept decomposition into sub-shapes.
1111 //! Every new Object which has been loaded into the interactive context and which answers these decomposition criteria
1112 //! is automatically activated according to these modes.
1114 //! If you have opened a local context by loading an object with the default options (<AllowShapeDecomposition >= Standard_True),
1115 //! all objects of the "Shape" type are also activated with the same modes.
1116 //! You can act on the state of these "Standard" objects by using SetShapeDecomposition(Status).
1117 Standard_DEPRECATED ("Local Context is deprecated - ::Activate() and AIS_Shape::SelectionMode() should be used instead")
1118 Standard_EXPORT void ActivateStandardMode (const TopAbs_ShapeEnum aStandardActivation);
1120 //! Provides an alternative to the Display methods when deactivating specific selection modes.
1121 //! This has the effect of deactivating the corresponding selection mode aStandardActivation for all objects
1122 //! in Local Context which accept decomposition into sub-shapes.
1123 Standard_DEPRECATED ("Local Context is deprecated - ::Deactivate() should be used instead")
1124 Standard_EXPORT void DeactivateStandardMode (const TopAbs_ShapeEnum aStandardActivation);
1126 //! Returns the list of activated standard selection modes available in a local context.
1127 Standard_DEPRECATED ("Local Context is deprecated - list of activated Selection Modes should be tracked on application side; see also ::ActivatedModes()")
1128 Standard_EXPORT const TColStd_ListOfInteger& ActivatedStandardModes() const;
1130 //! returns if possible, the first local context where the object is seen
1131 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1132 Standard_EXPORT Standard_Boolean IsInLocal (const Handle(AIS_InteractiveObject)& anObject, Standard_Integer& TheIndex) const;
1134 //! Sets the highlighting status aStatus of detected and selected entities.
1135 //! Whether you are in Neutral Point or local context, this is automatically managed by the Interactive Context.
1136 //! This function allows you to disconnect the automatic mode.
1137 Standard_EXPORT void SetAutomaticHilight (const Standard_Boolean aStatus);
1139 //! Returns true if the automatic highlight mode is active in an open context.
1140 Standard_EXPORT Standard_Boolean AutomaticHilight() const;
1142 //! Changes the status of a temporary object.
1143 //! It will be kept at the neutral point, i.e. put in the list of displayed objects along with its temporary attributes.
1144 //! These include display mode and selection mode, for example.
1145 //! Returns true if done.
1146 //! inWhichLocal gives the local context in which anIObj is displayed.
1147 //! By default, the index -1 refers to the last Local Context opened.
1148 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1149 Standard_EXPORT Standard_Boolean KeepTemporary (const Handle(AIS_InteractiveObject)& anIObj, const Standard_Integer InWhichLocal = -1);
1153 //! Updates the view of the current object in open context.
1154 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1155 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1156 Standard_EXPORT void SetCurrentObject (const Handle(AIS_InteractiveObject)& theIObj,
1157 const Standard_Boolean theToUpdateViewer);
1159 //! Allows to add or remove the object given to the list of current and highlight/unhighlight it correspondingly.
1160 //! Is valid for global context only; for local context use method AddOrRemoveSelected.
1161 //! Since this method makes sence only for neutral point selection of a whole object,
1162 //! if 0 selection of the object is empty this method simply does nothing.
1163 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1164 Standard_EXPORT void AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
1165 const Standard_Boolean theIsToUpdateViewer);
1167 //! Updates the list of current objects, i.e. hilights new current objects, removes hilighting from former current objects.
1168 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1169 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1170 Standard_EXPORT void UpdateCurrent();
1172 //! Returns true if there is a non-null interactive object in Neutral Point.
1173 //! Objects selected when there is no open local context are called current objects;
1174 //! those selected in open local context, selected objects.
1175 Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
1176 Standard_EXPORT Standard_Boolean IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const;
1178 //! Initializes a scan of the current selected objects in Neutral Point.
1179 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1180 Standard_DEPRECATED ("Local Context is deprecated - ::InitSelected() should be called instead")
1181 Standard_EXPORT void InitCurrent();
1183 //! Returns true if there is another object found by the scan of the list of current objects.
1184 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1185 Standard_DEPRECATED ("Local Context is deprecated - ::MoreSelected() should be called instead")
1186 Standard_EXPORT Standard_Boolean MoreCurrent() const;
1188 //! Continues the scan to the next object in the list of current objects.
1189 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1190 Standard_DEPRECATED ("Local Context is deprecated - ::NextSelected() should be called instead")
1191 Standard_EXPORT void NextCurrent();
1193 //! Returns the current interactive object.
1194 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1195 Standard_DEPRECATED ("Local Context is deprecated - ::SelectedInteractive() should be called instead")
1196 Standard_EXPORT Handle(AIS_InteractiveObject) Current() const;
1198 Standard_DEPRECATED ("Local Context is deprecated - ::NbSelected() should be called instead")
1199 Standard_EXPORT Standard_Integer NbCurrents();
1201 //! Highlights current objects.
1202 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1203 Standard_DEPRECATED ("Local Context is deprecated - ::HilightSelected() should be called instead")
1204 Standard_EXPORT void HilightCurrents (const Standard_Boolean theToUpdateViewer);
1206 //! Removes highlighting from current objects.
1207 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1208 Standard_DEPRECATED ("Local Context is deprecated - ::UnhilightSelected() should be called instead")
1209 Standard_EXPORT void UnhilightCurrents (const Standard_Boolean theToUpdateViewer);
1211 //! Empties previous current objects in order to get the current objects detected by the selector using UpdateCurrent.
1212 //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
1213 Standard_DEPRECATED ("Local Context is deprecated - ::ClearSelected() should be called instead")
1214 Standard_EXPORT void ClearCurrents (const Standard_Boolean theToUpdateViewer);
1216 //! @return current mouse-detected shape or empty (null) shape, if current interactive object
1217 //! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
1218 //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected().
1219 Standard_DEPRECATED ("Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
1220 Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const;
1222 //! @return current mouse-detected interactive object or null object, if there is no currently detected interactives
1223 //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected().
1224 Standard_DEPRECATED ("Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
1225 Standard_EXPORT Handle(AIS_InteractiveObject) DetectedCurrentObject() const;
1227 public: //! @name sub-intensity management (deprecated)
1229 //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight,
1230 //! but without actual selection (e.g., global status and owner's selection state will not be updated).
1231 //! The method returns the color of such highlighting.
1232 //! By default, it is Quantity_NOC_GRAY40.
1233 const Quantity_Color& SubIntensityColor() const
1235 return myStyles[Prs3d_TypeOfHighlight_SubIntensity]->Color();
1238 //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight,
1239 //! but without actual selection (e.g., global status and owner's selection state will not be updated).
1240 //! The method sets up the color for such highlighting.
1241 //! By default, this is Quantity_NOC_GRAY40.
1242 void SetSubIntensityColor (const Quantity_Color& theColor)
1244 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetColor (theColor);
1247 //! Highlights, and removes highlights from, the displayed object which is displayed at Neutral Point with subintensity color.
1248 //! Available only for active local context.
1249 //! There is no effect if there is no local context.
1250 //! If a local context is open, the presentation of the Interactive Object activates the selection mode.
1251 Standard_EXPORT void SubIntensityOn (const Handle(AIS_InteractiveObject)& theIObj,
1252 const Standard_Boolean theToUpdateViewer);
1254 //! Removes the subintensity option for the entity.
1255 //! If a local context is open, the presentation of the Interactive Object activates the selection mode.
1256 Standard_EXPORT void SubIntensityOff (const Handle(AIS_InteractiveObject)& theIObj,
1257 const Standard_Boolean theToUpdateViewer);
1259 //! hilights/unhilights displayed objects which are displayed at neutral state with subintensity color.
1260 //! Available only for active local context.
1261 //! No effect if no local context.
1262 Standard_EXPORT void SubIntensityOn (const Standard_Boolean theToUpdateViewer);
1264 //! Removes subintensity option for all objects.
1265 Standard_EXPORT void SubIntensityOff (const Standard_Boolean theToUpdateViewer);
1267 protected: //! @name internal methods
1269 Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
1271 Standard_EXPORT void EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
1272 const Standard_Boolean theToUpdateViewer);
1274 Standard_EXPORT void ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
1275 const Standard_Boolean theToUpdateViewer);
1277 Standard_EXPORT void ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theObj,
1278 const Standard_Integer theMode,
1279 const Standard_Boolean theToUpdateViewer);
1281 Standard_EXPORT void InitAttributes();
1283 Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
1286 Standard_EXPORT void redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1287 const Standard_Boolean theToUpdateViewer);
1290 Standard_EXPORT void redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1291 const Standard_Boolean theToUpdateViewer);
1293 //! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
1294 Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
1296 //! Helper function that highlights the owner given with <theStyle> without
1297 //! performing AutoHighlight checks, e.g. is used for dynamic highlight.
1298 Standard_EXPORT void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
1299 const Handle(V3d_Viewer)& theViewer = NULL);
1301 //! Helper function that highlights the owner given with <theStyle> with check
1302 //! for AutoHighlight, e.g. is used for selection.
1303 Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
1305 //! Helper function that highlights global owner of the object given with <theStyle> with check
1306 //! for AutoHighlight, e.g. is used for selection.
1307 //! If global owner is null, it simply highlights the whole object
1308 Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
1309 const Handle(Prs3d_Drawer)& theStyle,
1310 const Standard_Integer theDispMode) const;
1312 //! Helper function that unhighlights all owners that are stored in current AIS_Selection.
1313 //! The function updates global status and selection state of owner and interactive object.
1314 //! If the parameter <theIsToHilightSubIntensity> is set to true, interactive objects with sub-intensity
1315 //! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
1316 Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
1318 //! Helper function that unhighlights global selection owner of given interactive.
1319 //! The function does not perform any updates of global or owner status
1320 Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const;
1322 //! Helper function that turns on sub-intensity in global status and highlights
1323 //! given objects with sub-intensity color
1324 //! @param theObject [in] the object. If NULL is given, than sub-intensity will be turned on for
1325 //! all inveractive objects of the context
1326 //! @param theDispMode [in] display mode. If -1 is given, sub-intensity will be turned on for
1327 //! all display modes in global status's list of modes
1328 //! @param theIsDisplayedOnly [in] is true if sub-intensity should be applied only to objects with
1329 //! status AIS_DS_Displayed
1330 Standard_EXPORT void turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject = NULL,
1331 const Standard_Integer theDispMode = -1,
1332 const Standard_Boolean theIsDisplayedOnly = Standard_True) const;
1334 //! Helper function that highlights the object with sub-intensity color without any checks
1335 //! @param theObject [in] the object that will be highlighted
1336 //! @param theMode [in] display mode
1337 Standard_EXPORT void highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
1338 const Standard_Integer theMode) const;
1340 //! Helper function that highlights the owner with sub-intensity color without any checks
1341 //! @param theOwner [in] the owner that will be highlighted
1342 //! @param theMode [in] display mode
1343 Standard_EXPORT void highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
1344 const Standard_Integer theMode) const;
1346 //! Helper function that returns correct dynamic highlight style for the object:
1347 //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1348 //! dynamic highlight style of interactive context will be returned.
1349 //! @param theObj [in] the object to check
1350 const Handle(Prs3d_Drawer)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj,
1351 const Handle(SelectMgr_EntityOwner)& theOwner) const
1353 const Handle(Prs3d_Drawer)& aHiDrawer = theObj->DynamicHilightAttributes();
1354 if (!aHiDrawer.IsNull())
1359 return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalDynamic : Prs3d_TypeOfHighlight_Dynamic];
1362 //! Helper function that returns correct selection style for the object:
1363 //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1364 //! selection style of interactive context will be returned.
1365 //! @param theObj [in] the object to check
1366 const Handle(Prs3d_Drawer)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj,
1367 const Handle(SelectMgr_EntityOwner)& theOwner) const
1369 const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes();
1370 if (!aHiDrawer.IsNull())
1375 return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalSelected : Prs3d_TypeOfHighlight_Selected];
1378 //! Assign the context to the object or throw exception if object was already assigned to another context.
1379 void setContextToObject (const Handle(AIS_InteractiveObject)& theObj)
1381 if (theObj->HasInteractiveContext())
1383 if (theObj->myCTXPtr != this)
1385 throw Standard_ProgramError("AIS_InteractiveContext - object has been already displayed in another context!");
1390 theObj->SetContext (this);
1394 //! Return display mode for highlighting.
1395 Standard_Integer getHilightMode (const Handle(AIS_InteractiveObject)& theObj,
1396 const Handle(Prs3d_Drawer)& theStyle,
1397 const Standard_Integer theDispMode) const
1399 if (!theStyle.IsNull()
1400 && theStyle->DisplayMode() != -1
1401 && theObj->AcceptDisplayMode (theStyle->DisplayMode()))
1403 return theStyle->DisplayMode();
1405 else if (theDispMode != -1)
1409 else if (theObj->HasDisplayMode())
1411 return theObj->DisplayMode();
1413 return myDefaultDrawer->DisplayMode();
1416 //! Removes dynamic highlight draw
1417 void clearDynamicHighlight() const
1419 if (myLastinMain.IsNull())
1422 if (myLastinMain->IsAutoHilight())
1424 myMainPM->ClearImmediateDraw();
1428 myLastinMain->Selectable()->ClearDynamicHighlight (myMainPM);
1432 protected: //! @name internal fields
1434 AIS_DataMapOfIOStatus myObjects;
1435 Handle(SelectMgr_SelectionManager) mgrSelector;
1436 Handle(PrsMgr_PresentationManager3d) myMainPM;
1437 Handle(V3d_Viewer) myMainVwr;
1438 Handle(StdSelect_ViewerSelector3d) myMainSel;
1439 Handle(SelectMgr_EntityOwner) myLastPicked;
1440 Handle(SelectMgr_EntityOwner) myLastinMain;
1441 Standard_Boolean myWasLastMain;
1442 Standard_Boolean myToHilightSelected;
1443 Handle(AIS_Selection) mySelection;
1444 Handle(SelectMgr_OrFilter) myFilters;
1445 Handle(Prs3d_Drawer) myDefaultDrawer;
1446 Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB];
1447 AIS_DataMapOfILC myLocalContexts;
1448 Standard_Integer myCurLocalIndex;
1449 TColStd_SequenceOfInteger myDetectedSeq;
1450 Standard_Integer myCurDetected;
1451 Standard_Integer myCurHighlighted;
1452 SelectMgr_PickingStrategy myPickingStrategy; //!< picking strategy to be applied within MoveTo()
1453 Standard_Boolean myIsAutoActivateSelMode;
1457 DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient)
1459 #endif // _AIS_InteractiveContext_HeaderFile