Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:24:38

0001 // Created on: 1992-01-15
0002 // Created by: GG
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _V3d_View_HeaderFile
0018 #define _V3d_View_HeaderFile
0019 
0020 #include <Aspect_GridParams.hxx>
0021 #include <Graphic3d_ClipPlane.hxx>
0022 #include <Graphic3d_Texture2D.hxx>
0023 #include <Graphic3d_TypeOfShadingModel.hxx>
0024 #include <Image_PixMap.hxx>
0025 #include <Quantity_TypeOfColor.hxx>
0026 #include <V3d_ImageDumpOptions.hxx>
0027 #include <V3d_Viewer.hxx>
0028 #include <V3d_Trihedron.hxx>
0029 #include <V3d_TypeOfAxe.hxx>
0030 #include <V3d_TypeOfOrientation.hxx>
0031 #include <V3d_TypeOfView.hxx>
0032 #include <V3d_TypeOfVisualization.hxx>
0033 
0034 class Aspect_Grid;
0035 class Aspect_Window;
0036 class Graphic3d_Group;
0037 class Graphic3d_Structure;
0038 class Graphic3d_TextureEnv;
0039 class Graphic3d_Vertex;
0040 
0041 //! Defines the application object VIEW for the
0042 //! VIEWER application.
0043 //! The methods of this class allow the editing
0044 //! and inquiring the parameters linked to the view.
0045 //! Provides a set of services common to all types of view.
0046 //! Warning: The default parameters are defined by the class
0047 //! Viewer (Example : SetDefaultViewSize()).
0048 //! Certain methods are mouse oriented, and it is
0049 //! necessary to know the difference between the start and
0050 //! the continuation of this gesture in putting the method
0051 //! into operation.
0052 //! Example : Shifting the eye-view along the screen axes.
0053 //!
0054 //! View->Move(10.,20.,0.,True)     (Starting motion)
0055 //! View->Move(15.,-5.,0.,False)    (Next motion)
0056 class V3d_View : public Standard_Transient
0057 {
0058   DEFINE_STANDARD_RTTIEXT(V3d_View, Standard_Transient)
0059 public:
0060   //! Initializes the view.
0061   Standard_EXPORT V3d_View(const occ::handle<V3d_Viewer>& theViewer,
0062                            const V3d_TypeOfView           theType = V3d_ORTHOGRAPHIC);
0063 
0064   //! Initializes the view by copying.
0065   Standard_EXPORT V3d_View(const occ::handle<V3d_Viewer>& theViewer,
0066                            const occ::handle<V3d_View>&   theView);
0067 
0068   //! Default destructor.
0069   Standard_EXPORT ~V3d_View() override;
0070 
0071   //! Activates the view in the specified Window
0072   //! If <aContext> is not NULL the graphic context is used
0073   //! to draw something in this view.
0074   //! Otherwise an internal graphic context is created.
0075   //! Warning: The view is centered and resized to preserve
0076   //! the height/width ratio of the window.
0077   Standard_EXPORT void SetWindow(const occ::handle<Aspect_Window>& theWindow,
0078                                  const Aspect_RenderingContext     theContext = nullptr);
0079 
0080   //! Activates the view as subview of another view.
0081   //! @param[in] theParentView parent view to put subview into
0082   //! @param[in] theSize subview dimensions;
0083   //!                    values >= 2   define size in pixels,
0084   //!                    values <= 1.0 define size as a fraction of parent view
0085   //! @param[in] theCorner corner within parent view
0086   //! @param[in] theOffset offset from the corner;
0087   //!                      values >= 1   define offset in pixels,
0088   //!                      values <  1.0 define offset as a fraction of parent view
0089   //! @param[in] theMargins subview margins in pixels
0090   //!
0091   //! Example: to split parent view horizontally into 2 subview,
0092   //! define one subview with Size=(0.5,1.0),Offset=(0.0,0.0), and 2nd with
0093   //! Size=(0.5,1.0),Offset=(5.0,0.0);
0094   Standard_EXPORT void SetWindow(
0095     const occ::handle<V3d_View>&    theParentView,
0096     const NCollection_Vec2<double>& theSize,
0097     Aspect_TypeOfTriedronPosition   theCorner  = Aspect_TOTP_LEFT_UPPER,
0098     const NCollection_Vec2<double>& theOffset  = NCollection_Vec2<double>(),
0099     const NCollection_Vec2<int>&    theMargins = NCollection_Vec2<int>());
0100 
0101   Standard_EXPORT void SetMagnify(const occ::handle<Aspect_Window>& theWindow,
0102                                   const occ::handle<V3d_View>&      thePreviousView,
0103                                   const int                         theX1,
0104                                   const int                         theY1,
0105                                   const int                         theX2,
0106                                   const int                         theY2);
0107 
0108   //! Destroys the view.
0109   Standard_EXPORT void Remove();
0110 
0111   //! Deprecated, Redraw() should be used instead.
0112   Standard_EXPORT void Update() const;
0113 
0114   //! Redisplays the view even if there has not
0115   //! been any modification.
0116   //! Must be called if the view is shown.
0117   //! (Ex: DeIconification ) .
0118   Standard_EXPORT virtual void Redraw() const;
0119 
0120   //! Updates layer of immediate presentations.
0121   Standard_EXPORT virtual void RedrawImmediate() const;
0122 
0123   //! Invalidates view content but does not redraw it.
0124   Standard_EXPORT void Invalidate() const;
0125 
0126   //! Returns true if cached view content has been invalidated.
0127   Standard_EXPORT bool IsInvalidated() const;
0128 
0129   //! Returns true if immediate layer content has been invalidated.
0130   bool IsInvalidatedImmediate() const { return myIsInvalidatedImmediate; }
0131 
0132   //! Invalidates view content within immediate layer but does not redraw it.
0133   void InvalidateImmediate() { myIsInvalidatedImmediate = true; }
0134 
0135   //! Must be called when the window supporting the
0136   //! view changes size.
0137   //! if the view is not mapped on a window.
0138   //! Warning: The view is centered and resized to preserve
0139   //! the height/width ratio of the window.
0140   Standard_EXPORT void MustBeResized();
0141 
0142   //! Must be called when the window supporting the
0143   //! view is mapped or unmapped.
0144   Standard_EXPORT void DoMapping();
0145 
0146   //! Returns the status of the view regarding
0147   //! the displayed structures inside
0148   //! Returns True is The View is empty
0149   Standard_EXPORT bool IsEmpty() const;
0150 
0151   //! Updates the lights of the view.
0152   Standard_EXPORT void UpdateLights() const;
0153 
0154   //! Sets the automatic z-fit mode and its parameters.
0155   //! The auto z-fit has extra parameters which can controlled from application level
0156   //! to ensure that the size of viewing volume will be sufficiently large to cover
0157   //! the depth of unmanaged objects, for example, transformation persistent ones.
0158   //! @param[in] theScaleFactor  the scale factor for Z-range.
0159   //! The range between Z-min, Z-max projection volume planes
0160   //! evaluated by z fitting method will be scaled using this coefficient.
0161   //! Program error exception is thrown if negative or zero value
0162   //! is passed.
0163   Standard_EXPORT void SetAutoZFitMode(const bool theIsOn, const double theScaleFactor = 1.0);
0164 
0165   //! returns TRUE if automatic z-fit mode is turned on.
0166   bool AutoZFitMode() const { return myAutoZFitIsOn; }
0167 
0168   //! returns scale factor parameter of automatic z-fit mode.
0169   double AutoZFitScaleFactor() const { return myAutoZFitScaleFactor; }
0170 
0171   //! If automatic z-range fitting is turned on, adjusts Z-min and Z-max
0172   //! projection volume planes with call to ZFitAll.
0173   Standard_EXPORT void AutoZFit() const;
0174 
0175   //! Change Z-min and Z-max planes of projection volume to match the
0176   //! displayed objects.
0177   Standard_EXPORT void ZFitAll(const double theScaleFactor = 1.0) const;
0178 
0179 public:
0180   //! Defines the background color of the view by the color definition type and the three
0181   //! corresponding values.
0182   Standard_EXPORT void SetBackgroundColor(const Quantity_TypeOfColor theType,
0183                                           const double               theV1,
0184                                           const double               theV2,
0185                                           const double               theV3);
0186 
0187   //! Defines the background color of the view.
0188   Standard_EXPORT void SetBackgroundColor(const Quantity_Color& theColor);
0189 
0190   //! Defines the gradient background colors of the view by supplying the colors
0191   //! and the fill method (horizontal by default).
0192   Standard_EXPORT void SetBgGradientColors(
0193     const Quantity_Color&           theColor1,
0194     const Quantity_Color&           theColor2,
0195     const Aspect_GradientFillMethod theFillStyle = Aspect_GradientFillMethod_Horizontal,
0196     const bool                      theToUpdate  = false);
0197 
0198   //! Defines the gradient background fill method of the view.
0199   Standard_EXPORT void SetBgGradientStyle(
0200     const Aspect_GradientFillMethod theMethod   = Aspect_GradientFillMethod_Horizontal,
0201     const bool                      theToUpdate = false);
0202 
0203   //! Defines the background texture of the view by supplying the texture image file name
0204   //! and fill method (centered by default).
0205   Standard_EXPORT void SetBackgroundImage(const char* const       theFileName,
0206                                           const Aspect_FillMethod theFillStyle = Aspect_FM_CENTERED,
0207                                           const bool              theToUpdate  = false);
0208 
0209   //! Defines the background texture of the view by supplying the texture and fill method (centered
0210   //! by default)
0211   Standard_EXPORT void SetBackgroundImage(const occ::handle<Graphic3d_Texture2D>& theTexture,
0212                                           const Aspect_FillMethod theFillStyle = Aspect_FM_CENTERED,
0213                                           const bool              theToUpdate  = false);
0214 
0215   //! Defines the textured background fill method of the view.
0216   Standard_EXPORT void SetBgImageStyle(const Aspect_FillMethod theFillStyle,
0217                                        const bool              theToUpdate = false);
0218 
0219   //! Sets environment cubemap as background.
0220   //! @param theCubeMap cubemap source to be set as background
0221   //! @param theToUpdatePBREnv defines whether IBL maps will be generated or not (see
0222   //! 'GeneratePBREnvironment')
0223   Standard_EXPORT void SetBackgroundCubeMap(const occ::handle<Graphic3d_CubeMap>& theCubeMap,
0224                                             bool theToUpdatePBREnv = true,
0225                                             bool theToUpdate       = false);
0226 
0227   //! Returns skydome aspect;
0228   const Aspect_SkydomeBackground& BackgroundSkydome() const { return myView->BackgroundSkydome(); }
0229 
0230   //! Sets skydome aspect
0231   //! @param theAspect cubemap generation parameters
0232   //! @param theToUpdatePBREnv defines whether IBL maps will be generated or not
0233   Standard_EXPORT void SetBackgroundSkydome(const Aspect_SkydomeBackground& theAspect,
0234                                             bool theToUpdatePBREnv = true);
0235 
0236   //! Returns TRUE if IBL (Image Based Lighting) from background cubemap is enabled.
0237   Standard_EXPORT bool IsImageBasedLighting() const;
0238 
0239   //! Enables or disables IBL (Image Based Lighting) from background cubemap.
0240   //! Has no effect if PBR is not used.
0241   //! @param[in] theToEnableIBL enable or disable IBL from background cubemap
0242   //! @param[in] theToUpdate redraw the view
0243   Standard_EXPORT void SetImageBasedLighting(bool theToEnableIBL, bool theToUpdate = false);
0244 
0245   //! Activates IBL from background cubemap.
0246   void GeneratePBREnvironment(bool theToUpdate = false)
0247   {
0248     SetImageBasedLighting(true, theToUpdate);
0249   }
0250 
0251   //! Disables IBL from background cubemap; fills PBR specular probe and irradiance map with white
0252   //! color.
0253   void ClearPBREnvironment(bool theToUpdate = false) { SetImageBasedLighting(true, theToUpdate); }
0254 
0255   //! Sets the environment texture to use. No environment texture by default.
0256   Standard_EXPORT void SetTextureEnv(const occ::handle<Graphic3d_TextureEnv>& theTexture);
0257 
0258   //! Definition of an axis from its origin and
0259   //! its orientation .
0260   //! This will be the current axis for rotations and movements.
0261   //! Warning! raises BadValue from V3d if the vector normal is NULL. .
0262   Standard_EXPORT void SetAxis(const double X,
0263                                const double Y,
0264                                const double Z,
0265                                const double Vx,
0266                                const double Vy,
0267                                const double Vz);
0268 
0269 public:
0270   //! Defines the visualization type in the view.
0271   Standard_EXPORT void SetVisualization(const V3d_TypeOfVisualization theType);
0272 
0273   //! Activates theLight in the view.
0274   Standard_EXPORT void SetLightOn(const occ::handle<V3d_Light>& theLight);
0275 
0276   //! Activates all the lights defined in this view.
0277   Standard_EXPORT void SetLightOn();
0278 
0279   //! Deactivate theLight in this view.
0280   Standard_EXPORT void SetLightOff(const occ::handle<V3d_Light>& theLight);
0281 
0282   //! Deactivate all the Lights defined in this view.
0283   Standard_EXPORT void SetLightOff();
0284 
0285   //! Returns TRUE when the light is active in this view.
0286   Standard_EXPORT bool IsActiveLight(const occ::handle<V3d_Light>& theLight) const;
0287 
0288   //! sets the immediate update mode and returns the previous one.
0289   Standard_EXPORT bool SetImmediateUpdate(const bool theImmediateUpdate);
0290 
0291   //! Returns trihedron object.
0292   const occ::handle<V3d_Trihedron>& Trihedron(bool theToCreate = true)
0293   {
0294     if (myTrihedron.IsNull() && theToCreate)
0295     {
0296       myTrihedron = new V3d_Trihedron();
0297     }
0298     return myTrihedron;
0299   }
0300 
0301   //! Customization of the ZBUFFER Triedron.
0302   //! XColor,YColor,ZColor - colors of axis
0303   //! SizeRatio - ratio of decreasing of the trihedron size when its physical
0304   //! position comes out of the view
0305   //! AxisDiametr - diameter relatively to axis length
0306   //! NbFacettes - number of facets of cylinders and cones
0307   Standard_EXPORT void ZBufferTriedronSetup(const Quantity_Color& theXColor    = Quantity_NOC_RED,
0308                                             const Quantity_Color& theYColor    = Quantity_NOC_GREEN,
0309                                             const Quantity_Color& theZColor    = Quantity_NOC_BLUE1,
0310                                             const double          theSizeRatio = 0.8,
0311                                             const double          theAxisDiametr = 0.05,
0312                                             const int             theNbFacettes  = 12);
0313 
0314   //! Display of the Triedron.
0315   //! Initialize position, color and length of Triedron axes.
0316   //! The scale is a percent of the window width.
0317   Standard_EXPORT void TriedronDisplay(
0318     const Aspect_TypeOfTriedronPosition thePosition = Aspect_TOTP_CENTER,
0319     const Quantity_Color&               theColor    = Quantity_NOC_WHITE,
0320     const double                        theScale    = 0.02,
0321     const V3d_TypeOfVisualization       theMode     = V3d_WIREFRAME);
0322 
0323   //! Erases the Triedron.
0324   Standard_EXPORT void TriedronErase();
0325 
0326   //! Returns data of a graduated trihedron.
0327   Standard_EXPORT const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() const;
0328 
0329   //! Displays a graduated trihedron.
0330   Standard_EXPORT void GraduatedTrihedronDisplay(
0331     const Graphic3d_GraduatedTrihedron& theTrihedronData);
0332 
0333   //! Erases a graduated trihedron from the view.
0334   Standard_EXPORT void GraduatedTrihedronErase();
0335 
0336   //! modify the Projection of the view perpendicularly to
0337   //! the privileged plane of the viewer.
0338   Standard_EXPORT void SetFront();
0339 
0340   //! Rotates the eye about the coordinate system of
0341   //! reference of the screen
0342   //! for which the origin is the view point of the projection,
0343   //! with a relative angular value in RADIANS with respect to
0344   //! the initial position expressed by Start = true
0345   //! Warning! raises BadValue from V3d
0346   //! If the eye, the view point, or the high point are
0347   //! aligned or confused.
0348   Standard_EXPORT void Rotate(const double Ax,
0349                               const double Ay,
0350                               const double Az,
0351                               const bool   Start = true);
0352 
0353   //! Rotates the eye about the coordinate system of
0354   //! reference of the screen
0355   //! for which the origin is Gravity point {X,Y,Z},
0356   //! with a relative angular value in RADIANS with respect to
0357   //! the initial position expressed by Start = true
0358   //! If the eye, the view point, or the high point are
0359   //! aligned or confused.
0360   Standard_EXPORT void Rotate(const double Ax,
0361                               const double Ay,
0362                               const double Az,
0363                               const double X,
0364                               const double Y,
0365                               const double Z,
0366                               const bool   Start = true);
0367 
0368   //! Rotates the eye about one of the coordinate axes of
0369   //! of the view for which the origin is the Gravity point{X,Y,Z}
0370   //! with an relative angular value in RADIANS with
0371   //! respect to the initial position expressed by
0372   //! Start = true
0373   Standard_EXPORT void Rotate(const V3d_TypeOfAxe Axe,
0374                               const double        Angle,
0375                               const double        X,
0376                               const double        Y,
0377                               const double        Z,
0378                               const bool          Start = true);
0379 
0380   //! Rotates the eye about one of the coordinate axes of
0381   //! of the view for which the origin is the view point of the
0382   //! projection with an relative angular value in RADIANS with
0383   //! respect to the initial position expressed by
0384   //! Start = true
0385   Standard_EXPORT void Rotate(const V3d_TypeOfAxe Axe, const double Angle, const bool Start = true);
0386 
0387   //! Rotates the eye around the current axis a relative
0388   //! angular value in RADIANS with respect to the initial
0389   //! position expressed by Start = true
0390   Standard_EXPORT void Rotate(const double Angle, const bool Start = true);
0391 
0392   //! Movement of the eye parallel to the coordinate system
0393   //! of reference of the screen a distance relative to the
0394   //! initial position expressed by Start = true.
0395   Standard_EXPORT void Move(const double Dx,
0396                             const double Dy,
0397                             const double Dz,
0398                             const bool   Start = true);
0399 
0400   //! Movement of the eye parallel to one of the axes of the
0401   //! coordinate system of reference of the view a distance
0402   //! relative to the initial position expressed by
0403   //! Start = true.
0404   Standard_EXPORT void Move(const V3d_TypeOfAxe Axe, const double Length, const bool Start = true);
0405 
0406   //! Movement of the eye parllel to the current axis
0407   //! a distance relative to the initial position
0408   //! expressed by Start = true
0409   Standard_EXPORT void Move(const double Length, const bool Start = true);
0410 
0411   //! Movement of the ye and the view point parallel to the
0412   //! frame of reference of the screen a distance relative
0413   //! to the initial position expressed by
0414   //! Start = true
0415   Standard_EXPORT void Translate(const double Dx,
0416                                  const double Dy,
0417                                  const double Dz,
0418                                  const bool   Start = true);
0419 
0420   //! Movement of the eye and the view point parallel to one
0421   //! of the axes of the fame of reference of the view a
0422   //! distance relative to the initial position
0423   //! expressed by Start = true
0424   Standard_EXPORT void Translate(const V3d_TypeOfAxe Axe,
0425                                  const double        Length,
0426                                  const bool          Start = true);
0427 
0428   //! Movement of the eye and view point parallel to
0429   //! the current axis a distance relative to the initial
0430   //! position expressed by Start = true
0431   Standard_EXPORT void Translate(const double Length, const bool Start = true);
0432 
0433   //! places the point of the view corresponding
0434   //! at the pixel position x,y at the center of the window
0435   //! and updates the view.
0436   Standard_EXPORT void Place(const int theXp, const int theYp, const double theZoomFactor = 1);
0437 
0438   //! Rotation of the view point around the frame of reference
0439   //! of the screen for which the origin is the eye of the
0440   //! projection with a relative angular value in RADIANS
0441   //! with respect to the initial position expressed by
0442   //! Start = true
0443   Standard_EXPORT void Turn(const double Ax,
0444                             const double Ay,
0445                             const double Az,
0446                             const bool   Start = true);
0447 
0448   //! Rotation of the view point around one of the axes of the
0449   //! frame of reference of the view for which the origin is
0450   //! the eye of the projection with an angular value in
0451   //! RADIANS relative to the initial position expressed by
0452   //! Start = true
0453   Standard_EXPORT void Turn(const V3d_TypeOfAxe Axe, const double Angle, const bool Start = true);
0454 
0455   //! Rotation of the view point around the current axis an
0456   //! angular value in RADIANS relative to the initial
0457   //! position expressed by Start = true
0458   Standard_EXPORT void Turn(const double Angle, const bool Start = true);
0459 
0460   //! Defines the angular position of the high point of
0461   //! the reference frame of the view with respect to the
0462   //! Y screen axis with an absolute angular value in
0463   //! RADIANS.
0464   Standard_EXPORT void SetTwist(const double Angle);
0465 
0466   //! Defines the position of the eye..
0467   Standard_EXPORT void SetEye(const double X, const double Y, const double Z);
0468 
0469   //! Defines the Depth of the eye from the view point
0470   //! without update the projection .
0471   Standard_EXPORT void SetDepth(const double Depth);
0472 
0473   //! Defines the orientation of the projection.
0474   Standard_EXPORT void SetProj(const double Vx, const double Vy, const double Vz);
0475 
0476   //! Defines the orientation of the projection .
0477   //! @param theOrientation camera direction
0478   //! @param theIsYup       flag indicating Y-up (TRUE) or Z-up (FALSE) convention
0479   Standard_EXPORT void SetProj(const V3d_TypeOfOrientation theOrientation,
0480                                const bool                  theIsYup = false);
0481 
0482   //! Defines the position of the view point.
0483   Standard_EXPORT void SetAt(const double X, const double Y, const double Z);
0484 
0485   //! Defines the orientation of the high point.
0486   Standard_EXPORT void SetUp(const double Vx, const double Vy, const double Vz);
0487 
0488   //! Defines the orientation(SO) of the high point.
0489   Standard_EXPORT void SetUp(const V3d_TypeOfOrientation Orientation);
0490 
0491   //! Saves the current state of the orientation of the view
0492   //! which will be the return state at ResetViewOrientation.
0493   Standard_EXPORT void SetViewOrientationDefault();
0494 
0495   //! Resets the orientation of the view.
0496   //! Updates the view
0497   Standard_EXPORT void ResetViewOrientation();
0498 
0499   //! Translates the center of the view along "x" and "y" axes of
0500   //! view projection. Can be used to perform interactive panning operation.
0501   //! In that case the DXv, DXy parameters specify panning relative to the
0502   //! point where the operation is started.
0503   //! @param[in] theDXv  the relative panning on "x" axis of view projection, in view space
0504   //! coordinates.
0505   //! @param[in] theDYv  the relative panning on "y" axis of view projection, in view space
0506   //! coordinates.
0507   //! @param[in] theZoomFactor  the zooming factor.
0508   //! @param[in] theToStart  pass TRUE when starting panning to remember view
0509   //! state prior to panning for relative arguments. If panning is started,
0510   //! passing {0, 0} for {theDXv, theDYv} will return view to initial state.
0511   //! Performs update of view.
0512   Standard_EXPORT void Panning(const double theDXv,
0513                                const double theDYv,
0514                                const double theZoomFactor = 1,
0515                                const bool   theToStart    = true);
0516 
0517   //! Relocates center of screen to the point, determined by
0518   //! {Xp, Yp} pixel coordinates relative to the bottom-left corner of
0519   //! screen. To calculate pixel coordinates for any point from world
0520   //! coordinate space, it can be projected using "Project".
0521   //! @param[in] theXp  the x coordinate.
0522   //! @param[in] theYp  the y coordinate.
0523   Standard_EXPORT void SetCenter(const int theXp, const int theYp);
0524 
0525   //! Defines the view projection size in its maximum dimension,
0526   //! keeping the initial height/width ratio unchanged.
0527   Standard_EXPORT void SetSize(const double theSize);
0528 
0529   //! Defines the Depth size of the view
0530   //! Front Plane will be set to Size/2.
0531   //! Back Plane will be set to -Size/2.
0532   //! Any Object located Above the Front Plane or
0533   //! behind the Back Plane will be Clipped .
0534   //! NOTE than the XY Size of the View is NOT modified .
0535   Standard_EXPORT void SetZSize(const double SetZSize);
0536 
0537   //! Zooms the view by a factor relative to the initial
0538   //! value expressed by Start = true
0539   //! Updates the view.
0540   Standard_EXPORT void SetZoom(const double Coef, const bool Start = true);
0541 
0542   //! Zooms the view by a factor relative to the value
0543   //! initialised by SetViewMappingDefault().
0544   //! Updates the view.
0545   Standard_EXPORT void SetScale(const double Coef);
0546 
0547   //! Sets anisotropic (axial) scale factors <Sx>, <Sy>, <Sz> for view <me>.
0548   //! Anisotropic scaling operation is performed through multiplying
0549   //! the current view orientation matrix by a scaling matrix:
0550   //! || Sx  0   0   0 ||
0551   //! || 0   Sy  0   0 ||
0552   //! || 0   0   Sz  0 ||
0553   //! || 0   0   0   1 ||
0554   //! Updates the view.
0555   Standard_EXPORT void SetAxialScale(const double Sx, const double Sy, const double Sz);
0556 
0557   //! Adjust view parameters to fit the displayed scene, respecting height / width ratio.
0558   //! The Z clipping range (depth range) is fitted if AutoZFit flag is TRUE.
0559   //! Throws program error exception if margin coefficient is < 0 or >= 1.
0560   //! Updates the view.
0561   //! @param[in] theMargin  the margin coefficient for view borders.
0562   //! @param[in] theToUpdate  flag to perform view update.
0563   Standard_EXPORT void FitAll(const double theMargin = 0.01, const bool theToUpdate = true);
0564 
0565   //! Adjust view parameters to fit the displayed scene, respecting height / width ratio
0566   //! according to the custom bounding box given.
0567   //! Throws program error exception if margin coefficient is < 0 or >= 1.
0568   //! Updates the view.
0569   //! @param[in] theBox  the custom bounding box to fit.
0570   //! @param[in] theMargin  the margin coefficient for view borders.
0571   //! @param[in] theToUpdate  flag to perform view update.
0572   Standard_EXPORT void FitAll(const Bnd_Box& theBox,
0573                               const double   theMargin   = 0.01,
0574                               const bool     theToUpdate = true);
0575 
0576   //! Adjusts the viewing volume so as not to clip the displayed objects by front and back
0577   //! and back clipping planes. Also sets depth value automatically depending on the
0578   //! calculated Z size and Aspect parameter.
0579   //! NOTE than the original XY size of the view is NOT modified .
0580   Standard_EXPORT void DepthFitAll(const double Aspect = 0.01, const double Margin = 0.01);
0581 
0582   //! Centers the defined projection window so that it occupies
0583   //! the maximum space while respecting the initial
0584   //! height/width ratio.
0585   //! NOTE than the original Z size of the view is NOT modified .
0586   Standard_EXPORT void FitAll(const double theMinXv,
0587                               const double theMinYv,
0588                               const double theMaxXv,
0589                               const double theMaxYv);
0590 
0591   //! Centers the defined PIXEL window so that it occupies
0592   //! the maximum space while respecting the initial height/width ratio.
0593   //! NOTE than the original Z size of the view is NOT modified.
0594   //! @param[in] theMinXp  pixel coordinates of minimal corner on x screen axis.
0595   //! @param[in] theMinYp  pixel coordinates of minimal corner on y screen axis.
0596   //! @param[in] theMaxXp  pixel coordinates of maximal corner on x screen axis.
0597   //! @param[in] theMaxYp  pixel coordinates of maximal corner on y screen axis.
0598   Standard_EXPORT void WindowFit(const int theMinXp,
0599                                  const int theMinYp,
0600                                  const int theMaxXp,
0601                                  const int theMaxYp);
0602 
0603   //! Saves the current view mapping. This will be the
0604   //! state returned from ResetViewmapping.
0605   Standard_EXPORT void SetViewMappingDefault();
0606 
0607   //! Resets the centering of the view.
0608   //! Updates the view
0609   Standard_EXPORT void ResetViewMapping();
0610 
0611   //! Resets the centering and the orientation of the view.
0612   Standard_EXPORT void Reset(const bool theToUpdate = true);
0613 
0614   //! Converts the PIXEL value
0615   //! to a value in the projection plane.
0616   Standard_EXPORT double Convert(const int Vp) const;
0617 
0618   //! Converts the point PIXEL into a point projected
0619   //! in the reference frame of the projection plane.
0620   Standard_EXPORT void Convert(const int Xp, const int Yp, double& Xv, double& Yv) const;
0621 
0622   //! Converts tha value of the projection plane into
0623   //! a PIXEL value.
0624   Standard_EXPORT int Convert(const double Vv) const;
0625 
0626   //! Converts the point defined in the reference frame
0627   //! of the projection plane into a point PIXEL.
0628   Standard_EXPORT void Convert(const double Xv, const double Yv, int& Xp, int& Yp) const;
0629 
0630   //! Converts the projected point into a point
0631   //! in the reference frame of the view corresponding
0632   //! to the intersection with the projection plane
0633   //! of the eye/view point vector.
0634   Standard_EXPORT void Convert(const int Xp, const int Yp, double& X, double& Y, double& Z) const;
0635 
0636   //! Converts the projected point into a point
0637   //! in the reference frame of the view corresponding
0638   //! to the intersection with the projection plane
0639   //! of the eye/view point vector and returns the
0640   //! projection ray for further computations.
0641   Standard_EXPORT void ConvertWithProj(const int Xp,
0642                                        const int Yp,
0643                                        double&   X,
0644                                        double&   Y,
0645                                        double&   Z,
0646                                        double&   Vx,
0647                                        double&   Vy,
0648                                        double&   Vz) const;
0649 
0650   //! Converts the projected point into the nearest grid point
0651   //! in the reference frame of the view corresponding
0652   //! to the intersection with the projection plane
0653   //! of the eye/view point vector and display the grid marker.
0654   //! Warning: When the grid is not active the result is identical to the above Convert() method.
0655   //! How to use:
0656   //! 1) Enable the grid echo display
0657   //! myViewer->SetGridEcho(true);
0658   //! 2) When application receive a move event:
0659   //! 2.1) Check if any object is detected
0660   //! if( myInteractiveContext->MoveTo(x,y) == AIS_SOD_Nothing ) {
0661   //! 2.2) Check if the grid is active
0662   //! if( myViewer->Grid()->IsActive() ) {
0663   //! 2.3) Display the grid echo and gets the grid point
0664   //! myView->ConvertToGrid(x,y,X,Y,Z);
0665   //! myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (X,Y,Z));
0666   //! myView->RedrawImmediate();
0667   //! 2.4) Else this is the standard case
0668   //! } else myView->Convert(x,y,X,Y,Z);
0669   Standard_EXPORT void ConvertToGrid(const int Xp,
0670                                      const int Yp,
0671                                      double&   Xg,
0672                                      double&   Yg,
0673                                      double&   Zg) const;
0674 
0675   //! Converts the projected point into the nearest visible grid point.
0676   //! @return TRUE when an active grid accepts the point; FALSE otherwise.
0677   //! Unlike the double-output overload, this method has no unproject fallback
0678   //! and is intended for grid echo / snap-hit callers.
0679   Standard_EXPORT bool ConvertToGrid(const int         Xp,
0680                                      const int         Yp,
0681                                      Graphic3d_Vertex& theGridPoint) const;
0682 
0683   //! Converts the projected point into the nearest visible grid point and echo display point.
0684   //! The echo display point is suitable only for displaying the grid echo marker.
0685   Standard_EXPORT bool ConvertToGridEcho(const int         Xp,
0686                                          const int         Yp,
0687                                          Graphic3d_Vertex& theGridPoint,
0688                                          Graphic3d_Vertex& theEchoPoint) const;
0689 
0690   //! Converts the point into the nearest grid point
0691   //! and display the grid marker.
0692   Standard_EXPORT void ConvertToGrid(const double X,
0693                                      const double Y,
0694                                      const double Z,
0695                                      double&      Xg,
0696                                      double&      Yg,
0697                                      double&      Zg) const;
0698 
0699   //! Projects the point defined in the reference frame of
0700   //! the view into the projected point in the associated window.
0701   Standard_EXPORT void Convert(const double X,
0702                                const double Y,
0703                                const double Z,
0704                                int&         Xp,
0705                                int&         Yp) const;
0706 
0707   //! Converts the point defined in the user space of
0708   //! the view to the projection plane at the depth
0709   //! relative to theZ.
0710   Standard_EXPORT void Project(const double theX,
0711                                const double theY,
0712                                const double theZ,
0713                                double&      theXp,
0714                                double&      theYp) const;
0715 
0716   //! Converts the point defined in the user space of
0717   //! the view to the projection plane at the depth
0718   //! relative to theZ.
0719   Standard_EXPORT void Project(const double theX,
0720                                const double theY,
0721                                const double theZ,
0722                                double&      theXp,
0723                                double&      theYp,
0724                                double&      theZp) const;
0725 
0726   //! Returns the Background color values of the view
0727   //! depending of the color Type.
0728   Standard_EXPORT void BackgroundColor(const Quantity_TypeOfColor Type,
0729                                        double&                    V1,
0730                                        double&                    V2,
0731                                        double&                    V3) const;
0732 
0733   //! Returns the Background color object of the view.
0734   Standard_EXPORT Quantity_Color BackgroundColor() const;
0735 
0736   //! Returns the gradient background colors of the view.
0737   Standard_EXPORT void GradientBackgroundColors(Quantity_Color& theColor1,
0738                                                 Quantity_Color& theColor2) const;
0739 
0740   //! Returns the gradient background of the view.
0741   Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
0742 
0743   //! Returns the current value of the zoom expressed with
0744   //! respect to SetViewMappingDefault().
0745   Standard_EXPORT double Scale() const;
0746 
0747   //! Returns the current values of the anisotropic (axial) scale factors.
0748   Standard_EXPORT void AxialScale(double& Sx, double& Sy, double& Sz) const;
0749 
0750   //! Returns the height and width of the view.
0751   Standard_EXPORT void Size(double& Width, double& Height) const;
0752 
0753   //! Returns the Depth of the view .
0754   Standard_EXPORT double ZSize() const;
0755 
0756   //! Returns the position of the eye.
0757   Standard_EXPORT void Eye(double& X, double& Y, double& Z) const;
0758 
0759   //! Returns the position of point which emanating the projections.
0760   void FocalReferencePoint(double& X, double& Y, double& Z) const { Eye(X, Y, Z); }
0761 
0762   //! Returns the coordinate of the point (Xpix,Ypix)
0763   //! in the view (XP,YP,ZP), and the projection vector of the
0764   //! view passing by the point (for PerspectiveView).
0765   Standard_EXPORT void ProjReferenceAxe(const int Xpix,
0766                                         const int Ypix,
0767                                         double&   XP,
0768                                         double&   YP,
0769                                         double&   ZP,
0770                                         double&   VX,
0771                                         double&   VY,
0772                                         double&   VZ) const;
0773 
0774   //! Returns the Distance between the Eye and View Point.
0775   Standard_EXPORT double Depth() const;
0776 
0777   //! Returns the projection vector.
0778   Standard_EXPORT void Proj(double& Vx, double& Vy, double& Vz) const;
0779 
0780   //! Returns the position of the view point.
0781   Standard_EXPORT void At(double& X, double& Y, double& Z) const;
0782 
0783   //! Returns the vector giving the position of the high point.
0784   Standard_EXPORT void Up(double& Vx, double& Vy, double& Vz) const;
0785 
0786   //! Returns in RADIANS the orientation of the view around
0787   //! the visual axis measured from the Y axis of the screen.
0788   Standard_EXPORT double Twist() const;
0789 
0790   //! Returns the current shading model; Graphic3d_TypeOfShadingModel_Phong by default.
0791   Standard_EXPORT Graphic3d_TypeOfShadingModel ShadingModel() const;
0792 
0793   //! Defines the shading model for the visualization.
0794   Standard_EXPORT void SetShadingModel(const Graphic3d_TypeOfShadingModel theShadingModel);
0795 
0796   Standard_EXPORT occ::handle<Graphic3d_TextureEnv> TextureEnv() const;
0797 
0798   //! Returns the current visualisation mode.
0799   Standard_EXPORT V3d_TypeOfVisualization Visualization() const;
0800 
0801   //! Returns a list of active lights.
0802   const NCollection_List<occ::handle<Graphic3d_CLight>>& ActiveLights() const
0803   {
0804     return myActiveLights;
0805   }
0806 
0807   //! Return iterator for defined lights.
0808   NCollection_List<occ::handle<Graphic3d_CLight>>::Iterator ActiveLightIterator() const
0809   {
0810     return NCollection_List<occ::handle<Graphic3d_CLight>>::Iterator(myActiveLights);
0811   }
0812 
0813   //! Returns the MAX number of light associated to the view.
0814   Standard_EXPORT int LightLimit() const;
0815 
0816   //! Returns the viewer in which the view has been created.
0817   occ::handle<V3d_Viewer> Viewer() const { return MyViewer; }
0818 
0819   //! Returns True if MyView is associated with a window .
0820   Standard_EXPORT bool IfWindow() const;
0821 
0822   //! Returns the Aspect Window associated with the view.
0823   const occ::handle<Aspect_Window>& Window() const { return MyWindow; }
0824 
0825   //! Returns the Type of the View
0826   Standard_EXPORT V3d_TypeOfView Type() const;
0827 
0828   //! Translates the center of the view along "x" and "y" axes of
0829   //! view projection. Can be used to perform interactive panning operation.
0830   //! In that case the DXp, DXp parameters specify panning relative to the
0831   //! point where the operation is started.
0832   //! @param[in] theDXp  the relative panning on "x" axis of view projection, in pixels.
0833   //! @param[in] theDYp  the relative panning on "y" axis of view projection, in pixels.
0834   //! @param[in] theZoomFactor  the zooming factor.
0835   //! @param[in] theToStart  pass TRUE when starting panning to remember view
0836   //! state prior to panning for relative arguments. Passing 0 for relative
0837   //! panning parameter should return view panning to initial state.
0838   //! Performs update of view.
0839   Standard_EXPORT void Pan(const int    theDXp,
0840                            const int    theDYp,
0841                            const double theZoomFactor = 1,
0842                            const bool   theToStart    = true);
0843 
0844   //! Zoom the view according to a zoom factor computed
0845   //! from the distance between the 2 mouse position.
0846   //! @param[in] theXp1  the x coordinate of first mouse position, in pixels.
0847   //! @param[in] theYp1  the y coordinate of first mouse position, in pixels.
0848   //! @param[in] theXp2  the x coordinate of second mouse position, in pixels.
0849   //! @param[in] theYp2  the y coordinate of second mouse position, in pixels.
0850   Standard_EXPORT void Zoom(const int theXp1, const int theYp1, const int theXp2, const int theYp2);
0851 
0852   //! Defines starting point for ZoomAtPoint view operation.
0853   //! @param[in] theXp  the x mouse coordinate, in pixels.
0854   //! @param[in] theYp  the y mouse coordinate, in pixels.
0855   Standard_EXPORT void StartZoomAtPoint(const int theXp, const int theYp);
0856 
0857   //! Zooms the model at a pixel defined by the method StartZoomAtPoint().
0858   Standard_EXPORT void ZoomAtPoint(const int theMouseStartX,
0859                                    const int theMouseStartY,
0860                                    const int theMouseEndX,
0861                                    const int theMouseEndY);
0862 
0863   //! Performs anisotropic scaling of <me> view along the given <Axis>.
0864   //! The scale factor is calculated on a basis of
0865   //! the mouse pointer displacement <Dx,Dy>.
0866   //! The calculated scale factor is then passed to SetAxialScale(Sx, Sy, Sz) method.
0867   Standard_EXPORT void AxialScale(const int Dx, const int Dy, const V3d_TypeOfAxe Axis);
0868 
0869   //! Begin the rotation of the view around the screen axis
0870   //! according to the mouse position <X,Y>.
0871   //! Warning: Enable rotation around the Z screen axis when <zRotationThreshold>
0872   //! factor is > 0 soon the distance from the start point and the center
0873   //! of the view is > (medium viewSize * <zRotationThreshold> ).
0874   //! Generally a value of 0.4 is usable to rotate around XY screen axis
0875   //! inside the circular threshold area and to rotate around Z screen axis
0876   //! outside this area.
0877   Standard_EXPORT void StartRotation(const int    X,
0878                                      const int    Y,
0879                                      const double zRotationThreshold = 0.0);
0880 
0881   //! Continues the rotation of the view
0882   //! with an angle computed from the last and new mouse position <X,Y>.
0883   Standard_EXPORT void Rotation(const int X, const int Y);
0884 
0885   //! Change View Plane Distance for Perspective Views
0886   //! Warning! raises TypeMismatch from Standard if the view
0887   //! is not a perspective view.
0888   Standard_EXPORT void SetFocale(const double Focale);
0889 
0890   //! Returns the View Plane Distance for Perspective Views
0891   Standard_EXPORT double Focale() const;
0892 
0893   //! Returns the associated Graphic3d view.
0894   const occ::handle<Graphic3d_CView>& View() const { return myView; }
0895 
0896   //! Switches computed HLR mode in the view.
0897   Standard_EXPORT void SetComputedMode(const bool theMode);
0898 
0899   //! Returns the computed HLR mode state.
0900   Standard_EXPORT bool ComputedMode() const;
0901 
0902   //! idem than WindowFit
0903   void WindowFitAll(const int Xmin, const int Ymin, const int Xmax, const int Ymax)
0904   {
0905     WindowFit(Xmin, Ymin, Xmax, Ymax);
0906   }
0907 
0908   //! Transform camera eye, center and scale to fit in the passed bounding box specified in WCS.
0909   //! @param[in] theCamera  the camera
0910   //! @param[in] theBox     the bounding box
0911   //! @param[in] theMargin  the margin coefficient for view borders
0912   //! @param[in] theResolution  the minimum size of projection of bounding box in Xv or Yv direction
0913   //! when it considered to be a thin plane or point (without a volume);
0914   //!                           in this case only the center of camera is adjusted
0915   //! @param[in] theToEnlargeIfLine  when TRUE - in cases when the whole bounding box projected into
0916   //! thin line going along Z-axis of screen,
0917   //!                                the view plane is enlarged such thatwe see the whole line on
0918   //!                                rotation, otherwise only the center of camera is adjusted.
0919   //! @return TRUE if the fit all operation can be done
0920   Standard_EXPORT bool FitMinMax(const occ::handle<Graphic3d_Camera>& theCamera,
0921                                  const Bnd_Box&                       theBox,
0922                                  const double                         theMargin,
0923                                  const double                         theResolution = 0.0,
0924                                  const bool theToEnlargeIfLine                      = true) const;
0925 
0926 public: //! @name Viewer grid plumbing
0927   //! Viewer-managed grid plane and snap object. It is separate from the per-view
0928   //! shader grid controlled by GridDisplay().
0929 
0930   //! Defines or updates the grid plane and snap object on this view.
0931   //! @param[in] aPlane grid plane (origin + axes)
0932   //! @param[in] aGrid  snap object (Aspect_RectangularGrid or Aspect_CircularGrid)
0933   Standard_EXPORT void SetGrid(const gp_Ax3& aPlane, const occ::handle<Aspect_Grid>& aGrid);
0934 
0935   //! Activates / deactivates snap on this view.
0936   //! @param[in] aFlag true to enable snap, false to disable
0937   Standard_EXPORT void SetGridActivity(const bool aFlag);
0938 
0939   //! Return TRUE if either viewer-managed grid or per-view shader grid is active.
0940   bool IsGridActive() const { return MyViewer->IsGridActive() || myShaderGridActive; }
0941 
0942   //! Return TRUE if the per-view shader grid is active.
0943   bool IsShaderGridActive() const { return myShaderGridActive; }
0944 
0945 public: //! @name Shader grid
0946   //! Per-view immediate-mode shader grid; supports unbounded extents, AA, background,
0947   //! circular grids, arc range and view-adaptive spacing.
0948 
0949   //! Display a shader-rendered grid on the viewer's privileged plane.
0950   //! @param[in] theParams appearance: color, scale, bounds, arc, draw-mode, background /
0951   //! view-adaptive flags
0952   Standard_EXPORT void GridDisplay(const Aspect_GridParams& theParams);
0953 
0954   //! Display a shader-rendered grid on an explicit plane (overrides the viewer's
0955   //! privileged plane for this view only).
0956   //! @param[in] theParams appearance parameters; see the single-argument overload
0957   //! @param[in] thePlane  world-space grid plane (origin + axes)
0958   Standard_EXPORT void GridDisplay(const Aspect_GridParams& theParams, const gp_Ax3& thePlane);
0959 
0960   //! Erase the shader-rendered grid from this view.
0961   Standard_EXPORT void GridErase();
0962 
0963   //! Dumps the full contents of the View into the image file. This is an alias for ToPixMap() with
0964   //! Image_AlienPixMap.
0965   //! @param theFile destination image file (image format is determined by file extension like .png,
0966   //! .bmp, .jpg)
0967   //! @param theBufferType buffer to dump
0968   //! @return FALSE when the dump has failed
0969   Standard_EXPORT bool Dump(const char* const           theFile,
0970                             const Graphic3d_BufferType& theBufferType = Graphic3d_BT_RGB);
0971 
0972   //! Dumps the full contents of the view to a pixmap with specified parameters.
0973   //! Internally this method calls Redraw() with an offscreen render buffer of requested target size
0974   //! (theWidth x theHeight), so that there is no need resizing a window control for making a dump
0975   //! of different size.
0976   Standard_EXPORT bool ToPixMap(Image_PixMap& theImage, const V3d_ImageDumpOptions& theParams);
0977 
0978   //! Dumps the full contents of the view to a pixmap.
0979   //! Internally this method calls Redraw() with an offscreen render buffer of requested target size
0980   //! (theWidth x theHeight), so that there is no need resizing a window control for making a dump
0981   //! of different size.
0982   //! @param theImage          target image, will be re-allocated to match theWidth x theHeight
0983   //! @param theWidth          target image width
0984   //! @param theHeight         target image height
0985   //! @param theBufferType     type of the view buffer to dump (color / depth)
0986   //! @param theToAdjustAspect when true, active view aspect ratio will be overridden by (theWidth /
0987   //! theHeight)
0988   //! @param theStereoOptions  how to dump stereographic camera
0989   bool ToPixMap(Image_PixMap&               theImage,
0990                 const int                   theWidth,
0991                 const int                   theHeight,
0992                 const Graphic3d_BufferType& theBufferType     = Graphic3d_BT_RGB,
0993                 const bool                  theToAdjustAspect = true,
0994                 const Graphic3d_ZLayerId    theTargetZLayerId = Graphic3d_ZLayerId_BotOSD,
0995                 const int                   theIsSingleLayer  = false,
0996                 const V3d_StereoDumpOptions theStereoOptions  = V3d_SDO_MONO,
0997                 const char* const           theLightName      = "")
0998   {
0999     V3d_ImageDumpOptions aParams;
1000     aParams.Width          = theWidth;
1001     aParams.Height         = theHeight;
1002     aParams.BufferType     = theBufferType;
1003     aParams.StereoOptions  = theStereoOptions;
1004     aParams.ToAdjustAspect = theToAdjustAspect;
1005     aParams.TargetZLayerId = theTargetZLayerId;
1006     aParams.IsSingleLayer  = theIsSingleLayer;
1007     aParams.LightName      = theLightName;
1008     return ToPixMap(theImage, aParams);
1009   }
1010 
1011   //! Manages display of the back faces
1012   Standard_EXPORT void SetBackFacingModel(
1013     const Graphic3d_TypeOfBackfacingModel theModel = Graphic3d_TypeOfBackfacingModel_Auto);
1014 
1015   //! Returns current state of the back faces display; Graphic3d_TypeOfBackfacingModel_Auto by
1016   //! default, which means that backface culling is defined by each presentation.
1017   Standard_EXPORT Graphic3d_TypeOfBackfacingModel BackFacingModel() const;
1018 
1019   //! Adds clip plane to the view. The composition of clip planes truncates the
1020   //! rendering space to convex volume. Number of supported clip planes can be consulted
1021   //! by PlaneLimit method of associated Graphic3d_GraphicDriver.
1022   //! Please be aware that the planes which exceed the limit are ignored during rendering.
1023   //! @param[in] thePlane  the clip plane to be added to view.
1024   Standard_EXPORT virtual void AddClipPlane(const occ::handle<Graphic3d_ClipPlane>& thePlane);
1025 
1026   //! Removes clip plane from the view.
1027   //! @param[in] thePlane  the clip plane to be removed from view.
1028   Standard_EXPORT virtual void RemoveClipPlane(const occ::handle<Graphic3d_ClipPlane>& thePlane);
1029 
1030   //! Get clip planes.
1031   //! @return sequence clip planes that have been set for the view
1032   Standard_EXPORT const occ::handle<Graphic3d_SequenceOfHClipPlane>& ClipPlanes() const;
1033 
1034   //! Sets sequence of clip planes to the view. The planes that have been set
1035   //! before are removed from the view. The composition of clip planes
1036   //! truncates the rendering space to convex volume. Number of supported
1037   //! clip planes can be consulted by InquirePlaneLimit method of
1038   //! Graphic3d_GraphicDriver. Please be aware that the planes that
1039   //! exceed the limit are ignored during rendering.
1040   //! @param[in] thePlanes  the clip planes to set.
1041   Standard_EXPORT void SetClipPlanes(const occ::handle<Graphic3d_SequenceOfHClipPlane>& thePlanes);
1042 
1043   //! Returns the MAX number of clipping planes associated to the view.
1044   Standard_EXPORT int PlaneLimit() const;
1045 
1046   //! Change camera used by view.
1047   Standard_EXPORT void SetCamera(const occ::handle<Graphic3d_Camera>& theCamera);
1048 
1049   //! Returns camera object of the view.
1050   //! @return: handle to camera object, or NULL if 3D view does not use
1051   //! the camera approach.
1052   Standard_EXPORT const occ::handle<Graphic3d_Camera>& Camera() const;
1053 
1054   //! Return default camera.
1055   const occ::handle<Graphic3d_Camera>& DefaultCamera() const { return myDefaultCamera; }
1056 
1057   //! Returns current rendering parameters and effect settings.
1058   //! By default it returns default parameters of current viewer.
1059   //! To define view-specific settings use method V3d_View::ChangeRenderingParams().
1060   //! @sa V3d_Viewer::DefaultRenderingParams()
1061   Standard_EXPORT const Graphic3d_RenderingParams& RenderingParams() const;
1062 
1063   //! Returns reference to current rendering parameters and effect settings.
1064   Standard_EXPORT Graphic3d_RenderingParams& ChangeRenderingParams();
1065 
1066   //! @return flag value of objects culling mechanism
1067   bool IsCullingEnabled() const
1068   {
1069     return RenderingParams().FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On;
1070   }
1071 
1072   //! Turn on/off automatic culling of objects outside frustum (ON by default)
1073   void SetFrustumCulling(bool theMode)
1074   {
1075     ChangeRenderingParams().FrustumCullingState = theMode
1076                                                     ? Graphic3d_RenderingParams::FrustumCulling_On
1077                                                     : Graphic3d_RenderingParams::FrustumCulling_Off;
1078   }
1079 
1080   //! Fill in the dictionary with diagnostic info.
1081   //! Should be called within rendering thread.
1082   //!
1083   //! This API should be used only for user output or for creating automated reports.
1084   //! The format of returned information (e.g. key-value layout)
1085   //! is NOT part of this API and can be changed at any time.
1086   //! Thus application should not parse returned information to weed out specific parameters.
1087   //! @param theDict  destination map for information
1088   //! @param theFlags defines the information to be retrieved
1089   Standard_EXPORT void DiagnosticInformation(
1090     NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theDict,
1091     Graphic3d_DiagnosticInfo                                                      theFlags) const;
1092 
1093   //! Returns string with statistic performance info.
1094   Standard_EXPORT TCollection_AsciiString StatisticInformation() const;
1095 
1096   //! Fills in the dictionary with statistic performance info.
1097   Standard_EXPORT void StatisticInformation(
1098     NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theDict) const;
1099 
1100   //! Returns the Objects number and the gravity center of ALL viewable points in the view
1101   Standard_EXPORT gp_Pnt GravityPoint() const;
1102 
1103   //! Dumps the content of me into the stream
1104   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
1105 
1106 public: //! @name subvew management
1107   //! Return TRUE if this is a subview of another view.
1108   bool IsSubview() const { return myParentView != nullptr; }
1109 
1110   //! Return parent View or NULL if this is not a subview.
1111   V3d_View* ParentView() { return myParentView; }
1112 
1113   //! Return subview list.
1114   const NCollection_Sequence<occ::handle<V3d_View>>& Subviews() const { return mySubviews; }
1115 
1116   //! Pick subview from the given 2D point.
1117   Standard_EXPORT occ::handle<V3d_View> PickSubview(const NCollection_Vec2<int>& thePnt) const;
1118 
1119   //! Add subview to the list.
1120   Standard_EXPORT void AddSubview(const occ::handle<V3d_View>& theView);
1121 
1122   //! Remove subview from the list.
1123   Standard_EXPORT bool RemoveSubview(const V3d_View* theView);
1124 
1125 public: //! @name deprecated methods
1126   //! Returns True if One light more can be
1127   //! activated in this View.
1128   Standard_DEPRECATED("Deprecated method - ActiveLights() should be used instead")
1129   Standard_EXPORT bool IfMoreLights() const;
1130 
1131   //! initializes an iteration on the active Lights.
1132   Standard_DEPRECATED("Deprecated method - ActiveLights() should be used instead")
1133   void InitActiveLights() { myActiveLightsIterator.Initialize(myActiveLights); }
1134 
1135   //! returns true if there are more active Light(s) to return.
1136   Standard_DEPRECATED("Deprecated method - ActiveLights() should be used instead")
1137   bool MoreActiveLights() const { return myActiveLightsIterator.More(); }
1138 
1139   //! Go to the next active Light (if there is not, ActiveLight will raise an exception)
1140   Standard_DEPRECATED("Deprecated method - ActiveLights() should be used instead")
1141   void NextActiveLights() { myActiveLightsIterator.Next(); }
1142 
1143   Standard_DEPRECATED("Deprecated method - ActiveLights() should be used instead")
1144   const occ::handle<V3d_Light>& ActiveLight() const { return myActiveLightsIterator.Value(); }
1145 
1146 protected:
1147   Standard_EXPORT void ImmediateUpdate() const;
1148 
1149   //! Scales camera to fit the view frame of defined width and height
1150   //! keeping the aspect. For orthogonal camera the method changes scale,
1151   //! for perspective adjusts Eye location about the Center point.
1152   //! @param[in] theSizeXv  size of viewport frame on "x" axis.
1153   //! @param[in] theSizeYv  size of viewport frame on "y" axis.
1154   Standard_EXPORT void Scale(const occ::handle<Graphic3d_Camera>& theCamera,
1155                              const double                         theSizeXv,
1156                              const double                         theSizeYv) const;
1157 
1158   Standard_EXPORT void Translate(const occ::handle<Graphic3d_Camera>& theCamera,
1159                                  const double                         theDXv,
1160                                  const double                         theDYv) const;
1161 
1162 private:
1163   //! Modifies the aspect ratio of the camera when
1164   //! the associated window is defined or resized.
1165   Standard_EXPORT void SetRatio();
1166 
1167   //! Determines the screen axes in the reference
1168   //! framework of the view.
1169   Standard_EXPORT static bool screenAxis(const gp_Dir& theVpn,
1170                                          const gp_Dir& theVup,
1171                                          gp_Vec&       theXaxe,
1172                                          gp_Vec&       theYaxe,
1173                                          gp_Vec&       theZaxe);
1174 
1175   //! Transforms the Vertex V according to the matrice Matrix .
1176   Standard_EXPORT static gp_XYZ TrsPoint(const Graphic3d_Vertex&           V,
1177                                          const NCollection_Array2<double>& Matrix);
1178 
1179   //! Returns the objects number and the projection window
1180   //! of the objects contained in the view.
1181   Standard_EXPORT int MinMax(double& Umin, double& Vmin, double& Umax, double& Vmax) const;
1182 
1183   //! Returns the objects number and the box encompassing
1184   //! the objects contained in the view
1185   Standard_EXPORT int MinMax(double& Xmin,
1186                              double& Ymin,
1187                              double& Zmin,
1188                              double& Xmax,
1189                              double& Ymax,
1190                              double& Zmax) const;
1191 
1192   Standard_EXPORT void Init();
1193 
1194   //! Returns a new vertex when the grid is activated.
1195   Standard_EXPORT Graphic3d_Vertex Compute(const Graphic3d_Vertex& AVertex) const;
1196 
1197 protected:
1198   double                        myOldMouseX;
1199   double                        myOldMouseY;
1200   gp_Dir                        myCamStartOpUp;
1201   gp_Dir                        myCamStartOpDir;
1202   gp_Pnt                        myCamStartOpEye;
1203   gp_Pnt                        myCamStartOpCenter;
1204   occ::handle<Graphic3d_Camera> myDefaultCamera;
1205   occ::handle<Graphic3d_CView>  myView;
1206   bool                          myImmediateUpdate;
1207   mutable bool                  myIsInvalidatedImmediate;
1208 
1209 private:
1210   V3d_Viewer* MyViewer;
1211 
1212   NCollection_Sequence<occ::handle<V3d_View>> mySubviews;
1213   V3d_View*                                   myParentView;
1214 
1215   NCollection_List<occ::handle<Graphic3d_CLight>>           myActiveLights;
1216   gp_Dir                                                    myDefaultViewAxis;
1217   gp_Pnt                                                    myDefaultViewPoint;
1218   occ::handle<Aspect_Window>                                MyWindow;
1219   NCollection_List<occ::handle<Graphic3d_CLight>>::Iterator myActiveLightsIterator;
1220   int                                                       sx;
1221   int                                                       sy;
1222   double                                                    rx;
1223   double                                                    ry;
1224   gp_Pnt                                                    myRotateGravity;
1225   bool                                                      myComputedMode;
1226   bool                                                      SwitchSetFront;
1227   bool                                                      myZRotation;
1228   int                                                       MyZoomAtPointX;
1229   int                                                       MyZoomAtPointY;
1230   occ::handle<V3d_Trihedron>                                myTrihedron;
1231   occ::handle<Aspect_Grid>                                  MyGrid;
1232   gp_Ax3                                                    MyPlane;
1233   NCollection_Array2<double>                                MyTrsf;
1234   bool                                                      myShaderGridActive = false;
1235   occ::handle<Graphic3d_Structure>                          MyGridEchoStructure;
1236   occ::handle<Graphic3d_Group>                              MyGridEchoGroup;
1237   gp_Vec                                                    myXscreenAxis;
1238   gp_Vec                                                    myYscreenAxis;
1239   gp_Vec                                                    myZscreenAxis;
1240   gp_Dir                                                    myViewAxis;
1241   Graphic3d_Vertex                                          myGravityReferencePoint;
1242   bool                                                      myAutoZFitIsOn;
1243   double                                                    myAutoZFitScaleFactor;
1244 };
1245 
1246 #endif // _V3d_View_HeaderFile