From 1315eaf2d7e6a45d893dd74fd598798440a6ee0a Mon Sep 17 00:00:00 2001 From: abd Date: Wed, 6 Jul 2005 11:16:34 +0000 Subject: [PATCH] Update comments --- src/GLViewer/GLViewer.h | 2 +- src/GLViewer/GLViewer_AspectLine.h | 6 +- src/GLViewer/GLViewer_BaseDrawers.h | 25 ++- src/GLViewer/GLViewer_BaseObjects.h | 140 +++++++++----- src/GLViewer/GLViewer_Drawer.cxx | 222 ++++++++++++++++------ src/GLViewer/GLViewer_Drawer.h | 193 ++++++++++++++++--- src/GLViewer/GLViewer_Geom.h | 47 +++-- src/GLViewer/GLViewer_Grid.h | 42 ++++- src/GLViewer/GLViewer_Group.h | 21 ++- src/GLViewer/GLViewer_MimeSource.h | 15 +- src/GLViewer/GLViewer_Object.h | 160 ++++++++++++++-- src/GLViewer/GLViewer_Selector.h | 13 +- src/GLViewer/GLViewer_Selector2d.h | 29 +-- src/GLViewer/GLViewer_Text.h | 24 ++- src/GLViewer/GLViewer_Tools.h | 89 ++++++--- src/GLViewer/GLViewer_ViewFrame.h | 7 +- src/GLViewer/GLViewer_ViewPort.h | 24 ++- src/GLViewer/GLViewer_ViewPort2d.h | 282 ++++++++++++++++------------ src/GLViewer/GLViewer_Viewer.h | 10 +- src/GLViewer/GLViewer_Viewer2d.cxx | 1 + src/GLViewer/GLViewer_Viewer2d.h | 234 +++++++++++++++-------- 21 files changed, 1136 insertions(+), 450 deletions(-) diff --git a/src/GLViewer/GLViewer.h b/src/GLViewer/GLViewer.h index 25d77c3be..f0e020c66 100644 --- a/src/GLViewer/GLViewer.h +++ b/src/GLViewer/GLViewer.h @@ -3,7 +3,7 @@ // Author: OCC team // Copyright (C) CEA 2004 -// Macro for exports +//! Macro for exports #ifdef WNT #ifdef GLVIEWER_EXPORTS diff --git a/src/GLViewer/GLViewer_AspectLine.h b/src/GLViewer/GLViewer_AspectLine.h index e1ea29421..7fb8b7e39 100644 --- a/src/GLViewer/GLViewer_AspectLine.h +++ b/src/GLViewer/GLViewer_AspectLine.h @@ -14,9 +14,9 @@ #pragma warning( disable:4251 ) #endif -/*! Class GLViewer_AspectLine - * Substitution of Prs2d_AspectLine for OpenGL - * +/*! + * Class GLViewer_AspectLine + * Substitution of Prs2d_AspectLine for OpenGL */ class GLVIEWER_API GLViewer_AspectLine diff --git a/src/GLViewer/GLViewer_BaseDrawers.h b/src/GLViewer/GLViewer_BaseDrawers.h index abdb1309f..43c5a98ef 100644 --- a/src/GLViewer/GLViewer_BaseDrawers.h +++ b/src/GLViewer/GLViewer_BaseDrawers.h @@ -21,8 +21,9 @@ class GLViewer_AspectLine; #pragma warning( disable:4251 ) #endif -// Class: GLViewer_MarkerDrawer -// Descr: Drawer for GLViewer_MarkerSet +/*! Class GLViewer_MarkerDrawer +* Drawer for GLViewer_MarkerSet + */ class GLVIEWER_API GLViewer_MarkerDrawer : public GLViewer_Drawer { @@ -30,26 +31,30 @@ public: GLViewer_MarkerDrawer(); ~GLViewer_MarkerDrawer(); + //! Redefined method virtual void create( float, float, bool ); private: - void drawMarker( float&, float&, float&, QColor&, GLViewer_AspectLine* ); + //! Draws marker in point (x,y) of \param radius with \param color and \param aspect + void drawMarker( float& x, float& y, float& radius, QColor& color, GLViewer_AspectLine* aspect ); }; -// Class: GLViewer_PolylineDrawer -// Descr: Drawer for GLViewer_Polyline +/*! Class GLViewer_PolylineDrawer +* Drawer for GLViewer_Polyline +*/ class GLVIEWER_API GLViewer_PolylineDrawer : public GLViewer_Drawer { public: GLViewer_PolylineDrawer(); ~GLViewer_PolylineDrawer(); - + //! Redefined method virtual void create( float, float, bool ); }; -// Class: GLViewer_TextDrawer -// Descr: +/* Class GLViewer_TextDrawer +* Drawer for GLViewer_Text +*/ class GLVIEWER_API GLViewer_TextDrawer: public GLViewer_Drawer { @@ -58,8 +63,10 @@ public: GLViewer_TextDrawer(); ~GLViewer_TextDrawer(); + //! Redefined method virtual void create( float, float, bool ); - void updateObjects(); //after update font + //! Updates objects after updating font + void updateObjects(); }; #ifdef WNT diff --git a/src/GLViewer/GLViewer_BaseObjects.h b/src/GLViewer/GLViewer_BaseObjects.h index 53604863f..fdd1f75fc 100644 --- a/src/GLViewer/GLViewer_BaseObjects.h +++ b/src/GLViewer/GLViewer_BaseObjects.h @@ -18,55 +18,74 @@ #pragma warning( disable:4251 ) #endif -// Class: GLViewer_MarkerSet -// Descr: OpenGL MarkerSet +/*! + * Class GLViewer_MarkerSet + * OpenGL MarkerSet + */ class GLVIEWER_API GLViewer_MarkerSet : public GLViewer_Object { public: + //! A constructor GLViewer_MarkerSet( int number = 1, float size = 5.0, const QString& toolTip = "GLMarker" ); + //! A destructor ~GLViewer_MarkerSet(); - - virtual void compute(); + + // redefined methods + virtual void compute(); virtual GLViewer_Drawer* createDrawer(); - virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE ); - virtual GLboolean unhighlight(); - virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE, + virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE ); + virtual GLboolean unhighlight(); + virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE, GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ); - virtual GLboolean unselect(); - - virtual GLViewer_Rect* getUpdateRect(); - - void setXCoord( GLfloat* xCoord, int size ); - void setYCoord( GLfloat* yCoord, int size ); - GLfloat* getXCoord() const { return myXCoord; } - GLfloat* getYCoord() const { return myYCoord; } - void setNumMarkers( GLint ); - GLint getNumMarkers() const { return myNumber; }; - - void setMarkerSize( const float size ) { myMarkerSize = size; } - float getMarkerSize() const { return myMarkerSize; } - - void exportNumbers( QValueList&, QValueList& , QValueList&, QValueList& ); + virtual GLboolean unselect(); - QValueList getSelectedElements() { return mySelNumbers; } - bool addOrRemoveSelected( int index ); - void addSelected( const TColStd_SequenceOfInteger& ); - void setSelected( const TColStd_SequenceOfInteger& ); + virtual GLViewer_Rect* getUpdateRect(); - virtual void moveObject( float, float, bool fromGroup = false ); + virtual void moveObject( float, float, bool fromGroup = false ); - virtual QByteArray getByteCopy(); - virtual bool initializeFromByteCopy( QByteArray ); + virtual QByteArray getByteCopy(); + virtual bool initializeFromByteCopy( QByteArray ); - virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ); - virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ); + virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ); + virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ); #ifdef WIN32 - virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ); + virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ); #endif + //! Sets array of x coords of markers + void setXCoord( GLfloat* xCoord, int size ); + //! Sets array of y coords of markers + void setYCoord( GLfloat* yCoord, int size ); + //! Returns x coords + GLfloat* getXCoord() const { return myXCoord; } + //! Returns y coords + GLfloat* getYCoord() const { return myYCoord; } + + //! Sets markers number + void setNumMarkers( GLint ); + //! returns markers number + GLint getNumMarkers() const { return myNumber; }; + //! Sets merker radius + void setMarkerSize( const float size ) { myMarkerSize = size; } + //! Returns merker radius + float getMarkerSize() const { return myMarkerSize; } + + //! Export numbers of heghlighted/selected markers + void exportNumbers( QValueList& high, QValueList& unhigh, + QValueList& sel, QValueList& unsel ); + + //! Returns selected numbers + QValueList getSelectedElements() { return mySelNumbers; } + //! Adds or remove selected number + bool addOrRemoveSelected( int index ); + //! Adds selected numbers + void addSelected( const TColStd_SequenceOfInteger& ); + //! Sets selected nembers + void setSelected( const TColStd_SequenceOfInteger& ); + protected: GLint myNumber; GLfloat* myXCoord; @@ -81,15 +100,18 @@ protected: TColStd_SequenceOfInteger mySelectedIndexes; }; -// Class: GLViewer_Polyline -// Descr: OpenGL Polyline +/*! + * Class GLViewer_Polyline + * OpenGL Polyline + */ class GLVIEWER_API GLViewer_Polyline: public GLViewer_Object { public: GLViewer_Polyline( int number = 1, float size = 5.0, const QString& toolTip = "GLPolyline" ); - ~GLViewer_Polyline(); + ~GLViewer_Polyline(); + // redefined methods virtual void compute(); virtual GLViewer_Drawer* createDrawer(); @@ -101,23 +123,6 @@ public: virtual GLViewer_Rect* getUpdateRect(); - void setXCoord( GLfloat* xCoord, int size ); - void setYCoord( GLfloat* yCoord, int size ); - GLfloat* getXCoord() const { return myXCoord; } - GLfloat* getYCoord() const { return myYCoord; } - void setNumber( GLint ); - GLint getNumber() const { return myNumber; }; - - void setClosed( GLboolean closed ) { myIsClosed = closed; } - GLboolean isClosed() const { return myIsClosed; } - - void setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; } - GLboolean isHighSelAll() const { return myHighSelAll; } - - void exportNumbers( QValueList&, QValueList& , QValueList&, QValueList& ); - - QValueList getSelectedElements() { return mySelNumbers; } - virtual void moveObject( float, float, bool fromGroup = false ); virtual QByteArray getByteCopy(); @@ -129,6 +134,37 @@ public: #ifdef WIN32 virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ); #endif + + //! Sets array of x coords of points + void setXCoord( GLfloat* xCoord, int size ); + //! Sets array of y coords of points + void setYCoord( GLfloat* yCoord, int size ); + //! Returns x coords + GLfloat* getXCoord() const { return myXCoord; } + //! Returns y coords + GLfloat* getYCoord() const { return myYCoord; } + + //! SetS number of points + void setNumber( GLint ); + //! Returns number of points + GLint getNumber() const { return myNumber; }; + + //! On/off closed status of polyline + void setClosed( GLboolean closed ) { myIsClosed = closed; } + //! Checks closed status of polyline + GLboolean isClosed() const { return myIsClosed; } + + //! On/off highlight as whole object status + void setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; } + //! Checks highlight as whole object status + GLboolean isHighSelAll() const { return myHighSelAll; } + + //! Export numbers of heghlighted/selected lines + void exportNumbers( QValueList& high, QValueList& unhigh, + QValueList& sel, QValueList& unsel ); + + //! Returns numbers of selected lines + QValueList getSelectedElements() { return mySelNumbers; } protected: GLfloat* myXCoord; diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index e983b8a08..65d0dcf1f 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -17,29 +17,44 @@ #include #include -static int FirstSymbolNumber = 32; -static int LastSymbolNumber = 127; - -QMap GLViewer_TexFont::TexFontBase; - #define TEXT_GAP 5 -GLboolean TFLoaded = GL_FALSE; +GLboolean TFLoaded = GL_FALSE; -GLdouble modelMatrix[16], projMatrix[16]; -GLint viewport[4]; -GLdouble winx, winy, winz; -GLint status; +GLdouble modelMatrix[16], projMatrix[16]; +GLint viewport[4]; +GLdouble winx, winy, winz; +GLint status; GLViewer_TexFont* staticGlFont; +//================================================================ +// Class : GLViewer_TexFont +// Description : +//================================================================ +//! code of first font symbol +static int FirstSymbolNumber = 32; +//! code of last font symbol +static int LastSymbolNumber = 127; + +QMap GLViewer_TexFont::TexFontBase; +QMap GLViewer_TexFont::BitmapFontCache; -/*************************************************************************** -** Class: GLViewer_TexFont -** Descr: Texture Font for GLViewer_Object -** Module: GLViewer -** Created: UI team, 01.10.01 -****************************************************************************/ +//======================================================================= +// Function: clearTextBases +// Purpose : +//======================================================================= +void GLViewer_TexFont::clearTextBases() +{ + //cout << "Clear font map" << endl; + TexFontBase.clear(); + BitmapFontCache.clear(); +} + +//====================================================================== +// Function: GLViewer_TexFont +// Purpose : +//======================================================================= GLViewer_TexFont::GLViewer_TexFont() { myQFont = QFont::defaultFont(); @@ -58,6 +73,10 @@ GLViewer_TexFont::GLViewer_TexFont() myTexFontHeight = 0; } +//====================================================================== +// Function: GLViewer_TexFont +// Purpose : +//======================================================================= GLViewer_TexFont::GLViewer_TexFont( QFont* theFont, int theSeparator ) { myQFont = *theFont; @@ -77,12 +96,20 @@ GLViewer_TexFont::GLViewer_TexFont( QFont* theFont, int theSeparator ) } +//====================================================================== +// Function: ~GLViewer_TexFont +// Purpose : +//======================================================================= GLViewer_TexFont::~GLViewer_TexFont() { delete[] myWidths; delete[] myPositions; -} - +} + +//====================================================================== +// Function: generateTexture +// Purpose : +//======================================================================= void GLViewer_TexFont::generateTexture() { QFontMetrics aFM( myQFont ); @@ -172,6 +199,10 @@ void GLViewer_TexFont::generateTexture() } } +//====================================================================== +// Function: drawString +// Purpose : +//======================================================================= void GLViewer_TexFont::drawString( QString theStr, GLdouble theX , GLdouble theY ) { glEnable(GL_TEXTURE_2D); @@ -211,6 +242,10 @@ void GLViewer_TexFont::drawString( QString theStr, GLdouble theX , GLdouble theY glDisable(GL_TEXTURE_2D); } +//====================================================================== +// Function: getStringWidth +// Purpose : +//======================================================================= int GLViewer_TexFont::getStringWidth( QString theStr ) { int aWidth = 0; @@ -224,25 +259,21 @@ int GLViewer_TexFont::getStringWidth( QString theStr ) return aWidth; } +//====================================================================== +// Function: getStringHeight +// Purpose : +//======================================================================= int GLViewer_TexFont::getStringHeight() { QFontMetrics aFM( myQFont ); return aFM.height(); } -void GLViewer_Drawer::destroyAllTextures() -{ - QMap::Iterator anIt= GLViewer_TexFont::TexFontBase.begin(); - QMap::Iterator anEndIt= GLViewer_TexFont::TexFontBase.end(); - - for( ; anIt != anEndIt; anIt++ ) - glDeleteTextures( 1, &(anIt.data().myTexFontId) ); -} - +//! function for generation list base for bitmap fonts static GLuint displayListBase( QFont* theFont ) { GLuint aList = 0; - static QMap fontCache; + //static QMap fontCache; GLViewer_TexFindId aFindFont; aFindFont.myFontString = theFont->toString(); @@ -253,13 +284,13 @@ static GLuint displayListBase( QFont* theFont ) aFindFont.myViewPortId = (int)ctx; - if ( fontCache.contains( aFindFont ) ) - aList = fontCache[aFindFont]; + if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) ) + aList = GLViewer_TexFont::BitmapFontCache[aFindFont]; else { GLuint listBase = 0; - QMap::iterator it = fontCache.begin(); - for ( ; it != fontCache.end(); ++it ) + QMap::iterator it = GLViewer_TexFont::BitmapFontCache.begin(); + for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it ) { if ( it.key().myViewPortId == (int)ctx && it.data() > listBase ) listBase = it.data(); @@ -271,42 +302,71 @@ static GLuint displayListBase( QFont* theFont ) if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) ) listBase = 0; aList = listBase; - fontCache[aFindFont] = aList; + GLViewer_TexFont::BitmapFontCache[aFindFont] = aList; } #else //X Window Display* aDisp = glXGetCurrentDisplay(); if( !aDisp ) { +#ifdef _DEBUG_ printf( "Can't find current dislay\n" ); +#endif return aList; } GLXContext aCont = glXGetCurrentContext(); if( !aCont ) { +#ifdef _DEBUG_ printf( "Can't find current context\n" ); +#endif return aList; } aFindFont.myViewPortId = (int)aCont; - if ( fontCache.contains( aFindFont ) ) - aList = fontCache[aFindFont]; + if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) ) + aList = GLViewer_TexFont::BitmapFontCache[aFindFont]; else { GLuint listBase = 0; - QMap::iterator it = fontCache.begin(); - for ( ; it != fontCache.end(); ++it ) + QMap::iterator it = GLViewer_TexFont::BitmapFontCache.begin(); + for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it ) { if ( it.key().myViewPortId == (int)aCont && it.data() > listBase ) listBase = it.data(); } listBase += 256; - - glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase ); - + + //glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase ); + int aFontCont = 0; + char** xFontList = XListFonts( aDisp, aFindFont.myFontString.data(), 1, &aFontCont ); + if( !theFont->handle() ) + { +#ifdef _DEBUG_ + printf( "Can't load font %s. loading default font....\n", aFindFont.myFontString.data() ); +#endif + QString aFontMask ("-*-*-*-r-*-*-"); + aFontMask += aFindFont.myFontString.section( ',', 1, 1 ); +#ifdef _DEBUG_ + printf( "Height of Default font: %s\n", aFindFont.myFontString.section( ',', 1, 1 ).data() ); +#endif + aFontMask += "-*-*-*-m-*-*-*"; + xFontList = XListFonts( aDisp, aFontMask.data()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont ); + if( aFontCont == 0 ) + { +#ifdef _DEBUG_ + printf( "Can't load default font\n" ); +#endif + return 0; + } + glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase ); + } + else + glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase ); + aList = listBase; - fontCache[aFindFont] = aList; + GLViewer_TexFont::BitmapFontCache[aFindFont] = aList; } #endif @@ -320,6 +380,10 @@ static GLuint displayListBase( QFont* theFont ) ** Module: GLViewer ** Created: UI team, 01.10.01 ****************************************************************************/ +//====================================================================== +// Function: GLViewer_Drawer +// Purpose : +//======================================================================= GLViewer_Drawer::GLViewer_Drawer() { myXScale = myYScale = 0.0; @@ -329,12 +393,32 @@ GLViewer_Drawer::GLViewer_Drawer() myPriority = 0; } +//====================================================================== +// Function: ~GLViewer_Drawer +// Purpose : +//======================================================================= GLViewer_Drawer::~GLViewer_Drawer() { myObjects.clear(); glDeleteLists( myTextList, 1 ); } +//====================================================================== +// Function: destroyAllTextures +// Purpose : +//======================================================================= +void GLViewer_Drawer::destroyAllTextures() +{ + QMap::Iterator anIt= GLViewer_TexFont::TexFontBase.begin(); + QMap::Iterator anEndIt= GLViewer_TexFont::TexFontBase.end(); + + for( ; anIt != anEndIt; anIt++ ) + glDeleteTextures( 1, &(anIt.data().myTexFontId) ); +} +//====================================================================== +// Function: loadTexture +// Purpose : +//======================================================================= GLuint GLViewer_Drawer::loadTexture( const QString& fileName ) { QImage buf; @@ -355,30 +439,28 @@ GLuint GLViewer_Drawer::loadTexture( const QString& fileName ) { for( int j = 0; j < size; j++ ) { - GLubyte r, g, b; + GLubyte r, g, b, a; if( j < w && i < h ) { QRgb pixel = buf.pixel( j, h - i - 1 ); r = (GLubyte)qRed( pixel ); g = (GLubyte)qGreen( pixel ); b = (GLubyte)qBlue( pixel ); + a = (GLubyte)qAlpha( pixel ); } else { r = (GLubyte)255; g = (GLubyte)255; b = (GLubyte)255; + a = (GLubyte)255; } int index = 4 * ( i * size + j ); pixels[ index ] = r; pixels[ index + 1 ] = g; pixels[ index + 2 ] = b; - - if( r == (GLubyte)255 && g == (GLubyte)255 && b == (GLubyte)255 ) - pixels[ index + 3 ] = (GLubyte)0; - else - pixels[ index + 3 ] = (GLubyte)255; + pixels[ index + 3 ] = a; } } @@ -396,10 +478,14 @@ GLuint GLViewer_Drawer::loadTexture( const QString& fileName ) return texture; } +//====================================================================== +// Function: drawTexture +// Purpose : +//======================================================================= void GLViewer_Drawer::drawTexture( GLuint texture, GLint size, GLfloat x, GLfloat y ) { - float xScale = myXScale; - float yScale = myYScale; + if( !texture ) + return; glColor4f( 1.0, 1.0, 1.0, 1.0 ); @@ -412,16 +498,16 @@ void GLViewer_Drawer::drawTexture( GLuint texture, GLint size, GLfloat x, GLfloa glBegin( GL_QUADS ); glTexCoord2f( 0.0, 0.0 ); - glVertex3f( x-size/2./xScale, y-size/2./yScale, 0.0 ); + glVertex3f( x-size/2., y-size/2., 0.0 ); glTexCoord2f( 0.0, 1.0 ); - glVertex3f( x-size/2./xScale, y+size/2./yScale, 0.0 ); + glVertex3f( x-size/2., y+size/2., 0.0 ); glTexCoord2f( 1.0, 1.0 ); - glVertex3f( x+size/2./xScale, y+size/2./yScale, 0.0 ); + glVertex3f( x+size/2., y+size/2., 0.0 ); glTexCoord2f( 1.0, 0.0 ); - glVertex3f( x+size/2./xScale, y-size/2./yScale, 0.0 ); + glVertex3f( x+size/2., y-size/2., 0.0 ); glEnd(); glFlush(); @@ -430,6 +516,10 @@ void GLViewer_Drawer::drawTexture( GLuint texture, GLint size, GLfloat x, GLfloa glDisable( GL_TEXTURE_2D ); } +//====================================================================== +// Function: drawText +// Purpose : +//======================================================================= void GLViewer_Drawer::drawText( const QString& text, GLfloat xPos, GLfloat yPos, const QColor& color, QFont* theFont, int theSeparator, DisplayTextFormat theFormat ) { @@ -474,6 +564,10 @@ void GLViewer_Drawer::drawText( const QString& text, GLfloat xPos, GLfloat yPos, } } +//====================================================================== +// Function: drawText +// Purpose : +//======================================================================= void GLViewer_Drawer::drawText( GLViewer_Object* theObject ) { if( !theObject ) @@ -490,6 +584,10 @@ void GLViewer_Drawer::drawText( GLViewer_Object* theObject ) drawText( aText->getText(), aPosX, aPosY, aText->getColor(), &aTmpVarFont, aText->getSeparator(), aText->getDisplayTextFormat() ); } +//====================================================================== +// Function: drawGLText +// Purpose : +//======================================================================= void GLViewer_Drawer::drawGLText( QString text, float x, float y, int hPosition, int vPosition, QColor color, bool smallFont ) { @@ -518,9 +616,13 @@ void GLViewer_Drawer::drawGLText( QString text, float x, float y, default : break; } - drawText( text, x, y, color, &aFont, 2 ); + drawText( text, x, y, color, &aFont, 2, DTF_BITMAP ); // DTF_BITMAP or DTF_TEXTURE } +//====================================================================== +// Function: drawRectangle +// Purpose : +//======================================================================= void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, QColor color ) { if( !rect ) @@ -544,6 +646,10 @@ void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, QColor color ) glEnd(); } +//====================================================================== +// Function: translateToHPGL +// Purpose : +//======================================================================= bool GLViewer_Drawer::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) { bool result = true; @@ -552,6 +658,10 @@ bool GLViewer_Drawer::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aView return result; } +//====================================================================== +// Function: translateToPS +// Purpose : +//======================================================================= bool GLViewer_Drawer::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) { bool result = true; @@ -561,6 +671,10 @@ bool GLViewer_Drawer::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewer } #ifdef WIN32 +//====================================================================== +// Function: translateToEMF +// Purpose : +//======================================================================= bool GLViewer_Drawer::translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) { bool result = true; diff --git a/src/GLViewer/GLViewer_Drawer.h b/src/GLViewer/GLViewer_Drawer.h index 644e76411..22ca4842a 100644 --- a/src/GLViewer/GLViewer_Drawer.h +++ b/src/GLViewer/GLViewer_Drawer.h @@ -3,12 +3,6 @@ // Author: OCC team // Copyright (C) CEA 2004 -/*************************************************************************** -** Class: GLViewer_Drawer -** Descr: Drawer for GLViewer_Object -** Module: GLViewer -** Created: UI team, 01.10.01 -****************************************************************************/ #ifndef GLVIEWER_DRAWER_H #define GLVIEWER_DRAWER_H @@ -34,18 +28,31 @@ class GLViewer_CoordSystem; #ifdef WNT #pragma warning( disable:4251 ) #endif - +/*! + * Struct GLViewer_TexIdStored + * Structure for store information about texture + */ struct GLVIEWER_API GLViewer_TexIdStored { + //! Texture ID GLuint myTexFontId; + //! Texture width int myTexFontWidth; + //! texture height int myTexFontHeight; }; +/*! + * Struct GLViewer_TexFindId + * Structure for srorage information about texture font + */ struct GLVIEWER_API GLViewer_TexFindId { + //! Font description QString myFontString; + //! View POrt ID int myViewPortId; + //! Overloaded operator for using struct as MAP key bool operator < (const GLViewer_TexFindId theStruct) const { if ( myViewPortId != theStruct.myViewPortId ) return myViewPortId < theStruct.myViewPortId; @@ -53,32 +60,68 @@ struct GLVIEWER_API GLViewer_TexFindId } }; +/*************************************************************************** +** Class: GLViewer_TexFont +** Descr: Font for GLViewer_Drawer +** Module: GLViewer +** Created: UI team, 03.10.01 +****************************************************************************/ + +/*! + * Class GLViewer_TexFont + * Drawing bitmap and texture fonts in GLViewer + */ class GLVIEWER_API GLViewer_TexFont { public: + //! A default constructor GLViewer_TexFont(); + //! A constructor + /* + * \param theFont - a base font + * \param theSeparator - separator between letters + */ GLViewer_TexFont( QFont* theFont, int theSeparator = 2 ); + //! A destructor ~GLViewer_TexFont(); + //! Generating font texture void generateTexture(); + //! Drawing string theStr in point with coords theX and theY void drawString( QString theStr, GLdouble theX = 0.0, GLdouble theY = 0.0 ); + //! Returns separator between letters int getSeparator(){ return mySeparator; } + //! Installing separator between letters void setSeparator( int theSeparator ){ mySeparator = theSeparator; } - int getStringWidth( QString ); + //! Returns width of string in pixels + int getStringWidth( QString theString ); + //! Returns height of string in pixels int getStringHeight(); - static QMap TexFontBase; - static int LastmyTexStoredId; + //! Clears all generated fonts + static void clearTextBases(); + + //! Map for strorage generated texture fonts + static QMap TexFontBase; + //! Map for strorage generated bitmaps fonts + static QMap BitmapFontCache; protected: + //! Array of letter width int* myWidths; + //! Array of letter positions in texture int* myPositions; + //! Pointer to base font QFont myQFont; + //! Font texture ID GLuint myTexFont; + //! Font texture width int myTexFontWidth; + //! Font texture height int myTexFontHeight; + //! Separator between letters int mySeparator; }; @@ -88,60 +131,162 @@ protected: ** Module: GLViewer ** Created: UI team, 03.10.01 ****************************************************************************/ +/*! + * Class GLViewer_Drawer + * Drawer for GLViewer_Objects. + * Drawer creates only one times per one type of object + */ class GLVIEWER_API GLViewer_Drawer { public: - enum { GLText_Center = 0, GLText_Left, GLText_Right, GLText_Top, GLText_Bottom }; + //! Text position relatively object + enum + { + GLText_Center = 0, + GLText_Left, + GLText_Right, + GLText_Top, + GLText_Bottom + }; -public: + // Objects status ( needs for change colors ) + //enum ObjectStatus + //{ + // OS_Normal = 0, + // OS_Highlighted, + // OS_Selected + //}; + + // + //enum ClosedStatus + //{ + // CS_CLOSED = 0, + // CS_OPEN = 1 + //}; + + //! A constructor GLViewer_Drawer(); + //! A destructor virtual ~GLViewer_Drawer(); - enum ObjectStatus { OS_Normal = 0, OS_Highlighted = 1, OS_Selected = 2 }; - enum ClosedStatus { CS_CLOSED = 0, CS_OPEN = 1 }; - - virtual void create( float, float, bool ) = 0; + //! Main method which drawing object in GLViewer + /* + *\param xScale - current scale along X-direction + *\param yScale - current scale along Y-direction + *\param onlyUpdate - = true if only update highlight-select information + */ + virtual void create( float xScale, float yScale, bool onlyUpdate ) = 0; + //! Adds object to drawer display list virtual void addObject( GLViewer_Object* theObject ){ myObjects.append( theObject ); } + //! Clears drawer display list virtual void clear(){ myObjects.clear(); } + //! Returns object type (needs for dynamic search of right drawer ) QString getObjectType() const { return myObjectType; } + + //! Returns object priority int getPriority() const { return myPriority; } + //! Clears all generated textures static void destroyAllTextures(); + //! A function translate object in to HPGL file on disk + /*! + *\param hFile the name of PostScript file chosen by user + *\param aViewerCS the GLViewer_CoordSystem of window + *\param aHPGLCS the GLViewer_CoordSystem of PostScript page + */ virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ); + + //! A function translate object in to PostScript file on disk + /*! + *\param hFile the name of PostScript file chosen by user + *\param aViewerCS the GLViewer_CoordSystem of window + *\param aPSCS the GLViewer_CoordSystem of PostScript page + */ virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ); #ifdef WIN32 + //! A function translate object in to EMF file on disk + /*! + *\warning WIN32 only + * + *\param dc the name of HDC associated with file chosen by user + *\param aViewerCS the GLViewer_CoordSystem of window + *\param aEMFCS the GLViewer_CoordSystem of EMF page + */ virtual bool translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ); #endif - GLuint loadTexture( const QString& fileName ); + //! Loads texture from file + static GLuint loadTexture( const QString& fileName ); + + //! Draw square texture + /*! + *\param texture - the texture ID + *\param size - the size of texture + *\param x - x coord + *\param y - y coord + */ void drawTexture( GLuint texture, GLint size, GLfloat x, GLfloat y ); + //! Draw text string + /*! + *\param text - the text string + *\param xPos - x coord + *\param yPos - y coord + *\param color - text color + *\param aFont - base font of text + *\param theSeparator - letter separator + *\param DisplayTextFormat - text format + */ void drawText( const QString& text, - GLfloat xPos, GLfloat yPos, + GLfloat xPos, + GLfloat yPos, const QColor& color, - QFont* aFont, int, + QFont* aFont, + int theSeparator, DisplayTextFormat = DTF_BITMAP ); - void drawGLText( QString text, float x, float y, - int hPosition = GLText_Center, int vPosition = GLText_Center, - QColor color = Qt::black, bool smallFont = false ); + //! Draw text string + /*! + *\param text - the text string + *\param x - x coord + *\param y - y coord + *\param hPosition - horizontal alignment + *\param vPosition - vertical alignment + *\param color - text color + *\param smallFont - font format + */ + void drawGLText( QString text, + float x, + float y, + int hPosition = GLText_Center, + int vPosition = GLText_Center, + QColor color = Qt::black, + bool smallFont = false ); - static void drawRectangle( GLViewer_Rect*, QColor = Qt::black ); + //! Draw rectangle with predefined color + static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black ); protected: - virtual void drawText( GLViewer_Object* ); + //! Draw object text + virtual void drawText( GLViewer_Object* theObject ); + //! X Scale factor float myXScale; + //! Y scale factor float myYScale; + //! List of objects QValueList myObjects; + //! List generated textures GLuint myTextList; + //! Type of supporting object QString myObjectType; + //! Dislay priority int myPriority; }; diff --git a/src/GLViewer/GLViewer_Geom.h b/src/GLViewer/GLViewer_Geom.h index cc55453bb..40a28797f 100644 --- a/src/GLViewer/GLViewer_Geom.h +++ b/src/GLViewer/GLViewer_Geom.h @@ -18,8 +18,9 @@ #pragma warning( disable:4251 ) #endif -// Class: GLViewer_Pnt -// Descr: Substitution of QPoint for OpenGL +/*! Struct GLViewer_Pnt +* Substitution of QPoint for OpenGL +*/ struct GLVIEWER_API GLViewer_Pnt { @@ -41,8 +42,9 @@ private: typedef QValueList GLViewer_PntList; -// Class: GLViewer_Rect -// Descr: Substitution of QRect for OpenGL +/*! Class GLViewer_Rect +* Substitution of QRect for OpenGL +*/ class GLVIEWER_API GLViewer_Rect { @@ -70,16 +72,22 @@ public: void setCoords( float theLeft, float theRight, float theBottom, float theTop ) { myLeft = theLeft; myRight = theRight; myBottom = theBottom; myTop = theTop; } + //! \warning This method translate only rect format QRect toQRect() { return QRect( ( int )myLeft, ( int )myBottom, ( int )( myRight - myLeft ), ( int )( myTop - myBottom ) ); } + //! On/off empty status void setIsEmpty( bool on ) { myIsEmpty = on; } + //! Checks empty status bool isEmpty() const { return myIsEmpty; } + //! Checks null status bool isNull() const { return myLeft == 0.0 && myRight == 0.0 && myBottom == 0.0 && myTop == 0.0; } + //! Checks valid status bool isValid() const { return ( myLeft < myRight && myBottom < myTop ); } + //! Checks staus of contains point bool contains( GLViewer_Pnt pnt ) { return ( pnt.x() > left() && pnt.x() < right() && pnt.y() > bottom() && @@ -94,22 +102,23 @@ protected: bool myIsEmpty; }; -// Class: GLViewer_Segment -// Descr: Segment for 2d detection +/*! Class GLViewer_Segment +* Segment for 2d detection +*/ class GLVIEWER_API GLViewer_Segment { public: GLViewer_Segment( const GLViewer_Pnt& thePnt1, const GLViewer_Pnt& thePnt2 ); - // Ordinary segment construction + + //! Ordinary segment construction + /*!Construction of a ray with given equation Ax + By + C = 0 */ GLViewer_Segment( const GLViewer_Pnt& thePnt, const GLfloat theA, const GLfloat theB, const GLfloat theC ); - // Construction of a ray with given equation Ax + By + C = 0 - ~GLViewer_Segment(); bool HasIntersection( const GLViewer_Segment& theOther ) const; @@ -123,8 +132,9 @@ private: GLfloat myC; }; -// Class: GLViewer_Poly -// Descr: Polygon for 2d detection +/*! Class GLViewer_Poly +* Polygon for 2d detection +*/ class GLVIEWER_API GLViewer_Poly { @@ -132,20 +142,21 @@ public: GLViewer_Poly( const GLViewer_PntList* thePoints ); virtual ~GLViewer_Poly(); + //! Returns number of point int Count() const { return myPoints->count(); } + //! Returns true if a point lies inside this polygon virtual bool IsIn( const GLViewer_Pnt& thePnt ) const; - //virtual bool IsIn( const GLViewer_Pnt& thePnt, const float tolerance = 0 ) const; - // Detects if a point lies inside this polygon - + + //! Returns true if a other polygon covers this polygon virtual bool IsCovers( const GLViewer_Poly& thePoly ) const; - // Detect if a other polygon covers this polygon + //! Likes the above function virtual bool IsCovers( const GLViewer_Rect& theRect ) const; - // likes the above function - + + // Returns true if intersection of this polygon with a segment or a ray not empty virtual bool HasIntersection( const GLViewer_Segment& theSegment ) const; - // Detects intersection of this polygon with a segment or a ray + private: GLViewer_PntList* myPoints; diff --git a/src/GLViewer/GLViewer_Grid.h b/src/GLViewer/GLViewer_Grid.h index 7cdd6bd22..4440802d0 100644 --- a/src/GLViewer/GLViewer_Grid.h +++ b/src/GLViewer/GLViewer_Grid.h @@ -19,33 +19,61 @@ #pragma warning( disable:4251 ) #endif +/*! Class GLViewer_Grid + 2D rectangular grid for GLViewer + Grid is adapt cells for current view +*/ + class GLVIEWER_API GLViewer_Grid { public: + //! A default constructor GLViewer_Grid(); - GLViewer_Grid( float, float, float, float, float, float, float, float, float, float ); + //! A constructor + /* + * \param width and \param height - width and height of grid + * \param winW and \param winH - width and height of window + * \param xSize and \param ySize - steps along x and y direction + * \param xPan and \param yPan - offsets along x and y direction + * \param xScale and \param yScal - scale factors along x and y direction + */ + GLViewer_Grid( GLfloat width, GLfloat height, + GLfloat winW, GLfloat winH, + GLfloat xSize, GLfloat ySize, + GLfloat xPan, GLfloat yPan, + GLfloat xScale, GLfloat yScale ); ~GLViewer_Grid(); + //! Draws grid void draw(); - void setGridColor( GLfloat, GLfloat, GLfloat ); - void setAxisColor( GLfloat, GLfloat, GLfloat ); + //! Sets color of grid in RGB format + void setGridColor( GLfloat r, GLfloat g, GLfloat b ); + //! Sets color of grid axes in RGB format + void setAxisColor( GLfloat r, GLfloat g, GLfloat b ); void setGridWidth( float ); + //! Sets Radius of center point( begin coords ) void setCenterRadius( int ); - void setSize( float, float ); - void setPan( float, float ); - bool setZoom( float ); - void setResize( float, float, float ); + //! Sets steps along x and y directions + void setSize( float xs, float ys ); + //! Sets offset along x and y direction + void setPan( float xp, float yp ); + //! Sets common scale factor along x and y direction + bool setZoom( float zoom ); + //! Recomputes grid in new size and scale of view + void setResize( float winW, float winH, float Zoom ); void getSize( float&, float& ) const; void getPan( float&, float& ) const; void getScale( float&, float& ) const; + //! Sets step of scale void setScaleFactor( int ); int getScaleFactor(); protected: + //! Initialize grid display list bool initList(); GLuint myGridList; diff --git a/src/GLViewer/GLViewer_Group.h b/src/GLViewer/GLViewer_Group.h index 0e792efe6..1384a0bae 100644 --- a/src/GLViewer/GLViewer_Group.h +++ b/src/GLViewer/GLViewer_Group.h @@ -18,12 +18,11 @@ class GLViewer_Object; typedef std::list OGList; typedef std::list::iterator OGIterator; -/*************************************************************************** -** Class: GLViewer_Group -** Descr: Group of GLViewer_Objects -** Module: GLViewer -** Created: UI team, 25.03.05 -****************************************************************************/ +/*! Class GLViewer_Group +* Group of GLViewer_Objects for synchronized moving. +* If you move one or more objects from group, than all objects from group is moved +* If group is empty, it must be deleted +*/ class GLVIEWER_API GLViewer_Group { @@ -32,20 +31,26 @@ public: ~GLViewer_Group(); bool isEmpty(); + //! Returns number ob objects int count(); - + + //! Returns index of position, else -1 int contains( GLViewer_Object* ); int addObject( GLViewer_Object* ); int removeObject( GLViewer_Object* ); OGList getObjects() const { return myList; } - //operations + //! Dragging operation + /*! Once = true, if this operation calls only one time for all object*/ void dragingObjects( float x, float y, bool once = false ); + //!\warning it is for ouv void updateZoom( GLViewer_Object* sender, float zoom ); private: + //! List of objects OGList myList; + //! This number needs for synchranization group with viewport drag methods int mySelObjNum; }; diff --git a/src/GLViewer/GLViewer_MimeSource.h b/src/GLViewer/GLViewer_MimeSource.h index 3c8a3ced9..440fc4155 100644 --- a/src/GLViewer/GLViewer_MimeSource.h +++ b/src/GLViewer/GLViewer_MimeSource.h @@ -21,8 +21,9 @@ class GLViewer_Object; -// Class: GLViewer_MimeSource -// Descr: Needs for a work with QClipboard +/*! Class GLViewer_MimeSource +* Needs for a work with QClipboard +*/ class GLVIEWER_API GLViewer_MimeSource: public QMimeSource { @@ -30,10 +31,16 @@ public: GLViewer_MimeSource():QMimeSource(){}; ~GLViewer_MimeSource(); + //! Translate objects to byte array bool setObjects( QValueList ); - static QValueList getObjects( QByteArray, QString ); - static GLViewer_Object* getObject( QByteArray, QString ); + //! Gets objects from byte array + /*If you want to use new class, following two method must be redefined*/ + static QValueList 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; diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index 6cb8f2aa8..334563466 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -26,9 +26,10 @@ #pragma warning( disable:4251 ) #endif -// Class: GLViewer_Object -// Descr: OpenGL Object - +/*! + * Class GLViewer_Object + * Base Object for GLViewer + */ class GLViewer_Drawer; class GLViewer_AspectLine; class GLViewer_Group; @@ -39,129 +40,258 @@ class GLViewer_Owner; class GLVIEWER_API GLViewer_Object { public: + //! A constructor GLViewer_Object(); + //! A destructor virtual ~GLViewer_Object(); + //! Main method. Computes all needed information about object for presentation in drawer virtual void compute() = 0; + //! Creates correspond drawer virtual GLViewer_Drawer* createDrawer() = 0; + //! Installing already exist drawer with same type virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; } + //! Returns current drawer GLViewer_Drawer* getDrawer() const { return myDrawer; } - virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE ) = 0; + //! 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 + */ + virtual GLboolean highlight( GLfloat x, + GLfloat y, + GLfloat tol, + GLboolean isCircle = GL_FALSE ) = 0; + //! Clears all highlight information virtual GLboolean unhighlight() = 0; - virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, - GLboolean isFull = GL_FALSE, GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ) = 0; + + //! Computes select presentation + /*! + *\param x - x coord + *\param y - y coord + *\param tol - tolerance of detecting + *\param rect - Non empty for rectangle selection + *\param isFull - = true if + *\param isCircle - = true if sensitive area of detection is round + *\param isShift - = true if selection exec with append option + */ + virtual GLboolean select( GLfloat x, + GLfloat y, + GLfloat tol, + GLViewer_Rect rect, + GLboolean isFull = GL_FALSE, + GLboolean isCircle = GL_FALSE, + GLboolean isShift = GL_FALSE ) = 0; + //! Clears all select information virtual GLboolean unselect() = 0; - virtual GLboolean isInside( GLViewer_Rect ); + //! Returns if theRect inside object + virtual GLboolean isInside( GLViewer_Rect theRect); + //!\warning It is for ouv virtual bool portContains( GLViewer_Pnt ) { return false; } + //!\warning It is for ouv virtual bool startPulling( GLViewer_Pnt ) { return false; } + //!\warning It is for ouv virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {} + //!\warning It is for ouv virtual void finishPulling() {} + //!\warning It is for ouv virtual bool isPulling() { return false; } + //!\warning It is for ouv virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect( myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); } + //! Installs object rectangle virtual void setRect( GLViewer_Rect* rect) { myRect = rect; } + //! Returns object rectungle virtual GLViewer_Rect* getRect() const { return myRect; } + //! Returns update object rectangle + /*! Does not equal getRect() if object have a persistence to some viewer transformations*/ virtual GLViewer_Rect* getUpdateRect() = 0; + //! Installs scale factors virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; } + //! Returns scale factors virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;} + //!\warning It is for ouv virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false ); + //!\warning It is for ouv virtual GLfloat getZoom() const { return myZoom; } + //!\warning It is for ouv virtual GLboolean updateZoom( bool zoomIn ); + //! Returns true if object is highlighted virtual GLboolean isHighlighted() const { return myIsHigh; } - virtual GLboolean isSelected() const { return myIsSel; } + //! Returns true if object is selected + virtual GLboolean isSelected() const { return myIsSel; } + //! Installs select status to object virtual void setSelected( GLboolean state ) { myIsSel = state; } + //! Installs GLText to object void setGLText( GLViewer_Text* glText ) { myGLText = glText; } + //! Returns object GLText GLViewer_Text* getGLText() const { return myGLText; } - virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; } + //! Installs acpect line for object presentation + virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; } + //! Returns acpect line of object presentation virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; } + //! Returns object type + /*! Needs for GLViewer_Drawer*/ QString getObjectType() const { return myType; } + //! Installs object name void setName( QString name ) { myName = name; } + //! Returns object name QString getName() const { return myName; } + //! Returns object priority virtual int getPriority() const; - virtual void moveObject( float, float, bool fromGroup = false ) = 0; + //! Moves object per by recomputing + /*! + *\param dx - moving along X coord + *\param dy - moving along Y coord + *\param fromGroup - = true if this method called from group + */ + virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0; + //! Finaly recomputing object after moving virtual bool finishMove() { return true; } + //! Returns visible object status bool getVisible() const { return myIsVisible; } + //! Installs visible object status virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; } + //! Installs onject tool tip text void setToolTipText( QString str ){ myToolTipText = str; } + //! Returns onject tool tip text virtual QString getToolTipText(){ return myToolTipText; } + //! Returns true if tool tip contains HTML tags bool isTooTipHTML() const { return isToolTipHTML; } + //! Installs tool tip supporting of HTML tags void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; } + //! A function for coding object to the byte copy + /*! A function is used for copy-past technollogy in copy method */ virtual QByteArray getByteCopy(); + //! A function for decoding object from the byte copy + /*! A function is used for copy-past technollogy in past method */ virtual bool initializeFromByteCopy( QByteArray ); + //! A function translate object in to PostScript file on disk + /*! + *\param hFile the name of PostScript file chosen by user + *\param aViewerCS the GLViewer_CoordSystem of window + *\param aPSCS the GLViewer_CoordSystem of PostScript page + */ virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0; + //! A function translate object in to HPGL file on disk + /*! + *\param hFile the name of PostScript file chosen by user + *\param aViewerCS the GLViewer_CoordSystem of window + *\param aHPGLCS the GLViewer_CoordSystem of PostScript page + */ virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0; #ifdef WIN32 + //! A function translate object in to EMF file on disk + /*! + *\warning WIN32 only + * + *\param dc the name of HDC associated with file chosen by user + *\param aViewerCS the GLViewer_CoordSystem of window + *\param aEMFCS the GLViewer_CoordSystem of EMF page + */ virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0; #endif - + //!\warning It is for ouv GLViewer_Owner* owner() const { return myOwner; } + //!\warning It is for ouv void setOwner( GLViewer_Owner* owner ) { myOwner = owner; } - void setGroup( GLViewer_Group* ); + //! Adds object to group theGroup + void setGroup( GLViewer_Group* theGroup ); + //! Returns object group GLViewer_Group* getGroup() const; - + + //!\warning It is for ouv virtual GLViewer_Object* getOwner() { return this; } + //! Returns true if object can be selected virtual bool isSelectable() { return true; } + //!\warning It is for ouv virtual bool isScalable() { return true; } protected: + //! Object name QString myName; + //! Object type QString myType; + //! Object base rect GLViewer_Rect* myRect; + //! Update object rect (after some viewer transformations) GLViewer_Rect* myUpdateRect; + //! Object GLText GLViewer_Text* myGLText; + //! X scale factor GLfloat myXScale; + //! Y scale factor GLfloat myYScale; + //! Gap for X direction of rect GLfloat myXGap; + //! Gap for Y direction of rect GLfloat myYGap; + //!\warning It is for ouv GLfloat myZoom; + //! Highlight status + /*! = true after right highlighting*/ GLboolean myIsHigh; + //! Selectt status + /*! = true after right selection*/ GLboolean myIsSel; + //! Object drawer GLViewer_Drawer* myDrawer; + //! Line aspect for object presentation GLViewer_AspectLine* myAspectLine; + //! Objet tool tip text QString myToolTipText; + //! HTML object tool tip status + /*! = true if tool tip text contains HTML tags */ bool isToolTipHTML; + //! Object visibke status bool myIsVisible; + //!\warning It is for ouv GLViewer_Owner* myOwner; + + //! Object Group GLViewer_Group* myGroup; }; -// Class: GLViewer_Object -// Descr: OpenGL Object +//!\warning It is for ouv class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner { public: + //!\warning It is for ouv GLViewer_Owner() : SUIT_DataOwner() {} + //!\warning It is for ouv ~GLViewer_Owner() {} protected: diff --git a/src/GLViewer/GLViewer_Selector.h b/src/GLViewer/GLViewer_Selector.h index 44963e15d..74af33e1f 100644 --- a/src/GLViewer/GLViewer_Selector.h +++ b/src/GLViewer/GLViewer_Selector.h @@ -22,6 +22,10 @@ class GLViewer_Viewer; +/*! Class GLViewer_Selector +* Based select manager for GLViewer +*/ + class GLVIEWER_API GLViewer_Selector : public QObject { Q_OBJECT @@ -31,20 +35,25 @@ public: ~GLViewer_Selector(); public: + //! Sets lock status (enable/disable interavtive) void lock( bool ); void setMinRectSize( const QSize& minSize ); - virtual void detect( int, int ) = 0; + //! Highlights in point (x,y) + virtual void detect( int x, int y ) = 0; virtual void undetectAll() = 0; + //! Selects highlight objects virtual void select( bool append = false ) = 0; + //! Selects by rect virtual void select( const QRect&, bool append = false ) = 0; virtual void unselectAll() = 0; virtual int numSelected() const = 0; virtual void setHilightColor( Quantity_NameOfColor ) = 0; virtual void setSelectColor( Quantity_NameOfColor ) = 0; - + //!Checks selection state and emits 'selSelectionDone' or 'selSelectionCancel' + /*!Should be called by after non-interactive selection. */ virtual void checkSelection( int, bool, int ) = 0; /*! Sets/returns the key for appending selected objects ( SHIFT by default ) */ diff --git a/src/GLViewer/GLViewer_Selector2d.h b/src/GLViewer/GLViewer_Selector2d.h index 86c9d8695..18df15994 100644 --- a/src/GLViewer/GLViewer_Selector2d.h +++ b/src/GLViewer/GLViewer_Selector2d.h @@ -23,6 +23,9 @@ class GLViewer_Viewer2d; class GLViewer_Context; +/*! Class GLViewer_Selector2d +* 2D select manager for GLViewer +*/ class GLVIEWER_API GLViewer_Selector2d : public GLViewer_Selector { Q_OBJECT @@ -32,24 +35,26 @@ public: ~GLViewer_Selector2d(); public: - void setContext( GLViewer_Context* glc ) { myGLContext = glc; } - GLViewer_Context* getContext() const { return myGLContext; } + //! Sets context from Viewer2d + void setContext( GLViewer_Context* glc ) { myGLContext = glc; } + GLViewer_Context* getContext() const { return myGLContext; } - void setHilightColor( Quantity_NameOfColor ); - void setSelectColor( Quantity_NameOfColor ); + // Redefined methods + virtual void setHilightColor( Quantity_NameOfColor ); + virtual void setSelectColor( Quantity_NameOfColor ); - void detect( int, int ); - void undetectAll(); + virtual void detect( int, int ); + virtual void undetectAll(); - void select( bool append = false ); - void select( const QRect&, bool append = false ); - void unselectAll(); - int numSelected() const; + virtual void select( bool append = false ); + virtual void select( const QRect&, bool append = false ); + virtual void unselectAll(); + virtual int numSelected() const; - void checkSelection( int, bool, int ); + virtual void checkSelection( int, bool, int ); protected: - GLViewer_Context* myGLContext; + GLViewer_Context* myGLContext; }; #endif diff --git a/src/GLViewer/GLViewer_Text.h b/src/GLViewer/GLViewer_Text.h index bb1995ac9..16ec3ec43 100644 --- a/src/GLViewer/GLViewer_Text.h +++ b/src/GLViewer/GLViewer_Text.h @@ -24,39 +24,57 @@ #pragma warning( disable:4251 ) #endif -// Class: GLViewer_Text -// Descr: Substitution of Prs3d_Text for OpenGL +/* Class GLViewer_Text +* Substitution of Prs3d_Text for OpenGL */ class GLVIEWER_API GLViewer_Text { public: GLViewer_Text( const QString&, float xPos = 0.0, float yPos = 0.0, const QColor& color = QColor( 0, 255, 0 ) ); - GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont, int ); + GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont theFont, int theSeparator); ~GLViewer_Text(); + //! Sets text void setText( const QString& text ) { myText = text; } + //! Returns text QString getText() const { return myText; } + //! Sets text position void setPosition( float xPos, float yPos ) { myXPos = xPos; myYPos = yPos; } + //! Returns text position void getPosition( float& xPos, float& yPos ) { xPos = myXPos; yPos = myYPos; } + //! Sets text color void setColor( const QColor& color ) { myColor = color; } + //! Returns text color QColor getColor() const { return myColor; } + //! Sets text font void setFont( const QFont theQFont) { myQFont = theQFont; } + //! Returns text font QFont getFont() const { return myQFont; } + //! Returns text separator int getSeparator(){ return mySeparator; } + //! Sets text separator void setSeparator( int theSep ){ mySeparator = theSep; } + //! Returns text width int getWidth(); + //! Returns text height int getHeight(); + //! A function for coding object to the byte copy + /*! A function is used for copy-past technollogy in copy method */ QByteArray getByteCopy() const; + //! A function for decoding object from the byte copy + /*! A function is used for copy-past technollogy in past method */ static GLViewer_Text* fromByteCopy( QByteArray ); + //! Sets text format BITMAP or TEXTURE DisplayTextFormat getDisplayTextFormat() const { return myDTF; } + //! Returns text format BITMAP or TEXTURE void setTextDisplayFormat( DisplayTextFormat theDTF ) { myDTF = theDTF; } protected: diff --git a/src/GLViewer/GLViewer_Tools.h b/src/GLViewer/GLViewer_Tools.h index 257b9ca79..9f267e767 100644 --- a/src/GLViewer/GLViewer_Tools.h +++ b/src/GLViewer/GLViewer_Tools.h @@ -1,6 +1,7 @@ // File: GLViewer_Tools.h // Created: April, 2005 // Author: OCC team +// Copyright (C) CEA 2005 #ifndef GLVIEWER_TOOLS_H #define GLVIEWER_TOOLS_H @@ -29,35 +30,41 @@ public: }; +//! Dimension of line enum FieldDim { - FD_X = 0, - FD_Y = 1 + FD_X = 0, /*along x axis*/ + FD_Y /*along y axis*/ }; -/**************************************************************************** -** Class: GLViewer_LineList -** Descr: Tools for distinct line -** Module: GLViewer -** Created: UI team, 27.10.05 -*****************************************************************************/ +/*! + Class GLViewer_LineList + Tools for distinct line + This class implmented interface for segment operations: + add, cut, remove and etc. + Memory does not changed and allocated only one time +*/ class GLViewer_LineList { public: - GLViewer_LineList( int ); - virtual ~GLViewer_LineList(); + GLViewer_LineList( int ); + virtual ~GLViewer_LineList(); + //! Returns number of segments int count() const { return mySegmentNumber; } + //! Returns real size int size() const { return myRealSize; } - + bool addSegment( double coord1, double coord2 ); bool removeSegment( int index ); bool removeSegment( double coord1, double coord2 ); - bool readSegment( int index, double&, double& ); + bool readSegment( int index, double& coord1, double& coord2 ); + //! Returns index of segment, else -1 int contains( double thePoint ) const; + //! Sets level of segments void setMainCoord( double theVal ) { myMainCoord = theVal; } double mainCoord() const { return myMainCoord; } @@ -76,6 +83,7 @@ private: double myMainCoord; }; +/*! struct GraphNode describe node in algorithm on rare grid*/ struct GraphNode { int myCount; @@ -85,6 +93,7 @@ struct GraphNode int prevNodeIndex; //feedback for searching for solution }; +/*! struct SearchPoint describe node for solving algorithm*/ struct SearchPoint { int myXLineIndex; @@ -94,21 +103,21 @@ struct SearchPoint int mySolveIndex; }; -/**************************************************************************** -** Class: GLViewer_LineField -** Descr: Tools for solving -** Module: GLViewer -** Created: UI team, 27.10.05 -*****************************************************************************/ +/*! Class GLViewer_LineField +* Tools for solving algorithm of finding shortest path on rare grid with minimum of +* line turns number +*/ class GLViewer_LineField { public: + //!Searched point enum FieldPoint { FP_Start = 0, FP_End = 1 }; + //! Status of interation enum IterationStatus { IS_ERROR = 0, @@ -117,6 +126,7 @@ public: IS_SOLVED }; + //! Final status of solving enum EndStatus { ES_ERROR = 0, @@ -128,21 +138,30 @@ public: GLViewer_LineField( const int theMAXSize, const int xn, const int yn ); virtual ~GLViewer_LineField(); - //best way, if line is already sorted + //! Adds new line + /*!best way, if line is already sorted*/ void addLine( FieldDim, GLViewer_LineList* ); + //! Calls previous void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd ); -// void addLine( FieldDim, double theMainCoord, double theBegin, double theEnd ): - int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition ); // return position - int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition ); // return position + //! Adds new line and sorted field + /*! Returns position*/ + int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition ); + //! Calls previous + int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition ); + //! Returns other dimension static FieldDim invertDim( FieldDim ); + //! Returns line by index and dimension GLViewer_LineList* getLine( int index, FieldDim ); + //! Nullifys field and sets same continued segments void setBorders( double X1, double X2, double Y1, double Y2 ); + //! Cut rectangle in grid void addRectangle( double top, double right, double bottom, double left ); + //! returns arrey of intersects indexes with \param theLL int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize ); void print(); @@ -150,28 +169,44 @@ public: void show(); int getDimSize( FieldDim ); + //! Returns number of segment int segmentNumber(); - bool setPoint( FieldPoint, double, double ); + //! Sets start/end search point + bool setPoint( FieldPoint, double x, double y ); + //! Optimize field + /*! Removes all multiple segments*/ void optimize(); - void initialize();//needs call setPoint before - EndStatus startAlgorithm();//main method + //! Some prepare actions + /*! Needs call setPoint before*/ + void initialize(); + //! Main method + EndStatus startAlgorithm(); - double* solution( int& ); + //! Returns solution and size of solution + double* solution( int& size ); protected: + //! One iteration of algorithm void iteration(); + //! Checks for complete status IterationStatus checkComplete(); + //! Finds LileList by counts and returns indexes int* findByCount( int& theParam ); - int findBySegment( FieldDim, int, int, bool inCurArray = true ); + //! Finds LileList by segment and dimension + int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true ); + //! Returns current solution array GraphNode* getCurArray(); + //! Returns GraphNode* getSecArray(); + //! Returns maximum segment number int maxSegmentNum(); + //! Returns list of LileList by dimension GLViewer_LineList** getLLArray( FieldDim ); private: diff --git a/src/GLViewer/GLViewer_ViewFrame.h b/src/GLViewer/GLViewer_ViewFrame.h index b6b5f6c58..6c7353316 100644 --- a/src/GLViewer/GLViewer_ViewFrame.h +++ b/src/GLViewer/GLViewer_ViewFrame.h @@ -28,6 +28,10 @@ class GLViewer_ViewPort; #pragma warning( disable:4251 ) #endif +/*! Class GLViewer_ViewFrame +* Frame window for viewport in GLViewer +*/ + class GLVIEWER_API GLViewer_ViewFrame: public SUIT_ViewWindow { Q_OBJECT @@ -36,7 +40,7 @@ public: GLViewer_ViewFrame( SUIT_Desktop* , GLViewer_Viewer* ); ~GLViewer_ViewFrame(); -public: +public: void setViewer( GLViewer_Viewer* ); GLViewer_Viewer* getViewer() const; @@ -90,6 +94,7 @@ private: void createToolBar(); private: + //! Actions ID enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId }; typedef QMap ActionsMap; diff --git a/src/GLViewer/GLViewer_ViewPort.h b/src/GLViewer/GLViewer_ViewPort.h index 5f9c049aa..9553fcf24 100644 --- a/src/GLViewer/GLViewer_ViewPort.h +++ b/src/GLViewer/GLViewer_ViewPort.h @@ -5,9 +5,8 @@ /*************************************************************************** ** Class: GLViewer_ViewPort -** Descr: Visualisation canvas of QAD-based application -** Module: QAD -** Created: UI team, 05.09.00 +** Descr: Visualisation canvas of GLViewer +** Created: UI team, 05.09.04 ****************************************************************************/ #ifndef GLVIEWER_VIEWPORT_H #define GLVIEWER_VIEWPORT_H @@ -39,6 +38,10 @@ enum BlockStatus BS_Dragging = 0x0004 }; +/*! + * Class GLViewer_ViewPort + * Visualisation canvas of GLViewer + */ class GLVIEWER_API GLViewer_ViewPort: public QWidget { Q_OBJECT @@ -50,18 +53,27 @@ public: ~GLViewer_ViewPort(); public: + //! Activates/deactivates sketching void setSketchingEnabled( bool ); + //! Checks active status of sketcher bool isSketchingEnabled() const; + //! Activates/deactivates transformer void setTransformEnabled( bool ); + //! Checks active status of transformer bool isTransformEnabled() const; + //! Returns background color virtual QColor backgroundColor() const; + //! Sets background color virtual void setBackgroundColor( const QColor& ); + //! Redraw external pa inters void redrawPainters(); + //! Updates view virtual void onUpdate(); + //! Returns blocking status for current started operations virtual BlockStatus currentBlock(){ return BS_NoBlock; } protected: @@ -71,7 +83,7 @@ protected: virtual QPaintDevice* getPaintDevice() { return this; } virtual void contextMenuEvent( QContextMenuEvent * e ); -// STATICS +//! STATICS static void createCursors(); static void destroyCursors(); static QCursor* getHandCursor() { return handCursor; } @@ -92,7 +104,7 @@ public://ouv static void setSketchCursor( const QCursor& newCursor ); protected: -// EVENTS +//! EVENTS virtual void paintEvent( QPaintEvent *); virtual void mouseMoveEvent( QMouseEvent *); virtual void mouseReleaseEvent( QMouseEvent *); @@ -102,7 +114,7 @@ protected: virtual void keyReleaseEvent( QKeyEvent *); virtual void wheelEvent( QWheelEvent *); -// TO BE REDEFINED +//! TO BE REDEFINED virtual void reset() = 0; virtual void pan( int, int ) = 0; virtual void setCenter( int, int ) = 0; diff --git a/src/GLViewer/GLViewer_ViewPort2d.h b/src/GLViewer/GLViewer_ViewPort2d.h index ab76e56c7..de2438663 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.h +++ b/src/GLViewer/GLViewer_ViewPort2d.h @@ -32,137 +32,189 @@ class GLViewer_Object; class GLViewer_ViewFrame; class QtxToolTip; - +/*! + * Class GLViewer_ViewPort + * 2D visualisation canvas of GLViewer + */ class GLViewer_ViewPort2d: public GLViewer_ViewPort { Q_OBJECT - enum vpDragState{ noDrag, initDrag, inDrag }; + //! Dragging states + enum vpDragState{ noDrag, initDrag, inDrag }; public: - GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL ); - ~GLViewer_ViewPort2d(); - - void turnGrid( GLboolean on ); - GLViewer_Grid* getGrid() const { return myGrid; } - void setGridColor( const QColor gridColor, const QColor axisColor ); - - GLViewer_ViewFrame* getViewFrame() const { return myViewFrame; } - GLViewer_Widget* getGLWidget() const { return myGLWidget; } - virtual QPaintDevice* getPaintDevice() { return myGLWidget; } - - void setBackgroundColor( const QColor& color); - QColor backgroundColor() const; - - void setBorder( GLViewer_Rect* border ) { myBorder = border; } - GLViewer_Rect* getBorder() const { return myBorder; } - - void setMargin( GLfloat margin ) { myMargin = margin; } - GLfloat getMargin() const { return myMargin; } - - int getHeight() const { return myHeight; } - int getWidth() const { return myWidth; } - - void getScale( GLfloat& xSc, GLfloat& ySc ) const { xSc = myXScale; ySc = myYScale; } - void getPan( GLfloat& xPan, GLfloat& yPan ) const { xPan = myXPan; yPan = myYPan; } - - void initResize( int, int ); - - void startRotation( int, int ); - void rotate( int, int ); - void endRotation(); - - bool isDragProcess(){ return myIsDragProcess; } - - void turnCompass( GLboolean on ); - void drawCompass(); - - int getViewPortId(){ return myViewPortId; } - - virtual BlockStatus currentBlock(); - - void startSelectByRect( int, int ); - void drawSelectByRect( int, int ); - void finishSelectByRect(); - - bool startPulling( GLViewer_Pnt ); - void drawPulling( GLViewer_Pnt ); - void finishPulling(); - bool isPulling() const { return myIsPulling; } - - //selection by rect - QRect selectionRect(); - - GLViewer_Rect win2GLV( const QRect& ) const; - QRect GLV2win( const GLViewer_Rect& ) const; + GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL ); + ~GLViewer_ViewPort2d(); + + //! On/off rectangular grid + void turnGrid( GLboolean on ); + //! Returns rectangular grid + GLViewer_Grid* getGrid() const { return myGrid; } + //! Returns grid color + void setGridColor( const QColor gridColor, const QColor axisColor ); + + //! Returns parent window + GLViewer_ViewFrame* getViewFrame() const { return myViewFrame; } + //! Returns painted widget + GLViewer_Widget* getGLWidget() const { return myGLWidget; } + virtual QPaintDevice* getPaintDevice() { return myGLWidget; } + + //! Sets background color + void setBackgroundColor( const QColor& color); + //! Returns background color + QColor backgroundColor() const; + + //! Sets borders of scene + void setBorder( GLViewer_Rect* border ) { myBorder = border; } + //! Get current borders of scene + GLViewer_Rect* getBorder() const { return myBorder; } + + //! Sets margin of borders + void setMargin( GLfloat margin ) { myMargin = margin; } + //! Returns margin of borders + GLfloat getMargin() const { return myMargin; } + + //! Returns width of view + int getWidth() const { return myWidth; } + //! Returns height of view + int getHeight() const { return myHeight; } + + + //! Returns scale factors + void getScale( GLfloat& xSc, GLfloat& ySc ) const { xSc = myXScale; ySc = myYScale; } + //! returns offsets + void getPan( GLfloat& xPan, GLfloat& yPan ) const { xPan = myXPan; yPan = myYPan; } + + //! Resize view + void initResize( int width, int height ); + + //! Begins rotation + void startRotation( int, int ); + //! Process rotation + void rotate( int, int ); + //! Completes rotation + void endRotation(); + + //! Checks of dragging process state + bool isDragProcess(){ return myIsDragProcess; } + + //! On/off compass + void turnCompass( GLboolean on ); + //! Draws compass + void drawCompass(); + + //! Returns unique ID of ViewPort + int getViewPortId(){ return myViewPortId; } + + //! Redefined method + virtual BlockStatus currentBlock(); + + //! Initializes before selecting by rect + void startSelectByRect( int x, int y ); + //! Draw selecting rectandle + void drawSelectByRect( int x, int y ); + //! Pass rect into selector and update + void finishSelectByRect(); + + //! \warnign It is for ouv + bool startPulling( GLViewer_Pnt ); + //! \warnign It is for ouv + void drawPulling( GLViewer_Pnt ); + //! \warnign It is for ouv + void finishPulling(); + //! \warnign It is for ouv + bool isPulling() const { return myIsPulling; } + + //! Returns selection by rect + QRect selectionRect(); + + //! Transforms window rect to global rect + GLViewer_Rect win2GLV( const QRect& ) const; + //! Transforms global rect to window rect + QRect GLV2win( const GLViewer_Rect& ) const; signals: - void vpUpdateValues(); - void objectMoved(); + //! Emits after any transformation + void vpUpdateValues(); + + void objectMoved(); protected: - void onDragObject( QMouseEvent* ); + void onDragObject( QMouseEvent* ); - virtual void mouseMoveEvent( QMouseEvent *); - virtual void mousePressEvent( QMouseEvent *); - virtual void mouseReleaseEvent( QMouseEvent *); - - virtual void paintEvent( QPaintEvent* ); - virtual void resizeEvent( QResizeEvent* ); - - virtual void reset(); - virtual void pan( int, int ); - virtual void setCenter( int, int ); - virtual void zoom( int, int, int, int ); - virtual void fitRect( const QRect& ); - virtual void fitSelect(); - virtual void fitAll( bool keepScale = false, bool withZ = true ); + virtual void mouseMoveEvent( QMouseEvent *); + virtual void mousePressEvent( QMouseEvent *); + virtual void mouseReleaseEvent( QMouseEvent *); + + virtual void paintEvent( QPaintEvent* ); + virtual void resizeEvent( QResizeEvent* ); + + //! Returns view to begin state + virtual void reset(); + //! Sets offset to view + virtual void pan( int dx, int dy ); + //! Sets view center in global coords + virtual void setCenter( int x, int y ); + //! Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 ) + virtual void zoom( int x0, int y0, int x1, int y1 ); + //! Transforms view by certangle + virtual void fitRect( const QRect& ); + //! Transforms view by selection + virtual void fitSelect(); + //! Transform view by view borders ( if \param keepScale = true, zoom does not change ) + virtual void fitAll( bool keepScale = false, bool withZ = true ); protected slots: - void onStartDragObject(); - void onPasteObject(); - void onCutObject(); - void onCopyObject(); - - void onMaybeTip( QPoint, QString&, QFont&, QRect&, QRect& ); - + //! Initializes drag process + void onStartDragObject(); + //! Pastes object from clipboard + void onPasteObject(); + //! Cuts object to clipboard + void onCutObject(); + //! Copies object to clipboard + void onCopyObject(); + + //! Sets tool tip with \param text to \param theTextReg and on \param theViewReg whan mouse is on \param thePoint + void onMaybeTip( QPoint thePoint, QString& text, QFont& font, QRect& theTextReg, QRect& theViewReg ); + protected: - GLViewer_ViewFrame* myViewFrame; - GLViewer_Widget* myGLWidget; - GLViewer_Rect* myBorder; - QColor myBackgroundColor; - - GLfloat myMargin; - int myHeight; - int myWidth; - - GLfloat myXScale; - GLfloat myYScale; - GLfloat myXOldScale; - GLfloat myYOldScale; - GLfloat myXPan; - GLfloat myYPan; - - GLViewer_Grid* myGrid; - GLViewer_Compass* myCompass; - - //dragging - int myIsDragProcess; - float* myCurDragPosX; - float* myCurDragPosY; - - //selection by rect - QPoint* mypFirstPoint; - QPoint* mypLastPoint; - - //pulling - bool myIsPulling; - GLViewer_Object* myPullingObject; + GLViewer_ViewFrame* myViewFrame; + GLViewer_Widget* myGLWidget; + GLViewer_Rect* myBorder; + QColor myBackgroundColor; + + GLfloat myMargin; + int myHeight; + int myWidth; + + GLfloat myXScale; + GLfloat myYScale; + GLfloat myXOldScale; + GLfloat myYOldScale; + GLfloat myXPan; + GLfloat myYPan; + + GLViewer_Grid* myGrid; + GLViewer_Compass* myCompass; + + //dragging + int myIsDragProcess; + float* myCurDragPosX; + float* myCurDragPosY; + + //selection by rect + QPoint* mypFirstPoint; + QPoint* mypLastPoint; + + //pulling + bool myIsPulling; + GLViewer_Object* myPullingObject; - int myViewPortId; + int myViewPortId; - //GLViewer_ObjectTip* myObjectTip; - QtxToolTip* myObjectTip; + //GLViewer_ObjectTip* myObjectTip; + QtxToolTip* myObjectTip; }; #ifdef WNT diff --git a/src/GLViewer/GLViewer_Viewer.h b/src/GLViewer/GLViewer_Viewer.h index 100276b89..ec64dc496 100644 --- a/src/GLViewer/GLViewer_Viewer.h +++ b/src/GLViewer/GLViewer_Viewer.h @@ -3,12 +3,6 @@ // Author: OCC team // Copyright (C) CEA 2004 -/*************************************************************************** -** Class: GLViewer_Viewer -** Descr: Viewer for QAD-based application -** Module: QAD -** Created: UI team, 05.09.00 -****************************************************************************/ #ifndef GLVIEWER_VIEWER_H #define GLVIEWER_VIEWER_H @@ -32,6 +26,10 @@ class SUIT_ViewWindow; #pragma warning( disable:4251 ) #endif +/*! + * Class GLViewer_Object + * Base Viewer for GLViewer + */ class GLVIEWER_API GLViewer_Viewer: public SUIT_ViewModel { Q_OBJECT diff --git a/src/GLViewer/GLViewer_Viewer2d.cxx b/src/GLViewer/GLViewer_Viewer2d.cxx index 37a746106..bbd6533e5 100644 --- a/src/GLViewer/GLViewer_Viewer2d.cxx +++ b/src/GLViewer/GLViewer_Viewer2d.cxx @@ -49,6 +49,7 @@ GLViewer_Viewer2d::~GLViewer_Viewer2d() { //myGLSketcher = 0; //delete myGLSketcher; + GLViewer_TexFont::clearTextBases(); } SUIT_ViewWindow* GLViewer_Viewer2d::createView( SUIT_Desktop* theDesktop ) diff --git a/src/GLViewer/GLViewer_Viewer2d.h b/src/GLViewer/GLViewer_Viewer2d.h index 8c787346f..289d1e141 100644 --- a/src/GLViewer/GLViewer_Viewer2d.h +++ b/src/GLViewer/GLViewer_Viewer2d.h @@ -7,7 +7,7 @@ ** Class: GLViewer_Viewer2d ** Descr: OpenGL Viewer 2D ** Module: GLViewer -** Created: UI team, 04.09.02 +** Created: UI team, 04.09.04 ****************************************************************************/ #ifndef GLVIEWER_VIEWER2D_H #define GLVIEWER_VIEWER2D_H @@ -36,6 +36,7 @@ class GLViewer_Selector2d; class SUIT_Desktop; class SUIT_ViewWindow; +//! Paper sizes array const double Sizes[2*5] = { /* A1 */ 594.0, 840.0, /* A2 */ 420.0, 594.0, @@ -48,96 +49,165 @@ const double Sizes[2*5] = { #pragma warning( disable:4251 ) #endif +/*! + * Class GLViewer_Object + * 2D viewer for GLViewer + */ class GLVIEWER_API GLViewer_Viewer2d : public GLViewer_Viewer { - Q_OBJECT + Q_OBJECT public: - enum GLSketchingType { None, Polyline, Arc, Curve, Scribble, Oval, Rectangle }; - enum VectorFileType { POST_SCRIPT, HPGL + //! Type of sketcher operation + enum GLSketchingType + { + None, + Polyline, + Arc, + Curve, + Scribble, + Oval, + Rectangle + }; + //! Type of export vector file + enum VectorFileType + { + POST_SCRIPT, + HPGL #ifdef WIN32 - , ENH_METAFILE + , ENH_METAFILE #endif - }; - - enum PaperType { A1=0, A2, A3, A4, A5 }; + }; + + //! Type of paper for export to vector format + enum PaperType + { + A1=0, + A2, + A3, + A4, + A5 + }; public: - GLViewer_Viewer2d( const QString& title ); - ~GLViewer_Viewer2d(); + //! A constructor + GLViewer_Viewer2d( const QString& title ); + //! A destructor + ~GLViewer_Viewer2d(); public: - SUIT_ViewWindow* createView( SUIT_Desktop* ); - - void addPopupItems( QPopupMenu* ); - - //void activateGLSketching( int ); - - const QValueList& getDrawers() const { return myDrawers; } - - GLViewer_Context* getGLContext() const { return myGLContext; } - void updateColors( QColor colorH, QColor colorS ); - void updateBorders( GLViewer_Rect* theRect ); - void updateBorders(); - - void updateAll(); - void updateDrawers( GLboolean update, GLfloat scX = 0.0, GLfloat scY = 0.0 ); - void activateDrawers( QValueList& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE ); - void activateDrawer( GLViewer_Object*, bool onlyUpdate, GLboolean swap = GL_FALSE ); - void activateAllDrawers( bool onlyUpdate, GLboolean swap = GL_FALSE ); - - void transPoint( GLfloat& x, GLfloat& y ); - QRect* getWinObjectRect( GLViewer_Object* ); - - - GLViewer_Rect getGLVRect( const QRect& ) const; - QRect getQRect( const GLViewer_Rect& ) const; - - virtual void insertHeader( VectorFileType aType, QFile& hFile ); - virtual void insertEnding( VectorFileType aType, QFile& hFile ); - virtual bool translateTo( VectorFileType aType, QString FileName, PaperType aPType, - double mmLeft, double mmRight, double mmTop, double mmBottom ); + //! Redefined method + /*Returns GLViewer_ViewFrame*/ + virtual SUIT_ViewWindow* createView( SUIT_Desktop* ); + + //! Adds item for change background color + void addPopupItems( QPopupMenu* ); + + //void activateGLSketching( int ); + + //! Returns all drawers + const QValueList& getDrawers() const { return myDrawers; } + + //! Returns context + GLViewer_Context* getGLContext() const { return myGLContext; } + //! Updates colors for all drawers (does not work) + void updateColors( QColor colorH, QColor colorS ); + + //! Updates rect of global scene by adding new rect + void updateBorders( GLViewer_Rect* theRect ); + //! Recomputes global scene rect + void updateBorders(); + + //! Redraws all active objects by updating all drawers in all views + void updateAll(); + //! Updates all drawers with new scale factor + /* \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& 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 + /* \param onlyUpdate is passed to drawers*/ + void activateAllDrawers( bool onlyUpdate, GLboolean swap = GL_FALSE ); + + //! Translates point (x,y) from global CS to curreent viewer CS + void transPoint( GLfloat& x, GLfloat& y ); + //! Returns object rect in window CS + QRect* getWinObjectRect( GLViewer_Object* theObject); + + //! Translates rect in window CS to rect in global CS + GLViewer_Rect getGLVRect( const QRect& ) const; + //! Translates rect in global CS to rect in window CS + QRect getQRect( const GLViewer_Rect& ) const; + + //! Inserts common text lines starting file of \param aType + virtual void insertHeader( VectorFileType aType, QFile& hFile ); + //! Inserts common text lines ending file of \param aType + virtual void insertEnding( VectorFileType aType, QFile& hFile ); + //! Translates current view content to vector file + /* Translates current view content to vector file with type \param aType, name \param FileName, + * output paper size \param aPType, with margins in mm + */ + virtual bool translateTo( VectorFileType aType, QString FileName, PaperType aPType, + double mmLeft, double mmRight, double mmTop, double mmBottom ); - //bool isSketchingActive(); - //int getSketchingType(); + //bool isSketchingActive(); + //int getSketchingType(); + + //virtual void startSketching(); + //virtual void finishSketching(); - //virtual void startSketching(); - //virtual void finishSketching(); - - void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false ); + //! Repaints view \param theView. If \param theView = NULL repaints all views. + void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false ); public slots: - //void onSketchDelObject(); - //void onSketchUndoLast(); - //void onSketchFinish(); - void onChangeBgColor(); - void onCreateGLMarkers( int = 1000, int = 5 ); - void onCreateGLPolyline( int = 100, int = 10, int = 100 ); - void onCreateGLText( QString = "Text", int = 1 ); + //void onSketchDelObject(); + //void onSketchUndoLast(); + //void onSketchFinish(); + + //! Changes background color + void onChangeBgColor(); + //! Creates set of marker number \param number and radius = \param size + void onCreateGLMarkers( int number = 1000, int size = 5 ); + //! Creates set of polyline number \param number, number of angles = \param angles and diameter = \param size + void onCreateGLPolyline( int number = 100, int angles = 10, int size = 100 ); + //! Creates set of text number \param number and with text = \param text + void onCreateGLText( QString text = "Text", int number = 1 ); protected: - GLViewer_Selector* createSelector(); - GLViewer_ViewTransformer* createTransformer( int ); - - void transformCoordsToPS( double& x, double& y ); - void transformCoordsToHPGL( double& x, double& y ); - - virtual void startOperations( QMouseEvent* ); - virtual bool updateOperations( QMouseEvent* ); - virtual void finishOperations( QMouseEvent* ); - virtual void startOperations( QWheelEvent* ); + //! Returns new selector + GLViewer_Selector* createSelector(); + //! Returns new Transformer with type \param type + GLViewer_ViewTransformer* createTransformer( int type); + + //! Transforms point (x,y) in Viewer CS to Post Script CS + void transformCoordsToPS( double& x, double& y ); + //! Transforms point (x,y) in Viewer CS to HPGL CS + void transformCoordsToHPGL( double& x, double& y ); + + //! Starts any operations on mouse event + virtual void startOperations( QMouseEvent* ); + //! Updates started operations on mouse event + virtual bool updateOperations( QMouseEvent* ); + //! Completes started operations on mouse event + virtual void finishOperations( QMouseEvent* ); + //! Starts any operations on mouse wheel event + virtual void startOperations( QWheelEvent* ); protected slots: - void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* ); + void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* ); private: - bool testRotation( QMouseEvent* ); - -protected: - GLViewer_Context* myGLContext; - QValueList myDrawers; - - //GLViewer_Sketcher* myGLSketcher; + //! Rotation transformation + bool testRotation( QMouseEvent* ); +protected: + //! Current context + GLViewer_Context* myGLContext; + //! Map of active drawers + QValueList myDrawers; + + //GLViewer_Sketcher* myGLSketcher; }; /**************************************************************** @@ -147,21 +217,19 @@ protected: class GLVIEWER_API GLViewer_View2dTransformer : public GLViewer_ViewTransformer { public: - GLViewer_View2dTransformer( GLViewer_Viewer*, int ); - ~GLViewer_View2dTransformer(); - -public: - virtual void exec(); - - /*! Sets/returns mouse butto which will be used for rotation ( MB1 by default ) */ - static int rotateButton() { return rotateBtn; } - static void setRotateButton( int b ) { rotateBtn = b; } + GLViewer_View2dTransformer( GLViewer_Viewer*, int ); + ~GLViewer_View2dTransformer(); + + virtual void exec(); + + /*! Sets/returns mouse butto which will be used for rotation ( MB1 by default ) */ + static int rotateButton() { return rotateBtn; } + static void setRotateButton( int b ) { rotateBtn = b; } protected: - void onTransform( TransformState ); + void onTransform( TransformState ); -protected: - static int rotateBtn; + static int rotateBtn; }; #ifdef WNT -- 2.30.2