int aHR = myHColor.red(), aHG = myHColor.green(), aHB = myHColor.blue();
int aSR = mySColor.red(), aSG = mySColor.green(), aSB = mySColor.blue();
- QByteArray aResult( anISize * 10 + aFSize );
+ QByteArray aResult;
+ aResult.resize( anISize * 10 + aFSize );
int i = 0;
#include "GLViewer.h"
-#include <qcolor.h>
+#include <QColor>
#ifdef WIN32
#pragma warning( disable:4251 )
#include "GLViewer_AspectLine.h"
#include "GLViewer_BaseObjects.h"
+// Qt includes
+#include <QColor>
+
+
#ifndef WIN32
#include <GL/glx.h>
#endif
*/
void GLViewer_MarkerDrawer::create( float xScale, float yScale, bool onlyUpdate )
{
- QValueList<int>::Iterator it;
- QValueList<int>::Iterator EndIt;
- QValueList<GLViewer_Object*>::Iterator anObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator anEndObjectIt = myObjects.end();
+ QList<int>::Iterator it;
+ QList<int>::Iterator EndIt;
+ QList<GLViewer_Object*>::Iterator anObjectIt = myObjects.begin();
+ QList<GLViewer_Object*>::Iterator anEndObjectIt = myObjects.end();
myXScale = xScale;
myYScale = yScale;
float* anYCoord = aMarkerSet->getYCoord();
float aRadius = aMarkerSet->getMarkerSize();
- QValueList<int> aHNumbers, anUHNumbers, aSelNumbers, anUSelNumbers;
+ QList<int> aHNumbers, anUHNumbers, aSelNumbers, anUSelNumbers;
aMarkerSet->exportNumbers( aHNumbers, anUHNumbers, aSelNumbers, anUSelNumbers );
if( onlyUpdate )
*/
void GLViewer_PolylineDrawer::create( float xScale, float yScale, bool onlyUpdate )
{
- QValueList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
+ QList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
+ QList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
myXScale = xScale;
myYScale = yScale;
*/
void GLViewer_TextDrawer::create( float xScale, float yScale, bool onlyUpdate )
{
- QValueList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
+ QList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
+ QList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
myXScale = xScale;
myYScale = yScale;
*/
void GLViewer_TextDrawer::updateObjects()
{
- QValueList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
+ QList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
+ QList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
for( ; aObjectIt != aObjectEndIt; aObjectIt++ )
(*aObjectIt)->compute();
}
#ifndef GLVIEWER_BASEDRAWERS_H
#define GLVIEWER_BASEDRAWERS_H
-#include <qcolor.h>
-#include <qobject.h>
-#include <qfile.h>
-#include <qfont.h>
-#include <qgl.h>
+class QColor;
#include "GLViewer.h"
#include "GLViewer_Drawer.h"
#include "GLViewer_Drawer.h"
+#include <QFile>
+
//#include <cmath>
//using namespace std;
}
aBuffer+="closepath\nstroke\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
}
aBuffer+="PU;\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
}
return true;
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;
// 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;
// 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.;
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--;
}
/*!
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;
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;
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 );
}
*/
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 );
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++ )
*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];
aBuffer+="closepath\nstroke\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
aBuffer+="PU;\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
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;
/*!
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;
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++ )
*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];
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;
}
aBuffer = "LB" + aText + "#;";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
return true;
}
#include "GLViewer.h"
#include "GLViewer_Object.h"
-#include <qcolor.h>
-#include <qvaluelist.h>
+#include <QColor>
#include <TColStd_SequenceOfInteger.hxx>
float getMarkerSize() const { return myMarkerSize; }
//! Export numbers of heghlighted/selected markers
- void exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
- QValueList<int>& sel, QValueList<int>& unsel );
+ void exportNumbers( QList<int>& high, QList<int>& unhigh,
+ QList<int>& sel, QList<int>& unsel );
//! Returns selected numbers
- QValueList<int> getSelectedElements() { return mySelNumbers; }
+ QList<int> getSelectedElements() { return mySelNumbers; }
//! Adds or remove selected number
bool addOrRemoveSelected( int index );
//! Adds selected numbers
GLfloat* myXCoord;
GLfloat* myYCoord;
GLfloat myMarkerSize;
- QValueList<int> myHNumbers;
- QValueList<int> myUHNumbers;
- QValueList<int> mySelNumbers;
- QValueList<int> myCurSelNumbers;
- QValueList<int> myUSelNumbers;
- QValueList<int> myPrevHNumbers;
+ QList<int> myHNumbers;
+ QList<int> myUHNumbers;
+ QList<int> mySelNumbers;
+ QList<int> myCurSelNumbers;
+ QList<int> myUSelNumbers;
+ QList<int> myPrevHNumbers;
TColStd_SequenceOfInteger mySelectedIndexes;
};
GLboolean isHighSelAll() const { return myHighSelAll; }
//! Export numbers of highlighted/selected lines
- void exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
- QValueList<int>& sel, QValueList<int>& unsel );
+ void exportNumbers( QList<int>& high, QList<int>& unhigh,
+ QList<int>& sel, QList<int>& unsel );
//! Returns numbers of selected lines
- QValueList<int> getSelectedElements() { return mySelNumbers; }
+ QList<int> getSelectedElements() { return mySelNumbers; }
protected:
GLfloat* myXCoord;
GLboolean myIsClosed;
GLboolean myHighSelAll;
- QValueList<int> myHNumbers;
- QValueList<int> myUHNumbers;
- QValueList<int> mySelNumbers;
- QValueList<int> myUSelNumbers;
- QValueList<int> myCurSelNumbers;
- QValueList<int> myPrevHNumbers;
+ QList<int> myHNumbers;
+ QList<int> myUHNumbers;
+ QList<int> mySelNumbers;
+ QList<int> myUSelNumbers;
+ QList<int> myCurSelNumbers;
+ QList<int> myPrevHNumbers;
TColStd_SequenceOfInteger mySelectedIndexes;
GLboolean myHighFlag;
#include "GLViewer.h"
-#include <qcolor.h>
+#include <QColor>
+
+class QFont;
#ifdef WIN32
#pragma warning( disable:4251 )
#include "GLViewer_Object.h"
#include "GLViewer_Viewer2d.h"
#include "GLViewer_ViewPort2d.h"
+#include "GLViewer_ViewFrame.h"
+
+//QT includes
+#include <QRect>
#include <TColStd_SequenceOfInteger.hxx>
}
else if( myLastPicked->isSelected() && status != SS_LocalChanged )
{
- mySelectedObjects.remove( myLastPicked );
+ mySelectedObjects.removeAll( myLastPicked );
myLastPicked->unselect();
myGLViewer2d->updateAll();
}
if ( myLastPicked->select( myXhigh, myYhigh, myTolerance, GLViewer_Rect(), false, byCircle, Append )
- && mySelectedObjects.findIndex( myLastPicked ) == -1 )
+ && mySelectedObjects.indexOf( myLastPicked ) == -1 )
{
mySelectedObjects.append( myLastPicked );
myGLViewer2d->activateDrawer( myLastPicked, TRUE, TRUE );
isSel = (*it)->isSelected();
}
- if( isSel && mySelectedObjects.findIndex( *it ) == -1 )
+ if( isSel && mySelectedObjects.indexOf( *it ) == -1 )
{
aList.append( *it );
mySelectedObjects.append( *it );
if( myActiveObjects.contains( oldObject ) )
{
- myActiveObjects.remove( oldObject );
+ myActiveObjects.removeAll( oldObject );
myActiveObjects.append( newObject );
return true;
}
if( myInactiveObjects.contains( oldObject ) )
{
- myInactiveObjects.remove( oldObject );
+ myInactiveObjects.removeAll( oldObject );
myInactiveObjects.append( newObject );
return true;
}
if( !object || !mySelectedObjects.contains( object ) )
return;
- mySelectedObjects.remove( object );
+ mySelectedObjects.removeAll( object );
object->unselect();
if( updateViewer )
return;
if( myActiveObjects.contains( theObject ) )
- myActiveObjects.remove( theObject );
+ myActiveObjects.removeAll( theObject );
else if( myInactiveObjects.contains( theObject ) )
- myInactiveObjects.remove( theObject );
+ myInactiveObjects.removeAll( theObject );
else
return;
if( mySelectedObjects.contains( theObject ) )
- mySelectedObjects.remove( theObject );
+ mySelectedObjects.removeAll( theObject );
GLViewer_Group* aGroup = theObject->getGroup();
if( aGroup )
if( !theObject || !myInactiveObjects.contains( theObject ) )
return false;
- myInactiveObjects.remove( theObject );
+ myInactiveObjects.removeAll( theObject );
myActiveObjects.append( theObject );
return true;
}
if( !theObject || !myActiveObjects.contains( theObject ) )
return false;
- myActiveObjects.remove( theObject );
+ myActiveObjects.removeAll( theObject );
myInactiveObjects.append( theObject );
return true;
}
#include "GLViewer_Defs.h"
#include "GLViewer_Object.h"
-#include <qrect.h>
-#include <qobject.h>
-#include <qregion.h>
+class QRect;
#include <Quantity_NameOfColor.hxx>
#include <Quantity_Color.hxx>
#ifndef GLVIEWER_DEFS_H
#define GLVIEWER_DEFS_H
-#include <qmap.h>
-#include <qvaluelist.h>
+#include <QMap>
+#include <QList>
class GLViewer_Object;
//Selection staus
};
typedef QMap<GLViewer_Object*,int> ObjectMap;
-typedef QValueList<GLViewer_Object*> ObjList;
+typedef QList<GLViewer_Object*> ObjList;
#define SEGMENTS 32
#define PI 3.14159265359
#include "GLViewer_ViewFrame.h"
#include "GLViewer_ViewPort2d.h"
+#include <QApplication>
+#include <QImage>
+#include <QPainter>
+#include <QFile>
+
#ifndef WIN32
#include <GL/glx.h>
#endif
#include <gp_Pnt2d.hxx>
-#include <qimage.h>
-#include <qpainter.h>
-
#define TEXT_GAP 5
// Two texture components for texmapped fonts: luminance and alpha
#define NB_TEX_COMP 2
GLViewer_TexFont::GLViewer_TexFont()
: myMaxRowWidth( 0 ), myFontHeight( 0 )
{
- myQFont = QFont::defaultFont();
+ myQFont = QApplication::font();//QFont::defaultFont();
mySeparator = 2;
myIsResizeable = false;
myMinMagFilter = GL_LINEAR;
aPainter.drawText( myPositions[l], ( row + 1 ) * aRowPixelHeight - aDescent, aLetter );
}
- QImage aImage = aPixmap.convertToImage();
+ QImage aImage = aPixmap.toImage();
//int qqq = 0;
//if (qqq)
int aLettIndex, row;
for ( int i = 0; i < (int)theStr.length(); i++ )
{
- aLetter = theStr.data()[i];
+ aLetter = theStr.data()[i].toLatin1();
aLettIndex = (int)aLetter - FirstSymbolNumber;
row = aLettIndex / TEX_ROW_LEN;
int aWidth = 0;
for ( int i = 0; i < (int)theStr.length(); i ++ )
{
- char aLetter = theStr.data()[i];
+ char aLetter = theStr.data()[i].toLatin1();
int aLettIndex = (int)aLetter - FirstSymbolNumber;
aWidth += myWidths[aLettIndex] + mySeparator;
}
QMap<GLViewer_TexFindId, GLuint>::iterator it = GLViewer_TexFont::BitmapFontCache.begin();
for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it )
{
- if ( it.key().myViewPortId == size_t(aCont) && it.data() > listBase )
- listBase = it.data();
+ if ( it.key().myViewPortId == size_t(aCont) && it.value() > listBase )
+ listBase = it.value();
}
listBase += 256;
//glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase );
int aFontCont = 0;
QString aFontDef = theFont->toString();
- char** xFontList = XListFonts( aDisp, aFontDef.latin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont );
+ char** xFontList = XListFonts( aDisp, aFontDef.toLatin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont );
if( !theFont->handle() )
{
#ifdef _DEBUG_
- printf( "Can't load font %s. loading default font....\n", aFontDef.latin1()/*aFindFont.myFontString.data()*/ );
+ printf( "Can't load font %s. loading default font....\n", aFontDef.toLatin1().data()/*aFindFont.myFontString.data()*/ );
#endif
QString aFontMask ("-*-*-*-r-*-*-");
aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 );
printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() );
#endif
aFontMask += "-*-*-*-m-*-*-*";
- xFontList = XListFonts( aDisp, aFontMask.data()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont );
+ xFontList = XListFonts( aDisp, aFontMask.toLatin1().constData()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont );
if( aFontCont == 0 )
{
#ifdef _DEBUG_
QMap<GLViewer_TexFindId,GLViewer_TexIdStored>::Iterator anEndIt= GLViewer_TexFont::TexFontBase.end();
for( ; anIt != anEndIt; anIt++ )
- glDeleteTextures( 1, &(anIt.data().myTexFontId) );
+ glDeleteTextures( 1, &(anIt.value().myTexFontId) );
}
/*!
{
glRasterPos2f( xPos, yPos );
glListBase( displayListBase( theFont ) );
- glCallLists( text.length(), GL_UNSIGNED_BYTE, text.local8Bit().data() );
+ glCallLists( text.length(), GL_UNSIGNED_BYTE, text.toLocal8Bit().data() );
}
}
glLineWidth( lineWidth );
glBegin( GL_LINES );
- QValueList<GLViewer_Pnt>::const_iterator it = pntList.begin();
+ QList<GLViewer_Pnt>::const_iterator it = pntList.begin();
for( ; it != pntList.end(); ++it )
glVertex2f( (*it).x(), (*it).y() );
glEnd();
( GLfloat )color.green() / 255,
( GLfloat )color.blue() / 255 );
glBegin( GL_POLYGON );
- QValueList<GLViewer_Pnt>::const_iterator it = pntList.begin();
+ QList<GLViewer_Pnt>::const_iterator it = pntList.begin();
for( ; it != pntList.end(); ++it )
glVertex2f( (*it).x(), (*it).y() );
glEnd();
#include "windows.h"
#endif
-#include <qcolor.h>
-#include <qobject.h>
-#include <qfile.h>
-#include <qfont.h>
-#include <qgl.h>
+#include <QColor>
+#include <QFont>
+
+class QFile;
#include <GL/gl.h>
float myYScale;
//! List of objects
- QValueList<GLViewer_Object*> myObjects;
+ QList<GLViewer_Object*> myObjects;
//! List generated textures
GLuint myTextList;
#include "GLViewer.h"
-#include <qrect.h>
-#include <qvaluelist.h>
-#include <qgl.h>
+#include <QRect>
+#include <QtOpenGL>
#include <math.h>
+//using namespace QGL;
#ifdef WIN32
#pragma warning( disable:4251 )
GLfloat myY;
};
-typedef QValueList<GLViewer_Pnt> GLViewer_PntList;
+typedef QList<GLViewer_Pnt> GLViewer_PntList;
/*! Class GLViewer_Rect
* Substitution of QRect for OpenGL
#include "GLViewer_Defs.h"
#include <Precision.hxx>
-#include <qglobal.h>
/*!
Default constructor
--- /dev/null
+// Copyright (C) 2005 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.
+//
+// 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.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : OPEN CASCADE
+//
+
+//#include <GLViewerAfx.h>
+#include "GLViewer_MimeData.h"
+#include "GLViewer_BaseObjects.h"
+
+//#include <cmath>
+//using namespace std;
+
+/*!
+ Destructor
+*/
+GLViewer_MimeData::~GLViewer_MimeData()
+{
+}
+
+/*!
+ Translate objects to byte array
+ \param theObjects - list of objects
+*/
+bool GLViewer_MimeData::setObjects( QList<GLViewer_Object*> theObjects )
+{
+ if( !theObjects.empty() )
+ {
+ QStringList aObjectsType;
+ QList<QByteArray> aObjects;
+ QList<GLViewer_Object*>::const_iterator anIt = theObjects.begin();
+ QList<GLViewer_Object*>::const_iterator anEndIt = theObjects.end();
+
+ int aObjByteSize = 0;
+ for( ; anIt != anEndIt; anIt++ )
+ {
+ aObjects.append( (*anIt)->getByteCopy() );
+ aObjByteSize += aObjects.last().size();
+ aObjectsType.append( (*anIt)->getObjectType() );
+ }
+
+ int anISize = sizeof( int );
+ QString aTypes = aObjectsType.join("");
+ int aStrByteSize = aTypes.length();
+ int aObjNum = aObjects.count();
+
+ myByteArray.resize( anISize * (1 + 2*aObjNum) + aStrByteSize + aObjByteSize );
+
+ int anIndex = 0, j = 0;
+ char* aPointer = (char*)&aObjNum;
+ for( anIndex = 0; anIndex < anISize; anIndex++, aPointer++ )
+ myByteArray[anIndex] = *aPointer;
+
+ QStringList::const_iterator aStrIt = aObjectsType.begin();
+ QStringList::const_iterator aEndStrIt = aObjectsType.end();
+ for( j = 1; aStrIt != aEndStrIt; aStrIt++, j++ )
+ {
+ int aStrLen = (*aStrIt).length();
+ aPointer = (char*)&aStrLen;
+ for( ; anIndex < anISize*( 1 + j ); anIndex++, aPointer++ )
+ myByteArray[anIndex] = *aPointer;
+ }
+
+ int aCurIndex = anIndex;
+ const char* aStr = aTypes.toLatin1().constData();
+
+ for( j = 0 ; anIndex < aCurIndex + aStrByteSize; aPointer++, anIndex++, j++ )
+ myByteArray[anIndex] = aStr[j];
+
+ aCurIndex = anIndex;
+ QList<QByteArray>::iterator anObjIt = aObjects.begin();
+ QList<QByteArray>::iterator anEndObjIt = aObjects.end();
+ for( j = 1; anObjIt != anEndObjIt; anObjIt++, j++ )
+ {
+ int aObjLen = (int)((*anObjIt).size());
+ aPointer = (char*)&aObjLen;
+ for( ; anIndex < aCurIndex + anISize*j; anIndex++, aPointer++ )
+ myByteArray[anIndex] = *aPointer;
+ }
+
+ aCurIndex = anIndex;
+ anObjIt = aObjects.begin();
+
+ for( ; anObjIt != anEndObjIt; anObjIt++ )
+ {
+ int aObjLen = (int)((*anObjIt).size());
+ for( j = 0 ; anIndex < aCurIndex + aObjLen; anIndex++, aPointer++, j++ )
+ myByteArray[anIndex] = (*anObjIt)[j];
+ aCurIndex = anIndex;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+/*!
+ Creates object by it's representation (byte array)
+ \param theArray - byte array
+ \param theType - type of object
+*/
+GLViewer_Object* GLViewer_MimeData::getObject( QByteArray theArray, QString theType )
+{
+ if( !theArray.isEmpty() )
+ {
+ if( theType == "GLViewer_MarkerSet" )
+ {
+ GLViewer_MarkerSet* aObject = new GLViewer_MarkerSet( 0, (float)0.0, 0 );
+ if( aObject->initializeFromByteCopy( theArray ) )
+ return aObject;
+ }
+ else if ( theType == "GLViewer_Polyline" )
+ {
+ GLViewer_Polyline* aObject = new GLViewer_Polyline( 0, (float)0.0, 0 );
+ if( aObject->initializeFromByteCopy( theArray ) )
+ return aObject;
+ }
+ else if( theType == "GLViewer_TextObject" )
+ {
+ GLViewer_TextObject* aObject = new GLViewer_TextObject( 0, 0, 0, QColor(255,255,255), 0 );
+ if( aObject->initializeFromByteCopy( theArray ) )
+ return aObject;
+ }
+ }
+
+ return NULL;
+}
+
+/*!
+ Creates list of objects by its representation (byte array)
+ \param theArray - byte array
+ \param theType - type of object
+*/
+QList<GLViewer_Object*> GLViewer_MimeData::getObjects( QByteArray theArray, QString theType )
+{
+ if( !theArray.isEmpty() )
+ {
+ int anISize = sizeof( int );
+ if( theType == "GLViewer_Objects" )
+ {
+ QStringList aTypeList;
+ QList<QByteArray> aObjects;
+ QList<GLViewer_Object*> aObjectList;
+
+ QList<int> aTypeSizeList;
+ QList<int> aObjSizeList;
+ int aObjNum = 0;
+ char* aPointer = (char*)&aObjNum;
+
+ int anIndex = 0, j = 0;
+ for( anIndex = 0; anIndex < anISize; anIndex++, aPointer++ )
+ *aPointer = theArray[anIndex];
+
+ for( j = 0; j < aObjNum; j++ )
+ {
+ int aTempVal = 0;
+ aPointer = (char*)&aTempVal;
+ for( ; anIndex < anISize*(j+2); anIndex++, aPointer++ )
+ *aPointer = theArray[anIndex];
+ aTypeSizeList.append( aTempVal );
+ }
+
+ int aCurIndex = anIndex;
+ for( j = 0; j < aObjNum; j++ )
+ {
+ QString aTempStr;
+ for( ; anIndex < aCurIndex + aTypeSizeList[j]; anIndex++ )
+ {
+ char aLetter = theArray[anIndex];
+ aTempStr.append( aLetter );
+ }
+ aTypeList.append( aTempStr );
+ aCurIndex = anIndex;
+ }
+
+ for( j = 0; j < aObjNum; j++ )
+ {
+ int aTempVal = 0;
+ aPointer = (char*)&aTempVal;
+ for( ; anIndex < aCurIndex + anISize*(j+1); anIndex++, aPointer++ )
+ *aPointer = theArray[anIndex];
+ aObjSizeList.append( aTempVal );
+ }
+
+ aCurIndex = anIndex;
+ for( j = 0; j < aObjNum; j++ )
+ {
+ QByteArray aTempArray;
+ aTempArray.resize(aObjSizeList[j]);
+ for( ; anIndex < aCurIndex + aObjSizeList[j]; anIndex++ )
+ aTempArray[anIndex-aCurIndex] = theArray[anIndex];
+ aObjects.append( aTempArray );
+ aCurIndex = anIndex;
+ }
+
+ for( j = 0; j < aObjNum; j++ )
+ aObjectList.append( getObject( aObjects[j], aTypeList[j] ) );
+
+ return aObjectList;
+ }
+ }
+
+ return QList<GLViewer_Object*>();
+}
+
+/*!
+ \return format by index
+ \param theIndex - index
+*/
+const char* GLViewer_MimeData::format( int theIndex ) const
+{
+ switch( theIndex )
+ {
+ case 0: return "GLViewer_Objects";
+ //case 1: return "GLViewer_MarkerSet";
+ //case 2: return "GLViewer_Polyline";
+ //case 3: return "GLViewer_TextObject";
+ default: return 0;
+ }
+
+}
+
+/*!
+ \return internal byte array
+*/
+QByteArray GLViewer_MimeData::encodedData( const char* theObjectType ) const
+{
+ if( theObjectType == "GLViewer_Objects" )
+ return myByteArray;
+
+ return QByteArray();
+}
--- /dev/null
+// Copyright (C) 2005 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.
+//
+// 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.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : OPEN CASCADE
+//
+
+// File: GLViewer_MimeData.h
+// Created: November, 2004
+
+#ifndef GLVIEWER_MIMEDATA_H
+#define GLVIEWER_MIMEDATA_H
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include "GLViewer.h"
+
+#include <QMimeData>
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class GLViewer_Object;
+
+/*!
+ \class GLViewer_MimeData
+ Needs for a work with QClipboard
+*/
+class GLVIEWER_API GLViewer_MimeData: public QMimeData
+{
+public:
+ GLViewer_MimeData():QMimeData(){};
+ ~GLViewer_MimeData();
+
+ //! Translate objects to byte array
+ bool setObjects( QList<GLViewer_Object*> );
+ //! Gets objects from byte array
+ /*If you want to use new class, following two method must be redefined*/
+ static QList<GLViewer_Object*> getObjects( QByteArray, QString theType);
+ //! Get object from byte array
+ /*If you want to use new class, following two method must be redefined*/
+ static GLViewer_Object* getObject( QByteArray, QString theType);
+
+ const char* format( int theIndex = 0 ) const;
+ QByteArray encodedData( const char* ) const;
+
+private:
+ QByteArray myByteArray;
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
+#endif
+++ /dev/null
-// Copyright (C) 2005 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.
-//
-// 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.
-//
-// 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
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_MimeSource.h"
-#include "GLViewer_BaseObjects.h"
-
-//#include <cmath>
-//using namespace std;
-
-/*!
- Destructor
-*/
-GLViewer_MimeSource::~GLViewer_MimeSource()
-{
-}
-
-/*!
- Translate objects to byte array
- \param theObjects - list of objects
-*/
-bool GLViewer_MimeSource::setObjects( QValueList<GLViewer_Object*> theObjects )
-{
- if( !theObjects.empty() )
- {
- QStringList aObjectsType;
- QValueList<QByteArray> aObjects;
- QValueList<GLViewer_Object*>::const_iterator anIt = theObjects.begin();
- QValueList<GLViewer_Object*>::const_iterator anEndIt = theObjects.end();
-
- int aObjByteSize = 0;
- for( ; anIt != anEndIt; anIt++ )
- {
- aObjects.append( (*anIt)->getByteCopy() );
- aObjByteSize += aObjects.last().size();
- aObjectsType.append( (*anIt)->getObjectType() );
- }
-
- int anISize = sizeof( int );
- QString aTypes = aObjectsType.join("");
- int aStrByteSize = aTypes.length();
- int aObjNum = aObjects.count();
-
- myByteArray = QByteArray( anISize * (1 + 2*aObjNum) + aStrByteSize + aObjByteSize );
-
- int anIndex = 0, j = 0;
- char* aPointer = (char*)&aObjNum;
- for( anIndex = 0; anIndex < anISize; anIndex++, aPointer++ )
- myByteArray[anIndex] = *aPointer;
-
- QStringList::const_iterator aStrIt = aObjectsType.begin();
- QStringList::const_iterator aEndStrIt = aObjectsType.end();
- for( j = 1; aStrIt != aEndStrIt; aStrIt++, j++ )
- {
- int aStrLen = (*aStrIt).length();
- aPointer = (char*)&aStrLen;
- for( ; anIndex < anISize*( 1 + j ); anIndex++, aPointer++ )
- myByteArray[anIndex] = *aPointer;
- }
-
- int aCurIndex = anIndex;
- const char* aStr = aTypes.data();
-
- for( j = 0 ; anIndex < aCurIndex + aStrByteSize; aPointer++, anIndex++, j++ )
- myByteArray[anIndex] = aStr[j];
-
- aCurIndex = anIndex;
- QValueList<QByteArray>::iterator anObjIt = aObjects.begin();
- QValueList<QByteArray>::iterator anEndObjIt = aObjects.end();
- for( j = 1; anObjIt != anEndObjIt; anObjIt++, j++ )
- {
- int aObjLen = (int)((*anObjIt).size());
- aPointer = (char*)&aObjLen;
- for( ; anIndex < aCurIndex + anISize*j; anIndex++, aPointer++ )
- myByteArray[anIndex] = *aPointer;
- }
-
- aCurIndex = anIndex;
- anObjIt = aObjects.begin();
-
- for( ; anObjIt != anEndObjIt; anObjIt++ )
- {
- int aObjLen = (int)((*anObjIt).size());
- for( j = 0 ; anIndex < aCurIndex + aObjLen; anIndex++, aPointer++, j++ )
- myByteArray[anIndex] = (*anObjIt)[j];
- aCurIndex = anIndex;
- }
-
- return true;
- }
-
- return false;
-}
-
-/*!
- Creates object by it's representation (byte array)
- \param theArray - byte array
- \param theType - type of object
-*/
-GLViewer_Object* GLViewer_MimeSource::getObject( QByteArray theArray, QString theType )
-{
- if( !theArray.isEmpty() )
- {
- if( theType == "GLViewer_MarkerSet" )
- {
- GLViewer_MarkerSet* aObject = new GLViewer_MarkerSet( 0, (float)0.0, 0 );
- if( aObject->initializeFromByteCopy( theArray ) )
- return aObject;
- }
- else if ( theType == "GLViewer_Polyline" )
- {
- GLViewer_Polyline* aObject = new GLViewer_Polyline( 0, (float)0.0, 0 );
- if( aObject->initializeFromByteCopy( theArray ) )
- return aObject;
- }
- else if( theType == "GLViewer_TextObject" )
- {
- GLViewer_TextObject* aObject = new GLViewer_TextObject( 0, 0, 0, QColor(255,255,255), 0 );
- if( aObject->initializeFromByteCopy( theArray ) )
- return aObject;
- }
- }
-
- return NULL;
-}
-
-/*!
- Creates list of objects by its representation (byte array)
- \param theArray - byte array
- \param theType - type of object
-*/
-QValueList<GLViewer_Object*> GLViewer_MimeSource::getObjects( QByteArray theArray, QString theType )
-{
- if( !theArray.isEmpty() )
- {
- int anISize = sizeof( int );
- if( theType == "GLViewer_Objects" )
- {
- QStringList aTypeList;
- QValueList<QByteArray> aObjects;
- QValueList<GLViewer_Object*> aObjectList;
-
- QValueList<int> aTypeSizeList;
- QValueList<int> aObjSizeList;
- int aObjNum = 0;
- char* aPointer = (char*)&aObjNum;
-
- int anIndex = 0, j = 0;
- for( anIndex = 0; anIndex < anISize; anIndex++, aPointer++ )
- *aPointer = theArray[anIndex];
-
- for( j = 0; j < aObjNum; j++ )
- {
- int aTempVal = 0;
- aPointer = (char*)&aTempVal;
- for( ; anIndex < anISize*(j+2); anIndex++, aPointer++ )
- *aPointer = theArray[anIndex];
- aTypeSizeList.append( aTempVal );
- }
-
- int aCurIndex = anIndex;
- for( j = 0; j < aObjNum; j++ )
- {
- QString aTempStr;
- for( ; anIndex < aCurIndex + aTypeSizeList[j]; anIndex++ )
- {
- char aLetter = theArray[anIndex];
- aTempStr.append( aLetter );
- }
- aTypeList.append( aTempStr );
- aCurIndex = anIndex;
- }
-
- for( j = 0; j < aObjNum; j++ )
- {
- int aTempVal = 0;
- aPointer = (char*)&aTempVal;
- for( ; anIndex < aCurIndex + anISize*(j+1); anIndex++, aPointer++ )
- *aPointer = theArray[anIndex];
- aObjSizeList.append( aTempVal );
- }
-
- aCurIndex = anIndex;
- for( j = 0; j < aObjNum; j++ )
- {
- QByteArray aTempArray(aObjSizeList[j]);
- for( ; anIndex < aCurIndex + aObjSizeList[j]; anIndex++ )
- aTempArray[anIndex-aCurIndex] = theArray[anIndex];
- aObjects.append( aTempArray );
- aCurIndex = anIndex;
- }
-
- for( j = 0; j < aObjNum; j++ )
- aObjectList.append( getObject( aObjects[j], aTypeList[j] ) );
-
- return aObjectList;
- }
- }
-
- return QValueList<GLViewer_Object*>();
-}
-
-/*!
- \return format by index
- \param theIndex - index
-*/
-const char* GLViewer_MimeSource::format( int theIndex ) const
-{
- switch( theIndex )
- {
- case 0: return "GLViewer_Objects";
- //case 1: return "GLViewer_MarkerSet";
- //case 2: return "GLViewer_Polyline";
- //case 3: return "GLViewer_TextObject";
- default: return 0;
- }
-
-}
-
-/*!
- \return internal byte array
-*/
-QByteArray GLViewer_MimeSource::encodedData( const char* theObjectType ) const
-{
- if( theObjectType == "GLViewer_Objects" )
- return myByteArray;
-
- return QByteArray();
-}
+++ /dev/null
-// Copyright (C) 2005 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.
-//
-// 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.
-//
-// 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
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_MimeSource.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_MIMESOURCE_H
-#define GLVIEWER_MIMESOURCE_H
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include "GLViewer.h"
-
-#include <qmime.h>
-#include <qvaluelist.h>
-
-#ifdef WIN32
-#pragma warning( disable:4251 )
-#endif
-
-class GLViewer_Object;
-
-/*!
- \class GLViewer_MimeSource
- Needs for a work with QClipboard
-*/
-class GLVIEWER_API GLViewer_MimeSource: public QMimeSource
-{
-public:
- GLViewer_MimeSource():QMimeSource(){};
- ~GLViewer_MimeSource();
-
- //! Translate objects to byte array
- bool setObjects( QValueList<GLViewer_Object*> );
- //! Gets objects from byte array
- /*If you want to use new class, following two method must be redefined*/
- static QValueList<GLViewer_Object*> getObjects( QByteArray, QString theType);
- //! Get object from byte array
- /*If you want to use new class, following two method must be redefined*/
- static GLViewer_Object* getObject( QByteArray, QString theType);
-
- // Redefined methods
- virtual const char* format( int theIndex = 0 ) const;
- virtual QByteArray encodedData( const char* ) const;
-
-private:
- QByteArray myByteArray;
-};
-
-#ifdef WIN32
-#pragma warning ( default:4251 )
-#endif
-
-#endif
#include "GLViewer_Object.h"
#include "GLViewer_Drawer.h"
#include "GLViewer_AspectLine.h"
-#include "GLViewer_Geom.h"
#include "GLViewer_Text.h"
#include "GLViewer_Group.h"
+#include <SUIT_DataOwner.h>
+
//#include <cmath>
//using namespace std;
int i = 0;
int anISize = sizeof( int );
- const char* aTypeStr = myType.data();
- const char* aToolTipStr = myToolTipText.data();
+ const char* aTypeStr = myType.toLatin1().constData();
+ const char* aToolTipStr = myToolTipText.toLatin1().constData();
int aTypeLength = myType.length();
int aToolTipLength = myToolTipText.length();
int sizeOf8Float = sizeof( aRectData );
- QByteArray aResult( 2*anISize + sizeOf8Float +
- aTypeLength + aToolTipLength +
- aGLText.size() + aAspect.size() );
+ QByteArray aResult;
+ aResult.resize( 2*anISize + sizeOf8Float +
+ aTypeLength + aToolTipLength +
+ aGLText.size() + aAspect.size() );
// puts 8 float values into the byte array
char* aPointer = (char*)&aRectData;
for( i = 0; i < sizeOf8Float; i++, aPointer++ )
GLViewer_AspectLine* aAspectLine = new GLViewer_AspectLine();
int aGLAspLineSize = (aAspectLine->getByteCopy()).size();
- QByteArray aGLTextArray, aAspect( aGLAspLineSize );
+ QByteArray aGLTextArray, aAspect;
+ aGLTextArray.resize( aGLAspLineSize );
+ aAspect.resize( aGLAspLineSize );
if( aSize < 2*anISize + 8*aFSize + aGLTextMinSize + aGLAspLineSize )
return false;
#endif
#include "GLViewer.h"
-#include "GLViewer_Defs.h"
#include "GLViewer_Geom.h"
-#include <SUIT_DataOwner.h>
-
#include <GL/gl.h>
-#include <qfile.h>
-#include <qstring.h>
-#include <qrect.h>
+#include <QString>
+
+class QFile;
#ifdef WIN32
#pragma warning( disable:4251 )
class GLViewer_Text;
//class GLViewer_Owner;
+class SUIT_DataOwner;
+
/*!
* Class GLViewer_Object
* Base Object for all GLViewer objects
#include "GLViewer_Viewer.h"
-int GLViewer_Selector::apppendKey = Qt::ShiftButton;
+int GLViewer_Selector::apppendKey = Qt::ShiftModifier;
/*!
Constructor
#include "GLViewer.h"
#include "GLViewer_Defs.h"
-#include <qsize.h>
-#include <qobject.h>
+#include <QSize>
+#include <QObject>
+
+class QRect;
#include <Quantity_NameOfColor.hxx>
#include "GLViewer_Selector2d.h"
#include "GLViewer_Viewer2d.h"
#include "GLViewer_Context.h"
-#include "GLViewer_ViewPort2d.h"
+#include "GLViewer_ViewPort.h"
+#include "GLViewer_ViewFrame.h"
/*!
Constructor
//#include <GLViewerAfx.h>
#include "GLViewer_Text.h"
+#include <QApplication>
+#include <QFontMetrics>
+
/*!
Constructor
*/
myXPos = xPos;
myYPos = yPos;
myColor = color;
- myQFont = QFont::defaultFont();
+ myQFont = QApplication::font();//QFont::defaultFont();
mySeparator = 2;
myDTF = DTF_BITMAP;
}
int aR = myColor.red();
int aG = myColor.green();
int aB = myColor.blue();
- const char* aStr = myText.data();
+ const char* aStr = myText.toLatin1().constData();
int anISize = sizeof( int );
- QByteArray aResult( aSize );
+ QByteArray aResult;
+ aResult.resize( aSize );
char* aPointer = (char*)&myXPos;
for( i = 0; i < anISize; i++, aPointer++ )
for( ; i < 7*anISize + aTextSize; i++, aPointer++ )
aResult[i] = *aPointer;
- const char* aFontStr = myQFont.toString().data();
+ const char* aFontStr = myQFont.toString().toLatin1().constData();
int aFontSize = myQFont.toString().length();
for( i = 0; i < aFontSize; i++ )
#include <GL/gl.h>
-#include <qfont.h>
-#include <qstring.h>
-#include <qcolor.h>
-#include <qfontmetrics.h>
+#include <QFont>
+#include <QString>
+#include <QColor>
#ifdef WIN32
#pragma warning( disable:4251 )
#include "GLViewer_ToolTip.h"
#include "GLViewer_Viewer2d.h"
#include "GLViewer_ViewPort2d.h"
+#include "GLViewer_ViewFrame.h"
-#include <qlabel.h>
-#include <qtimer.h>
-#include <qbitmap.h>
-#include <qapplication.h>
-#include <qtooltip.h>
+#include <QLabel>
+#include <QTimer>
+#include <QBitmap>
+#include <QApplication>
+#include <QToolTip>
+#include <QMouseEvent>
/*!
constructor
{
mypViewPort = theParent;
//mypLabel = NULL;
- mypLabel = new QLabel( "Test", NULL, "ObjectTipText",
- WStyle_StaysOnTop | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM );
- mypLabel->setMargin( 1 );
- mypLabel->setAutoMask( FALSE );
+ mypLabel = new QLabel( "Test", NULL,
+ Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool | Qt::X11BypassWindowManagerHint );
+ mypLabel->setObjectName("ObjectTipText");
+ mypLabel->setMargin( 1 );
+ //mypLabel->setAutoMask( FALSE );
mypLabel->setFrameStyle( QFrame::Plain | QFrame::Box );
mypLabel->setLineWidth( 1 );
- mypLabel->setAlignment( AlignAuto | AlignTop );
+ mypLabel->setAlignment( Qt::AlignAbsolute | Qt::AlignTop );
mypLabel->setIndent( 0 );
- mypLabel->polish();
+ mypLabel->ensurePolished();
//mypLabel->setPalette( QToolTip::palette() );
//#include <qtooltip.h>
//#include <QtxToolTip.h>
-#include <qobject.h>
+#include <QObject>
+#include <QPoint>
#define TIP_TIME 1000
class GLViewer_ViewPort2d;
class QLabel;
+class QTimer;
/*!
\class GLViewer_ObjectTip
ToolTip of GLViewer_Objects
#endif
#include "GLViewer.h"
-#include "GLViewer_Defs.h"
-
-class GLViewer_LineField;
/*!
\class GLViewer_Tools
//#include <GLViewerAfx.h>
#include "GLViewer_ViewFrame.h"
#include "GLViewer_Viewer.h"
-#include "GLViewer_Viewer2d.h"
#include "GLViewer_ViewPort2d.h"
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_MessageBox.h>
-#include <qcolor.h>
-#include <qfiledialog.h>
-#include <qimage.h>
-#include <qlayout.h>
-#include <qstring.h>
+#include <QColor>
+#include <QFileDialog>
+#include <QImage>
+#include <QHBoxLayout>
+#include <QString>
+#include <QFrame>
+#include <QToolBar>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QWheelEvent>
/*!
Constructor
QFrame* client = new QFrame( this );
setCentralWidget( client );
- QBoxLayout* layout = new QHBoxLayout( client, 1, 1 );
- layout->setAutoAdd( true );
+ QBoxLayout* layout = new QHBoxLayout( client );
+ layout->setMargin(1);
+ layout->setSpacing(1);
GLViewer_ViewPort2d* vp = new GLViewer_ViewPort2d( client, this );
//vp->turnGrid( true );
//vp->enablePopup( false );
setViewPort( vp );
setBackgroundColor( Qt::white );
+ layout->addWidget( vp );
myToolBar = new QToolBar(this);
- myToolBar->setCloseMode(QDockWindow::Undocked);
- myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+ //myToolBar->setCloseMode(QDockWindow::Undocked);
+ myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL"));
createActions();
createToolBar();
}
{
if (!myActionsMap.isEmpty()) return;
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QAction* aAction;
+ QtxAction* aAction;
// Dump view
- aAction = new QAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
- tr( "MNU_DUMP_VIEW" ), 0, this);
+ aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
+ tr( "MNU_DUMP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump()));
myActionsMap[ DumpId ] = aAction;
// FitAll
- aAction = new QAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ),
- tr( "MNU_FITALL" ), 0, this);
+ aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ),
+ tr( "MNU_FITALL" ), 0, this);
aAction->setStatusTip(tr("DSC_FITALL"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitAll()));
myActionsMap[ FitAllId ] = aAction;
// FitRect
- aAction = new QAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ),
- tr( "MNU_FITRECT" ), 0, this);
+ aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ),
+ tr( "MNU_FITRECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITRECT"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitArea()));
myActionsMap[ FitRectId ] = aAction;
// FitSelect
- aAction = new QAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ),
- tr( "MNU_FITSELECT" ), 0, this);
+ aAction = new QtxAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ),
+ tr( "MNU_FITSELECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITSELECT"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitSelect()));
myActionsMap[ FitSelectId ] = aAction;
// Zoom
- aAction = new QAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ),
- tr( "MNU_ZOOM_VIEW" ), 0, this);
+ aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ),
+ tr( "MNU_ZOOM_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewZoom()));
myActionsMap[ ZoomId ] = aAction;
// Panning
- aAction = new QAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ),
- tr( "MNU_PAN_VIEW" ), 0, this);
+ aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ),
+ tr( "MNU_PAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PAN_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
myActionsMap[ PanId ] = aAction;
// Global Panning
- aAction = new QAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ),
- tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+ aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ),
+ tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewGlobalPan()));
myActionsMap[ GlobalPanId ] = aAction;
- aAction = new QAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ),
- tr( "MNU_RESET_VIEW" ), 0, this);
+ aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ),
+ tr( "MNU_RESET_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_RESET_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
myActionsMap[ ResetId ] = aAction;
{
if ( myVP )
return myVP->backgroundColor();
- return QMainWindow::backgroundColor();
+ return palette().color( backgroundRole() );
}
/*!
#endif
unsigned int* aPix = NULL;
- QImage anImage( width, height, 32 );
+ QImage anImage( width, height, QImage::Format_RGB32 );
for( int i = 0; i < height; i++ )
{
memset( anImage.scanLine( i ), 0, sizeof(unsigned int)*width );
QString aFilter( "*.bmp\n*.png" );
- QFileDialog aFileDlg( QDir::current().absPath(), aFilter, this );
- aFileDlg.setCaption( tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ) );
- aFileDlg.setMode( QFileDialog::AnyFile );
+ QFileDialog aFileDlg( this, tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ), QDir::current().absolutePath(), aFilter );
+ aFileDlg.setFileMode( QFileDialog::AnyFile );
if( !aFileDlg.exec() )
return;
- QString aFileName = aFileDlg.selectedFile();
+ QStringList files = aFileDlg.selectedFiles();
+ QString aFileName;
+ if ( !files.isEmpty() ) aFileName = files[0];
+
QString aFileExt = aFileDlg.selectedFilter();
if( aFileName.isEmpty() )
}
QString aSaveOp = "BMP";
- QString aTypedFileExt = QFileInfo( aFileName ).extension( false ).lower();
+ QString aTypedFileExt = QFileInfo( aFileName ).suffix().toLower();
if( aFileExt == "*.bmp" )
{
//#ifdef WIN32
// if( !anImage.save( aFileName, aSaveOp ) )
//#else
- if( !aWidget->grabFrameBuffer().save( aFileName, aSaveOp ) )
+ if( !aWidget->grabFrameBuffer().save( aFileName, aSaveOp.toLatin1().constData() ) )
//#endif
{
SUIT_MessageBox::critical( this,
*/
void GLViewer_ViewFrame::setVisualParameters( const QString& parameters )
{
- QStringList paramsLst = QStringList::split( '*', parameters, true );
+ QStringList paramsLst = parameters.split( '*' );
if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 4) {
GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP;
class GLViewer_Viewer;
class GLViewer_ViewPort;
-#include <qaction.h>
+#include <QtxAction.h>
#ifdef WIN32
#pragma warning( disable:4251 )
private:
//! Actions ID
enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId };
- typedef QMap<int, QAction*> ActionsMap;
+ typedef QMap<int, QtxAction*> ActionsMap;
private:
ActionsMap myActionsMap;
//#include <GLViewerAfx.h>
#include "GLViewer_ViewManager.h"
-#include "GLViewer_ViewFrame.h"
#include "GLViewer_Viewer2d.h"
#include "SUIT_Desktop.h"
}
/*!Context menu popup for \a popup.*/
-void GLViewer_ViewManager::contextMenuPopup( QPopupMenu* popup )
+void GLViewer_ViewManager::contextMenuPopup( QMenu* popup )
{
SUIT_ViewManager::contextMenuPopup( popup );
// if it is necessary invoke method CreatePopup of ViewPort
GLViewer_Viewer* getGLViewer() { return (GLViewer_Viewer*) myViewModel; }
- virtual void contextMenuPopup( QPopupMenu* );
+ virtual void contextMenuPopup( QMenu* );
};
#endif // GLVIEWER_VIEWMANAGER_H
#include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h"
-#include <qrect.h>
-#include <qcursor.h>
-#include <qpixmap.h>
-#include <qpainter.h>
-#include <qintdict.h>
-#include <qpopupmenu.h>
-#include <qcolordialog.h>
+#include <QRect>
+#include <QCursor>
+#include <QPainter>
+#include <QMultiHash>
+//#include <QMenu>
+#include <QColorDialog>
+#include <QColormap>
+#include <QMouseEvent>
+#include <QCoreApplication>
+#include <QX11Info>
#include <stdlib.h>
CMapEntry::~CMapEntry()
{
if ( alloc )
- XFreeColormap( QPaintDevice::x11AppDisplay(), cmap );
+ XFreeColormap( QX11Info::display(), cmap );
}
-static QIntDict<CMapEntry> *cmap_dict = 0;
+static QMultiHash<int,CMapEntry> *cmap_dict = 0;
static bool mesa_gl = false;
static void cleanup_cmaps()
{
if ( !cmap_dict )
return;
- cmap_dict->setAutoDelete( true );
+ //while (!cmap_dict->isEmpty())
+ // cmap_dict->erase(cmap_dict->begin());
+ cmap_dict->clear();
delete cmap_dict;
cmap_dict = 0;
}
{
if ( !cmap_dict )
{
- cmap_dict = new QIntDict<CMapEntry>;
+ cmap_dict = new QMultiHash<int,CMapEntry>;
const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION );
mesa_gl = strstr( v,"Mesa" ) != 0;
qAddPostRoutine( cleanup_cmaps );
}
- CMapEntry *x = cmap_dict->find( (long)vi->visualid );
- if ( x ) // found colormap for visual
- return x->cmap;
+ QHash<int,CMapEntry>::iterator itH = cmap_dict->find( (long)vi->visualid );
+ if ( itH != cmap_dict->end() ) // found colormap for visual
+ return itH.value().cmap;
- x = new CMapEntry();
+ CMapEntry x;
XStandardColormap *c;
int n, i;
cout << "Choosing cmap for vID = " << vi->visualid << endl;
#endif
- if ( vi->visualid == XVisualIDFromVisual( (Visual*)QPaintDevice::x11AppVisual() ) )
+ if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) )
{
#ifdef DEBUG
cout << "Using x11AppColormap" << endl;
#endif
- return QPaintDevice::x11AppColormap();
+ return QX11Info::appColormap();
}
if ( mesa_gl )
if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, hp_cmaps ) )
{
i = 0;
- while ( i < n && x->cmap == 0 )
+ while ( i < n && x.cmap == 0 )
{
if ( c[i].visualid == vi->visual->visualid )
{
- x->cmap = c[i].colormap;
- x->scmap = c[i];
+ x.cmap = c[i].colormap;
+ x.scmap = c[i];
}
i++;
}
}
}
#if !defined( _OS_SOLARIS_ )
- if ( !x->cmap )
+ if ( !x.cmap )
{
if ( XmuLookupStandardColormap( dpy, vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP, false, true ) )
{
if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, XA_RGB_DEFAULT_MAP ) )
{
i = 0;
- while ( i < n && x->cmap == 0 )
+ while ( i < n && x.cmap == 0 )
{
if ( c[i].visualid == vi->visualid )
{
- x->cmap = c[i].colormap;
- x->scmap = c[i];
+ x.cmap = c[i].colormap;
+ x.scmap = c[i];
}
i++;
}
}
}
#endif
- if ( !x->cmap )
+ if ( !x.cmap )
{
// no shared cmap found
- x->cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone );
- x->alloc = true;
+ x.cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone );
+ x.alloc = true;
}
cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid
- return x->cmap;
+ return x.cmap;
}
#endif
*/
void GLViewer_ViewPort::createCursors ()
{
- defCursor = new QCursor( ArrowCursor );
- panglCursor = new QCursor( CrossCursor );
- handCursor = new QCursor( PointingHandCursor );
- panCursor = new QCursor( SizeAllCursor );
+ defCursor = new QCursor( Qt::ArrowCursor );
+ panglCursor = new QCursor( Qt::CrossCursor );
+ handCursor = new QCursor( Qt::PointingHandCursor );
+ panCursor = new QCursor( Qt::SizeAllCursor );
SUIT_ResourceMgr* rmgr = SUIT_Session::session()->resourceMgr();
zoomCursor = new QCursor( rmgr->loadPixmap( "GLViewer", tr( "ICON_GL_CURSOR_ZOOM" ) ) );
Constructor
*/
GLViewer_ViewPort::GLViewer_ViewPort( QWidget* parent )
-: QWidget( parent, 0, WRepaintNoErase | WResizeNoErase )
+: QWidget( parent, 0 )
{
initialize();
}
myEnableTransform = true;
setMouseTracking( true );
- setBackgroundMode( NoBackground );
+ setBackgroundRole( QPalette::NoRole );//NoBackground );
- setFocusPolicy( StrongFocus );
+ setFocusPolicy( Qt::StrongFocus );
}
/*!
{
#if !defined WIN32
XVisualInfo* pVisualInfo;
- if ( x11Display() )
+ if ( QX11Info::display() )
{
/* Initialization with the default VisualID */
//Visual *v = DefaultVisual( x11Display(), DefaultScreen( x11Display() ) );
int visualAttr[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None };
- pVisualInfo = ::glXChooseVisual( x11Display(), DefaultScreen( x11Display() ), visualAttr );
+ pVisualInfo = ::glXChooseVisual( QX11Info::display(), DefaultScreen( QX11Info::display() ), visualAttr );
if ( isVisible() )
hide();
XSetWindowAttributes a;
- a.colormap = choose_cmap( x11Display(), pVisualInfo ); /* find best colormap */
- a.background_pixel = backgroundColor().pixel();
- a.border_pixel = black.pixel();
- Window p = RootWindow( x11Display(), DefaultScreen( x11Display() ) );
+ a.colormap = choose_cmap( QX11Info::display(), pVisualInfo ); /* find best colormap */
+ a.background_pixel = QColormap::instance().pixel( backgroundColor() );
+ a.border_pixel = QColormap::instance().pixel( Qt::black );
+ Window p = RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
if ( parentWidget() )
p = parentWidget()->winId();
if ( type == Type2D ) // creating simple X window for 2d
{
unsigned long xbackground =
- BlackPixel( x11Display(), DefaultScreen( x11Display() ) );
+ BlackPixel( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
unsigned long xforeground =
- WhitePixel( x11Display(), DefaultScreen( x11Display() ) );
+ WhitePixel( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
- w = XCreateSimpleWindow ( x11Display(), p, x(), y(), width(),
+ w = XCreateSimpleWindow ( QX11Info::display(), p, x(), y(), width(),
height(), 0, xforeground, xbackground );
}
else if ( type == Type3D )
{
- w = XCreateWindow( x11Display(), p, x(), y(), width(), height(),
+ w = XCreateWindow( QX11Info::display(), p, x(), y(), width(), height(),
0, pVisualInfo->depth, InputOutput, pVisualInfo->visual,
CWBackPixel | CWBorderPixel | CWColormap, &a );
}
Window *cmw;
Window *cmwret;
int count;
- if ( XGetWMColormapWindows( x11Display(), topLevelWidget()->winId(), &cmwret, &count ) )
+ if ( XGetWMColormapWindows( QX11Info::display(), topLevelWidget()->winId(), &cmwret, &count ) )
{
cmw = new Window[count+1];
memcpy( (char*)cmw, (char*)cmwret, sizeof(Window) * count );
/* Creating new window (with good VisualID) for this widget */
create(w);
- XSetWMColormapWindows( x11Display(), topLevelWidget()->winId(), cmw, count );
+ XSetWMColormapWindows( QX11Info::display(), topLevelWidget()->winId(), cmw, count );
delete[] cmw;
if ( isVisible() )
{
XFree( (char *)pVisualInfo );
}
- XFlush( x11Display() );
+ XFlush( QX11Info::display() );
}
#endif
}
void GLViewer_ViewPort::setBackgroundColor( const QColor& color )
{
QPalette pal = palette();
- pal.setColor( QColorGroup::Background, color );
+ pal.setColor( QPalette::Background, color );
setPalette( pal );
repaint();
}
*/
QColor GLViewer_ViewPort::backgroundColor() const
{
- return palette().active().background();
+ return palette().color( QPalette::Active, QPalette::Background );
}
/*!
#include "GLViewer.h"
-#include <qlist.h>
-#include <qcolor.h>
-#include <qaction.h>
-#include <qwidget.h>
+//#include <QList>
+#include <QColor>
+//#include <QAction>
+#include <QWidget>
-#include <Aspect_Window.hxx>
+//#include <Aspect_Window.hxx>
class QRect;
class QCursor;
#include "GLViewer_ViewPort2d.h"
#include "GLViewer_Viewer2d.h"
#include "GLViewer_ViewFrame.h"
-#include "GLViewer_MimeSource.h"
+#include "GLViewer_MimeData.h"
#include "GLViewer_Context.h"
#include "GLViewer_Compass.h"
#include "GLViewer_Grid.h"
+#include "GLViewer_Drawer.h"
#include <QtxToolTip.h>
-#include <qlayout.h>
-#include <qevent.h>
-#include <qrect.h>
-#include <qpopupmenu.h>
-#include <qtooltip.h>
-#include <qapplication.h>
-#include <qclipboard.h>
-#include <qpainter.h>
-#include <qbitmap.h>
-#include <qlabel.h>
+#include <QHBoxLayout>
+#include <QMouseEvent>
+#include <QRect>
+//#include <QMenu>
+//#include <QToolTip>
+#include <QApplication>
+#include <QClipboard>
+#include <QBitmap>
+#include <QLabel>
+#include <QWidget>
+#include <QRubberBand>
#define WIDTH 640
#define HEIGHT 480
myMargin( MARGIN ), myWidth( WIDTH ), myHeight( HEIGHT ),
myXScale( 1.0 ), myYScale( 1.0 ), myXOldScale( 1.0 ), myYOldScale( 1.0 ),
myXPan( 0.0 ), myYPan( 0.0 ),
- myIsMouseReleaseBlock( false )
+ myIsMouseReleaseBlock( false ),
+ myRectBand(0)
{
if( theViewFrame == NULL )
myViewFrame = ( GLViewer_ViewFrame* )parent;
delete myBorder;
delete myGLWidget;
+
+ if ( myRectBand ) myRectBand->hide();
+ delete myRectBand;
}
/*!
int aObjNum = aContext->NbSelected();
if( aObjNum > 0 )
{
- QValueList<GLViewer_Object*> aObjects;
- GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
+ QList<GLViewer_Object*> aObjects;
+ GLViewer_MimeData* aMimeData = new GLViewer_MimeData();
aContext->InitSelected();
for( ; aContext->MoreSelected(); aContext->NextSelected() )
aObjects.append( aContext->SelectedObject() );
- //aMimeSource->setObjects( aObjects ); ouv 6.05.04
+ //aMimeData->setObjects( aObjects ); ouv 6.05.04
QClipboard *aClipboard = QApplication::clipboard();
aClipboard->clear();
- aClipboard->setData( aMimeSource );
+ aClipboard->setMimeData( aMimeData );
for( int i = 0; i < aObjNum; i++ )
aContext->deleteObject( aObjects[i] );
int aObjNum = aContext->NbSelected();
if( aObjNum > 0 )
{
- QValueList<GLViewer_Object*> aObjects;
- GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
+ QList<GLViewer_Object*> aObjects;
+ GLViewer_MimeData* aMimeData = new GLViewer_MimeData();
aContext->InitSelected();
for( ; aContext->MoreSelected(); aContext->NextSelected() )
aObjects.append( aContext->SelectedObject() );
- //aMimeSource->setObjects( aObjects ); ouv 6.05.04
+ //aMimeData->setObjects( aObjects ); ouv 6.05.04
QClipboard *aClipboard = QApplication::clipboard();
aClipboard->clear();
- aClipboard->setData( aMimeSource );
+ aClipboard->setMimeData( aMimeData );
}
}
if( aMimeSource->provides( "GLViewer_Objects" ) )
{
QByteArray anArray = aMimeSource->encodedData( "GLViewer_Objects" );
- QValueList<GLViewer_Object*> aObjects = GLViewer_MimeSource::getObjects( anArray, "GLViewer_Objects" );
+ QList<GLViewer_Object*> aObjects = GLViewer_MimeSource::getObjects( anArray, "GLViewer_Objects" );
if( aObjects.empty() )
return;
GLViewer_Context* aContext = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext();
//QPoint aNewPos = e->pos();
//GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- if( anObject && (e->state() & LeftButton ) )
+ if( anObject && (e->buttons() & Qt::LeftButton ) )
{
if( aContext->isSelected( anObject ) )
{
else
anObject->moveObject( aX - *myCurDragPosX, anY - *myCurDragPosY);
}
- else if( aContext->NbSelected() && (e->state() & MidButton ) )
+ else if( aContext->NbSelected() && (e->buttons() & Qt::MidButton ) )
for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
(aContext->SelectedObject())->moveObject( aX - *myCurDragPosX, anY - *myCurDragPosY);
if( aContext )
anObject = aContext->getCurrentObject();
- bool accel = e->state() & GLViewer_ViewTransformer::accelKey();
+ bool accel = e->modifiers() & GLViewer_ViewTransformer::accelKey();
if( ( anObject && !( accel || e->button() == Qt::RightButton ) ) ||
( aContext->NbSelected() && !accel && e->button() == Qt::MidButton ) )
{
float dx, dy, zm;
float xScale, yScale;
- myMargin = QMAX( myBorder->width(), myBorder->height() ) / 5;
+ myMargin = qMax( myBorder->width(), myBorder->height() ) / 5;
xa = myBorder->left() - myMargin;
xb = myBorder->right() + myMargin;
mypFirstPoint = new QPoint( x, y );
mypLastPoint = new QPoint( x, y );
}
+
+ if ( !myRectBand ) {
+ myRectBand = new QRubberBand( QRubberBand::Rectangle, this );
+ QPalette palette;
+ palette.setColor(myRectBand->foregroundRole(), Qt::white);
+ myRectBand->setPalette(palette);
+ }
+ myRectBand->hide();
}
/*!
{
if( mypFirstPoint && mypLastPoint )
{
-
- QPainter p( getPaintDevice() );
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
-
- p.drawRect( selectionRect() ); /* erase */
-
- mypLastPoint->setX( x );
+ myRectBand->hide(); /* erase */
+
+ mypLastPoint->setX( x );
mypLastPoint->setY( y );
- p.drawRect( selectionRect() ); /* draw */
+ QRect aRect = selectionRect();
+ myRectBand->setGeometry( aRect ); /* draw */
+ myRectBand->setVisible( aRect.isValid() );
}
}
if( mypFirstPoint && mypLastPoint )
{
- QPainter p( getPaintDevice() );
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
- p.drawRect( selectionRect() ); /* erase */
+ if ( myRectBand ) myRectBand->hide(); /* erase */
delete mypFirstPoint;
delete mypLastPoint;
mypFirstPoint = NULL;
mypLastPoint = NULL;
+
+ delete myRectBand;
+ myRectBand = 0;
}
}
QRect aRect;
if( mypFirstPoint && mypLastPoint )
{
- aRect.setLeft( QMIN( mypFirstPoint->x(), mypLastPoint->x() ) );
- aRect.setTop( QMIN( mypFirstPoint->y(), mypLastPoint->y() ) );
- aRect.setRight( QMAX( mypFirstPoint->x(), mypLastPoint->x() ) );
- aRect.setBottom( QMAX( mypFirstPoint->y(), mypLastPoint->y() ) );
+ aRect.setLeft( qMin( mypFirstPoint->x(), mypLastPoint->x() ) );
+ aRect.setTop( qMin( mypFirstPoint->y(), mypLastPoint->y() ) );
+ aRect.setRight( qMax( mypFirstPoint->x(), mypLastPoint->x() ) );
+ aRect.setBottom( qMax( mypFirstPoint->y(), mypLastPoint->y() ) );
}
return aRect;
QStringList aList;
if( anObj->isTooTipHTML() )
- aList = QStringList::split( "<br>", theText );
+ aList = theText.split( "<br>", QString::SkipEmptyParts );
else
- aList = QStringList::split( "\n", theText );
+ aList = theText.split( "\n", QString::SkipEmptyParts );
if( !aList.isEmpty() )
{
#include "GLViewer_Widget.h"
#include "GLViewer_Geom.h"
-#include <qgl.h>
-#include <qcolor.h>
-#include <qwidget.h>
-#include <qpaintdevice.h>
+#include <QtOpenGL>
+#include <QColor>
+#include <QPaintDevice>
#ifdef WIN32
#pragma warning( disable:4251 )
class GLViewer_ViewFrame;
class QtxToolTip;
+
+class QWidget;
+class QRubberBand;
+
/*!
* Class GLViewer_ViewPort
* 2D visualisation canvas of GLViewer
QtxToolTip* myObjectTip;
//! flag to block mouse release event just after mouse double-click
bool myIsMouseReleaseBlock;
+
+ QRubberBand* myRectBand; //!< selection rectangle rubber band
};
#ifdef WIN32
#include "GLViewer_ViewPort.h"
#include "GLViewer_ViewFrame.h"
-#include "SUIT_Desktop.h"
+//#include "SUIT_Desktop.h"
#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
-#include <qapplication.h>
-#include <qpainter.h>
-#include <qpopupmenu.h>
-#include <qcolordialog.h>
+#include <QApplication>
+#include <QMenu>
+#include <QColorDialog>
+#include <QMouseEvent>
+#include <QWheelEvent>
+#include <QRect>
+#include <QRubberBand>
/* used for sketching */
static QEvent* l_mbPressEvent = 0;
/*!
Builds popup for GL viewer
*/
-void GLViewer_Viewer::contextMenuPopup( QPopupMenu* thePopup )
+void GLViewer_Viewer::contextMenuPopup( QMenu* thePopup )
{
- if( thePopup->count() > 0 )
- thePopup->insertSeparator();
+ if( thePopup->actions().count() > 0 )
+ thePopup->addSeparator();
- thePopup->insertItem( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
+ thePopup->addAction( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
}
/*!
void GLViewer_Viewer::onSelectionModeChanged()
{
bool enable = ( mySelMode == Multiple );
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
+ QVector<SUIT_ViewWindow*> views = getViewManager()->getViews();
for ( int i = 0, n = views.count(); i < n; i++ )
{
GLViewer_ViewPort* vp = ((GLViewer_ViewFrame*)views[i])->getViewPort();
*/
void GLViewer_Viewer::update( int flags )
{
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
+ QVector<SUIT_ViewWindow*> views = getViewManager()->getViews();
for ( int i = 0, n = views.count(); i < n; i++ )
((GLViewer_ViewFrame*)views[i])->onUpdate( flags );
}
void GLViewer_Viewer::handleMousePress( QMouseEvent* e )
{
/* test accel for transforms */
- if ( e->state() & GLViewer_ViewTransformer::accelKey() )
+ if ( e->modifiers() & GLViewer_ViewTransformer::accelKey() )
{
- ButtonState bs = e->button();
+ Qt::MouseButton bs = e->button();
if ( bs == GLViewer_ViewTransformer::zoomButton() )
activateTransform( Zoom );
else if ( bs == GLViewer_ViewTransformer::panButton() )
void GLViewer_Viewer::handleMouseMove( QMouseEvent* e )
{
/* Highlight for selection */
- bool dragged = ( e->state() & ( LeftButton | MidButton | RightButton ) );
+ bool dragged = ( e->buttons() & ( Qt::LeftButton | Qt::MidButton | Qt::RightButton ) );
if ( !dragged )
{
if ( getSelector() )
}
/* Try to activate default sketching
*/
- else if ( e->state() == GLViewer_ViewSketcher::sketchButton() )
+ else if ( e->button() == GLViewer_ViewSketcher::sketchButton() )
{
activateSketching( Rect );
if ( mySketcher )
{
/* selection */
/* tmp - in handleMousePress*/
- if( e->button() == LeftButton && !(getActiveView()->getViewPort()->currentBlock() & BS_Selection) )
+ if( e->button() == Qt::LeftButton && !(getActiveView()->getViewPort()->currentBlock() & BS_Selection) )
{
if ( getSelector() )
{
- bool append = bool ( e->state() & GLViewer_Selector::appendKey() );
+ bool append = bool ( e->modifiers() & GLViewer_Selector::appendKey() );
getSelector()->select( append );
}
}
int GLViewer_ViewTransformer::zoomBtn = Qt::LeftButton;
int GLViewer_ViewTransformer::fitRectBtn = Qt::LeftButton;
int GLViewer_ViewTransformer::panGlobalBtn = Qt::LeftButton;
-int GLViewer_ViewTransformer::acccelKey = Qt::ControlButton;
+int GLViewer_ViewTransformer::acccelKey = Qt::ControlModifier;
/*!
Constructor
: QObject( 0 ),
myViewer( v ),
myType( type ),
-myMajorBtn( NoButton ),
-myButtonState( 0 )
+myMajorBtn( Qt::NoButton ),
+myButtonState( 0 ),
+myRectBand( 0 )
{
if ( myType == GLViewer_Viewer::Pan ||
myType == GLViewer_Viewer::Zoom ||
}
//QAD_Application::getDesktop()->clearInfo();
+
+ endDrawRect();
}
/*!
TransformState state = EnTrain;
QMouseEvent* me = ( QMouseEvent* )e;
- myButtonState = me->state();
+ myButtonState = me->modifiers();
if ( e->type() == QEvent::MouseButtonPress )
myButtonState |= me->button(); /* add pressed button */
- int mouseOnlyState = ( myButtonState & ( LeftButton | MidButton | RightButton ) );
+ int mouseOnlyState = ( myButtonState & ( Qt::LeftButton | Qt::MidButton | Qt::RightButton ) );
if ( myStart.isNull() )
{
state = Debut;
{
if ( doTrsf )
{
- QRect rect( QMIN( myStart.x(), myCurr.x() ), QMIN( myStart.y(), myCurr.y() ),
- QABS( myStart.x() - myCurr.x() ), QABS( myStart.y() - myCurr.y() ) );
+ QRect rect( qMin( myStart.x(), myCurr.x() ), qMin( myStart.y(), myCurr.y() ),
+ qAbs( myStart.x() - myCurr.x() ), qAbs( myStart.y() - myCurr.y() ) );
if ( !rect.isEmpty() )
{
switch ( state )
break;
default:
{
- QPainter p( avp->getPaintDevice() ); // for QAD_GLWidget
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
- if ( !myDrawRect.isEmpty() )
- p.drawRect( myDrawRect ); /* erase */
- p.drawRect( rect );
- myDrawRect = rect;
+ drawRect( rect );
break;
}
}
myViewer->activateTransform( GLViewer_Viewer::NoTransform );
}
+/*!
+ Draws rectangle by starting and current points
+*/
+void GLViewer_ViewTransformer::drawRect(const QRect& theRect)
+{
+ if ( !myRectBand ) {
+ myRectBand = new QRubberBand( QRubberBand::Rectangle, myViewer->getActiveView()->getViewPort() );
+ QPalette palette;
+ palette.setColor(myRectBand->foregroundRole(), Qt::white);
+ myRectBand->setPalette(palette);
+ }
+ myRectBand->hide();
+
+ myRectBand->setGeometry( theRect );
+ myRectBand->setVisible( theRect.isValid() );
+}
+
+/*!
+ \brief Delete rubber band on the end on the dragging operation.
+*/
+void GLViewer_ViewTransformer::endDrawRect()
+{
+ if ( myRectBand ) myRectBand->hide();
+
+ delete myRectBand;
+ myRectBand = 0;
+}
+
/*!
Returns the type of the transformer. [ public ]
*/
}
-int GLViewer_ViewSketcher::sketchBtn = LeftButton;
+int GLViewer_ViewSketcher::sketchBtn = Qt::LeftButton;
/*!
Constructor
: QObject( 0 ),
myViewer( viewer ),
myData( 0 ),
-myType( type )
+myType( type ),
+myRectBand( 0 )
{
if( !myViewer )
return;
if ( myType == GLViewer_Viewer::Rect )
delete ( QRect* ) myData;
+
+ endDrawRect();
}
/*!
SketchState state = EnTrain;
QMouseEvent* me = (QMouseEvent*)e;
- myButtonState = me->state();
+ myButtonState = me->modifiers();
if ( e->type() == QEvent::MouseButtonPress )
myButtonState |= me->button(); /* add pressed button */
myStart = me->pos();
}
- int mouseOnlyState = ( myButtonState & ( LeftButton | MidButton | RightButton ) );
+ int mouseOnlyState = ( myButtonState & ( Qt::LeftButton | Qt::MidButton | Qt::RightButton ) );
if ( e->type() == QEvent::MouseButtonRelease && mouseOnlyState == sketchButton() )
{
state = Fin;
QRect* sketchRect = ( QRect* )data();
if ( myButtonState & sketchButton() )
{
- QRect rect( QMIN( myStart.x(), myCurr.x() ), QMIN( myStart.y(), myCurr.y() ),
- QABS( myStart.x() - myCurr.x() ), QABS( myStart.y() - myCurr.y() ) );
+ QRect rect( qMin( myStart.x(), myCurr.x() ), qMin( myStart.y(), myCurr.y() ),
+ qAbs( myStart.x() - myCurr.x() ), qAbs( myStart.y() - myCurr.y() ) );
if ( !rect.isEmpty() )
{
- QPainter p( avp );
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
- if ( !sketchRect->isEmpty() )
- p.drawRect( *sketchRect ); /* erase */
+ if ( !sketchRect->isEmpty() && myRectBand )
+ myRectBand->hide(); /* erase */
*sketchRect = rect;
if ( state != Fin )
- p.drawRect( *sketchRect );
+ drawRect( *sketchRect );
}
}
}
myViewer->activateSketching( GLViewer_Viewer::NoSketching );
}
}
+
+/*!
+ Draws rectangle by starting and current points
+*/
+void GLViewer_ViewSketcher::drawRect(const QRect& theRect)
+{
+ if ( !myRectBand ) {
+ myRectBand = new QRubberBand( QRubberBand::Rectangle, myViewer->getActiveView()->getViewPort() );
+ QPalette palette;
+ palette.setColor(myRectBand->foregroundRole(), Qt::white);
+ myRectBand->setPalette(palette);
+ }
+ myRectBand->hide();
+
+ myRectBand->setGeometry( theRect );
+ myRectBand->setVisible( theRect.isValid() );
+}
+
+/*!
+ \brief Delete rubber band on the end on the dragging operation.
+*/
+void GLViewer_ViewSketcher::endDrawRect()
+{
+ if ( myRectBand ) myRectBand->hide();
+
+ delete myRectBand;
+ myRectBand = 0;
+}
#ifndef GLVIEWER_VIEWER_H
#define GLVIEWER_VIEWER_H
+#include "GLViewer.h"
#include "GLViewer_Defs.h"
-#include "GLViewer_ViewFrame.h"
#include <SUIT_ViewModel.h>
-#include <qlist.h>
-#include <qcursor.h>
-#include <qobject.h>
-#include <qpixmap.h>
+#include <QCursor>
+#include <QObject>
+
+class QMouseEvent;
+class QKeyEvent;
+class QWheelEvent;
+class QRect;
+class QRubberBand;
class GLViewer_Selector;
class GLViewer_ViewSketcher;
class GLViewer_ViewTransformer;
+class GLViewer_ViewFrame;
-class SUIT_Desktop;
+//class SUIT_Desktop;
class SUIT_ViewWindow;
#ifdef WIN32
virtual QString getType() const { return Type(); }
static QString Type() { return "GLViewer_ViewModel"; }
- virtual void contextMenuPopup( QPopupMenu* );
+ virtual void contextMenuPopup( QMenu* );
public:
void setSelectionMode( SelectionMode );
virtual void onTransform( TransformState );
void initTransform( bool );
+ void drawRect(const QRect& theRect);
+ void endDrawRect();
+
protected:
static int panBtn;
static int zoomBtn;
bool mySavedMouseTrack;
QPoint myStart, myCurr;
int myButtonState;
- QRect myDrawRect;
int myMajorBtn;
+
+ QRubberBand* myRectBand; //!< selection rectangle rubber band
};
class GLVIEWER_API GLViewer_ViewSketcher : public QObject
enum SketchState { Debut, EnTrain, Fin };
virtual void onSketch( SketchState );
+ void drawRect(const QRect& theRect);
+ void endDrawRect();
+
protected:
static int sketchBtn;
GLViewer_Viewer* myViewer;
QCursor mySavedCursor;
QPoint myStart, myCurr;
int myButtonState;
+
+ QRubberBand* myRectBand; //!< selection rectangle rubber band
};
#ifdef WIN32
//#include <GLViewerAfx.h>
#include "GLViewer_Viewer2d.h"
#include "GLViewer_Object.h"
+#include "GLViewer_ViewFrame.h"
#include "GLViewer_BaseObjects.h"
#include "GLViewer_CoordSystem.h"
#include "GLViewer_Context.h"
#include "SUIT_Desktop.h"
#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
-#include "OSD_Timer.hxx"
-#include <TColStd_MapOfInteger.hxx>
-
-#include <qpopupmenu.h>
-#include <qpointarray.h>
-#include <qcolordialog.h>
+#include <QMenu>
+#include <QPolygon>
+#include <QColorDialog>
+#include <QRect>
+#include <QFile>
+#include <QMouseEvent>
/*!
Constructor
Adds item for change background color
\param thePopup - menu
*/
-void GLViewer_Viewer2d::addPopupItems( QPopupMenu* thePopup )
+void GLViewer_Viewer2d::addPopupItems( QMenu* thePopup )
{
// CTH8434. "Change background color" menu item is available if there are no selected objects
if ( getSelector() == 0 || getSelector()->numSelected() == 0 )
{
- if( thePopup->count() > 0 )
- thePopup->insertSeparator();
- thePopup->insertItem( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
+ if( thePopup->actions().count() > 0 )
+ thePopup->addSeparator();
+ thePopup->addAction( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
}
}
*/
void GLViewer_Viewer2d::updateBorders( GLViewer_Rect* theRect )
{
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
+ QVector<SUIT_ViewWindow*> views = getViewManager()->getViews();
for ( int i = 0, n = views.count(); i < n; i++ )
{
GLViewer_Rect* border = ( ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)views[i])->getViewPort() )->getBorder();
- border->setLeft( QMIN( border->left(), theRect->left() ) );
- border->setRight( QMAX( border->right(), theRect->right() ) );
- border->setBottom( QMIN( border->bottom(), theRect->bottom() ) );
- border->setTop( QMAX( border->top(), theRect->top() ) );
+ border->setLeft( qMin( border->left(), theRect->left() ) );
+ border->setRight( qMax( border->right(), theRect->right() ) );
+ border->setBottom( qMin( border->bottom(), theRect->bottom() ) );
+ border->setTop( qMax( border->top(), theRect->top() ) );
}
}
*/
void GLViewer_Viewer2d::updateBorders()
{
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
+ QVector<SUIT_ViewWindow*> views = getViewManager()->getViews();
ObjList anObjects = myGLContext->getObjects();
ObjList::Iterator beginIt = anObjects.begin();
}
else
{
- border->setLeft( QMIN( border->left(), aRect->left() ) );
- border->setRight( QMAX( border->right(), aRect->right() ) );
- border->setBottom( QMIN( border->bottom(), aRect->bottom() ) );
- border->setTop( QMAX( border->top(), aRect->top() ) );
+ border->setLeft( qMin( border->left(), aRect->left() ) );
+ border->setRight( qMax( border->right(), aRect->right() ) );
+ border->setBottom( qMin( border->bottom(), aRect->bottom() ) );
+ border->setTop( qMax( border->top(), aRect->top() ) );
}
}
}
if ( !getActiveView() )
return;
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
+ QVector<SUIT_ViewWindow*> views = getViewManager()->getViews();
for ( int i = 0, n = views.count(); i < n; i++ )
( ( GLViewer_ViewPort2d* )( ( GLViewer_ViewFrame* )views[i] )->getViewPort() )->getGLWidget()->updateGL();
}
/*!
Activates drawers for objects from list \param theObjects only
*/
-void GLViewer_Viewer2d::activateDrawers( QValueList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap )
+void GLViewer_Viewer2d::activateDrawers( QList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap )
{
//cout << "GLViewer_Viewer2d::activateDrawers " << (int)onlyUpdate << " " << (int)swap << endl;
- QValueList<GLViewer_Drawer*>::Iterator anIt = myDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator endDIt = myDrawers.end();
+ QList<GLViewer_Drawer*>::Iterator anIt = myDrawers.begin();
+ QList<GLViewer_Drawer*>::Iterator endDIt = myDrawers.end();
for( ; anIt != endDIt; anIt++ )
(*anIt)->clear();
- QValueList<GLViewer_Drawer*> anActiveDrawers;
- QValueList<GLViewer_Object*>::Iterator endOIt = theObjects.end();
+ QList<GLViewer_Drawer*> anActiveDrawers;
+ QList<GLViewer_Object*>::Iterator endOIt = theObjects.end();
- for( QValueList<GLViewer_Object*>::Iterator oit = theObjects.begin(); oit != endOIt; ++oit )
+ for( QList<GLViewer_Object*>::Iterator oit = theObjects.begin(); oit != endOIt; ++oit )
{
GLViewer_Drawer* aDrawer = (*oit)->getDrawer();
if( !aDrawer )
int aPriority = aDrawer->getPriority();
- if( anActiveDrawers.findIndex( aDrawer ) != -1 )
+ if( anActiveDrawers.indexOf( aDrawer ) != -1 )
continue;
- QValueList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
+ QList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
+ QList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
for( ; aDIt != aDEndIt; ++aDIt )
if( (*aDIt)->getPriority() > aPriority )
break;
anActiveDrawers.insert( aDIt, aDrawer );
}
- QValueList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
+ QList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
+ QList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
+ QVector<SUIT_ViewWindow*> views = getViewManager()->getViews();
for ( int i = 0, n = views.count(); i < n; i++ )
{
float xScale, yScale;
GLfloat anAngle = curvp->getGLWidget()->getRotationAngle() * PI / 180.;
- QPointArray aPointArray(4);
+ QPolygon aPointArray(4);
aPointArray[0] = QPoint( (int)(aLeft*cos(anAngle) - aTop*sin(anAngle)),
(int)(aLeft*sin(anAngle) + aTop*cos(anAngle)) );
aPointArray[1] = QPoint( (int)(aRight*cos(anAngle) - aTop*sin(anAngle)),
{
int x = aPointArray[i].x();
int y = aPointArray[i].y();
- aMinLeft = QMIN( aMinLeft,x );
- aMaxRight = QMAX( aMaxRight, x );
- aMinTop = QMIN( aMinTop, y );
- aMaxBottom = QMAX( aMaxBottom, y );
+ aMinLeft = qMin( aMinLeft,x );
+ aMaxRight = qMax( aMaxRight, x );
+ aMinTop = qMin( aMinTop, y );
+ aMaxBottom = qMax( aMaxBottom, y );
}
aLeft = (aMinLeft/* + xPan*/)*xScale + aWidth / 2;
{
if ( ( e->button() == GLViewer_View2dTransformer::rotateButton() ) &&
( e->type() == QEvent::MouseButtonPress ) &&
- ( e->state() & GLViewer_ViewTransformer::accelKey() ) )
+ ( e->modifiers() & GLViewer_ViewTransformer::accelKey() ) )
{
activateTransform( GLViewer_Viewer::Rotate );
return true;
header += "%%Pages: 1\n";
header += "%%Page: 1\n\n";
- hFile.writeBlock( header.ascii(), header.length() );
+ hFile.write( header.toAscii() );
}
else if( aType == HPGL )
{
header += "LT;\n";
header += "VS36;\n";
- hFile.writeBlock( header.ascii(), header.length() );
+ hFile.write( header.toAscii() );
}
}
if( aType == POST_SCRIPT )
{
QString ending = "showpage\n\n%%EOF";
- hFile.writeBlock( ending.ascii(), ending.length() );
+ hFile.write( ending.toAscii() );
}
else if( aType == HPGL )
{
QString ending = "PU;PA0,0;SP;EC;PG1;EC1;OE\n";
- hFile.writeBlock( ending.ascii(), ending.length() );
+ hFile.write( ending.toAscii() );
}
}
if ( !getActiveView() )
return false;
- QFile hFile( FileName.ascii() );
+ QFile hFile( FileName.toAscii() );
#ifdef WIN32
HDC hMetaFileDC;
if( aType==POST_SCRIPT || aType==HPGL )
{
- hFile.open( IO_ReadWrite | IO_Truncate );
- hFile.at( 0 );
+ hFile.open( QIODevice::ReadWrite | QIODevice::Truncate );
+ hFile.seek( 0 );
insertHeader( aType, hFile );
}
#ifdef WIN32
arg( AW-mmLeft-mmRight ).arg( AH-mmBottom-mmTop );
//It is set clipping path
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
aCurVP->getGLWidget()->translateBackgroundToPS( hFile, &aViewerCS, &aPaperCS );
}
float xScale;
float yScale;
- QValueList<GLViewer_Drawer*>::Iterator anIt = myDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator endDIt = myDrawers.end();
+ QList<GLViewer_Drawer*>::Iterator anIt = myDrawers.begin();
+ QList<GLViewer_Drawer*>::Iterator endDIt = myDrawers.end();
for( ; anIt != endDIt; anIt++ )
(*anIt)->clear();
- QValueList<GLViewer_Drawer*> anActiveDrawers;
- QValueList<GLViewer_Object*>::Iterator endOIt = anActiveObjs.end();
+ QList<GLViewer_Drawer*> anActiveDrawers;
+ QList<GLViewer_Object*>::Iterator endOIt = anActiveObjs.end();
- for( QValueList<GLViewer_Object*>::Iterator oit = anActiveObjs.begin(); oit != endOIt; ++oit )
+ for( QList<GLViewer_Object*>::Iterator oit = anActiveObjs.begin(); oit != endOIt; ++oit )
{
GLViewer_Drawer* aDrawer = (*oit)->getDrawer();
if( !aDrawer )
}
}
aDrawer->addObject( (*oit) );
- if( anActiveDrawers.findIndex( aDrawer ) == -1 )
+ if( anActiveDrawers.indexOf( aDrawer ) == -1 )
anActiveDrawers.append( aDrawer );
}
- QValueList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
+ QList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
+ QList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )aCurView->getViewPort();
vp->getScale( xScale, yScale );
vp->finishSelectByRect();
if ( getSelector() && !aSelRect.isNull() )
{
- bool append = bool ( e->state() & GLViewer_Selector::appendKey() );
+ bool append = bool ( e->modifiers() & GLViewer_Selector::appendKey() );
getSelector()->select( aSelRect, append );
}
}
}
-int GLViewer_View2dTransformer::rotateBtn = RightButton;
+int GLViewer_View2dTransformer::rotateBtn = Qt::RightButton;
/*!
Constructor
#include <windows.h>
#endif
-#include <qmap.h>
-#include <qrect.h>
+class QRect;
+class QFile;
#include "GLViewer_Viewer.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_ViewFrame.h"
-#include "GLViewer_Drawer.h"
#include <TColStd_SequenceOfInteger.hxx>
#include <GL/gl.h>
class GLViewer_Object;
+class GLViewer_ViewFrame;
+class GLViewer_Drawer;
class GLViewer_Context;
-class GLViewer_Selector2d;
+class GLViewer_Rect;
//class GLViewer_Sketcher;
class SUIT_Desktop;
virtual SUIT_ViewWindow* createView( SUIT_Desktop* );
//! Adds item for change background color
- void addPopupItems( QPopupMenu* );
+ void addPopupItems( QMenu* );
//void activateGLSketching( int );
//! Returns all drawers
- const QValueList<GLViewer_Drawer*>& getDrawers() const { return myDrawers; }
+ const QList<GLViewer_Drawer*>& getDrawers() const { return myDrawers; }
//! Returns context
GLViewer_Context* getGLContext() const { return myGLContext; }
/* \param onlyUpdate is passed to method activateAllDrawersdrawers*/
void updateDrawers( GLboolean onlyUpdate, GLfloat scX = 0.0, GLfloat scY = 0.0 );
//! Activates drawers for objects from list \param theObjects only
- void activateDrawers( QValueList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE );
+ void activateDrawers( QList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE );
//! Activates drawer for \param theObject
void activateDrawer( GLViewer_Object* theObject, bool onlyUpdate, GLboolean swap = GL_FALSE );
//! Updates all drawers with new scale factor
//! Current context
GLViewer_Context* myGLContext;
//! Map of active drawers
- QValueList<GLViewer_Drawer*> myDrawers;
+ QList<GLViewer_Drawer*> myDrawers;
//GLViewer_Sketcher* myGLSketcher;
};
#include "GLViewer_Widget.h"
#include "GLViewer_ViewPort2d.h"
#include "GLViewer_Viewer2d.h"
-#include "GLViewer_Compass.h"
+//#include "GLViewer_Compass.h"
#include "GLViewer_Grid.h"
-#include "GLViewer_Object.h"
+//#include "GLViewer_Object.h"
#include "GLViewer_CoordSystem.h"
+#include "GLViewer_ViewFrame.h"
#include <cmath>
using namespace std;
-#include <qevent.h>
-#include <qrect.h>
+#include <QEvent>
+#include <QPaintEvent>
+#include <QRect>
-#include <qpixmap.h>
-#include <qimage.h>
-#include <qapplication.h>
-#include <qintdict.h>
-#include <qpaintdevicemetrics.h>
-#include <qsize.h>
-#include <qtooltip.h>
+#include <QFile>
+//#include <qpixmap.h>
+#include <QImage>
+#include <QApplication>
+//#include <qintdict.h>
+//#include <qpaintdevicemetrics.h>
+//#include <qsize.h>
+#include <QToolTip>
/*!
A constructor
void GLViewer_Widget::addToolTip( QString theString, QRect theRect )
{
myToolTipRect = theRect;
- QToolTip::add( this, myToolTipRect, theString );
+ setToolTip(theString);
+ //QToolTip::add( this, myToolTipRect, theString );
}
/*!
*/
void GLViewer_Widget::removeToolTip()
{
- QToolTip::remove( this, myToolTipRect );
+ setToolTip("");
+ //QToolTip::remove( this, myToolTipRect );
}
/*!
updateGL();
}
+/*!
+ Custom leave event handler
+*/
+bool GLViewer_Widget::event ( QEvent* e )
+{
+ if (e->type() == QEvent::ToolTip) {
+ QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
+ if ( myToolTipRect.contains(helpEvent->pos()) )
+ QToolTip::showText(helpEvent->globalPos(), toolTip());
+ }
+ return QGLWidget::event(e);
+}
/*!
\return the hex code of digit < 16
aBuffer += "> false 3 colorimage\n\n";
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+ hFile.write( aBuffer.toAscii() );
}
}
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) );
}
}
#include "GLViewer.h"
-#include <qgl.h>
-#include <qfile.h>
+#include <QtOpenGL>
+
+class QFile;
class GLViewer_ViewPort2d;
class GLViewer_CoordSystem;
virtual void enterEvent( QEvent* );
/* Needs to redefine because Window must be updated highlight presentation when mouse leave window */
virtual void leaveEvent( QEvent* );
+
+ virtual bool event ( QEvent* );
private:
//! width of window
GLViewer_Geom.h \
GLViewer_Grid.h \
GLViewer_Group.h \
- GLViewer_MimeSource.h \
+ GLViewer_MimeData.h \
GLViewer_Object.h \
GLViewer_Selector.h \
GLViewer_Selector2d.h \
GLViewer_Geom.cxx \
GLViewer_Grid.cxx \
GLViewer_Group.cxx \
- GLViewer_MimeSource.cxx \
+ GLViewer_MimeData.cxx \
GLViewer_Object.cxx \
GLViewer_Selector.cxx \
GLViewer_Selector2d.cxx \
# VSR: this is the original packages list
# SUBDIRS += GLViewer
# VSR: already migrated to Qt4 packages
- SUBDIRS +=
+ SUBDIRS += GLViewer
endif
if ENABLE_VTKVIEWER
*/
void OCCViewer_ViewWindow::drawRect()
{
- if ( !myRectBand )
+ if ( !myRectBand ) {
myRectBand = new QRubberBand( QRubberBand::Rectangle, myViewPort );
+ QPalette palette;
+ palette.setColor(myRectBand->foregroundRole(), Qt::white);
+ myRectBand->setPalette(palette);
+ }
myRectBand->hide();
QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
SVTK_InteractorStyle
::drawRect()
{
- if ( !myRectBand )
+ if ( !myRectBand ) {
myRectBand = new QRubberBand( QRubberBand::Rectangle, GetRenderWidget() );
+ QPalette palette;
+ palette.setColor(myRectBand->foregroundRole(), Qt::white);
+ myRectBand->setPalette(palette);
+ }
myRectBand->hide();
QRect aRect(myPoint, myOtherPoint);
*/
void VTKViewer_InteractorStyle::drawRect()
{
- if ( !myRectBand )
+ if ( !myRectBand ) {
myRectBand = new QRubberBand( QRubberBand::Rectangle, myGUIWindow );
+ QPalette palette;
+ palette.setColor(myRectBand->foregroundRole(), Qt::white);
+ myRectBand->setPalette(palette);
+ }
myRectBand->hide();
QRect aRect(myPoint, myOtherPoint);
SUBDIRS += PyConsole
SUBDIRS += Prs
SUBDIRS += OBJECT
+SUBDIRS += GLViewer
SUBDIRS += VTKViewer
SUBDIRS += SVTK
SUBDIRS += OCCViewer