-// Copyright (C) 2005 OPEN CASCADE
+// Copyright (C) 2007-2014 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
//
-/***************************************************************************
-** Class: GLViewer_BaseObjects
-** Descr: Internal OpenGL Objects
-** Module: GLViewer
-** Created: UI team, 02.09.02
-****************************************************************************/
-
-//#include <GLViewerAfx.h>
#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 <cmath>
-//using namespace std;
-
-/***************************************************************************
-** Class: GLViewer_MarkerSet
-** Descr: OpenGL MarkerSet
-** Module: GLViewer
-** Created: UI team, 03.09.02
-****************************************************************************/
+#include <QFile>
+/*!
+ Constructor
+*/
GLViewer_MarkerSet::GLViewer_MarkerSet( int number, float size, const QString& toolTip ) :
GLViewer_Object(),
myNumber( 0 ),
setNumMarkers( number );
}
+/*!
+ Destructor
+*/
GLViewer_MarkerSet::~GLViewer_MarkerSet()
{
if ( myXCoord )
delete[] myYCoord;
}
+/*!
+ Adds coords to text buffer in HPGL format
+ \param buffer - text buffer
+ \param command - command to be added with coords
+ \param aViewerCS - viewer co-ordinates system
+ \param aPaperCS - paper co-ordinates system
+ \param x - x co-ordinate
+ \param y - y co-ordinate
+ \param NewLine - adds new line to buffer
+*/
void AddCoordsToHPGL( QString& buffer, QString command, GLViewer_CoordSystem* aViewerCS,
GLViewer_CoordSystem* aPaperCS, double x, double y, bool NewLine = true )
{
buffer += ";\n";
}
+/*!
+ Adds coords to text buffer in PostScript format
+ \param buffer - text buffer
+ \param command - command to be added with coords
+ \param aViewerCS - viewer co-ordinates system
+ \param aPaperCS - paper co-ordinates system
+ \param x - x co-ordinate
+ \param y - y co-ordinate
+ \param NewLine - adds new line to buffer
+*/
void AddCoordsToPS( QString& buffer, QString command, GLViewer_CoordSystem* aViewerCS,
GLViewer_CoordSystem* aPaperCS, double x, double y, bool NewLine = true )
{
buffer += "\n";
}
+/*!
+ Adds line aspect description to text buffer in PostScript format
+ \param buffer - text buffer
+ \param anAspect - line aspect
+ \param aViewerCS - viewer co-ordinates system
+ \param aPaperCS - paper co-ordinates system
+*/
void AddLineAspectToPS( QString& buffer, GLViewer_AspectLine* anAspect,
GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPaperCS )
{
}
#ifdef WIN32
+/*!
+ Adds line aspect description EMF image
+ \param hDC - descriptor of EMF
+ \param anAspect - line aspect
+ \param aViewerCS - viewer co-ordinates system
+ \param aPaperCS - paper co-ordinates system
+*/
HPEN AddLineAspectToEMF( HDC hDC, GLViewer_AspectLine* anAspect,
GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPaperCS )
{
}
#endif
+/*!
+ Saves to file PostScript set of markers
+ \param hFile - file instance
+ \param aViewerCS - viewer co-ordinates system
+ \param aPSCS - paper co-ordinates system
+*/
bool GLViewer_MarkerSet::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
{
int noPoints = 20;
}
aBuffer+="closepath\nstroke\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
+/*!
+ Saves to file HPGL set of markers
+ \param hFile - file instance
+ \param aViewerCS - viewer co-ordinates system
+ \param aHPGLCS - paper co-ordinates system
+*/
bool GLViewer_MarkerSet::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS,
GLViewer_CoordSystem* aHPGLCS )
{
}
aBuffer+="PU;\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
}
return true;
}
#ifdef WIN32
+/*!
+ Saves to EMF image set of markers
+ \param dc - EMF image descriptor
+ \param aViewerCS - viewer co-ordinates system
+ \param aEMFCS - paper co-ordinates system
+*/
bool GLViewer_MarkerSet::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
{
int noPoints = 20;
}
#endif
-
+/*!
+ Computes all necessary information about object for presentation in drawer
+*/
void GLViewer_MarkerSet::compute()
{
// cout << "GLViewer_MarkerSet::compute" << endl;
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;
myRect->setBottom( ya - myYGap );
}
+/*!
+ Creates corresponding drawer
+*/
GLViewer_Drawer* GLViewer_MarkerSet::createDrawer()
{
// cout << "GLViewer_MarkerSet::createDrawer" << endl;
return myDrawer = new GLViewer_MarkerDrawer();
}
-
+/*!
+ Computes highlight presentation
+ \param x - x coord
+ \param y - y coord
+ \param tol - tolerance of detecting
+ \param isCircle - true if sensitive area of detection is round
+ \return true if highlight status is changed
+*/
GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
{
if( !myIsVisible )
// cout << "GLViewer_MarkerSet::highlight " << x <<" " << y << " " << tol << endl;
int count = 0;
GLfloat xdist, ydist, radius;
- QValueList<int>::Iterator it;
- QValueList<int> curHNumbers;
+ QList<int>::Iterator it;
+ QList<int> curHNumbers;
bool isFound;
GLboolean update;
int cnt = 0;
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;
count++;
return update;
}
+/*!
+ Unhilights object
+*/
GLboolean GLViewer_MarkerSet::unhighlight()
{
if( !myHNumbers.isEmpty() )
return GL_FALSE;
}
+/*!
+ Selects marker set
+ /param x, y - co-ordinates of mouse
+ /param tol - tolerance
+ /param rect - rectangle (in case of rectangular selection)
+ /param isFull - if it is true, then object may selected only if it lays whole in selection zone
+ \param isCircle - true if sensitive area of detection is round
+ \param isShift - true if selection exec with append option
+*/
GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
GLboolean isCircle, GLboolean isShift )
{
// cout << "GLViewer_MarkerSet::select " << x << " " << y << endl;
int count = 0;
GLfloat xdist, ydist, radius;
- QValueList<int>::Iterator it;
- QValueList<int>::Iterator it1;
- QValueList<int>::Iterator remIt;
- QValueList<int>::Iterator curIt;
+ QList<int>::Iterator it;
+ QList<int>::Iterator it1;
+ QList<int>::Iterator remIt;
+ QList<int>::Iterator curIt;
radius = tol - myMarkerSize / 2.;
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 )
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;
}
}
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;
}
}
for( it1 = myUSelNumbers.begin(); it1 != myUSelNumbers.end(); ++it1 )
if( *it == *it1 )
{
- it1 = myUSelNumbers.remove( it1 );
+ it1 = myUSelNumbers.erase( it1 );
it1--;
}
return myIsSel;
}
+/*!
+ Unselects marker set
+*/
GLboolean GLViewer_MarkerSet::unselect()
{
if( !mySelNumbers.isEmpty() )
return GL_FALSE;
}
+/*!
+ \return update object rectangle
+ Does not equal getRect() if object have a persistence to some viewer transformations
+*/
GLViewer_Rect* GLViewer_MarkerSet::getUpdateRect()
{
GLViewer_Rect* rect = new GLViewer_Rect();
return rect;
}
-
+/*!
+ Sets array of x coords of points
+ \param xCoord - array of co-ordinates
+ \param size - array size
+*/
void GLViewer_MarkerSet::setXCoord( GLfloat* xCoord, int size )
{
myXCoord = new GLfloat[ size ];
myXCoord[i] = xCoord[i];
}
+/*!
+ Sets array of y coords of points
+ \param yCoord - array of co-ordinates
+ \param size - array size
+*/
void GLViewer_MarkerSet::setYCoord( GLfloat* yCoord, int size )
{
myYCoord = new GLfloat[ size ];
myYCoord[i] = yCoord[i];
}
+/*!
+ Sets number of markers
+ \param number - new number of markers
+*/
void GLViewer_MarkerSet::setNumMarkers( GLint number )
{
if ( myNumber == number )
myXCoord = new GLfloat[ myNumber ];
myYCoord = new GLfloat[ myNumber ];
}
-/*
-void GLViewer_MarkerSet::onSelectionDone( bool append)
-{
- mySelectedIndexes.Clear();
- QValueList<int>::Iterator it;
- //for( it = myMarkers->mySelNumbers.begin(); it != myMarkers->mySelNumbers.end(); ++it )
- // mySelectedIndexes.Append( *it / 2 ); //!!!
- emit dvMarkersSelected( mySelectedIndexes );
-}
-void GLViewer_MarkerSet::onSelectionCancel()
-{
- mySelectedIndexes.Clear();
- emit dvMarkersSelected( mySelectedIndexes );
-}
+/*!
+ Export numbers of highlighted/selected lines
*/
-void GLViewer_MarkerSet::exportNumbers( QValueList<int>& highlight,
- QValueList<int>& unhighlight,
- QValueList<int>& select,
- QValueList<int>& unselect )
+void GLViewer_MarkerSet::exportNumbers( QList<int>& highlight,
+ QList<int>& unhighlight,
+ QList<int>& select,
+ QList<int>& unselect )
{
highlight = myHNumbers;
unhighlight = myUHNumbers;
myUHNumbers = myHNumbers;
}
+/*!
+ Adds or remove selected number
+ \param index - selected index
+*/
bool GLViewer_MarkerSet::addOrRemoveSelected( int index )
{
if( index < 0 || index > myNumber )
return FALSE;
- int n = mySelNumbers.findIndex( index );
+ int n = mySelNumbers.indexOf( index );
if( n == -1 )
mySelNumbers.append( index );
else
{
- QValueList<int>::Iterator it;
- it = mySelNumbers.at( n );
- mySelNumbers.remove( it );
+ mySelNumbers.removeAt(n);
myUSelNumbers.append( index );
}
return TRUE;
}
+/*!
+ Adds some selected numbers
+ \param seq - sequence of indices
+*/
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 );
}
+/*!
+ Sets some numbers as selected
+ \param seq - sequence of indices
+*/
void GLViewer_MarkerSet::setSelected( const TColStd_SequenceOfInteger& seq )
{
-// for( QValueList<int>::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
+// for( QList<int>::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
// if( myUSelNumbers.findIndex( *it ) == -1 )
// myUSelNumbers.append( *it );
mySelNumbers.append( seq.Value( i ) - 1 );
}
+/*! Moves object by recomputing
+ \param dx - moving along X coord
+ \param dy - moving along Y coord
+ \param fromGroup - is true if this method called from group
+*/
void GLViewer_MarkerSet::moveObject( float theX, float theY, bool fromGroup )
{
if( !fromGroup && myGroup)
compute();
}
+/*!
+ Codes marker set as byte copy
+ \return byte array
+*/
QByteArray GLViewer_MarkerSet::getByteCopy()
{
int i = 0;
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++ )
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;
}
+/*!
+ Initialize marker set by byte array
+ \param theArray - byte array
+*/
bool GLViewer_MarkerSet::initializeFromByteCopy( QByteArray theArray )
{
int i = 0;
*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];
return true;
}
-/***************************************************************************
-** Class: GLViewer_Polyline
-** Descr: OpenGL Polyline
-** Module: GLViewer
-** Created: UI team, 03.09.02
-****************************************************************************/
+/*!
+ \class GLViewer_Polyline
+ OpenGL Polyline
+*/
#define SECTIONS 100
#define DISTANTION 5
+/*!
+ Constructor
+ \param number - number of segments
+ \param size - size of polyline
+ \param toolTip - tool tip of polyline
+*/
GLViewer_Polyline::GLViewer_Polyline( int number, float size, const QString& toolTip ):
GLViewer_Object(),
myNumber( 0 ),
myToolTipText = toolTip;
}
+/*!
+ Destructor, destroys internal arrays of co-ordinates
+*/
GLViewer_Polyline::~GLViewer_Polyline()
{
if ( myXCoord )
delete[] myYCoord;
}
+/*!
+ Saves polyline to file PostScript
+ \param hFile - file instance
+ \param aViewerCS - viewer co-ordinates system
+ \param aPSCS - paper co-ordinates system
+*/
bool GLViewer_Polyline::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
{
QString aBuffer = "newpath\n";
aBuffer+="closepath\nstroke\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
+/*!
+ Saves polyline to file HPGL
+ \param hFile - file instance
+ \param aViewerCS - viewer co-ordinates system
+ \param aHPGLCS - paper co-ordinates system
+*/
bool GLViewer_Polyline::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
{
QString aBuffer = "";
aBuffer+="PU;\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
#ifdef WIN32
+/*!
+ Saves polyline to EMF image
+ \param dc - EMF image descriptor
+ \param aViewerCS - viewer co-ordinates system
+ \param aEMFCS - paper co-ordinates system
+*/
bool GLViewer_Polyline::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
{
if( !aViewerCS || !aEMFCS )
}
#endif
+/*!
+ Computes all necessary information about object for presentation in drawer
+*/
void GLViewer_Polyline::compute()
{
// cout << "GLViewer_MarkerSet::compute" << endl;
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;
myRect->setBottom( ya - yGap );
}
+/*!
+ \return update object rectangle
+ Does not equal getRect() if object have a persistence to some viewer transformations
+*/
GLViewer_Rect* GLViewer_Polyline::getUpdateRect()
{
GLViewer_Rect* rect = new GLViewer_Rect();
return rect;
}
+/*!
+ Creates corresponding drawer
+*/
GLViewer_Drawer* GLViewer_Polyline::createDrawer()
{
// cout << "GLViewer_MarkerSet::createDrawer" << endl;
return myDrawer = new GLViewer_PolylineDrawer();
}
+/*!
+ Computes highlight presentation
+ \param x - x coord
+ \param y - y coord
+ \param tol - tolerance of detecting
+ \param isCircle - true if sensitive area of detection is round
+ \return true if highlight status is changed
+*/
GLboolean GLViewer_Polyline::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
{
if( !myIsVisible )
return update;
}
+/*!
+ Unhilights object
+*/
GLboolean GLViewer_Polyline::unhighlight()
{
// if( !myHNumbers.isEmpty() )
return GL_FALSE;
}
+/*!
+ Selects polyline
+ /param x, y - co-ordinates of mouse
+ /param tol - tolerance
+ /param rect - rectangle (in case of rectangular selection)
+ /param isFull - if it is true, then object may selected only if it lays whole in selection zone
+ \param isCircle - true if sensitive area of detection is round
+ \param isShift - true if selection exec with append option
+*/
GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
GLboolean isCircle, GLboolean isShift )
{
return false;
GLfloat xa, xb, ya, yb, l;
GLfloat rsin, rcos, r, ra, rb;
- GLboolean update;
+ // GLboolean update;
GLboolean selected = myIsSel;
myIsSel = GL_FALSE;
else
myHighFlag = GL_TRUE;
- update = ( GLboolean )( myIsSel != selected );
+ // update = ( GLboolean )( myIsSel != selected );
// cout << "GLViewer_Polyline::select complete with " << (int)myIsSel << endl;
return myIsSel;
}
+/*!
+ Unselects polyline
+*/
GLboolean GLViewer_Polyline::unselect()
{
// if( !mySelNumbers.isEmpty() )
return GL_FALSE;
}
+/*!
+ Sets array of abscisses for points of polyline
+ \param xCoord - array of of abscisses
+ \param size - size of array
+*/
void GLViewer_Polyline::setXCoord( GLfloat* xCoord, int size )
{
myXCoord = new GLfloat[ size ];
myXCoord[i] = xCoord[i];
}
+/*!
+ Sets array of ordinates for points of polyline
+ \param xCoord - array of of ordinates
+ \param size - size of array
+*/
void GLViewer_Polyline::setYCoord( GLfloat* yCoord, int size )
{
myYCoord = new GLfloat[ size ];
myYCoord[i] = yCoord[i];
}
+/*!
+ Sets number of points
+ \param number - new number of points
+*/
void GLViewer_Polyline::setNumber( GLint number )
{
if ( myNumber == number )
myXCoord = new GLfloat[ myNumber ];
myYCoord = new GLfloat[ myNumber ];
}
-/*
-void GLViewer_Polyline::onSelectionDone( bool append)
-{
- mySelectedIndexes.Clear();
- QValueList<int>::Iterator it;
- //for( it = myMarkers->mySelNumbers.begin(); it != myMarkers->mySelNumbers.end(); ++it )
- // mySelectedIndexes.Append( *it / 2 ); //!!!
-}
-void GLViewer_Polyline::onSelectionCancel()
-{
- mySelectedIndexes.Clear();
-}
+/*!
+ Export numbers of highlighted/selected lines
*/
-void GLViewer_Polyline::exportNumbers( QValueList<int>& highlight,
- QValueList<int>& unhighlight,
- QValueList<int>& select,
- QValueList<int>& unselect )
+void GLViewer_Polyline::exportNumbers( QList<int>& highlight,
+ QList<int>& unhighlight,
+ QList<int>& select,
+ QList<int>& unselect )
{
highlight = myHNumbers;
unhighlight = myUHNumbers;
unselect = myUSelNumbers;
}
+/*!
+ Moves object by recomputing
+ \param dx - moving along X coord
+ \param dy - moving along Y coord
+ \param fromGroup - is true if this method called from group
+*/
void GLViewer_Polyline::moveObject( float theX, float theY, bool fromGroup )
{
if( !fromGroup && myGroup)
compute();
}
+/*!
+ Codes polyline as byte copy
+ \return byte array
+*/
QByteArray GLViewer_Polyline::getByteCopy()
{
int i = 0;
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++ )
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;
}
+/*!
+ Initialize polyline by byte array
+ \param theArray - byte array
+*/
bool GLViewer_Polyline::initializeFromByteCopy( QByteArray theArray )
{
int i = 0;
*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];
return true;
}
-/***************************************************************************
-** Class: GLViewer_TextObject
-** Descr: Text as Object for OpenGL
-** Module: GLViewer
-** Created: UI team, 12.02.04
-****************************************************************************/
+
+/*!
+ Constructor
+ \param theStr - text string
+ \param xPos - x position
+ \param yPos - y position
+ \param color - color of text
+ \param toolTip - tooltip of text object
+*/
GLViewer_TextObject::GLViewer_TextObject( const QString& theStr, float xPos, float yPos,
const QColor& color, const QString& toolTip )
: GLViewer_Object()
myToolTipText = toolTip;
}
+
+/*!
+ Destructor
+*/
GLViewer_TextObject::~GLViewer_TextObject()
{
if ( myGLText )
delete myGLText;
}
+/*!
+ Saves text object to file PostScript
+ \param hFile - file instance
+ \param aViewerCS - viewer co-ordinates system
+ \param aPSCS - paper co-ordinates system
+*/
bool GLViewer_TextObject::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
{
QString aText = myGLText->getText();
AddCoordsToPS( aBuffer, "moveto", aViewerCS, aPSCS, double(xPos), double(yPos) );
aBuffer += "(" + aText + ") show\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
+/*!
+ Saves text object to file HPGL
+ \param hFile - file instance
+ \param aViewerCS - viewer co-ordinates system
+ \param aHPGLCS - paper co-ordinates system
+*/
bool GLViewer_TextObject::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
{
QString aText = myGLText->getText();
aBuffer = "LB" + aText + "#;";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
#ifdef WIN32
+/*!
+ Saves text object to EMF image
+ \param dc - EMF image descriptor
+ \param aViewerCS - viewer co-ordinates system
+ \param aEMFCS - paper co-ordinates system
+*/
bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
{
QString aText = myGLText->getText();
y = double( yPos );
aViewerCS->transform( *aEMFCS, x, y );
- const char* str = aText.ascii();
+ const char* str = aText.toAscii();
int nHeight = 35*14; // height of font
int nWidth = 35*12; // average character width
}
#endif
+/*!
+ Creates corresponding drawer
+*/
GLViewer_Drawer* GLViewer_TextObject::createDrawer()
{
myDrawer = new GLViewer_TextDrawer();
return myDrawer;
}
+/*!
+ Computes all necessary information about object for presentation in drawer
+*/
void GLViewer_TextObject::compute()
{
float xPos, yPos;
myRect->setBottom( yPos );
}
+/*!
+ Installing already exist drawer with same type
+ \param theDrawer - new drawer
+*/
void GLViewer_TextObject::setDrawer( GLViewer_Drawer* theDrawer )
{
myDrawer = theDrawer;
//compute();
}
+/*!
+ \return update object rectangle
+ Does not equal getRect() if object have a persistence to some viewer transformations
+*/
GLViewer_Rect* GLViewer_TextObject::getUpdateRect()
{
GLViewer_Rect* rect = new GLViewer_Rect();
return rect;
}
+/*!
+ Computes highlight presentation
+ \param x - x coord
+ \param y - y coord
+ \param tol - tolerance of detecting
+ \param isCircle - true if sensitive area of detection is round
+ \return true if highlight status is changed
+*/
GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat theTol, GLboolean isCircle )
{
if( !myIsVisible )
return myIsHigh;
}
+/*!
+ Unhilights object
+*/
GLboolean GLViewer_TextObject::unhighlight()
{
if( myIsHigh )
return GL_FALSE;
}
+/*!
+ Selects text object
+ /param x, y - co-ordinates of mouse
+ /param tol - tolerance
+ /param rect - rectangle (in case of rectangular selection)
+ /param isFull - if it is true, then object may selected only if it lays whole in selection zone
+ \param isCircle - true if sensitive area of detection is round
+ \param isShift - true if selection exec with append option
+*/
GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTol, GLViewer_Rect rect,
GLboolean isFull, GLboolean isCircle, GLboolean isShift )
{
return myIsSel;
}
+/*!
+ Unselects text object
+*/
GLboolean GLViewer_TextObject::unselect()
{
if( myIsSel )
return GL_FALSE;
}
+/*!
+ Moves object by recomputing
+ \param dx - moving along X coord
+ \param dy - moving along Y coord
+ \param fromGroup - is true if this method called from group
+*/
void GLViewer_TextObject::moveObject( float theX, float theY, bool fromGroup )
{
if( !fromGroup && myGroup)
compute();
}
+/*!
+ Codes text object as byte copy
+ \return byte array
+*/
QByteArray GLViewer_TextObject::getByteCopy()
{
QByteArray aObject = GLViewer_Object::getByteCopy();
return aObject;
}
+/*!
+ Initialize text object by byte array
+ \param theArray - byte array
+*/
bool GLViewer_TextObject::initializeFromByteCopy( QByteArray theArray )
{
if( !GLViewer_Object::initializeFromByteCopy( theArray ) || myType != "GLViewer_TextObject" )