1 // Copyright (C) 2005 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : OPEN CASCADE
22 // File: GLViewer_Object.h
23 // Created: November, 2004
25 #ifndef GLVIEWER_OBJECT_H
26 #define GLVIEWER_OBJECT_H
33 #include "GLViewer_Defs.h"
34 #include "GLViewer_Geom.h"
36 #include <SUIT_DataOwner.h>
45 #pragma warning( disable:4251 )
48 class GLViewer_Drawer;
49 class GLViewer_AspectLine;
51 class GLViewer_CoordSystem;
56 * Class GLViewer_Object
57 * Base Object for all GLViewer objects
59 class GLVIEWER_API GLViewer_Object
65 virtual ~GLViewer_Object();
67 //! Main method. Computes all needed information about object for presentation in drawer
68 virtual void compute() = 0;
69 //! Creates correspond drawer
70 virtual GLViewer_Drawer* createDrawer() = 0;
72 //! Installing already exist drawer with same type
73 virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
74 //! Returns current drawer
75 GLViewer_Drawer* getDrawer() const { return myDrawer; }
77 //! Computes highlight presentation
81 *\param tol - tolerance of detecting
82 *\param isCircle - = true if sensitive area of detection is round
84 virtual GLboolean highlight( GLfloat x,
87 GLboolean isCircle = GL_FALSE ) = 0;
88 //! Clears all highlight information
89 virtual GLboolean unhighlight() = 0;
91 //! Computes select presentation
95 *\param tol - tolerance of detecting
96 *\param rect - Non empty for rectangle selection
97 *\param isFull - = true if
98 *\param isCircle - = true if sensitive area of detection is round
99 *\param isShift - = true if selection exec with append option
101 virtual GLboolean select( GLfloat x,
105 GLboolean isFull = GL_FALSE,
106 GLboolean isCircle = GL_FALSE,
107 GLboolean isShift = GL_FALSE ) = 0;
108 //! Clears all select information
109 virtual GLboolean unselect() = 0;
111 //! Returns if theRect inside object
112 virtual GLboolean isInside( GLViewer_Rect theRect);
114 //!\warning It is for ouv
115 virtual bool portContains( GLViewer_Pnt ) { return false; }
116 //!\warning It is for ouv
117 virtual bool startPulling( GLViewer_Pnt ) { return false; }
118 //!\warning It is for ouv
119 virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
120 //!\warning It is for ouv
121 virtual void finishPulling() {}
122 //!\warning It is for ouv
123 virtual bool isPulling() { return false; }
124 //!\warning It is for ouv
125 virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
126 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
128 //! Installs object rectangle
129 virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
130 //! Returns object rectungle
131 virtual GLViewer_Rect* getRect() const { return myRect; }
132 //! Returns update object rectangle
133 /*! Does not equal getRect() if object have a persistence to some viewer transformations*/
134 virtual GLViewer_Rect* getUpdateRect() = 0;
136 //! Installs scale factors
137 virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
138 //! Returns scale factors
139 virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
141 //!\warning It is for ouv
142 virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
143 //!\warning It is for ouv
144 virtual GLfloat getZoom() const { return myZoom; }
145 //!\warning It is for ouv
146 virtual GLboolean updateZoom( bool zoomIn );
148 //! Returns true if object is highlighted
149 virtual GLboolean isHighlighted() const { return myIsHigh; }
150 //! Returns true if object is selected
151 virtual GLboolean isSelected() const { return myIsSel; }
152 //! Installs select status to object
153 virtual void setSelected( GLboolean state ) { myIsSel = state; }
155 //! Installs GLText to object
156 void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
157 //! Returns object GLText
158 GLViewer_Text* getGLText() const { return myGLText; }
160 //! Installs acpect line for object presentation
161 virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
162 //! Returns acpect line of object presentation
163 virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
165 //! Returns object type
166 /*! Needs for GLViewer_Drawer*/
167 QString getObjectType() const { return myType; }
169 //! Installs object name
170 void setName( QString name ) { myName = name; }
171 //! Returns object name
172 QString getName() const { return myName; }
174 //! Returns object priority
175 virtual int getPriority() const;
177 //! Moves object per by recomputing
179 *\param dx - moving along X coord
180 *\param dy - moving along Y coord
181 *\param fromGroup - = true if this method called from group
183 virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0;
184 //! Finaly recomputing object after moving
185 virtual bool finishMove() { return true; }
187 //! Returns visible object status
188 virtual bool getVisible() const { return myIsVisible; }
189 //! Installs visible object status
190 virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
192 //! Installs onject tool tip text
193 void setToolTipText( QString str ){ myToolTipText = str; }
194 //! Returns onject tool tip text
195 virtual QString getToolTipText(){ return myToolTipText; }
197 //! Returns true if tool tip contains HTML tags
198 bool isTooTipHTML() const { return isToolTipHTML; }
199 //! Installs tool tip supporting of HTML tags
200 void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
202 //! A function for coding object to the byte copy
203 /*! A function is used for copy-past technollogy in copy method */
204 virtual QByteArray getByteCopy();
205 //! A function for decoding object from the byte copy
206 /*! A function is used for copy-past technollogy in past method */
207 virtual bool initializeFromByteCopy( QByteArray );
209 //! A function translate object in to PostScript file on disk
211 *\param hFile the name of PostScript file chosen by user
212 *\param aViewerCS the GLViewer_CoordSystem of window
213 *\param aPSCS the GLViewer_CoordSystem of PostScript page
215 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
216 //! A function translate object in to HPGL file on disk
218 *\param hFile the name of PostScript file chosen by user
219 *\param aViewerCS the GLViewer_CoordSystem of window
220 *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
222 virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
225 //! A function translate object in to EMF file on disk
229 *\param dc the name of HDC associated with file chosen by user
230 *\param aViewerCS the GLViewer_CoordSystem of window
231 *\param aEMFCS the GLViewer_CoordSystem of EMF page
233 virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
235 //!\warning It is for ouv
236 GLViewer_Owner* owner() const { return myOwner; }
237 //!\warning It is for ouv
238 void setOwner( GLViewer_Owner* owner ) { myOwner = owner; }
240 //! Adds object to group theGroup
241 void setGroup( GLViewer_Group* theGroup );
242 //! Returns object group
243 GLViewer_Group* getGroup() const;
245 //!\warning It is for ouv
246 virtual GLViewer_Object* getOwner() { return this; }
248 //! Returns true if object can be selected
249 virtual bool isSelectable() { return true; }
250 //!\warning It is for ouv
251 virtual bool isScalable() { return true; }
260 GLViewer_Rect* myRect;
261 //! Update object rect (after some viewer transformations)
262 GLViewer_Rect* myUpdateRect;
264 GLViewer_Text* myGLText;
270 //! Gap for X direction of rect
272 //! Gap for Y direction of rect
275 //!\warning It is for ouv
279 /*! = true after right highlighting*/
282 /*! = true after right selection*/
286 GLViewer_Drawer* myDrawer;
287 //! Line aspect for object presentation
288 GLViewer_AspectLine* myAspectLine;
290 //! Objet tool tip text
291 QString myToolTipText;
292 //! HTML object tool tip status
293 /*! = true if tool tip text contains HTML tags */
296 //! Object visibke status
299 //!\warning It is for ouv
300 GLViewer_Owner* myOwner;
303 GLViewer_Group* myGroup;
307 //!\warning It is for ouv
308 class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner
311 //!\warning It is for ouv
312 GLViewer_Owner() : SUIT_DataOwner() {}
313 //!\warning It is for ouv
321 #pragma warning ( default:4251 )