From: vsr Date: Thu, 10 Apr 2014 12:58:22 +0000 (+0400) Subject: Add virtual method to compute OCC scene size X-Git-Tag: V7_4_0b1~1^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=560b20bbf09e80b3263c393a1ae34bf078f665f1;p=modules%2Fgui.git Add virtual method to compute OCC scene size --- diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 1eb2ec85e..f34b888e5 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -966,18 +966,7 @@ bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize if ( view3d.IsNull() ) return false; - double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0; - double aMaxSide; - - view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax ); - - if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() || - Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() ) - return false; - - aMaxSide = Xmax - Xmin; - if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin; - if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin; + double aMaxSide = computeSceneSize( view3d ); // IPAL21687 // The boundary box of the view may be initialized but nullified @@ -991,8 +980,29 @@ bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize theSize = getTrihedron()->Size(); theNewSize = aMaxSide*aSizeInPercents / 100.0; - return fabs( theNewSize - theSize ) > theSize * EPS || - fabs( theNewSize - theSize) > theNewSize * EPS; + return fabs( theNewSize - theSize ) > theSize * EPS || + fabs( theNewSize - theSize ) > theNewSize * EPS; +} + +/*! + * Compute scene size + */ +double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const +{ + double aMaxSide = 0; + double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0; + + view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax ); + + if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() && + Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() ) + { + aMaxSide = Xmax - Xmin; + if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin; + if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin; + } + + return aMaxSide; } /*! diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index d289dd408..c4f88dbd9 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -114,8 +114,9 @@ public: bool trihedronRelative() const {return myIsRelative; } - // a utility function, used by SALOME_View_s methods + // a utility functions, used by SALOME_View_s methods bool computeTrihedronSize( double& theNewSize, double& theSize ); + virtual double computeSceneSize(const Handle(V3d_View)&) const; void updateTrihedron();