Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GLViewer_Object.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // Author : OPEN CASCADE
24 // File: GLViewer_Object.h
25 // Created: November, 2004
26 //
27 #ifndef GLVIEWER_OBJECT_H
28 #define GLVIEWER_OBJECT_H
29 
30 #ifdef WIN32
31 #include <windows.h>
32 #endif
33 
34 #include "GLViewer.h"
35 #include "GLViewer_Geom.h"
36 
37 #ifdef __APPLE__
38 #include <OpenGL/gl.h>
39 #else
40 #include <GL/gl.h>
41 #endif
42 
43 #include <QString>
44 
45 class QFile;
46 
47 #ifdef WIN32
48 #pragma warning( disable:4251 )
49 #endif
50 
51 class GLViewer_Drawer;
53 class GLViewer_Group;
55 class GLViewer_Text;
56 //class GLViewer_Owner;
57 
58 class SUIT_DataOwner;
59 
65 {
66 public:
70  virtual ~GLViewer_Object();
71 
73  virtual void compute() = 0;
75  virtual GLViewer_Drawer* createDrawer() = 0;
76 
78  virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
80  GLViewer_Drawer* getDrawer() const { return myDrawer; }
81 
83 
89  virtual GLboolean highlight( GLfloat x,
90  GLfloat y,
91  GLfloat tol,
92  GLboolean isCircle = GL_FALSE ) = 0;
94  virtual GLboolean unhighlight() = 0;
95 
97 
106  virtual GLboolean select( GLfloat x,
107  GLfloat y,
108  GLfloat tol,
109  GLViewer_Rect rect,
110  GLboolean isFull = GL_FALSE,
111  GLboolean isCircle = GL_FALSE,
112  GLboolean isShift = GL_FALSE ) = 0;
114  virtual GLboolean unselect() = 0;
115 
117  virtual GLboolean isInside( GLViewer_Rect theRect);
118 
120  virtual bool portContains( GLViewer_Pnt ) { return false; }
122  virtual bool startPulling( GLViewer_Pnt ) { return false; }
124  virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
126  virtual void finishPulling() {}
128  virtual bool isPulling() { return false; }
130  virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
131  myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
132 
134  virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
136  virtual GLViewer_Rect* getRect() const { return myRect; }
138 
139  virtual GLViewer_Rect* getUpdateRect() = 0;
140 
142  virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
144  virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
145 
147  virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
149  virtual GLfloat getZoom() const { return myZoom; }
151  virtual GLboolean updateZoom( bool zoomIn );
152 
154  virtual GLboolean isHighlighted() const { return myIsHigh; }
156  virtual GLboolean isSelected() const { return myIsSel; }
158  virtual void setSelected( GLboolean state ) { myIsSel = state; }
159 
161  void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
163  GLViewer_Text* getGLText() const { return myGLText; }
164 
166  virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
168  virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
169 
171 
172  QString getObjectType() const { return myType; }
173 
175  void setName( QString name ) { myName = name; }
177  QString getName() const { return myName; }
178 
180  virtual int getPriority() const;
181 
183 
188  virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0;
190  virtual bool finishMove() { return true; }
191 
193  virtual bool getVisible() const { return myIsVisible; }
195  virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
196 
198  void setToolTipText( QString str ){ myToolTipText = str; }
200  virtual QString getToolTipText(){ return myToolTipText; }
201 
203  bool isTooTipHTML() const { return isToolTipHTML; }
205  void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
206 
208 
209  virtual QByteArray getByteCopy();
211 
212  virtual bool initializeFromByteCopy( QByteArray );
213 
215 
220  virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
222 
227  virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
228 
229 #ifdef WIN32
230 
231 
238  virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
239 #endif
240 
241  SUIT_DataOwner* owner() const { return myOwner; }
243  void setOwner( SUIT_DataOwner* owner ) { myOwner = owner; }
244 
246  void setGroup( GLViewer_Group* theGroup );
248  GLViewer_Group* getGroup() const;
249 
251  virtual GLViewer_Object* getOwner() { return this; }
252 
254  virtual bool isSelectable() { return true; }
256  virtual bool isScalable() { return true; }
257 
258 protected:
260  QString myName;
262  QString myType;
263 
270 
272  GLfloat myXScale;
274  GLfloat myYScale;
276  GLfloat myXGap;
278  GLfloat myYGap;
279 
281  GLfloat myZoom;
282 
284 
285  GLboolean myIsHigh;
287 
288  GLboolean myIsSel;
289 
294 
296  QString myToolTipText;
298 
300 
303 
306 
309 };
310 
311 #ifdef WIN32
312 #pragma warning ( default:4251 )
313 #endif
314 
315 #endif