1 // Created on: 1995-01-25
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _PrsMgr_PresentationManager_HeaderFile
18 #define _PrsMgr_PresentationManager_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
24 #include <PrsMgr_ListOfPresentations.hxx>
25 #include <Quantity_Color.hxx>
26 #include <MMgt_TShared.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Quantity_NameOfColor.hxx>
29 #include <Graphic3d_NameOfMaterial.hxx>
30 class Visual3d_ViewManager;
32 class Standard_NoSuchObject;
33 class PrsMgr_PresentableObject;
34 class Prs3d_Presentation;
35 class Geom_Transformation;
36 class Graphic3d_StructureManager;
37 class Prs3d_ShadingAspect;
38 class PrsMgr_Presentation;
41 class PrsMgr_PresentationManager;
42 DEFINE_STANDARD_HANDLE(PrsMgr_PresentationManager, MMgt_TShared)
44 //! A framework to manage 3D displays, graphic entities and their updates.
45 //! Used in the AIS package (Application Interactive Services), to enable the advanced user to define the
46 //! default display mode of a new interactive object which extends the list of signatures and types.
47 //! Definition of new display types is handled by calling the presentation algorithms provided by the StdPrs package.
48 class PrsMgr_PresentationManager : public MMgt_TShared
55 //! Creates a framework to manage displays and graphic entities with the 3D view theStructureManager.
56 Standard_EXPORT PrsMgr_PresentationManager(const Handle(Visual3d_ViewManager)& theStructureManager);
58 //! Displays the presentation of the object in the given Presentation manager with the given mode.
59 //! The mode should be enumerated by the object which inherits PresentableObject.
60 Standard_EXPORT void Display (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
62 //! erases the presentation of the object in the given
63 //! Presentation manager with the given mode.
64 Standard_EXPORT void Erase (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
67 //! Clears the presentation of the presentable object thePrsObject in this framework with the display mode theMode.
68 Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
70 //! Sets the visibility of presentable object.
71 Standard_EXPORT void SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Boolean theValue);
73 //! Highlights the presentation of the presentable object
74 //! thePrsObject in this framework with the display mode theMode.
75 Standard_EXPORT void Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
77 //! Removes highlighting from the presentation of the
78 //! presentable object thePrsObject in this framework with the display mode theMode.
79 Standard_EXPORT void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
82 //! Sets the display priority theNewPrior of the
83 //! presentable object thePrsObject in this framework with the display mode theMode.
84 Standard_EXPORT void SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Integer theNewPrior) const;
87 //! Returns the display priority of the presentable object
88 //! thePrsObject in this framework with the display mode theMode.
89 Standard_EXPORT Standard_Integer DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode) const;
91 //! Set Z layer ID for all presentations of the object.
92 Standard_EXPORT void SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theLayerId);
94 //! Get Z layer ID assigned to all presentations of the object.
95 //! Method returns -1 value if object has no presentations and is
96 //! impossible to get layer index.
97 Standard_EXPORT Standard_Integer GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObject) const;
99 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
101 //! Returns true if the presentation of the presentable
102 //! object thePrsObject in this framework with the display mode theMode is highlighted.
103 Standard_EXPORT Standard_Boolean IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
105 //! Updates the presentation of the presentable object
106 //! thePrsObject in this framework with the display mode theMode.
107 Standard_EXPORT void Update (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
109 //! Resets the transient list of presentations previously displayed in immediate mode
110 //! and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls.
111 Standard_EXPORT void BeginImmediateDraw();
113 //! Resets the transient list of presentations previously displayed in immediate mode.
114 Standard_EXPORT void ClearImmediateDraw();
116 //! Stores thePrs in the transient list of presentations to be displayed in immediate mode.
117 //! Will be taken in account in EndImmediateDraw method.
118 Standard_EXPORT void AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs);
120 //! Allows rapid drawing of the view theView by avoiding an update of the whole background.
121 Standard_EXPORT void EndImmediateDraw (const Handle(V3d_View)& theView);
123 //! Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode.
124 Standard_Boolean IsImmediateModeOn() const;
126 //! Highlights the graphic object thePrsObject in the color theColor.
127 //! thePrsObject has the display mode theMode;
128 //! this has the default value of 0, that is, the wireframe display mode.
129 Standard_EXPORT void Color (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Quantity_NameOfColor theColor = Quantity_NOC_YELLOW, const Standard_Integer theMode = 0, const Handle(PrsMgr_PresentableObject)& theSelObj = NULL);
131 //! highlights the boundbox of the presentation
132 Standard_EXPORT void BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
134 Standard_EXPORT void Connect (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(PrsMgr_PresentableObject)& theOtherObject, const Standard_Integer theMode = 0, const Standard_Integer theOtherMode = 0);
137 //! Sets the transformation theTransformation for the presentable object thePrsObject.
138 //! thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode.
139 Standard_EXPORT void Transform (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(Geom_Transformation)& theTransformation, const Standard_Integer theMode = 0);
141 //! Returns the structure manager.
142 const Handle(Graphic3d_StructureManager)& StructureManager() const;
144 //! this method will change the color and the aspect of the presentations containing shaded structures.
145 Standard_EXPORT void SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Quantity_NameOfColor theColor, const Graphic3d_NameOfMaterial theMaterial, const Standard_Integer theMode = 0);
147 //! this method will change the color and the aspect of the presentations containing shaded structures.
148 Standard_EXPORT void SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(Prs3d_ShadingAspect)& theShadingAspect, const Standard_Integer theMode = 0);
150 //! Returns true if there is a presentation of the
151 //! presentable object thePrsObject in this framework, thePrsObject having the display mode theMode.
152 Standard_EXPORT Standard_Boolean HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
154 //! Returns the presentation Presentation of the presentable object thePrsObject in this framework.
155 //! When theToCreate is true - automatically creates presentation for specified mode when not exist.
156 //! Optional argument theSelObj specifies parent decomposed object to inherit its view affinity.
157 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;
162 DEFINE_STANDARD_RTTI(PrsMgr_PresentationManager,MMgt_TShared)
167 //! Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject has the display mode theMode.
168 Standard_EXPORT Standard_Boolean RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
170 Handle(Visual3d_ViewManager) myStructureManager;
171 Standard_Integer myImmediateModeOn;
172 PrsMgr_ListOfPresentations myImmediateList;
173 Handle(V3d_View) myImmediateView;
174 Quantity_Color mySelectionColor;
185 #include <PrsMgr_PresentationManager.lxx>
191 #endif // _PrsMgr_PresentationManager_HeaderFile