1 // File: GLViewer_Drawer.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 #ifndef GLVIEWER_DRAWER_H
7 #define GLVIEWER_DRAWER_H
22 #include "GLViewer_Defs.h"
24 class GLViewer_Object;
26 class GLViewer_CoordSystem;
29 #pragma warning( disable:4251 )
32 * Struct GLViewer_TexIdStored
33 * Structure for store information about texture
35 struct GLVIEWER_API GLViewer_TexIdStored
46 * Struct GLViewer_TexFindId
47 * Structure for srorage information about texture font
49 struct GLVIEWER_API GLViewer_TexFindId
55 //! Overloaded operator for using struct as MAP key
56 bool operator < (const GLViewer_TexFindId theStruct) const
58 if ( myViewPortId != theStruct.myViewPortId ) return myViewPortId < theStruct.myViewPortId;
59 else return myFontString < theStruct.myFontString;
63 /***************************************************************************
64 ** Class: GLViewer_TexFont
65 ** Descr: Font for GLViewer_Drawer
67 ** Created: UI team, 03.10.01
68 ****************************************************************************/
71 * Class GLViewer_TexFont
72 * Drawing bitmap and texture fonts in GLViewer
74 class GLVIEWER_API GLViewer_TexFont
77 //! A default constructor
81 * \param theFont - a base font
82 * \param theSeparator - separator between letters
84 GLViewer_TexFont( QFont* theFont, int theSeparator = 2 );
88 //! Generating font texture
89 void generateTexture();
90 //! Drawing string theStr in point with coords theX and theY
91 void drawString( QString theStr, GLdouble theX = 0.0, GLdouble theY = 0.0 );
93 //! Returns separator between letters
94 int getSeparator(){ return mySeparator; }
95 //! Installing separator between letters
96 void setSeparator( int theSeparator ){ mySeparator = theSeparator; }
98 //! Returns width of string in pixels
99 int getStringWidth( QString theString );
100 //! Returns height of string in pixels
101 int getStringHeight();
103 //! Clears all generated fonts
104 static void clearTextBases();
106 //! Map for strorage generated texture fonts
107 static QMap<GLViewer_TexFindId,GLViewer_TexIdStored> TexFontBase;
108 //! Map for strorage generated bitmaps fonts
109 static QMap<GLViewer_TexFindId,GLuint> BitmapFontCache;
112 //! Array of letter width
114 //! Array of letter positions in texture
116 //! Pointer to base font
120 //! Font texture width
122 //! Font texture height
124 //! Separator between letters
128 /***************************************************************************
129 ** Class: GLViewer_Drawer
130 ** Descr: Drawer for GLObject
132 ** Created: UI team, 03.10.01
133 ****************************************************************************/
135 * Class GLViewer_Drawer
136 * Drawer for GLViewer_Objects.
137 * Drawer creates only one times per one type of object
139 class GLVIEWER_API GLViewer_Drawer
142 //! Text position relatively object
152 // Objects status ( needs for change colors )
170 virtual ~GLViewer_Drawer();
172 //! Main method which drawing object in GLViewer
174 *\param xScale - current scale along X-direction
175 *\param yScale - current scale along Y-direction
176 *\param onlyUpdate - = true if only update highlight-select information
178 virtual void create( float xScale, float yScale, bool onlyUpdate ) = 0;
180 //! Adds object to drawer display list
181 virtual void addObject( GLViewer_Object* theObject ){ myObjects.append( theObject ); }
182 //! Clears drawer display list
183 virtual void clear(){ myObjects.clear(); }
185 //! Returns object type (needs for dynamic search of right drawer )
186 QString getObjectType() const { return myObjectType; }
188 //! Returns object priority
189 int getPriority() const { return myPriority; }
191 //! The function enables and disables antialiasing in Open GL (for points, lines and polygons).
192 void setAntialiasing(const bool on);
194 //! Clears all generated textures
195 static void destroyAllTextures();
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 );
205 //! A function translate object in to PostScript file on disk
207 *\param hFile the name of PostScript file chosen by user
208 *\param aViewerCS the GLViewer_CoordSystem of window
209 *\param aPSCS the GLViewer_CoordSystem of PostScript page
211 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
214 //! A function translate object in to EMF file on disk
218 *\param dc the name of HDC associated with file chosen by user
219 *\param aViewerCS the GLViewer_CoordSystem of window
220 *\param aEMFCS the GLViewer_CoordSystem of EMF page
222 virtual bool translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
225 //! Loads texture from file
226 static GLuint loadTexture( const QString& fileName );
228 //! Draw square texture
230 *\param texture - the texture ID
231 *\param size - the size of texture
235 void drawTexture( GLuint texture, GLint size, GLfloat x, GLfloat y );
239 *\param text - the text string
240 *\param xPos - x coord
241 *\param yPos - y coord
242 *\param color - text color
243 *\param aFont - base font of text
244 *\param theSeparator - letter separator
245 *\param DisplayTextFormat - text format
247 void drawText( const QString& text,
253 DisplayTextFormat = DTF_BITMAP );
257 *\param text - the text string
260 *\param hPosition - horizontal alignment
261 *\param vPosition - vertical alignment
262 *\param color - text color
263 *\param smallFont - font format
265 void drawGLText( QString text,
268 int hPosition = GLText_Center,
269 int vPosition = GLText_Center,
270 QColor color = Qt::black,
271 bool smallFont = false );
273 //! Draw rectangle with predefined color
274 static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black );
278 virtual void drawText( GLViewer_Object* theObject );
286 QValueList<GLViewer_Object*> myObjects;
287 //! List generated textures
290 //! Type of supporting object
291 QString myObjectType;
297 #pragma warning ( default:4251 )
300 #endif // GLVIEWER_DRAWER_H