Version: 9.12.0
GLViewer_Object.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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
231 
238  virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
239 #endif
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
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
Class for manage of presentations in GLViewer.
Definition: GLViewer_AspectLine.h:44
Class implementing mathematical model of 2D coordinate system.
Definition: GLViewer_CoordSystem.h:45
Definition: GLViewer_Drawer.h:193
Definition: GLViewer_Group.h:49
Definition: GLViewer_Object.h:65
SUIT_DataOwner * myOwner
Definition: GLViewer_Object.h:305
GLfloat myYGap
Gap for Y direction of rect.
Definition: GLViewer_Object.h:278
virtual bool translateToHPGL(QFile &hFile, GLViewer_CoordSystem *aViewerCS, GLViewer_CoordSystem *aHPGLCS)=0
A function translate object in to HPGL file on disk.
GLfloat myZoom
Definition: GLViewer_Object.h:281
QString getObjectType() const
Returns object type.
Definition: GLViewer_Object.h:172
virtual GLViewer_Object * getOwner()
Definition: GLViewer_Object.h:251
GLboolean myIsHigh
Highlight status.
Definition: GLViewer_Object.h:285
GLViewer_Text * getGLText() const
Returns object GLText.
Definition: GLViewer_Object.h:163
GLViewer_Drawer * myDrawer
Object drawer.
Definition: GLViewer_Object.h:291
SUIT_DataOwner * owner() const
Definition: GLViewer_Object.h:241
virtual QString getToolTipText()
Returns onject tool tip text.
Definition: GLViewer_Object.h:200
virtual GLViewer_Rect getPullingRect() const
Definition: GLViewer_Object.h:130
bool myIsVisible
Object visibke status.
Definition: GLViewer_Object.h:302
QString myToolTipText
Objet tool tip text.
Definition: GLViewer_Object.h:296
virtual void setSelected(GLboolean state)
Installs select status to object.
Definition: GLViewer_Object.h:158
GLViewer_Drawer * getDrawer() const
Returns current drawer.
Definition: GLViewer_Object.h:80
virtual GLViewer_AspectLine * getAspectLine() const
Returns acpect line of object presentation.
Definition: GLViewer_Object.h:168
GLboolean myIsSel
Selectt status.
Definition: GLViewer_Object.h:288
GLViewer_Group * myGroup
Object Group.
Definition: GLViewer_Object.h:308
virtual GLViewer_Rect * getRect() const
Returns object rectungle.
Definition: GLViewer_Object.h:136
virtual bool getVisible() const
Returns visible object status.
Definition: GLViewer_Object.h:193
virtual void setVisible(bool theStatus)
Installs visible object status.
Definition: GLViewer_Object.h:195
virtual void finishPulling()
Definition: GLViewer_Object.h:126
virtual bool isPulling()
Definition: GLViewer_Object.h:128
QString getName() const
Returns object name.
Definition: GLViewer_Object.h:177
virtual GLboolean unselect()=0
Clears all select information.
virtual bool translateToPS(QFile &hFile, GLViewer_CoordSystem *aViewerCS, GLViewer_CoordSystem *aPSCS)=0
A function translate object in to PostScript file on disk.
virtual GLboolean unhighlight()=0
Clears all highlight information.
virtual GLboolean select(GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull=GL_FALSE, GLboolean isCircle=GL_FALSE, GLboolean isShift=GL_FALSE)=0
Computes select presentation.
virtual GLboolean isHighlighted() const
Returns true if object is highlighted.
Definition: GLViewer_Object.h:154
QString myName
Object name.
Definition: GLViewer_Object.h:260
virtual GLboolean highlight(GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle=GL_FALSE)=0
Computes highlight presentation.
GLfloat myXScale
X scale factor.
Definition: GLViewer_Object.h:272
virtual GLfloat getZoom() const
Definition: GLViewer_Object.h:149
GLViewer_Text * myGLText
Object GLText.
Definition: GLViewer_Object.h:269
void setGLText(GLViewer_Text *glText)
Installs GLText to object.
Definition: GLViewer_Object.h:161
void setOwner(SUIT_DataOwner *owner)
Definition: GLViewer_Object.h:243
virtual bool startPulling(GLViewer_Pnt)
Definition: GLViewer_Object.h:122
virtual void pull(GLViewer_Pnt, GLViewer_Object *)
Definition: GLViewer_Object.h:124
void setToolTipText(QString str)
Installs onject tool tip text.
Definition: GLViewer_Object.h:198
bool isTooTipHTML() const
Returns true if tool tip contains HTML tags.
Definition: GLViewer_Object.h:203
virtual void setRect(GLViewer_Rect *rect)
Installs object rectangle.
Definition: GLViewer_Object.h:134
bool isToolTipHTML
HTML object tool tip status.
Definition: GLViewer_Object.h:299
virtual void setAspectLine(GLViewer_AspectLine *aspect)
Installs acpect line for object presentation.
Definition: GLViewer_Object.h:166
virtual GLViewer_Rect * getUpdateRect()=0
Returns update object rectangle.
void setToolTipFormat(bool isHTML)
Installs tool tip supporting of HTML tags.
Definition: GLViewer_Object.h:205
virtual void setDrawer(GLViewer_Drawer *theDrawer)
Installing already exist drawer with same type.
Definition: GLViewer_Object.h:78
virtual bool isScalable()
Definition: GLViewer_Object.h:256
GLfloat myYScale
Y scale factor.
Definition: GLViewer_Object.h:274
virtual bool portContains(GLViewer_Pnt)
Definition: GLViewer_Object.h:120
virtual bool finishMove()
Finaly recomputing object after moving.
Definition: GLViewer_Object.h:190
GLfloat myXGap
Gap for X direction of rect.
Definition: GLViewer_Object.h:276
virtual void getScale(GLfloat &xScale, GLfloat &yScale) const
Returns scale factors.
Definition: GLViewer_Object.h:144
void setName(QString name)
Installs object name.
Definition: GLViewer_Object.h:175
GLViewer_AspectLine * myAspectLine
Line aspect for object presentation.
Definition: GLViewer_Object.h:293
QString myType
Object type.
Definition: GLViewer_Object.h:262
virtual GLboolean isSelected() const
Returns true if object is selected.
Definition: GLViewer_Object.h:156
virtual GLViewer_Drawer * createDrawer()=0
Creates correspond drawer.
virtual void setScale(GLfloat xScale, GLfloat yScale)
Installs scale factors.
Definition: GLViewer_Object.h:142
virtual void moveObject(float dx, float dy, bool fromGroup=false)=0
Moves object per by recomputing.
virtual void compute()=0
Main method. Computes all needed information about object for presentation in drawer.
virtual bool isSelectable()
Returns true if object can be selected.
Definition: GLViewer_Object.h:254
GLViewer_Rect * myUpdateRect
Update object rect (after some viewer transformations)
Definition: GLViewer_Object.h:267
GLViewer_Rect * myRect
Object base rect.
Definition: GLViewer_Object.h:265
Definition: GLViewer_Geom.h:69
Definition: GLViewer_Text.h:56
Definition: SUIT_DataOwner.h:44
Definition: GLViewer_Geom.h:45