}
}
+/*!
+ Gets foreground enable state
+*/
+bool GLViewer_ViewPort2d::isForegroundEnabled() const
+{
+ return myGLWidget->isForegroundEnabled();
+}
+
+/*!
+ Sets foreground enable state
+ \param theIsEnabled - enable state
+*/
+void GLViewer_ViewPort2d::setForegroundEnabled( const bool theIsEnabled )
+{
+ myGLWidget->setForegroundEnabled( theIsEnabled );
+}
+
+/*!
+ Sets foreground size
+ \param theWidth - foreground width
+ \param theHeight - foreground height
+*/
+void GLViewer_ViewPort2d::setForegroundSize( const GLfloat theWidth, const GLfloat theHeight )
+{
+ myGLWidget->setForegroundSize( theWidth, theHeight );
+}
+
+/*!
+ Sets foreground margin
+ \param theMargin - foreground margin
+*/
+void GLViewer_ViewPort2d::setForegroundMargin( const GLfloat theMargin )
+{
+ myGLWidget->setForegroundMargin( theMargin );
+}
+
+/*!
+ Sets foreground color
+ \param theColor - foreground color
+*/
+void GLViewer_ViewPort2d::setForegroundColor( const QColor& theColor )
+{
+ myGLWidget->setForegroundColor( theColor );
+}
+
+/*!
+ Sets foreground frame color
+ \param theColor - foreground frame color
+*/
+void GLViewer_ViewPort2d::setForegroundFrameColor( const QColor& theColor )
+{
+ myGLWidget->setForegroundFrameColor( theColor );
+}
+
+/*!
+ Sets foreground frame line width
+ \theLineWidth theColor - foreground frame line width
+*/
+void GLViewer_ViewPort2d::setForegroundFrameLineWidth( const GLfloat theLineWidth )
+{
+ myGLWidget->setForegroundFrameLineWidth( theLineWidth );
+}
+
/*!
Changes background color
\param color - new background color
void GLViewer_ViewPort2d::setBackgroundColor( const QColor& color )
{
GLViewer_ViewPort::setBackgroundColor( color );
- myGLWidget->makeCurrent();
- glClearColor( color.redF(), color.greenF(), color.blueF(), 1.0 );
+ myGLWidget->setBackgroundColor( color );
myGLWidget->repaint();
}
GLViewer_Widget* getGLWidget() const { return myGLWidget; }
virtual QPaintDevice* getPaintDevice() { return myGLWidget; }
+ //! Gets foreground enable state
+ bool isForegroundEnabled() const;
+
+ //! Sets foreground enable state
+ void setForegroundEnabled( const bool theIsEnabled );
+
+ //! Sets foreground size
+ void setForegroundSize( const GLfloat theWidth, const GLfloat theHeight );
+
+ //! Sets foreground margin
+ void setForegroundMargin( const GLfloat theMargin );
+
+ //! Sets foreground color
+ void setForegroundColor( const QColor& theColor );
+
+ //! Sets foreground frame color
+ void setForegroundFrameColor( const QColor& theColor );
+
+ //! Sets foreground frame line width
+ void setForegroundFrameLineWidth( const GLfloat theLineWidth );
+
//! Sets background color
void setBackgroundColor( const QColor& color);
//! Returns background color
QColor selColor = QColorDialog::getColor( vp->backgroundColor(), vp );
if ( selColor.isValid() ) {
- vp->setBackgroundColor( selColor );
+ if( vp->isForegroundEnabled() )
+ vp->setForegroundColor( selColor );
+ else
+ vp->setBackgroundColor( selColor );
}
}
{
myViewPort = ( GLViewer_ViewPort2d* )parent;
+ myIsForegroundEnabled = false;
+ myForegroundWidth = 100.0;
+ myForegroundHeight = 30.0;
+ myForegroundMargin = 1.0;
+ myForegroundColor = Qt::white;
+ myForegroundFrameColor = Qt::black;
+ myForegroundFrameLineWidth = 1.0;
+ myBackgroundColor = Qt::darkGray;
+
myXPan = 0.0;
myYPan = 0.0;
myZPan = 0.0;
{
}
+/*!
+ Sets foreground enable state
+ \param theIsEnabled - enable state
+*/
+void GLViewer_Widget::setForegroundEnabled( const bool theIsEnabled )
+{
+ myIsForegroundEnabled = theIsEnabled;
+}
+
+/*!
+ Sets foreground size
+ \param theWidth - foreground width
+ \param theHeight - foreground height
+*/
+void GLViewer_Widget::setForegroundSize( const GLfloat theWidth, const GLfloat theHeight )
+{
+ myForegroundWidth = theWidth;
+ myForegroundHeight = theHeight;
+}
+
+/*!
+ Sets foreground margin
+ \param theMargin - foreground margin
+*/
+void GLViewer_Widget::setForegroundMargin( const GLfloat theMargin )
+{
+ myForegroundMargin = theMargin;
+}
+
+/*!
+ Sets foreground color
+ \param theColor - foreground color
+*/
+void GLViewer_Widget::setForegroundColor( const QColor& theColor )
+{
+ myForegroundColor = theColor;
+}
+
+/*!
+ Sets foreground frame color
+ \param theColor - foreground frame color
+*/
+void GLViewer_Widget::setForegroundFrameColor( const QColor& theColor )
+{
+ myForegroundFrameColor = theColor;
+}
+
+/*!
+ Sets foreground frame line width
+ \theLineWidth theColor - foreground frame line width
+*/
+void GLViewer_Widget::setForegroundFrameLineWidth( const GLfloat theLineWidth )
+{
+ myForegroundFrameLineWidth = theLineWidth;
+}
+
+/*!
+ Sets foreground color
+ \param theColor - background color
+*/
+void GLViewer_Widget::setBackgroundColor( const QColor& theColor )
+{
+ myBackgroundColor = theColor;
+}
+
/*!
\return offset parameters of Window in OpenGL global scene
*/
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
+ // background
+ glClearColor( myBackgroundColor.redF(),
+ myBackgroundColor.greenF(),
+ myBackgroundColor.blueF(),
+ 1.0 );
+
+ // foreground
+ if( myIsForegroundEnabled )
+ {
+ glColor3f( myForegroundColor.redF(),
+ myForegroundColor.greenF(),
+ myForegroundColor.blueF() );
+
+ glBegin( GL_POLYGON );
+ glVertex2f( - myForegroundMargin, - myForegroundMargin );
+ glVertex2f( myForegroundWidth + myForegroundMargin, - myForegroundMargin );
+ glVertex2f( myForegroundWidth + myForegroundMargin, myForegroundHeight + myForegroundMargin );
+ glVertex2f( - myForegroundMargin, myForegroundHeight + myForegroundMargin );
+ glEnd();
+
+ glColor3f( myForegroundFrameColor.redF(),
+ myForegroundFrameColor.greenF(),
+ myForegroundFrameColor.blueF() );
+ glLineWidth( myForegroundFrameLineWidth );
+
+ glBegin( GL_LINE_LOOP );
+ glVertex2f( - myForegroundMargin, - myForegroundMargin );
+ glVertex2f( myForegroundWidth + myForegroundMargin, - myForegroundMargin );
+ glVertex2f( myForegroundWidth + myForegroundMargin, myForegroundHeight + myForegroundMargin );
+ glVertex2f( - myForegroundMargin, myForegroundHeight + myForegroundMargin );
+ glEnd();
+ }
GLViewer_Grid* grid = myViewPort->getGrid();
if( grid )
//! A destructor
~GLViewer_Widget();
+ //! Gets foreground enable state
+ bool isForegroundEnabled() const { return myIsForegroundEnabled; }
+
+ //! Sets foreground enable state
+ void setForegroundEnabled( const bool theIsEnabled );
+
+ //! Sets foreground size
+ void setForegroundSize( const GLfloat theWidth, const GLfloat theHeight );
+
+ //! Sets foreground margin
+ void setForegroundMargin( const GLfloat theMargin );
+
+ //! Sets foreground color
+ void setForegroundColor( const QColor& theColor );
+
+ //! Sets foreground frame color
+ void setForegroundFrameColor( const QColor& theColor );
+
+ //! Sets foreground frame line width
+ void setForegroundFrameLineWidth( const GLfloat theLineWidth );
+
+ //! Sets background color
+ void setBackgroundColor( const QColor& theColor );
+
//! Returns parent GLViewer_ViewPort2d
/*! ViewPort2d because this class is not use for 3D Viewer */
GLViewer_ViewPort2d* getViewPort() const { return myViewPort; }
virtual bool event ( QEvent* );
private:
+ //! foreground enable state
+ bool myIsForegroundEnabled;
+
+ //! foreground width
+ GLfloat myForegroundWidth;
+
+ //! foreground height
+ GLfloat myForegroundHeight;
+
+ //! foreground margin
+ GLfloat myForegroundMargin;
+
+ //! foreground color
+ QColor myForegroundColor;
+
+ //! foreground frame color
+ QColor myForegroundFrameColor;
+
+ //! foreground frame line width
+ GLfloat myForegroundFrameLineWidth;
+
+ //! background color
+ QColor myBackgroundColor;
+
//! width of window
GLint myWidth;
//! height of window