Integration of OCCT 6.5.0 from SVN
[occt.git] / src / OpenGl / OpenGl_TextRender.hxx
1 #include <OSD_FontAspect.hxx>
2 #include <InterfaceGraphic_tgl_all.hxx>
3 #include <OpenGl_tgl_all.hxx>
4 #include <InterfaceGraphic_telem.hxx>
5 #include <NCollection_DataMap.hxx>
6 #include <TCollection_AsciiString.hxx>
7 #include <TCollection_HAsciiString.hxx>
8 #include <FTFont.h>
9
10 #define NUM_FONT_SIZES 40
11 #define NUM_CHAR_FONT 1024
12 #define CACHE_SIZE 30
13
14 class OpenGl_TextRender{
15
16 public:
17
18   static OpenGl_TextRender* instance();
19   Tint FindFont ( Tchar*, OSD_FontAspect, Tfloat, Tfloat = 1. , Tfloat = 1.);
20
21   void   StringSize( char *text, GLint *width, GLint *ascent, GLint *descent);
22   void   RenderText( const Standard_Integer id, const char* text);
23   void   RenderText( char*, GLuint, int, GLfloat, GLfloat, GLfloat );
24   void   ExportText( char* str, char* fontname, GLfloat height, GLfloat angle, GLint alingment, GLfloat x, GLfloat y, GLfloat z, GLboolean is2d );
25 #ifdef HAVE_GL2PS
26   static void getGL2PSFontName(char *src_font, char *ps_font);
27 #endif
28   
29 private:
30
31   static int curFont  ;
32   static int curSize  ;
33   static int curScale ;
34   static int curTexFont ; 
35 #ifdef HAVE_GL2PS
36   int alignmentforgl2ps(int Hmode, int Vmode);
37 #endif
38
39   struct FontMapNode 
40   {
41     char*     enumName;
42     char*     FontName;
43     OSD_FontAspect  fontAspect;
44   };
45
46   struct FontEntry
47   {
48     char*     name;
49     char*     xlfd;
50     float     xsizes[NUM_FONT_SIZES];
51     int       count;
52   };
53
54   FontMapNode searchFontInMap( Handle(TCollection_HAsciiString)& fontName );
55
56   static FontMapNode  fontMap[];
57   static FontEntry    fontEntry[];
58
59   OpenGl_TextRender();
60   OpenGl_TextRender( const OpenGl_TextRender& ){};
61   OpenGl_TextRender& operator = ( const OpenGl_TextRender&){ return *this;};
62  ~OpenGl_TextRender(){};
63
64
65   struct OGLFont_Cache 
66   {
67     FTFont*            Font;
68     Standard_Integer   FontHeight;
69     GLCONTEXT          GlContext;
70   };
71
72   typedef NCollection_DataMap<Standard_Integer,OGLFont_Cache> FontCache;
73   FontCache               _FontCache;
74   Standard_Integer        _CurrentFontId;
75   Standard_ShortReal      _XCurrentScale,
76                           _YCurrentScale; 
77
78 };