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