1 // File: GLViewer_Object.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 #ifndef GLVIEWER_OBJECT_H
7 #define GLVIEWER_OBJECT_H
14 #include "GLViewer_Defs.h"
15 #include "GLViewer_Geom.h"
17 #include <SUIT_DataOwner.h>
26 #pragma warning( disable:4251 )
30 * Class GLViewer_Object
31 * Base Object for GLViewer
33 class GLViewer_Drawer;
34 class GLViewer_AspectLine;
36 class GLViewer_CoordSystem;
40 class GLVIEWER_API GLViewer_Object
46 virtual ~GLViewer_Object();
48 //! Main method. Computes all needed information about object for presentation in drawer
49 virtual void compute() = 0;
50 //! Creates correspond drawer
51 virtual GLViewer_Drawer* createDrawer() = 0;
53 //! Installing already exist drawer with same type
54 virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
55 //! Returns current drawer
56 GLViewer_Drawer* getDrawer() const { return myDrawer; }
58 //! Computes highlight presentation
62 *\param tol - tolerance of detecting
63 *\param isCircle - = true if sensitive area of detection is round
65 virtual GLboolean highlight( GLfloat x,
68 GLboolean isCircle = GL_FALSE ) = 0;
69 //! Clears all highlight information
70 virtual GLboolean unhighlight() = 0;
72 //! Computes select presentation
76 *\param tol - tolerance of detecting
77 *\param rect - Non empty for rectangle selection
78 *\param isFull - = true if
79 *\param isCircle - = true if sensitive area of detection is round
80 *\param isShift - = true if selection exec with append option
82 virtual GLboolean select( GLfloat x,
86 GLboolean isFull = GL_FALSE,
87 GLboolean isCircle = GL_FALSE,
88 GLboolean isShift = GL_FALSE ) = 0;
89 //! Clears all select information
90 virtual GLboolean unselect() = 0;
92 //! Returns if theRect inside object
93 virtual GLboolean isInside( GLViewer_Rect theRect);
95 //!\warning It is for ouv
96 virtual bool portContains( GLViewer_Pnt ) { return false; }
97 //!\warning It is for ouv
98 virtual bool startPulling( GLViewer_Pnt ) { return false; }
99 //!\warning It is for ouv
100 virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
101 //!\warning It is for ouv
102 virtual void finishPulling() {}
103 //!\warning It is for ouv
104 virtual bool isPulling() { return false; }
105 //!\warning It is for ouv
106 virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
107 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
109 //! Installs object rectangle
110 virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
111 //! Returns object rectungle
112 virtual GLViewer_Rect* getRect() const { return myRect; }
113 //! Returns update object rectangle
114 /*! Does not equal getRect() if object have a persistence to some viewer transformations*/
115 virtual GLViewer_Rect* getUpdateRect() = 0;
117 //! Installs scale factors
118 virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
119 //! Returns scale factors
120 virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
122 //!\warning It is for ouv
123 virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
124 //!\warning It is for ouv
125 virtual GLfloat getZoom() const { return myZoom; }
126 //!\warning It is for ouv
127 virtual GLboolean updateZoom( bool zoomIn );
129 //! Returns true if object is highlighted
130 virtual GLboolean isHighlighted() const { return myIsHigh; }
131 //! Returns true if object is selected
132 virtual GLboolean isSelected() const { return myIsSel; }
133 //! Installs select status to object
134 virtual void setSelected( GLboolean state ) { myIsSel = state; }
136 //! Installs GLText to object
137 void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
138 //! Returns object GLText
139 GLViewer_Text* getGLText() const { return myGLText; }
141 //! Installs acpect line for object presentation
142 virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
143 //! Returns acpect line of object presentation
144 virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
146 //! Returns object type
147 /*! Needs for GLViewer_Drawer*/
148 QString getObjectType() const { return myType; }
150 //! Installs object name
151 void setName( QString name ) { myName = name; }
152 //! Returns object name
153 QString getName() const { return myName; }
155 //! Returns object priority
156 virtual int getPriority() const;
158 //! Moves object per by recomputing
160 *\param dx - moving along X coord
161 *\param dy - moving along Y coord
162 *\param fromGroup - = true if this method called from group
164 virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0;
165 //! Finaly recomputing object after moving
166 virtual bool finishMove() { return true; }
168 //! Returns visible object status
169 bool getVisible() const { return myIsVisible; }
170 //! Installs visible object status
171 virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
173 //! Installs onject tool tip text
174 void setToolTipText( QString str ){ myToolTipText = str; }
175 //! Returns onject tool tip text
176 virtual QString getToolTipText(){ return myToolTipText; }
178 //! Returns true if tool tip contains HTML tags
179 bool isTooTipHTML() const { return isToolTipHTML; }
180 //! Installs tool tip supporting of HTML tags
181 void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
183 //! A function for coding object to the byte copy
184 /*! A function is used for copy-past technollogy in copy method */
185 virtual QByteArray getByteCopy();
186 //! A function for decoding object from the byte copy
187 /*! A function is used for copy-past technollogy in past method */
188 virtual bool initializeFromByteCopy( QByteArray );
190 //! A function translate object in to PostScript file on disk
192 *\param hFile the name of PostScript file chosen by user
193 *\param aViewerCS the GLViewer_CoordSystem of window
194 *\param aPSCS the GLViewer_CoordSystem of PostScript page
196 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
197 //! A function translate object in to HPGL file on disk
199 *\param hFile the name of PostScript file chosen by user
200 *\param aViewerCS the GLViewer_CoordSystem of window
201 *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
203 virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
206 //! A function translate object in to EMF file on disk
210 *\param dc the name of HDC associated with file chosen by user
211 *\param aViewerCS the GLViewer_CoordSystem of window
212 *\param aEMFCS the GLViewer_CoordSystem of EMF page
214 virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
216 //!\warning It is for ouv
217 GLViewer_Owner* owner() const { return myOwner; }
218 //!\warning It is for ouv
219 void setOwner( GLViewer_Owner* owner ) { myOwner = owner; }
221 //! Adds object to group theGroup
222 void setGroup( GLViewer_Group* theGroup );
223 //! Returns object group
224 GLViewer_Group* getGroup() const;
226 //!\warning It is for ouv
227 virtual GLViewer_Object* getOwner() { return this; }
229 //! Returns true if object can be selected
230 virtual bool isSelectable() { return true; }
231 //!\warning It is for ouv
232 virtual bool isScalable() { return true; }
241 GLViewer_Rect* myRect;
242 //! Update object rect (after some viewer transformations)
243 GLViewer_Rect* myUpdateRect;
245 GLViewer_Text* myGLText;
251 //! Gap for X direction of rect
253 //! Gap for Y direction of rect
256 //!\warning It is for ouv
260 /*! = true after right highlighting*/
263 /*! = true after right selection*/
267 GLViewer_Drawer* myDrawer;
268 //! Line aspect for object presentation
269 GLViewer_AspectLine* myAspectLine;
271 //! Objet tool tip text
272 QString myToolTipText;
273 //! HTML object tool tip status
274 /*! = true if tool tip text contains HTML tags */
277 //! Object visibke status
280 //!\warning It is for ouv
281 GLViewer_Owner* myOwner;
284 GLViewer_Group* myGroup;
288 //!\warning It is for ouv
289 class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner
292 //!\warning It is for ouv
293 GLViewer_Owner() : SUIT_DataOwner() {}
294 //!\warning It is for ouv
302 #pragma warning ( default:4251 )