X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGLViewer%2FGLViewer_Widget.cxx;h=a12208c73354396fb641b2e98623f518e626505c;hb=refs%2Fheads%2Fngr%2Fpython3_dev_pv5.4;hp=616e57546bae805c019c230e7b9bc5db5bfbf432;hpb=aa05f2a1b23a54321ea7248ae9ac3463652c734e;p=modules%2Fgui.git diff --git a/src/GLViewer/GLViewer_Widget.cxx b/src/GLViewer/GLViewer_Widget.cxx index 616e57546..a12208c73 100644 --- a/src/GLViewer/GLViewer_Widget.cxx +++ b/src/GLViewer/GLViewer_Widget.cxx @@ -1,48 +1,41 @@ -// Copyright (C) 2005 OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// Author : OPEN CASCADE +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: GLViewer_Widget.cxx -// Created: November, 2004 - #include "GLViewer_Widget.h" #include "GLViewer_ViewPort2d.h" #include "GLViewer_Viewer2d.h" -#include "GLViewer_Compass.h" #include "GLViewer_Grid.h" -#include "GLViewer_Object.h" #include "GLViewer_CoordSystem.h" +#include "GLViewer_ViewFrame.h" #include -using namespace std; - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /*! A constructor @@ -127,7 +120,7 @@ void GLViewer_Widget::setScale( GLfloat xScale, GLfloat yScale, GLfloat zScale ) \return start point of curren rotation of Window in OpenGL global scene */ void GLViewer_Widget::getRotationStart( GLfloat& rotationStartX, - GLfloat& rotationStartY, + GLfloat& rotationStartY, GLfloat& rotationStartZ ) { rotationStartX = myRotationStartX; @@ -139,7 +132,7 @@ void GLViewer_Widget::getRotationStart( GLfloat& rotationStartX, A function for installing the rotation angle of Window in OpenGL global scene in degree (Only in 2D) */ void GLViewer_Widget::setRotationStart( GLfloat rotationStartX, - GLfloat rotationStartY, + GLfloat rotationStartY, GLfloat rotationStartZ ) { myRotationStartX = rotationStartX; @@ -155,9 +148,9 @@ void GLViewer_Widget::setRotationStart( GLfloat rotationStartX, \param rotationCenterZ - center z */ void GLViewer_Widget::getRotation( GLfloat& rotationAngle, - GLfloat& rotationCenterX, - GLfloat& rotationCenterY, - GLfloat& rotationCenterZ ) + GLfloat& rotationCenterX, + GLfloat& rotationCenterY, + GLfloat& rotationCenterZ ) { rotationAngle = myRotationAngle; rotationCenterX = myRotationCenterX; @@ -173,9 +166,9 @@ void GLViewer_Widget::getRotation( GLfloat& rotationAngle, \param rotationCenterZ - center z */ void GLViewer_Widget::setRotation( GLfloat rotationAngle, - GLfloat rotationCenterX, - GLfloat rotationCenterY, - GLfloat rotationCenterZ ) + GLfloat rotationCenterX, + GLfloat rotationCenterY, + GLfloat rotationCenterZ ) { myRotationAngle = rotationAngle; myRotationCenterX = rotationCenterX; @@ -248,7 +241,8 @@ void GLViewer_Widget::setBackground( QString filename ) void GLViewer_Widget::addToolTip( QString theString, QRect theRect ) { myToolTipRect = theRect; - QToolTip::add( this, myToolTipRect, theString ); + setToolTip(theString); + //QToolTip::add( this, myToolTipRect, theString ); } /*! @@ -256,7 +250,8 @@ void GLViewer_Widget::addToolTip( QString theString, QRect theRect ) */ void GLViewer_Widget::removeToolTip() { - QToolTip::remove( this, myToolTipRect ); + setToolTip(""); + //QToolTip::remove( this, myToolTipRect ); } /*! @@ -419,6 +414,18 @@ void GLViewer_Widget::leaveEvent( QEvent* e ) updateGL(); } +/*! + Custom leave event handler +*/ +bool GLViewer_Widget::event ( QEvent* e ) +{ + if (e->type() == QEvent::ToolTip) { + QHelpEvent *helpEvent = static_cast(e); + if ( myToolTipRect.contains(helpEvent->pos()) ) + QToolTip::showText(helpEvent->globalPos(), toolTip()); + } + return QGLWidget::event(e); +} /*! \return the hex code of digit < 16 @@ -470,25 +477,25 @@ void AddImagePart( QFile& hFile, QImage& image, int w1, int w2, int h1, int h2, { uchar* theCurLine = image.scanLine( i ), cur; for( int j=w1; j<=w2; j++ ) - for( int k=0; k<3; k++ ) - { - cur = *(theCurLine+4*j+2-k); - *(line+cur_index) = hex( cur/16 ); //HI - *(line+cur_index+1) = hex( cur%16 ); //LO - full++; - cur_index+=2; - if( cur_index>=80 ) - { - aBuffer += line; - aBuffer += "\n"; - cur_index = 0; - } - } + for( int k=0; k<3; k++ ) + { + cur = *(theCurLine+4*j+2-k); + *(line+cur_index) = hex( cur/16 ); //HI + *(line+cur_index+1) = hex( cur%16 ); //LO + full++; + cur_index+=2; + if( cur_index>=80 ) + { + aBuffer += line; + aBuffer += "\n"; + cur_index = 0; + } + } } aBuffer += "> false 3 colorimage\n\n"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); } } @@ -548,7 +555,7 @@ void GLViewer_Widget::translateBackgroundToPS( QFile& hFile, GLViewer_CoordSyste const int max = 133000; //The maximum length of string in PS int dh = int( floor( double( max ) / ( 3.0*2.0*width ) ) ); for( int k=buf.height()-1; k>=0; k-=dh ) - AddImagePart( hFile, buf, 0, buf.width()-1, QMAX( k-dh+1, 0 ), k, + AddImagePart( hFile, buf, 0, buf.width()-1, qMax( k-dh+1, 0 ), k, aViewerCS, aPSCS, a, b, c, d, dx, dy-(buf.height()-1-k) ); } }