X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGLViewer%2FGLViewer_BaseObjects.cxx;h=cf12ae7ba5d29b1c5520cba1e17c03af4f09be15;hb=refs%2Fheads%2Fngr%2Fpython3_dev_pv5.4;hp=c35c664dbde1da0a1703710971e1e0ef5e53279c;hpb=aa05f2a1b23a54321ea7248ae9ac3463652c734e;p=modules%2Fgui.git diff --git a/src/GLViewer/GLViewer_BaseObjects.cxx b/src/GLViewer/GLViewer_BaseObjects.cxx index c35c664db..cf12ae7ba 100644 --- a/src/GLViewer/GLViewer_BaseObjects.cxx +++ b/src/GLViewer/GLViewer_BaseObjects.cxx @@ -1,36 +1,34 @@ -// 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 // -//#include #include "GLViewer_BaseObjects.h" #include "GLViewer_BaseDrawers.h" #include "GLViewer_AspectLine.h" #include "GLViewer_CoordSystem.h" #include "GLViewer_Text.h" #include "GLViewer_Group.h" - #include "GLViewer_Drawer.h" -//#include -//using namespace std; +#include /*! Constructor @@ -214,7 +212,7 @@ bool GLViewer_MarkerSet::translateToPS( QFile& hFile, GLViewer_CoordSystem* aVie } aBuffer+="closepath\nstroke\n"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); return true; } @@ -252,7 +250,7 @@ bool GLViewer_MarkerSet::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aV } aBuffer+="PU;\n"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); } return true; @@ -313,10 +311,10 @@ void GLViewer_MarkerSet::compute() for ( int i = 0; i < myNumber; i++ ) { - xa = QMIN( xa, myXCoord[i] ); - xb = QMAX( xb, myXCoord[i] ); - ya = QMIN( ya, myYCoord[i] ); - yb = QMAX( yb, myYCoord[i] ); + xa = qMin( xa, myXCoord[i] ); + xb = qMax( xb, myXCoord[i] ); + ya = qMin( ya, myYCoord[i] ); + yb = qMax( yb, myYCoord[i] ); } myXGap = ( xb - xa ) / 10; @@ -352,8 +350,8 @@ GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLbo // cout << "GLViewer_MarkerSet::highlight " << x <<" " << y << " " << tol << endl; int count = 0; GLfloat xdist, ydist, radius; - QValueList::Iterator it; - QValueList curHNumbers; + QList::Iterator it; + QList curHNumbers; bool isFound; GLboolean update; int cnt = 0; @@ -369,15 +367,15 @@ GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLbo ydist = ( myYCoord[i] - y ) * myYScale; // if ( isCircle && ( xdist * xdist + ydist * ydist <= radius * radius ) || - if ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) || - !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) ) + if ( ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ) || + ( !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) ) ) { - isFound = FALSE; + isFound = false; count++; for ( it = myCurSelNumbers.begin(); it != myCurSelNumbers.end(); ++it ) if( i == *it ) { - isFound = TRUE; + isFound = true; curHNumbers.append( i ); } @@ -432,10 +430,10 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe // cout << "GLViewer_MarkerSet::select " << x << " " << y << endl; int count = 0; GLfloat xdist, ydist, radius; - QValueList::Iterator it; - QValueList::Iterator it1; - QValueList::Iterator remIt; - QValueList::Iterator curIt; + QList::Iterator it; + QList::Iterator it1; + QList::Iterator remIt; + QList::Iterator curIt; radius = tol - myMarkerSize / 2.; @@ -458,19 +456,19 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe ydist = ( myYCoord[i] - y ) * myYScale; //if ( isCircle && ( xdist * xdist + ydist * ydist <= radius * radius ) || - if ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) || - !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) ) + if ( ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ) || + ( !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) ) ) { count++; if ( isShift ) { - bool isFound = FALSE; + bool isFound = false; for( it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it ) if ( *it == i ) { myUSelNumbers.append( *it ); remIt = it; - isFound = TRUE; + isFound = true; break; } @@ -481,35 +479,35 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 ) if( i == *it1 ) { - myHNumbers.remove( it1 ); + myHNumbers.erase( it1 ); break; } for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 ) if( i == *it1 ) { - myUHNumbers.remove( it1 ); + myUHNumbers.erase( it1 ); break; } } else { - mySelNumbers.remove( remIt ); + mySelNumbers.erase( remIt ); for ( curIt = myCurSelNumbers.begin(); curIt != myCurSelNumbers.end(); ++curIt ) if( *curIt == *remIt) { - myCurSelNumbers.remove( curIt ); + myCurSelNumbers.erase( curIt ); break; } for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 ) if( i == *it1 ) { - myHNumbers.remove( it1 ); + myHNumbers.erase( it1 ); break; } for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 ) if( i == *it1 ) { - myUHNumbers.remove( it1 ); + myUHNumbers.erase( it1 ); break; } } @@ -521,13 +519,13 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 ) if( i == *it1 ) { - myHNumbers.remove( it1 ); + myHNumbers.erase( it1 ); break; } for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 ) if( i == *it1 ) { - myUHNumbers.remove( it1 ); + myUHNumbers.erase( it1 ); break; } } @@ -538,7 +536,7 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe for( it1 = myUSelNumbers.begin(); it1 != myUSelNumbers.end(); ++it1 ) if( *it == *it1 ) { - it1 = myUSelNumbers.remove( it1 ); + it1 = myUSelNumbers.erase( it1 ); it1--; } @@ -633,10 +631,10 @@ void GLViewer_MarkerSet::setNumMarkers( GLint number ) /*! Export numbers of highlighted/selected lines */ -void GLViewer_MarkerSet::exportNumbers( QValueList& highlight, - QValueList& unhighlight, - QValueList& select, - QValueList& unselect ) +void GLViewer_MarkerSet::exportNumbers( QList& highlight, + QList& unhighlight, + QList& select, + QList& unselect ) { highlight = myHNumbers; unhighlight = myUHNumbers; @@ -653,19 +651,17 @@ void GLViewer_MarkerSet::exportNumbers( QValueList& highlight, bool GLViewer_MarkerSet::addOrRemoveSelected( int index ) { if( index < 0 || index > myNumber ) - return FALSE; + return false; - int n = mySelNumbers.findIndex( index ); + int n = mySelNumbers.indexOf( index ); if( n == -1 ) mySelNumbers.append( index ); else { - QValueList::Iterator it; - it = mySelNumbers.at( n ); - mySelNumbers.remove( it ); + mySelNumbers.removeAt(n); myUSelNumbers.append( index ); } - return TRUE; + return true; } /*! @@ -675,7 +671,7 @@ bool GLViewer_MarkerSet::addOrRemoveSelected( int index ) void GLViewer_MarkerSet::addSelected( const TColStd_SequenceOfInteger& seq ) { for ( int i = 1; i <= seq.Length(); i++ ) - if( mySelNumbers.findIndex( seq.Value( i ) ) == -1 ) + if( mySelNumbers.indexOf( seq.Value( i ) ) == -1 ) mySelNumbers.append( seq.Value( i ) - 1 ); } @@ -685,7 +681,7 @@ void GLViewer_MarkerSet::addSelected( const TColStd_SequenceOfInteger& seq ) */ void GLViewer_MarkerSet::setSelected( const TColStd_SequenceOfInteger& seq ) { -// for( QValueList::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it ) +// for( QList::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it ) // if( myUSelNumbers.findIndex( *it ) == -1 ) // myUSelNumbers.append( *it ); @@ -728,7 +724,8 @@ QByteArray GLViewer_MarkerSet::getByteCopy() QByteArray aObject = GLViewer_Object::getByteCopy(); - QByteArray aResult( anISize + 2*aFSize*myNumber + aFSize + aObject.size()); + QByteArray aResult; + aResult.resize( anISize + 2*aFSize*myNumber + aFSize + aObject.size()); char* aPointer = (char*)&myNumber; for( i = 0; i < anISize; i++, aPointer++ ) @@ -746,7 +743,7 @@ QByteArray GLViewer_MarkerSet::getByteCopy() aResult[i] = *aPointer; - for( ; i < aResult.size(); i++ ) + for ( ; i < (int)aResult.size(); i++ ) aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - aFSize]; return aResult; @@ -784,7 +781,8 @@ bool GLViewer_MarkerSet::initializeFromByteCopy( QByteArray theArray ) *aPointer = theArray[i]; int aCurIndex = anISize + 2*aFSize*myNumber + aFSize; - QByteArray aObject( aSize - aCurIndex ); + QByteArray aObject; + aObject.resize( aSize - aCurIndex ); for( ; i < aSize; i++ ) aObject[i - aCurIndex] = theArray[i]; @@ -871,7 +869,7 @@ bool GLViewer_Polyline::translateToPS( QFile& hFile, GLViewer_CoordSystem* aView aBuffer+="closepath\nstroke\n"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); return true; } @@ -897,7 +895,7 @@ bool GLViewer_Polyline::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aVi aBuffer+="PU;\n"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); return true; } @@ -958,10 +956,10 @@ void GLViewer_Polyline::compute() for ( int i = 0; i < myNumber; i++ ) { - xa = QMIN( xa, myXCoord[i] ); - xb = QMAX( xb, myXCoord[i] ); - ya = QMIN( ya, myYCoord[i] ); - yb = QMAX( yb, myYCoord[i] ); + xa = qMin( xa, myXCoord[i] ); + xb = qMax( xb, myXCoord[i] ); + ya = qMin( ya, myYCoord[i] ); + yb = qMax( yb, myYCoord[i] ); } GLfloat xGap = ( xb - xa ) / 10; @@ -1097,8 +1095,8 @@ GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer return false; GLfloat xa, xb, ya, yb, l; GLfloat rsin, rcos, r, ra, rb; - GLboolean update; - GLboolean selected = myIsSel; + // GLboolean update; + // GLboolean selected = myIsSel; myIsSel = GL_FALSE; @@ -1142,7 +1140,7 @@ GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer else myHighFlag = GL_TRUE; - update = ( GLboolean )( myIsSel != selected ); + // update = ( GLboolean )( myIsSel != selected ); // cout << "GLViewer_Polyline::select complete with " << (int)myIsSel << endl; @@ -1219,10 +1217,10 @@ void GLViewer_Polyline::setNumber( GLint number ) /*! Export numbers of highlighted/selected lines */ -void GLViewer_Polyline::exportNumbers( QValueList& highlight, - QValueList& unhighlight, - QValueList& select, - QValueList& unselect ) +void GLViewer_Polyline::exportNumbers( QList& highlight, + QList& unhighlight, + QList& select, + QList& unselect ) { highlight = myHNumbers; unhighlight = myUHNumbers; @@ -1264,7 +1262,8 @@ QByteArray GLViewer_Polyline::getByteCopy() QByteArray aObject = GLViewer_Object::getByteCopy(); - QByteArray aResult( aFSize*myNumber*2 + anISize + 2*aBSize + aObject.size()); + QByteArray aResult; + aResult.resize( aFSize*myNumber*2 + anISize + 2*aBSize + aObject.size()); char* aPointer = (char*)&myNumber; for( i = 0; i < anISize; i++, aPointer++ ) @@ -1284,7 +1283,7 @@ QByteArray GLViewer_Polyline::getByteCopy() for( ; i < anISize + 2*aFSize*myNumber + 2*aBSize; i++, aPointer++ ) aResult[i] = *aPointer; - for( ; i < aResult.size(); i++ ) + for ( ; i < (int)aResult.size(); i++ ) aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - 2*aBSize]; return aResult; @@ -1327,7 +1326,8 @@ bool GLViewer_Polyline::initializeFromByteCopy( QByteArray theArray ) *aPointer = theArray[i]; int aCurIndex = anISize + 2*aFSize*myNumber + 2*aBSize; - QByteArray aObject( aSize - aCurIndex ); + QByteArray aObject; + aObject.resize( aSize - aCurIndex ); for( ; i < aSize; i++ ) aObject[i - aCurIndex] = theArray[i]; @@ -1394,7 +1394,7 @@ bool GLViewer_TextObject::translateToPS( QFile& hFile, GLViewer_CoordSystem* aVi AddCoordsToPS( aBuffer, "moveto", aViewerCS, aPSCS, double(xPos), double(yPos) ); aBuffer += "(" + aText + ") show\n"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); return true; } @@ -1416,7 +1416,7 @@ bool GLViewer_TextObject::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* a aBuffer = "LB" + aText + "#;"; - hFile.writeBlock( aBuffer.ascii(), aBuffer.length() ); + hFile.write( aBuffer.toLatin1() ); return true; } @@ -1438,16 +1438,15 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC y = double( yPos ); aViewerCS->transform( *aEMFCS, x, y ); - const char* str = aText.ascii(); int nHeight = 35*14; // height of font int nWidth = 35*12; // average character width int nEscapement = 0; // angle of escapement int nOrientation = 0; // base-line orientation angle int fnWeight = FW_NORMAL; // font weight - DWORD fdwItalic = FALSE; // italic attribute option - DWORD fdwUnderline = FALSE; // underline attribute option - DWORD fdwStrikeOut = FALSE; // strikeout attribute option + DWORD fdwItalic = false; // italic attribute option + DWORD fdwUnderline = false; // underline attribute option + DWORD fdwStrikeOut = false; // strikeout attribute option DWORD fdwCharSet = ANSI_CHARSET; // character set identifier DWORD fdwOutputPrecision = OUT_DEFAULT_PRECIS; // output precision DWORD fdwClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision @@ -1467,7 +1466,7 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC HGDIOBJ old1 = SelectObject( dc, aFont ); HGDIOBJ old2 = SelectObject( dc, aBrush ); - TextOut( dc, x, y, str, aText.length() ); + TextOut( dc, x, y, aText.toLatin1().constData(), aText.length() ); SelectObject ( dc, old1 ); SelectObject ( dc, old2 ); @@ -1573,9 +1572,9 @@ GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat th QRegion circle( (int)(theX - theTol), (int)(theY - theTol), (int)(2 * theTol), (int)(2 * theTol), QRegion::Ellipse ); if( isCircle ) - intersection = obj.intersect( circle ); + intersection = obj.intersected( circle ); else - intersection = obj.intersect( region ); + intersection = obj.intersected( region ); if( intersection.isEmpty() ) myIsHigh = false; @@ -1631,9 +1630,9 @@ GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTo QRegion circle( (int)(theX - theTol), (int)(theY - theTol), (int)(2 * theTol), (int)(2 * theTol), QRegion::Ellipse ); if( isCircle ) - intersection = obj.intersect( circle ); + intersection = obj.intersected( circle ); else - intersection = obj.intersect( region ); + intersection = obj.intersected( region ); if( intersection.isEmpty() ) myIsSel = false;