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