Back to index

salome-gui  6.5.0
GLViewer_BaseObjects.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  Author : OPEN CASCADE
00024 // File:      GLViewer_BaseObjects.h
00025 // Created:   November, 2004
00026 //
00027 #ifndef GLVIEWER_BASEOBJECTS_H
00028 #define GLVIEWER_BASEOBJECTS_H
00029 
00030 #include "GLViewer.h"
00031 #include "GLViewer_Object.h"
00032 
00033 #include <QColor>
00034 
00035 #include <TColStd_SequenceOfInteger.hxx>
00036 
00037 #ifdef WIN32
00038 #pragma warning( disable:4251 )
00039 #endif
00040 
00045 class GLVIEWER_API GLViewer_MarkerSet : public GLViewer_Object
00046 {
00047 public:
00049   GLViewer_MarkerSet( int number = 1, float size = 5.0, const QString& toolTip = "GLMarker" );
00051   ~GLViewer_MarkerSet();
00052 
00053   // redefined  methods
00054   virtual void             compute();
00055   virtual GLViewer_Drawer* createDrawer();
00056   
00057   virtual GLboolean        highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
00058   virtual GLboolean        unhighlight();
00059   virtual GLboolean        select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
00060     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
00061   virtual GLboolean        unselect();
00062   
00063   virtual GLViewer_Rect*   getUpdateRect();
00064   
00065   virtual void             moveObject( float, float, bool fromGroup = false );
00066   
00067   virtual QByteArray       getByteCopy();
00068   virtual bool             initializeFromByteCopy( QByteArray );
00069   
00070   virtual bool             translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
00071   virtual bool             translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
00072   
00073 #ifdef WIN32
00074   virtual bool             translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
00075 #endif
00076 
00078   void                     setXCoord( GLfloat* xCoord, int size );
00080   void                     setYCoord( GLfloat* yCoord, int size );
00082   GLfloat*                 getXCoord() const { return myXCoord; }
00084   GLfloat*                 getYCoord() const { return myYCoord; }
00085   
00087   void                     setNumMarkers( GLint );
00089   GLint                    getNumMarkers() const { return myNumber; };
00091   void                     setMarkerSize( const float size ) { myMarkerSize = size; }
00093   float                    getMarkerSize() const { return myMarkerSize; }
00094   
00096   void                     exportNumbers( QList<int>& high, QList<int>& unhigh,
00097                                           QList<int>& sel, QList<int>& unsel );
00098   
00100   QList<int>               getSelectedElements() { return mySelNumbers; }
00102   bool                     addOrRemoveSelected( int index );
00104   void                     addSelected( const TColStd_SequenceOfInteger& );
00106   void                     setSelected( const TColStd_SequenceOfInteger& );
00107 
00108 protected:
00109   GLint                   myNumber;
00110   GLfloat*                myXCoord;
00111   GLfloat*                myYCoord;    
00112   GLfloat                 myMarkerSize;
00113   QList<int>              myHNumbers;
00114   QList<int>              myUHNumbers;
00115   QList<int>              mySelNumbers;
00116   QList<int>              myCurSelNumbers;
00117   QList<int>              myUSelNumbers;
00118   QList<int>              myPrevHNumbers;
00119   TColStd_SequenceOfInteger mySelectedIndexes;
00120 };
00121 
00126 class GLVIEWER_API GLViewer_Polyline: public GLViewer_Object
00127 {
00128 public:
00129   GLViewer_Polyline( int number = 1, float size = 5.0, const QString& toolTip = "GLPolyline" );
00130  ~GLViewer_Polyline();
00131   
00132   // redefined  methods
00133   virtual void            compute();
00134   virtual GLViewer_Drawer* createDrawer();
00135   
00136   virtual GLboolean       highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
00137   virtual GLboolean       unhighlight();
00138   virtual GLboolean       select( GLfloat x, GLfloat y, GLfloat tol,  GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
00139     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
00140   virtual GLboolean       unselect();
00141   
00142   virtual GLViewer_Rect*  getUpdateRect();
00143   
00144   virtual void            moveObject( float, float, bool fromGroup = false );
00145   
00146   virtual QByteArray      getByteCopy();
00147   virtual bool            initializeFromByteCopy( QByteArray );
00148   
00149   virtual bool            translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
00150   virtual bool            translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
00151   
00152 #ifdef WIN32
00153   virtual bool            translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
00154 #endif
00155   
00157   void                     setXCoord( GLfloat* xCoord, int size );
00159   void                     setYCoord( GLfloat* yCoord, int size );
00161   GLfloat*                 getXCoord() const { return myXCoord; }
00163   GLfloat*                 getYCoord() const { return myYCoord; }
00164 
00166   void                    setNumber( GLint );
00168   GLint                   getNumber() const { return myNumber; };
00169   
00171   void                    setClosed( GLboolean closed ) { myIsClosed = closed; }
00173   GLboolean               isClosed() const { return myIsClosed; }
00174   
00176   void                    setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; }
00178   GLboolean               isHighSelAll() const { return myHighSelAll; }
00179   
00181   void                    exportNumbers( QList<int>& high, QList<int>& unhigh,
00182                                          QList<int>& sel, QList<int>& unsel );
00183 
00185   QList<int>              getSelectedElements() { return mySelNumbers; }
00186 
00187 protected:
00188   GLfloat*                myXCoord;
00189   GLfloat*                myYCoord;
00190   GLint                   myNumber;
00191   GLboolean               myIsClosed;
00192   GLboolean               myHighSelAll;
00193   
00194   QList<int>              myHNumbers;
00195   QList<int>              myUHNumbers;
00196   QList<int>              mySelNumbers;
00197   QList<int>              myUSelNumbers;
00198   QList<int>              myCurSelNumbers;
00199   QList<int>              myPrevHNumbers;
00200   TColStd_SequenceOfInteger mySelectedIndexes;
00201   
00202   GLboolean               myHighFlag;
00203 };
00204 
00209 class GLVIEWER_API GLViewer_TextObject : public GLViewer_Object
00210 {
00211 public:  
00212   GLViewer_TextObject( const QString&, float xPos = 0, float yPos = 0, 
00213     const QColor& color = QColor( 0, 255, 0 ), const QString& toolTip = "GLText" );
00214   ~GLViewer_TextObject();
00215   
00216   virtual void              compute();
00217   virtual GLViewer_Drawer*  createDrawer();
00218   
00219   virtual void              setDrawer( GLViewer_Drawer* theDrawer );
00220   
00221   virtual GLboolean         highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE );
00222   virtual GLboolean         unhighlight();
00223   virtual GLboolean         select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
00224     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
00225   virtual GLboolean         unselect();
00226   
00227   virtual GLViewer_Rect*    getUpdateRect();
00228   
00229   virtual void              moveObject( float, float, bool fromGroup = false );
00230   
00231   virtual QByteArray        getByteCopy();
00232   virtual bool              initializeFromByteCopy( QByteArray );
00233   
00234   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
00235   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );  
00236   
00237 #ifdef WIN32
00238   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
00239 #endif
00240   
00241   int                       getWidth(){ return myWidth; }
00242   int                       getHeight(){ return myWidth; }
00243   void                      setWidth( int w ){ myWidth=w; }
00244   void                      setHeight( int h ){ myHeight=h; }
00245   
00246 protected:
00247   bool                      myHighFlag;
00248   int                       myWidth;
00249   int                       myHeight;
00250 };
00251 
00252 #ifdef WIN32
00253 #pragma warning ( default:4251 )
00254 #endif
00255 
00256 #endif