0029384: Visualization, TKOpenGl - basic integration with OpenVR
[occt.git] / src / Graphic3d / Graphic3d_CView.hxx
CommitLineData
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_Handle.hxx>
c357e426 18#include <Aspect_RenderingContext.hxx>
c357e426 19#include <Aspect_Window.hxx>
20#include <Graphic3d_BufferType.hxx>
b5ac8292 21#include <Graphic3d_Camera.hxx>
077a220c 22#include <Graphic3d_CubeMap.hxx>
12381341 23#include <Graphic3d_CLight.hxx>
c357e426 24#include <Graphic3d_CStructure.hxx>
25#include <Graphic3d_DataStructureManager.hxx>
26d9c835 26#include <Graphic3d_DiagnosticInfo.hxx>
c357e426 27#include <Graphic3d_GraduatedTrihedron.hxx>
28#include <Graphic3d_MapOfStructure.hxx>
29#include <Graphic3d_NMapOfTransient.hxx>
c357e426 30#include <Graphic3d_RenderingParams.hxx>
51b10cd4 31#include <Graphic3d_SequenceOfHClipPlane.hxx>
c357e426 32#include <Graphic3d_SequenceOfStructure.hxx>
c357e426 33#include <Graphic3d_Structure.hxx>
c357e426 34#include <Graphic3d_TextureEnv.hxx>
35#include <Graphic3d_TypeOfAnswer.hxx>
36#include <Graphic3d_TypeOfBackfacingModel.hxx>
37#include <Graphic3d_TypeOfShadingModel.hxx>
c357e426 38#include <Graphic3d_TypeOfVisualization.hxx>
39#include <Graphic3d_Vec3.hxx>
40#include <Graphic3d_ZLayerId.hxx>
41#include <Graphic3d_ZLayerSettings.hxx>
42#include <Image_PixMap.hxx>
43#include <Quantity_NameOfColor.hxx>
44#include <Standard_Address.hxx>
45#include <Standard_Transient.hxx>
26d9c835 46#include <TColStd_IndexedDataMapOfStringString.hxx>
c357e426 47
b40cdc2b 48class Aspect_XRSession;
c357e426 49class Graphic3d_CView;
50class Graphic3d_GraphicDriver;
1c728f2d 51class Graphic3d_Layer;
c357e426 52class Graphic3d_StructureManager;
53
54DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
55
56//! Base class of a graphical view that carries out rendering process for a concrete
57//! implementation of graphical driver. Provides virtual interfaces for redrawing its
58//! contents, management of displayed structures and render settings. The source code
59//! of the class itself implements functionality related to management of
60//! computed (HLR or "view-dependent") structures.
61class Graphic3d_CView : public Graphic3d_DataStructureManager
bf75be98 62{
dc89236f 63 friend class Graphic3d_StructureManager;
64 DEFINE_STANDARD_RTTIEXT(Graphic3d_CView, Graphic3d_DataStructureManager)
bf75be98 65public:
66
c357e426 67 //! Constructor.
68 Standard_EXPORT Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theMgr);
69
70 //! Destructor.
71 Standard_EXPORT virtual ~Graphic3d_CView();
72
73 //! Returns the identification number of the view.
74 Standard_Integer Identification() const { return myId; }
75
46710942 76 //! Activates the view. Maps presentations defined within structure manager onto this view.
c357e426 77 Standard_EXPORT virtual void Activate();
78
46710942 79 //! Deactivates the view. Unmaps presentations defined within structure manager.
80 //! The view in deactivated state will ignore actions on structures such as Display().
c357e426 81 Standard_EXPORT virtual void Deactivate();
82
83 //! Returns the activity flag of the view.
84 Standard_Boolean IsActive() const { return myIsActive; }
85
86 //! Erases the view and removes from graphic driver.
87 //! No more graphic operations are allowed in this view after the call.
88 Standard_EXPORT virtual void Remove();
89
90 //! Returns true if the view was removed.
91 Standard_Boolean IsRemoved() const { return myIsRemoved; }
bf75be98 92
d325cb7f 93 //! Returns camera object of the view.
b5163d2f 94 virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
d325cb7f 95
96 //! Sets camera used by the view.
97 virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
98
bf75be98 99public:
100
dc89236f 101 //! Returns default Shading Model of the view; Graphic3d_TOSM_FRAGMENT by default.
102 Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
103
104 //! Sets default Shading Model of the view.
105 //! Will throw an exception on attempt to set Graphic3d_TOSM_DEFAULT.
106 Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel);
107
c357e426 108 //! Returns visualization type of the view.
109 Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; }
bf75be98 110
c357e426 111 //! Sets visualization type of the view.
112 void SetVisualizationType (const Graphic3d_TypeOfVisualization theType) { myVisualization = theType; }
bf75be98 113
c357e426 114 //! Switches computed HLR mode in the view
115 Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode);
bf75be98 116
c357e426 117 //! Returns the computed HLR mode state
118 Standard_Boolean ComputedMode() const { return myIsInComputedMode; }
bf75be98 119
c357e426 120 //! Computes the new presentation of the structure displayed in this view with the type Graphic3d_TOS_COMPUTED.
121 Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& theStructure);
bf75be98 122
cfece3ef 123 //! Invalidates bounding box of specified ZLayerId.
124 Standard_EXPORT void Update (const Graphic3d_ZLayerId theLayerId = Graphic3d_ZLayerId_UNKNOWN);
125
126 //! Computes the new presentation of the structures displayed in this view with the type Graphic3d_TOS_COMPUTED.
127 Standard_EXPORT void Compute();
bf75be98 128
c357e426 129 //! Returns Standard_True if one of the structures displayed in the view contains Polygons, Triangles or Quadrangles.
130 Standard_EXPORT Standard_Boolean ContainsFacet() const;
bf75be98 131
c357e426 132 //! Returns Standard_True if one of the structures in the set contains Polygons, Triangles or Quadrangles.
133 Standard_EXPORT Standard_Boolean ContainsFacet (const Graphic3d_MapOfStructure& theSet) const;
bf75be98 134
c357e426 135 //! Returns the set of structures displayed in this view.
136 Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const;
b5ac8292 137
c357e426 138 //! Returns number of displayed structures in the view.
91515621 139 virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
bf75be98 140
c357e426 141 //! Returns map of objects hidden within this specific view (not viewer-wise).
142 const Handle(Graphic3d_NMapOfTransient)& HiddenObjects() const { return myHiddenObjects; }
143
144 //! Returns map of objects hidden within this specific view (not viewer-wise).
145 Handle(Graphic3d_NMapOfTransient)& ChangeHiddenObjects() { return myHiddenObjects; }
146
147 //! Returns Standard_True in case if the structure with the given <theStructId> is
148 //! in list of structures to be computed and stores computed struct to <theComputedStruct>.
149 Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId,
150 Handle(Graphic3d_Structure)& theComputedStruct) const;
151
50d06d8f 152 //! Returns the bounding box of all structures displayed in the view.
3fe9ce0e 153 //! If theToIncludeAuxiliary is TRUE, then the boundary box also includes minimum and maximum limits
154 //! of graphical elements forming parts of infinite and other auxiliary structures.
155 //! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
156 //! @return computed bounding box
91515621 157 Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary = Standard_False) const;
c357e426 158
159 //! Returns the coordinates of the boundary box of all structures in the set <theSet>.
160 //! If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
161 //! also includes minimum and maximum limits of graphical elements
162 //! forming parts of infinite structures.
163 Standard_EXPORT Bnd_Box MinMaxValues (const Graphic3d_MapOfStructure& theSet,
3fe9ce0e 164 const Standard_Boolean theToIncludeAuxiliary = Standard_False) const;
c357e426 165
166 //! Returns the structure manager handle which manage structures associated with this view.
167 const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; }
168
169private:
170
c357e426 171 //! Is it possible to display the structure in the view?
172 Standard_EXPORT Graphic3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const;
173
c357e426 174 //! Clears the structure in this view.
7dd7c146 175 Standard_EXPORT void Clear (Graphic3d_Structure* theStructure,
176 const Standard_Boolean theWithDestruction);
c357e426 177
178 //! Connects the structures.
7dd7c146 179 Standard_EXPORT void Connect (const Graphic3d_Structure* theMother,
180 const Graphic3d_Structure* theDaughter);
c357e426 181
182 //! Disconnects the structures.
7dd7c146 183 Standard_EXPORT void Disconnect (const Graphic3d_Structure* theMother,
184 const Graphic3d_Structure* theDaughter);
c357e426 185
186 //! Displays the structure in the view.
187 Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& theStructure);
188
c357e426 189 //! Erases the structure from the view.
190 Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& theStructure);
191
c357e426 192 //! Highlights the structure in the view.
8e5fb5ea 193 Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure);
c357e426 194
195 //! Transforms the structure in the view.
196 Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure,
7f24b768 197 const Handle(TopLoc_Datum3D)& theTrsf);
c357e426 198
199 //! Suppress the highlighting on the structure <AStructure>
200 //! in the view <me>.
201 Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& theStructure);
202
203 //! Returns an index != 0 if the structure have another structure computed for the view <me>.
7dd7c146 204 Standard_EXPORT Standard_Integer IsComputed (const Graphic3d_Structure* theStructure) const;
205
206 Standard_Integer IsComputed (const Handle(Graphic3d_Structure)& theStructure) const { return IsComputed (theStructure.get()); }
c357e426 207
208 //! Returns true if the structure is displayed in the view.
209 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(Graphic3d_Structure)& theStructure) const;
210
211 //! Changes the display priority of the structure.
212 Standard_EXPORT void ChangePriority (const Handle(Graphic3d_Structure)& theStructure,
213 const Standard_Integer theOldPriority,
214 const Standard_Integer theNewPriority);
215
216 //! Change Z layer of already displayed structure in the view.
217 Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
218 const Graphic3d_ZLayerId theLayerId);
219
220 //! Returns an index != 0 if the structure have the same owner than another structure
221 //! in the sequence of the computed structures.
222 Standard_EXPORT Standard_Integer HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStructure) const;
bf75be98 223
224public:
225
c357e426 226 //! Redraw content of the view.
227 virtual void Redraw() = 0;
228
229 //! Redraw immediate content of the view.
230 virtual void RedrawImmediate() = 0;
231
232 //! Invalidates content of the view but does not redraw it.
233 virtual void Invalidate() = 0;
234
235 //! Return true if view content cache has been invalidated.
236 virtual Standard_Boolean IsInvalidated() = 0;
237
238 //! Handle changing size of the rendering window.
239 virtual void Resized() = 0;
240
241 //! @param theDrawToFrontBuffer Advanced option to modify rendering mode:
242 //! 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image.
243 //! Fast, so preferred for interactive work (used by default).
244 //! However these extra drawings will be missed in image dump since it is performed from back buffer.
245 //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
246 //! in run-time (in case of slow hardware) and/or tearing may appear.
247 //! So this is strongly recommended to draw only simple (fast) structures.
248 //! 2. FALSE. Drawing immediate mode structures to the back buffer.
249 //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync
250 //! is turned on. But it works in any case and is especially useful for view dump because the dump image is read
251 //! from the back buffer.
252 //! @return previous mode.
253 virtual Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) = 0;
254
255 //! Creates and maps rendering window to the view.
c357e426 256 //! @param theWindow [in] the window.
257 //! @param theContext [in] the rendering context. If NULL the context will be created internally.
c357e426 258 virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
a521d90d 259 const Aspect_RenderingContext theContext = NULL) = 0;
c357e426 260
261 //! Returns the window associated to the view.
262 virtual Handle(Aspect_Window) Window() const = 0;
263
264 //! Returns True if the window associated to the view is defined.
265 virtual Standard_Boolean IsDefined() const = 0;
266
c357e426 267 //! Dump active rendering buffer into specified memory buffer.
268 virtual Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0;
269
c357e426 270 //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
8f138407 271 virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) = 0;
c357e426 272
1c728f2d 273 //! Add a layer to the view.
274 //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
275 //! @param theSettings [in] new layer settings
276 //! @param theLayerAfter [in] id of layer to append new layer before
277 virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
278 const Graphic3d_ZLayerSettings& theSettings,
279 const Graphic3d_ZLayerId theLayerAfter) = 0;
280
281 //! Add a layer to the view.
282 //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
283 //! @param theSettings [in] new layer settings
284 //! @param theLayerBefore [in] id of layer to append new layer after
285 virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
286 const Graphic3d_ZLayerSettings& theSettings,
287 const Graphic3d_ZLayerId theLayerBefore) = 0;
c357e426 288
50d06d8f 289 //! Returns the maximum Z layer ID.
290 //! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
291 virtual Standard_Integer ZLayerMax() const = 0;
292
1c728f2d 293 //! Returns the list of layers.
294 virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0;
295
296 //! Returns layer with given ID or NULL if undefined.
297 virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0;
50d06d8f 298
299 //! Returns the bounding box of all structures displayed in the Z layer.
1c728f2d 300 Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
50d06d8f 301
c357e426 302 //! Remove Z layer from the specified view. All structures
303 //! displayed at the moment in layer will be displayed in default layer
304 //! ( the bottom-level z layer ). To unset layer ID from associated
305 //! structures use method UnsetZLayer (...).
306 virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
307
308 //! Sets the settings for a single Z layer of specified view.
309 virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
310 const Graphic3d_ZLayerSettings& theSettings) = 0;
311
50d06d8f 312 //! Returns zoom-scale factor.
313 Standard_EXPORT Standard_Real ConsiderZoomPersistenceObjects();
314
c357e426 315 //! Returns pointer to an assigned framebuffer object.
b128c892 316 virtual Handle(Standard_Transient) FBO() const = 0;
c357e426 317
318 //! Sets framebuffer object for offscreen rendering.
b128c892 319 virtual void SetFBO (const Handle(Standard_Transient)& theFbo) = 0;
c357e426 320
321 //! Generate offscreen FBO in the graphic library.
322 //! If not supported on hardware returns NULL.
b128c892 323 virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth,
324 const Standard_Integer theHeight) = 0;
c357e426 325
326 //! Remove offscreen FBO from the graphic library
b128c892 327 virtual void FBORelease (Handle(Standard_Transient)& theFbo) = 0;
c357e426 328
329 //! Read offscreen FBO configuration.
b128c892 330 virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
c357e426 331 Standard_Integer& theWidth,
332 Standard_Integer& theHeight,
333 Standard_Integer& theWidthMax,
334 Standard_Integer& theHeightMax) = 0;
335
336 //! Change offscreen FBO viewport.
b128c892 337 virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
c357e426 338 const Standard_Integer theWidth,
339 const Standard_Integer theHeight) = 0;
bf75be98 340
341public:
342
c357e426 343 //! Copy visualization settings from another view.
344 //! Method is used for cloning views in viewer when its required to create view
345 //! with same view properties.
346 Standard_EXPORT virtual void CopySettings (const Handle(Graphic3d_CView)& theOther);
347
348 //! Returns current rendering parameters and effect settings.
349 const Graphic3d_RenderingParams& RenderingParams() const { return myRenderParams; }
350
351 //! Returns reference to current rendering parameters and effect settings.
352 Graphic3d_RenderingParams& ChangeRenderingParams() { return myRenderParams; }
353
c357e426 354 //! Returns background fill color.
d325cb7f 355 virtual Aspect_Background Background() const { return Aspect_Background (myBgColor.GetRGB()); }
c357e426 356
357 //! Sets background fill color.
d325cb7f 358 virtual void SetBackground (const Aspect_Background& theBackground) { myBgColor.SetRGB (theBackground.Color()); }
c357e426 359
360 //! Returns gradient background fill colors.
361 virtual Aspect_GradientBackground GradientBackground() const = 0;
362
363 //! Sets gradient background fill colors.
364 virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) = 0;
365
366 //! Returns background image texture file path.
367 virtual TCollection_AsciiString BackgroundImage() = 0;
368
369 //! Sets background image texture file path.
370 virtual void SetBackgroundImage (const TCollection_AsciiString& theFilePath) = 0;
371
372 //! Returns background image fill style.
373 virtual Aspect_FillMethod BackgroundImageStyle() const = 0;
374
375 //! Sets background image fill style.
376 virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0;
377
077a220c 378 //! Returns cubemap being setted last time on background.
379 virtual Handle(Graphic3d_CubeMap) BackgroundCubeMap() const = 0;
380
381 //! Sets environment cubemap as background.
67312b79 382 //! @param theCubeMap cubemap source to be set as background
383 //! @param theToUpdatePBREnv defines whether IBL maps will be generated or not (see 'GeneratePBREnvironment')
384 virtual void SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap,
385 Standard_Boolean theToUpdatePBREnv = Standard_True) = 0;
386
387 //! Generates PBR specular probe and irradiance map
388 //! in order to provide environment indirect illumination in PBR shading model (Image Based Lighting).
389 //! The source of environment data is background cubemap.
390 //! If PBR is unavailable it does nothing.
391 //! If PBR is available but there is no cubemap being set to background it clears all IBL maps (see 'ClearPBREnvironment').
392 virtual void GeneratePBREnvironment() = 0;
393
394 //! Fills PBR specular probe and irradiance map with white color.
395 //! So that environment indirect illumination will be constant
396 //! and will be fully controlled by ambient light sources.
397 //! If PBR is unavailable it does nothing.
398 virtual void ClearPBREnvironment() = 0;
077a220c 399
c357e426 400 //! Returns environment texture set for the view.
401 virtual Handle(Graphic3d_TextureEnv) TextureEnv() const = 0;
402
403 //! Sets environment texture for the view.
404 virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
405
c357e426 406 //! Return backfacing model used for the view.
407 virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0;
bf75be98 408
c357e426 409 //! Sets backfacing model for the view.
410 virtual void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) = 0;
bf75be98 411
c357e426 412 //! Returns list of lights of the view.
992ed6b3 413 virtual const Handle(Graphic3d_LightSet)& Lights() const = 0;
c357e426 414
415 //! Sets list of lights for the view.
992ed6b3 416 virtual void SetLights (const Handle(Graphic3d_LightSet)& theLights) = 0;
c357e426 417
418 //! Returns list of clip planes set for the view.
3202bf1e 419 virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const = 0;
c357e426 420
421 //! Sets list of clip planes for the view.
3202bf1e 422 virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) = 0;
c357e426 423
26d9c835 424 //! Fill in the dictionary with diagnostic info.
425 //! Should be called within rendering thread.
426 //!
427 //! This API should be used only for user output or for creating automated reports.
428 //! The format of returned information (e.g. key-value layout)
429 //! is NOT part of this API and can be changed at any time.
430 //! Thus application should not parse returned information to weed out specific parameters.
b40cdc2b 431 Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
432 Graphic3d_DiagnosticInfo theFlags) const = 0;
26d9c835 433
79b544e6 434 //! Returns string with statistic performance info.
435 virtual TCollection_AsciiString StatisticInformation() const = 0;
436
437 //! Fills in the dictionary with statistic performance info.
438 virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const = 0;
439
b40cdc2b 440public:
441
442 //! Return unit scale factor defined as scale factor for m (meters); 1.0 by default.
443 //! Normally, view definition is unitless, however some operations like VR input requires proper units mapping.
444 Standard_Real UnitFactor() const { return myUnitFactor; }
445
446 //! Set unit scale factor.
447 Standard_EXPORT void SetUnitFactor (Standard_Real theFactor);
448
449 //! Return XR session.
450 const Handle(Aspect_XRSession)& XRSession() const { return myXRSession; }
451
452 //! Set XR session.
453 void SetXRSession (const Handle(Aspect_XRSession)& theSession) { myXRSession = theSession; }
454
455 //! Return TRUE if there is active XR session.
456 Standard_EXPORT bool IsActiveXR() const;
457
458 //! Initialize XR session.
459 Standard_EXPORT virtual bool InitXR();
460
461 //! Release XR session.
462 Standard_EXPORT virtual void ReleaseXR();
463
464 //! Process input.
465 Standard_EXPORT virtual void ProcessXRInput();
466
467 //! Compute PosedXRCamera() based on current XR head pose and make it active.
468 Standard_EXPORT void SetupXRPosedCamera();
469
470 //! Set current camera back to BaseXRCamera() and copy temporary modifications of PosedXRCamera().
471 //! Calls SynchronizeXRPosedToBaseCamera() beforehand.
472 Standard_EXPORT void UnsetXRPosedCamera();
473
474 //! Returns transient XR camera position with tracked head orientation applied.
475 const Handle(Graphic3d_Camera)& PosedXRCamera() const { return myPosedXRCamera; }
476
477 //! Sets transient XR camera position with tracked head orientation applied.
478 void SetPosedXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myPosedXRCamera = theCamera; }
479
480 //! Returns anchor camera definition (without tracked head orientation).
481 const Handle(Graphic3d_Camera)& BaseXRCamera() const { return myBaseXRCamera; }
482
483 //! Sets anchor camera definition.
484 void SetBaseXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myBaseXRCamera = theCamera; }
485
486 //! Convert XR pose to world space.
487 //! @param theTrsfXR [in] transformation defined in VR local coordinate system,
488 //! oriented as Y-up, X-right and -Z-forward
489 //! @return transformation defining orientation of XR pose in world space
490 gp_Trsf PoseXRToWorld (const gp_Trsf& thePoseXR) const
491 {
492 const Handle(Graphic3d_Camera)& anOrigin = myBaseXRCamera;
493 const gp_Ax3 anAxVr (gp::Origin(), gp::DZ(), gp::DX());
494 const gp_Ax3 aCameraCS (anOrigin->Eye().XYZ(), -anOrigin->Direction(), -anOrigin->SideRight());
495 gp_Trsf aTrsfCS;
496 aTrsfCS.SetTransformation (aCameraCS, anAxVr);
497 return aTrsfCS * thePoseXR;
498 }
499
500 //! Recomputes PosedXRCamera() based on BaseXRCamera() and head orientation.
501 Standard_EXPORT void SynchronizeXRBaseToPosedCamera();
502
503 //! Checks if PosedXRCamera() has been modified since SetupXRPosedCamera()
504 //! and copies these modifications to BaseXRCamera().
505 Standard_EXPORT void SynchronizeXRPosedToBaseCamera();
506
507 //! Compute camera position based on XR pose.
508 Standard_EXPORT void ComputeXRPosedCameraFromBase (Graphic3d_Camera& theCam,
509 const gp_Trsf& theXRTrsf) const;
510
511 //! Update based camera from posed camera by applying reversed transformation.
512 Standard_EXPORT void ComputeXRBaseCameraFromPosed (const Graphic3d_Camera& theCamPosed,
513 const gp_Trsf& thePoseTrsf);
514
515 //! Turn XR camera direction using current (head) eye position as anchor.
516 Standard_EXPORT void TurnViewXRCamera (const gp_Trsf& theTrsfTurn);
517
d325cb7f 518public: //! @name obsolete Graduated Trihedron functionality
519
520 //! Returns data of a graduated trihedron
521 virtual const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() { return myGTrihedronData; }
522
523 //! Displays Graduated Trihedron.
524 virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) { (void )theTrihedronData; }
525
526 //! Erases Graduated Trihedron.
527 virtual void GraduatedTrihedronErase() {}
528
529 //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
530 //! @param theMin [in] the minimum point of scene.
531 //! @param theMax [in] the maximum point of scene.
532 virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
533 {
534 (void )theMin;
535 (void )theMax;
536 }
537
c357e426 538private:
539
540 //! Adds the structure to display lists of the view.
541 virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
542 const Standard_Integer thePriority) = 0;
543
544 //! Erases the structure from display lists of the view.
545 virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) = 0;
546
547 //! Change Z layer of a structure already presented in view.
548 virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
549 const Graphic3d_ZLayerId theNewLayerId) = 0;
550
551 //! Changes the priority of a structure within its Z layer in the specified view.
552 virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
553 const Standard_Integer theNewPriority) = 0;
554
c357e426 555protected:
556
557 Standard_Integer myId;
558 Graphic3d_RenderingParams myRenderParams;
d325cb7f 559 Quantity_ColorRGBA myBgColor;
c357e426 560 Handle(Graphic3d_StructureManager) myStructureManager;
d325cb7f 561 Handle(Graphic3d_Camera) myCamera;
c357e426 562 Graphic3d_SequenceOfStructure myStructsToCompute;
563 Graphic3d_SequenceOfStructure myStructsComputed;
564 Graphic3d_MapOfStructure myStructsDisplayed;
565 Handle(Graphic3d_NMapOfTransient) myHiddenObjects;
566 Standard_Boolean myIsInComputedMode;
567 Standard_Boolean myIsActive;
568 Standard_Boolean myIsRemoved;
dc89236f 569 Graphic3d_TypeOfShadingModel myShadingModel;
c357e426 570 Graphic3d_TypeOfVisualization myVisualization;
c357e426 571
b40cdc2b 572 Handle(Aspect_XRSession) myXRSession;
573 Handle(Graphic3d_Camera) myBackXRCamera; //!< camera projection parameters to restore after closing XR session (FOV, aspect and similar)
574 Handle(Graphic3d_Camera) myBaseXRCamera; //!< neutral camera orientation defining coordinate system in which head tracking is defined
575 Handle(Graphic3d_Camera) myPosedXRCamera; //!< transient XR camera orientation with tracked head orientation applied (based on myBaseXRCamera)
576 Handle(Graphic3d_Camera) myPosedXRCameraCopy; //!< neutral camera orientation copy at the beginning of processing input
577 Standard_Real myUnitFactor; //!< unit scale factor defined as scale factor for m (meters)
578
d325cb7f 579protected:
580
581 Graphic3d_GraduatedTrihedron myGTrihedronData;
582
bf75be98 583};
584
c357e426 585#endif // _Graphic3d_CView_HeaderFile