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 //! Clears all generated textures
192 static void destroyAllTextures();
194 //! A function translate object in to HPGL file on disk
196 *\param hFile the name of PostScript file chosen by user
197 *\param aViewerCS the GLViewer_CoordSystem of window
198 *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
200 virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );
202 //! A function translate object in to PostScript file on disk
204 *\param hFile the name of PostScript file chosen by user
205 *\param aViewerCS the GLViewer_CoordSystem of window
206 *\param aPSCS the GLViewer_CoordSystem of PostScript page
208 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
211 //! A function translate object in to EMF file on disk
215 *\param dc the name of HDC associated with file chosen by user
216 *\param aViewerCS the GLViewer_CoordSystem of window
217 *\param aEMFCS the GLViewer_CoordSystem of EMF page
219 virtual bool translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
222 //! Loads texture from file
223 static GLuint loadTexture( const QString& fileName );
225 //! Draw square texture
227 *\param texture - the texture ID
228 *\param size - the size of texture
232 void drawTexture( GLuint texture, GLint size, GLfloat x, GLfloat y );
236 *\param text - the text string
237 *\param xPos - x coord
238 *\param yPos - y coord
239 *\param color - text color
240 *\param aFont - base font of text
241 *\param theSeparator - letter separator
242 *\param DisplayTextFormat - text format
244 void drawText( const QString& text,
250 DisplayTextFormat = DTF_BITMAP );
254 *\param text - the text string
257 *\param hPosition - horizontal alignment
258 *\param vPosition - vertical alignment
259 *\param color - text color
260 *\param smallFont - font format
262 void drawGLText( QString text,
265 int hPosition = GLText_Center,
266 int vPosition = GLText_Center,
267 QColor color = Qt::black,
268 bool smallFont = false );
270 //! Draw rectangle with predefined color
271 static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black );
275 virtual void drawText( GLViewer_Object* theObject );
283 QValueList<GLViewer_Object*> myObjects;
284 //! List generated textures
287 //! Type of supporting object
288 QString myObjectType;
294 #pragma warning ( default:4251 )
297 #endif // GLVIEWER_DRAWER_H