Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:29:08

0001 // Created on: 1995-01-25
0002 // Created by: Jean-Louis Frenkel
0003 // Copyright (c) 1995-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 _PrsMgr_PresentationManager_HeaderFile
0018 #define _PrsMgr_PresentationManager_HeaderFile
0019 
0020 #include <Graphic3d_StructureManager.hxx>
0021 #include <Graphic3d_ZLayerId.hxx>
0022 #include <NCollection_List.hxx>
0023 #include <Prs3d_Presentation.hxx>
0024 
0025 class Graphic3d_Structure;
0026 typedef Graphic3d_Structure Prs3d_Presentation;
0027 
0028 class TopLoc_Datum3D;
0029 class Prs3d_Drawer;
0030 class PrsMgr_Presentation;
0031 class PrsMgr_PresentableObject;
0032 class V3d_Viewer;
0033 
0034 //! A framework to manage 3D displays, graphic entities and their updates.
0035 //! Used in the AIS package (Application Interactive Services), to enable the advanced user to
0036 //! define the default display mode of a new interactive object which extends the list of signatures
0037 //! and types. Definition of new display types is handled by calling the presentation algorithms
0038 //! provided by the StdPrs package.
0039 class PrsMgr_PresentationManager : public Standard_Transient
0040 {
0041   DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient)
0042 public:
0043   //! Creates a framework to manage displays and graphic entities with the 3D view
0044   //! theStructureManager.
0045   Standard_EXPORT PrsMgr_PresentationManager(
0046     const occ::handle<Graphic3d_StructureManager>& theStructureManager);
0047 
0048   //! Displays the presentation of the object in the given Presentation manager with the given mode.
0049   //! The mode should be enumerated by the object which inherits PresentableObject.
0050   Standard_EXPORT void Display(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0051                                const int                                    theMode = 0);
0052 
0053   //! erases the presentation of the object in the given
0054   //! Presentation manager with the given mode.
0055   //! If @theMode is -1, then erases all presentations of the object.
0056   Standard_EXPORT void Erase(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0057                              const int                                    theMode = 0);
0058 
0059   //! Clears the presentation of the presentable object thePrsObject in this framework with the
0060   //! display mode theMode.
0061   Standard_EXPORT virtual void Clear(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0062                                      const int                                    theMode = 0);
0063 
0064   //! Sets the visibility of presentable object.
0065   Standard_EXPORT void SetVisibility(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0066                                      const int                                    theMode,
0067                                      const bool                                   theValue);
0068 
0069   //! Removes highlighting from the presentation of the presentable object.
0070   Standard_EXPORT void Unhighlight(const occ::handle<PrsMgr_PresentableObject>& thePrsObject);
0071 
0072   //! Sets the display priority theNewPrior of the
0073   //! presentable object thePrsObject in this framework with the display mode theMode.
0074   Standard_EXPORT void SetDisplayPriority(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0075                                           const int                                    theMode,
0076                                           const Graphic3d_DisplayPriority theNewPrior) const;
0077 
0078   //! Returns the display priority of the presentable object
0079   //! thePrsObject in this framework with the display mode theMode.
0080   Standard_EXPORT Graphic3d_DisplayPriority
0081     DisplayPriority(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0082                     const int                                    theMode) const;
0083 
0084   //! Set Z layer ID for all presentations of the object.
0085   Standard_EXPORT void SetZLayer(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0086                                  const Graphic3d_ZLayerId                     theLayerId);
0087 
0088   //! Get Z layer ID assigned to all presentations of the object.
0089   //! Method returns -1 value if object has no presentations and is
0090   //! impossible to get layer index.
0091   Standard_EXPORT Graphic3d_ZLayerId
0092     GetZLayer(const occ::handle<PrsMgr_PresentableObject>& thePrsObject) const;
0093 
0094   Standard_EXPORT bool IsDisplayed(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0095                                    const int                                    theMode = 0) const;
0096 
0097   //! Returns true if the presentation of the presentable
0098   //! object thePrsObject in this framework with the display mode theMode is highlighted.
0099   Standard_EXPORT bool IsHighlighted(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0100                                      const int theMode = 0) const;
0101 
0102   //! Updates the presentation of the presentable object
0103   //! thePrsObject in this framework with the display mode theMode.
0104   Standard_EXPORT void Update(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0105                               const int                                    theMode = 0) const;
0106 
0107   //! Resets the transient list of presentations previously displayed in immediate mode
0108   //! and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight()
0109   //! calls.
0110   Standard_EXPORT void BeginImmediateDraw();
0111 
0112   //! Resets the transient list of presentations previously displayed in immediate mode.
0113   Standard_EXPORT void ClearImmediateDraw();
0114 
0115   //! Stores thePrs in the transient list of presentations to be displayed in immediate mode.
0116   //! Will be taken in account in EndImmediateDraw method.
0117   Standard_EXPORT void AddToImmediateList(const occ::handle<Prs3d_Presentation>& thePrs);
0118 
0119   //! Allows rapid drawing of the each view in theViewer by avoiding an update of the whole
0120   //! background.
0121   Standard_EXPORT void EndImmediateDraw(const occ::handle<V3d_Viewer>& theViewer);
0122 
0123   //! Clears and redisplays immediate structures of the viewer taking into account its affinity.
0124   Standard_EXPORT void RedrawImmediate(const occ::handle<V3d_Viewer>& theViewer);
0125 
0126   //! Returns true if Presentation Manager is accumulating transient list of presentations to be
0127   //! displayed in immediate mode.
0128   bool IsImmediateModeOn() const { return myImmediateModeOn > 0; }
0129 
0130   //! Highlights the graphic object thePrsObject in the color theColor.
0131   //! thePrsObject has the display mode theMode;
0132   //! this has the default value of 0, that is, the wireframe display mode.
0133   Standard_EXPORT void Color(
0134     const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0135     const occ::handle<Prs3d_Drawer>&             theStyle,
0136     const int                                    theMode   = 0,
0137     const occ::handle<PrsMgr_PresentableObject>& theSelObj = nullptr,
0138     const Graphic3d_ZLayerId theImmediateStructLayerId     = Graphic3d_ZLayerId_Topmost);
0139 
0140   Standard_EXPORT void Connect(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0141                                const occ::handle<PrsMgr_PresentableObject>& theOtherObject,
0142                                const int                                    theMode      = 0,
0143                                const int                                    theOtherMode = 0);
0144 
0145   //! Sets the transformation theTransformation for the presentable object thePrsObject.
0146   //! thePrsObject has the display mode theMode; this has the default value of 0, that is, the
0147   //! wireframe display mode.
0148   Standard_EXPORT void Transform(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0149                                  const occ::handle<TopLoc_Datum3D>&           theTransformation,
0150                                  const int                                    theMode = 0);
0151 
0152   //! Returns the structure manager.
0153   const occ::handle<Graphic3d_StructureManager>& StructureManager() const
0154   {
0155     return myStructureManager;
0156   }
0157 
0158   //! Returns true if there is a presentation of the
0159   //! presentable object thePrsObject in this framework, thePrsObject having the display mode
0160   //! theMode.
0161   Standard_EXPORT bool HasPresentation(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0162                                        const int theMode = 0) const;
0163 
0164   //! Returns the presentation Presentation of the presentable object thePrsObject in this
0165   //! framework. When theToCreate is true - automatically creates presentation for specified mode
0166   //! when not exist. Optional argument theSelObj specifies parent decomposed object to inherit its
0167   //! view affinity.
0168   Standard_EXPORT occ::handle<PrsMgr_Presentation> Presentation(
0169     const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0170     const int                                    theMode     = 0,
0171     const bool                                   theToCreate = false,
0172     const occ::handle<PrsMgr_PresentableObject>& theSelObj   = nullptr) const;
0173 
0174   //! Allows to apply location transformation to shadow highlight presentation immediately.
0175   //! @param theObj defines the base object, it local transformation will be applied to
0176   //! corresponding highlight structure
0177   //! @param theMode defines display mode of the base object
0178   //! @param theSelObj defines the object produced after decomposition of the base object for local
0179   //! selection
0180   Standard_EXPORT void UpdateHighlightTrsf(
0181     const occ::handle<V3d_Viewer>&               theViewer,
0182     const occ::handle<PrsMgr_PresentableObject>& theObj,
0183     const int                                    theMode   = 0,
0184     const occ::handle<PrsMgr_PresentableObject>& theSelObj = nullptr);
0185 
0186 protected:
0187   //! Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject
0188   //! has the display mode theMode.
0189   Standard_EXPORT bool RemovePresentation(const occ::handle<PrsMgr_PresentableObject>& thePrsObject,
0190                                           const int                                    theMode = 0);
0191 
0192 private:
0193   //! Handles the structures from <myImmediateList> and displays it separating view-dependent
0194   //! structures and taking into account structure visibility by setting proper affinity.
0195   void displayImmediate(const occ::handle<V3d_Viewer>& theViewer);
0196 
0197 protected:
0198   occ::handle<Graphic3d_StructureManager>           myStructureManager;
0199   int                                               myImmediateModeOn;
0200   NCollection_List<occ::handle<Prs3d_Presentation>> myImmediateList;
0201   NCollection_List<occ::handle<Prs3d_Presentation>> myViewDependentImmediateList;
0202 };
0203 
0204 #endif // _PrsMgr_PresentationManager_HeaderFile