From: ouv Date: Mon, 23 Aug 2010 11:22:03 +0000 (+0000) Subject: 1) GLViewer_ViewPort2d::turnGrid() returns boolean value X-Git-Tag: DIAGRAM_0_1~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=39d4dc86715d984d1fcac843ede10cb9389799a6;p=modules%2Fgui.git 1) GLViewer_ViewPort2d::turnGrid() returns boolean value 2) additional check in GLViewer_Widget::resizeGL() --- diff --git a/src/GLViewer/GLViewer_ViewPort2d.cxx b/src/GLViewer/GLViewer_ViewPort2d.cxx index 855c3ccc7..3b18e54b6 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.cxx +++ b/src/GLViewer/GLViewer_ViewPort2d.cxx @@ -470,17 +470,22 @@ void GLViewer_ViewPort2d::turnCompass( GLboolean on ) /*! Creates or deletes grid \param on - if it is true, then to create + \return true if the grid has been just created */ -void GLViewer_ViewPort2d::turnGrid( GLboolean on ) +bool GLViewer_ViewPort2d::turnGrid( GLboolean on ) { + bool aResult = false; if( on ) { if( !myGrid ) + { myGrid = new GLViewer_Grid( 2*WIDTH, 2*HEIGHT, 2*WIDTH, 2*HEIGHT, GRID_XSIZE, GRID_YSIZE, myXPan, myYPan, myXScale, myYScale ); + aResult = true; + } myGrid->setEnabled( GL_TRUE ); } else @@ -488,6 +493,7 @@ void GLViewer_ViewPort2d::turnGrid( GLboolean on ) if( myGrid ) myGrid->setEnabled( GL_FALSE ); } + return aResult; } /*! diff --git a/src/GLViewer/GLViewer_ViewPort2d.h b/src/GLViewer/GLViewer_ViewPort2d.h index 8d9419ae1..cb5bfc7a3 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.h +++ b/src/GLViewer/GLViewer_ViewPort2d.h @@ -73,7 +73,7 @@ public: ~GLViewer_ViewPort2d(); //! On/off rectangular grid - void turnGrid( GLboolean on ); + bool turnGrid( GLboolean on ); //! Returns rectangular grid GLViewer_Grid* getGrid() const { return myGrid; } //! Returns grid color diff --git a/src/GLViewer/GLViewer_Widget.cxx b/src/GLViewer/GLViewer_Widget.cxx index e1de5e4c3..1322ff49d 100644 --- a/src/GLViewer/GLViewer_Widget.cxx +++ b/src/GLViewer/GLViewer_Widget.cxx @@ -340,14 +340,17 @@ void GLViewer_Widget::paintGL() */ void GLViewer_Widget::resizeGL( int w, int h ) { - if( h < 1 ) h = 1; if( w < 1 ) w = 1; glViewport( 0, 0, w, h); myViewPort->initResize( w, h ); - if( myStart ) + // check if the widget has not been resized yet + // (values 100 and 30 of width and height are default initial) + bool anIsUnitializedWidget = ( w == 100 && h == 30 ); + + if( myStart && !anIsUnitializedWidget ) { myWidth = w; myHeight = h;