src/GLViewer/GLViewer_BaseObjects.h

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