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
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 _Visual3d_ViewManager_HeaderFile
18 #define _Visual3d_ViewManager_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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>
38 class Graphic3d_GraphicDriver;
40 class Graphic3d_Structure;
42 class Graphic3d_DataStructureManager;
45 class Visual3d_ViewManager;
46 DEFINE_STANDARD_HANDLE(Visual3d_ViewManager, Graphic3d_StructureManager)
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
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.
63 //! Category: Methods to modify the class definition
64 Standard_EXPORT Visual3d_ViewManager(const Handle(Graphic3d_GraphicDriver)& theDriver);
66 //! Activates all the views of the manager <me>.
67 Standard_EXPORT void Activate();
69 //! Deactivates all the views of the manager <me>.
70 Standard_EXPORT void Deactivate();
72 //! Deletes and erases the 3D visualiser <me>.
73 Standard_EXPORT virtual void Destroy() Standard_OVERRIDE;
74 ~Visual3d_ViewManager()
79 //! Erases all of the structures displayed in the
81 Standard_EXPORT void Erase();
83 //! Redraws all the displayed structures.
84 Standard_EXPORT void Redraw() const;
86 //! Updates layer of immediate presentations.
87 Standard_EXPORT void RedrawImmediate() const;
89 //! Invalidates viewer content but does not redraw it.
90 Standard_EXPORT void Invalidate() const;
92 //! Deletes and erases the 3D visualiser <me>.
93 Standard_EXPORT void Remove();
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;
99 //! Returns the group of views activated in the visualiser <me>.
100 Standard_EXPORT Handle(Visual3d_HSequenceOfView) ActivatedView() const;
102 //! Returns the group of views defined in the visualiser <me>.
103 Standard_EXPORT const Visual3d_SequenceOfView& DefinedViews() const;
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;
114 //! a new identification number for a new view
115 //! in the visualiser.
116 Standard_EXPORT Standard_Integer Identification (const Handle(Visual3d_View)& AView);
118 //! Release a unique ID of the view reserved for the view on its creation.
119 Standard_EXPORT void UnIdentification (const Standard_Integer aViewId);
121 //! Returns the structure with the identification number <AId>.
122 Standard_EXPORT Handle(Graphic3d_Structure) Identification (const Standard_Integer AId) const Standard_OVERRIDE;
124 //! Returns the identification number of the visualiser.
125 Standard_EXPORT Standard_Integer Identification() const Standard_OVERRIDE;
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;
130 //! Change Z layer for structure. The layer mechanism allows
131 //! to display structures in higher layers in overlay of structures in
133 Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
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;
138 //! Returns the settings of a single Z layer.
139 Standard_EXPORT Graphic3d_ZLayerSettings ZLayerSettings (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
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;
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
151 Standard_EXPORT Standard_Boolean RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
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;
158 //! Clears the structure <AStructure>.
159 Standard_EXPORT void Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) Standard_OVERRIDE;
161 //! Connects the structures <AMother> and <ADaughter>.
162 Standard_EXPORT void Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) Standard_OVERRIDE;
164 //! Disconnects the structures <AMother> and <ADaughter>.
165 Standard_EXPORT void Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) Standard_OVERRIDE;
167 //! Display of the structure <AStructure>.
168 Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
170 //! Erases the structure <AStructure>.
171 Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
173 //! Highlights the structure <AStructure>.
174 Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) Standard_OVERRIDE;
176 Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) Standard_OVERRIDE;
178 //! Suppress the highlighting on all the structures.
179 Standard_EXPORT void UnHighlight() Standard_OVERRIDE;
181 //! Suppress the highlighting on the structure <AStructure>.
182 Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& AStructure) Standard_OVERRIDE;
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;
190 //! Returns the underlay of the viewer <me>.
191 Standard_EXPORT const Handle(Visual3d_Layer)& UnderLayer() const;
193 //! Returns the underlay of the viewer <me>.
194 Standard_EXPORT const Handle(Visual3d_Layer)& OverLayer() const;
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;
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;
204 //! Returns Standard_True if the zbuffer activity
205 //! is managed automatically.
206 //! Default Standard_False
207 Standard_EXPORT Standard_Boolean ZBufferAuto() const;
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);
214 friend class Visual3d_View;
215 friend class Visual3d_Layer;
218 DEFINE_STANDARD_RTTI(Visual3d_ViewManager,Graphic3d_StructureManager)
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;
233 //! Adds a new layer in all the views of <me>.
234 Standard_EXPORT void SetLayer (const Handle(Visual3d_Layer)& ALayer);
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;
256 #endif // _Visual3d_ViewManager_HeaderFile