From 662b193e51df3dd8b16ded4d1eb285bf610f570d Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 13 Sep 2007 10:32:25 +0000 Subject: [PATCH] Minor change --- src/GLViewer/GLViewer_Drawer.cxx | 72 ++++++++++++-------------------- src/GLViewer/GLViewer_Drawer.h | 5 ++- 2 files changed, 29 insertions(+), 48 deletions(-) diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index d0001a49c..46ebd5ef1 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -892,6 +892,32 @@ void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, QColor color ) glEnd(); } +/*! + Draws filled rectangle + \param rect - instance of primitive + \param fillingColor - color of filling +*/ +void GLViewer_Drawer::drawFilledRectangle( GLViewer_Rect* rect, QColor color ) +{ + if( !rect ) + return; + + float x1 = rect->left(); + float x2 = rect->right(); + float y1 = rect->bottom(); + float y2 = rect->top(); + + glColor3f( ( GLfloat )color.red() / 255, + ( GLfloat )color.green() / 255, + ( GLfloat )color.blue() / 255 ); + glBegin( GL_POLYGON ); + glVertex2f( x1, y1 ); + glVertex2f( x1, y2 ); + glVertex2f( x2, y2 ); + glVertex2f( x2, y1 ); + glEnd(); +} + /*! Saves object to file with format of HPGL \param hFile - file @@ -936,52 +962,6 @@ bool GLViewer_Drawer::translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, } #endif -/*! - Draws rectangle - \param rect - instance of primitive - \param lineWidth - width of line - \param gap - gap of rectangle - \param color - color of primitive - \param filled - if it is true, then rectangle will be drawn filled with color "fillingColor" - \param fillingColor - color of filling -*/ -void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, GLfloat lineWidth, GLfloat gap, - QColor color, bool filled, QColor fillingColor ) -{ - if( !rect ) - return; - - float x1 = rect->left() - gap; - float x2 = rect->right() + gap; - float y1 = rect->bottom() - gap; - float y2 = rect->top() + gap; - - if( filled ) - { - glColor3f( ( GLfloat )fillingColor.red() / 255, - ( GLfloat )fillingColor.green() / 255, - ( GLfloat )fillingColor.blue() / 255 ); - glBegin( GL_POLYGON ); - glVertex2f( x1, y1 ); - glVertex2f( x1, y2 ); - glVertex2f( x2, y2 ); - glVertex2f( x2, y1 ); - glEnd(); - } - - glColor3f( ( GLfloat )color.red() / 255, - ( GLfloat )color.green() / 255, - ( GLfloat )color.blue() / 255 ); - glLineWidth( lineWidth ); - - glBegin( GL_LINE_LOOP ); - glVertex2f( x1, y1 ); - glVertex2f( x1, y2 ); - glVertex2f( x2, y2 ); - glVertex2f( x2, y1 ); - glEnd(); -} - /*! Draws contour \param pntList - list of points diff --git a/src/GLViewer/GLViewer_Drawer.h b/src/GLViewer/GLViewer_Drawer.h index 21c6386ce..f50f8a983 100644 --- a/src/GLViewer/GLViewer_Drawer.h +++ b/src/GLViewer/GLViewer_Drawer.h @@ -400,11 +400,12 @@ public: //! Draw rectangle with predefined color static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black ); + //! Draw filled rectangle with predefined color + static void drawFilledRectangle( GLViewer_Rect*, QColor = Qt::black ); + protected: //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow //* with predefined color - static void drawRectangle( GLViewer_Rect*, GLfloat, GLfloat = 0, QColor = Qt::black, - bool = false, QColor = Qt::white ); static void drawContour( GLViewer_Rect*, QColor, GLfloat, GLushort, bool ); static void drawContour( const GLViewer_PntList&, QColor, GLfloat ); static void drawPolygon( GLViewer_Rect*, QColor, GLushort, bool ); -- 2.39.2