1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, 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"
44 #pragma warning( disable:4251 )
47 class GLViewer_Drawer;
48 class GLViewer_AspectLine;
50 class GLViewer_CoordSystem;
52 //class GLViewer_Owner;
57 * Class GLViewer_Object
58 * Base Object for all GLViewer objects
60 class GLVIEWER_API GLViewer_Object
66 virtual ~GLViewer_Object();
68 //! Main method. Computes all needed information about object for presentation in drawer
69 virtual void compute() = 0;
70 //! Creates correspond drawer
71 virtual GLViewer_Drawer* createDrawer() = 0;
73 //! Installing already exist drawer with same type
74 virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
75 //! Returns current drawer
76 GLViewer_Drawer* getDrawer() const { return myDrawer; }
78 //! Computes highlight presentation
82 *\param tol - tolerance of detecting
83 *\param isCircle - = true if sensitive area of detection is round
85 virtual GLboolean highlight( GLfloat x,
88 GLboolean isCircle = GL_FALSE ) = 0;
89 //! Clears all highlight information
90 virtual GLboolean unhighlight() = 0;
92 //! Computes select presentation
96 *\param tol - tolerance of detecting
97 *\param rect - Non empty for rectangle selection
98 *\param isFull - = true if
99 *\param isCircle - = true if sensitive area of detection is round
100 *\param isShift - = true if selection exec with append option
102 virtual GLboolean select( GLfloat x,
106 GLboolean isFull = GL_FALSE,
107 GLboolean isCircle = GL_FALSE,
108 GLboolean isShift = GL_FALSE ) = 0;
109 //! Clears all select information
110 virtual GLboolean unselect() = 0;
112 //! Returns if theRect inside object
113 virtual GLboolean isInside( GLViewer_Rect theRect);
115 //!\warning It is for ouv
116 virtual bool portContains( GLViewer_Pnt ) { return false; }
117 //!\warning It is for ouv
118 virtual bool startPulling( GLViewer_Pnt ) { return false; }
119 //!\warning It is for ouv
120 virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
121 //!\warning It is for ouv
122 virtual void finishPulling() {}
123 //!\warning It is for ouv
124 virtual bool isPulling() { return false; }
125 //!\warning It is for ouv
126 virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
127 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
129 //! Installs object rectangle
130 virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
131 //! Returns object rectungle
132 virtual GLViewer_Rect* getRect() const { return myRect; }
133 //! Returns update object rectangle
134 /*! Does not equal getRect() if object have a persistence to some viewer transformations*/
135 virtual GLViewer_Rect* getUpdateRect() = 0;
137 //! Installs scale factors
138 virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
139 //! Returns scale factors
140 virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
142 //!\warning It is for ouv
143 virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
144 //!\warning It is for ouv
145 virtual GLfloat getZoom() const { return myZoom; }
146 //!\warning It is for ouv
147 virtual GLboolean updateZoom( bool zoomIn );
149 //! Returns true if object is highlighted
150 virtual GLboolean isHighlighted() const { return myIsHigh; }
151 //! Returns true if object is selected
152 virtual GLboolean isSelected() const { return myIsSel; }
153 //! Installs select status to object
154 virtual void setSelected( GLboolean state ) { myIsSel = state; }
156 //! Installs GLText to object
157 void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
158 //! Returns object GLText
159 GLViewer_Text* getGLText() const { return myGLText; }
161 //! Installs acpect line for object presentation
162 virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
163 //! Returns acpect line of object presentation
164 virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
166 //! Returns object type
167 /*! Needs for GLViewer_Drawer*/
168 QString getObjectType() const { return myType; }
170 //! Installs object name
171 void setName( QString name ) { myName = name; }
172 //! Returns object name
173 QString getName() const { return myName; }
175 //! Returns object priority
176 virtual int getPriority() const;
178 //! Moves object per by recomputing
180 *\param dx - moving along X coord
181 *\param dy - moving along Y coord
182 *\param fromGroup - = true if this method called from group
184 virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0;
185 //! Finaly recomputing object after moving
186 virtual bool finishMove() { return true; }
188 //! Returns visible object status
189 virtual bool getVisible() const { return myIsVisible; }
190 //! Installs visible object status
191 virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
193 //! Installs onject tool tip text
194 void setToolTipText( QString str ){ myToolTipText = str; }
195 //! Returns onject tool tip text
196 virtual QString getToolTipText(){ return myToolTipText; }
198 //! Returns true if tool tip contains HTML tags
199 bool isTooTipHTML() const { return isToolTipHTML; }
200 //! Installs tool tip supporting of HTML tags
201 void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
203 //! A function for coding object to the byte copy
204 /*! A function is used for copy-past technollogy in copy method */
205 virtual QByteArray getByteCopy();
206 //! A function for decoding object from the byte copy
207 /*! A function is used for copy-past technollogy in past method */
208 virtual bool initializeFromByteCopy( QByteArray );
210 //! A function translate object in to PostScript file on disk
212 *\param hFile the name of PostScript file chosen by user
213 *\param aViewerCS the GLViewer_CoordSystem of window
214 *\param aPSCS the GLViewer_CoordSystem of PostScript page
216 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
217 //! A function translate object in to HPGL file on disk
219 *\param hFile the name of PostScript file chosen by user
220 *\param aViewerCS the GLViewer_CoordSystem of window
221 *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
223 virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
226 //! A function translate object in to EMF file on disk
230 *\param dc the name of HDC associated with file chosen by user
231 *\param aViewerCS the GLViewer_CoordSystem of window
232 *\param aEMFCS the GLViewer_CoordSystem of EMF page
234 virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
236 //!\warning It is for ouv
237 SUIT_DataOwner* owner() const { return myOwner; }
238 //!\warning It is for ouv
239 void setOwner( SUIT_DataOwner* owner ) { myOwner = owner; }
241 //! Adds object to group theGroup
242 void setGroup( GLViewer_Group* theGroup );
243 //! Returns object group
244 GLViewer_Group* getGroup() const;
246 //!\warning It is for ouv
247 virtual GLViewer_Object* getOwner() { return this; }
249 //! Returns true if object can be selected
250 virtual bool isSelectable() { return true; }
251 //!\warning It is for ouv
252 virtual bool isScalable() { return true; }
261 GLViewer_Rect* myRect;
262 //! Update object rect (after some viewer transformations)
263 GLViewer_Rect* myUpdateRect;
265 GLViewer_Text* myGLText;
271 //! Gap for X direction of rect
273 //! Gap for Y direction of rect
276 //!\warning It is for ouv
280 /*! = true after right highlighting*/
283 /*! = true after right selection*/
287 GLViewer_Drawer* myDrawer;
288 //! Line aspect for object presentation
289 GLViewer_AspectLine* myAspectLine;
291 //! Objet tool tip text
292 QString myToolTipText;
293 //! HTML object tool tip status
294 /*! = true if tool tip text contains HTML tags */
297 //! Object visibke status
300 //!\warning It is for ouv
301 SUIT_DataOwner* myOwner;
304 GLViewer_Group* myGroup;
308 #pragma warning ( default:4251 )