0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / PrsMgr / PrsMgr_PresentationManager.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _PrsMgr_PresentationManager_HeaderFile
18#define _PrsMgr_PresentationManager_HeaderFile
19
c357e426 20#include <Graphic3d_NameOfMaterial.hxx>
21#include <Graphic3d_StructureManager.hxx>
22#include <Graphic3d_ZLayerId.hxx>
f838dac4 23#include <Standard_Transient.hxx>
42cf5bc1 24#include <PrsMgr_ListOfPresentations.hxx>
25#include <Quantity_Color.hxx>
42cf5bc1 26#include <Quantity_NameOfColor.hxx>
c357e426 27#include <Standard.hxx>
28#include <Standard_Boolean.hxx>
29#include <Standard_Integer.hxx>
30#include <Standard_Type.hxx>
31
7dd7c146 32class Graphic3d_Structure;
33typedef Graphic3d_Structure Prs3d_Presentation;
34
7f24b768 35class TopLoc_Datum3D;
f838dac4 36class Prs3d_Drawer;
42cf5bc1 37class PrsMgr_Presentation;
7dd7c146 38class PrsMgr_PresentableObject;
c357e426 39class Standard_NoSuchObject;
40class V3d_Viewer;
42cf5bc1 41
f838dac4 42DEFINE_STANDARD_HANDLE(PrsMgr_PresentationManager, Standard_Transient)
42cf5bc1 43
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.
f838dac4 48class PrsMgr_PresentationManager : public Standard_Transient
42cf5bc1 49{
f838dac4 50 DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient)
42cf5bc1 51public:
52
42cf5bc1 53 //! Creates a framework to manage displays and graphic entities with the 3D view theStructureManager.
c357e426 54 Standard_EXPORT PrsMgr_PresentationManager(const Handle(Graphic3d_StructureManager)& theStructureManager);
42cf5bc1 55
56 //! Displays the presentation of the object in the given Presentation manager with the given mode.
57 //! The mode should be enumerated by the object which inherits PresentableObject.
58 Standard_EXPORT void Display (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
59
60 //! erases the presentation of the object in the given
61 //! Presentation manager with the given mode.
e2d7642f 62 //! If @theMode is -1, then erases all presentations of the object.
42cf5bc1 63 Standard_EXPORT void Erase (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
64
65
66 //! Clears the presentation of the presentable object thePrsObject in this framework with the display mode theMode.
67 Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
68
69 //! Sets the visibility of presentable object.
70 Standard_EXPORT void SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Boolean theValue);
8e5fb5ea 71
f838dac4 72 //! Removes highlighting from the presentation of the presentable object.
73 Standard_EXPORT void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject);
74
75 Standard_DEPRECATED("Deprecated method Unhighlight() - argument theMode will be ignored")
76 void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode) { Unhighlight (thePrsObject); (void )theMode; }
42cf5bc1 77
78 //! Sets the display priority theNewPrior of the
79 //! presentable object thePrsObject in this framework with the display mode theMode.
80 Standard_EXPORT void SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Integer theNewPrior) const;
81
82
83 //! Returns the display priority of the presentable object
84 //! thePrsObject in this framework with the display mode theMode.
85 Standard_EXPORT Standard_Integer DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode) const;
86
87 //! Set Z layer ID for all presentations of the object.
8f138407 88 Standard_EXPORT void SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Graphic3d_ZLayerId theLayerId);
42cf5bc1 89
90 //! Get Z layer ID assigned to all presentations of the object.
91 //! Method returns -1 value if object has no presentations and is
92 //! impossible to get layer index.
8f138407 93 Standard_EXPORT Graphic3d_ZLayerId GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObject) const;
42cf5bc1 94
95 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
96
97 //! Returns true if the presentation of the presentable
98 //! object thePrsObject in this framework with the display mode theMode is highlighted.
99 Standard_EXPORT Standard_Boolean IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
100
101 //! Updates the presentation of the presentable object
102 //! thePrsObject in this framework with the display mode theMode.
103 Standard_EXPORT void Update (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
104
105 //! Resets the transient list of presentations previously displayed in immediate mode
106 //! and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls.
107 Standard_EXPORT void BeginImmediateDraw();
108
109 //! Resets the transient list of presentations previously displayed in immediate mode.
110 Standard_EXPORT void ClearImmediateDraw();
111
112 //! Stores thePrs in the transient list of presentations to be displayed in immediate mode.
113 //! Will be taken in account in EndImmediateDraw method.
114 Standard_EXPORT void AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs);
c3282ec1 115
116 //! Allows rapid drawing of the each view in theViewer by avoiding an update of the whole background.
117 Standard_EXPORT void EndImmediateDraw (const Handle(V3d_Viewer)& theViewer);
118
119 //! Clears and redisplays immediate structures of the viewer taking into account its affinity.
120 Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer);
121
42cf5bc1 122 //! Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode.
f838dac4 123 Standard_Boolean IsImmediateModeOn() const { return myImmediateModeOn > 0; }
c3282ec1 124
42cf5bc1 125 //! Highlights the graphic object thePrsObject in the color theColor.
126 //! thePrsObject has the display mode theMode;
127 //! this has the default value of 0, that is, the wireframe display mode.
c3282ec1 128 Standard_EXPORT void Color (const Handle(PrsMgr_PresentableObject)& thePrsObject,
f838dac4 129 const Handle(Prs3d_Drawer)& theStyle,
c3282ec1 130 const Standard_Integer theMode = 0,
131 const Handle(PrsMgr_PresentableObject)& theSelObj = NULL,
132 const Graphic3d_ZLayerId theImmediateStructLayerId = Graphic3d_ZLayerId_Topmost);
42cf5bc1 133
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);
135
136
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.
7f24b768 139 Standard_EXPORT void Transform (const Handle(PrsMgr_PresentableObject)& thePrsObject,
140 const Handle(TopLoc_Datum3D)& theTransformation,
141 const Standard_Integer theMode = 0);
42cf5bc1 142
143 //! Returns the structure manager.
f838dac4 144 const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; }
2831708b 145
42cf5bc1 146 //! Returns true if there is a presentation of the
147 //! presentable object thePrsObject in this framework, thePrsObject having the display mode theMode.
148 Standard_EXPORT Standard_Boolean HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const;
149
150 //! Returns the presentation Presentation of the presentable object thePrsObject in this framework.
151 //! When theToCreate is true - automatically creates presentation for specified mode when not exist.
152 //! Optional argument theSelObj specifies parent decomposed object to inherit its view affinity.
153 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;
154
5396886c 155 //! Allows to apply location transformation to shadow highlight presentation immediately.
156 //! @param theObj defines the base object, it local transformation will be applied to corresponding highlight structure
157 //! @param theMode defines display mode of the base object
158 //! @param theSelObj defines the object produced after decomposition of the base object for local selection
159 Standard_EXPORT void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
160 const Handle(PrsMgr_PresentableObject)& theObj,
161 const Standard_Integer theMode = 0,
162 const Handle(PrsMgr_PresentableObject)& theSelObj = NULL);
42cf5bc1 163
42cf5bc1 164protected:
165
42cf5bc1 166 //! Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject has the display mode theMode.
167 Standard_EXPORT Standard_Boolean RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0);
168
42cf5bc1 169private:
170
c3282ec1 171 //! Handles the structures from <myImmediateList> and displays it separating view-dependent structures and taking into account
172 //! structure visibility by setting proper affinity.
173 void displayImmediate (const Handle(V3d_Viewer)& theViewer);
42cf5bc1 174
f838dac4 175protected:
42cf5bc1 176
f838dac4 177 Handle(Graphic3d_StructureManager) myStructureManager;
178 Standard_Integer myImmediateModeOn;
179 PrsMgr_ListOfPresentations myImmediateList;
180 PrsMgr_ListOfPresentations myViewDependentImmediateList;
42cf5bc1 181
f838dac4 182};
42cf5bc1 183
184#endif // _PrsMgr_PresentationManager_HeaderFile