]> SALOME platform Git repositories - modules/gui.git/blob - src/GLViewer/GLViewer_Object.h
Salome HOME
new files added
[modules/gui.git] / src / GLViewer / GLViewer_Object.h
1 // File:      GLViewer_Object.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 #ifndef GLVIEWER_OBJECT_H
7 #define GLVIEWER_OBJECT_H
8
9 #ifdef WNT
10 #include <windows.h>
11 #endif
12
13 #include "GLViewer.h"
14 #include "GLViewer_Defs.h"
15 #include "GLViewer_Geom.h"
16
17 #include <SUIT_DataOwner.h>
18
19 #include <GL/gl.h>
20
21 #include <qfile.h>
22 #include <qstring.h>
23 #include <qrect.h>
24
25 #ifdef WNT
26 #pragma warning( disable:4251 )
27 #endif
28
29 // Class:   GLViewer_Object
30 // Descr:   OpenGL Object
31
32 class GLViewer_Drawer;
33 class GLViewer_AspectLine;
34 class GLViewer_Group;
35 class GLViewer_CoordSystem;
36 class GLViewer_Text;
37 class GLViewer_Owner;
38
39 class GLVIEWER_API GLViewer_Object
40 {
41 public:
42   GLViewer_Object();
43   virtual ~GLViewer_Object();
44   
45   virtual void              compute() = 0;
46   virtual GLViewer_Drawer*  createDrawer() = 0;
47
48   virtual void              setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
49   GLViewer_Drawer*          getDrawer() const { return myDrawer; }
50   
51   virtual GLboolean         highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE ) = 0;
52   virtual GLboolean         unhighlight() = 0;
53   virtual GLboolean         select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect,
54                                     GLboolean isFull = GL_FALSE, GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ) = 0;
55   virtual GLboolean         unselect() = 0;
56   
57   virtual GLboolean         isInside( GLViewer_Rect );
58   
59   virtual bool              portContains( GLViewer_Pnt ) { return false; }
60   virtual bool              startPulling( GLViewer_Pnt ) { return false; }
61   virtual void              pull( GLViewer_Pnt, GLViewer_Object* ) {}
62   virtual void              finishPulling() {}
63   virtual bool              isPulling() { return false; }
64   virtual GLViewer_Rect     getPullingRect() const { return GLViewer_Rect(
65                                 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
66   
67   virtual void              setRect( GLViewer_Rect* rect) { myRect = rect; }
68   virtual GLViewer_Rect*    getRect() const { return myRect; }
69   virtual GLViewer_Rect*    getUpdateRect() = 0;
70   
71   virtual void              setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
72   virtual void              getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
73
74   virtual GLboolean         setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
75   virtual GLfloat           getZoom() const { return myZoom; }
76   virtual GLboolean         updateZoom( bool zoomIn );
77   
78   virtual GLboolean         isHighlighted() const { return myIsHigh; }
79   virtual GLboolean         isSelected() const { return myIsSel; }  
80   virtual void              setSelected( GLboolean state ) { myIsSel = state; }
81   
82   void                      setGLText( GLViewer_Text* glText ) { myGLText = glText; }
83   GLViewer_Text*            getGLText() const { return myGLText; }
84   
85   virtual void              setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
86   virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
87   
88   QString                   getObjectType() const { return myType; } 
89   
90   void                      setName( QString name ) { myName = name; } 
91   QString                   getName() const { return myName; } 
92   
93   virtual int               getPriority() const;
94
95   virtual void              moveObject( float, float, bool fromGroup = false ) = 0;
96   virtual bool              finishMove() { return true; }
97   
98   bool                      getVisible() const { return myIsVisible; }
99   virtual void              setVisible( bool theStatus ) { myIsVisible = theStatus; }
100   
101   void                      setToolTipText( QString str ){ myToolTipText = str; }
102   virtual QString           getToolTipText(){ return myToolTipText; }
103   
104   bool                      isTooTipHTML() const { return isToolTipHTML; }
105   void                      setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
106   
107   virtual QByteArray        getByteCopy();
108   virtual bool              initializeFromByteCopy( QByteArray );
109   
110   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
111   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;  
112   
113 #ifdef WIN32
114   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
115 #endif
116
117   GLViewer_Owner*           owner() const { return myOwner; }
118   void                      setOwner( GLViewer_Owner* owner ) { myOwner = owner; }
119   
120   void                      setGroup( GLViewer_Group* );
121   GLViewer_Group*           getGroup() const;
122
123   virtual GLViewer_Object*  getOwner() { return this; }
124
125   virtual bool              isSelectable() { return true; }
126   virtual bool              isScalable() { return true; }
127   
128 protected:
129   QString                   myName;
130   QString                   myType;
131
132   GLViewer_Rect*            myRect;
133   GLViewer_Rect*            myUpdateRect;
134   GLViewer_Text*            myGLText;
135
136   GLfloat                   myXScale;
137   GLfloat                   myYScale;
138   GLfloat                   myXGap;
139   GLfloat                   myYGap;
140
141   GLfloat                   myZoom;
142
143   GLboolean                 myIsHigh;
144   GLboolean                 myIsSel;
145   
146   GLViewer_Drawer*          myDrawer;
147   GLViewer_AspectLine*      myAspectLine;
148   
149   QString                   myToolTipText;
150   bool                      isToolTipHTML;
151
152   bool                      myIsVisible;
153
154   GLViewer_Owner*           myOwner;
155   GLViewer_Group*           myGroup;
156 };
157
158 // Class:   GLViewer_Object
159 // Descr:   OpenGL Object
160
161 class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner
162 {
163 public:
164   GLViewer_Owner() : SUIT_DataOwner() {}
165   ~GLViewer_Owner() {}
166
167 protected:
168
169 };
170
171 #ifdef WNT
172 #pragma warning ( default:4251 )
173 #endif
174
175 #endif