32e71af10fa5eb00e976c656a425a4159cc02bce
[occt.git] / src / Visual3d / Visual3d_ViewManager.hxx
1 // Created on: 1991-09-05
2 // Created by: NW,JPB,CAL
3 // Copyright (c) 1991-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 _Visual3d_ViewManager_HeaderFile
18 #define _Visual3d_ViewManager_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Visual3d_SequenceOfView.hxx>
24 #include <Aspect_GenId.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <TColStd_MapOfInteger.hxx>
27 #include <TColStd_SequenceOfInteger.hxx>
28 #include <Visual3d_MapOfZLayerSettings.hxx>
29 #include <Graphic3d_StructureManager.hxx>
30 #include <Visual3d_HSequenceOfView.hxx>
31 #include <Standard_Integer.hxx>
32 #include <Graphic3d_ZLayerId.hxx>
33 #include <Graphic3d_ZLayerSettings.hxx>
34 #include <Aspect_TypeOfHighlightMethod.hxx>
35 #include <TColStd_Array2OfReal.hxx>
36 #include <Graphic3d_CView.hxx>
37 class Visual3d_Layer;
38 class Graphic3d_GraphicDriver;
39 class Visual3d_View;
40 class Graphic3d_Structure;
41 class Aspect_Window;
42 class Graphic3d_DataStructureManager;
43
44
45 class Visual3d_ViewManager;
46 DEFINE_STANDARD_HANDLE(Visual3d_ViewManager, Graphic3d_StructureManager)
47
48 //! This class allows the definition of a manager to
49 //! which the views are associated.
50 //! It allows them to be globally manipulated.
51 class Visual3d_ViewManager : public Graphic3d_StructureManager
52 {
53
54 public:
55
56   
57   //! Creates a 3D visualizer.
58   //! Currently creating of more than 100 viewer instances
59   //! is not supported and leads to InitializationError and
60   //! initialisation failure.
61   //! This limitation might be addressed in some future OCCT releases.
62   //!
63   //! Category: Methods to modify the class definition
64   Standard_EXPORT Visual3d_ViewManager(const Handle(Graphic3d_GraphicDriver)& theDriver);
65   
66   //! Activates all the views of the manager <me>.
67   Standard_EXPORT void Activate();
68   
69   //! Deactivates all the views of the manager <me>.
70   Standard_EXPORT void Deactivate();
71   
72   //! Deletes and erases the 3D visualiser <me>.
73   Standard_EXPORT virtual void Destroy() Standard_OVERRIDE;
74 ~Visual3d_ViewManager()
75 {
76   Destroy();
77 }
78   
79   //! Erases all of the structures displayed in the
80   //! visualiser <me>.
81   Standard_EXPORT void Erase();
82   
83   //! Redraws all the displayed structures.
84   Standard_EXPORT void Redraw() const;
85   
86   //! Updates layer of immediate presentations.
87   Standard_EXPORT void RedrawImmediate() const;
88   
89   //! Invalidates viewer content but does not redraw it.
90   Standard_EXPORT void Invalidate() const;
91   
92   //! Deletes and erases the 3D visualiser <me>.
93   Standard_EXPORT void Remove();
94   
95   //! Updates screen in function of modifications of the structures.
96   //! Category: Methods to modify the class definition
97   Standard_EXPORT void Update() const Standard_OVERRIDE;
98   
99   //! Returns the group of views activated in the visualiser <me>.
100   Standard_EXPORT Handle(Visual3d_HSequenceOfView) ActivatedView() const;
101   
102   //! Returns the group of views defined in the visualiser <me>.
103   Standard_EXPORT const Visual3d_SequenceOfView& DefinedViews() const;
104   
105   //! Returns the theoretical maximum number of
106   //! definable views in the view manager <me>.
107   //! Warning: It's not possible to accept an infinite
108   //! number of definable views because each
109   //! view must have an identification and we
110   //! have different view managers.
111   Standard_EXPORT Standard_Integer MaxNumOfViews() const;
112   
113   //! Returns :
114   //! a new identification number for a new view
115   //! in the visualiser.
116   Standard_EXPORT Standard_Integer Identification (const Handle(Visual3d_View)& AView);
117   
118   //! Release a unique ID of the view reserved for the view on its creation.
119   Standard_EXPORT void UnIdentification (const Standard_Integer aViewId);
120   
121   //! Returns the structure with the identification number <AId>.
122   Standard_EXPORT Handle(Graphic3d_Structure) Identification (const Standard_Integer AId) const Standard_OVERRIDE;
123   
124   //! Returns the identification number of the visualiser.
125   Standard_EXPORT Standard_Integer Identification() const Standard_OVERRIDE;
126   
127   //! Changes the display priority of the structure <AStructure>.
128   Standard_EXPORT void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) Standard_OVERRIDE;
129   
130   //! Change Z layer for structure. The layer mechanism allows
131   //! to display structures in higher layers in overlay of structures in
132   //! lower layers.
133   Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
134   
135   //! Sets the settings for a single Z layer for all managed views.
136   Standard_EXPORT void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) Standard_OVERRIDE;
137   
138   //! Returns the settings of a single Z layer.
139   Standard_EXPORT Graphic3d_ZLayerSettings ZLayerSettings (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
140   
141   //! Add a new top-level Z layer and get its ID as
142   //! <theLayerId> value. The method returns Standard_False if the layer
143   //! can not be created. The layer mechanism allows to display
144   //! structures in higher layers in overlay of structures in lower layers.
145   Standard_EXPORT Standard_Boolean AddZLayer (Graphic3d_ZLayerId& theLayerId) Standard_OVERRIDE;
146   
147   //! Remove Z layer with ID <theLayerId>. Method returns
148   //! Standard_False if the layer can not be removed or doesn't exists.
149   //! By default, there are always default bottom-level layer that can't
150   //! be removed.
151   Standard_EXPORT Standard_Boolean RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
152   
153   //! Return all Z layer ids in sequence ordered by overlay level
154   //! from lowest layer to highest ( foreground ). The first layer ID
155   //! in sequence is the default layer that can't be removed.
156   Standard_EXPORT void GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const Standard_OVERRIDE;
157   
158   //! Clears the structure <AStructure>.
159   Standard_EXPORT void Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) Standard_OVERRIDE;
160   
161   //! Connects the structures <AMother> and <ADaughter>.
162   Standard_EXPORT void Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) Standard_OVERRIDE;
163   
164   //! Disconnects the structures <AMother> and <ADaughter>.
165   Standard_EXPORT void Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) Standard_OVERRIDE;
166   
167   //! Display of the structure <AStructure>.
168   Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
169   
170   //! Erases the structure <AStructure>.
171   Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
172   
173   //! Highlights the structure <AStructure>.
174   Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) Standard_OVERRIDE;
175   
176   Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) Standard_OVERRIDE;
177   
178   //! Suppress the highlighting on all the structures.
179   Standard_EXPORT void UnHighlight() Standard_OVERRIDE;
180   
181   //! Suppress the highlighting on the structure <AStructure>.
182   Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
183   
184   //! Returns Standard_True if the view associated to the
185   //! window <AWindow> exists and is activated.
186   //! <TheViewId> contains the internal identification of
187   //! the associated view.
188   Standard_EXPORT Standard_Boolean ViewExists (const Handle(Aspect_Window)& AWindow, Graphic3d_CView& TheCView) const;
189   
190   //! Returns the underlay of the viewer <me>.
191   Standard_EXPORT const Handle(Visual3d_Layer)& UnderLayer() const;
192   
193   //! Returns the underlay of the viewer <me>.
194   Standard_EXPORT const Handle(Visual3d_Layer)& OverLayer() const;
195   
196   //! Forces a new construction of the structure <AStructure>
197   //! if <AStructure> is displayed and TOS_COMPUTED.
198   Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
199   
200   //! Forces a new construction of the structure <AStructure>
201   //! if <AStructure> is displayed in <AProjector> and TOS_COMPUTED.
202   Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& AStructure, const Handle(Graphic3d_DataStructureManager)& AProjector) Standard_OVERRIDE;
203   
204   //! Returns Standard_True if the zbuffer activity
205   //! is managed automatically.
206   //! Default Standard_False
207   Standard_EXPORT Standard_Boolean ZBufferAuto() const;
208   
209   //! if <AFlag> is  Standard_True then the zbuffer activity
210   //! is managed automatically.
211   //! Default Standard_False
212   Standard_EXPORT void SetZBufferAuto (const Standard_Boolean AFlag);
213
214 friend class Visual3d_View;
215 friend class Visual3d_Layer;
216
217
218   DEFINE_STANDARD_RTTI(Visual3d_ViewManager,Graphic3d_StructureManager)
219
220 protected:
221
222
223
224
225 private:
226
227   
228   //! Install z layers managed by the view manager into the
229   //! controlled view. This method used on the view initialization to
230   //! make the layer lists consistent.
231   Standard_EXPORT void InstallZLayers (const Handle(Visual3d_View)& theView) const;
232   
233   //! Adds a new layer in all the views of <me>.
234   Standard_EXPORT void SetLayer (const Handle(Visual3d_Layer)& ALayer);
235
236   Visual3d_SequenceOfView MyDefinedView;
237   Handle(Visual3d_Layer) MyUnderLayer;
238   Handle(Visual3d_Layer) MyOverLayer;
239   Aspect_GenId MyViewGenId;
240   Handle(Graphic3d_GraphicDriver) MyGraphicDriver;
241   Standard_Boolean MyZBufferAuto;
242   Aspect_GenId myZLayerGenId;
243   TColStd_MapOfInteger myLayerIds;
244   TColStd_SequenceOfInteger myLayerSeq;
245   Visual3d_MapOfZLayerSettings myMapOfZLayerSettings;
246
247
248 };
249
250
251
252
253
254
255
256 #endif // _Visual3d_ViewManager_HeaderFile