1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // Author : OPEN CASCADE
24 // File: GLViewer_Object.h
25 // Created: November, 2004
27 #ifndef GLVIEWER_OBJECT_H
28 #define GLVIEWER_OBJECT_H
35 #include "GLViewer_Geom.h"
38 #include <OpenGL/gl.h>
48 #pragma warning( disable:4251 )
51 class GLViewer_Drawer;
52 class GLViewer_AspectLine;
54 class GLViewer_CoordSystem;
56 //class GLViewer_Owner;
61 * Class GLViewer_Object
62 * Base Object for all GLViewer objects
64 class GLVIEWER_API GLViewer_Object
70 virtual ~GLViewer_Object();
72 //! Main method. Computes all needed information about object for presentation in drawer
73 virtual void compute() = 0;
74 //! Creates correspond drawer
75 virtual GLViewer_Drawer* createDrawer() = 0;
77 //! Installing already exist drawer with same type
78 virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
79 //! Returns current drawer
80 GLViewer_Drawer* getDrawer() const { return myDrawer; }
82 //! Computes highlight presentation
86 *\param tol - tolerance of detecting
87 *\param isCircle - = true if sensitive area of detection is round
89 virtual GLboolean highlight( GLfloat x,
92 GLboolean isCircle = GL_FALSE ) = 0;
93 //! Clears all highlight information
94 virtual GLboolean unhighlight() = 0;
96 //! Computes select presentation
100 *\param tol - tolerance of detecting
101 *\param rect - Non empty for rectangle selection
102 *\param isFull - = true if
103 *\param isCircle - = true if sensitive area of detection is round
104 *\param isShift - = true if selection exec with append option
106 virtual GLboolean select( GLfloat x,
110 GLboolean isFull = GL_FALSE,
111 GLboolean isCircle = GL_FALSE,
112 GLboolean isShift = GL_FALSE ) = 0;
113 //! Clears all select information
114 virtual GLboolean unselect() = 0;
116 //! Returns if theRect inside object
117 virtual GLboolean isInside( GLViewer_Rect theRect);
119 //!\warning It is for ouv
120 virtual bool portContains( GLViewer_Pnt ) { return false; }
121 //!\warning It is for ouv
122 virtual bool startPulling( GLViewer_Pnt ) { return false; }
123 //!\warning It is for ouv
124 virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
125 //!\warning It is for ouv
126 virtual void finishPulling() {}
127 //!\warning It is for ouv
128 virtual bool isPulling() { return false; }
129 //!\warning It is for ouv
130 virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
131 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
133 //! Installs object rectangle
134 virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
135 //! Returns object rectungle
136 virtual GLViewer_Rect* getRect() const { return myRect; }
137 //! Returns update object rectangle
138 /*! Does not equal getRect() if object have a persistence to some viewer transformations*/
139 virtual GLViewer_Rect* getUpdateRect() = 0;
141 //! Installs scale factors
142 virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
143 //! Returns scale factors
144 virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
146 //!\warning It is for ouv
147 virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
148 //!\warning It is for ouv
149 virtual GLfloat getZoom() const { return myZoom; }
150 //!\warning It is for ouv
151 virtual GLboolean updateZoom( bool zoomIn );
153 //! Returns true if object is highlighted
154 virtual GLboolean isHighlighted() const { return myIsHigh; }
155 //! Returns true if object is selected
156 virtual GLboolean isSelected() const { return myIsSel; }
157 //! Installs select status to object
158 virtual void setSelected( GLboolean state ) { myIsSel = state; }
160 //! Installs GLText to object
161 void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
162 //! Returns object GLText
163 GLViewer_Text* getGLText() const { return myGLText; }
165 //! Installs acpect line for object presentation
166 virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
167 //! Returns acpect line of object presentation
168 virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
170 //! Returns object type
171 /*! Needs for GLViewer_Drawer*/
172 QString getObjectType() const { return myType; }
174 //! Installs object name
175 void setName( QString name ) { myName = name; }
176 //! Returns object name
177 QString getName() const { return myName; }
179 //! Returns object priority
180 virtual int getPriority() const;
182 //! Moves object per by recomputing
184 *\param dx - moving along X coord
185 *\param dy - moving along Y coord
186 *\param fromGroup - = true if this method called from group
188 virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0;
189 //! Finaly recomputing object after moving
190 virtual bool finishMove() { return true; }
192 //! Returns visible object status
193 virtual bool getVisible() const { return myIsVisible; }
194 //! Installs visible object status
195 virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
197 //! Installs onject tool tip text
198 void setToolTipText( QString str ){ myToolTipText = str; }
199 //! Returns onject tool tip text
200 virtual QString getToolTipText(){ return myToolTipText; }
202 //! Returns true if tool tip contains HTML tags
203 bool isTooTipHTML() const { return isToolTipHTML; }
204 //! Installs tool tip supporting of HTML tags
205 void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
207 //! A function for coding object to the byte copy
208 /*! A function is used for copy-past technollogy in copy method */
209 virtual QByteArray getByteCopy();
210 //! A function for decoding object from the byte copy
211 /*! A function is used for copy-past technollogy in past method */
212 virtual bool initializeFromByteCopy( QByteArray );
214 //! A function translate object in to PostScript file on disk
216 *\param hFile the name of PostScript file chosen by user
217 *\param aViewerCS the GLViewer_CoordSystem of window
218 *\param aPSCS the GLViewer_CoordSystem of PostScript page
220 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
221 //! A function translate object in to HPGL file on disk
223 *\param hFile the name of PostScript file chosen by user
224 *\param aViewerCS the GLViewer_CoordSystem of window
225 *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
227 virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
230 //! A function translate object in to EMF file on disk
234 *\param dc the name of HDC associated with file chosen by user
235 *\param aViewerCS the GLViewer_CoordSystem of window
236 *\param aEMFCS the GLViewer_CoordSystem of EMF page
238 virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
240 //!\warning It is for ouv
241 SUIT_DataOwner* owner() const { return myOwner; }
242 //!\warning It is for ouv
243 void setOwner( SUIT_DataOwner* owner ) { myOwner = owner; }
245 //! Adds object to group theGroup
246 void setGroup( GLViewer_Group* theGroup );
247 //! Returns object group
248 GLViewer_Group* getGroup() const;
250 //!\warning It is for ouv
251 virtual GLViewer_Object* getOwner() { return this; }
253 //! Returns true if object can be selected
254 virtual bool isSelectable() { return true; }
255 //!\warning It is for ouv
256 virtual bool isScalable() { return true; }
265 GLViewer_Rect* myRect;
266 //! Update object rect (after some viewer transformations)
267 GLViewer_Rect* myUpdateRect;
269 GLViewer_Text* myGLText;
275 //! Gap for X direction of rect
277 //! Gap for Y direction of rect
280 //!\warning It is for ouv
284 /*! = true after right highlighting*/
287 /*! = true after right selection*/
291 GLViewer_Drawer* myDrawer;
292 //! Line aspect for object presentation
293 GLViewer_AspectLine* myAspectLine;
295 //! Objet tool tip text
296 QString myToolTipText;
297 //! HTML object tool tip status
298 /*! = true if tool tip text contains HTML tags */
301 //! Object visibke status
304 //!\warning It is for ouv
305 SUIT_DataOwner* myOwner;
308 GLViewer_Group* myGroup;
312 #pragma warning ( default:4251 )