Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:41

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