From cbb7f29f36e6ed0dab9271c7a42217c769c9d45b Mon Sep 17 00:00:00 2001 From: sln Date: Sun, 18 Feb 2007 13:54:07 +0000 Subject: [PATCH] Zoom changed on XZoom, YZoom changed on Zoom --- src/GLViewer/GLViewer_Group.cxx | 8 +++---- src/GLViewer/GLViewer_Group.h | 6 ++--- src/GLViewer/GLViewer_Object.cxx | 38 +++++++++++++++--------------- src/GLViewer/GLViewer_Object.h | 18 +++++++------- src/GLViewer/GLViewer_Viewer2d.cxx | 4 ++-- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/GLViewer/GLViewer_Group.cxx b/src/GLViewer/GLViewer_Group.cxx index af707c2df..55c611010 100644 --- a/src/GLViewer/GLViewer_Group.cxx +++ b/src/GLViewer/GLViewer_Group.cxx @@ -146,7 +146,7 @@ void GLViewer_Group::dragingObjects( float x, float y, bool once ) \param sender - object to be updated \param zoom - zoom coefficient */ -void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom ) +void GLViewer_Group::updateXZoom( GLViewer_Object* sender, float zoom ) { OGIterator it = myList.begin(); OGIterator end_it = myList.end(); @@ -154,7 +154,7 @@ void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom ) { GLViewer_Object* anObject = *it; if( anObject != sender ) - anObject->setZoom( zoom, true, true ); + anObject->setXZoom( zoom, true, true ); } } @@ -163,7 +163,7 @@ void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom ) \param sender - object to be updated \param zoom - zoom coefficient */ -void GLViewer_Group::updateYZoom( GLViewer_Object* sender, float zoom ) +void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom ) { OGIterator it = myList.begin(); OGIterator end_it = myList.end(); @@ -171,6 +171,6 @@ void GLViewer_Group::updateYZoom( GLViewer_Object* sender, float zoom ) { GLViewer_Object* anObject = *it; if( anObject != sender ) - anObject->setYZoom( zoom, true, true ); + anObject->setZoom( zoom, true, true ); } } diff --git a/src/GLViewer/GLViewer_Group.h b/src/GLViewer/GLViewer_Group.h index 94678837a..cef578d67 100644 --- a/src/GLViewer/GLViewer_Group.h +++ b/src/GLViewer/GLViewer_Group.h @@ -64,9 +64,9 @@ public: /*! Once = true, if this operation calls only one time for all object*/ void dragingObjects( float x, float y, bool once = false ); //!\warning it is for ouv - void updateZoom( GLViewer_Object* sender, float zoom ); + void updateXZoom( GLViewer_Object* sender, float zoom ); //!\warning it is for ouv - void updateYZoom( GLViewer_Object* sender, float zoom ); + void updateZoom( GLViewer_Object* sender, float zoom ); private: //! List of objects @@ -75,4 +75,4 @@ private: int mySelObjNum; }; -#endif //GLVIEWER_GROUP_H +#endif diff --git a/src/GLViewer/GLViewer_Object.cxx b/src/GLViewer/GLViewer_Object.cxx index 22140de12..371a1fdf0 100644 --- a/src/GLViewer/GLViewer_Object.cxx +++ b/src/GLViewer/GLViewer_Object.cxx @@ -39,8 +39,8 @@ GLViewer_Object::GLViewer_Object() myYScale = 1.0; myXGap = 0; myYGap = 0; + myXZoom = 1.0; myZoom = 1.0; - myYZoom = 1.0; myIsHigh = GL_FALSE; myIsSel = GL_FALSE; @@ -101,12 +101,12 @@ GLboolean GLViewer_Object::isInside( GLViewer_Rect theRect ) Sets horizontal zoom factor \param zoom - zoom factor */ -GLboolean GLViewer_Object::setZoom( GLfloat zoom, bool, bool ) +GLboolean GLViewer_Object::setXZoom( GLfloat zoom, bool, bool ) { - if( myZoom == zoom ) + if( myXZoom == zoom ) return GL_FALSE; - myZoom = zoom; + myXZoom = zoom; return GL_TRUE; } @@ -114,35 +114,35 @@ GLboolean GLViewer_Object::setZoom( GLfloat zoom, bool, bool ) Performs horizontal zoom change by step \param zoomIn - to increase to decrease zoom */ -GLboolean GLViewer_Object::updateZoom( bool zoomIn ) +GLboolean GLViewer_Object::updateXZoom( bool zoomIn ) { float newZoom; float step = zoomIn ? 1 : -1; double epsilon = 0.001; - if( myZoom - 1 > epsilon ) - newZoom = ( myZoom * 2 + step ) / 2; - else if( 1 - myZoom > epsilon ) - newZoom = 2 / ( 2 / myZoom - step ); + if( myXZoom - 1 > epsilon ) + newZoom = ( myXZoom * 2 + step ) / 2; + else if( 1 - myXZoom > epsilon ) + newZoom = 2 / ( 2 / myXZoom - step ); else newZoom = zoomIn ? 3./2. : 2./3.; if( newZoom < 0.01 || newZoom > 100.0 ) return GL_FALSE; - return setZoom( newZoom, true ); + return setXZoom( newZoom, true ); } /*! Sets vertical zoom factor \param zoom - zoom factor */ -GLboolean GLViewer_Object::setYZoom( GLfloat zoom, bool, bool ) +GLboolean GLViewer_Object::setZoom( GLfloat zoom, bool, bool ) { - if( myYZoom == zoom ) + if( myZoom == zoom ) return GL_FALSE; - myYZoom = zoom; + myZoom = zoom; return GL_TRUE; } @@ -150,23 +150,23 @@ GLboolean GLViewer_Object::setYZoom( GLfloat zoom, bool, bool ) Performs vertical zoom change by step \param zoomIn - to increase to decrease zoom */ -GLboolean GLViewer_Object::updateYZoom( bool zoomIn ) +GLboolean GLViewer_Object::updateZoom( bool zoomIn ) { float newZoom; float step = zoomIn ? 1 : -1; double epsilon = 0.001; - if( myYZoom - 1 > epsilon ) - newZoom = ( myYZoom * 2 + step ) / 2; - else if( 1 - myYZoom > epsilon ) - newZoom = 2 / ( 2 / myYZoom - step ); + if( myZoom - 1 > epsilon ) + newZoom = ( myZoom * 2 + step ) / 2; + else if( 1 - myZoom > epsilon ) + newZoom = 2 / ( 2 / myZoom - step ); else newZoom = zoomIn ? 3./2. : 2./3.; if( newZoom < 0.01 || newZoom > 100.0 ) return GL_FALSE; - return setYZoom( newZoom, true ); + return setZoom( newZoom, true ); } /*! diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index b75ba3946..33bbb33ea 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -139,18 +139,18 @@ public: virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;} //!\warning It is for ouv - virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false ); + virtual GLboolean setXZoom( GLfloat zoom, bool recompute, bool fromGroup = false ); //!\warning It is for ouv - virtual GLfloat getZoom() const { return myZoom; } + virtual GLfloat getXZoom() const { return myXZoom; } //!\warning It is for ouv - virtual GLboolean updateZoom( bool zoomIn ); + virtual GLboolean updateXZoom( bool zoomIn ); //!\warning It is for ouv - virtual GLboolean setYZoom( GLfloat yoom, bool recompute, bool fromGroup = false ); + virtual GLboolean setZoom( GLfloat yoom, bool recompute, bool fromGroup = false ); //!\warning It is for ouv - virtual GLfloat getYZoom() const { return myYZoom; } + virtual GLfloat getZoom() const { return myZoom; } //!\warning It is for ouv - virtual GLboolean updateYZoom( bool zoomIn ); + virtual GLboolean updateZoom( bool zoomIn ); //! Returns true if object is highlighted virtual GLboolean isHighlighted() const { return myIsHigh; } @@ -280,9 +280,9 @@ protected: GLfloat myYGap; //!\warning It is for ouv - GLfloat myZoom; + GLfloat myXZoom; //!\warning It is for ouv - GLfloat myYZoom; + GLfloat myZoom; //! Highlight status /*! = true after right highlighting*/ @@ -316,4 +316,4 @@ protected: #pragma warning ( default:4251 ) #endif -#endif +#endif \ No newline at end of file diff --git a/src/GLViewer/GLViewer_Viewer2d.cxx b/src/GLViewer/GLViewer_Viewer2d.cxx index b7f169efc..65962dbe4 100644 --- a/src/GLViewer/GLViewer_Viewer2d.cxx +++ b/src/GLViewer/GLViewer_Viewer2d.cxx @@ -1008,9 +1008,9 @@ void GLViewer_Viewer2d::startOperations( QWheelEvent* e ) { GLViewer_Object* anObject = myGLContext->SelectedObject(); if( e->state() & ControlButton ) - update = anObject->updateZoom( zoomIn ) || update; + update = anObject->updateXZoom( zoomIn ) || update; else - update = anObject->updateYZoom( zoomIn ) || update; + update = anObject->updateZoom( zoomIn ) || update; } emit wheelZoomChange( zoomIn ); -- 2.39.2