0024776: Visualization - inherit OpenGl_View from Graphic3d_CView
[occt.git] / src / Graphic3d / Graphic3d_StructureManager.hxx
CommitLineData
42cf5bc1 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 _Graphic3d_StructureManager_HeaderFile
18#define _Graphic3d_StructureManager_HeaderFile
19
c357e426 20#include <Aspect_GenId.hxx>
21#include <Aspect_TypeOfHighlightMethod.hxx>
42cf5bc1 22#include <Aspect_TypeOfUpdate.hxx>
c357e426 23#include <Graphic3d_CView.hxx>
42cf5bc1 24#include <Graphic3d_MapOfObject.hxx>
c357e426 25#include <Graphic3d_MapOfStructure.hxx>
26#include <Graphic3d_ViewAffinity.hxx>
42cf5bc1 27#include <Graphic3d_ZLayerId.hxx>
28#include <Graphic3d_ZLayerSettings.hxx>
c357e426 29#include <MMgt_TShared.hxx>
30#include <NCollection_IndexedMap.hxx>
31#include <Standard.hxx>
42cf5bc1 32#include <Standard_Boolean.hxx>
c357e426 33#include <Standard_Integer.hxx>
34#include <Standard_Type.hxx>
42cf5bc1 35#include <TColStd_Array2OfReal.hxx>
c357e426 36#include <TColStd_SequenceOfInteger.hxx>
37
38typedef NCollection_IndexedMap<Graphic3d_CView*> Graphic3d_IndexedMapOfView;
39
42cf5bc1 40class Graphic3d_AspectLine3d;
41class Graphic3d_AspectText3d;
42class Graphic3d_AspectMarker3d;
43class Graphic3d_AspectFillArea3d;
44class Graphic3d_GraphicDriver;
45class Graphic3d_InitialisationError;
46class Graphic3d_Structure;
47class Graphic3d_DataStructureManager;
48class Standard_Transient;
49
42cf5bc1 50class Graphic3d_StructureManager;
51DEFINE_STANDARD_HANDLE(Graphic3d_StructureManager, MMgt_TShared)
52
53//! This class allows the definition of a manager to
54//! which the graphic objects are associated.
55//! It allows them to be globally manipulated.
56//! It defines the global attributes.
57//! Keywords: Structure, Structure Manager, Update Mode,
58//! Destroy, Highlight, Visible
59class Graphic3d_StructureManager : public MMgt_TShared
60{
42cf5bc1 61public:
62
c357e426 63 //! Initializes the ViewManager.
64 //! Currently creating of more than 100 viewer instances
65 //! is not supported and leads to InitializationError and
66 //! initialization failure.
67 //! This limitation might be addressed in some future OCCT releases.
68 //! Warning: Raises InitialisationError if the initialization
69 //! of the ViewManager failed.
70 Standard_EXPORT Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver);
71
42cf5bc1 72 //! Deletes the manager <me>.
73 Standard_EXPORT virtual void Destroy();
74~Graphic3d_StructureManager()
75{
76 Destroy();
77}
c357e426 78
42cf5bc1 79 //! Modifies the default attributes for lines
80 //! in the visualiser.
81 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX);
c357e426 82
42cf5bc1 83 //! Modifies the default attributes for faces
84 //! in the visualiser.
85 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX);
c357e426 86
42cf5bc1 87 //! Modifies the default attributes for text
88 //! in the visualiser.
89 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX);
c357e426 90
42cf5bc1 91 //! Modifies the default attributes for markers
92 //! in the visualiser.
93 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX);
c357e426 94
42cf5bc1 95 //! Modifies the screen update mode.
96 //!
c357e426 97 //! TOU_ASAP - as soon as possible
98 //! TOU_WAIT - on demand (with the Update function)
42cf5bc1 99 //! Note : Dynamic Operations and Update Mode
100 //! Use SetUpdateMode to control when changes to
101 //! the display are made. Use one of the following
102 //! functions to update one or more views:
c357e426 103 //! - Update all views of the viewer: Graphic3d_StructureManager::Update()
104 //! - Update one view of the viewer: Graphic3d_View::Update()
105 //! Use one of the following functions to update the entire display:
106 //! - Redraw all structures in all views: Graphic3d_StructureManager::Redraw()
107 //! - Redraw all structures in one view: Graphic3d_View::Redraw()
108 Standard_EXPORT void SetUpdateMode (const Aspect_TypeOfUpdate theType);
109
110 //! Returns the screen update mode.
111 //!
112 //! TOU_ASAP as soon as possible
113 //! TOU_WAIT on demand (Update)
114 Standard_EXPORT Aspect_TypeOfUpdate UpdateMode() const;
115
116 //! Updates screen in function of modifications of the structures.
117 Standard_EXPORT virtual void Update (const Aspect_TypeOfUpdate theMode = Aspect_TOU_ASAP) const;
118
119 //! Deletes and erases the 3D structure manager.
120 Standard_EXPORT virtual void Remove();
121
122 //! Erases all the structures.
123 Standard_EXPORT virtual void Erase();
124
42cf5bc1 125 //! Returns the set of structures displayed in
126 //! visualiser <me>.
127 Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& SG) const;
c357e426 128
42cf5bc1 129 //! Returns the set of highlighted structures
130 //! in a visualiser <me>.
131 Standard_EXPORT void HighlightedStructures (Graphic3d_MapOfStructure& SG) const;
c357e426 132
42cf5bc1 133 //! Returns the values of the current default attributes.
134 Standard_EXPORT Handle(Graphic3d_AspectFillArea3d) FillArea3dAspect() const;
c357e426 135
42cf5bc1 136 //! Returns maximum number of managers defineable.
137 Standard_EXPORT static Standard_Integer Limit();
c357e426 138
42cf5bc1 139 //! Returns the values of the current default attributes.
140 Standard_EXPORT Handle(Graphic3d_AspectLine3d) Line3dAspect() const;
c357e426 141
42cf5bc1 142 //! Returns the values of the current default attributes.
143 Standard_EXPORT Handle(Graphic3d_AspectMarker3d) Marker3dAspect() const;
c357e426 144
42cf5bc1 145 //! Returns the values of the current default attributes.
146 Standard_EXPORT void PrimitivesAspect (Handle(Graphic3d_AspectLine3d)& CTXL, Handle(Graphic3d_AspectText3d)& CTXT, Handle(Graphic3d_AspectMarker3d)& CTXM, Handle(Graphic3d_AspectFillArea3d)& CTXF) const;
c357e426 147
42cf5bc1 148 //! Returns the values of the current default attributes.
149 Standard_EXPORT Handle(Graphic3d_AspectText3d) Text3dAspect() const;
c357e426 150
42cf5bc1 151 //! Returns a current identifier available.
152 Standard_EXPORT static Standard_Integer CurrentId();
c357e426 153
154 //! Forces a new construction of the structure.
155 //! if <theStructure> is displayed and TOS_COMPUTED.
156 Standard_EXPORT virtual void ReCompute (const Handle(Graphic3d_Structure)& theStructure);
157
158 //! Forces a new construction of the structure.
159 //! if <theStructure> is displayed in <theProjector> and TOS_COMPUTED.
160 Standard_EXPORT virtual void ReCompute (const Handle(Graphic3d_Structure)& theStructure, const Handle(Graphic3d_DataStructureManager)& theProjector);
161
162 //! Clears the structure.
163 Standard_EXPORT virtual void Clear (const Handle(Graphic3d_Structure)& theStructure, const Standard_Boolean theWithDestruction);
164
165 //! Connects the structures.
166 Standard_EXPORT virtual void Connect (const Handle(Graphic3d_Structure)& theMother, const Handle(Graphic3d_Structure)& theDaughter);
167
168 //! Disconnects the structures.
169 Standard_EXPORT virtual void Disconnect (const Handle(Graphic3d_Structure)& theMother, const Handle(Graphic3d_Structure)& theDaughter);
170
171 //! Display the structure.
172 Standard_EXPORT virtual void Display (const Handle(Graphic3d_Structure)& theStructure);
173
174 //! Erases the structure.
175 Standard_EXPORT virtual void Erase (const Handle(Graphic3d_Structure)& theStructure);
176
177 //! Highlights the structure.
178 Standard_EXPORT virtual void Highlight (const Handle(Graphic3d_Structure)& theStructure, const Aspect_TypeOfHighlightMethod theMethod);
179
180 //! Transforms the structure.
181 Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const TColStd_Array2OfReal& theTrsf);
182
183 //! Changes the display priority of the structure <AStructure>.
184 Standard_EXPORT virtual void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStructure, const Standard_Integer theOldPriority, const Standard_Integer theNewPriority);
185
186 //! Change Z layer for structure. The Z layer mechanism allows to display structures in higher
187 //! layers in overlay of structures in lower layers.
188 Standard_EXPORT virtual void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, const Graphic3d_ZLayerId theLayerId);
189
42cf5bc1 190 //! Returns the graphic driver of <me>.
191 Standard_EXPORT const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const;
c357e426 192
193 //! Attaches the view to this structure manager and sets its identification number within the manager.
194 Standard_EXPORT Standard_Integer Identification (Graphic3d_CView* theView);
195
196 //! Detach the view from this structure manager and release its identification.
197 Standard_EXPORT void UnIdentification (Graphic3d_CView* theView);
198
199 //! Returns the group of views defined in the structure manager.
200 Standard_EXPORT const Graphic3d_IndexedMapOfView& DefinedViews() const;
201
202 //! Returns the theoretical maximum number of definable views in the manager.
203 //! Warning: It's not possible to accept an infinite number of definable views because each
204 //! view must have an identification and we have different managers.
205 Standard_EXPORT Standard_Integer MaxNumOfViews() const;
206
42cf5bc1 207 //! Returns the identification number of the manager.
208 Standard_EXPORT virtual Standard_Integer Identification() const;
c357e426 209
42cf5bc1 210 //! Returns the structure with the identification number <AId>.
211 Standard_EXPORT virtual Handle(Graphic3d_Structure) Identification (const Standard_Integer AId) const;
c357e426 212
42cf5bc1 213 //! Returns a new identification number for a new structure in the manager.
214 Standard_EXPORT Standard_Integer NewIdentification();
c357e426 215
42cf5bc1 216 //! Suppress the highlighting on the structure <AStructure>.
c357e426 217 Standard_EXPORT virtual void UnHighlight (const Handle(Graphic3d_Structure)& AStructure);
218
219 //! Suppresses the highlighting on all the structures in <me>.
220 Standard_EXPORT virtual void UnHighlight();
221
42cf5bc1 222 Standard_EXPORT void RecomputeStructures();
c357e426 223
42cf5bc1 224 //! Recomputes all structures from theStructures.
225 Standard_EXPORT void RecomputeStructures (const Graphic3d_MapOfStructure& theStructures);
c357e426 226
42cf5bc1 227 Standard_EXPORT Handle(Graphic3d_ViewAffinity) RegisterObject (const Handle(Standard_Transient)& theObject);
c357e426 228
42cf5bc1 229 Standard_EXPORT void UnregisterObject (const Handle(Standard_Transient)& theObject);
42cf5bc1 230
c357e426 231 Standard_EXPORT Handle(Graphic3d_ViewAffinity) ObjectAffinity (const Handle(Standard_Transient)& theObject) const;
42cf5bc1 232
c357e426 233 friend class Graphic3d_Structure;
42cf5bc1 234
235 DEFINE_STANDARD_RTTI(Graphic3d_StructureManager,MMgt_TShared)
236
237protected:
238
42cf5bc1 239 //! Returns the number of structures displayed in
c357e426 240 //! visualizer <me>.
241 //! Returns the structure displayed in visualizer <me>.
42cf5bc1 242 Standard_EXPORT Standard_Integer NumberOfDisplayedStructures() const;
243
42cf5bc1 244private:
245
c357e426 246 //! Frees the identifier of a structure.
247 void Remove (const Standard_Integer theId);
42cf5bc1 248
c357e426 249protected:
42cf5bc1 250
c357e426 251 Standard_Integer myId;
252 Aspect_GenId myStructGenId;
253 Aspect_GenId myViewGenId;
254 Aspect_TypeOfUpdate myUpdateMode;
255 Handle(Graphic3d_AspectLine3d) myAspectLine3d;
256 Handle(Graphic3d_AspectText3d) myAspectText3d;
257 Handle(Graphic3d_AspectMarker3d) myAspectMarker3d;
258 Handle(Graphic3d_AspectFillArea3d) myAspectFillArea3d;
259 Graphic3d_MapOfStructure myDisplayedStructure;
260 Graphic3d_MapOfStructure myHighlightedStructure;
261 Graphic3d_MapOfObject myRegisteredObjects;
262 Handle(Graphic3d_GraphicDriver) myGraphicDriver;
263 Graphic3d_IndexedMapOfView myDefinedViews;
42cf5bc1 264};
265
42cf5bc1 266#endif // _Graphic3d_StructureManager_HeaderFile