2) additional check in GLViewer_Widget::resizeGL()
/*!
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
if( myGrid )
myGrid->setEnabled( GL_FALSE );
}
+ return aResult;
}
/*!
~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
*/
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;