Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:48

0001 // Copyright (c) 2015 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Graphic3d_CView_HeaderFile
0015 #define _Graphic3d_CView_HeaderFile
0016 
0017 #include <Aspect_RenderingContext.hxx>
0018 #include <Aspect_SkydomeBackground.hxx>
0019 #include <Aspect_Window.hxx>
0020 #include <Graphic3d_BufferType.hxx>
0021 #include <Graphic3d_CubeMap.hxx>
0022 #include <Graphic3d_DataStructureManager.hxx>
0023 #include <Graphic3d_DiagnosticInfo.hxx>
0024 #include <Graphic3d_GraduatedTrihedron.hxx>
0025 #include <Graphic3d_NMapOfTransient.hxx>
0026 #include <Graphic3d_RenderingParams.hxx>
0027 #include <Graphic3d_SequenceOfStructure.hxx>
0028 #include <Graphic3d_Structure.hxx>
0029 #include <Graphic3d_TextureEnv.hxx>
0030 #include <Graphic3d_TypeOfAnswer.hxx>
0031 #include <Graphic3d_TypeOfBackfacingModel.hxx>
0032 #include <Graphic3d_TypeOfBackground.hxx>
0033 #include <Graphic3d_TypeOfShadingModel.hxx>
0034 #include <Graphic3d_TypeOfVisualization.hxx>
0035 #include <Graphic3d_Vec3.hxx>
0036 #include <Graphic3d_ZLayerId.hxx>
0037 #include <Graphic3d_ZLayerSettings.hxx>
0038 #include <Image_PixMap.hxx>
0039 #include <Standard_Transient.hxx>
0040 #include <TColStd_IndexedDataMapOfStringString.hxx>
0041 
0042 class Aspect_NeutralWindow;
0043 class Aspect_XRSession;
0044 class Graphic3d_CView;
0045 class Graphic3d_Layer;
0046 class Graphic3d_StructureManager;
0047 
0048 DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
0049 
0050 //! Base class of a graphical view that carries out rendering process for a concrete
0051 //! implementation of graphical driver. Provides virtual interfaces for redrawing its
0052 //! contents, management of displayed structures and render settings. The source code 
0053 //! of the class itself implements functionality related to management of
0054 //! computed (HLR or "view-dependent") structures.
0055 class Graphic3d_CView : public Graphic3d_DataStructureManager
0056 {
0057   friend class Graphic3d_StructureManager;
0058   DEFINE_STANDARD_RTTIEXT(Graphic3d_CView, Graphic3d_DataStructureManager)
0059 public:
0060 
0061   //! Constructor.
0062   Standard_EXPORT Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theMgr);
0063 
0064   //! Destructor.
0065   Standard_EXPORT virtual ~Graphic3d_CView();
0066 
0067   //! Returns the identification number of the view.
0068   Standard_Integer Identification() const { return myId; }
0069 
0070   //! Activates the view. Maps presentations defined within structure manager onto this view.
0071   Standard_EXPORT virtual void Activate();
0072 
0073   //! Deactivates the view. Unmaps presentations defined within structure manager.
0074   //! The view in deactivated state will ignore actions on structures such as Display().
0075   Standard_EXPORT virtual void Deactivate();
0076 
0077   //! Returns the activity flag of the view.
0078   Standard_Boolean IsActive() const { return myIsActive; }
0079 
0080   //! Erases the view and removes from graphic driver.
0081   //! No more graphic operations are allowed in this view after the call.
0082   Standard_EXPORT virtual void Remove();
0083 
0084   //! Returns true if the view was removed.
0085   Standard_Boolean IsRemoved() const { return myIsRemoved; }
0086 
0087   //! Returns camera object of the view.
0088   virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
0089 
0090   //! Sets camera used by the view.
0091   virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
0092 
0093 public:
0094 
0095   //! Returns default Shading Model of the view; Graphic3d_TypeOfShadingModel_Phong by default.
0096   Graphic3d_TypeOfShadingModel ShadingModel() const { return myRenderParams.ShadingModel; }
0097 
0098   //! Sets default Shading Model of the view.
0099   //! Will throw an exception on attempt to set Graphic3d_TypeOfShadingModel_DEFAULT.
0100   Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel);
0101 
0102   //! Return backfacing model used for the view; Graphic3d_TypeOfBackfacingModel_Auto by default,
0103   //! which means that backface culling is defined by each presentation.
0104   Graphic3d_TypeOfBackfacingModel BackfacingModel() const { return myBackfacing; }
0105 
0106   //! Sets backfacing model for the view.
0107   void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) { myBackfacing = theModel; }
0108 
0109   //! Returns visualization type of the view.
0110   Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; }
0111 
0112   //! Sets visualization type of the view.
0113   void SetVisualizationType (const Graphic3d_TypeOfVisualization theType) { myVisualization = theType; }
0114 
0115   //! Switches computed HLR mode in the view
0116   Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode);
0117 
0118   //! Returns the computed HLR mode state
0119   Standard_Boolean ComputedMode() const { return myIsInComputedMode; }
0120 
0121   //! Computes the new presentation of the structure  displayed in this view with the type Graphic3d_TOS_COMPUTED.
0122   Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& theStructure);
0123 
0124   //! Invalidates bounding box of specified ZLayerId.
0125   Standard_EXPORT void Update (const Graphic3d_ZLayerId theLayerId = Graphic3d_ZLayerId_UNKNOWN);
0126 
0127   //! Computes the new presentation of the structures displayed in this view with the type Graphic3d_TOS_COMPUTED.
0128   Standard_EXPORT void Compute();
0129 
0130   //! Returns the set of structures displayed in this view.
0131   Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const;
0132 
0133   //! Returns number of displayed structures in the view.
0134   virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
0135 
0136   //! Returns Standard_True in case if the structure with the given <theStructId> is
0137   //! in list of structures to be computed and stores computed struct to <theComputedStruct>.
0138   Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId,
0139                                                Handle(Graphic3d_Structure)& theComputedStruct) const;
0140 
0141   //! Returns the bounding box of all structures displayed in the view.
0142   //! If theToIncludeAuxiliary is TRUE, then the boundary box also includes minimum and maximum limits
0143   //! of graphical elements forming parts of infinite and other auxiliary structures.
0144   //! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
0145   //! @return computed bounding box
0146   Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary = Standard_False) const;
0147 
0148   //! Returns the coordinates of the boundary box of all structures in the set <theSet>.
0149   //! If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
0150   //! also includes minimum and maximum limits of graphical elements
0151   //! forming parts of infinite structures.
0152   Standard_EXPORT Bnd_Box MinMaxValues (const Graphic3d_MapOfStructure& theSet,
0153                                         const Standard_Boolean theToIncludeAuxiliary = Standard_False) const;
0154 
0155   //! Returns the structure manager handle which manage structures associated with this view.
0156   const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; }
0157 
0158 private:
0159 
0160   //! Is it possible to display the structure in the view?
0161   Standard_EXPORT Graphic3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const;
0162 
0163   //! Clears the structure in this view.
0164   Standard_EXPORT void Clear (Graphic3d_Structure* theStructure,
0165                               const Standard_Boolean theWithDestruction);
0166 
0167   //! Connects the structures.
0168   Standard_EXPORT void Connect (const Graphic3d_Structure* theMother,
0169                                 const Graphic3d_Structure* theDaughter);
0170 
0171   //! Disconnects the structures.
0172   Standard_EXPORT void Disconnect (const Graphic3d_Structure* theMother,
0173                                    const Graphic3d_Structure* theDaughter);
0174 
0175   //! Displays the structure in the view.
0176   Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& theStructure);
0177 
0178   //! Erases the structure from the view.
0179   Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& theStructure);
0180 
0181   //! Highlights the structure in the view.
0182   Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure);
0183 
0184   //! Transforms the structure in the view.
0185   Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure,
0186                                      const Handle(TopLoc_Datum3D)& theTrsf);
0187 
0188   //! Suppress the highlighting on the structure <AStructure>
0189   //! in the view <me>.
0190   Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& theStructure);
0191 
0192   //! Returns an index != 0 if the structure have another structure computed for the view <me>.
0193   Standard_EXPORT Standard_Integer IsComputed (const Graphic3d_Structure* theStructure) const;
0194 
0195   Standard_Integer IsComputed (const Handle(Graphic3d_Structure)& theStructure) const { return IsComputed (theStructure.get()); }
0196 
0197   //! Returns true if the structure is displayed in the view.
0198   Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(Graphic3d_Structure)& theStructure) const;
0199 
0200   //! Changes the display priority of the structure.
0201   Standard_EXPORT void ChangePriority (const Handle(Graphic3d_Structure)& theStructure,
0202                                        const Graphic3d_DisplayPriority theOldPriority,
0203                                        const Graphic3d_DisplayPriority theNewPriority);
0204 
0205   //! Change Z layer of already displayed structure in the view.
0206   Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
0207                                      const Graphic3d_ZLayerId theLayerId);
0208 
0209   //! Returns an index != 0 if the structure have the same owner than another structure
0210   //! in the sequence of the computed structures.
0211   Standard_EXPORT Standard_Integer HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStructure) const;
0212 
0213 public:
0214 
0215   //! Redraw content of the view.
0216   virtual void Redraw() = 0;
0217 
0218   //! Redraw immediate content of the view.
0219   virtual void RedrawImmediate() = 0;
0220 
0221   //! Invalidates content of the view but does not redraw it.
0222   virtual void Invalidate() = 0;
0223 
0224   //! Return true if view content cache has been invalidated.
0225   virtual Standard_Boolean IsInvalidated() = 0;
0226 
0227   //! Handle changing size of the rendering window.
0228   Standard_EXPORT virtual void Resized() = 0;
0229 
0230   //! @param theDrawToFrontBuffer Advanced option to modify rendering mode:
0231   //! 1. TRUE.  Drawing immediate mode structures directly to the front buffer over the scene image.
0232   //! Fast, so preferred for interactive work (used by default).
0233   //! However these extra drawings will be missed in image dump since it is performed from back buffer.
0234   //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
0235   //! in run-time (in case of slow hardware) and/or tearing may appear.
0236   //! So this is strongly recommended to draw only simple (fast) structures.
0237   //! 2. FALSE. Drawing immediate mode structures to the back buffer.
0238   //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync
0239   //! is turned on. But it works in any case and is especially useful for view dump because the dump image is read
0240   //! from the back buffer.
0241   //! @return previous mode.
0242   virtual Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) = 0;
0243 
0244   //! Creates and maps rendering window to the view.
0245   //! @param[in] theParentVIew parent view or NULL
0246   //! @param[in] theWindow the window
0247   //! @param[in] theContext the rendering context; if NULL the context will be created internally
0248   virtual void SetWindow (const Handle(Graphic3d_CView)& theParentVIew,
0249                           const Handle(Aspect_Window)& theWindow,
0250                           const Aspect_RenderingContext theContext) = 0;
0251 
0252   //! Returns the window associated to the view.
0253   virtual Handle(Aspect_Window) Window() const = 0;
0254 
0255   //! Returns True if the window associated to the view is defined.
0256   virtual Standard_Boolean IsDefined() const = 0;
0257 
0258   //! Dump active rendering buffer into specified memory buffer.
0259   virtual Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0;
0260 
0261   //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
0262   virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) = 0;
0263 
0264   //! Add a layer to the view.
0265   //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
0266   //! @param theSettings   [in] new layer settings
0267   //! @param theLayerAfter [in] id of layer to append new layer before
0268   virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
0269                                   const Graphic3d_ZLayerSettings& theSettings,
0270                                   const Graphic3d_ZLayerId theLayerAfter) = 0;
0271 
0272   //! Add a layer to the view.
0273   //! @param theNewLayerId  [in] id of new layer, should be > 0 (negative values are reserved for default layers).
0274   //! @param theSettings    [in] new layer settings
0275   //! @param theLayerBefore [in] id of layer to append new layer after
0276   virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
0277                                  const Graphic3d_ZLayerSettings& theSettings,
0278                                  const Graphic3d_ZLayerId theLayerBefore) = 0;
0279 
0280   //! Returns the maximum Z layer ID.
0281   //! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
0282   virtual Standard_Integer ZLayerMax() const = 0;
0283 
0284   //! Returns the list of layers.
0285   virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0;
0286 
0287   //! Returns layer with given ID or NULL if undefined.
0288   virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0;
0289 
0290   //! Returns the bounding box of all structures displayed in the Z layer.
0291   Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
0292 
0293   //! Remove Z layer from the specified view. All structures
0294   //! displayed at the moment in layer will be displayed in default layer
0295   //! ( the bottom-level z layer ). To unset layer ID from associated
0296   //! structures use method UnsetZLayer (...).
0297   virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
0298 
0299   //! Sets the settings for a single Z layer of specified view.
0300   virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
0301                                   const Graphic3d_ZLayerSettings& theSettings) = 0;
0302 
0303   //! Returns zoom-scale factor.
0304   Standard_EXPORT Standard_Real ConsiderZoomPersistenceObjects();
0305 
0306   //! Returns pointer to an assigned framebuffer object.
0307   virtual Handle(Standard_Transient) FBO() const = 0;
0308 
0309   //! Sets framebuffer object for offscreen rendering.
0310   virtual void SetFBO (const Handle(Standard_Transient)& theFbo) = 0;
0311 
0312   //! Generate offscreen FBO in the graphic library.
0313   //! If not supported on hardware returns NULL.
0314   virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth,
0315                                                 const Standard_Integer theHeight) = 0;
0316 
0317   //! Remove offscreen FBO from the graphic library
0318   virtual void FBORelease (Handle(Standard_Transient)& theFbo) = 0;
0319 
0320   //! Read offscreen FBO configuration.
0321   virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
0322                                  Standard_Integer& theWidth,
0323                                  Standard_Integer& theHeight,
0324                                  Standard_Integer& theWidthMax,
0325                                  Standard_Integer& theHeightMax) = 0;
0326 
0327   //! Change offscreen FBO viewport.
0328   virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
0329                                   const Standard_Integer theWidth,
0330                                   const Standard_Integer theHeight) = 0;
0331 
0332 public:
0333 
0334   //! Copy visualization settings from another view.
0335   //! Method is used for cloning views in viewer when its required to create view
0336   //! with same view properties.
0337   Standard_EXPORT virtual void CopySettings (const Handle(Graphic3d_CView)& theOther);
0338 
0339   //! Returns current rendering parameters and effect settings.
0340   const Graphic3d_RenderingParams& RenderingParams() const { return myRenderParams; }
0341 
0342   //! Returns reference to current rendering parameters and effect settings.
0343   Graphic3d_RenderingParams& ChangeRenderingParams() { return myRenderParams; }
0344 
0345 public:
0346 
0347   //! Returns background  fill color.
0348   virtual Aspect_Background Background() const { return Aspect_Background (myBgColor.GetRGB()); }
0349 
0350   //! Sets background fill color.
0351   virtual void SetBackground (const Aspect_Background& theBackground) { myBgColor.SetRGB (theBackground.Color()); }
0352 
0353   //! Returns gradient background fill colors.
0354   virtual Aspect_GradientBackground GradientBackground() const = 0;
0355 
0356   //! Sets gradient background fill colors.
0357   virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) = 0;
0358 
0359   //! Returns background image texture map.
0360   const Handle(Graphic3d_TextureMap)& BackgroundImage() { return myBackgroundImage; }
0361 
0362   //! Returns cubemap being set last time on background.
0363   const Handle(Graphic3d_CubeMap)& BackgroundCubeMap() const { return myCubeMapBackground; }
0364 
0365   //! Returns cubemap being set last time on background.
0366   const Handle(Graphic3d_CubeMap)& IBLCubeMap() const { return myCubeMapIBL; }
0367 
0368   //! Sets image texture or environment cubemap as background.
0369   //! @param theTextureMap [in] source to set a background;
0370   //!                           should be either Graphic3d_Texture2D or Graphic3d_CubeMap
0371   //! @param theToUpdatePBREnv [in] defines whether IBL maps will be generated or not
0372   //!                               (see GeneratePBREnvironment())
0373   virtual void SetBackgroundImage (const Handle(Graphic3d_TextureMap)& theTextureMap,
0374                                    Standard_Boolean theToUpdatePBREnv = Standard_True) = 0;
0375 
0376   //! Returns background image fill style.
0377   virtual Aspect_FillMethod BackgroundImageStyle() const = 0;
0378 
0379   //! Sets background image fill style.
0380   virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0;
0381 
0382   //! Returns background type.
0383   Graphic3d_TypeOfBackground BackgroundType() const { return myBackgroundType; }
0384 
0385   //! Sets background type.
0386   void SetBackgroundType (Graphic3d_TypeOfBackground theType) { myBackgroundType = theType; }
0387 
0388   //! Returns skydome aspect;
0389   const Aspect_SkydomeBackground& BackgroundSkydome() const { return mySkydomeAspect; }
0390 
0391   //! Sets skydome aspect
0392   Standard_EXPORT void SetBackgroundSkydome (const Aspect_SkydomeBackground& theAspect,
0393                                              Standard_Boolean theToUpdatePBREnv = Standard_True);
0394 
0395   //! Enables or disables IBL (Image Based Lighting) from background cubemap.
0396   //! Has no effect if PBR is not used.
0397   //! @param[in] theToEnableIBL enable or disable IBL from background cubemap
0398   virtual void SetImageBasedLighting (Standard_Boolean theToEnableIBL) = 0;
0399 
0400   //! Returns environment texture set for the view.
0401   const Handle(Graphic3d_TextureEnv)& TextureEnv() const { return myTextureEnvData; }
0402 
0403   //! Sets environment texture for the view.
0404   virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
0405 
0406 public:
0407 
0408   //! Returns list of lights of the view.
0409   virtual const Handle(Graphic3d_LightSet)& Lights() const = 0;
0410 
0411   //! Sets list of lights for the view.
0412   virtual void SetLights (const Handle(Graphic3d_LightSet)& theLights) = 0;
0413 
0414   //! Returns list of clip planes set for the view.
0415   virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const = 0;
0416 
0417   //! Sets list of clip planes for the view.
0418   virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) = 0;
0419 
0420   //! Fill in the dictionary with diagnostic info.
0421   //! Should be called within rendering thread.
0422   //!
0423   //! This API should be used only for user output or for creating automated reports.
0424   //! The format of returned information (e.g. key-value layout)
0425   //! is NOT part of this API and can be changed at any time.
0426   //! Thus application should not parse returned information to weed out specific parameters.
0427   Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
0428                                                       Graphic3d_DiagnosticInfo theFlags) const = 0;
0429 
0430   //! Returns string with statistic performance info.
0431   virtual TCollection_AsciiString StatisticInformation() const = 0;
0432 
0433   //! Fills in the dictionary with statistic performance info.
0434   virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const = 0;
0435 
0436 public:
0437 
0438   //! Return unit scale factor defined as scale factor for m (meters); 1.0 by default.
0439   //! Normally, view definition is unitless, however some operations like VR input requires proper units mapping.
0440   Standard_Real UnitFactor() const { return myUnitFactor; }
0441 
0442   //! Set unit scale factor.
0443   Standard_EXPORT void SetUnitFactor (Standard_Real theFactor);
0444 
0445   //! Return XR session.
0446   const Handle(Aspect_XRSession)& XRSession() const { return myXRSession; }
0447 
0448   //! Set XR session.
0449   void SetXRSession (const Handle(Aspect_XRSession)& theSession) { myXRSession = theSession; }
0450 
0451   //! Return TRUE if there is active XR session.
0452   Standard_EXPORT bool IsActiveXR() const;
0453 
0454   //! Initialize XR session.
0455   Standard_EXPORT virtual bool InitXR();
0456 
0457   //! Release XR session.
0458   Standard_EXPORT virtual void ReleaseXR();
0459 
0460   //! Process input.
0461   Standard_EXPORT virtual void ProcessXRInput();
0462 
0463   //! Compute PosedXRCamera() based on current XR head pose and make it active.
0464   Standard_EXPORT void SetupXRPosedCamera();
0465 
0466   //! Set current camera back to BaseXRCamera() and copy temporary modifications of PosedXRCamera().
0467   //! Calls SynchronizeXRPosedToBaseCamera() beforehand.
0468   Standard_EXPORT void UnsetXRPosedCamera();
0469 
0470   //! Returns transient XR camera position with tracked head orientation applied.
0471   const Handle(Graphic3d_Camera)& PosedXRCamera() const { return myPosedXRCamera; }
0472 
0473   //! Sets transient XR camera position with tracked head orientation applied.
0474   void SetPosedXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myPosedXRCamera = theCamera; }
0475 
0476   //! Returns anchor camera definition (without tracked head orientation).
0477   const Handle(Graphic3d_Camera)& BaseXRCamera() const { return myBaseXRCamera; }
0478 
0479   //! Sets anchor camera definition.
0480   void SetBaseXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myBaseXRCamera = theCamera; }
0481 
0482   //! Convert XR pose to world space.
0483   //! @param thePoseXR [in] transformation defined in VR local coordinate system,
0484   //!                       oriented as Y-up, X-right and -Z-forward
0485   //! @return transformation defining orientation of XR pose in world space
0486   gp_Trsf PoseXRToWorld (const gp_Trsf& thePoseXR) const
0487   {
0488     const Handle(Graphic3d_Camera)& anOrigin = myBaseXRCamera;
0489     const gp_Ax3 anAxVr    (gp::Origin(),  gp::DZ(), gp::DX());
0490     const gp_Ax3 aCameraCS (anOrigin->Eye().XYZ(), -anOrigin->Direction(), -anOrigin->SideRight());
0491     gp_Trsf aTrsfCS;
0492     aTrsfCS.SetTransformation (aCameraCS, anAxVr);
0493     return aTrsfCS * thePoseXR;
0494   }
0495 
0496   //! Returns view direction in the world space based on XR pose.
0497   //! @param thePoseXR [in] transformation defined in VR local coordinate system,
0498   //!                       oriented as Y-up, X-right and -Z-forward
0499   gp_Ax1 ViewAxisInWorld (const gp_Trsf& thePoseXR) const
0500   {
0501     return gp_Ax1 (gp::Origin(), -gp::DZ()).Transformed (PoseXRToWorld (thePoseXR));
0502   }
0503 
0504   //! Recomputes PosedXRCamera() based on BaseXRCamera() and head orientation.
0505   Standard_EXPORT void SynchronizeXRBaseToPosedCamera();
0506 
0507   //! Checks if PosedXRCamera() has been modified since SetupXRPosedCamera()
0508   //! and copies these modifications to BaseXRCamera().
0509   Standard_EXPORT void SynchronizeXRPosedToBaseCamera();
0510 
0511   //! Compute camera position based on XR pose.
0512   Standard_EXPORT void ComputeXRPosedCameraFromBase (Graphic3d_Camera& theCam,
0513                                                      const gp_Trsf& theXRTrsf) const;
0514 
0515   //! Update based camera from posed camera by applying reversed transformation.
0516   Standard_EXPORT void ComputeXRBaseCameraFromPosed (const Graphic3d_Camera& theCamPosed,
0517                                                      const gp_Trsf& thePoseTrsf);
0518 
0519   //! Turn XR camera direction using current (head) eye position as anchor.
0520   Standard_EXPORT void TurnViewXRCamera (const gp_Trsf& theTrsfTurn);
0521 
0522 public: //! @name obsolete Graduated Trihedron functionality
0523 
0524   //! Returns data of a graduated trihedron
0525   virtual const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() { return myGTrihedronData; }
0526 
0527   //! Displays Graduated Trihedron.
0528   virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) { (void )theTrihedronData; }
0529 
0530   //! Erases Graduated Trihedron.
0531   virtual void GraduatedTrihedronErase() {}
0532 
0533   //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
0534   //! @param theMin [in] the minimum point of scene.
0535   //! @param theMax [in] the maximum point of scene.
0536   virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
0537   {
0538     (void )theMin;
0539     (void )theMax;
0540   }
0541   
0542   //! Dumps the content of me into the stream
0543   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0544 
0545 public: //! @name subview properties
0546 
0547   //! Return TRUE if this is a subview of another view.
0548   bool IsSubview() const { return myParentView != nullptr; }
0549 
0550   //! Return parent View or NULL if this is not a subview.
0551   Graphic3d_CView* ParentView() { return myParentView; }
0552 
0553   //! Return TRUE if this is view performs rendering of subviews and nothing else; FALSE by default.
0554   //! By default, view with subviews will render main scene and blit subviews on top of it.
0555   //! Rendering of main scene might become redundant in case if subviews cover entire window of parent view.
0556   //! This flag allows to disable rendering of the main scene in such scenarios
0557   //! without creation of a dedicated V3d_Viewer instance just for composing subviews.
0558   bool IsSubviewComposer() const { return myIsSubviewComposer; }
0559 
0560   //! Set if this view should perform composing of subviews and nothing else.
0561   void SetSubviewComposer (bool theIsComposer) { myIsSubviewComposer = theIsComposer; }
0562 
0563   //! Return subview list.
0564   const NCollection_Sequence<Handle(Graphic3d_CView)>& Subviews() const { return mySubviews; }
0565 
0566   //! Add subview to the list.
0567   Standard_EXPORT void AddSubview (const Handle(Graphic3d_CView)& theView);
0568 
0569   //! Remove subview from the list.
0570   Standard_EXPORT bool RemoveSubview (const Graphic3d_CView* theView);
0571 
0572   //! Return subview position within parent view; Aspect_TOTP_LEFT_UPPER by default.
0573   Aspect_TypeOfTriedronPosition SubviewCorner() const { return mySubviewCorner; }
0574 
0575   //! Set subview position within parent view.
0576   void SetSubviewCorner (Aspect_TypeOfTriedronPosition thePos) { mySubviewCorner = thePos; }
0577 
0578   //! Return subview top-left position relative to parent view in pixels.
0579   const Graphic3d_Vec2i& SubviewTopLeft() const { return mySubviewTopLeft; }
0580 
0581   //! Return TRUE if subview size is set as proportions relative to parent view.
0582   bool IsSubViewRelativeSize() const { return mySubviewSize.x() <= 1.0 && mySubviewSize.y() <= 1.0; }
0583 
0584   //! Return subview dimensions; (1.0, 1.0) by default.
0585   //! Values >= 2   define size in pixels;
0586   //! Values <= 1.0 define size as fraction of parent view.
0587   const Graphic3d_Vec2d& SubviewSize() const { return mySubviewSize; }
0588 
0589   //! Set subview size relative to parent view.
0590   void SetSubviewSize (const Graphic3d_Vec2d& theSize) { mySubviewSize = theSize; }
0591 
0592   //! Return corner offset within parent view; (0.0,0.0) by default.
0593   //! Values >= 2   define offset in pixels;
0594   //! Values <= 1.0 define offset as fraction of parent view dimensions.
0595   const Graphic3d_Vec2d& SubviewOffset() const { return mySubviewOffset; }
0596 
0597   //! Set corner offset within parent view.
0598   void SetSubviewOffset (const Graphic3d_Vec2d& theOffset) { mySubviewOffset = theOffset; }
0599 
0600   //! Return subview margins in pixels; (0,0) by default
0601   const Graphic3d_Vec2i& SubviewMargins() const { return mySubviewMargins; }
0602 
0603   //! Set subview margins in pixels.
0604   void SetSubviewMargins (const Graphic3d_Vec2i& theMargins) { mySubviewMargins = theMargins; }
0605 
0606   //! Update subview position and dimensions.
0607   Standard_EXPORT void SubviewResized (const Handle(Aspect_NeutralWindow)& theWindow);
0608 
0609 private:
0610 
0611   //! Adds the structure to display lists of the view.
0612   virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
0613                                  const Graphic3d_DisplayPriority thePriority) = 0;
0614 
0615   //! Erases the structure from display lists of the view.
0616   virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) = 0;
0617 
0618   //! Change Z layer of a structure already presented in view.
0619   virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
0620                              const Graphic3d_ZLayerId theNewLayerId) = 0;
0621 
0622   //! Changes the priority of a structure within its Z layer in the specified view.
0623   virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
0624                                const Graphic3d_DisplayPriority theNewPriority) = 0;
0625 
0626 protected:
0627 
0628   Standard_Integer myId;
0629   Graphic3d_RenderingParams myRenderParams;
0630 
0631   NCollection_Sequence<Handle(Graphic3d_CView)> mySubviews; //!< list of child views
0632   Graphic3d_CView*              myParentView;               //!< back-pointer to the parent view
0633   Standard_Boolean              myIsSubviewComposer;        //!< flag to skip rendering of viewer contents
0634   Aspect_TypeOfTriedronPosition mySubviewCorner;            //!< position within parent view
0635   Graphic3d_Vec2i               mySubviewTopLeft;           //!< subview top-left position relative to parent view
0636   Graphic3d_Vec2i               mySubviewMargins;           //!< subview margins in pixels
0637   Graphic3d_Vec2d               mySubviewSize;              //!< subview size
0638   Graphic3d_Vec2d               mySubviewOffset;            //!< subview corner offset within parent view
0639 
0640   Handle(Graphic3d_StructureManager) myStructureManager;
0641   Handle(Graphic3d_Camera)  myCamera;
0642   Graphic3d_SequenceOfStructure myStructsToCompute;
0643   Graphic3d_SequenceOfStructure myStructsComputed;
0644   Graphic3d_MapOfStructure myStructsDisplayed;
0645   Standard_Boolean myIsInComputedMode;
0646   Standard_Boolean myIsActive;
0647   Standard_Boolean myIsRemoved;
0648   Graphic3d_TypeOfBackfacingModel myBackfacing;
0649   Graphic3d_TypeOfVisualization myVisualization;
0650 
0651   Quantity_ColorRGBA           myBgColor;
0652   Handle(Graphic3d_TextureMap) myBackgroundImage;
0653   Handle(Graphic3d_CubeMap)    myCubeMapBackground;  //!< Cubemap displayed at background
0654   Handle(Graphic3d_CubeMap)    myCubeMapIBL;         //!< Cubemap used for environment lighting
0655   Handle(Graphic3d_TextureEnv) myTextureEnvData;
0656   Graphic3d_GraduatedTrihedron myGTrihedronData;
0657   Graphic3d_TypeOfBackground   myBackgroundType;     //!< Current type of background
0658   Aspect_SkydomeBackground     mySkydomeAspect;
0659   Standard_Boolean             myToUpdateSkydome;
0660 
0661   Handle(Aspect_XRSession) myXRSession;
0662   Handle(Graphic3d_Camera) myBackXRCamera;       //!< camera projection parameters to restore after closing XR session (FOV, aspect and similar)
0663   Handle(Graphic3d_Camera) myBaseXRCamera;       //!< neutral camera orientation defining coordinate system in which head tracking is defined
0664   Handle(Graphic3d_Camera) myPosedXRCamera;      //!< transient XR camera orientation with tracked head orientation applied (based on myBaseXRCamera)
0665   Handle(Graphic3d_Camera) myPosedXRCameraCopy;  //!< neutral camera orientation copy at the beginning of processing input
0666   Standard_Real            myUnitFactor;         //!< unit scale factor defined as scale factor for m (meters)
0667 
0668 };
0669 
0670 #endif // _Graphic3d_CView_HeaderFile