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