Back to index

salome-gui  6.5.0
GLViewer_Object.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_Object.h
00025 // Created:   November, 2004
00026 //
00027 #ifndef GLVIEWER_OBJECT_H
00028 #define GLVIEWER_OBJECT_H
00029 
00030 #ifdef WIN32
00031 #include <windows.h>
00032 #endif
00033 
00034 #include "GLViewer.h"
00035 #include "GLViewer_Geom.h"
00036 
00037 #include <GL/gl.h>
00038 
00039 #include <QString>
00040 
00041 class QFile;
00042 
00043 #ifdef WIN32
00044 #pragma warning( disable:4251 )
00045 #endif
00046 
00047 class GLViewer_Drawer;
00048 class GLViewer_AspectLine;
00049 class GLViewer_Group;
00050 class GLViewer_CoordSystem;
00051 class GLViewer_Text;
00052 //class GLViewer_Owner;
00053 
00054 class SUIT_DataOwner;
00055 
00060 class GLVIEWER_API GLViewer_Object
00061 {
00062 public:
00064   GLViewer_Object();
00066   virtual ~GLViewer_Object();
00067   
00069   virtual void              compute() = 0;
00071   virtual GLViewer_Drawer*  createDrawer() = 0;
00072 
00074   virtual void              setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
00076   GLViewer_Drawer*          getDrawer() const { return myDrawer; }
00077   
00079 
00085   virtual GLboolean         highlight( GLfloat x,
00086                                        GLfloat y,
00087                                        GLfloat tol,
00088                                        GLboolean isCircle = GL_FALSE ) = 0;
00090   virtual GLboolean         unhighlight() = 0;
00091 
00093 
00102   virtual GLboolean         select( GLfloat x,
00103                                     GLfloat y,
00104                                     GLfloat tol,
00105                                     GLViewer_Rect rect,
00106                                     GLboolean isFull = GL_FALSE,
00107                                     GLboolean isCircle = GL_FALSE,
00108                                     GLboolean isShift = GL_FALSE ) = 0;
00110   virtual GLboolean         unselect() = 0;
00111   
00113   virtual GLboolean         isInside( GLViewer_Rect theRect);
00114   
00116   virtual bool              portContains( GLViewer_Pnt ) { return false; }
00118   virtual bool              startPulling( GLViewer_Pnt ) { return false; }
00120   virtual void              pull( GLViewer_Pnt, GLViewer_Object* ) {}
00122   virtual void              finishPulling() {}
00124   virtual bool              isPulling() { return false; }
00126   virtual GLViewer_Rect     getPullingRect() const { return GLViewer_Rect(
00127                                 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
00128   
00130   virtual void              setRect( GLViewer_Rect* rect) { myRect = rect; }
00132   virtual GLViewer_Rect*    getRect() const { return myRect; }
00134 
00135   virtual GLViewer_Rect*    getUpdateRect() = 0;
00136   
00138   virtual void              setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
00140   virtual void              getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
00141 
00143   virtual GLboolean         setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
00145   virtual GLfloat           getZoom() const { return myZoom; }
00147   virtual GLboolean         updateZoom( bool zoomIn );
00148   
00150   virtual GLboolean         isHighlighted() const { return myIsHigh; }
00152   virtual GLboolean         isSelected() const { return myIsSel; }
00154   virtual void              setSelected( GLboolean state ) { myIsSel = state; }
00155   
00157   void                      setGLText( GLViewer_Text* glText ) { myGLText = glText; }
00159   GLViewer_Text*            getGLText() const { return myGLText; }
00160   
00162   virtual void                 setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
00164   virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
00165   
00167 
00168   QString                   getObjectType() const { return myType; } 
00169   
00171   void                      setName( QString name ) { myName = name; } 
00173   QString                   getName() const { return myName; } 
00174   
00176   virtual int               getPriority() const;
00177 
00179 
00184   virtual void              moveObject( float dx, float dy, bool fromGroup = false ) = 0;
00186   virtual bool              finishMove() { return true; }
00187   
00189   virtual bool              getVisible() const { return myIsVisible; }
00191   virtual void              setVisible( bool theStatus ) { myIsVisible = theStatus; }
00192   
00194   void                      setToolTipText( QString str ){ myToolTipText = str; }
00196   virtual QString           getToolTipText(){ return myToolTipText; }
00197   
00199   bool                      isTooTipHTML() const { return isToolTipHTML; }
00201   void                      setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
00202   
00204 
00205   virtual QByteArray        getByteCopy();
00207 
00208   virtual bool              initializeFromByteCopy( QByteArray );
00209   
00211 
00216   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
00218 
00223   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;  
00224   
00225 #ifdef WIN32
00226 
00227 
00234   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
00235 #endif
00236 
00237   SUIT_DataOwner*           owner() const { return myOwner; }
00239   void                      setOwner( SUIT_DataOwner* owner ) { myOwner = owner; }
00240   
00242   void                      setGroup( GLViewer_Group* theGroup );
00244   GLViewer_Group*           getGroup() const;
00245   
00247   virtual GLViewer_Object*  getOwner() { return this; }
00248 
00250   virtual bool              isSelectable() { return true; }
00252   virtual bool              isScalable() { return true; }
00253   
00254 protected:
00256   QString                   myName;
00258   QString                   myType;
00259 
00261   GLViewer_Rect*            myRect;
00263   GLViewer_Rect*            myUpdateRect;
00265   GLViewer_Text*            myGLText;
00266 
00268   GLfloat                   myXScale;
00270   GLfloat                   myYScale;
00272   GLfloat                   myXGap;
00274   GLfloat                   myYGap;
00275 
00277   GLfloat                   myZoom;
00278 
00280 
00281   GLboolean                 myIsHigh;
00283 
00284   GLboolean                 myIsSel;
00285   
00287   GLViewer_Drawer*          myDrawer;
00289   GLViewer_AspectLine*      myAspectLine;
00290   
00292   QString                   myToolTipText;
00294 
00295   bool                      isToolTipHTML;
00296 
00298   bool                      myIsVisible;
00299 
00301   SUIT_DataOwner*           myOwner;
00302 
00304   GLViewer_Group*           myGroup;
00305 };
00306 
00307 #ifdef WIN32
00308 #pragma warning ( default:4251 )
00309 #endif
00310 
00311 #endif