0030640: Visualization, Graphic3d_Camera - add option creating Projection matrix...
[occt.git] / src / Graphic3d / Graphic3d_CView.hxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Graphic3d_CView_HeaderFile
15 #define _Graphic3d_CView_HeaderFile
16
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>
48
49 class Aspect_XRSession;
50 class Graphic3d_CView;
51 class Graphic3d_GraphicDriver;
52 class Graphic3d_Layer;
53 class Graphic3d_StructureManager;
54
55 DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
56
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
63 {
64   friend class Graphic3d_StructureManager;
65   DEFINE_STANDARD_RTTIEXT(Graphic3d_CView, Graphic3d_DataStructureManager)
66 public:
67
68   //! Constructor.
69   Standard_EXPORT Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theMgr);
70
71   //! Destructor.
72   Standard_EXPORT virtual ~Graphic3d_CView();
73
74   //! Returns the identification number of the view.
75   Standard_Integer Identification() const { return myId; }
76
77   //! Activates the view. Maps presentations defined within structure manager onto this view.
78   Standard_EXPORT virtual void Activate();
79
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();
83
84   //! Returns the activity flag of the view.
85   Standard_Boolean IsActive() const { return myIsActive; }
86
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();
90
91   //! Returns true if the view was removed.
92   Standard_Boolean IsRemoved() const { return myIsRemoved; }
93
94   //! Returns camera object of the view.
95   virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
96
97   //! Sets camera used by the view.
98   virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
99
100 public:
101
102   //! Returns default Shading Model of the view; Graphic3d_TOSM_FRAGMENT by default.
103   Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
104
105   //! Sets default Shading Model of the view.
106   //! Will throw an exception on attempt to set Graphic3d_TOSM_DEFAULT.
107   Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel);
108
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; }
112
113   //! Sets backfacing model for the view.
114   void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) { myBackfacing = theModel; }
115
116   //! Returns visualization type of the view.
117   Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; }
118
119   //! Sets visualization type of the view.
120   void SetVisualizationType (const Graphic3d_TypeOfVisualization theType) { myVisualization = theType; }
121
122   //! Switches computed HLR mode in the view
123   Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode);
124
125   //! Returns the computed HLR mode state
126   Standard_Boolean ComputedMode() const { return myIsInComputedMode; }
127
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);
130
131   //! Invalidates bounding box of specified ZLayerId.
132   Standard_EXPORT void Update (const Graphic3d_ZLayerId theLayerId = Graphic3d_ZLayerId_UNKNOWN);
133
134   //! Computes the new presentation of the structures displayed in this view with the type Graphic3d_TOS_COMPUTED.
135   Standard_EXPORT void Compute();
136
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;
139
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;
142
143   //! Returns the set of structures displayed in this view.
144   Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const;
145
146   //! Returns number of displayed structures in the view.
147   virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
148
149   //! Returns map of objects hidden within this specific view (not viewer-wise).
150   const Handle(Graphic3d_NMapOfTransient)& HiddenObjects() const { return myHiddenObjects; }
151
152   //! Returns map of objects hidden within this specific view (not viewer-wise).
153   Handle(Graphic3d_NMapOfTransient)& ChangeHiddenObjects() { return myHiddenObjects; }
154
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;
159
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;
166
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;
173
174   //! Returns the structure manager handle which manage structures associated with this view.
175   const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; }
176
177 private:
178
179   //! Is it possible to display the structure in the view?
180   Standard_EXPORT Graphic3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const;
181
182   //! Clears the structure in this view.
183   Standard_EXPORT void Clear (Graphic3d_Structure* theStructure,
184                               const Standard_Boolean theWithDestruction);
185
186   //! Connects the structures.
187   Standard_EXPORT void Connect (const Graphic3d_Structure* theMother,
188                                 const Graphic3d_Structure* theDaughter);
189
190   //! Disconnects the structures.
191   Standard_EXPORT void Disconnect (const Graphic3d_Structure* theMother,
192                                    const Graphic3d_Structure* theDaughter);
193
194   //! Displays the structure in the view.
195   Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& theStructure);
196
197   //! Erases the structure from the view.
198   Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& theStructure);
199
200   //! Highlights the structure in the view.
201   Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure);
202
203   //! Transforms the structure in the view.
204   Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure,
205                                      const Handle(TopLoc_Datum3D)& theTrsf);
206
207   //! Suppress the highlighting on the structure <AStructure>
208   //! in the view <me>.
209   Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& theStructure);
210
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;
213
214   Standard_Integer IsComputed (const Handle(Graphic3d_Structure)& theStructure) const { return IsComputed (theStructure.get()); }
215
216   //! Returns true if the structure is displayed in the view.
217   Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(Graphic3d_Structure)& theStructure) const;
218
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);
223
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);
227
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;
231
232 public:
233
234   //! Redraw content of the view.
235   virtual void Redraw() = 0;
236
237   //! Redraw immediate content of the view.
238   virtual void RedrawImmediate() = 0;
239
240   //! Invalidates content of the view but does not redraw it.
241   virtual void Invalidate() = 0;
242
243   //! Return true if view content cache has been invalidated.
244   virtual Standard_Boolean IsInvalidated() = 0;
245
246   //! Handle changing size of the rendering window.
247   virtual void Resized() = 0;
248
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;
262
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;
268
269   //! Returns the window associated to the view.
270   virtual Handle(Aspect_Window) Window() const = 0;
271
272   //! Returns True if the window associated to the view is defined.
273   virtual Standard_Boolean IsDefined() const = 0;
274
275   //! Dump active rendering buffer into specified memory buffer.
276   virtual Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0;
277
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;
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 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;
288
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;
296
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;
300
301   //! Returns the list of layers.
302   virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0;
303
304   //! Returns layer with given ID or NULL if undefined.
305   virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0;
306
307   //! Returns the bounding box of all structures displayed in the Z layer.
308   Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
309
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;
315
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;
319
320   //! Returns zoom-scale factor.
321   Standard_EXPORT Standard_Real ConsiderZoomPersistenceObjects();
322
323   //! Returns pointer to an assigned framebuffer object.
324   virtual Handle(Standard_Transient) FBO() const = 0;
325
326   //! Sets framebuffer object for offscreen rendering.
327   virtual void SetFBO (const Handle(Standard_Transient)& theFbo) = 0;
328
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;
333
334   //! Remove offscreen FBO from the graphic library
335   virtual void FBORelease (Handle(Standard_Transient)& theFbo) = 0;
336
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;
343
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;
348
349 public:
350
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);
355
356   //! Returns current rendering parameters and effect settings.
357   const Graphic3d_RenderingParams& RenderingParams() const { return myRenderParams; }
358
359   //! Returns reference to current rendering parameters and effect settings.
360   Graphic3d_RenderingParams& ChangeRenderingParams() { return myRenderParams; }
361
362   //! Returns background  fill color.
363   virtual Aspect_Background Background() const { return Aspect_Background (myBgColor.GetRGB()); }
364
365   //! Sets background fill color.
366   virtual void SetBackground (const Aspect_Background& theBackground) { myBgColor.SetRGB (theBackground.Color()); }
367
368   //! Returns gradient background fill colors.
369   virtual Aspect_GradientBackground GradientBackground() const = 0;
370
371   //! Sets gradient background fill colors.
372   virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) = 0;
373
374   //! Returns background image texture map.
375   virtual Handle(Graphic3d_TextureMap) BackgroundImage() = 0;
376
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;
384
385   //! Returns background image fill style.
386   virtual Aspect_FillMethod BackgroundImageStyle() const = 0;
387
388   //! Sets background image fill style.
389   virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0;
390
391   //! Returns cubemap being set last time on background.
392   virtual Handle(Graphic3d_CubeMap) BackgroundCubeMap() const = 0;
393
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;
400
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;
406
407   //! Returns environment texture set for the view.
408   virtual Handle(Graphic3d_TextureEnv) TextureEnv() const = 0; 
409
410   //! Sets environment texture for the view.
411   virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
412
413   //! Returns list of lights of the view.
414   virtual const Handle(Graphic3d_LightSet)& Lights() const = 0;
415
416   //! Sets list of lights for the view.
417   virtual void SetLights (const Handle(Graphic3d_LightSet)& theLights) = 0;
418
419   //! Returns list of clip planes set for the view.
420   virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const = 0;
421
422   //! Sets list of clip planes for the view.
423   virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) = 0;
424
425   //! Fill in the dictionary with diagnostic info.
426   //! Should be called within rendering thread.
427   //!
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;
434
435   //! Returns string with statistic performance info.
436   virtual TCollection_AsciiString StatisticInformation() const = 0;
437
438   //! Fills in the dictionary with statistic performance info.
439   virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const = 0;
440
441 public:
442
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; }
446
447   //! Set unit scale factor.
448   Standard_EXPORT void SetUnitFactor (Standard_Real theFactor);
449
450   //! Return XR session.
451   const Handle(Aspect_XRSession)& XRSession() const { return myXRSession; }
452
453   //! Set XR session.
454   void SetXRSession (const Handle(Aspect_XRSession)& theSession) { myXRSession = theSession; }
455
456   //! Return TRUE if there is active XR session.
457   Standard_EXPORT bool IsActiveXR() const;
458
459   //! Initialize XR session.
460   Standard_EXPORT virtual bool InitXR();
461
462   //! Release XR session.
463   Standard_EXPORT virtual void ReleaseXR();
464
465   //! Process input.
466   Standard_EXPORT virtual void ProcessXRInput();
467
468   //! Compute PosedXRCamera() based on current XR head pose and make it active.
469   Standard_EXPORT void SetupXRPosedCamera();
470
471   //! Set current camera back to BaseXRCamera() and copy temporary modifications of PosedXRCamera().
472   //! Calls SynchronizeXRPosedToBaseCamera() beforehand.
473   Standard_EXPORT void UnsetXRPosedCamera();
474
475   //! Returns transient XR camera position with tracked head orientation applied.
476   const Handle(Graphic3d_Camera)& PosedXRCamera() const { return myPosedXRCamera; }
477
478   //! Sets transient XR camera position with tracked head orientation applied.
479   void SetPosedXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myPosedXRCamera = theCamera; }
480
481   //! Returns anchor camera definition (without tracked head orientation).
482   const Handle(Graphic3d_Camera)& BaseXRCamera() const { return myBaseXRCamera; }
483
484   //! Sets anchor camera definition.
485   void SetBaseXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myBaseXRCamera = theCamera; }
486
487   //! Convert XR pose to world space.
488   //! @param theTrsfXR [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
492   {
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());
496     gp_Trsf aTrsfCS;
497     aTrsfCS.SetTransformation (aCameraCS, anAxVr);
498     return aTrsfCS * thePoseXR;
499   }
500
501   //! Recomputes PosedXRCamera() based on BaseXRCamera() and head orientation.
502   Standard_EXPORT void SynchronizeXRBaseToPosedCamera();
503
504   //! Checks if PosedXRCamera() has been modified since SetupXRPosedCamera()
505   //! and copies these modifications to BaseXRCamera().
506   Standard_EXPORT void SynchronizeXRPosedToBaseCamera();
507
508   //! Compute camera position based on XR pose.
509   Standard_EXPORT void ComputeXRPosedCameraFromBase (Graphic3d_Camera& theCam,
510                                                      const gp_Trsf& theXRTrsf) const;
511
512   //! Update based camera from posed camera by applying reversed transformation.
513   Standard_EXPORT void ComputeXRBaseCameraFromPosed (const Graphic3d_Camera& theCamPosed,
514                                                      const gp_Trsf& thePoseTrsf);
515
516   //! Turn XR camera direction using current (head) eye position as anchor.
517   Standard_EXPORT void TurnViewXRCamera (const gp_Trsf& theTrsfTurn);
518
519 public: //! @name obsolete Graduated Trihedron functionality
520
521   //! Returns data of a graduated trihedron
522   virtual const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() { return myGTrihedronData; }
523
524   //! Displays Graduated Trihedron.
525   virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) { (void )theTrihedronData; }
526
527   //! Erases Graduated Trihedron.
528   virtual void GraduatedTrihedronErase() {}
529
530   //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
531   //! @param theMin [in] the minimum point of scene.
532   //! @param theMax [in] the maximum point of scene.
533   virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
534   {
535     (void )theMin;
536     (void )theMax;
537   }
538   
539   //! Dumps the content of me into the stream
540   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
541
542 private:
543
544   //! Adds the structure to display lists of the view.
545   virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
546                                  const Standard_Integer thePriority) = 0;
547
548   //! Erases the structure from display lists of the view.
549   virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) = 0;
550
551   //! Change Z layer of a structure already presented in view.
552   virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
553                              const Graphic3d_ZLayerId theNewLayerId) = 0;
554
555   //! Changes the priority of a structure within its Z layer in the specified view.
556   virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
557                                const Standard_Integer theNewPriority) = 0;
558
559 protected:
560
561   Standard_Integer myId;
562   Graphic3d_RenderingParams myRenderParams;
563   Quantity_ColorRGBA        myBgColor;
564   Handle(Graphic3d_StructureManager) myStructureManager;
565   Handle(Graphic3d_Camera)  myCamera;
566   Graphic3d_SequenceOfStructure myStructsToCompute;
567   Graphic3d_SequenceOfStructure myStructsComputed;
568   Graphic3d_MapOfStructure myStructsDisplayed;
569   Handle(Graphic3d_NMapOfTransient) myHiddenObjects;
570   Standard_Boolean myIsInComputedMode;
571   Standard_Boolean myIsActive;
572   Standard_Boolean myIsRemoved;
573   Graphic3d_TypeOfShadingModel  myShadingModel;
574   Graphic3d_TypeOfBackfacingModel myBackfacing;
575   Graphic3d_TypeOfVisualization myVisualization;
576
577   Handle(Aspect_XRSession) myXRSession;
578   Handle(Graphic3d_Camera) myBackXRCamera;       //!< camera projection parameters to restore after closing XR session (FOV, aspect and similar)
579   Handle(Graphic3d_Camera) myBaseXRCamera;       //!< neutral camera orientation defining coordinate system in which head tracking is defined
580   Handle(Graphic3d_Camera) myPosedXRCamera;      //!< transient XR camera orientation with tracked head orientation applied (based on myBaseXRCamera)
581   Handle(Graphic3d_Camera) myPosedXRCameraCopy;  //!< neutral camera orientation copy at the beginning of processing input
582   Standard_Real            myUnitFactor;         //!< unit scale factor defined as scale factor for m (meters)
583
584 protected:
585
586   Graphic3d_GraduatedTrihedron myGTrihedronData;
587
588 };
589
590 #endif // _Graphic3d_CView_HeaderFile