From: ouv Date: Mon, 4 Oct 2010 13:31:54 +0000 (+0000) Subject: 1) Correction of vertical orientation of GLViewer_Rect object X-Git-Tag: DIAGRAM_0_1~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1e675c519adad107c008a60a76b897321658bab2;p=modules%2Fgui.git 1) Correction of vertical orientation of GLViewer_Rect object 2) Fixing small bugs with chaging foreground color --- diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index fb45550e3..11f0235f2 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -909,7 +909,7 @@ GLViewer_Rect GLViewer_Drawer::textRect( const QString& text ) const height = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.height() * scale : aFontMetrics.height(); } - return GLViewer_Rect( 0, width, height, 0 ); + return GLViewer_Rect( 0, width, 0, height ); } /*! diff --git a/src/GLViewer/GLViewer_Geom.h b/src/GLViewer/GLViewer_Geom.h index 522408ac7..22ed1c7a1 100644 --- a/src/GLViewer/GLViewer_Geom.h +++ b/src/GLViewer/GLViewer_Geom.h @@ -70,28 +70,28 @@ typedef QList GLViewer_PntList; class GLVIEWER_API GLViewer_Rect { public: - GLViewer_Rect(): myLeft(0.0), myRight(0.0), myTop(0.0), myBottom(0.0){} - GLViewer_Rect( float theLeft, float theRight, float theTop, float theBottom ) - : myLeft(theLeft), myRight(theRight), myTop(theTop), myBottom(theBottom) {} + GLViewer_Rect(): myLeft(0.0), myRight(0.0), myBottom(0.0), myTop(0.0) {} + GLViewer_Rect( float theLeft, float theRight, float theBottom, float theTop ) + : myLeft(theLeft), myRight(theRight), myBottom(theBottom), myTop(theTop) {} GLViewer_Rect( QRect theRect ) { myLeft = ( float )theRect.left(); myRight = ( float )theRect.right(); - myTop = ( float )theRect.top(); myBottom = ( float )theRect.bottom(); } + myBottom = ( float )theRect.bottom(); myTop = ( float )theRect.top(); } GLViewer_Rect( QRectF theRect ) { myLeft = theRect.left(); myRight = theRect.right(); - myTop = theRect.top(); myBottom = theRect.bottom(); } + myBottom = theRect.bottom(); myTop = theRect.top(); } float left() const { return myLeft; } float right() const { return myRight; } - float top() const { return myTop; } float bottom() const { return myBottom; } + float top() const { return myTop; } float width() const { return fabs( myRight - myLeft ); } float height() const { return fabs( myTop - myBottom ); } void setLeft( float theLeft ) { myLeft = theLeft; } void setRight( float theRight ) { myRight = theRight; } - void setTop( float theTop ) { myTop = theTop; } void setBottom( float theBottom ) { myBottom = theBottom; } + void setTop( float theTop ) { myTop = theTop; } void setCoords( float theLeft, float theRight, float theBottom, float theTop ) { myLeft = theLeft; myRight = theRight; myBottom = theBottom; myTop = theTop; } @@ -134,8 +134,8 @@ public: protected: float myLeft; float myRight; - float myTop; float myBottom; + float myTop; bool myIsEmpty; }; diff --git a/src/GLViewer/GLViewer_Object.cxx b/src/GLViewer/GLViewer_Object.cxx index 2cdb4242e..3705657ae 100644 --- a/src/GLViewer/GLViewer_Object.cxx +++ b/src/GLViewer/GLViewer_Object.cxx @@ -279,7 +279,7 @@ bool GLViewer_Object::initializeFromByteCopy( QByteArray theArray ) *aPointer = theArray[i]; //myRect = new QRect( aLeft, aTop, aRight - aLeft, aBottom - aTop ); - myRect = new GLViewer_Rect( aLeft, aRight, aTop, aBottom ); + myRect = new GLViewer_Rect( aLeft, aRight, aBottom, aTop ); aPointer = (char*)&myXScale; for( ; i < 5*aFSize; i++, aPointer++ ) diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index 80c9f7868..f3ab08800 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -122,7 +122,7 @@ public: virtual bool isPulling() { return false; } //!\warning It is for ouv virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect( - myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); } + myRect->left(), myRect->right(), myRect->bottom(), myRect->top() ); } //! Installs object rectangle virtual void setRect( GLViewer_Rect* rect) { myRect = rect; } diff --git a/src/GLViewer/GLViewer_ViewPort2d.cxx b/src/GLViewer/GLViewer_ViewPort2d.cxx index 61da7c1dc..64d67f148 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.cxx +++ b/src/GLViewer/GLViewer_ViewPort2d.cxx @@ -582,6 +582,15 @@ void GLViewer_ViewPort2d::setForegroundColor( const QColor& theColor ) myGLWidget->setForegroundColor( theColor ); } +/*! + Gets foreground color + \return foreground color +*/ +QColor GLViewer_ViewPort2d::foregroundColor() const +{ + return myGLWidget->foregroundColor(); +} + /*! Sets foreground frame color \param theColor - foreground frame color diff --git a/src/GLViewer/GLViewer_ViewPort2d.h b/src/GLViewer/GLViewer_ViewPort2d.h index 688927d45..c18e962df 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.h +++ b/src/GLViewer/GLViewer_ViewPort2d.h @@ -100,6 +100,9 @@ public: //! Sets foreground color void setForegroundColor( const QColor& theColor ); + //! Gets foreground color + QColor foregroundColor() const; + //! Sets foreground frame color void setForegroundFrameColor( const QColor& theColor ); diff --git a/src/GLViewer/GLViewer_Viewer2d.cxx b/src/GLViewer/GLViewer_Viewer2d.cxx index 9fe45257b..f80ee8baf 100644 --- a/src/GLViewer/GLViewer_Viewer2d.cxx +++ b/src/GLViewer/GLViewer_Viewer2d.cxx @@ -102,7 +102,8 @@ void GLViewer_Viewer2d::onChangeBgColor() return; GLViewer_ViewPort2d* vp = ( ( GLViewer_ViewPort2d* )getActiveView()->getViewPort() ); - QColor selColor = QColorDialog::getColor( vp->backgroundColor(), vp ); + QColor selColor = vp->isForegroundEnabled() ? vp->foregroundColor() : vp->backgroundColor(); + selColor = QColorDialog::getColor( selColor, vp ); if ( selColor.isValid() ) { if( vp->isForegroundEnabled() ) vp->setForegroundColor( selColor ); diff --git a/src/GLViewer/GLViewer_Widget.cxx b/src/GLViewer/GLViewer_Widget.cxx index 4f638570a..d5493add2 100644 --- a/src/GLViewer/GLViewer_Widget.cxx +++ b/src/GLViewer/GLViewer_Widget.cxx @@ -130,6 +130,15 @@ void GLViewer_Widget::setForegroundColor( const QColor& theColor ) myForegroundColor = theColor; } +/*! + Gets foreground color + \return foreground color +*/ +QColor GLViewer_Widget::foregroundColor() const +{ + return myForegroundColor; +} + /*! Sets foreground frame color \param theColor - foreground frame color diff --git a/src/GLViewer/GLViewer_Widget.h b/src/GLViewer/GLViewer_Widget.h index 9eab50ff6..cfa0b87d2 100644 --- a/src/GLViewer/GLViewer_Widget.h +++ b/src/GLViewer/GLViewer_Widget.h @@ -69,6 +69,9 @@ public: //! Sets foreground color void setForegroundColor( const QColor& theColor ); + //! Gets foreground color + QColor foregroundColor() const; + //! Sets foreground frame color void setForegroundFrameColor( const QColor& theColor );