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_StructureManager.hxx> |
21 | #include <Graphic3d_ZLayerId.hxx> |
42cf5bc1 |
22 | #include <PrsMgr_ListOfPresentations.hxx> |
c357e426 |
23 | |
7dd7c146 |
24 | class Graphic3d_Structure; |
25 | typedef Graphic3d_Structure Prs3d_Presentation; |
26 | |
7f24b768 |
27 | class TopLoc_Datum3D; |
f838dac4 |
28 | class Prs3d_Drawer; |
42cf5bc1 |
29 | class PrsMgr_Presentation; |
7dd7c146 |
30 | class PrsMgr_PresentableObject; |
c357e426 |
31 | class V3d_Viewer; |
42cf5bc1 |
32 | |
f838dac4 |
33 | DEFINE_STANDARD_HANDLE(PrsMgr_PresentationManager, Standard_Transient) |
42cf5bc1 |
34 | |
35 | //! A framework to manage 3D displays, graphic entities and their updates. |
36 | //! Used in the AIS package (Application Interactive Services), to enable the advanced user to define the |
37 | //! default display mode of a new interactive object which extends the list of signatures and types. |
38 | //! Definition of new display types is handled by calling the presentation algorithms provided by the StdPrs package. |
f838dac4 |
39 | class PrsMgr_PresentationManager : public Standard_Transient |
42cf5bc1 |
40 | { |
f838dac4 |
41 | DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient) |
42cf5bc1 |
42 | public: |
43 | |
42cf5bc1 |
44 | //! Creates a framework to manage displays and graphic entities with the 3D view theStructureManager. |
c357e426 |
45 | Standard_EXPORT PrsMgr_PresentationManager(const Handle(Graphic3d_StructureManager)& theStructureManager); |
42cf5bc1 |
46 | |
47 | //! Displays the presentation of the object in the given Presentation manager with the given mode. |
48 | //! The mode should be enumerated by the object which inherits PresentableObject. |
49 | Standard_EXPORT void Display (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); |
50 | |
51 | //! erases the presentation of the object in the given |
52 | //! Presentation manager with the given mode. |
e2d7642f |
53 | //! If @theMode is -1, then erases all presentations of the object. |
42cf5bc1 |
54 | Standard_EXPORT void Erase (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); |
f4e7c307 |
55 | |
42cf5bc1 |
56 | |
57 | //! Clears the presentation of the presentable object thePrsObject in this framework with the display mode theMode. |
58 | Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); |
59 | |
60 | //! Sets the visibility of presentable object. |
61 | Standard_EXPORT void SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Boolean theValue); |
8e5fb5ea |
62 | |
f838dac4 |
63 | //! Removes highlighting from the presentation of the presentable object. |
64 | Standard_EXPORT void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject); |
65 | |
42cf5bc1 |
66 | //! Sets the display priority theNewPrior of the |
67 | //! presentable object thePrsObject in this framework with the display mode theMode. |
e463b2f6 |
68 | Standard_EXPORT void SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
69 | const Standard_Integer theMode, |
70 | const Graphic3d_DisplayPriority theNewPrior) const; |
42cf5bc1 |
71 | |
72 | //! Returns the display priority of the presentable object |
73 | //! thePrsObject in this framework with the display mode theMode. |
e463b2f6 |
74 | Standard_EXPORT Graphic3d_DisplayPriority DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode) const; |
42cf5bc1 |
75 | |
76 | //! Set Z layer ID for all presentations of the object. |
8f138407 |
77 | Standard_EXPORT void SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Graphic3d_ZLayerId theLayerId); |
42cf5bc1 |
78 | |
79 | //! Get Z layer ID assigned to all presentations of the object. |
80 | //! Method returns -1 value if object has no presentations and is |
81 | //! impossible to get layer index. |
8f138407 |
82 | Standard_EXPORT Graphic3d_ZLayerId GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObject) const; |
42cf5bc1 |
83 | |
84 | Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const; |
85 | |
86 | //! Returns true if the presentation of the presentable |
87 | //! object thePrsObject in this framework with the display mode theMode is highlighted. |
88 | Standard_EXPORT Standard_Boolean IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const; |
89 | |
90 | //! Updates the presentation of the presentable object |
91 | //! thePrsObject in this framework with the display mode theMode. |
92 | Standard_EXPORT void Update (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const; |
93 | |
94 | //! Resets the transient list of presentations previously displayed in immediate mode |
95 | //! and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls. |
96 | Standard_EXPORT void BeginImmediateDraw(); |
97 | |
98 | //! Resets the transient list of presentations previously displayed in immediate mode. |
99 | Standard_EXPORT void ClearImmediateDraw(); |
100 | |
101 | //! Stores thePrs in the transient list of presentations to be displayed in immediate mode. |
102 | //! Will be taken in account in EndImmediateDraw method. |
103 | Standard_EXPORT void AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs); |
c3282ec1 |
104 | |
105 | //! Allows rapid drawing of the each view in theViewer by avoiding an update of the whole background. |
106 | Standard_EXPORT void EndImmediateDraw (const Handle(V3d_Viewer)& theViewer); |
107 | |
108 | //! Clears and redisplays immediate structures of the viewer taking into account its affinity. |
109 | Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer); |
110 | |
42cf5bc1 |
111 | //! Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode. |
f838dac4 |
112 | Standard_Boolean IsImmediateModeOn() const { return myImmediateModeOn > 0; } |
c3282ec1 |
113 | |
42cf5bc1 |
114 | //! Highlights the graphic object thePrsObject in the color theColor. |
115 | //! thePrsObject has the display mode theMode; |
116 | //! this has the default value of 0, that is, the wireframe display mode. |
c3282ec1 |
117 | Standard_EXPORT void Color (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
f838dac4 |
118 | const Handle(Prs3d_Drawer)& theStyle, |
c3282ec1 |
119 | const Standard_Integer theMode = 0, |
120 | const Handle(PrsMgr_PresentableObject)& theSelObj = NULL, |
121 | const Graphic3d_ZLayerId theImmediateStructLayerId = Graphic3d_ZLayerId_Topmost); |
42cf5bc1 |
122 | |
123 | Standard_EXPORT void Connect (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(PrsMgr_PresentableObject)& theOtherObject, const Standard_Integer theMode = 0, const Standard_Integer theOtherMode = 0); |
124 | |
125 | |
126 | //! Sets the transformation theTransformation for the presentable object thePrsObject. |
127 | //! thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode. |
7f24b768 |
128 | Standard_EXPORT void Transform (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
129 | const Handle(TopLoc_Datum3D)& theTransformation, |
130 | const Standard_Integer theMode = 0); |
42cf5bc1 |
131 | |
132 | //! Returns the structure manager. |
f838dac4 |
133 | const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; } |
2831708b |
134 | |
42cf5bc1 |
135 | //! Returns true if there is a presentation of the |
136 | //! presentable object thePrsObject in this framework, thePrsObject having the display mode theMode. |
137 | Standard_EXPORT Standard_Boolean HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0) const; |
138 | |
139 | //! Returns the presentation Presentation of the presentable object thePrsObject in this framework. |
140 | //! When theToCreate is true - automatically creates presentation for specified mode when not exist. |
141 | //! Optional argument theSelObj specifies parent decomposed object to inherit its view affinity. |
142 | 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; |
143 | |
5396886c |
144 | //! Allows to apply location transformation to shadow highlight presentation immediately. |
145 | //! @param theObj defines the base object, it local transformation will be applied to corresponding highlight structure |
146 | //! @param theMode defines display mode of the base object |
147 | //! @param theSelObj defines the object produced after decomposition of the base object for local selection |
148 | Standard_EXPORT void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer, |
149 | const Handle(PrsMgr_PresentableObject)& theObj, |
150 | const Standard_Integer theMode = 0, |
151 | const Handle(PrsMgr_PresentableObject)& theSelObj = NULL); |
42cf5bc1 |
152 | |
42cf5bc1 |
153 | protected: |
154 | |
42cf5bc1 |
155 | //! Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject has the display mode theMode. |
156 | Standard_EXPORT Standard_Boolean RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); |
157 | |
42cf5bc1 |
158 | private: |
159 | |
c3282ec1 |
160 | //! Handles the structures from <myImmediateList> and displays it separating view-dependent structures and taking into account |
161 | //! structure visibility by setting proper affinity. |
162 | void displayImmediate (const Handle(V3d_Viewer)& theViewer); |
42cf5bc1 |
163 | |
f838dac4 |
164 | protected: |
42cf5bc1 |
165 | |
f838dac4 |
166 | Handle(Graphic3d_StructureManager) myStructureManager; |
167 | Standard_Integer myImmediateModeOn; |
168 | PrsMgr_ListOfPresentations myImmediateList; |
169 | PrsMgr_ListOfPresentations myViewDependentImmediateList; |
42cf5bc1 |
170 | |
f838dac4 |
171 | }; |
42cf5bc1 |
172 | |
173 | #endif // _PrsMgr_PresentationManager_HeaderFile |