src/GLViewer/GLViewer_Object.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_Object.h
00023 // Created:   November, 2004
00024 
00025 #ifndef GLVIEWER_OBJECT_H
00026 #define GLVIEWER_OBJECT_H
00027 
00028 #ifdef WNT
00029 #include <windows.h>
00030 #endif
00031 
00032 #include "GLViewer.h"
00033 #include "GLViewer_Defs.h"
00034 #include "GLViewer_Geom.h"
00035 
00036 #include <SUIT_DataOwner.h>
00037 
00038 #include <GL/gl.h>
00039 
00040 #include <qfile.h>
00041 #include <qstring.h>
00042 #include <qrect.h>
00043 
00044 #ifdef WNT
00045 #pragma warning( disable:4251 )
00046 #endif
00047 
00048 class GLViewer_Drawer;
00049 class GLViewer_AspectLine;
00050 class GLViewer_Group;
00051 class GLViewer_CoordSystem;
00052 class GLViewer_Text;
00053 class GLViewer_Owner;
00054 
00059 class GLVIEWER_API GLViewer_Object
00060 {
00061 public:
00063   GLViewer_Object();
00065   virtual ~GLViewer_Object();
00066   
00068   virtual void              compute() = 0;
00070   virtual GLViewer_Drawer*  createDrawer() = 0;
00071 
00073   virtual void              setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
00075   GLViewer_Drawer*          getDrawer() const { return myDrawer; }
00076   
00078 
00084   virtual GLboolean         highlight( GLfloat x,
00085                            GLfloat y,
00086                                        GLfloat tol,
00087                                        GLboolean isCircle = GL_FALSE ) = 0;
00089   virtual GLboolean         unhighlight() = 0;
00090 
00092 
00101   virtual GLboolean         select( GLfloat x,
00102                                     GLfloat y,
00103                                     GLfloat tol,
00104                                     GLViewer_Rect rect,
00105                                     GLboolean isFull = GL_FALSE,
00106                                     GLboolean isCircle = GL_FALSE,
00107                                     GLboolean isShift = GL_FALSE ) = 0;
00109   virtual GLboolean         unselect() = 0;
00110   
00112   virtual GLboolean         isInside( GLViewer_Rect theRect);
00113   
00115   virtual bool              portContains( GLViewer_Pnt ) { return false; }
00117   virtual bool              startPulling( GLViewer_Pnt ) { return false; }
00119   virtual void              pull( GLViewer_Pnt, GLViewer_Object* ) {}
00121   virtual void              finishPulling() {}
00123   virtual bool              isPulling() { return false; }
00125   virtual GLViewer_Rect     getPullingRect() const { return GLViewer_Rect(
00126                                 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
00127   
00129   virtual void              setRect( GLViewer_Rect* rect) { myRect = rect; }
00131   virtual GLViewer_Rect*    getRect() const { return myRect; }
00133 
00134   virtual GLViewer_Rect*    getUpdateRect() = 0;
00135   
00137   virtual void              setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
00139   virtual void              getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
00140 
00142   virtual GLboolean         setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
00144   virtual GLfloat           getZoom() const { return myZoom; }
00146   virtual GLboolean         updateZoom( bool zoomIn );
00147   
00149   virtual GLboolean         isHighlighted() const { return myIsHigh; }
00151   virtual GLboolean         isSelected() const { return myIsSel; }
00153   virtual void              setSelected( GLboolean state ) { myIsSel = state; }
00154   
00156   void                      setGLText( GLViewer_Text* glText ) { myGLText = glText; }
00158   GLViewer_Text*            getGLText() const { return myGLText; }
00159   
00161   virtual void                 setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
00163   virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
00164   
00166 
00167   QString                   getObjectType() const { return myType; } 
00168   
00170   void                      setName( QString name ) { myName = name; } 
00172   QString                   getName() const { return myName; } 
00173   
00175   virtual int               getPriority() const;
00176 
00178 
00183   virtual void              moveObject( float dx, float dy, bool fromGroup = false ) = 0;
00185   virtual bool              finishMove() { return true; }
00186   
00188   virtual bool              getVisible() const { return myIsVisible; }
00190   virtual void              setVisible( bool theStatus ) { myIsVisible = theStatus; }
00191   
00193   void                      setToolTipText( QString str ){ myToolTipText = str; }
00195   virtual QString           getToolTipText(){ return myToolTipText; }
00196   
00198   bool                      isTooTipHTML() const { return isToolTipHTML; }
00200   void                      setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
00201   
00203 
00204   virtual QByteArray        getByteCopy();
00206 
00207   virtual bool              initializeFromByteCopy( QByteArray );
00208   
00210 
00215   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
00217 
00222   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;  
00223   
00224 #ifdef WIN32
00225 
00226 
00233   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
00234 #endif
00235 
00236   GLViewer_Owner*           owner() const { return myOwner; }
00238   void                      setOwner( GLViewer_Owner* owner ) { myOwner = owner; }
00239   
00241   void                      setGroup( GLViewer_Group* theGroup );
00243   GLViewer_Group*           getGroup() const;
00244   
00246   virtual GLViewer_Object*  getOwner() { return this; }
00247 
00249   virtual bool              isSelectable() { return true; }
00251   virtual bool              isScalable() { return true; }
00252   
00253 protected:
00255   QString                   myName;
00257   QString                   myType;
00258 
00260   GLViewer_Rect*            myRect;
00262   GLViewer_Rect*            myUpdateRect;
00264   GLViewer_Text*            myGLText;
00265 
00267   GLfloat                   myXScale;
00269   GLfloat                   myYScale;
00271   GLfloat                   myXGap;
00273   GLfloat                   myYGap;
00274 
00276   GLfloat                   myZoom;
00277 
00279 
00280   GLboolean                 myIsHigh;
00282 
00283   GLboolean                 myIsSel;
00284   
00286   GLViewer_Drawer*          myDrawer;
00288   GLViewer_AspectLine*      myAspectLine;
00289   
00291   QString                   myToolTipText;
00293 
00294   bool                      isToolTipHTML;
00295 
00297   bool                      myIsVisible;
00298 
00300   GLViewer_Owner*           myOwner;
00301 
00303   GLViewer_Group*           myGroup;
00304 };
00305 
00306 
00308 class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner
00309 {
00310 public:
00312   GLViewer_Owner() : SUIT_DataOwner() {}
00314   ~GLViewer_Owner() {}
00315 
00316 protected:
00317 
00318 };
00319 
00320 #ifdef WNT
00321 #pragma warning ( default:4251 )
00322 #endif
00323 
00324 #endif