c357e426 |
1 | // Copyright (c) 2015 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | #ifndef _Graphic3d_CView_HeaderFile |
15 | #define _Graphic3d_CView_HeaderFile |
16 | |
c357e426 |
17 | #include <Aspect_RenderingContext.hxx> |
16a263dc |
18 | #include <Aspect_SkydomeBackground.hxx> |
c357e426 |
19 | #include <Aspect_Window.hxx> |
20 | #include <Graphic3d_BufferType.hxx> |
077a220c |
21 | #include <Graphic3d_CubeMap.hxx> |
c357e426 |
22 | #include <Graphic3d_DataStructureManager.hxx> |
26d9c835 |
23 | #include <Graphic3d_DiagnosticInfo.hxx> |
c357e426 |
24 | #include <Graphic3d_GraduatedTrihedron.hxx> |
c357e426 |
25 | #include <Graphic3d_NMapOfTransient.hxx> |
c357e426 |
26 | #include <Graphic3d_RenderingParams.hxx> |
c357e426 |
27 | #include <Graphic3d_SequenceOfStructure.hxx> |
c357e426 |
28 | #include <Graphic3d_Structure.hxx> |
c357e426 |
29 | #include <Graphic3d_TextureEnv.hxx> |
30 | #include <Graphic3d_TypeOfAnswer.hxx> |
31 | #include <Graphic3d_TypeOfBackfacingModel.hxx> |
3e9cb806 |
32 | #include <Graphic3d_TypeOfBackground.hxx> |
c357e426 |
33 | #include <Graphic3d_TypeOfShadingModel.hxx> |
c357e426 |
34 | #include <Graphic3d_TypeOfVisualization.hxx> |
35 | #include <Graphic3d_Vec3.hxx> |
36 | #include <Graphic3d_ZLayerId.hxx> |
37 | #include <Graphic3d_ZLayerSettings.hxx> |
38 | #include <Image_PixMap.hxx> |
c357e426 |
39 | #include <Standard_Transient.hxx> |
26d9c835 |
40 | #include <TColStd_IndexedDataMapOfStringString.hxx> |
c357e426 |
41 | |
879768fb |
42 | class Aspect_NeutralWindow; |
b40cdc2b |
43 | class Aspect_XRSession; |
c357e426 |
44 | class Graphic3d_CView; |
1c728f2d |
45 | class Graphic3d_Layer; |
c357e426 |
46 | class Graphic3d_StructureManager; |
47 | |
48 | DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager) |
49 | |
50 | //! Base class of a graphical view that carries out rendering process for a concrete |
51 | //! implementation of graphical driver. Provides virtual interfaces for redrawing its |
52 | //! contents, management of displayed structures and render settings. The source code |
53 | //! of the class itself implements functionality related to management of |
54 | //! computed (HLR or "view-dependent") structures. |
55 | class Graphic3d_CView : public Graphic3d_DataStructureManager |
bf75be98 |
56 | { |
dc89236f |
57 | friend class Graphic3d_StructureManager; |
58 | DEFINE_STANDARD_RTTIEXT(Graphic3d_CView, Graphic3d_DataStructureManager) |
bf75be98 |
59 | public: |
60 | |
c357e426 |
61 | //! Constructor. |
62 | Standard_EXPORT Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theMgr); |
63 | |
64 | //! Destructor. |
65 | Standard_EXPORT virtual ~Graphic3d_CView(); |
66 | |
67 | //! Returns the identification number of the view. |
68 | Standard_Integer Identification() const { return myId; } |
69 | |
46710942 |
70 | //! Activates the view. Maps presentations defined within structure manager onto this view. |
c357e426 |
71 | Standard_EXPORT virtual void Activate(); |
72 | |
46710942 |
73 | //! Deactivates the view. Unmaps presentations defined within structure manager. |
74 | //! The view in deactivated state will ignore actions on structures such as Display(). |
c357e426 |
75 | Standard_EXPORT virtual void Deactivate(); |
76 | |
77 | //! Returns the activity flag of the view. |
78 | Standard_Boolean IsActive() const { return myIsActive; } |
79 | |
80 | //! Erases the view and removes from graphic driver. |
81 | //! No more graphic operations are allowed in this view after the call. |
82 | Standard_EXPORT virtual void Remove(); |
83 | |
84 | //! Returns true if the view was removed. |
85 | Standard_Boolean IsRemoved() const { return myIsRemoved; } |
bf75be98 |
86 | |
d325cb7f |
87 | //! Returns camera object of the view. |
b5163d2f |
88 | virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; } |
d325cb7f |
89 | |
90 | //! Sets camera used by the view. |
91 | virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; } |
92 | |
bf75be98 |
93 | public: |
94 | |
13b36bb1 |
95 | //! Returns default Shading Model of the view; Graphic3d_TypeOfShadingModel_Phong by default. |
114db5a5 |
96 | Graphic3d_TypeOfShadingModel ShadingModel() const { return myRenderParams.ShadingModel; } |
dc89236f |
97 | |
98 | //! Sets default Shading Model of the view. |
13b36bb1 |
99 | //! Will throw an exception on attempt to set Graphic3d_TypeOfShadingModel_DEFAULT. |
dc89236f |
100 | Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel); |
101 | |
7fd4958d |
102 | //! Return backfacing model used for the view; Graphic3d_TypeOfBackfacingModel_Auto by default, |
103 | //! which means that backface culling is defined by each presentation. |
104 | Graphic3d_TypeOfBackfacingModel BackfacingModel() const { return myBackfacing; } |
105 | |
106 | //! Sets backfacing model for the view. |
107 | void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) { myBackfacing = theModel; } |
108 | |
c357e426 |
109 | //! Returns visualization type of the view. |
110 | Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; } |
bf75be98 |
111 | |
c357e426 |
112 | //! Sets visualization type of the view. |
113 | void SetVisualizationType (const Graphic3d_TypeOfVisualization theType) { myVisualization = theType; } |
bf75be98 |
114 | |
c357e426 |
115 | //! Switches computed HLR mode in the view |
116 | Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode); |
bf75be98 |
117 | |
c357e426 |
118 | //! Returns the computed HLR mode state |
119 | Standard_Boolean ComputedMode() const { return myIsInComputedMode; } |
bf75be98 |
120 | |
c357e426 |
121 | //! Computes the new presentation of the structure displayed in this view with the type Graphic3d_TOS_COMPUTED. |
122 | Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& theStructure); |
bf75be98 |
123 | |
cfece3ef |
124 | //! Invalidates bounding box of specified ZLayerId. |
125 | Standard_EXPORT void Update (const Graphic3d_ZLayerId theLayerId = Graphic3d_ZLayerId_UNKNOWN); |
126 | |
127 | //! Computes the new presentation of the structures displayed in this view with the type Graphic3d_TOS_COMPUTED. |
128 | Standard_EXPORT void Compute(); |
bf75be98 |
129 | |
c357e426 |
130 | //! Returns the set of structures displayed in this view. |
131 | Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const; |
b5ac8292 |
132 | |
c357e426 |
133 | //! Returns number of displayed structures in the view. |
91515621 |
134 | virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); } |
bf75be98 |
135 | |
c357e426 |
136 | //! Returns Standard_True in case if the structure with the given <theStructId> is |
137 | //! in list of structures to be computed and stores computed struct to <theComputedStruct>. |
138 | Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId, |
139 | Handle(Graphic3d_Structure)& theComputedStruct) const; |
140 | |
50d06d8f |
141 | //! Returns the bounding box of all structures displayed in the view. |
3fe9ce0e |
142 | //! If theToIncludeAuxiliary is TRUE, then the boundary box also includes minimum and maximum limits |
143 | //! of graphical elements forming parts of infinite and other auxiliary structures. |
144 | //! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence) |
145 | //! @return computed bounding box |
91515621 |
146 | Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary = Standard_False) const; |
c357e426 |
147 | |
148 | //! Returns the coordinates of the boundary box of all structures in the set <theSet>. |
149 | //! If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box |
150 | //! also includes minimum and maximum limits of graphical elements |
151 | //! forming parts of infinite structures. |
152 | Standard_EXPORT Bnd_Box MinMaxValues (const Graphic3d_MapOfStructure& theSet, |
3fe9ce0e |
153 | const Standard_Boolean theToIncludeAuxiliary = Standard_False) const; |
c357e426 |
154 | |
155 | //! Returns the structure manager handle which manage structures associated with this view. |
156 | const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; } |
157 | |
158 | private: |
159 | |
c357e426 |
160 | //! Is it possible to display the structure in the view? |
161 | Standard_EXPORT Graphic3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const; |
162 | |
c357e426 |
163 | //! Clears the structure in this view. |
7dd7c146 |
164 | Standard_EXPORT void Clear (Graphic3d_Structure* theStructure, |
165 | const Standard_Boolean theWithDestruction); |
c357e426 |
166 | |
167 | //! Connects the structures. |
7dd7c146 |
168 | Standard_EXPORT void Connect (const Graphic3d_Structure* theMother, |
169 | const Graphic3d_Structure* theDaughter); |
c357e426 |
170 | |
171 | //! Disconnects the structures. |
7dd7c146 |
172 | Standard_EXPORT void Disconnect (const Graphic3d_Structure* theMother, |
173 | const Graphic3d_Structure* theDaughter); |
c357e426 |
174 | |
175 | //! Displays the structure in the view. |
176 | Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& theStructure); |
177 | |
c357e426 |
178 | //! Erases the structure from the view. |
179 | Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& theStructure); |
180 | |
c357e426 |
181 | //! Highlights the structure in the view. |
8e5fb5ea |
182 | Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure); |
c357e426 |
183 | |
184 | //! Transforms the structure in the view. |
185 | Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure, |
7f24b768 |
186 | const Handle(TopLoc_Datum3D)& theTrsf); |
c357e426 |
187 | |
188 | //! Suppress the highlighting on the structure <AStructure> |
189 | //! in the view <me>. |
190 | Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& theStructure); |
191 | |
192 | //! Returns an index != 0 if the structure have another structure computed for the view <me>. |
7dd7c146 |
193 | Standard_EXPORT Standard_Integer IsComputed (const Graphic3d_Structure* theStructure) const; |
194 | |
195 | Standard_Integer IsComputed (const Handle(Graphic3d_Structure)& theStructure) const { return IsComputed (theStructure.get()); } |
c357e426 |
196 | |
197 | //! Returns true if the structure is displayed in the view. |
198 | Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(Graphic3d_Structure)& theStructure) const; |
199 | |
200 | //! Changes the display priority of the structure. |
201 | Standard_EXPORT void ChangePriority (const Handle(Graphic3d_Structure)& theStructure, |
e463b2f6 |
202 | const Graphic3d_DisplayPriority theOldPriority, |
203 | const Graphic3d_DisplayPriority theNewPriority); |
c357e426 |
204 | |
205 | //! Change Z layer of already displayed structure in the view. |
206 | Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, |
207 | const Graphic3d_ZLayerId theLayerId); |
208 | |
209 | //! Returns an index != 0 if the structure have the same owner than another structure |
210 | //! in the sequence of the computed structures. |
211 | Standard_EXPORT Standard_Integer HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStructure) const; |
bf75be98 |
212 | |
213 | public: |
214 | |
c357e426 |
215 | //! Redraw content of the view. |
216 | virtual void Redraw() = 0; |
217 | |
218 | //! Redraw immediate content of the view. |
219 | virtual void RedrawImmediate() = 0; |
220 | |
221 | //! Invalidates content of the view but does not redraw it. |
222 | virtual void Invalidate() = 0; |
223 | |
224 | //! Return true if view content cache has been invalidated. |
225 | virtual Standard_Boolean IsInvalidated() = 0; |
226 | |
227 | //! Handle changing size of the rendering window. |
879768fb |
228 | Standard_EXPORT virtual void Resized() = 0; |
c357e426 |
229 | |
230 | //! @param theDrawToFrontBuffer Advanced option to modify rendering mode: |
231 | //! 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image. |
232 | //! Fast, so preferred for interactive work (used by default). |
233 | //! However these extra drawings will be missed in image dump since it is performed from back buffer. |
234 | //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen |
235 | //! in run-time (in case of slow hardware) and/or tearing may appear. |
236 | //! So this is strongly recommended to draw only simple (fast) structures. |
237 | //! 2. FALSE. Drawing immediate mode structures to the back buffer. |
238 | //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync |
239 | //! is turned on. But it works in any case and is especially useful for view dump because the dump image is read |
240 | //! from the back buffer. |
241 | //! @return previous mode. |
242 | virtual Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) = 0; |
243 | |
244 | //! Creates and maps rendering window to the view. |
879768fb |
245 | //! @param[in] theParentVIew parent view or NULL |
246 | //! @param[in] theWindow the window |
247 | //! @param[in] theContext the rendering context; if NULL the context will be created internally |
248 | virtual void SetWindow (const Handle(Graphic3d_CView)& theParentVIew, |
249 | const Handle(Aspect_Window)& theWindow, |
250 | const Aspect_RenderingContext theContext) = 0; |
c357e426 |
251 | |
252 | //! Returns the window associated to the view. |
253 | virtual Handle(Aspect_Window) Window() const = 0; |
254 | |
255 | //! Returns True if the window associated to the view is defined. |
256 | virtual Standard_Boolean IsDefined() const = 0; |
257 | |
c357e426 |
258 | //! Dump active rendering buffer into specified memory buffer. |
259 | virtual Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0; |
260 | |
c357e426 |
261 | //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated. |
8f138407 |
262 | virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) = 0; |
c357e426 |
263 | |
1c728f2d |
264 | //! Add a layer to the view. |
265 | //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers). |
266 | //! @param theSettings [in] new layer settings |
267 | //! @param theLayerAfter [in] id of layer to append new layer before |
268 | virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId, |
269 | const Graphic3d_ZLayerSettings& theSettings, |
270 | const Graphic3d_ZLayerId theLayerAfter) = 0; |
271 | |
272 | //! Add a layer to the view. |
273 | //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers). |
274 | //! @param theSettings [in] new layer settings |
275 | //! @param theLayerBefore [in] id of layer to append new layer after |
276 | virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId, |
277 | const Graphic3d_ZLayerSettings& theSettings, |
278 | const Graphic3d_ZLayerId theLayerBefore) = 0; |
c357e426 |
279 | |
50d06d8f |
280 | //! Returns the maximum Z layer ID. |
281 | //! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax(). |
282 | virtual Standard_Integer ZLayerMax() const = 0; |
283 | |
1c728f2d |
284 | //! Returns the list of layers. |
285 | virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0; |
286 | |
287 | //! Returns layer with given ID or NULL if undefined. |
288 | virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0; |
50d06d8f |
289 | |
290 | //! Returns the bounding box of all structures displayed in the Z layer. |
1c728f2d |
291 | Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId); |
50d06d8f |
292 | |
c357e426 |
293 | //! Remove Z layer from the specified view. All structures |
294 | //! displayed at the moment in layer will be displayed in default layer |
295 | //! ( the bottom-level z layer ). To unset layer ID from associated |
296 | //! structures use method UnsetZLayer (...). |
297 | virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0; |
298 | |
299 | //! Sets the settings for a single Z layer of specified view. |
300 | virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, |
301 | const Graphic3d_ZLayerSettings& theSettings) = 0; |
302 | |
50d06d8f |
303 | //! Returns zoom-scale factor. |
304 | Standard_EXPORT Standard_Real ConsiderZoomPersistenceObjects(); |
305 | |
c357e426 |
306 | //! Returns pointer to an assigned framebuffer object. |
b128c892 |
307 | virtual Handle(Standard_Transient) FBO() const = 0; |
c357e426 |
308 | |
309 | //! Sets framebuffer object for offscreen rendering. |
b128c892 |
310 | virtual void SetFBO (const Handle(Standard_Transient)& theFbo) = 0; |
c357e426 |
311 | |
312 | //! Generate offscreen FBO in the graphic library. |
313 | //! If not supported on hardware returns NULL. |
b128c892 |
314 | virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth, |
315 | const Standard_Integer theHeight) = 0; |
c357e426 |
316 | |
317 | //! Remove offscreen FBO from the graphic library |
b128c892 |
318 | virtual void FBORelease (Handle(Standard_Transient)& theFbo) = 0; |
c357e426 |
319 | |
320 | //! Read offscreen FBO configuration. |
b128c892 |
321 | virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo, |
c357e426 |
322 | Standard_Integer& theWidth, |
323 | Standard_Integer& theHeight, |
324 | Standard_Integer& theWidthMax, |
325 | Standard_Integer& theHeightMax) = 0; |
326 | |
327 | //! Change offscreen FBO viewport. |
b128c892 |
328 | virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo, |
c357e426 |
329 | const Standard_Integer theWidth, |
330 | const Standard_Integer theHeight) = 0; |
bf75be98 |
331 | |
332 | public: |
333 | |
c357e426 |
334 | //! Copy visualization settings from another view. |
335 | //! Method is used for cloning views in viewer when its required to create view |
336 | //! with same view properties. |
337 | Standard_EXPORT virtual void CopySettings (const Handle(Graphic3d_CView)& theOther); |
338 | |
339 | //! Returns current rendering parameters and effect settings. |
340 | const Graphic3d_RenderingParams& RenderingParams() const { return myRenderParams; } |
341 | |
342 | //! Returns reference to current rendering parameters and effect settings. |
343 | Graphic3d_RenderingParams& ChangeRenderingParams() { return myRenderParams; } |
344 | |
3e9cb806 |
345 | public: |
346 | |
c357e426 |
347 | //! Returns background fill color. |
d325cb7f |
348 | virtual Aspect_Background Background() const { return Aspect_Background (myBgColor.GetRGB()); } |
c357e426 |
349 | |
350 | //! Sets background fill color. |
d325cb7f |
351 | virtual void SetBackground (const Aspect_Background& theBackground) { myBgColor.SetRGB (theBackground.Color()); } |
c357e426 |
352 | |
353 | //! Returns gradient background fill colors. |
354 | virtual Aspect_GradientBackground GradientBackground() const = 0; |
355 | |
356 | //! Sets gradient background fill colors. |
357 | virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) = 0; |
358 | |
99289bed |
359 | //! Returns background image texture map. |
3e9cb806 |
360 | const Handle(Graphic3d_TextureMap)& BackgroundImage() { return myBackgroundImage; } |
361 | |
362 | //! Returns cubemap being set last time on background. |
363 | const Handle(Graphic3d_CubeMap)& BackgroundCubeMap() const { return myCubeMapBackground; } |
364 | |
365 | //! Returns cubemap being set last time on background. |
366 | const Handle(Graphic3d_CubeMap)& IBLCubeMap() const { return myCubeMapIBL; } |
c357e426 |
367 | |
54adc5e9 |
368 | //! Sets image texture or environment cubemap as background. |
99289bed |
369 | //! @param theTextureMap [in] source to set a background; |
370 | //! should be either Graphic3d_Texture2D or Graphic3d_CubeMap |
371 | //! @param theToUpdatePBREnv [in] defines whether IBL maps will be generated or not |
372 | //! (see GeneratePBREnvironment()) |
373 | virtual void SetBackgroundImage (const Handle(Graphic3d_TextureMap)& theTextureMap, |
374 | Standard_Boolean theToUpdatePBREnv = Standard_True) = 0; |
c357e426 |
375 | |
376 | //! Returns background image fill style. |
377 | virtual Aspect_FillMethod BackgroundImageStyle() const = 0; |
378 | |
379 | //! Sets background image fill style. |
380 | virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0; |
381 | |
3e9cb806 |
382 | //! Returns background type. |
383 | Graphic3d_TypeOfBackground BackgroundType() const { return myBackgroundType; } |
077a220c |
384 | |
3e9cb806 |
385 | //! Sets background type. |
386 | void SetBackgroundType (Graphic3d_TypeOfBackground theType) { myBackgroundType = theType; } |
67312b79 |
387 | |
16a263dc |
388 | //! Returns skydome aspect; |
389 | const Aspect_SkydomeBackground& BackgroundSkydome() const { return mySkydomeAspect; } |
390 | |
391 | //! Sets skydome aspect |
392 | Standard_EXPORT void SetBackgroundSkydome (const Aspect_SkydomeBackground& theAspect, |
393 | Standard_Boolean theToUpdatePBREnv = Standard_True); |
394 | |
3e9cb806 |
395 | //! Enables or disables IBL (Image Based Lighting) from background cubemap. |
396 | //! Has no effect if PBR is not used. |
397 | //! @param[in] theToEnableIBL enable or disable IBL from background cubemap |
3e9cb806 |
398 | virtual void SetImageBasedLighting (Standard_Boolean theToEnableIBL) = 0; |
077a220c |
399 | |
c357e426 |
400 | //! Returns environment texture set for the view. |
3e9cb806 |
401 | const Handle(Graphic3d_TextureEnv)& TextureEnv() const { return myTextureEnvData; } |
c357e426 |
402 | |
403 | //! Sets environment texture for the view. |
404 | virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0; |
405 | |
3e9cb806 |
406 | public: |
407 | |
c357e426 |
408 | //! Returns list of lights of the view. |
992ed6b3 |
409 | virtual const Handle(Graphic3d_LightSet)& Lights() const = 0; |
c357e426 |
410 | |
411 | //! Sets list of lights for the view. |
992ed6b3 |
412 | virtual void SetLights (const Handle(Graphic3d_LightSet)& theLights) = 0; |
c357e426 |
413 | |
414 | //! Returns list of clip planes set for the view. |
3202bf1e |
415 | virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const = 0; |
c357e426 |
416 | |
417 | //! Sets list of clip planes for the view. |
3202bf1e |
418 | virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) = 0; |
c357e426 |
419 | |
26d9c835 |
420 | //! Fill in the dictionary with diagnostic info. |
421 | //! Should be called within rendering thread. |
422 | //! |
423 | //! This API should be used only for user output or for creating automated reports. |
424 | //! The format of returned information (e.g. key-value layout) |
425 | //! is NOT part of this API and can be changed at any time. |
426 | //! Thus application should not parse returned information to weed out specific parameters. |
b40cdc2b |
427 | Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict, |
428 | Graphic3d_DiagnosticInfo theFlags) const = 0; |
26d9c835 |
429 | |
79b544e6 |
430 | //! Returns string with statistic performance info. |
431 | virtual TCollection_AsciiString StatisticInformation() const = 0; |
432 | |
433 | //! Fills in the dictionary with statistic performance info. |
434 | virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const = 0; |
435 | |
b40cdc2b |
436 | public: |
437 | |
438 | //! Return unit scale factor defined as scale factor for m (meters); 1.0 by default. |
439 | //! Normally, view definition is unitless, however some operations like VR input requires proper units mapping. |
440 | Standard_Real UnitFactor() const { return myUnitFactor; } |
441 | |
442 | //! Set unit scale factor. |
443 | Standard_EXPORT void SetUnitFactor (Standard_Real theFactor); |
444 | |
445 | //! Return XR session. |
446 | const Handle(Aspect_XRSession)& XRSession() const { return myXRSession; } |
447 | |
448 | //! Set XR session. |
449 | void SetXRSession (const Handle(Aspect_XRSession)& theSession) { myXRSession = theSession; } |
450 | |
451 | //! Return TRUE if there is active XR session. |
452 | Standard_EXPORT bool IsActiveXR() const; |
453 | |
454 | //! Initialize XR session. |
455 | Standard_EXPORT virtual bool InitXR(); |
456 | |
457 | //! Release XR session. |
458 | Standard_EXPORT virtual void ReleaseXR(); |
459 | |
460 | //! Process input. |
461 | Standard_EXPORT virtual void ProcessXRInput(); |
462 | |
463 | //! Compute PosedXRCamera() based on current XR head pose and make it active. |
464 | Standard_EXPORT void SetupXRPosedCamera(); |
465 | |
466 | //! Set current camera back to BaseXRCamera() and copy temporary modifications of PosedXRCamera(). |
467 | //! Calls SynchronizeXRPosedToBaseCamera() beforehand. |
468 | Standard_EXPORT void UnsetXRPosedCamera(); |
469 | |
470 | //! Returns transient XR camera position with tracked head orientation applied. |
471 | const Handle(Graphic3d_Camera)& PosedXRCamera() const { return myPosedXRCamera; } |
472 | |
473 | //! Sets transient XR camera position with tracked head orientation applied. |
474 | void SetPosedXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myPosedXRCamera = theCamera; } |
475 | |
476 | //! Returns anchor camera definition (without tracked head orientation). |
477 | const Handle(Graphic3d_Camera)& BaseXRCamera() const { return myBaseXRCamera; } |
478 | |
479 | //! Sets anchor camera definition. |
480 | void SetBaseXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myBaseXRCamera = theCamera; } |
481 | |
482 | //! Convert XR pose to world space. |
807340d9 |
483 | //! @param thePoseXR [in] transformation defined in VR local coordinate system, |
b40cdc2b |
484 | //! oriented as Y-up, X-right and -Z-forward |
485 | //! @return transformation defining orientation of XR pose in world space |
486 | gp_Trsf PoseXRToWorld (const gp_Trsf& thePoseXR) const |
487 | { |
488 | const Handle(Graphic3d_Camera)& anOrigin = myBaseXRCamera; |
489 | const gp_Ax3 anAxVr (gp::Origin(), gp::DZ(), gp::DX()); |
490 | const gp_Ax3 aCameraCS (anOrigin->Eye().XYZ(), -anOrigin->Direction(), -anOrigin->SideRight()); |
491 | gp_Trsf aTrsfCS; |
492 | aTrsfCS.SetTransformation (aCameraCS, anAxVr); |
493 | return aTrsfCS * thePoseXR; |
494 | } |
495 | |
807340d9 |
496 | //! Returns view direction in the world space based on XR pose. |
497 | //! @param thePoseXR [in] transformation defined in VR local coordinate system, |
498 | //! oriented as Y-up, X-right and -Z-forward |
499 | gp_Ax1 ViewAxisInWorld (const gp_Trsf& thePoseXR) const |
500 | { |
501 | return gp_Ax1 (gp::Origin(), -gp::DZ()).Transformed (PoseXRToWorld (thePoseXR)); |
502 | } |
503 | |
b40cdc2b |
504 | //! Recomputes PosedXRCamera() based on BaseXRCamera() and head orientation. |
505 | Standard_EXPORT void SynchronizeXRBaseToPosedCamera(); |
506 | |
507 | //! Checks if PosedXRCamera() has been modified since SetupXRPosedCamera() |
508 | //! and copies these modifications to BaseXRCamera(). |
509 | Standard_EXPORT void SynchronizeXRPosedToBaseCamera(); |
510 | |
511 | //! Compute camera position based on XR pose. |
512 | Standard_EXPORT void ComputeXRPosedCameraFromBase (Graphic3d_Camera& theCam, |
513 | const gp_Trsf& theXRTrsf) const; |
514 | |
515 | //! Update based camera from posed camera by applying reversed transformation. |
516 | Standard_EXPORT void ComputeXRBaseCameraFromPosed (const Graphic3d_Camera& theCamPosed, |
517 | const gp_Trsf& thePoseTrsf); |
518 | |
519 | //! Turn XR camera direction using current (head) eye position as anchor. |
520 | Standard_EXPORT void TurnViewXRCamera (const gp_Trsf& theTrsfTurn); |
521 | |
d325cb7f |
522 | public: //! @name obsolete Graduated Trihedron functionality |
523 | |
524 | //! Returns data of a graduated trihedron |
525 | virtual const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() { return myGTrihedronData; } |
526 | |
527 | //! Displays Graduated Trihedron. |
528 | virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) { (void )theTrihedronData; } |
529 | |
530 | //! Erases Graduated Trihedron. |
531 | virtual void GraduatedTrihedronErase() {} |
532 | |
533 | //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object. |
534 | //! @param theMin [in] the minimum point of scene. |
535 | //! @param theMax [in] the maximum point of scene. |
536 | virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) |
537 | { |
538 | (void )theMin; |
539 | (void )theMax; |
540 | } |
a5162275 |
541 | |
542 | //! Dumps the content of me into the stream |
543 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
d325cb7f |
544 | |
879768fb |
545 | public: //! @name subview properties |
546 | |
547 | //! Return TRUE if this is a subview of another view. |
548 | bool IsSubview() const { return myParentView != nullptr; } |
549 | |
550 | //! Return parent View or NULL if this is not a subview. |
551 | Graphic3d_CView* ParentView() { return myParentView; } |
552 | |
553 | //! Return TRUE if this is view performs rendering of subviews and nothing else; FALSE by default. |
554 | //! By default, view with subviews will render main scene and blit subviews on top of it. |
555 | //! Rendering of main scene might become redundant in case if subviews cover entire window of parent view. |
556 | //! This flag allows to disable rendering of the main scene in such scenarios |
557 | //! without creation of a dedicated V3d_Viewer instance just for composing subviews. |
558 | bool IsSubviewComposer() const { return myIsSubviewComposer; } |
559 | |
560 | //! Set if this view should perform composing of subviews and nothing else. |
561 | void SetSubviewComposer (bool theIsComposer) { myIsSubviewComposer = theIsComposer; } |
562 | |
563 | //! Return subview list. |
564 | const NCollection_Sequence<Handle(Graphic3d_CView)>& Subviews() const { return mySubviews; } |
565 | |
566 | //! Add subview to the list. |
567 | Standard_EXPORT void AddSubview (const Handle(Graphic3d_CView)& theView); |
568 | |
569 | //! Remove subview from the list. |
570 | Standard_EXPORT bool RemoveSubview (const Graphic3d_CView* theView); |
571 | |
572 | //! Return subview position within parent view; Aspect_TOTP_LEFT_UPPER by default. |
573 | Aspect_TypeOfTriedronPosition SubviewCorner() const { return mySubviewCorner; } |
574 | |
575 | //! Set subview position within parent view. |
576 | void SetSubviewCorner (Aspect_TypeOfTriedronPosition thePos) { mySubviewCorner = thePos; } |
577 | |
578 | //! Return subview top-left position relative to parent view in pixels. |
579 | const Graphic3d_Vec2i& SubviewTopLeft() const { return mySubviewTopLeft; } |
580 | |
581 | //! Return TRUE if subview size is set as proportions relative to parent view. |
582 | bool IsSubViewRelativeSize() const { return mySubviewSize.x() <= 1.0 && mySubviewSize.y() <= 1.0; } |
583 | |
584 | //! Return subview dimensions; (1.0, 1.0) by default. |
585 | //! Values >= 2 define size in pixels; |
586 | //! Values <= 1.0 define size as fraction of parent view. |
587 | const Graphic3d_Vec2d& SubviewSize() const { return mySubviewSize; } |
588 | |
589 | //! Set subview size relative to parent view. |
590 | void SetSubviewSize (const Graphic3d_Vec2d& theSize) { mySubviewSize = theSize; } |
591 | |
592 | //! Return corner offset within parent view; (0.0,0.0) by default. |
593 | //! Values >= 2 define offset in pixels; |
594 | //! Values <= 1.0 define offset as fraction of parent view dimensions. |
595 | const Graphic3d_Vec2d& SubviewOffset() const { return mySubviewOffset; } |
596 | |
597 | //! Set corner offset within parent view. |
598 | void SetSubviewOffset (const Graphic3d_Vec2d& theOffset) { mySubviewOffset = theOffset; } |
599 | |
600 | //! Return subview margins in pixels; (0,0) by default |
601 | const Graphic3d_Vec2i& SubviewMargins() const { return mySubviewMargins; } |
602 | |
603 | //! Set subview margins in pixels. |
604 | void SetSubviewMargins (const Graphic3d_Vec2i& theMargins) { mySubviewMargins = theMargins; } |
605 | |
606 | //! Update subview position and dimensions. |
607 | Standard_EXPORT void SubviewResized (const Handle(Aspect_NeutralWindow)& theWindow); |
608 | |
c357e426 |
609 | private: |
610 | |
611 | //! Adds the structure to display lists of the view. |
612 | virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure, |
e463b2f6 |
613 | const Graphic3d_DisplayPriority thePriority) = 0; |
c357e426 |
614 | |
615 | //! Erases the structure from display lists of the view. |
616 | virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) = 0; |
617 | |
618 | //! Change Z layer of a structure already presented in view. |
619 | virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure, |
620 | const Graphic3d_ZLayerId theNewLayerId) = 0; |
621 | |
622 | //! Changes the priority of a structure within its Z layer in the specified view. |
623 | virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure, |
e463b2f6 |
624 | const Graphic3d_DisplayPriority theNewPriority) = 0; |
c357e426 |
625 | |
c357e426 |
626 | protected: |
627 | |
628 | Standard_Integer myId; |
629 | Graphic3d_RenderingParams myRenderParams; |
3e9cb806 |
630 | |
879768fb |
631 | NCollection_Sequence<Handle(Graphic3d_CView)> mySubviews; //!< list of child views |
632 | Graphic3d_CView* myParentView; //!< back-pointer to the parent view |
633 | Standard_Boolean myIsSubviewComposer; //!< flag to skip rendering of viewer contents |
634 | Aspect_TypeOfTriedronPosition mySubviewCorner; //!< position within parent view |
635 | Graphic3d_Vec2i mySubviewTopLeft; //!< subview top-left position relative to parent view |
636 | Graphic3d_Vec2i mySubviewMargins; //!< subview margins in pixels |
637 | Graphic3d_Vec2d mySubviewSize; //!< subview size |
638 | Graphic3d_Vec2d mySubviewOffset; //!< subview corner offset within parent view |
3e9cb806 |
639 | |
c357e426 |
640 | Handle(Graphic3d_StructureManager) myStructureManager; |
d325cb7f |
641 | Handle(Graphic3d_Camera) myCamera; |
c357e426 |
642 | Graphic3d_SequenceOfStructure myStructsToCompute; |
643 | Graphic3d_SequenceOfStructure myStructsComputed; |
644 | Graphic3d_MapOfStructure myStructsDisplayed; |
c357e426 |
645 | Standard_Boolean myIsInComputedMode; |
646 | Standard_Boolean myIsActive; |
647 | Standard_Boolean myIsRemoved; |
7fd4958d |
648 | Graphic3d_TypeOfBackfacingModel myBackfacing; |
c357e426 |
649 | Graphic3d_TypeOfVisualization myVisualization; |
c357e426 |
650 | |
879768fb |
651 | Quantity_ColorRGBA myBgColor; |
652 | Handle(Graphic3d_TextureMap) myBackgroundImage; |
653 | Handle(Graphic3d_CubeMap) myCubeMapBackground; //!< Cubemap displayed at background |
654 | Handle(Graphic3d_CubeMap) myCubeMapIBL; //!< Cubemap used for environment lighting |
655 | Handle(Graphic3d_TextureEnv) myTextureEnvData; |
656 | Graphic3d_GraduatedTrihedron myGTrihedronData; |
657 | Graphic3d_TypeOfBackground myBackgroundType; //!< Current type of background |
658 | Aspect_SkydomeBackground mySkydomeAspect; |
659 | Standard_Boolean myToUpdateSkydome; |
660 | |
b40cdc2b |
661 | Handle(Aspect_XRSession) myXRSession; |
662 | Handle(Graphic3d_Camera) myBackXRCamera; //!< camera projection parameters to restore after closing XR session (FOV, aspect and similar) |
663 | Handle(Graphic3d_Camera) myBaseXRCamera; //!< neutral camera orientation defining coordinate system in which head tracking is defined |
664 | Handle(Graphic3d_Camera) myPosedXRCamera; //!< transient XR camera orientation with tracked head orientation applied (based on myBaseXRCamera) |
665 | Handle(Graphic3d_Camera) myPosedXRCameraCopy; //!< neutral camera orientation copy at the beginning of processing input |
666 | Standard_Real myUnitFactor; //!< unit scale factor defined as scale factor for m (meters) |
667 | |
bf75be98 |
668 | }; |
669 | |
c357e426 |
670 | #endif // _Graphic3d_CView_HeaderFile |