Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-09-20 |
2 | // Created by: Sergey ZERCHANINOV | |
3 | // Copyright (c) 2011-2012 OPEN CASCADE SAS | |
4 | // | |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
2166f0fa SK |
20 | |
21 | #ifndef _OpenGl_Display_Header | |
22 | #define _OpenGl_Display_Header | |
23 | ||
24 | #include <Handle_OpenGl_Display.hxx> | |
25 | #include <MMgt_TShared.hxx> | |
26 | ||
27 | #include <Standard_CString.hxx> | |
28 | #include <TColStd_HArray1OfByte.hxx> | |
29 | #include <NCollection_DataMap.hxx> | |
30 | ||
31 | #include <Aspect_Display.hxx> | |
32 | #include <Aspect_Drawable.hxx> | |
33 | #include <Aspect_TypeOfLine.hxx> | |
34 | #include <Aspect_TypeOfMarker.hxx> | |
35 | ||
eeaaaefb | 36 | #include <Font_FontAspect.hxx> |
2166f0fa SK |
37 | |
38 | #include <InterfaceGraphic_telem.hxx> | |
39 | ||
40 | #include <Handle_OpenGl_Window.hxx> | |
41 | ||
42 | struct OpenGl_Facilities | |
43 | { | |
44 | int AntiAliasing; | |
45 | int DepthCueing; | |
46 | int DoubleBuffer; | |
47 | int ZBuffer; | |
48 | int MaxLights; | |
49 | int MaxViews; | |
50 | }; | |
51 | ||
52 | struct OPENGL_MARKER_DATA | |
53 | { | |
54 | unsigned int ListId; | |
55 | unsigned int Width; | |
56 | unsigned int Height; | |
57 | unsigned char* Array; | |
1c35b92f | 58 | DEFINE_STANDARD_ALLOC |
2166f0fa SK |
59 | }; |
60 | ||
61 | typedef NCollection_DataMap<int,OPENGL_MARKER_DATA> OpenGl_MapOfUserMarker; | |
62 | ||
63 | class OpenGl_AspectText; | |
64 | struct OpenGl_TextParam; | |
65 | ||
66 | class OpenGl_Display : public MMgt_TShared | |
67 | { | |
68 | public: | |
69 | OpenGl_Display (const Standard_CString ADisplay); | |
70 | OpenGl_Display (const Aspect_Display ADisplay); | |
71 | virtual ~OpenGl_Display (); | |
72 | ||
73 | Aspect_Display GetDisplay () const { return myDisplay; } | |
74 | ||
75 | Handle(OpenGl_Window) GetWindow (const Aspect_Drawable AParent) const; | |
76 | void SetWindow (const Aspect_Drawable AParent, const Handle(OpenGl_Window) &AWindow); | |
77 | ||
78 | const OpenGl_Facilities & Facilities () const { return myFacilities; } | |
79 | ||
80 | Standard_Boolean DBuffer () const { return myDBuffer; } | |
81 | Standard_Boolean Dither () const { return myDither; } | |
82 | Standard_Boolean BackDither () const { return myBackDither; } | |
83 | Standard_Boolean Walkthrough () const { return myWalkthrough; } | |
84 | Standard_Boolean SymPerspective() const { return mySymPerspective; } | |
85 | Standard_Boolean PolygonOffset (Standard_ShortReal &AFactor, Standard_ShortReal &AUnits) const | |
86 | { | |
87 | AFactor = myOffsetFactor; | |
88 | AUnits = myOffsetUnits; | |
89 | return Standard_True; | |
90 | } | |
91 | Standard_Integer AntiAliasingMode () const { return myAntiAliasingMode; } | |
92 | ||
93 | // System attributes | |
94 | ||
95 | void InitAttributes (); | |
96 | ||
97 | const char * GetStringForMarker (const Aspect_TypeOfMarker AType, const Tfloat AVal) const; | |
98 | ||
99 | void SetBaseForMarker () const; | |
100 | ||
101 | void SetTypeOfLine (const Aspect_TypeOfLine AType) const; | |
102 | ||
103 | void SetTypeOfHatch (const int AType) const; | |
104 | ||
105 | // User markers | |
106 | ||
107 | void AddUserMarker (const Standard_Integer AIndex, | |
108 | const Standard_Integer AMarkWidth, | |
109 | const Standard_Integer AMarkHeight, | |
110 | const Handle(TColStd_HArray1OfByte)& ATexture); | |
111 | ||
112 | void UpdateUserMarkers (); | |
113 | ||
114 | Standard_Integer GetUserMarkerListIndex (const Standard_Integer AIndex) const; | |
115 | ||
116 | // Fonts | |
117 | ||
eeaaaefb | 118 | int FindFont (const char* AFontName, const Font_FontAspect AFontAspect, const int ABestSize = -1, const float AXScale = 1.F, const float AYScale = 1.F); |
2166f0fa SK |
119 | |
120 | void StringSize (const wchar_t *text, int &width, int &ascent, int &descent); | |
121 | ||
122 | void RenderText (const wchar_t *text, const int is2d, const float x, const float y, const float z, const OpenGl_AspectText *aspect, const OpenGl_TextParam *param); | |
123 | ||
124 | friend class OpenGl_Window; | |
125 | ||
126 | // Type definition | |
127 | // | |
128 | DEFINE_STANDARD_RTTI(OpenGl_Display) | |
129 | ||
130 | protected: | |
131 | ||
132 | void Init (); | |
133 | ||
c320e557 | 134 | void ExportText (const wchar_t *text, const int is2d, const float x, const float y, const float z, const OpenGl_AspectText *aspect, const OpenGl_TextParam *param, const short height); |
2166f0fa SK |
135 | |
136 | #ifdef HAVE_GL2PS | |
137 | static void getGL2PSFontName(const char *src_font, char *ps_font); | |
138 | #endif | |
139 | ||
140 | Aspect_Display myDisplay; | |
141 | OpenGl_Facilities myFacilities; | |
142 | ||
143 | Standard_Boolean myDBuffer; | |
144 | Standard_Boolean myDither; | |
145 | Standard_Boolean myBackDither; | |
146 | Standard_Boolean myWalkthrough; | |
147 | Standard_Boolean mySymPerspective; | |
148 | Standard_ShortReal myOffsetFactor; | |
149 | Standard_ShortReal myOffsetUnits; | |
150 | Standard_Integer myAntiAliasingMode; | |
151 | ||
152 | #if (defined(_WIN32) || defined(__WIN32__)) | |
153 | NCollection_DataMap<Aspect_Drawable, Handle(OpenGl_Window)> myMapOfWindows; | |
154 | #else | |
155 | NCollection_DataMap<Standard_Integer, Handle(OpenGl_Window)> myMapOfWindows; | |
156 | #endif | |
157 | ||
158 | unsigned int myLinestyleBase; | |
159 | unsigned int myPatternBase; | |
160 | unsigned int myMarkerBase; | |
161 | ||
162 | OpenGl_MapOfUserMarker myMapOfUM; | |
163 | ||
164 | Standard_Integer myFont; | |
165 | Standard_Integer myFontSize; | |
166 | ||
167 | public: | |
1c35b92f | 168 | DEFINE_STANDARD_ALLOC |
2166f0fa SK |
169 | }; |
170 | ||
171 | extern Handle(OpenGl_Display) openglDisplay; | |
172 | ||
173 | #endif //OpenGl_Workspace_Header |