From: kgv Date: Sat, 10 Oct 2015 19:45:14 +0000 (+0300) Subject: 0026768: Visualization, Graphic3d_Camera::ZFitAll() - define method estimating ZRange... X-Git-Tag: V7_0_0_beta~190 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=10dbdf3496c785d6b03a089563952537af657703;p=occt-copy.git 0026768: Visualization, Graphic3d_Camera::ZFitAll() - define method estimating ZRange without assigning it Declare methods V3d_View::Redraw() and V3d_View::RedrawImmediate() as virtual to allow customization. --- diff --git a/src/Graphic3d/Graphic3d_Camera.cxx b/src/Graphic3d/Graphic3d_Camera.cxx index 11e120bfc7..2443cab72b 100644 --- a/src/Graphic3d/Graphic3d_Camera.cxx +++ b/src/Graphic3d/Graphic3d_Camera.cxx @@ -1055,7 +1055,11 @@ void Graphic3d_Camera::LookOrientation (const NCollection_Vec3& theEye, //function : ZFitAll //purpose : //============================================================================= -void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Box& theMinMax, const Bnd_Box& theGraphicBB) +bool Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, + const Bnd_Box& theMinMax, + const Bnd_Box& theGraphicBB, + Standard_Real& theZNear, + Standard_Real& theZFar) const { Standard_ASSERT_RAISE (theScaleFactor > 0.0, "Zero or negative scale factor is not allowed."); @@ -1065,8 +1069,9 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo // scene with infinite or helper objects (third argument) for the sake of perspective projection. if (theGraphicBB.IsVoid()) { - SetZRange (DEFAULT_ZNEAR, DEFAULT_ZFAR); - return; + theZNear = DEFAULT_ZNEAR; + theZFar = DEFAULT_ZFAR; + return false; } // Measure depth of boundary points from camera eye. @@ -1153,8 +1158,9 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo // Everything is behind the perspective camera. if (aZFar < zEpsilon()) { - SetZRange (DEFAULT_ZNEAR, DEFAULT_ZFAR); - return; + theZNear = DEFAULT_ZNEAR; + theZFar = DEFAULT_ZFAR; + return false; } } @@ -1234,5 +1240,7 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo } } - SetZRange (aZNear, aZFar); + theZNear = aZNear; + theZFar = aZFar; + return true; } diff --git a/src/Graphic3d/Graphic3d_Camera.hxx b/src/Graphic3d/Graphic3d_Camera.hxx index 0450205dee..a83df8ccd0 100644 --- a/src/Graphic3d/Graphic3d_Camera.hxx +++ b/src/Graphic3d/Graphic3d_Camera.hxx @@ -272,7 +272,7 @@ public: return myFOVy; } - //! Change Z-min and Z-max planes of projection volume to match the + //! Estimate Z-min and Z-max planes of projection volume to match the //! displayed objects. The methods ensures that view volume will //! be close by depth range to the displayed objects. Fitting assumes that //! for orthogonal projection the view volume contains the displayed objects @@ -284,8 +284,19 @@ public: //! Program error exception is thrown if negative or zero value is passed. //! @param theMinMax [in] applicative min max boundaries. //! @param theScaleFactor [in] real graphical boundaries (not accounting infinite flag). - - Standard_EXPORT void ZFitAll (const Standard_Real theScaleFactor, const Bnd_Box& theMinMax, const Bnd_Box& theGraphicBB); + Standard_EXPORT bool ZFitAll (const Standard_Real theScaleFactor, + const Bnd_Box& theMinMax, + const Bnd_Box& theGraphicBB, + Standard_Real& theZNear, + Standard_Real& theZFar) const; + + //! Change Z-min and Z-max planes of projection volume to match the displayed objects. + void ZFitAll (const Standard_Real theScaleFactor, const Bnd_Box& theMinMax, const Bnd_Box& theGraphicBB) + { + Standard_Real aZNear = 0.0, aZFar = 1.0; + ZFitAll (theScaleFactor, theMinMax, theGraphicBB, aZNear, aZFar); + SetZRange (aZNear, aZFar); + } //! Change the Near and Far Z-clipping plane positions. //! For orthographic projection, theZNear, theZFar can be negative or positive. diff --git a/src/V3d/V3d_View.hxx b/src/V3d/V3d_View.hxx index 290dd1f76d..b8ce27e4be 100644 --- a/src/V3d/V3d_View.hxx +++ b/src/V3d/V3d_View.hxx @@ -156,10 +156,10 @@ public: //! been any modification. //! Must be called if the view is shown. //! (Ex: DeIconification ) . - Standard_EXPORT void Redraw() const; + Standard_EXPORT virtual void Redraw() const; //! Updates layer of immediate presentations. - Standard_EXPORT void RedrawImmediate() const; + Standard_EXPORT virtual void RedrawImmediate() const; //! Invalidates view content but does not redraw it. Standard_EXPORT void Invalidate() const;