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