Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/AIS_InteractiveContext.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created on: 1996-12-18
0002 // Created by: Robert COUBLANC
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _AIS_InteractiveContext_HeaderFile
0018 #define _AIS_InteractiveContext_HeaderFile
0019 
0020 #include <AIS_InteractiveObject.hxx>
0021 #include <AIS_GlobalStatus.hxx>
0022 #include <NCollection_DataMap.hxx>
0023 #include <AIS_DisplayMode.hxx>
0024 #include <AIS_DisplayStatus.hxx>
0025 #include <AIS_KindOfInteractive.hxx>
0026 #include <NCollection_List.hxx>
0027 #include <AIS_Selection.hxx>
0028 #include <AIS_SelectionModesConcurrency.hxx>
0029 #include <AIS_SelectionScheme.hxx>
0030 #include <AIS_StatusOfDetection.hxx>
0031 #include <AIS_StatusOfPick.hxx>
0032 #include <AIS_TypeOfIso.hxx>
0033 #include <Aspect_TypeOfFacingModel.hxx>
0034 #include <NCollection_Vec2.hxx>
0035 #include <Standard_TypeDef.hxx>
0036 #include <Prs3d_Drawer.hxx>
0037 #include <Prs3d_TypeOfHighlight.hxx>
0038 #include <PrsMgr_PresentationManager.hxx>
0039 #include <SelectMgr_AndOrFilter.hxx>
0040 #include <NCollection_IndexedMap.hxx>
0041 #include <NCollection_Shared.hxx>
0042 #include <SelectMgr_Filter.hxx>
0043 #include <SelectMgr_PickingStrategy.hxx>
0044 #include <SelectMgr_SelectionManager.hxx>
0045 #include <StdSelect_ViewerSelector3d.hxx>
0046 #include <TCollection_AsciiString.hxx>
0047 #include <gp_Pnt2d.hxx>
0048 #include <NCollection_Array1.hxx>
0049 #include <Standard_Integer.hxx>
0050 #include <NCollection_Sequence.hxx>
0051 #include <Quantity_Color.hxx>
0052 class SelectMgr_EntityOwner;
0053 
0054 class V3d_Viewer;
0055 class V3d_View;
0056 class TopLoc_Location;
0057 class TCollection_ExtendedString;
0058 class Prs3d_LineAspect;
0059 class Prs3d_BasicAspect;
0060 class TopoDS_Shape;
0061 class SelectMgr_Filter;
0062 
0063 //! The Interactive Context allows you to manage graphic behavior and selection of Interactive
0064 //! Objects in one or more viewers. Class methods make this highly transparent. It is essential to
0065 //! remember that an Interactive Object which is already known by the Interactive Context must be
0066 //! modified using Context methods. You can only directly call the methods available for an
0067 //! Interactive Object if it has not been loaded into an Interactive Context.
0068 //!
0069 //! Each selectable object must specify the selection mode that is
0070 //! responsible for selection of object as a whole (global selection mode).
0071 //! Interactive context itself supports decomposed object selection with selection filters support.
0072 //! By default, global selection mode is equal to 0, but it might be redefined if needed.
0073 class AIS_InteractiveContext : public Standard_Transient
0074 {
0075   DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
0076 public: //! @name object display management
0077   //! Constructs the interactive context object defined by the principal viewer MainViewer.
0078   Standard_EXPORT AIS_InteractiveContext(const occ::handle<V3d_Viewer>& MainViewer);
0079 
0080   //! Destructor.
0081   Standard_EXPORT ~AIS_InteractiveContext() override;
0082 
0083   //! Returns the display status of the entity anIobj.
0084   //! This will be one of the following:
0085   //! - AIS_DS_Displayed displayed in main viewer
0086   //! - AIS_DS_Erased    hidden in main viewer
0087   //! - AIS_DS_Temporary temporarily displayed
0088   //! - AIS_DS_None      nowhere displayed.
0089   Standard_EXPORT PrsMgr_DisplayStatus
0090     DisplayStatus(const occ::handle<AIS_InteractiveObject>& anIobj) const;
0091 
0092   //! Returns the status of the Interactive Context for the view of the Interactive Object.
0093   Standard_EXPORT void Status(const occ::handle<AIS_InteractiveObject>& anObj,
0094                               TCollection_ExtendedString&               astatus) const;
0095 
0096   //! Returns true if Object is displayed in the interactive context.
0097   Standard_EXPORT bool IsDisplayed(const occ::handle<AIS_InteractiveObject>& anIobj) const;
0098 
0099   Standard_EXPORT bool IsDisplayed(const occ::handle<AIS_InteractiveObject>& aniobj,
0100                                    const int                                 aMode) const;
0101 
0102   //! Enable or disable automatic activation of default selection mode while displaying the object.
0103   void SetAutoActivateSelection(const bool theIsAuto) { myIsAutoActivateSelMode = theIsAuto; }
0104 
0105   //! Manages displaying the new object should also automatically activate default selection mode;
0106   //! TRUE by default.
0107   bool GetAutoActivateSelection() const { return myIsAutoActivateSelMode; }
0108 
0109   //! Displays the object in this Context using default Display Mode.
0110   //! This will be the object's default display mode, if there is one. Otherwise, it will be the
0111   //! context mode. The Interactive Object's default selection mode is activated if
0112   //! GetAutoActivateSelection() is TRUE. In general, this is 0.
0113   Standard_EXPORT void Display(const occ::handle<AIS_InteractiveObject>& theIObj,
0114                                const bool                                theToUpdateViewer);
0115 
0116   //! Sets status, display mode and selection mode for specified Object
0117   //! If theSelectionMode equals -1, theIObj will not be activated: it will be displayed but will
0118   //! not be selectable.
0119   Standard_EXPORT void Display(
0120     const occ::handle<AIS_InteractiveObject>& theIObj,
0121     const int                                 theDispMode,
0122     const int                                 theSelectionMode,
0123     const bool                                theToUpdateViewer,
0124     const PrsMgr_DisplayStatus                theDispStatus = PrsMgr_DisplayStatus_None);
0125 
0126   //! Allows you to load the Interactive Object with a given selection mode,
0127   //! and/or with the desired decomposition option, whether the object is visualized or not.
0128   //! The loaded objects will be selectable but displayable in highlighting only when detected by
0129   //! the Selector.
0130   Standard_EXPORT void Load(const occ::handle<AIS_InteractiveObject>& theObj,
0131                             const int                                 theSelectionMode = -1);
0132 
0133   //! Hides the object. The object's presentations are simply flagged as invisible and therefore
0134   //! excluded from redrawing. To show hidden objects, use Display().
0135   Standard_EXPORT void Erase(const occ::handle<AIS_InteractiveObject>& theIObj,
0136                              const bool                                theToUpdateViewer);
0137 
0138   //! Hides all objects. The object's presentations are simply flagged as invisible and therefore
0139   //! excluded from redrawing. To show all hidden objects, use DisplayAll().
0140   Standard_EXPORT void EraseAll(const bool theToUpdateViewer);
0141 
0142   //! Displays all hidden objects.
0143   Standard_EXPORT void DisplayAll(const bool theToUpdateViewer);
0144 
0145   //! Hides selected objects. The object's presentations are simply flagged as invisible and
0146   //! therefore excluded from redrawing. To show hidden objects, use Display().
0147   Standard_EXPORT void EraseSelected(const bool theToUpdateViewer);
0148 
0149   //! Displays current objects.
0150   Standard_EXPORT void DisplaySelected(const bool theToUpdateViewer);
0151 
0152   //! Empties the graphic presentation of the mode indexed by aMode.
0153   //! Warning! Removes theIObj. theIObj is still active if it was previously activated.
0154   void ClearPrs(const occ::handle<AIS_InteractiveObject>& theIObj,
0155                 const int                                 theMode,
0156                 const bool                                theToUpdateViewer)
0157   {
0158     ClearGlobalPrs(theIObj, theMode, theToUpdateViewer);
0159   }
0160 
0161   //! Removes Object from every viewer.
0162   Standard_EXPORT void Remove(const occ::handle<AIS_InteractiveObject>& theIObj,
0163                               const bool                                theToUpdateViewer);
0164 
0165   //! Removes all the objects from Context.
0166   Standard_EXPORT void RemoveAll(const bool theToUpdateViewer);
0167 
0168   //! Recomputes the seen parts presentation of the Object.
0169   //! If theAllModes equals true, all presentations are present in the object even if unseen.
0170   Standard_EXPORT void Redisplay(const occ::handle<AIS_InteractiveObject>& theIObj,
0171                                  const bool                                theToUpdateViewer,
0172                                  const bool                                theAllModes = false);
0173 
0174   //! Recomputes the Prs/Selection of displayed objects of a given type and a given signature.
0175   //! if signature = -1  doesn't take signature criterion.
0176   Standard_EXPORT void Redisplay(const AIS_KindOfInteractive theTypeOfObject,
0177                                  const int                   theSignature,
0178                                  const bool                  theToUpdateViewer);
0179 
0180   //! Recomputes the displayed presentations, flags the others.
0181   //! Doesn't update presentations.
0182   Standard_EXPORT void RecomputePrsOnly(const occ::handle<AIS_InteractiveObject>& theIObj,
0183                                         const bool                                theToUpdateViewer,
0184                                         const bool theAllModes = false);
0185 
0186   //! Recomputes the active selections, flags the others.
0187   //! Doesn't update presentations.
0188   Standard_EXPORT void RecomputeSelectionOnly(const occ::handle<AIS_InteractiveObject>& anIObj);
0189 
0190   //! Updates displayed interactive object by checking and recomputing its flagged as "to be
0191   //! recomputed" presentation and selection structures. This method does not force any
0192   //! recomputation on its own. The method recomputes selections even if they are loaded without
0193   //! activation in particular selector.
0194   Standard_EXPORT void Update(const occ::handle<AIS_InteractiveObject>& theIObj,
0195                               const bool                                theUpdateViewer);
0196 
0197 public: //! @name highlighting management
0198   //! Returns default highlight style settings (could be overridden by PrsMgr_PresentableObject).
0199   //!
0200   //! Tip: although highlighting style is defined by Prs3d_Drawer,
0201   //! only a small set of properties derived from it's base class Graphic3d_PresentationAttributes
0202   //! will be actually used in most cases.
0203   //!
0204   //! Default highlight style for all types is Aspect_TOHM_COLOR. Other defaults:
0205   //!  - Prs3d_TypeOfHighlight_Dynamic
0206   //!    * Color: Quantity_NOC_CYAN1;
0207   //!    * Layer: Graphic3d_ZLayerId_Top,
0208   //!             object highlighting is drawn on top of main scene within Immediate Layers,
0209   //!             so that V3d_View::RedrawImmediate() will be enough to see update;
0210   //!  - Prs3d_TypeOfHighlight_LocalDynamic
0211   //!    * Color: Quantity_NOC_CYAN1;
0212   //!    * Layer: Graphic3d_ZLayerId_Topmost,
0213   //!             object parts highlighting is drawn on top of main scene within Immediate Layers
0214   //!             with depth cleared (even overlapped geometry will be revealed);
0215   //!  - Prs3d_TypeOfHighlight_Selected
0216   //!    * Color: Quantity_NOC_GRAY80;
0217   //!    * Layer: Graphic3d_ZLayerId_UNKNOWN,
0218   //!             object highlighting is drawn on top of main scene within the same layer
0219   //!             as object itself (e.g. Graphic3d_ZLayerId_Default by default) and increased
0220   //!             priority.
0221   //!
0222   //! @param[in] theStyleType highlight style to modify
0223   //! @return drawer associated to specified highlight type
0224   //!
0225   //! @sa MoveTo() using Prs3d_TypeOfHighlight_Dynamic and Prs3d_TypeOfHighlight_LocalDynamic types
0226   //! @sa SelectDetected() using Prs3d_TypeOfHighlight_Selected and
0227   //! Prs3d_TypeOfHighlight_LocalSelected types
0228   //! @sa PrsMgr_PresentableObject::DynamicHilightAttributes() overriding
0229   //! Prs3d_TypeOfHighlight_Dynamic and Prs3d_TypeOfHighlight_LocalDynamic defaults on object level
0230   //! @sa PrsMgr_PresentableObject::HilightAttributes() overriding Prs3d_TypeOfHighlight_Selected
0231   //! and Prs3d_TypeOfHighlight_LocalSelected defaults on object level
0232   const occ::handle<Prs3d_Drawer>& HighlightStyle(const Prs3d_TypeOfHighlight theStyleType) const
0233   {
0234     return myStyles[theStyleType];
0235   }
0236 
0237   //! Setup highlight style settings.
0238   //! Tip: it is better modifying existing style returned by method HighlightStyle()
0239   //! instead of creating a new Prs3d_Drawer to avoid unexpected results due misconfiguration.
0240   //!
0241   //! If a new highlight style is created, its presentation Zlayer should be checked,
0242   //! otherwise highlighting might not work as expected.
0243   void SetHighlightStyle(const Prs3d_TypeOfHighlight      theStyleType,
0244                          const occ::handle<Prs3d_Drawer>& theStyle)
0245   {
0246     myStyles[theStyleType] = theStyle;
0247     if (theStyleType == Prs3d_TypeOfHighlight_None)
0248     {
0249       myDefaultDrawer = theStyle;
0250     }
0251   }
0252 
0253   //! Returns current dynamic highlight style settings corresponding to
0254   //! Prs3d_TypeOfHighlight_Dynamic. This is just a short-cut to
0255   //! HighlightStyle(Prs3d_TypeOfHighlight_Dynamic).
0256   const occ::handle<Prs3d_Drawer>& HighlightStyle() const
0257   {
0258     return myStyles[Prs3d_TypeOfHighlight_Dynamic];
0259   }
0260 
0261   //! Setup the style of dynamic highlighting corresponding to Prs3d_TypeOfHighlight_Selected.
0262   //! This is just a short-cut to SetHighlightStyle(Prs3d_TypeOfHighlight_Dynamic,theStyle).
0263   void SetHighlightStyle(const occ::handle<Prs3d_Drawer>& theStyle)
0264   {
0265     myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle;
0266   }
0267 
0268   //! Returns current selection style settings corresponding to Prs3d_TypeOfHighlight_Selected.
0269   //! This is just a short-cut to HighlightStyle(Prs3d_TypeOfHighlight_Selected).
0270   const occ::handle<Prs3d_Drawer>& SelectionStyle() const
0271   {
0272     return myStyles[Prs3d_TypeOfHighlight_Selected];
0273   }
0274 
0275   //! Setup the style of selection highlighting.
0276   //! This is just a short-cut to SetHighlightStyle(Prs3d_TypeOfHighlight_Selected,theStyle).
0277   void SetSelectionStyle(const occ::handle<Prs3d_Drawer>& theStyle)
0278   {
0279     myStyles[Prs3d_TypeOfHighlight_Selected] = theStyle;
0280   }
0281 
0282   //! Returns highlight style of the object if it is marked as highlighted via global status
0283   //! @param[in] theObj  the object to check
0284   Standard_EXPORT bool HighlightStyle(const occ::handle<AIS_InteractiveObject>& theObj,
0285                                       occ::handle<Prs3d_Drawer>&                theStyle) const;
0286 
0287   //! Returns highlight style of the owner if it is selected
0288   //! @param[in] theOwner  the owner to check
0289   Standard_EXPORT bool HighlightStyle(const occ::handle<SelectMgr_EntityOwner>& theOwner,
0290                                       occ::handle<Prs3d_Drawer>&                theStyle) const;
0291 
0292   //! Returns true if the object is marked as highlighted via its global status
0293   //! @param[in] theObj  the object to check
0294   Standard_EXPORT bool IsHilighted(const occ::handle<AIS_InteractiveObject>& theObj) const;
0295 
0296   //! Returns true if the owner is marked as selected
0297   //! @param[in] theOwner  the owner to check
0298   Standard_EXPORT bool IsHilighted(const occ::handle<SelectMgr_EntityOwner>& theOwner) const;
0299 
0300   //! Changes the color of all the lines of the object in view.
0301   Standard_EXPORT void HilightWithColor(const occ::handle<AIS_InteractiveObject>& theObj,
0302                                         const occ::handle<Prs3d_Drawer>&          theStyle,
0303                                         const bool theToUpdateViewer);
0304 
0305   //! Removes highlighting from the Object.
0306   Standard_EXPORT void Unhilight(const occ::handle<AIS_InteractiveObject>& theIObj,
0307                                  const bool                                theToUpdateViewer);
0308 
0309 public: //! @name object presence management (View affinity, Layer, Priority)
0310   //! Returns the display priority of the Object.
0311   Standard_EXPORT Graphic3d_DisplayPriority
0312     DisplayPriority(const occ::handle<AIS_InteractiveObject>& theIObj) const;
0313 
0314   //! Sets the display priority of the seen parts presentation of the Object.
0315   Standard_EXPORT void SetDisplayPriority(const occ::handle<AIS_InteractiveObject>& theIObj,
0316                                           const Graphic3d_DisplayPriority           thePriority);
0317 
0318   Standard_DEPRECATED("Deprecated since OCCT7.7, Graphic3d_DisplayPriority should be passed "
0319                       "instead of integer number to SetDisplayPriority()")
0320   void SetDisplayPriority(const occ::handle<AIS_InteractiveObject>& theIObj, const int thePriority)
0321   {
0322     SetDisplayPriority(theIObj, (Graphic3d_DisplayPriority)thePriority);
0323   }
0324 
0325   //! Get Z layer id set for displayed interactive object.
0326   Standard_EXPORT Graphic3d_ZLayerId
0327     GetZLayer(const occ::handle<AIS_InteractiveObject>& theIObj) const;
0328 
0329   //! Set Z layer id for interactive object.
0330   //! The Z layers can be used to display temporarily presentations of some object in front of the
0331   //! other objects in the scene. The ids for Z layers are generated by V3d_Viewer.
0332   Standard_EXPORT void SetZLayer(const occ::handle<AIS_InteractiveObject>& theIObj,
0333                                  const Graphic3d_ZLayerId                  theLayerId);
0334 
0335   //! Setup object visibility in specified view.
0336   //! Has no effect if object is not displayed in this context.
0337   Standard_EXPORT void SetViewAffinity(const occ::handle<AIS_InteractiveObject>& theIObj,
0338                                        const occ::handle<V3d_View>&              theView,
0339                                        const bool                                theIsVisible);
0340 
0341 public: //! @name Display Mode management
0342   //! Returns the Display Mode setting to be used by default.
0343   int DisplayMode() const { return myDefaultDrawer->DisplayMode(); }
0344 
0345   //! Sets the display mode of seen Interactive Objects (which have no overridden Display Mode).
0346   Standard_EXPORT void SetDisplayMode(const int theMode, const bool theToUpdateViewer);
0347 
0348   //! Sets the display mode of seen Interactive Objects.
0349   //! theMode provides the display mode index of the entity theIObj.
0350   Standard_EXPORT void SetDisplayMode(const occ::handle<AIS_InteractiveObject>& theIObj,
0351                                       const int                                 theMode,
0352                                       const bool                                theToUpdateViewer);
0353 
0354   //! Unsets the display mode of seen Interactive Objects.
0355   Standard_EXPORT void UnsetDisplayMode(const occ::handle<AIS_InteractiveObject>& theIObj,
0356                                         const bool theToUpdateViewer);
0357 
0358 public: //! @name object local transformation management
0359   //! Puts the location on the initial graphic representation and the selection for the Object.
0360   Standard_EXPORT void SetLocation(const occ::handle<AIS_InteractiveObject>& theObject,
0361                                    const TopLoc_Location&                    theLocation);
0362 
0363   //! Puts the Object back into its initial position.
0364   Standard_EXPORT void ResetLocation(const occ::handle<AIS_InteractiveObject>& theObject);
0365 
0366   //! Returns true if the Object has a location.
0367   Standard_EXPORT bool HasLocation(const occ::handle<AIS_InteractiveObject>& theObject) const;
0368 
0369   //! Returns the location of the Object.
0370   Standard_EXPORT TopLoc_Location
0371     Location(const occ::handle<AIS_InteractiveObject>& theObject) const;
0372 
0373   //! Sets transform persistence.
0374   Standard_EXPORT void SetTransformPersistence(
0375     const occ::handle<AIS_InteractiveObject>&   theObject,
0376     const occ::handle<Graphic3d_TransformPers>& theTrsfPers);
0377 
0378 public: //! @name mouse picking logic (detection and dynamic highlighting of entities under cursor)
0379   //! Setup pixel tolerance for MoveTo() operation.
0380   //! @sa MoveTo().
0381   Standard_EXPORT void SetPixelTolerance(const int thePrecision = 2);
0382 
0383   //! Returns the pixel tolerance, default is 2.
0384   //! Pixel Tolerance extends sensitivity within MoveTo() operation (picking by point)
0385   //! and can be adjusted by application based on user input precision (e.g. screen pixel density,
0386   //! input device precision, etc.).
0387   Standard_EXPORT int PixelTolerance() const;
0388 
0389   //! Allows to manage sensitivity of a particular selection of interactive object theObject
0390   //! and changes previous sensitivity value of all sensitive entities in selection with theMode
0391   //! to the given theNewSensitivity.
0392   Standard_EXPORT void SetSelectionSensitivity(const occ::handle<AIS_InteractiveObject>& theObject,
0393                                                const int                                 theMode,
0394                                                const int theNewSensitivity);
0395 
0396   //! Returns last active View (argument of MoveTo()/Select() methods).
0397   Standard_EXPORT occ::handle<V3d_View> LastActiveView() const;
0398 
0399   //! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
0400   //! This is done by the view theView passing this position to the main viewer and updating it.
0401   //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight
0402   //! detected object.
0403   //! @sa PickingStrategy()
0404   //! @sa HighlightStyle() defining default dynamic highlight styles of detected owners
0405   //!                      (Prs3d_TypeOfHighlight_Dynamic and Prs3d_TypeOfHighlight_LocalDynamic)
0406   //! @sa PrsMgr_PresentableObject::DynamicHilightAttributes() defining per-object dynamic highlight
0407   //! style of detected owners (overrides defaults)
0408   Standard_EXPORT AIS_StatusOfDetection MoveTo(const int                    theXPix,
0409                                                const int                    theYPix,
0410                                                const occ::handle<V3d_View>& theView,
0411                                                const bool                   theToRedrawOnUpdate);
0412 
0413   //! Relays axis theAxis to the interactive context selectors.
0414   //! This is done by the view theView passing this axis to the main viewer and updating it.
0415   //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight
0416   //! detected object.
0417   //! @sa PickingStrategy()
0418   Standard_EXPORT AIS_StatusOfDetection MoveTo(const gp_Ax1&                theAxis,
0419                                                const occ::handle<V3d_View>& theView,
0420                                                const bool                   theToRedrawOnUpdate);
0421 
0422   //! Clears the list of entities detected by MoveTo() and resets dynamic highlighting.
0423   //! @param theToRedrawImmediate if TRUE, the main Viewer will be redrawn on update
0424   //! @return TRUE if viewer needs to be updated (e.g. there were actually dynamically highlighted
0425   //! entities)
0426   Standard_EXPORT bool ClearDetected(bool theToRedrawImmediate = false);
0427 
0428   //! Returns true if there is a mouse-detected entity in context.
0429   //! @sa DetectedOwner(), HasNextDetected(), HilightPreviousDetected(), HilightNextDetected().
0430   bool HasDetected() const { return !myLastPicked.IsNull(); }
0431 
0432   //! Returns the owner of the detected sensitive primitive which is currently dynamically
0433   //! highlighted. WARNING! This method is irrelevant to
0434   //! InitDetected()/MoreDetected()/NextDetected().
0435   //! @sa HasDetected(), HasNextDetected(), HilightPreviousDetected(), HilightNextDetected().
0436   const occ::handle<SelectMgr_EntityOwner>& DetectedOwner() const { return myLastPicked; }
0437 
0438   //! Returns the interactive objects last detected in context.
0439   //! In general this is just a wrapper for
0440   //! occ::down_cast<AIS_InteractiveObject>(DetectedOwner()->Selectable()).
0441   //! @sa DetectedOwner()
0442   occ::handle<AIS_InteractiveObject> DetectedInteractive() const
0443   {
0444     return occ::down_cast<AIS_InteractiveObject>(myLastPicked->Selectable());
0445   }
0446 
0447   //! Returns true if there is a detected shape in local context.
0448   //! @sa HasDetected(), DetectedShape()
0449   Standard_DEPRECATED(
0450     "Local Context is deprecated - local selection should be used without Local Context")
0451   Standard_EXPORT bool HasDetectedShape() const;
0452 
0453   //! Returns the shape detected in local context.
0454   //! @sa DetectedOwner()
0455   Standard_DEPRECATED(
0456     "Local Context is deprecated - local selection should be used without Local Context")
0457   Standard_EXPORT const TopoDS_Shape& DetectedShape() const;
0458 
0459   //! returns True if other entities were detected in the last mouse detection
0460   //! @sa HilightPreviousDetected(), HilightNextDetected().
0461   bool HasNextDetected() const
0462   {
0463     return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
0464   }
0465 
0466   //! If more than 1 object is detected by the selector, only the "best" owner is hilighted at the
0467   //! mouse position. This Method allows the user to hilight one after another the other detected
0468   //! entities. If The method select is called, the selected entity will be the hilighted one!
0469   //! WARNING: Loop Method. When all the detected entities have been hilighted, the next call will
0470   //! hilight the first one again.
0471   //! @return the Rank of hilighted entity
0472   //! @sa HasNextDetected(), HilightPreviousDetected().
0473   Standard_EXPORT int HilightNextDetected(const occ::handle<V3d_View>& theView,
0474                                           const bool                   theToRedrawImmediate = true);
0475 
0476   //! Same as previous methods in reverse direction.
0477   //! @sa HasNextDetected(), HilightNextDetected().
0478   Standard_EXPORT int HilightPreviousDetected(const occ::handle<V3d_View>& theView,
0479                                               const bool theToRedrawImmediate = true);
0480 
0481 public: //! @name iteration through detected entities
0482   //! Initialization for iteration through mouse-detected objects in
0483   //! interactive context or in local context if it is opened.
0484   //! @sa DetectedCurrentOwner(), MoreDetected(), NextDetected().
0485   void InitDetected()
0486   {
0487     if (!myDetectedSeq.IsEmpty())
0488     {
0489       myCurDetected = NCollection_Sequence<int>::Lower();
0490     }
0491   }
0492 
0493   //! Return TRUE if there is more mouse-detected objects after the current one
0494   //! during iteration through mouse-detected interactive objects.
0495   //! @sa DetectedCurrentOwner(), InitDetected(), NextDetected().
0496   bool MoreDetected() const
0497   {
0498     return myCurDetected >= NCollection_Sequence<int>::Lower()
0499            && myCurDetected <= myDetectedSeq.Upper();
0500   }
0501 
0502   //! Gets next current object during iteration through mouse-detected interactive objects.
0503   //! @sa DetectedCurrentOwner(), InitDetected(), MoreDetected().
0504   void NextDetected() { ++myCurDetected; }
0505 
0506   //! Returns the owner from detected list pointed by current iterator position.
0507   //! WARNING! This method is irrelevant to DetectedOwner() which returns last picked Owner
0508   //! regardless of iterator position!
0509   //! @sa InitDetected(), MoreDetected(), NextDetected().
0510   Standard_EXPORT occ::handle<SelectMgr_EntityOwner> DetectedCurrentOwner() const;
0511 
0512 public: //! @name Selection management
0513   //! Adds object in the selection.
0514   Standard_EXPORT AIS_StatusOfPick AddSelect(const occ::handle<SelectMgr_EntityOwner>& theObject);
0515 
0516   //! Adds object in the selection.
0517   AIS_StatusOfPick AddSelect(const occ::handle<AIS_InteractiveObject>& theObject)
0518   {
0519     return AddSelect(theObject->GlobalSelOwner());
0520   }
0521 
0522   //! Selects objects within the bounding rectangle.
0523   //! Viewer should be explicitly redrawn after selection.
0524   //! @param[in] thePntMin  rectangle lower point (in pixels)
0525   //! @param[in] thePntMax  rectangle upper point (in pixels)
0526   //! @param[in] theView    active view where rectangle is defined
0527   //! @param[in] theSelScheme  selection scheme
0528   //! @return picking status
0529   //! @sa StdSelect_ViewerSelector3d::AllowOverlapDetection()
0530   Standard_EXPORT AIS_StatusOfPick
0531     SelectRectangle(const NCollection_Vec2<int>& thePntMin,
0532                     const NCollection_Vec2<int>& thePntMax,
0533                     const occ::handle<V3d_View>& theView,
0534                     const AIS_SelectionScheme    theSelScheme = AIS_SelectionScheme_Replace);
0535 
0536   //! Select everything found in the polygon defined by bounding polyline.
0537   //! Viewer should be explicitly redrawn after selection.
0538   //! @param[in] thePolyline   polyline defining polygon bounds (in pixels)
0539   //! @param[in] theView       active view where polyline is defined
0540   //! @param[in] theSelScheme  selection scheme
0541   //! @return picking status
0542   Standard_EXPORT AIS_StatusOfPick
0543     SelectPolygon(const NCollection_Array1<gp_Pnt2d>& thePolyline,
0544                   const occ::handle<V3d_View>&        theView,
0545                   const AIS_SelectionScheme           theSelScheme = AIS_SelectionScheme_Replace);
0546 
0547   //! Selects the topmost object picked by the point in the view,
0548   //! Viewer should be explicitly redrawn after selection.
0549   //! @param[in] thePnt   point pixel coordinates within the view
0550   //! @param[in] theView  active view where point is defined
0551   //! @param[in] theSelScheme  selection scheme
0552   //! @return picking status
0553   Standard_EXPORT AIS_StatusOfPick
0554     SelectPoint(const NCollection_Vec2<int>& thePnt,
0555                 const occ::handle<V3d_View>& theView,
0556                 const AIS_SelectionScheme    theSelScheme = AIS_SelectionScheme_Replace);
0557 
0558   //! Select and hilights the previous detected via AIS_InteractiveContext::MoveTo() method;
0559   //! unhilights the previous picked.
0560   //! Viewer should be explicitly redrawn after selection.
0561   //! @param[in] theSelScheme  selection scheme
0562   //! @return picking status
0563   //!
0564   //! @sa HighlightStyle() defining default highlight styles of selected owners
0565   //! (Prs3d_TypeOfHighlight_Selected and Prs3d_TypeOfHighlight_LocalSelected)
0566   //! @sa PrsMgr_PresentableObject::HilightAttributes() defining per-object highlight style of
0567   //! selected owners (overrides defaults)
0568   //! For all selection schemes, allowing to select an object,
0569   //! HandleMouseClick is available
0570   Standard_EXPORT AIS_StatusOfPick
0571     SelectDetected(const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
0572 
0573   //! Returns bounding box of selected objects.
0574   Standard_EXPORT Bnd_Box BoundingBoxOfSelection(const occ::handle<V3d_View>& theView) const;
0575 
0576   Standard_DEPRECATED("BoundingBoxOfSelection() should be called with View argument")
0577   Bnd_Box BoundingBoxOfSelection() const { return BoundingBoxOfSelection(occ::handle<V3d_View>()); }
0578 
0579   //! Sets list of owner selected/deselected using specified selection scheme.
0580   //! @param theOwners owners to change selection state
0581   //! @param theSelScheme selection scheme
0582   //! @return picking status
0583   Standard_EXPORT AIS_StatusOfPick
0584     Select(const NCollection_Array1<occ::handle<SelectMgr_EntityOwner>>& theOwners,
0585            const AIS_SelectionScheme                                     theSelScheme);
0586 
0587   //! Fits the view correspondingly to the bounds of selected objects.
0588   //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
0589   Standard_EXPORT void FitSelected(const occ::handle<V3d_View>& theView,
0590                                    const double                 theMargin,
0591                                    const bool                   theToUpdate);
0592 
0593   //! Fits the view correspondingly to the bounds of selected objects.
0594   //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
0595   Standard_EXPORT void FitSelected(const occ::handle<V3d_View>& theView);
0596 
0597   //! Return value specified whether selected object must be hilighted when mouse cursor is moved
0598   //! above it
0599   //! @sa MoveTo()
0600   bool ToHilightSelected() const { return myToHilightSelected; }
0601 
0602   //! Specify whether selected object must be hilighted when mouse cursor is moved above it (in
0603   //! MoveTo method). By default this value is false and selected object is not hilighted in this
0604   //! case.
0605   //! @sa MoveTo()
0606   void SetToHilightSelected(const bool toHilight) { myToHilightSelected = toHilight; }
0607 
0608   //! Returns true if the automatic highlight mode is active; TRUE by default.
0609   //! @sa MoveTo(), Select(), HilightWithColor(), Unhilight()
0610   bool AutomaticHilight() const { return myAutoHilight; }
0611 
0612   //! Sets the highlighting status of detected and selected entities.
0613   //! This function allows you to disconnect the automatic mode.
0614   //!
0615   //! MoveTo() will fill the list of detected entities
0616   //! and Select() will set selected state to detected objects regardless of this flag,
0617   //! but with disabled AutomaticHiligh() their highlighting state will be left unaffected,
0618   //! so that application will be able performing custom highlighting in a different way, if needed.
0619   //!
0620   //! This API should be distinguished from SelectMgr_SelectableObject::SetAutoHilight()
0621   //! that is used to implement custom highlighting logic for a specific interactive object class.
0622   //!
0623   //! @sa MoveTo(), Select(), HilightWithColor(), Unhilight()
0624   void SetAutomaticHilight(bool theStatus) { myAutoHilight = theStatus; }
0625 
0626   //! Unhighlights previously selected owners and marks them as not selected.
0627   //! Marks owner given as selected and highlights it.
0628   //! Performs selection filters check.
0629   Standard_EXPORT void SetSelected(const occ::handle<SelectMgr_EntityOwner>& theOwners,
0630                                    const bool                                theToUpdateViewer);
0631 
0632   //! Puts the interactive object aniObj in the list of selected objects.
0633   //! Performs selection filters check.
0634   Standard_EXPORT void SetSelected(const occ::handle<AIS_InteractiveObject>& theObject,
0635                                    const bool                                theToUpdateViewer);
0636 
0637   //! Allows to highlight or unhighlight the owner given depending on its selection status
0638   Standard_EXPORT void AddOrRemoveSelected(const occ::handle<AIS_InteractiveObject>& theObject,
0639                                            const bool theToUpdateViewer);
0640 
0641   //! Updates Selected state of specified owner without calling HilightSelected().
0642   //! Has no effect if Selected state is not changed, and redirects to AddOrRemoveSelected()
0643   //! otherwise.
0644   //! @param theOwner owner object to set selected state
0645   //! @param theIsSelected new selected state
0646   //! @return TRUE if Selected state has been changed
0647   Standard_EXPORT bool SetSelectedState(const occ::handle<SelectMgr_EntityOwner>& theOwner,
0648                                         const bool                                theIsSelected);
0649 
0650   //! Highlights selected objects.
0651   Standard_EXPORT void HilightSelected(const bool theToUpdateViewer);
0652 
0653   //! Removes highlighting from selected objects.
0654   Standard_EXPORT void UnhilightSelected(const bool theToUpdateViewer);
0655 
0656   //! Updates the list of selected objects:
0657   //! i.e. highlights the newly selected ones and unhighlights previously selected objects.
0658   //! @sa HilightSelected().
0659   void UpdateSelected(bool theToUpdateViewer) { HilightSelected(theToUpdateViewer); }
0660 
0661   //! Empties previous selected objects in order to get the selected objects detected by the
0662   //! selector using UpdateSelected.
0663   Standard_EXPORT void ClearSelected(const bool theToUpdateViewer);
0664 
0665   //! Allows to highlight or unhighlight the owner given depending on its selection status
0666   Standard_EXPORT void AddOrRemoveSelected(const occ::handle<SelectMgr_EntityOwner>& theOwner,
0667                                            const bool theToUpdateViewer);
0668 
0669   //! Returns true is the owner given is selected
0670   bool IsSelected(const occ::handle<SelectMgr_EntityOwner>& theOwner) const
0671   {
0672     return !theOwner.IsNull() && theOwner->IsSelected();
0673   }
0674 
0675   //! Returns true is the object given is selected
0676   Standard_EXPORT bool IsSelected(const occ::handle<AIS_InteractiveObject>& theObj) const;
0677 
0678   //! Returns the first selected object in the list of current selected.
0679   Standard_EXPORT occ::handle<AIS_InteractiveObject> FirstSelectedObject() const;
0680 
0681   //! Count a number of selected entities using InitSelected()+MoreSelected()+NextSelected()
0682   //! iterator.
0683   //! @sa SelectedOwner(), InitSelected(), MoreSelected(), NextSelected().
0684   int NbSelected() { return mySelection->Extent(); }
0685 
0686   //! Initializes a scan of the selected objects.
0687   //! @sa SelectedOwner(), MoreSelected(), NextSelected().
0688   void InitSelected() { mySelection->Init(); }
0689 
0690   //! Returns true if there is another object found by the scan of the list of selected objects.
0691   //! @sa SelectedOwner(), InitSelected(), NextSelected().
0692   bool MoreSelected() const { return mySelection->More(); }
0693 
0694   //! Continues the scan to the next object in the list of selected objects.
0695   //! @sa SelectedOwner(), InitSelected(), MoreSelected().
0696   void NextSelected() { mySelection->Next(); }
0697 
0698   //! Returns the owner of the selected entity.
0699   //! @sa InitSelected(), MoreSelected(), NextSelected().
0700   occ::handle<SelectMgr_EntityOwner> SelectedOwner() const
0701   {
0702     return !mySelection->More() ? occ::handle<SelectMgr_EntityOwner>() : mySelection->Value();
0703   }
0704 
0705   //! Return Handle(AIS_InteractiveObject)::DownCast (SelectedOwner()->Selectable()).
0706   //! @sa SelectedOwner().
0707   occ::handle<AIS_InteractiveObject> SelectedInteractive() const
0708   {
0709     return !mySelection->More()
0710              ? occ::handle<AIS_InteractiveObject>()
0711              : occ::down_cast<AIS_InteractiveObject>(mySelection->Value()->Selectable());
0712   }
0713 
0714   //! Returns TRUE if the interactive context has a shape selected.
0715   //! @sa SelectedShape().
0716   Standard_EXPORT bool HasSelectedShape() const;
0717 
0718   //! Returns the selected shape.
0719   //! Basically it is just a shape returned stored by StdSelect_BRepOwner with graphic
0720   //! transformation being applied:
0721   //! @code
0722   //!   const occ::handle<StdSelect_BRepOwner> aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast
0723   //!   (SelectedOwner()); TopoDS_Shape aSelShape    = aBRepOwner->Shape(); TopoDS_Shape
0724   //!   aLocatedShape = aSelShape.Located (aBRepOwner->Location() * aSelShape.Location());
0725   //! @endcode
0726   //! @sa SelectedOwner(), HasSelectedShape().
0727   Standard_EXPORT TopoDS_Shape SelectedShape() const;
0728 
0729   //! Returns SelectedInteractive()->HasOwner().
0730   //! @sa SelectedOwner().
0731   bool HasApplicative() const { return SelectedInteractive()->HasOwner(); }
0732 
0733   //! Returns SelectedInteractive()->GetOwner().
0734   //! @sa SelectedOwner().
0735   occ::handle<Standard_Transient> Applicative() const { return SelectedInteractive()->GetOwner(); }
0736 
0737 public: //! @name immediate mode rendering
0738   Standard_DEPRECATED(
0739     "Deprecated method - Graphic3d_ZLayerId with IsImmediate flag should be used instead")
0740   Standard_EXPORT bool BeginImmediateDraw();
0741 
0742   Standard_DEPRECATED(
0743     "Deprecated method - Graphic3d_ZLayerId with IsImmediate flag should be used instead")
0744   Standard_EXPORT bool ImmediateAdd(const occ::handle<AIS_InteractiveObject>& theObj,
0745                                     const int                                 theMode = 0);
0746 
0747   Standard_DEPRECATED(
0748     "Deprecated method - Graphic3d_ZLayerId with IsImmediate flag should be used instead")
0749   Standard_EXPORT bool EndImmediateDraw(const occ::handle<V3d_View>& theView);
0750 
0751   Standard_DEPRECATED(
0752     "Deprecated method - Graphic3d_ZLayerId with IsImmediate flag should be used instead")
0753   Standard_EXPORT bool EndImmediateDraw();
0754 
0755   Standard_DEPRECATED(
0756     "Deprecated method - Graphic3d_ZLayerId with IsImmediate flag should be used instead")
0757   Standard_EXPORT bool IsImmediateModeOn() const;
0758 
0759   //! Redraws immediate structures in all views of the viewer given taking into account its
0760   //! visibility.
0761   void RedrawImmediate(const occ::handle<V3d_Viewer>& theViewer)
0762   {
0763     myMainPM->RedrawImmediate(theViewer);
0764   }
0765 
0766 public: //! @name management of active Selection Modes
0767   //! Activates or deactivates the selection mode for specified object.
0768   //! Has no effect if selection mode was already active/deactivated.
0769   //! @param theObj         object to activate/deactivate selection mode
0770   //! @param theMode        selection mode to activate/deactivate;
0771   //!                       deactivation of -1 selection mode will effectively deactivate all
0772   //!                       selection modes; activation of -1 selection mode with
0773   //!                       AIS_SelectionModesConcurrency_Single will deactivate all selection
0774   //!                       modes, and will has no effect otherwise
0775   //! @param theToActivate  activation/deactivation flag
0776   //! @param theConcurrency specifies how to handle already activated selection modes;
0777   //!                       default value (AIS_SelectionModesConcurrency_Multiple) means active
0778   //!                       selection modes should be left as is,
0779   //!                       AIS_SelectionModesConcurrency_Single can be used if only one selection
0780   //!                       mode is expected to be active and
0781   //!                       AIS_SelectionModesConcurrency_GlobalOrLocal can be used if either
0782   //!                       AIS_InteractiveObject::GlobalSelectionMode() or any combination of Local
0783   //!                       selection modes is acceptable; this value is considered only if
0784   //!                       theToActivate set to TRUE
0785   //! @param theIsForce     when set to TRUE, the display status will be ignored while activating
0786   //! selection mode
0787   Standard_EXPORT void SetSelectionModeActive(
0788     const occ::handle<AIS_InteractiveObject>& theObj,
0789     const int                                 theMode,
0790     const bool                                theToActivate,
0791     const AIS_SelectionModesConcurrency theConcurrency = AIS_SelectionModesConcurrency_Multiple,
0792     const bool                          theIsForce     = false);
0793 
0794   //! Activates the selection mode aMode whose index is given, for the given interactive entity
0795   //! anIobj.
0796   void Activate(const occ::handle<AIS_InteractiveObject>& theObj,
0797                 const int                                 theMode    = 0,
0798                 const bool                                theIsForce = false)
0799   {
0800     SetSelectionModeActive(theObj,
0801                            theMode,
0802                            true,
0803                            AIS_SelectionModesConcurrency_GlobalOrLocal,
0804                            theIsForce);
0805   }
0806 
0807   //! Activates the given selection mode for the all displayed objects.
0808   Standard_EXPORT void Activate(const int theMode, const bool theIsForce = false);
0809 
0810   //! Deactivates all the activated selection modes of an object.
0811   void Deactivate(const occ::handle<AIS_InteractiveObject>& theObj)
0812   {
0813     SetSelectionModeActive(theObj, -1, false, AIS_SelectionModesConcurrency_Single);
0814   }
0815 
0816   //! Deactivates all the activated selection modes of the interactive object anIobj with a given
0817   //! selection mode aMode.
0818   void Deactivate(const occ::handle<AIS_InteractiveObject>& theObj, const int theMode)
0819   {
0820     SetSelectionModeActive(theObj, theMode, false);
0821   }
0822 
0823   //! Deactivates the given selection mode for all displayed objects.
0824   Standard_EXPORT void Deactivate(const int theMode);
0825 
0826   //! Deactivates all the activated selection mode at all displayed objects.
0827   Standard_EXPORT void Deactivate();
0828 
0829   //! Returns the list of activated selection modes.
0830   Standard_EXPORT void ActivatedModes(const occ::handle<AIS_InteractiveObject>& anIobj,
0831                                       NCollection_List<int>&                    theList) const;
0832 
0833   //! Returns a collection containing all entity owners created for the interactive object in
0834   //! specified selection mode (in all active modes if the Mode == -1)
0835   Standard_EXPORT void EntityOwners(
0836     occ::handle<NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>>&
0837                                               theOwners,
0838     const occ::handle<AIS_InteractiveObject>& theIObj,
0839     const int                                 theMode = -1) const;
0840 
0841 public: //! @name Selection Filters management
0842   //! @return the context selection filter type.
0843   SelectMgr_FilterType FilterType() const { return myFilters->FilterType(); }
0844 
0845   //! Sets the context selection filter type.
0846   //! SelectMgr_TypeFilter_OR selection filter is used by default.
0847   //! @param theFilterType the filter type.
0848   void SetFilterType(const SelectMgr_FilterType theFilterType)
0849   {
0850     myFilters->SetFilterType(theFilterType);
0851   }
0852 
0853   //! Returns the list of filters active in a local context.
0854   const NCollection_List<occ::handle<SelectMgr_Filter>>& Filters() const
0855   {
0856     return myFilters->StoredFilters();
0857   }
0858 
0859   //! @return the context selection global context filter.
0860   const occ::handle<SelectMgr_AndOrFilter>& GlobalFilter() const { return myFilters; }
0861 
0862   //! Allows you to add the filter.
0863   void AddFilter(const occ::handle<SelectMgr_Filter>& theFilter) { myFilters->Add(theFilter); }
0864 
0865   //! Removes a filter from context.
0866   void RemoveFilter(const occ::handle<SelectMgr_Filter>& theFilter)
0867   {
0868     myFilters->Remove(theFilter);
0869   }
0870 
0871   //! Remove all filters from context.
0872   void RemoveFilters() { myFilters->Clear(); }
0873 
0874   //! Return picking strategy; SelectMgr_PickingStrategy_FirstAcceptable by default.
0875   //! @sa MoveTo(), Filters()
0876   SelectMgr_PickingStrategy PickingStrategy() const { return myPickingStrategy; }
0877 
0878   //! Setup picking strategy - which entities detected by picking line will be accepted, considering
0879   //! Selection Filters. By default (SelectMgr_PickingStrategy_FirstAcceptable), Selection Filters
0880   //! reduce the list of entities so that the context accepts topmost in remaining.
0881   //!
0882   //! This means that entities behind non-selectable (by filters) parts can be picked by user.
0883   //! If this behavior is undesirable, and user wants that non-selectable (by filters) parts
0884   //! should remain an obstacle for picking, SelectMgr_PickingStrategy_OnlyTopmost can be set
0885   //! instead.
0886   //!
0887   //! Notice, that since Selection Manager operates only objects registered in it,
0888   //! SelectMgr_PickingStrategy_OnlyTopmost will NOT prevent picking entities behind
0889   //! visible by unregistered in Selection Manager presentations (e.g. deactivated).
0890   //! Hence, SelectMgr_PickingStrategy_OnlyTopmost changes behavior only with Selection Filters
0891   //! enabled.
0892   void SetPickingStrategy(const SelectMgr_PickingStrategy theStrategy)
0893   {
0894     myPickingStrategy = theStrategy;
0895   }
0896 
0897 public: //! @name common properties
0898   //! Returns the default attribute manager.
0899   //! This contains all the color and line attributes which can be used by interactive objects which
0900   //! do not have their own attributes.
0901   const occ::handle<Prs3d_Drawer>& DefaultDrawer() const { return myDefaultDrawer; }
0902 
0903   //! Sets the default attribute manager; should be set at context creation time.
0904   //! Warning - this setter doesn't update links to the default drawer of already displayed objects!
0905   void SetDefaultDrawer(const occ::handle<Prs3d_Drawer>& theDrawer)
0906   {
0907     myDefaultDrawer                      = theDrawer;
0908     myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
0909   }
0910 
0911   //! Returns the current viewer.
0912   const occ::handle<V3d_Viewer>& CurrentViewer() const { return myMainVwr; }
0913 
0914   const occ::handle<SelectMgr_SelectionManager>& SelectionManager() const { return mgrSelector; }
0915 
0916   const occ::handle<PrsMgr_PresentationManager>& MainPrsMgr() const { return myMainPM; }
0917 
0918   const occ::handle<StdSelect_ViewerSelector3d>& MainSelector() const
0919   {
0920     return mgrSelector->Selector();
0921   }
0922 
0923   //! Updates the current viewer.
0924   Standard_EXPORT void UpdateCurrentViewer();
0925 
0926   //! Returns the list of displayed objects of a particular Type WhichKind and Signature
0927   //! WhichSignature. By Default, WhichSignature equals -1. This means that there is a check on type
0928   //! only.
0929   Standard_EXPORT void DisplayedObjects(
0930     NCollection_List<occ::handle<AIS_InteractiveObject>>& aListOfIO) const;
0931 
0932   //! gives the list of displayed objects of a particular Type and signature.
0933   //! by Default, <WhichSignature> = -1 means control only on <WhichKind>.
0934   Standard_EXPORT void DisplayedObjects(
0935     const AIS_KindOfInteractive                           theWhichKind,
0936     const int                                             theWhichSignature,
0937     NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const;
0938 
0939   //! Returns the list theListOfIO of erased objects (hidden objects) particular Type WhichKind and
0940   //! Signature WhichSignature. By Default, WhichSignature equals 1. This means that there is a
0941   //! check on type only.
0942   Standard_EXPORT void ErasedObjects(
0943     NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const;
0944 
0945   //! gives the list of erased objects (hidden objects)
0946   //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
0947   Standard_EXPORT void ErasedObjects(
0948     const AIS_KindOfInteractive                           theWhichKind,
0949     const int                                             theWhichSignature,
0950     NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const;
0951 
0952   //! Returns the list theListOfIO of objects with indicated display status particular Type
0953   //! WhichKind and Signature WhichSignature. By Default, WhichSignature equals 1. This means that
0954   //! there is a check on type only.
0955   Standard_EXPORT void ObjectsByDisplayStatus(
0956     const PrsMgr_DisplayStatus                            theStatus,
0957     NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const;
0958 
0959   //! gives the list of objects with indicated display status
0960   //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>.
0961   Standard_EXPORT void ObjectsByDisplayStatus(
0962     const AIS_KindOfInteractive                           WhichKind,
0963     const int                                             WhichSignature,
0964     const PrsMgr_DisplayStatus                            theStatus,
0965     NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const;
0966 
0967   //! fills <aListOfIO> with objects of a particular Type and Signature with no consideration of
0968   //! display status. by Default, <WhichSignature> = -1 means control only on <WhichKind>. if
0969   //! <WhichKind> = AIS_KindOfInteractive_None and <WhichSignature> = -1, all the objects are put
0970   //! into the list.
0971   Standard_EXPORT void ObjectsInside(
0972     NCollection_List<occ::handle<AIS_InteractiveObject>>& aListOfIO,
0973     const AIS_KindOfInteractive                           WhichKind = AIS_KindOfInteractive_None,
0974     const int                                             WhichSignature = -1) const;
0975 
0976   //! Create iterator through all objects registered in context.
0977   NCollection_DataMap<occ::handle<AIS_InteractiveObject>, occ::handle<AIS_GlobalStatus>>::Iterator
0978     ObjectIterator() const
0979   {
0980     return NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
0981                                occ::handle<AIS_GlobalStatus>>::Iterator(myObjects);
0982   }
0983 
0984   //! Rebuilds 1st level of BVH selection forcibly
0985   Standard_EXPORT void RebuildSelectionStructs();
0986 
0987   //! Disconnects theObjToDisconnect from theAssembly and removes dependent selection structures
0988   Standard_EXPORT void Disconnect(
0989     const occ::handle<AIS_InteractiveObject>& theAssembly,
0990     const occ::handle<AIS_InteractiveObject>& theObjToDisconnect = nullptr);
0991 
0992   //! Query objects visible or hidden in specified view due to affinity mask.
0993   Standard_EXPORT void ObjectsForView(
0994     NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO,
0995     const occ::handle<V3d_View>&                          theView,
0996     const bool                                            theIsVisibleInView,
0997     const PrsMgr_DisplayStatus theStatus = PrsMgr_DisplayStatus_None) const;
0998 
0999   //! Return rotation gravity point.
1000   Standard_EXPORT virtual gp_Pnt GravityPoint(const occ::handle<V3d_View>& theView) const;
1001 
1002 public: //! @name debug visualization
1003   //! Visualization of sensitives - for debugging purposes!
1004   Standard_EXPORT void DisplayActiveSensitive(const occ::handle<V3d_View>& aView);
1005 
1006   //! Clear visualization of sensitives.
1007   Standard_EXPORT void ClearActiveSensitive(const occ::handle<V3d_View>& aView);
1008 
1009   //! Visualization of sensitives - for debugging purposes!
1010   Standard_EXPORT void DisplayActiveSensitive(const occ::handle<AIS_InteractiveObject>& anObject,
1011                                               const occ::handle<V3d_View>&              aView);
1012 
1013 public: //! @name common object display attributes
1014   //! Sets the graphic attributes of the interactive object, such as visualization mode, color, and
1015   //! material.
1016   Standard_EXPORT void SetLocalAttributes(const occ::handle<AIS_InteractiveObject>& theIObj,
1017                                           const occ::handle<Prs3d_Drawer>&          theDrawer,
1018                                           const bool theToUpdateViewer);
1019 
1020   //! Removes the settings for local attributes of the Object and returns to defaults.
1021   Standard_EXPORT void UnsetLocalAttributes(const occ::handle<AIS_InteractiveObject>& theIObj,
1022                                             const bool theToUpdateViewer);
1023 
1024   //! change the current facing model apply on polygons for SetColor(), SetTransparency(),
1025   //! SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes
1026   //! is applying both on the front and back face.
1027   Standard_EXPORT void SetCurrentFacingModel(
1028     const occ::handle<AIS_InteractiveObject>& aniobj,
1029     const Aspect_TypeOfFacingModel            aModel = Aspect_TOFM_BOTH_SIDE);
1030 
1031   //! Returns true if a view of the Interactive Object has color.
1032   Standard_EXPORT bool HasColor(const occ::handle<AIS_InteractiveObject>& aniobj) const;
1033 
1034   //! Returns the color of the Object in the interactive context.
1035   Standard_EXPORT void Color(const occ::handle<AIS_InteractiveObject>& aniobj,
1036                              Quantity_Color&                           acolor) const;
1037 
1038   //! Sets the color of the selected entity.
1039   Standard_EXPORT void SetColor(const occ::handle<AIS_InteractiveObject>& theIObj,
1040                                 const Quantity_Color&                     theColor,
1041                                 const bool                                theToUpdateViewer);
1042 
1043   //! Removes the color selection for the selected entity.
1044   Standard_EXPORT void UnsetColor(const occ::handle<AIS_InteractiveObject>& theIObj,
1045                                   const bool                                theToUpdateViewer);
1046 
1047   //! Returns the width of the Interactive Object in the interactive context.
1048   Standard_EXPORT virtual double Width(const occ::handle<AIS_InteractiveObject>& aniobj) const;
1049 
1050   //! Sets the width of the Object.
1051   Standard_EXPORT virtual void SetWidth(const occ::handle<AIS_InteractiveObject>& theIObj,
1052                                         const double                              theValue,
1053                                         const bool theToUpdateViewer);
1054 
1055   //! Removes the width setting of the Object.
1056   Standard_EXPORT virtual void UnsetWidth(const occ::handle<AIS_InteractiveObject>& theIObj,
1057                                           const bool theToUpdateViewer);
1058 
1059   //! Provides the type of material setting for the view of the Object.
1060   Standard_EXPORT void SetMaterial(const occ::handle<AIS_InteractiveObject>& theIObj,
1061                                    const Graphic3d_MaterialAspect&           theMaterial,
1062                                    const bool                                theToUpdateViewer);
1063 
1064   //! Removes the type of material setting for viewing the Object.
1065   Standard_EXPORT void UnsetMaterial(const occ::handle<AIS_InteractiveObject>& theIObj,
1066                                      const bool                                theToUpdateViewer);
1067 
1068   //! Provides the transparency settings for viewing the Object.
1069   //! The transparency value aValue may be between 0.0, opaque, and 1.0, fully transparent.
1070   Standard_EXPORT void SetTransparency(const occ::handle<AIS_InteractiveObject>& theIObj,
1071                                        const double                              theValue,
1072                                        const bool                                theToUpdateViewer);
1073 
1074   //! Removes the transparency settings for viewing the Object.
1075   Standard_EXPORT void UnsetTransparency(const occ::handle<AIS_InteractiveObject>& theIObj,
1076                                          const bool theToUpdateViewer);
1077 
1078   //! Sets up polygon offsets for the given AIS_InteractiveObject.
1079   //! It simply calls AIS_InteractiveObject::SetPolygonOffsets().
1080   Standard_EXPORT void SetPolygonOffsets(const occ::handle<AIS_InteractiveObject>& theIObj,
1081                                          const int                                 theMode,
1082                                          const float                               theFactor,
1083                                          const float                               theUnits,
1084                                          const bool theToUpdateViewer);
1085 
1086   //! Simply calls AIS_InteractiveObject::HasPolygonOffsets().
1087   Standard_EXPORT bool HasPolygonOffsets(const occ::handle<AIS_InteractiveObject>& anObj) const;
1088 
1089   //! Retrieves current polygon offsets settings for Object.
1090   Standard_EXPORT void PolygonOffsets(const occ::handle<AIS_InteractiveObject>& anObj,
1091                                       int&                                      aMode,
1092                                       float&                                    aFactor,
1093                                       float&                                    aUnits) const;
1094 
1095 public: //! @name trihedron display attributes
1096   //! Sets the size aSize of the trihedron.
1097   //! Is used to change the default value 100 mm for display of trihedra.
1098   //! Use of this function in one of your own interactive objects requires a call to the Compute
1099   //! function of the new class. This will recalculate the presentation for every trihedron
1100   //! displayed.
1101   Standard_EXPORT void SetTrihedronSize(const double theSize, const bool theToUpdateViewer);
1102 
1103   //! returns the current value of trihedron size.
1104   Standard_EXPORT double TrihedronSize() const;
1105 
1106 public: //! @name plane display attributes
1107   //! Sets the plane size defined by the length in the X direction XSize and that in the Y direction
1108   //! YSize.
1109   Standard_EXPORT void SetPlaneSize(const double theSizeX,
1110                                     const double theSizeY,
1111                                     const bool   theToUpdateViewer);
1112 
1113   //! Sets the plane size aSize.
1114   Standard_EXPORT void SetPlaneSize(const double theSize, const bool theToUpdateViewer);
1115 
1116   //! Returns true if the length in the X direction XSize is the same as that in the Y direction
1117   //! YSize.
1118   Standard_EXPORT bool PlaneSize(double& XSize, double& YSize) const;
1119 
1120 public: //! @name tessellation deviation properties for automatic triangulation
1121   //! Sets the deviation coefficient theCoefficient.
1122   //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
1123   //! A Deviation coefficient is used in the shading display mode.
1124   //! The shape is seen decomposed into triangles.
1125   //! These are used to calculate reflection of light from the surface of the object.
1126   //! The triangles are formed from chords of the curves in the shape.
1127   //! The deviation coefficient theCoefficient gives the highest value of the angle with which a
1128   //! chord can deviate from a tangent to a curve. If this limit is reached, a new triangle is
1129   //! begun. This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
1130   //! The default value is 0.001.
1131   //! In drawing shapes, however, you are allowed to ask for a relative deviation.
1132   //! This deviation will be: SizeOfObject * DeviationCoefficient.
1133   Standard_EXPORT void SetDeviationCoefficient(const occ::handle<AIS_InteractiveObject>& theIObj,
1134                                                const double theCoefficient,
1135                                                const bool   theToUpdateViewer);
1136 
1137   Standard_EXPORT void SetDeviationAngle(const occ::handle<AIS_InteractiveObject>& theIObj,
1138                                          const double                              theAngle,
1139                                          const bool theToUpdateViewer);
1140 
1141   //! Calls the AIS_Shape SetAngleAndDeviation to set both Angle and Deviation coefficients
1142   Standard_EXPORT void SetAngleAndDeviation(const occ::handle<AIS_InteractiveObject>& theIObj,
1143                                             const double                              theAngle,
1144                                             const bool theToUpdateViewer);
1145 
1146   //! Sets the deviation coefficient theCoefficient.
1147   //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
1148   //! A Deviation coefficient is used in the shading display mode.
1149   //! The shape is seen decomposed into triangles.
1150   //! These are used to calculate reflection of light from the surface of the object.
1151   //! The triangles are formed from chords of the curves in the shape.
1152   //! The deviation coefficient theCoefficient gives the highest value of the angle with which a
1153   //! chord can deviate from a tangent to a curve. If this limit is reached, a new triangle is
1154   //! begun. This deviation is absolute and is set through the method: SetMaximalChordialDeviation.
1155   //! The default value is 0.001.
1156   //! In drawing shapes, however, you are allowed to ask for a relative deviation.
1157   //! This deviation will be: SizeOfObject * DeviationCoefficient.
1158   void SetDeviationCoefficient(const double theCoefficient)
1159   {
1160     myDefaultDrawer->SetDeviationCoefficient(theCoefficient);
1161   }
1162 
1163   //! Returns the deviation coefficient.
1164   //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
1165   //! A Deviation coefficient is used in the shading display mode.
1166   //! The shape is seen decomposed into triangles.
1167   //! These are used to calculate reflection of light from the surface of the object.
1168   //! The triangles are formed from chords of the curves in the shape.
1169   //! The deviation coefficient gives the highest value of the angle with which a chord can deviate
1170   //! from a tangent to a curve. If this limit is reached, a new triangle is begun. This deviation
1171   //! is absolute and is set through Prs3d_Drawer::SetMaximalChordialDeviation. The default value is
1172   //! 0.001. In drawing shapes, however, you are allowed to ask for a relative deviation. This
1173   //! deviation will be: SizeOfObject * DeviationCoefficient.
1174   double DeviationCoefficient() const { return myDefaultDrawer->DeviationCoefficient(); }
1175 
1176   //! default 20 degrees
1177   void SetDeviationAngle(const double theAngle) { myDefaultDrawer->SetDeviationAngle(theAngle); }
1178 
1179   double DeviationAngle() const { return myDefaultDrawer->DeviationAngle(); }
1180 
1181 public: //! @name HLR (Hidden Line Removal) display attributes
1182   //! Initializes hidden line aspect in the default drawing tool, or Drawer.
1183   //! The default values are:
1184   //! Color: Quantity_NOC_YELLOW
1185   //! Type of line: Aspect_TOL_DASH
1186   //! Width: 1.
1187   const occ::handle<Prs3d_LineAspect>& HiddenLineAspect() const
1188   {
1189     return myDefaultDrawer->HiddenLineAspect();
1190   }
1191 
1192   //! Sets the hidden line aspect anAspect.
1193   //! Aspect defines display attributes for hidden lines in HLR projections.
1194   void SetHiddenLineAspect(const occ::handle<Prs3d_LineAspect>& theAspect) const
1195   {
1196     myDefaultDrawer->SetHiddenLineAspect(theAspect);
1197   }
1198 
1199   //! returns true if the hidden lines are to be drawn.
1200   //! By default the hidden lines are not drawn.
1201   bool DrawHiddenLine() const { return myDefaultDrawer->DrawHiddenLine(); }
1202 
1203   void EnableDrawHiddenLine() const { myDefaultDrawer->EnableDrawHiddenLine(); }
1204 
1205   void DisableDrawHiddenLine() const { myDefaultDrawer->DisableDrawHiddenLine(); }
1206 
1207 public: //! @name iso-line display attributes
1208   //! Sets the number of U and V isoparameters displayed.
1209   Standard_EXPORT void SetIsoNumber(const int NbIsos, const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1210 
1211   //! Returns the number of U and V isoparameters displayed.
1212   Standard_EXPORT int IsoNumber(const AIS_TypeOfIso WhichIsos = AIS_TOI_Both);
1213 
1214   //! Returns True if drawing isoparameters on planes is enabled.
1215   void IsoOnPlane(const bool theToSwitchOn) { myDefaultDrawer->SetIsoOnPlane(theToSwitchOn); }
1216 
1217   //! Returns True if drawing isoparameters on planes is enabled.
1218   //! if <forUIsos> = False,
1219   bool IsoOnPlane() const { return myDefaultDrawer->IsoOnPlane(); }
1220 
1221   //! Enables or disables on-triangulation build for isolines for a particular object.
1222   //! In case if on-triangulation builder is disabled, default on-plane builder will compute
1223   //! isolines for the object given.
1224   Standard_EXPORT void IsoOnTriangulation(const bool                                theIsEnabled,
1225                                           const occ::handle<AIS_InteractiveObject>& theObject);
1226 
1227   //! Enables or disables on-triangulation build for isolines for default drawer.
1228   //! In case if on-triangulation builder is disabled, default on-plane builder will compute
1229   //! isolines for the object given.
1230   void IsoOnTriangulation(const bool theToSwitchOn)
1231   {
1232     myDefaultDrawer->SetIsoOnTriangulation(theToSwitchOn);
1233   }
1234 
1235   //! Returns true if drawing isolines on triangulation algorithm is enabled.
1236   bool IsoOnTriangulation() const { return myDefaultDrawer->IsoOnTriangulation(); }
1237 
1238   //! @name obsolete methods
1239 public:
1240   Standard_DEPRECATED("Deprecated method Display() with obsolete argument "
1241                       "theToAllowDecomposition")
1242   void Display(const occ::handle<AIS_InteractiveObject>& theIObj,
1243                const int                                 theDispMode,
1244                const int                                 theSelectionMode,
1245                const bool                                theToUpdateViewer,
1246                const bool                                theToAllowDecomposition,
1247                const PrsMgr_DisplayStatus                theDispStatus = PrsMgr_DisplayStatus_None)
1248   {
1249     (void)theToAllowDecomposition;
1250     Display(theIObj, theDispMode, theSelectionMode, theToUpdateViewer, theDispStatus);
1251   }
1252 
1253   Standard_DEPRECATED("Deprecated method Load() with obsolete last argument "
1254                       "theToAllowDecomposition")
1255   void Load(const occ::handle<AIS_InteractiveObject>& theObj, int theSelectionMode, bool)
1256   {
1257     Load(theObj, theSelectionMode);
1258   }
1259 
1260   //! Updates the display in the viewer to take dynamic detection into account.
1261   //! On dynamic detection by the mouse cursor, sensitive primitives are highlighted.
1262   //! The highlight color of entities detected by mouse movement is white by default.
1263   Standard_DEPRECATED("Deprecated method Hilight()")
1264   void Hilight(const occ::handle<AIS_InteractiveObject>& theObj, const bool theIsToUpdateViewer)
1265   {
1266     return HilightWithColor(theObj, myStyles[Prs3d_TypeOfHighlight_Dynamic], theIsToUpdateViewer);
1267   }
1268 
1269   //! Sets the graphic basic aspect to the current presentation of ALL selected objects.
1270   Standard_DEPRECATED(
1271     "Deprecated method - presentation attributes should be assigned directly to object")
1272   Standard_EXPORT void SetSelectedAspect(const occ::handle<Prs3d_BasicAspect>& theAspect,
1273                                          const bool                            theToUpdateViewer);
1274 
1275   //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima,
1276   //! XPMin, YPMin, XPMax, and YPMax in the view. The objects detected are passed to the main
1277   //! viewer, which is then updated.
1278   Standard_DEPRECATED("This method is deprecated - SelectRectangle() taking "
1279                       "AIS_SelectionScheme_Replace should be called instead")
1280   Standard_EXPORT AIS_StatusOfPick Select(const int                    theXPMin,
1281                                           const int                    theYPMin,
1282                                           const int                    theXPMax,
1283                                           const int                    theYPMax,
1284                                           const occ::handle<V3d_View>& theView,
1285                                           const bool                   theToUpdateViewer);
1286 
1287   //! polyline selection; clears the previous picked list
1288   Standard_DEPRECATED("This method is deprecated - SelectPolygon() taking "
1289                       "AIS_SelectionScheme_Replace should be called instead")
1290   Standard_EXPORT AIS_StatusOfPick Select(const NCollection_Array1<gp_Pnt2d>& thePolyline,
1291                                           const occ::handle<V3d_View>&        theView,
1292                                           const bool                          theToUpdateViewer);
1293 
1294   //! Stores and hilights the previous detected; Unhilights the previous picked.
1295   //! @sa MoveTo().
1296   Standard_DEPRECATED("This method is deprecated - SelectDetected() taking "
1297                       "AIS_SelectionScheme_Replace should be called instead")
1298   Standard_EXPORT AIS_StatusOfPick Select(const bool theToUpdateViewer);
1299 
1300   //! Adds the last detected to the list of previous picked.
1301   //! If the last detected was already declared as picked, removes it from the Picked List.
1302   //! @sa MoveTo().
1303   Standard_DEPRECATED("This method is deprecated - SelectDetected() taking AIS_SelectionScheme_XOR "
1304                       "should be called instead")
1305   Standard_EXPORT AIS_StatusOfPick ShiftSelect(const bool theToUpdateViewer);
1306 
1307   //! Adds the last detected to the list of previous picked.
1308   //! If the last detected was already declared as picked, removes it from the Picked List.
1309   Standard_DEPRECATED("This method is deprecated - SelectPolygon() taking AIS_SelectionScheme_XOR "
1310                       "should be called instead")
1311   Standard_EXPORT AIS_StatusOfPick ShiftSelect(const NCollection_Array1<gp_Pnt2d>& thePolyline,
1312                                                const occ::handle<V3d_View>&        theView,
1313                                                const bool theToUpdateViewer);
1314 
1315   //! Rectangle of selection; adds new detected entities into the picked list,
1316   //! removes the detected entities that were already stored.
1317   Standard_DEPRECATED("This method is deprecated - SelectRectangle() taking "
1318                       "AIS_SelectionScheme_XOR should be called instead")
1319   Standard_EXPORT AIS_StatusOfPick ShiftSelect(const int                    theXPMin,
1320                                                const int                    theYPMin,
1321                                                const int                    theXPMax,
1322                                                const int                    theYPMax,
1323                                                const occ::handle<V3d_View>& theView,
1324                                                const bool                   theToUpdateViewer);
1325 
1326 public:
1327   //! Updates the view of the current object in open context.
1328   //! Objects selected when there is no open local context are called current objects; those
1329   //! selected in open local context, selected objects.
1330   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1331                       "Context")
1332   void SetCurrentObject(const occ::handle<AIS_InteractiveObject>& theIObj,
1333                         const bool                                theToUpdateViewer)
1334   {
1335     SetSelected(theIObj, theToUpdateViewer);
1336   }
1337 
1338   //! Allows to add or remove the object given to the list of current and highlight/unhighlight it
1339   //! correspondingly. Is valid for global context only; for local context use method
1340   //! AddOrRemoveSelected. Since this method makes sense only for neutral point selection of a whole
1341   //! object, if 0 selection of the object is empty this method simply does nothing.
1342   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1343                       "Context")
1344   void AddOrRemoveCurrentObject(const occ::handle<AIS_InteractiveObject>& theObj,
1345                                 const bool                                theIsToUpdateViewer)
1346   {
1347     AddOrRemoveSelected(theObj, theIsToUpdateViewer);
1348   }
1349 
1350   //! Updates the list of current objects, i.e. hilights new current objects, removes hilighting
1351   //! from former current objects. Objects selected when there is no open local context are called
1352   //! current objects; those selected in open local context, selected objects.
1353   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1354                       "Context")
1355   void UpdateCurrent() { UpdateSelected(true); }
1356 
1357   //! Returns true if there is a non-null interactive object in Neutral Point.
1358   //! Objects selected when there is no open local context are called current objects;
1359   //! those selected in open local context, selected objects.
1360   Standard_DEPRECATED(
1361     "Local Context is deprecated - local selection should be used without Local Context")
1362   bool IsCurrent(const occ::handle<AIS_InteractiveObject>& theObject) const
1363   {
1364     return IsSelected(theObject);
1365   }
1366 
1367   //! Initializes a scan of the current selected objects in Neutral Point.
1368   //! Objects selected when there is no open local context are called current objects; those
1369   //! selected in open local context, selected objects.
1370   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1371                       "Context")
1372   void InitCurrent() { InitSelected(); }
1373 
1374   //! Returns true if there is another object found by the scan of the list of current objects.
1375   //! Objects selected when there is no open local context are called current objects; those
1376   //! selected in open local context, selected objects.
1377   Standard_DEPRECATED(
1378     "Local Context is deprecated - local selection should be used without Local Context")
1379   bool MoreCurrent() const { return MoreSelected(); }
1380 
1381   //! Continues the scan to the next object in the list of current objects.
1382   //! Objects selected when there is no open local context are called current objects; those
1383   //! selected in open local context, selected objects.
1384   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1385                       "Context")
1386   void NextCurrent() { NextSelected(); }
1387 
1388   //! Returns the current interactive object.
1389   //! Objects selected when there is no open local context are called current objects; those
1390   //! selected in open local context, selected objects.
1391   Standard_DEPRECATED(
1392     "Local Context is deprecated - local selection should be used without Local Context")
1393   occ::handle<AIS_InteractiveObject> Current() const { return SelectedInteractive(); }
1394 
1395   Standard_DEPRECATED(
1396     "Local Context is deprecated - local selection should be used without Local Context")
1397   int NbCurrents() { return NbSelected(); }
1398 
1399   //! Highlights current objects.
1400   //! Objects selected when there is no open local context are called current objects; those
1401   //! selected in open local context, selected objects.
1402   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1403                       "Context")
1404   void HilightCurrents(const bool theToUpdateViewer) { HilightSelected(theToUpdateViewer); }
1405 
1406   //! Removes highlighting from current objects.
1407   //! Objects selected when there is no open local context are called current objects; those
1408   //! selected in open local context, selected objects.
1409   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1410                       "Context")
1411   void UnhilightCurrents(const bool theToUpdateViewer) { UnhilightSelected(theToUpdateViewer); }
1412 
1413   //! Empties previous current objects in order to get the current objects detected by the selector
1414   //! using UpdateCurrent. Objects selected when there is no open local context are called current
1415   //! objects; those selected in open local context, selected objects.
1416   Standard_DEPRECATED("Local Context is deprecated - local selection should be used without Local "
1417                       "Context")
1418   void ClearCurrents(const bool theToUpdateViewer) { ClearSelected(theToUpdateViewer); }
1419 
1420   //! @return current mouse-detected shape or empty (null) shape, if current interactive object
1421   //! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
1422   //! @sa DetectedCurrentOwner(), InitDetected(), MoreDetected(), NextDetected().
1423   Standard_DEPRECATED(
1424     "Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
1425   Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const;
1426 
1427   //! @return current mouse-detected interactive object or null object, if there is no currently
1428   //! detected interactives
1429   //! @sa DetectedCurrentOwner(), InitDetected(), MoreDetected(), NextDetected().
1430   Standard_DEPRECATED(
1431     "Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
1432   Standard_EXPORT occ::handle<AIS_InteractiveObject> DetectedCurrentObject() const;
1433 
1434 public: //! @name sub-intensity management (deprecated)
1435   //! Sub-intensity allows temporary highlighting of particular objects with specified color in a
1436   //! manner of selection highlight, but without actual selection (e.g., global status and owner's
1437   //! selection state will not be updated). The method returns the color of such highlighting. By
1438   //! default, it is Quantity_NOC_GRAY40.
1439   const Quantity_Color& SubIntensityColor() const
1440   {
1441     return myStyles[Prs3d_TypeOfHighlight_SubIntensity]->Color();
1442   }
1443 
1444   //! Sub-intensity allows temporary highlighting of particular objects with specified color in a
1445   //! manner of selection highlight, but without actual selection (e.g., global status and owner's
1446   //! selection state will not be updated). The method sets up the color for such highlighting. By
1447   //! default, this is Quantity_NOC_GRAY40.
1448   void SetSubIntensityColor(const Quantity_Color& theColor)
1449   {
1450     myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetColor(theColor);
1451   }
1452 
1453   //! Highlights, and removes highlights from, the displayed object which is displayed at Neutral
1454   //! Point with subintensity color. Available only for active local context. There is no effect if
1455   //! there is no local context. If a local context is open, the presentation of the Interactive
1456   //! Object activates the selection mode.
1457   Standard_EXPORT void SubIntensityOn(const occ::handle<AIS_InteractiveObject>& theIObj,
1458                                       const bool                                theToUpdateViewer);
1459 
1460   //! Removes the subintensity option for the entity.
1461   //! If a local context is open, the presentation of the Interactive Object activates the selection
1462   //! mode.
1463   Standard_EXPORT void SubIntensityOff(const occ::handle<AIS_InteractiveObject>& theIObj,
1464                                        const bool                                theToUpdateViewer);
1465 
1466   //! Returns selection instance
1467   const occ::handle<AIS_Selection>& Selection() const { return mySelection; }
1468 
1469   //! Sets selection instance to manipulate a container of selected owners
1470   //! @param theSelection an instance of the selection
1471   void SetSelection(const occ::handle<AIS_Selection>& theSelection) { mySelection = theSelection; }
1472 
1473   //! Dumps the content of me into the stream
1474   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
1475 
1476 protected: //! @name internal methods
1477   Standard_EXPORT void GetDefModes(const occ::handle<AIS_InteractiveObject>& anIobj,
1478                                    int&                                      Dmode,
1479                                    int&                                      HiMod,
1480                                    int&                                      SelMode) const;
1481 
1482   Standard_EXPORT void EraseGlobal(const occ::handle<AIS_InteractiveObject>& theIObj,
1483                                    const bool                                theToUpdateViewer);
1484 
1485   Standard_EXPORT void ClearGlobal(const occ::handle<AIS_InteractiveObject>& theIObj,
1486                                    const bool                                theToUpdateViewer);
1487 
1488   Standard_EXPORT void ClearGlobalPrs(const occ::handle<AIS_InteractiveObject>& theObj,
1489                                       const int                                 theMode,
1490                                       const bool                                theToUpdateViewer);
1491 
1492   Standard_EXPORT void InitAttributes();
1493 
1494   //! Highlights detected objects.
1495   //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to update view.
1496   Standard_EXPORT AIS_StatusOfDetection moveTo(const occ::handle<V3d_View>& theView,
1497                                                const bool                   theToRedrawOnUpdate);
1498 
1499   //! Returns True if the object is detected.
1500   Standard_EXPORT bool isDetected(const occ::handle<AIS_InteractiveObject>& theObject);
1501 
1502   //! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
1503   Standard_EXPORT void unselectOwners(const occ::handle<AIS_InteractiveObject>& theObject);
1504 
1505   //! Helper function that highlights the owner given with <theStyle> without
1506   //! performing AutoHighlight checks, e.g. is used for dynamic highlight.
1507   Standard_EXPORT void highlightWithColor(const occ::handle<SelectMgr_EntityOwner>& theOwner,
1508                                           const occ::handle<V3d_Viewer>& theViewer = nullptr);
1509 
1510   //! Helper function that highlights the owner given with <theStyle> with check
1511   //! for AutoHighlight, e.g. is used for selection.
1512   Standard_EXPORT void highlightSelected(const occ::handle<SelectMgr_EntityOwner>& theOwner);
1513 
1514   //! Helper function that highlights the owners with check for AutoHighlight, e.g. is used for
1515   //! selection.
1516   //! @param[in] theOwners  list of owners to highlight
1517   //! @param[in] theStyle   highlight style to apply or NULL to apply selection style
1518   Standard_EXPORT void highlightOwners(
1519     const NCollection_List<occ::handle<SelectMgr_EntityOwner>>& theOwners,
1520     const occ::handle<Prs3d_Drawer>&                            theStyle);
1521 
1522   //! Helper function that highlights global owner of the object given with <theStyle> with check
1523   //! for AutoHighlight, e.g. is used for selection.
1524   //! If global owner is null, it simply highlights the whole object
1525   Standard_EXPORT void highlightGlobal(const occ::handle<AIS_InteractiveObject>& theObj,
1526                                        const occ::handle<Prs3d_Drawer>&          theStyle,
1527                                        const int                                 theDispMode);
1528 
1529   //! Helper function that unhighlights all owners that are stored in current AIS_Selection.
1530   //! The function updates global status and selection state of owner and interactive object.
1531   //! If the parameter <theIsToHilightSubIntensity> is set to true, interactive objects with
1532   //! sub-intensity switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity
1533   //! color.
1534   Standard_EXPORT void unhighlightSelected(const bool theIsToHilightSubIntensity = false);
1535 
1536   //! Helper function that unhighlights the owners with check
1537   //! for AutoHighlight, e.g. is used for selection.
1538   Standard_EXPORT void unhighlightOwners(
1539     const NCollection_List<occ::handle<SelectMgr_EntityOwner>>& theOwners,
1540     const bool                                                  theIsToHilightSubIntensity = false);
1541 
1542   //! Helper function that unhighlights global selection owner of given interactive.
1543   //! The function does not perform any updates of global or owner status
1544   Standard_EXPORT void unhighlightGlobal(const occ::handle<AIS_InteractiveObject>& theObj);
1545 
1546   //! Helper function that turns on sub-intensity in global status and highlights
1547   //! given objects with sub-intensity color
1548   //! @param[in] theObject  the object. If NULL is given, than sub-intensity will be turned on for
1549   //! all inveractive objects of the context
1550   //! @param[in] theDispMode  display mode. If -1 is given, sub-intensity will be turned on for
1551   //! all display modes in global status's list of modes
1552   //! @param[in] theIsDisplayedOnly  is true if sub-intensity should be applied only to objects with
1553   //! status AIS_DS_Displayed
1554   Standard_EXPORT void turnOnSubintensity(
1555     const occ::handle<AIS_InteractiveObject>& theObject          = nullptr,
1556     const int                                 theDispMode        = -1,
1557     const bool                                theIsDisplayedOnly = true) const;
1558 
1559   //! Helper function that highlights the object with sub-intensity color without any checks
1560   //! @param[in] theObject  the object that will be highlighted
1561   //! @param[in] theMode  display mode
1562   Standard_EXPORT void highlightWithSubintensity(
1563     const occ::handle<AIS_InteractiveObject>& theObject,
1564     const int                                 theMode) const;
1565 
1566   //! Helper function that highlights the owner with sub-intensity color without any checks
1567   //! @param[in] theOwner  the owner that will be highlighted
1568   //! @param[in] theMode  display mode
1569   Standard_EXPORT void highlightWithSubintensity(const occ::handle<SelectMgr_EntityOwner>& theOwner,
1570                                                  const int theMode) const;
1571 
1572   //! Helper function that returns correct dynamic highlight style for the object:
1573   //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1574   //! dynamic highlight style of interactive context will be returned.
1575   //! @param[in] theObj  the object to check
1576   const occ::handle<Prs3d_Drawer>& getHiStyle(
1577     const occ::handle<AIS_InteractiveObject>& theObj,
1578     const occ::handle<SelectMgr_EntityOwner>& theOwner) const
1579   {
1580     const occ::handle<Prs3d_Drawer>& aHiDrawer = theObj->DynamicHilightAttributes();
1581     if (!aHiDrawer.IsNull())
1582     {
1583       return aHiDrawer;
1584     }
1585 
1586     return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition()
1587                       ? Prs3d_TypeOfHighlight_LocalDynamic
1588                       : Prs3d_TypeOfHighlight_Dynamic];
1589   }
1590 
1591   //! Return TRUE if highlight style of owner requires full viewer redraw.
1592   Standard_EXPORT bool isSlowHiStyle(const occ::handle<SelectMgr_EntityOwner>& theOwner,
1593                                      const occ::handle<V3d_Viewer>&            theViewer) const;
1594 
1595   //! Helper function that returns correct selection style for the object:
1596   //! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
1597   //! selection style of interactive context will be returned.
1598   //! @param[in] theObj  the object to check
1599   const occ::handle<Prs3d_Drawer>& getSelStyle(
1600     const occ::handle<AIS_InteractiveObject>& theObj,
1601     const occ::handle<SelectMgr_EntityOwner>& theOwner) const
1602   {
1603     const occ::handle<Prs3d_Drawer>& aHiDrawer = theObj->HilightAttributes();
1604     if (!aHiDrawer.IsNull())
1605     {
1606       return aHiDrawer;
1607     }
1608 
1609     return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition()
1610                       ? Prs3d_TypeOfHighlight_LocalSelected
1611                       : Prs3d_TypeOfHighlight_Selected];
1612   }
1613 
1614   //! Assign the context to the object or throw exception if object was already assigned to another
1615   //! context.
1616   Standard_EXPORT void setContextToObject(const occ::handle<AIS_InteractiveObject>& theObj);
1617 
1618   //! Return display mode for highlighting.
1619   int getHilightMode(const occ::handle<AIS_InteractiveObject>& theObj,
1620                      const occ::handle<Prs3d_Drawer>&          theStyle,
1621                      const int                                 theDispMode) const
1622   {
1623     if (!theStyle.IsNull() && theStyle->DisplayMode() != -1
1624         && theObj->AcceptDisplayMode(theStyle->DisplayMode()))
1625     {
1626       return theStyle->DisplayMode();
1627     }
1628     else if (theDispMode != -1)
1629     {
1630       return theDispMode;
1631     }
1632     else if (theObj->HasDisplayMode())
1633     {
1634       return theObj->DisplayMode();
1635     }
1636     return myDefaultDrawer->DisplayMode();
1637   }
1638 
1639   //! Removes dynamic highlight draw
1640   void clearDynamicHighlight() const
1641   {
1642     if (myLastPicked.IsNull())
1643       return;
1644 
1645     myLastPicked->Selectable()->ClearDynamicHighlight(myMainPM);
1646   }
1647 
1648   //! Bind/Unbind status to object and its children
1649   //! @param[in] theIObj the object to change status
1650   //! @param[in] theStatus status, if NULL, unbind object
1651   Standard_EXPORT void setObjectStatus(const occ::handle<AIS_InteractiveObject>& theIObj,
1652                                        const PrsMgr_DisplayStatus                theStatus,
1653                                        const int                                 theDispyMode,
1654                                        const int                                 theSelectionMode);
1655 
1656 protected: //! @name internal fields
1657   NCollection_DataMap<occ::handle<AIS_InteractiveObject>, occ::handle<AIS_GlobalStatus>> myObjects;
1658   occ::handle<SelectMgr_SelectionManager> mgrSelector;
1659   occ::handle<PrsMgr_PresentationManager> myMainPM;
1660   occ::handle<V3d_Viewer>                 myMainVwr;
1661   V3d_View*                               myLastActiveView;
1662   occ::handle<SelectMgr_EntityOwner>      myLastPicked;
1663   bool                                    myToHilightSelected;
1664   occ::handle<AIS_Selection>              mySelection;
1665   occ::handle<SelectMgr_AndOrFilter>      myFilters; //!< context filter (the content active filters
1666                                                      //!  can be applied with AND or OR operation)
1667   occ::handle<Prs3d_Drawer> myDefaultDrawer;
1668   occ::handle<Prs3d_Drawer> myStyles[Prs3d_TypeOfHighlight_NB];
1669   NCollection_Sequence<int> myDetectedSeq;
1670   int                       myCurDetected;
1671   int                       myCurHighlighted;
1672   SelectMgr_PickingStrategy myPickingStrategy; //!< picking strategy to be applied within MoveTo()
1673   bool                      myAutoHilight;
1674   bool                      myIsAutoActivateSelMode;
1675 };
1676 
1677 #endif // _AIS_InteractiveContext_HeaderFile