a261f0f98b6d0f212e5c1874a571c8c92a8a7038
[occt.git] / src / OpenGl / OpenGl_AspectMarker.cxx
1 // Created on: 2011-07-14
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
20 #include <OpenGl_AspectMarker.hxx>
21 #include <OpenGl_Context.hxx>
22 #include <OpenGl_GraphicDriver.hxx>
23 #include <OpenGl_PointSprite.hxx>
24 #include <OpenGl_Workspace.hxx>
25
26 #include <Image_PixMap.hxx>
27 #include <Graphic3d_MarkerImage.hxx>
28 #include <NCollection_Vec4.hxx>
29
30 static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
31
32 // Following Section relates to default markers
33
34 #define TEL_NO_OF_SIZES 13
35 #define TEL_PM_START_SIZE 1.0
36 #define TEL_PM_END_SIZE   7.0
37
38 struct PM_FONT_INFO
39 {
40   Tfloat width, height;
41   Tint offset;
42 };
43 typedef PM_FONT_INFO* pm_font_info;
44
45 #define PM_PLUS_10_NUM  9*2
46 #define PM_PLUS_15_NUM  11*2
47 #define PM_PLUS_20_NUM  13*2
48 #define PM_PLUS_25_NUM  15*2
49 #define PM_PLUS_30_NUM  17*3
50 #define PM_PLUS_35_NUM  19*3
51 #define PM_PLUS_40_NUM  21*3
52 #define PM_PLUS_45_NUM  23*3
53 #define PM_PLUS_50_NUM  25*4
54 #define PM_PLUS_55_NUM  27*4
55 #define PM_PLUS_60_NUM  29*4
56 #define PM_PLUS_65_NUM  31*4
57 #define PM_PLUS_70_NUM  32*4
58
59 #define PM_STAR_10_NUM  9
60 #define PM_STAR_15_NUM  11*2
61 #define PM_STAR_20_NUM  13*2
62 #define PM_STAR_25_NUM  15*2
63 #define PM_STAR_30_NUM  17*2
64 #define PM_STAR_35_NUM  19*2
65 #define PM_STAR_40_NUM  21*3
66 #define PM_STAR_45_NUM  23*3
67 #define PM_STAR_50_NUM  25*3
68 #define PM_STAR_55_NUM  27*3
69 #define PM_STAR_60_NUM  29*4
70 #define PM_STAR_65_NUM  32*4
71 #define PM_STAR_70_NUM  32*4
72
73 #define PM_CIRC_10_NUM  7
74 #define PM_CIRC_15_NUM  9*2
75 #define PM_CIRC_20_NUM  9*2
76 #define PM_CIRC_25_NUM  11*2
77 #define PM_CIRC_30_NUM  13*2
78 #define PM_CIRC_35_NUM  15*2
79 #define PM_CIRC_40_NUM  17*3
80 #define PM_CIRC_45_NUM  19*3
81 #define PM_CIRC_50_NUM  21*3
82 #define PM_CIRC_55_NUM  23*3
83 #define PM_CIRC_60_NUM  25*4
84 #define PM_CIRC_65_NUM  27*4
85 #define PM_CIRC_70_NUM  29*4
86
87 #define PM_CROSS_10_NUM 7
88 #define PM_CROSS_15_NUM 9*2
89 #define PM_CROSS_20_NUM 11*2
90 #define PM_CROSS_25_NUM 13*2
91 #define PM_CROSS_30_NUM 15*2
92 #define PM_CROSS_35_NUM 17*3
93 #define PM_CROSS_40_NUM 19*3
94 #define PM_CROSS_45_NUM 21*3
95 #define PM_CROSS_50_NUM 23*3
96 #define PM_CROSS_55_NUM 25*4
97 #define PM_CROSS_60_NUM 27*4
98 #define PM_CROSS_65_NUM 32*4
99 #define PM_CROSS_70_NUM 32*4
100
101 #define PM_PLUS_10_OFT  0
102 #define PM_PLUS_15_OFT  PM_PLUS_10_OFT + PM_PLUS_10_NUM
103 #define PM_PLUS_20_OFT  PM_PLUS_15_OFT + PM_PLUS_15_NUM
104 #define PM_PLUS_25_OFT  PM_PLUS_20_OFT + PM_PLUS_20_NUM
105 #define PM_PLUS_30_OFT  PM_PLUS_25_OFT + PM_PLUS_25_NUM
106 #define PM_PLUS_35_OFT  PM_PLUS_30_OFT + PM_PLUS_30_NUM
107 #define PM_PLUS_40_OFT  PM_PLUS_35_OFT + PM_PLUS_35_NUM
108 #define PM_PLUS_45_OFT  PM_PLUS_40_OFT + PM_PLUS_40_NUM
109 #define PM_PLUS_50_OFT  PM_PLUS_45_OFT + PM_PLUS_45_NUM
110 #define PM_PLUS_55_OFT  PM_PLUS_50_OFT + PM_PLUS_50_NUM
111 #define PM_PLUS_60_OFT  PM_PLUS_55_OFT + PM_PLUS_55_NUM
112 #define PM_PLUS_65_OFT  PM_PLUS_60_OFT + PM_PLUS_60_NUM
113 #define PM_PLUS_70_OFT  PM_PLUS_65_OFT + PM_PLUS_65_NUM
114
115 #define PM_STAR_10_OFT  PM_PLUS_70_OFT + PM_PLUS_70_NUM
116 #define PM_STAR_15_OFT  PM_STAR_10_OFT + PM_STAR_10_NUM
117 #define PM_STAR_20_OFT  PM_STAR_15_OFT + PM_STAR_15_NUM
118 #define PM_STAR_25_OFT  PM_STAR_20_OFT + PM_STAR_20_NUM
119 #define PM_STAR_30_OFT  PM_STAR_25_OFT + PM_STAR_25_NUM
120 #define PM_STAR_35_OFT  PM_STAR_30_OFT + PM_STAR_30_NUM
121 #define PM_STAR_40_OFT  PM_STAR_35_OFT + PM_STAR_35_NUM
122 #define PM_STAR_45_OFT  PM_STAR_40_OFT + PM_STAR_40_NUM
123 #define PM_STAR_50_OFT  PM_STAR_45_OFT + PM_STAR_45_NUM
124 #define PM_STAR_55_OFT  PM_STAR_50_OFT + PM_STAR_50_NUM
125 #define PM_STAR_60_OFT  PM_STAR_55_OFT + PM_STAR_55_NUM
126 #define PM_STAR_65_OFT  PM_STAR_60_OFT + PM_STAR_60_NUM
127 #define PM_STAR_70_OFT  PM_STAR_65_OFT + PM_STAR_65_NUM
128
129 #define PM_CIRC_10_OFT  PM_STAR_70_OFT + PM_STAR_70_NUM
130 #define PM_CIRC_15_OFT  PM_CIRC_10_OFT + PM_CIRC_10_NUM
131 #define PM_CIRC_20_OFT  PM_CIRC_15_OFT + PM_CIRC_15_NUM
132 #define PM_CIRC_25_OFT  PM_CIRC_20_OFT + PM_CIRC_20_NUM
133 #define PM_CIRC_30_OFT  PM_CIRC_25_OFT + PM_CIRC_25_NUM
134 #define PM_CIRC_35_OFT  PM_CIRC_30_OFT + PM_CIRC_30_NUM
135 #define PM_CIRC_40_OFT  PM_CIRC_35_OFT + PM_CIRC_35_NUM
136 #define PM_CIRC_45_OFT  PM_CIRC_40_OFT + PM_CIRC_40_NUM
137 #define PM_CIRC_50_OFT  PM_CIRC_45_OFT + PM_CIRC_45_NUM
138 #define PM_CIRC_55_OFT  PM_CIRC_50_OFT + PM_CIRC_50_NUM
139 #define PM_CIRC_60_OFT  PM_CIRC_55_OFT + PM_CIRC_55_NUM
140 #define PM_CIRC_65_OFT  PM_CIRC_60_OFT + PM_CIRC_60_NUM
141 #define PM_CIRC_70_OFT  PM_CIRC_65_OFT + PM_CIRC_65_NUM
142
143 #define PM_CROSS_10_OFT  PM_CIRC_70_OFT + PM_CIRC_70_NUM
144 #define PM_CROSS_15_OFT  PM_CROSS_10_OFT + PM_CROSS_10_NUM
145 #define PM_CROSS_20_OFT  PM_CROSS_15_OFT + PM_CROSS_15_NUM
146 #define PM_CROSS_25_OFT  PM_CROSS_20_OFT + PM_CROSS_20_NUM
147 #define PM_CROSS_30_OFT  PM_CROSS_25_OFT + PM_CROSS_25_NUM
148 #define PM_CROSS_35_OFT  PM_CROSS_30_OFT + PM_CROSS_30_NUM
149 #define PM_CROSS_40_OFT  PM_CROSS_35_OFT + PM_CROSS_35_NUM
150 #define PM_CROSS_45_OFT  PM_CROSS_40_OFT + PM_CROSS_40_NUM
151 #define PM_CROSS_50_OFT  PM_CROSS_45_OFT + PM_CROSS_45_NUM
152 #define PM_CROSS_55_OFT  PM_CROSS_50_OFT + PM_CROSS_50_NUM
153 #define PM_CROSS_60_OFT  PM_CROSS_55_OFT + PM_CROSS_55_NUM
154 #define PM_CROSS_65_OFT  PM_CROSS_60_OFT + PM_CROSS_60_NUM
155 #define PM_CROSS_70_OFT  PM_CROSS_65_OFT + PM_CROSS_65_NUM
156
157 static const PM_FONT_INFO arrPMFontInfo[][TEL_NO_OF_SIZES] =
158 {
159  // TOM_POINT - not used
160  {{0},
161   {0},
162   {0},
163   {0},
164   {0},
165   {0},
166   {0},
167   {0},
168   {0},
169   {0},
170   {0},
171   {0},
172   {0}},
173
174  // TOM_PLUS
175  {{ 9.f,  9.f, PM_PLUS_10_OFT},
176   {11.f, 11.f, PM_PLUS_15_OFT},
177   {13.f, 13.f, PM_PLUS_20_OFT},
178   {15.f, 15.f, PM_PLUS_25_OFT},
179   {17.f, 17.f, PM_PLUS_30_OFT},
180   {19.f, 19.f, PM_PLUS_35_OFT},
181   {21.f, 21.f, PM_PLUS_40_OFT},
182   {23.f, 23.f, PM_PLUS_45_OFT},
183   {25.f, 25.f, PM_PLUS_50_OFT},
184   {27.f, 27.f, PM_PLUS_55_OFT},
185   {29.f, 29.f, PM_PLUS_60_OFT},
186   {31.f, 31.f, PM_PLUS_65_OFT},
187   {32.f, 32.f, PM_PLUS_70_OFT}},
188
189  // TOM_STAR
190  {{ 7.f,  9.f, PM_STAR_10_OFT},
191   {9.f,  11.f, PM_STAR_15_OFT},
192   {11.f, 13.f, PM_STAR_20_OFT},
193   {13.f, 15.f, PM_STAR_25_OFT},
194   {13.f, 17.f, PM_STAR_30_OFT},
195   {15.f, 19.f, PM_STAR_35_OFT},
196   {17.f, 21.f, PM_STAR_40_OFT},
197   {19.f, 23.f, PM_STAR_45_OFT},
198   {21.f, 25.f, PM_STAR_50_OFT},
199   {23.f, 27.f, PM_STAR_55_OFT},
200   {25.f, 29.f, PM_STAR_60_OFT},
201   {32.f, 32.f, PM_STAR_65_OFT},
202   {32.f, 32.f, PM_STAR_70_OFT}},
203
204  // TOM_X
205  {{ 7.f,  7.f, PM_CROSS_10_OFT},
206   { 9.f,  9.f, PM_CROSS_15_OFT},
207   {11.f, 11.f, PM_CROSS_20_OFT},
208   {13.f, 13.f, PM_CROSS_25_OFT},
209   {15.f, 15.f, PM_CROSS_30_OFT},
210   {17.f, 17.f, PM_CROSS_35_OFT},
211   {19.f, 19.f, PM_CROSS_40_OFT},
212   {21.f, 21.f, PM_CROSS_45_OFT},
213   {23.f, 23.f, PM_CROSS_50_OFT},
214   {25.f, 25.f, PM_CROSS_55_OFT},
215   {27.f, 27.f, PM_CROSS_60_OFT},
216   {32.f, 32.f, PM_CROSS_65_OFT},
217   {32.f, 32.f, PM_CROSS_70_OFT}},
218
219  // TOM_O
220  {{ 7.f,  7.f, PM_CIRC_10_OFT},
221   { 9.f,  9.f, PM_CIRC_15_OFT},
222   { 9.f,  9.f, PM_CIRC_20_OFT},
223   {11.f, 11.f, PM_CIRC_25_OFT},
224   {13.f, 13.f, PM_CIRC_30_OFT},
225   {15.f, 15.f, PM_CIRC_35_OFT},
226   {17.f, 17.f, PM_CIRC_40_OFT},
227   {19.f, 19.f, PM_CIRC_45_OFT},
228   {21.f, 21.f, PM_CIRC_50_OFT},
229   {23.f, 23.f, PM_CIRC_55_OFT},
230   {25.f, 25.f, PM_CIRC_60_OFT},
231   {27.f, 27.f, PM_CIRC_65_OFT},
232   {29.f, 29.f, PM_CIRC_70_OFT}}
233 };
234
235 static const Standard_Byte OpenGl_AspectMarker_myMarkerRaster[] =
236 {
237     // TYPE = PLUS
238
239     0x08,0x00,
240     0x08,0x00,
241     0x08,0x00,
242     0x08,0x00,
243     0xff,0x80,
244     0x08,0x00,
245     0x08,0x00,
246     0x08,0x00,
247     0x08,0x00, // PLUS 9x9 = 1.0
248
249     0x04,0x00,
250     0x04,0x00,
251     0x04,0x00,
252     0x04,0x00,
253     0x04,0x00,
254     0xff,0xe0,
255     0x04,0x00,
256     0x04,0x00,
257     0x04,0x00,
258     0x04,0x00,
259     0x04,0x00, // PLUS 11x11 = 1.5
260
261     0x02,0x00,
262     0x02,0x00,
263     0x02,0x00,
264     0x02,0x00,
265     0x02,0x00,
266     0x02,0x00,
267     0xff,0xf8,
268     0x02,0x00,
269     0x02,0x00,
270     0x02,0x00,
271     0x02,0x00,
272     0x02,0x00,
273     0x02,0x00, // PLUS 13x13 = 2.0
274
275     0x01,0x00,
276     0x01,0x00,
277     0x01,0x00,
278     0x01,0x00,
279     0x01,0x00,
280     0x01,0x00,
281     0x01,0x00,
282     0xff,0xfe,
283     0x01,0x00,
284     0x01,0x00,
285     0x01,0x00,
286     0x01,0x00,
287     0x01,0x00,
288     0x01,0x00,
289     0x01,0x00, // PLUS 15x15 = 2.5
290
291     0x00,0x80, 0x00,
292     0x00,0x80, 0x00,
293     0x00,0x80, 0x00,
294     0x00,0x80, 0x00,
295     0x00,0x80, 0x00,
296     0x00,0x80, 0x00,
297     0x00,0x80, 0x00,
298     0x00,0x80, 0x00,
299     0xff,0xff, 0x80,
300     0x00,0x80, 0x00,
301     0x00,0x80, 0x00,
302     0x00,0x80, 0x00,
303     0x00,0x80, 0x00,
304     0x00,0x80, 0x00,
305     0x00,0x80, 0x00,
306     0x00,0x80, 0x00,
307     0x00,0x80, 0x00, // PLUS 17x17 = 3.0
308
309     0x00,0x40, 0x00,
310     0x00,0x40, 0x00,
311     0x00,0x40, 0x00,
312     0x00,0x40, 0x00,
313     0x00,0x40, 0x00,
314     0x00,0x40, 0x00,
315     0x00,0x40, 0x00,
316     0x00,0x40, 0x00,
317     0x00,0x40, 0x00,
318     0xff,0xff, 0xe0,
319     0x00,0x40, 0x00,
320     0x00,0x40, 0x00,
321     0x00,0x40, 0x00,
322     0x00,0x40, 0x00,
323     0x00,0x40, 0x00,
324     0x00,0x40, 0x00,
325     0x00,0x40, 0x00,
326     0x00,0x40, 0x00,
327     0x00,0x40, 0x00, // PLUS 19x19 = 3.5
328
329     0x00,0x20, 0x00,
330     0x00,0x20, 0x00,
331     0x00,0x20, 0x00,
332     0x00,0x20, 0x00,
333     0x00,0x20, 0x00,
334     0x00,0x20, 0x00,
335     0x00,0x20, 0x00,
336     0x00,0x20, 0x00,
337     0x00,0x20, 0x00,
338     0x00,0x20, 0x00,
339     0xff,0xff, 0xf8,
340     0x00,0x20, 0x00,
341     0x00,0x20, 0x00,
342     0x00,0x20, 0x00,
343     0x00,0x20, 0x00,
344     0x00,0x20, 0x00,
345     0x00,0x20, 0x00,
346     0x00,0x20, 0x00,
347     0x00,0x20, 0x00,
348     0x00,0x20, 0x00,
349     0x00,0x20, 0x00, // PLUS 21x21 = 4.0
350
351     0x00,0x10, 0x00,
352     0x00,0x10, 0x00,
353     0x00,0x10, 0x00,
354     0x00,0x10, 0x00,
355     0x00,0x10, 0x00,
356     0x00,0x10, 0x00,
357     0x00,0x10, 0x00,
358     0x00,0x10, 0x00,
359     0x00,0x10, 0x00,
360     0x00,0x10, 0x00,
361     0x00,0x10, 0x00,
362     0xff,0xff, 0xfe,
363     0x00,0x10, 0x00,
364     0x00,0x10, 0x00,
365     0x00,0x10, 0x00,
366     0x00,0x10, 0x00,
367     0x00,0x10, 0x00,
368     0x00,0x10, 0x00,
369     0x00,0x10, 0x00,
370     0x00,0x10, 0x00,
371     0x00,0x10, 0x00,
372     0x00,0x10, 0x00,
373     0x00,0x10, 0x00, // PLUS 23x23 = 4.5
374
375     0x00,0x08, 0x00,0x00,
376     0x00,0x08, 0x00,0x00,
377     0x00,0x08, 0x00,0x00,
378     0x00,0x08, 0x00,0x00,
379     0x00,0x08, 0x00,0x00,
380     0x00,0x08, 0x00,0x00,
381     0x00,0x08, 0x00,0x00,
382     0x00,0x08, 0x00,0x00,
383     0x00,0x08, 0x00,0x00,
384     0x00,0x08, 0x00,0x00,
385     0x00,0x08, 0x00,0x00,
386     0x00,0x08, 0x00,0x00,
387     0xff,0xff, 0xff,0x80,
388     0x00,0x08, 0x00,0x00,
389     0x00,0x08, 0x00,0x00,
390     0x00,0x08, 0x00,0x00,
391     0x00,0x08, 0x00,0x00,
392     0x00,0x08, 0x00,0x00,
393     0x00,0x08, 0x00,0x00,
394     0x00,0x08, 0x00,0x00,
395     0x00,0x08, 0x00,0x00,
396     0x00,0x08, 0x00,0x00,
397     0x00,0x08, 0x00,0x00,
398     0x00,0x08, 0x00,0x00,
399     0x00,0x08, 0x00,0x00, // PLUS 25x25 = 5.0
400
401     0x00,0x04, 0x00,0x00,
402     0x00,0x04, 0x00,0x00,
403     0x00,0x04, 0x00,0x00,
404     0x00,0x04, 0x00,0x00,
405     0x00,0x04, 0x00,0x00,
406     0x00,0x04, 0x00,0x00,
407     0x00,0x04, 0x00,0x00,
408     0x00,0x04, 0x00,0x00,
409     0x00,0x04, 0x00,0x00,
410     0x00,0x04, 0x00,0x00,
411     0x00,0x04, 0x00,0x00,
412     0x00,0x04, 0x00,0x00,
413     0x00,0x04, 0x00,0x00,
414     0xff,0xff, 0xff,0xe0,
415     0x00,0x04, 0x00,0x00,
416     0x00,0x04, 0x00,0x00,
417     0x00,0x04, 0x00,0x00,
418     0x00,0x04, 0x00,0x00,
419     0x00,0x04, 0x00,0x00,
420     0x00,0x04, 0x00,0x00,
421     0x00,0x04, 0x00,0x00,
422     0x00,0x04, 0x00,0x00,
423     0x00,0x04, 0x00,0x00,
424     0x00,0x04, 0x00,0x00,
425     0x00,0x04, 0x00,0x00,
426     0x00,0x04, 0x00,0x00,
427     0x00,0x04, 0x00,0x00, // PLUS 27x27 = 5.5
428
429     0x00,0x02, 0x00,0x00,
430     0x00,0x02, 0x00,0x00,
431     0x00,0x02, 0x00,0x00,
432     0x00,0x02, 0x00,0x00,
433     0x00,0x02, 0x00,0x00,
434     0x00,0x02, 0x00,0x00,
435     0x00,0x02, 0x00,0x00,
436     0x00,0x02, 0x00,0x00,
437     0x00,0x02, 0x00,0x00,
438     0x00,0x02, 0x00,0x00,
439     0x00,0x02, 0x00,0x00,
440     0x00,0x02, 0x00,0x00,
441     0x00,0x02, 0x00,0x00,
442     0x00,0x02, 0x00,0x00,
443     0xff,0xff, 0xff,0xf8,
444     0x00,0x02, 0x00,0x00,
445     0x00,0x02, 0x00,0x00,
446     0x00,0x02, 0x00,0x00,
447     0x00,0x02, 0x00,0x00,
448     0x00,0x02, 0x00,0x00,
449     0x00,0x02, 0x00,0x00,
450     0x00,0x02, 0x00,0x00,
451     0x00,0x02, 0x00,0x00,
452     0x00,0x02, 0x00,0x00,
453     0x00,0x02, 0x00,0x00,
454     0x00,0x02, 0x00,0x00,
455     0x00,0x02, 0x00,0x00,
456     0x00,0x02, 0x00,0x00,
457     0x00,0x02, 0x00,0x00, // PLUS 29x29 = 6.0
458
459     0x00,0x01, 0x00,0x00,
460     0x00,0x01, 0x00,0x00,
461     0x00,0x01, 0x00,0x00,
462     0x00,0x01, 0x00,0x00,
463     0x00,0x01, 0x00,0x00,
464     0x00,0x01, 0x00,0x00,
465     0x00,0x01, 0x00,0x00,
466     0x00,0x01, 0x00,0x00,
467     0x00,0x01, 0x00,0x00,
468     0x00,0x01, 0x00,0x00,
469     0x00,0x01, 0x00,0x00,
470     0x00,0x01, 0x00,0x00,
471     0x00,0x01, 0x00,0x00,
472     0x00,0x01, 0x00,0x00,
473     0x00,0x01, 0x00,0x00,
474     0xff,0xff, 0xff,0xfd,
475     0x00,0x01, 0x00,0x00,
476     0x00,0x01, 0x00,0x00,
477     0x00,0x01, 0x00,0x00,
478     0x00,0x01, 0x00,0x00,
479     0x00,0x01, 0x00,0x00,
480     0x00,0x01, 0x00,0x00,
481     0x00,0x01, 0x00,0x00,
482     0x00,0x01, 0x00,0x00,
483     0x00,0x01, 0x00,0x00,
484     0x00,0x01, 0x00,0x00,
485     0x00,0x01, 0x00,0x00,
486     0x00,0x01, 0x00,0x00,
487     0x00,0x01, 0x00,0x00,
488     0x00,0x01, 0x00,0x00,
489     0x00,0x01, 0x00,0x00, // PLUS 31x31 = 6.5
490
491     0x00,0x00, 0x80,0x00,
492     0x00,0x00, 0x80,0x00,
493     0x00,0x00, 0x80,0x00,
494     0x00,0x00, 0x80,0x00,
495     0x00,0x00, 0x80,0x00,
496     0x00,0x00, 0x80,0x00,
497     0x00,0x00, 0x80,0x00,
498     0x00,0x00, 0x80,0x00,
499     0x00,0x00, 0x80,0x00,
500     0x00,0x00, 0x80,0x00,
501     0x00,0x00, 0x80,0x00,
502     0x00,0x00, 0x80,0x00,
503     0x00,0x00, 0x80,0x00,
504     0x00,0x00, 0x80,0x00,
505     0x00,0x00, 0x80,0x00,
506     0x00,0x00, 0x80,0x00,
507     0xff,0xff, 0xff,0xff,
508     0x00,0x00, 0x80,0x00,
509     0x00,0x00, 0x80,0x00,
510     0x00,0x00, 0x80,0x00,
511     0x00,0x00, 0x80,0x00,
512     0x00,0x00, 0x80,0x00,
513     0x00,0x00, 0x80,0x00,
514     0x00,0x00, 0x80,0x00,
515     0x00,0x00, 0x80,0x00,
516     0x00,0x00, 0x80,0x00,
517     0x00,0x00, 0x80,0x00,
518     0x00,0x00, 0x80,0x00,
519     0x00,0x00, 0x80,0x00,
520     0x00,0x00, 0x80,0x00,
521     0x00,0x00, 0x80,0x00,
522     0x00,0x00, 0x80,0x00, // PLUS 32x32 = 7.0
523
524     // TYPE = STAR
525
526     0x10,
527     0x10,
528     0xd6,
529     0x38,
530     0x10,
531     0x38,
532     0xd6,
533     0x10,
534     0x10, // STAR 7x9 = 1.0
535
536     0x08,0x00,
537     0x08,0x00,
538     0x08,0x00,
539     0xc9,0x80,
540     0x3e,0x00,
541     0x08,0x00,
542     0x3e,0x00,
543     0xc9,0x80,
544     0x08,0x00,
545     0x08,0x00,
546     0x08,0x00, // STAR 9x11 = 1.5
547
548     0x04,0x00,
549     0x04,0x00,
550     0x04,0x00,
551     0x84,0x20,
552     0x64,0xc0,
553     0x1f,0x00,
554     0x04,0x00,
555     0x1f,0x00,
556     0x64,0xc0,
557     0x84,0x20,
558     0x04,0x00,
559     0x04,0x00,
560     0x04,0x00, // STAR 11x13 = 2.0
561
562     0x02,0x00,
563     0x02,0x00,
564     0x02,0x00,
565     0x02,0x00,
566     0x82,0x18,
567     0x62,0x60,
568     0x1b,0x80,
569     0x06,0x00,
570     0x1b,0x80,
571     0x62,0x60,
572     0x82,0x18,
573     0x02,0x00,
574     0x02,0x00,
575     0x02,0x00,
576     0x02,0x00, // STAR 13x15 = 2.5
577
578     0x02,0x00,
579     0x02,0x00,
580     0x02,0x00,
581     0x02,0x00,
582     0x82,0x08,
583     0x62,0x30,
584     0x12,0x40,
585     0x0f,0x80,
586     0x02,0x00,
587     0x0f,0x80,
588     0x12,0x40,
589     0x62,0x30,
590     0x82,0x08,
591     0x02,0x00,
592     0x02,0x00,
593     0x02,0x00,
594     0x02,0x00, // STAR 13x17 = 3.0
595
596     0x01,0x00,
597     0x01,0x00,
598     0x01,0x00,
599     0x01,0x00,
600     0x01,0x00,
601     0xc1,0x06,
602     0x21,0x18,
603     0x19,0x20,
604     0x07,0xc0,
605     0x01,0x00,
606     0x07,0xc0,
607     0x19,0x20,
608     0x21,0x18,
609     0xc1,0x06,
610     0x01,0x00,
611     0x01,0x00,
612     0x01,0x00,
613     0x01,0x00,
614     0x01,0x00, // STAR 15x19 = 3.5
615
616     0x00,0x80, 0x00,
617     0x00,0x80, 0x00,
618     0x00,0x80, 0x00,
619     0x00,0x80, 0x00,
620     0x00,0x80, 0x00,
621     0x80,0x80, 0x80,
622     0x60,0x83, 0x00,
623     0x10,0x8c, 0x00,
624     0x0c,0x90, 0x00,
625     0x03,0xe0, 0x00,
626     0x00,0x80, 0x00,
627     0x03,0xe0, 0x00,
628     0x0c,0x90, 0x00,
629     0x10,0x8c, 0x00,
630     0x60,0x83, 0x00,
631     0x80,0x80, 0x80,
632     0x00,0x80, 0x00,
633     0x00,0x80, 0x00,
634     0x00,0x80, 0x00,
635     0x00,0x80, 0x00,
636     0x00,0x80, 0x00, // STAR 17x21 = 4.0
637
638     0x00,0x40, 0x00,
639     0x00,0x40, 0x00,
640     0x00,0x40, 0x00,
641     0x00,0x40, 0x00,
642     0x00,0x40, 0x00,
643     0x00,0x40, 0x00,
644     0xc0,0x40, 0x60,
645     0x30,0x41, 0x80,
646     0x08,0x42, 0x00,
647     0x06,0x4c, 0x00,
648     0x01,0xf0, 0x00,
649     0x00,0x40, 0x00,
650     0x01,0xf0, 0x00,
651     0x06,0x4c, 0x00,
652     0x08,0x42, 0x00,
653     0x30,0x41, 0x80,
654     0xc0,0x40, 0x60,
655     0x00,0x40, 0x00,
656     0x00,0x40, 0x00,
657     0x00,0x40, 0x00,
658     0x00,0x40, 0x00,
659     0x00,0x40, 0x00,
660     0x00,0x40, 0x00, // STAR 19x23 = 4.5
661
662     0x00,0x20, 0x00,
663     0x00,0x20, 0x00,
664     0x00,0x20, 0x00,
665     0x00,0x20, 0x00,
666     0x00,0x20, 0x00,
667     0x00,0x20, 0x00,
668     0x80,0x20, 0x08,
669     0x60,0x20, 0x30,
670     0x18,0x20, 0xc0,
671     0x04,0x21, 0x00,
672     0x03,0x26, 0x00,
673     0x00,0xf8, 0x00,
674     0x00,0x20, 0x00,
675     0x00,0xf8, 0x00,
676     0x03,0x26, 0x00,
677     0x04,0x21, 0x00,
678     0x18,0x20, 0xc0,
679     0x60,0x20, 0x30,
680     0x80,0x20, 0x08,
681     0x00,0x20, 0x00,
682     0x00,0x20, 0x00,
683     0x00,0x20, 0x00,
684     0x00,0x20, 0x00,
685     0x00,0x20, 0x00,
686     0x00,0x20, 0x00, // STAR 21x25 = 5.0
687
688     0x00,0x10, 0x00,
689     0x00,0x10, 0x00,
690     0x00,0x10, 0x00,
691     0x00,0x10, 0x00,
692     0x00,0x10, 0x00,
693     0x00,0x10, 0x00,
694     0x00,0x10, 0x00,
695     0xc0,0x10, 0x06,
696     0x30,0x10, 0x18,
697     0x08,0x10, 0x60,
698     0x06,0x10, 0x80,
699     0x01,0x93, 0x00,
700     0x00,0x7c, 0x00,
701     0x00,0x10, 0x00,
702     0x00,0x7c, 0x00,
703     0x01,0x93, 0x00,
704     0x06,0x10, 0x80,
705     0x08,0x10, 0x60,
706     0x30,0x10, 0x18,
707     0xc0,0x10, 0x06,
708     0x00,0x10, 0x00,
709     0x00,0x10, 0x00,
710     0x00,0x10, 0x00,
711     0x00,0x10, 0x00,
712     0x00,0x10, 0x00,
713     0x00,0x10, 0x00,
714     0x00,0x10, 0x00, // STAR 23x27 = 5.5
715
716     0x00,0x08, 0x00,0x00,
717     0x00,0x08, 0x00,0x00,
718     0x00,0x08, 0x00,0x00,
719     0x00,0x08, 0x00,0x00,
720     0x00,0x08, 0x00,0x00,
721     0x00,0x08, 0x00,0x00,
722     0x00,0x08, 0x00,0x00,
723     0x80,0x08, 0x00,0x80,
724     0x60,0x08, 0x03,0x00,
725     0x18,0x08, 0x0c,0x00,
726     0x04,0x08, 0x30,0x00,
727     0x03,0x08, 0x40,0x00,
728     0x00,0xc9, 0x80,0x00,
729     0x00,0x3e, 0x00,0x00,
730     0x00,0x08, 0x00,0x00,
731     0x00,0x3e, 0x00,0x00,
732     0x00,0xc9, 0x80,0x00,
733     0x03,0x08, 0x40,0x00,
734     0x04,0x08, 0x30,0x00,
735     0x18,0x08, 0x0c,0x00,
736     0x60,0x08, 0x03,0x00,
737     0x80,0x08, 0x00,0x80,
738     0x00,0x08, 0x00,0x00,
739     0x00,0x08, 0x00,0x00,
740     0x00,0x08, 0x00,0x00,
741     0x00,0x08, 0x00,0x00,
742     0x00,0x08, 0x00,0x00,
743     0x00,0x08, 0x00,0x00,
744     0x00,0x08, 0x00,0x00, // STAR 25x29 = 6.0
745
746     0x00,0x00, 0x80,0x00,
747     0x00,0x00, 0x80,0x00,
748     0x00,0x00, 0x80,0x00,
749     0x00,0x00, 0x80,0x00,
750     0x00,0x00, 0x80,0x00,
751     0x00,0x00, 0x80,0x00,
752     0x00,0x00, 0x80,0x00,
753     0x00,0x00, 0x80,0x00,
754     0x00,0x00, 0x80,0x00,
755     0x30,0x00, 0x80,0x06,
756     0x0c,0x00, 0x80,0x18,
757     0x03,0x00, 0x80,0x60,
758     0x00,0xc0, 0x81,0x80,
759     0x00,0x30, 0x86,0x00,
760     0x00,0x0c, 0x98,0x00,
761     0x00,0x03, 0xe0,0x00,
762     0x00,0x03, 0xe0,0x00,
763     0x00,0x0c, 0x98,0x00,
764     0x00,0x30, 0x86,0x00,
765     0x00,0xc0, 0x81,0x80,
766     0x03,0x00, 0x80,0x60,
767     0x0c,0x00, 0x80,0x18,
768     0x30,0x00, 0x80,0x06,
769     0x00,0x00, 0x80,0x00,
770     0x00,0x00, 0x80,0x00,
771     0x00,0x00, 0x80,0x00,
772     0x00,0x00, 0x80,0x00,
773     0x00,0x00, 0x80,0x00,
774     0x00,0x00, 0x80,0x00,
775     0x00,0x00, 0x80,0x00,
776     0x00,0x00, 0x00,0x00,
777     0x00,0x00, 0x00,0x00, // STAR 32x32 = 6.5
778
779     0x00, 0x00, 0x80, 0x00,
780     0x00, 0x00, 0x80, 0x00,
781     0x00, 0x00, 0x80, 0x00,
782     0x00, 0x00, 0x80, 0x00,
783     0x00, 0x00, 0x80, 0x00,
784     0x00, 0x00, 0x80, 0x00,
785     0x00, 0x00, 0x80, 0x00,
786     0x00, 0x00, 0x80, 0x00,
787     0x10, 0x00, 0x80, 0x04,
788     0x0c, 0x00, 0x80, 0x18,
789     0x02, 0x00, 0x80, 0x20,
790     0x01, 0x80, 0x80, 0xc0,
791     0x00, 0x40, 0x81, 0x00,
792     0x00, 0x30, 0x86, 0x00,
793     0x00, 0x08, 0x88, 0x00,
794     0x00, 0x06, 0xb0, 0x00,
795     0x00, 0x01, 0xc0, 0x00,
796     0x00, 0x06, 0xb0, 0x00,
797     0x00, 0x08, 0x88, 0x00,
798     0x00, 0x30, 0x86, 0x00,
799     0x00, 0x40, 0x81, 0x00,
800     0x01, 0x80, 0x80, 0xc0,
801     0x02, 0x00, 0x80, 0x20,
802     0x0c, 0x00, 0x80, 0x18,
803     0x10, 0x00, 0x80, 0x04,
804     0x00, 0x00, 0x80, 0x00,
805     0x00, 0x00, 0x80, 0x00,
806     0x00, 0x00, 0x80, 0x00,
807     0x00, 0x00, 0x80, 0x00,
808     0x00, 0x00, 0x80, 0x00,
809     0x00, 0x00, 0x80, 0x00,
810     0x00, 0x00, 0x80, 0x00, // STAR 32x32 = 7.0
811
812     // TYPE = CIRC
813
814     0x38,
815     0x44,
816     0x82,
817     0x82,
818     0x82,
819     0x44,
820     0x38, // CIRC 7x7 = 1.0
821
822     0x3c,0x00,
823     0x42,0x00,
824     0x81,0x00,
825     0x81,0x00,
826     0x81,0x00,
827     0x81,0x00,
828     0x42,0x00,
829     0x3c,0x00,
830     0x00,0x00, //CIRC 9x9 = 1.5
831
832     0x3e,0x00,
833     0x41,0x00,
834     0x81,0x80,
835     0x80,0x80,
836     0x80,0x80,
837     0x80,0x80,
838     0x81,0x80,
839     0x41,0x00,
840     0x3e,0x00, // CIRC 9x9 = 2.0
841
842     0x1f,0x00,
843     0x20,0x80,
844     0x40,0x40,
845     0x80,0x20,
846     0x80,0x20,
847     0x80,0x20,
848     0x80,0x20,
849     0x80,0x20,
850     0x40,0x40,
851     0x20,0x80,
852     0x1f,0x00, // CIRC 11x11 = 2.5
853
854     0x0f,0x80,
855     0x10,0x40,
856     0x20,0x20,
857     0x40,0x10,
858     0x80,0x08,
859     0x80,0x08,
860     0x80,0x08,
861     0x80,0x08,
862     0x80,0x08,
863     0x40,0x10,
864     0x20,0x20,
865     0x10,0x40,
866     0x0f,0x80, // CIRC 13x13 = 3.0
867
868     0x07,0xc0,
869     0x18,0x30,
870     0x20,0x08,
871     0x40,0x04,
872     0x40,0x04,
873     0x80,0x02,
874     0x80,0x02,
875     0x80,0x02,
876     0x80,0x02,
877     0x80,0x02,
878     0x40,0x04,
879     0x40,0x04,
880     0x20,0x08,
881     0x18,0x30,
882     0x07,0xc0, // CIRC 15x15 = 3.5
883
884     0x03,0xe0, 0x00,
885     0x0c,0x18, 0x00,
886     0x10,0x04, 0x00,
887     0x20,0x02, 0x00,
888     0x40,0x01, 0x00,
889     0x40,0x01, 0x00,
890     0x80,0x00, 0x80,
891     0x80,0x00, 0x80,
892     0x80,0x00, 0x80,
893     0x80,0x00, 0x80,
894     0x80,0x00, 0x80,
895     0x40,0x01, 0x00,
896     0x40,0x01, 0x00,
897     0x20,0x02, 0x00,
898     0x10,0x04, 0x00,
899     0x0c,0x18, 0x00,
900     0x03,0xe0, 0x00, // CIRC 17x17 = 4.0
901
902     0x03,0xf8, 0x00,
903     0x0e,0x0e, 0x00,
904     0x18,0x03, 0x00,
905     0x20,0x00, 0x80,
906     0x60,0x00, 0xc0,
907     0x40,0x00, 0x40,
908     0xc0,0x00, 0x60,
909     0x80,0x00, 0x20,
910     0x80,0x00, 0x20,
911     0x80,0x00, 0x20,
912     0x80,0x00, 0x20,
913     0x80,0x00, 0x20,
914     0xc0,0x00, 0x60,
915     0x40,0x00, 0x40,
916     0x60,0x00, 0xc0,
917     0x20,0x00, 0x80,
918     0x18,0x03, 0x00,
919     0x0e,0x0e, 0x00,
920     0x03,0xf8, 0x00, // CIRC 19x19 = 4.5
921
922     0x01,0xfc, 0x00,
923     0x06,0x03, 0x00,
924     0x08,0x00, 0x80,
925     0x10,0x00, 0x40,
926     0x20,0x00, 0x20,
927     0x40,0x00, 0x10,
928     0x40,0x00, 0x10,
929     0x80,0x00, 0x08,
930     0x80,0x00, 0x08,
931     0x80,0x00, 0x08,
932     0x80,0x00, 0x08,
933     0x80,0x00, 0x08,
934     0x80,0x00, 0x08,
935     0x80,0x00, 0x08,
936     0x40,0x00, 0x10,
937     0x40,0x00, 0x10,
938     0x20,0x00, 0x20,
939     0x10,0x00, 0x40,
940     0x08,0x00, 0x80,
941     0x06,0x03, 0x00,
942     0x01,0xfc, 0x00, // CIRC 21x21 = 5.0
943
944     0x00,0xfe, 0x00,
945     0x03,0x01, 0x80,
946     0x0c,0x00, 0x60,
947     0x18,0x00, 0x30,
948     0x30,0x00, 0x18,
949     0x20,0x00, 0x08,
950     0x40,0x00, 0x04,
951     0x40,0x00, 0x04,
952     0x80,0x00, 0x02,
953     0x80,0x00, 0x02,
954     0x80,0x00, 0x02,
955     0x80,0x00, 0x02,
956     0x80,0x00, 0x02,
957     0x80,0x00, 0x02,
958     0x80,0x00, 0x02,
959     0x40,0x00, 0x04,
960     0x40,0x00, 0x04,
961     0x20,0x00, 0x08,
962     0x30,0x00, 0x18,
963     0x18,0x00, 0x30,
964     0x0c,0x00, 0x60,
965     0x03,0x01, 0x80,
966     0x00,0xfe, 0x00, // CIRC 23x23 = 5.5
967
968     0x00,0x7f, 0x00,0x00,
969     0x01,0x80, 0xc0,0x00,
970     0x06,0x00, 0x30,0x00,
971     0x08,0x00, 0x08,0x00,
972     0x10,0x00, 0x04,0x00,
973     0x20,0x00, 0x02,0x00,
974     0x20,0x00, 0x02,0x00,
975     0x40,0x00, 0x01,0x00,
976     0x40,0x00, 0x01,0x00,
977     0x80,0x00, 0x00,0x80,
978     0x80,0x00, 0x00,0x80,
979     0x80,0x00, 0x00,0x80,
980     0x80,0x00, 0x00,0x80,
981     0x80,0x00, 0x00,0x80,
982     0x80,0x00, 0x00,0x80,
983     0x80,0x00, 0x00,0x80,
984     0x40,0x00, 0x01,0x00,
985     0x40,0x00, 0x01,0x00,
986     0x20,0x00, 0x02,0x00,
987     0x20,0x00, 0x02,0x00,
988     0x10,0x00, 0x04,0x00,
989     0x08,0x00, 0x08,0x00,
990     0x06,0x00, 0x30,0x00,
991     0x01,0x80, 0xc0,0x00,
992     0x00,0x7f, 0x00,0x00, // CIRC 25x25 = 6.0
993
994     0x00,0x3f, 0x80,0x00,
995     0x01,0xc0, 0x70,0x00,
996     0x03,0x00, 0x18,0x00,
997     0x0c,0x00, 0x06,0x00,
998     0x18,0x00, 0x03,0x00,
999     0x10,0x00, 0x01,0x00,
1000     0x20,0x00, 0x00,0x80,
1001     0x60,0x00, 0x00,0xc0,
1002     0x40,0x00, 0x00,0x40,
1003     0x40,0x00, 0x00,0x40,
1004     0x80,0x00, 0x00,0x20,
1005     0x80,0x00, 0x00,0x20,
1006     0x80,0x00, 0x00,0x20,
1007     0x80,0x00, 0x00,0x20,
1008     0x80,0x00, 0x00,0x20,
1009     0x80,0x00, 0x00,0x20,
1010     0x80,0x00, 0x00,0x20,
1011     0x40,0x00, 0x00,0x40,
1012     0x40,0x00, 0x00,0x40,
1013     0x60,0x00, 0x00,0xc0,
1014     0x20,0x00, 0x00,0x80,
1015     0x10,0x00, 0x01,0x00,
1016     0x18,0x00, 0x03,0x00,
1017     0x0c,0x00, 0x06,0x00,
1018     0x03,0x00, 0x18,0x00,
1019     0x01,0xc0, 0x70,0x00,
1020     0x00,0x3f, 0x80,0x00, // CIRC 27x27 = 6.5
1021
1022     0x00,0x1f, 0xc0,0x00,
1023     0x00,0xe0, 0x38,0x00,
1024     0x01,0x00, 0x04,0x00,
1025     0x06,0x00, 0x03,0x00,
1026     0x08,0x00, 0x00,0x80,
1027     0x10,0x00, 0x00,0x40,
1028     0x10,0x00, 0x00,0x40,
1029     0x20,0x00, 0x00,0x20,
1030     0x40,0x00, 0x00,0x10,
1031     0x40,0x00, 0x00,0x10,
1032     0x40,0x00, 0x00,0x10,
1033     0x80,0x00, 0x00,0x08,
1034     0x80,0x00, 0x00,0x08,
1035     0x80,0x00, 0x00,0x08,
1036     0x80,0x00, 0x00,0x08,
1037     0x80,0x00, 0x00,0x08,
1038     0x80,0x00, 0x00,0x08,
1039     0x80,0x00, 0x00,0x08,
1040     0x40,0x00, 0x00,0x10,
1041     0x40,0x00, 0x00,0x10,
1042     0x40,0x00, 0x00,0x10,
1043     0x20,0x00, 0x00,0x20,
1044     0x10,0x00, 0x00,0x40,
1045     0x10,0x00, 0x00,0x40,
1046     0x08,0x00, 0x00,0x80,
1047     0x06,0x00, 0x03,0x00,
1048     0x01,0x00, 0x04,0x00,
1049     0x00,0xe0, 0x38,0x00,
1050     0x00,0x1f, 0xc0,0x00, // CIRC 29x29 = 7.0
1051
1052     // TYPE = CROSS
1053
1054     0x82,
1055     0x44,
1056     0x28,
1057     0x10,
1058     0x28,
1059     0x44,
1060     0x82, // CROSS 7x7 = 1.0
1061
1062     0x80,0x80,
1063     0x41,0x00,
1064     0x22,0x00,
1065     0x14,0x00,
1066     0x08,0x00,
1067     0x14,0x00,
1068     0x22,0x00,
1069     0x41,0x00,
1070     0x80,0x80, // CROSS 9x9 = 1.5
1071
1072     0x80,0x20,
1073     0x40,0x40,
1074     0x20,0x80,
1075     0x11,0x00,
1076     0x0a,0x00,
1077     0x04,0x00,
1078     0x0a,0x00,
1079     0x11,0x00,
1080     0x20,0x80,
1081     0x40,0x40,
1082     0x80,0x20, // CROSS 11x11 = 2.0
1083
1084     0x80,0x08,
1085     0x40,0x10,
1086     0x20,0x20,
1087     0x10,0x40,
1088     0x08,0x80,
1089     0x05,0x00,
1090     0x02,0x00,
1091     0x05,0x00,
1092     0x08,0x80,
1093     0x10,0x40,
1094     0x20,0x20,
1095     0x40,0x10,
1096     0x80,0x08, // CROSS 13x13 = 2.5
1097
1098     0x80,0x02,
1099     0x40,0x04,
1100     0x20,0x08,
1101     0x10,0x10,
1102     0x08,0x20,
1103     0x04,0x40,
1104     0x02,0x80,
1105     0x01,0x00,
1106     0x02,0x80,
1107     0x04,0x40,
1108     0x08,0x20,
1109     0x10,0x10,
1110     0x20,0x08,
1111     0x40,0x04,
1112     0x80,0x02, // CROSS 15x15 = 3.0
1113
1114     0x80,0x00, 0x80,
1115     0x40,0x01, 0x00,
1116     0x20,0x02, 0x00,
1117     0x10,0x04, 0x00,
1118     0x08,0x08, 0x00,
1119     0x04,0x10, 0x00,
1120     0x02,0x20, 0x00,
1121     0x01,0x40, 0x00,
1122     0x00,0x80, 0x00,
1123     0x01,0x40, 0x00,
1124     0x02,0x20, 0x00,
1125     0x04,0x10, 0x00,
1126     0x08,0x08, 0x00,
1127     0x10,0x04, 0x00,
1128     0x20,0x02, 0x00,
1129     0x40,0x01, 0x00,
1130     0x80,0x00, 0x80, // CROSS 17x17 = 3.5
1131
1132     0x80,0x00, 0x20,
1133     0x40,0x00, 0x40,
1134     0x20,0x00, 0x80,
1135     0x10,0x01, 0x00,
1136     0x08,0x02, 0x00,
1137     0x04,0x04, 0x00,
1138     0x02,0x08, 0x00,
1139     0x01,0x10, 0x00,
1140     0x00,0xa0, 0x00,
1141     0x00,0x40, 0x00,
1142     0x00,0xa0, 0x00,
1143     0x01,0x10, 0x00,
1144     0x02,0x08, 0x00,
1145     0x04,0x04, 0x00,
1146     0x08,0x02, 0x00,
1147     0x10,0x01, 0x00,
1148     0x20,0x00, 0x80,
1149     0x40,0x00, 0x40,
1150     0x80,0x00, 0x20, // CROSS 19x19 = 4.0
1151
1152     0x80,0x00, 0x08,
1153     0x40,0x00, 0x10,
1154     0x20,0x00, 0x20,
1155     0x10,0x00, 0x40,
1156     0x08,0x00, 0x80,
1157     0x04,0x01, 0x00,
1158     0x02,0x02, 0x00,
1159     0x01,0x04, 0x00,
1160     0x00,0x88, 0x00,
1161     0x00,0x50, 0x00,
1162     0x00,0x20, 0x00,
1163     0x00,0x50, 0x00,
1164     0x00,0x88, 0x00,
1165     0x01,0x04, 0x00,
1166     0x02,0x02, 0x00,
1167     0x04,0x01, 0x00,
1168     0x08,0x00, 0x80,
1169     0x10,0x00, 0x40,
1170     0x20,0x00, 0x20,
1171     0x40,0x00, 0x10,
1172     0x80,0x00, 0x08,/* CROSS 21x21 = 4.5 */
1173
1174     0x80,0x00, 0x02,
1175     0x40,0x00, 0x04,
1176     0x20,0x00, 0x08,
1177     0x10,0x00, 0x10,
1178     0x08,0x00, 0x20,
1179     0x04,0x00, 0x40,
1180     0x02,0x00, 0x80,
1181     0x01,0x01, 0x00,
1182     0x00,0x82, 0x00,
1183     0x00,0x44, 0x00,
1184     0x00,0x28, 0x00,
1185     0x00,0x10, 0x00,
1186     0x00,0x28, 0x00,
1187     0x00,0x44, 0x00,
1188     0x00,0x82, 0x00,
1189     0x01,0x01, 0x00,
1190     0x02,0x00, 0x80,
1191     0x04,0x00, 0x40,
1192     0x08,0x00, 0x20,
1193     0x10,0x00, 0x10,
1194     0x20,0x00, 0x08,
1195     0x40,0x00, 0x04,
1196     0x80,0x00, 0x02, // CROSS 23x23 = 5.0
1197
1198     0x80,0x00, 0x00,0x80,
1199     0x40,0x00, 0x01,0x00,
1200     0x20,0x00, 0x02,0x00,
1201     0x10,0x00, 0x04,0x00,
1202     0x08,0x00, 0x08,0x00,
1203     0x04,0x00, 0x10,0x00,
1204     0x02,0x00, 0x20,0x00,
1205     0x01,0x00, 0x40,0x00,
1206     0x00,0x80, 0x80,0x00,
1207     0x00,0x41, 0x00,0x00,
1208     0x00,0x22, 0x00,0x00,
1209     0x00,0x14, 0x00,0x00,
1210     0x00,0x08, 0x00,0x00,
1211     0x00,0x14, 0x00,0x00,
1212     0x00,0x22, 0x00,0x00,
1213     0x00,0x41, 0x00,0x00,
1214     0x00,0x80, 0x80,0x00,
1215     0x01,0x00, 0x40,0x00,
1216     0x02,0x00, 0x20,0x00,
1217     0x04,0x00, 0x10,0x00,
1218     0x08,0x00, 0x08,0x00,
1219     0x10,0x00, 0x04,0x00,
1220     0x20,0x00, 0x02,0x00,
1221     0x40,0x00, 0x01,0x00,
1222     0x80,0x00, 0x00,0x80, // CROSS 25x25 = 5.5
1223
1224     0x80,0x00, 0x00,0x20,
1225     0x40,0x00, 0x00,0x40,
1226     0x20,0x00, 0x00,0x80,
1227     0x10,0x00, 0x01,0x00,
1228     0x08,0x00, 0x02,0x00,
1229     0x04,0x00, 0x04,0x00,
1230     0x02,0x00, 0x08,0x00,
1231     0x01,0x00, 0x10,0x00,
1232     0x00,0x80, 0x20,0x00,
1233     0x00,0x40, 0x40,0x00,
1234     0x00,0x20, 0x80,0x00,
1235     0x00,0x11, 0x00,0x00,
1236     0x00,0x0a, 0x00,0x00,
1237     0x00,0x04, 0x00,0x00,
1238     0x00,0x0a, 0x00,0x00,
1239     0x00,0x11, 0x00,0x00,
1240     0x00,0x20, 0x80,0x00,
1241     0x00,0x40, 0x40,0x00,
1242     0x00,0x80, 0x20,0x00,
1243     0x01,0x00, 0x10,0x00,
1244     0x02,0x00, 0x08,0x00,
1245     0x04,0x00, 0x04,0x00,
1246     0x08,0x00, 0x02,0x00,
1247     0x10,0x00, 0x01,0x00,
1248     0x20,0x00, 0x00,0x80,
1249     0x40,0x00, 0x00,0x40,
1250     0x80,0x00, 0x00,0x20, // CROSS 27x27 = 6.0
1251
1252     0x00,0x00, 0x00,0x00,
1253     0x00,0x00, 0x00,0x00,
1254     0x20,0x00, 0x00,0x04,
1255     0x10,0x00, 0x00,0x08,
1256     0x08,0x00, 0x00,0x10,
1257     0x04,0x00, 0x00,0x20,
1258     0x02,0x00, 0x00,0x40,
1259     0x01,0x00, 0x00,0x80,
1260     0x00,0x80, 0x01,0x00,
1261     0x00,0x40, 0x02,0x00,
1262     0x00,0x20, 0x04,0x00,
1263     0x00,0x10, 0x08,0x00,
1264     0x00,0x08, 0x10,0x00,
1265     0x00,0x04, 0x20,0x00,
1266     0x00,0x02, 0x40,0x00,
1267     0x00,0x01, 0x80,0x00,
1268     0x00,0x01, 0x80,0x00,
1269     0x00,0x02, 0x40,0x00,
1270     0x00,0x04, 0x20,0x00,
1271     0x00,0x08, 0x10,0x00,
1272     0x00,0x10, 0x08,0x00,
1273     0x00,0x20, 0x04,0x00,
1274     0x00,0x40, 0x02,0x00,
1275     0x00,0x80, 0x01,0x00,
1276     0x01,0x00, 0x00,0x80,
1277     0x02,0x00, 0x00,0x40,
1278     0x04,0x00, 0x00,0x20,
1279     0x08,0x00, 0x00,0x10,
1280     0x10,0x00, 0x00,0x08,
1281     0x20,0x00, 0x00,0x04,
1282     0x00,0x00, 0x00,0x00,
1283     0x00,0x00, 0x00,0x00, // CROSS 32x32 = 6.5
1284
1285     0x00,0x00, 0x00,0x00,
1286     0x40,0x00, 0x00,0x02,
1287     0x20,0x00, 0x00,0x04,
1288     0x10,0x00, 0x00,0x08,
1289     0x08,0x00, 0x00,0x10,
1290     0x04,0x00, 0x00,0x20,
1291     0x02,0x00, 0x00,0x40,
1292     0x01,0x00, 0x00,0x80,
1293     0x00,0x80, 0x01,0x00,
1294     0x00,0x40, 0x02,0x00,
1295     0x00,0x20, 0x04,0x00,
1296     0x00,0x10, 0x08,0x00,
1297     0x00,0x08, 0x10,0x00,
1298     0x00,0x04, 0x20,0x00,
1299     0x00,0x02, 0x40,0x00,
1300     0x00,0x01, 0x80,0x00,
1301     0x00,0x01, 0x80,0x00,
1302     0x00,0x02, 0x40,0x00,
1303     0x00,0x04, 0x20,0x00,
1304     0x00,0x08, 0x10,0x00,
1305     0x00,0x10, 0x08,0x00,
1306     0x00,0x20, 0x04,0x00,
1307     0x00,0x40, 0x02,0x00,
1308     0x00,0x80, 0x01,0x00,
1309     0x01,0x00, 0x00,0x80,
1310     0x02,0x00, 0x00,0x40,
1311     0x04,0x00, 0x00,0x20,
1312     0x08,0x00, 0x00,0x10,
1313     0x10,0x00, 0x00,0x08,
1314     0x20,0x00, 0x00,0x04,
1315     0x40,0x00, 0x00,0x02,
1316     0x00,0x00, 0x00,0x00  // CROSS 32x32 = 7.0
1317 };
1318
1319 // =======================================================================
1320 // function : GetMarkerBitMapArray
1321 // purpose  : Returns a parameters for the marker of the specified
1322 //            type and scale.
1323 // =======================================================================
1324 void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
1325                            const Standard_ShortReal& theScale,
1326                            Standard_Integer& theWidth,
1327                            Standard_Integer& theHeight,
1328                            Standard_Integer& theOffset,
1329                            Standard_Integer& theNumOfBytes)
1330 {
1331   const Standard_Integer aType = (Standard_Integer )((theMarkerType > Aspect_TOM_O) ? Aspect_TOM_O : theMarkerType);
1332   const Standard_Real anIndex = (Standard_Real )(TEL_NO_OF_SIZES - 1) * (theScale - (Standard_Real )TEL_PM_START_SIZE)
1333                               / (Standard_Real )(TEL_PM_END_SIZE - TEL_PM_START_SIZE);
1334   Standard_Integer anId = (Standard_Integer )(anIndex + 0.5);
1335   if (anId < 0)
1336   {
1337     anId = 0;
1338   }
1339   else if (anId >= TEL_NO_OF_SIZES)
1340   {
1341     anId = TEL_NO_OF_SIZES - 1;
1342   }
1343
1344   theWidth  = (Standard_Integer )arrPMFontInfo[aType][anId].width;
1345   theHeight = (Standard_Integer )arrPMFontInfo[aType][anId].height;
1346   theOffset = arrPMFontInfo[aType][anId].offset;
1347   const Standard_Integer aNumOfBytesInRow = theWidth / 8 + (theWidth % 8 ? 1 : 0);
1348   theNumOfBytes = theHeight * aNumOfBytesInRow;
1349 }
1350
1351 // =======================================================================
1352 // function : GetTextureImage
1353 // purpose  : Returns a marker image for the marker of the specified
1354 //            type and scale.
1355 // =======================================================================
1356 Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
1357                                                const Standard_ShortReal& theScale)
1358 {
1359   Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1360   GetMarkerBitMapParam (theMarkerType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
1361
1362   Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
1363   for (Standard_Integer anIter = 0; anIter < aNumOfBytes; anIter++)
1364   {
1365     aBitMap->ChangeValue (anIter) = OpenGl_AspectMarker_myMarkerRaster[anOffset + anIter];
1366   }
1367
1368   Handle(Graphic3d_MarkerImage) aTexture = new Graphic3d_MarkerImage (aBitMap, aWidth, aHeight);
1369   return aTexture;
1370 }
1371
1372 // =======================================================================
1373 // function : MergeImages
1374 // purpose  : Merge two image pixmap into one. Used for creating image for
1375 //            following markers: Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS,
1376 //            Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1,
1377 //            Aspect_TOM_RING2, Aspect_TOM_RING3
1378 // =======================================================================
1379 Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
1380                                   const Handle(Image_PixMap)& theImage2)
1381 {
1382   if (theImage1.IsNull() && theImage2.IsNull())
1383   {
1384     return Handle(Image_PixMap)();
1385   }
1386
1387   Handle(Image_PixMap) aResultImage = new Image_PixMap();
1388
1389   Standard_Integer aWidth1 (0), aHeight1 (0);
1390   if (!theImage1.IsNull())
1391   {
1392     aWidth1  = (Standard_Integer )theImage1->Width();
1393     aHeight1 = (Standard_Integer )theImage1->Height();
1394   }
1395
1396   Standard_Integer aWidth2 (0), aHeight2 (0);
1397   if (!theImage2.IsNull())
1398   {
1399     aWidth2  = (Standard_Integer )theImage2->Width();
1400     aHeight2 = (Standard_Integer )theImage2->Height();
1401   }
1402
1403   const Standard_Integer aMaxWidth  = Max (aWidth1,   aWidth2);
1404   const Standard_Integer aMaxHeight = Max (aHeight1,  aHeight2);
1405   const Standard_Integer aSize      = Max (aMaxWidth, aMaxHeight);
1406
1407   aResultImage->InitZero (Image_PixMap::ImgGray, aSize, aSize);
1408
1409   if (!theImage1.IsNull())
1410   {
1411     const Standard_Integer aXOffset1  = Abs (aWidth1  - aMaxWidth)  / 2;
1412     const Standard_Integer anYOffset1 = Abs (aHeight1 - aMaxHeight) / 2;
1413     for (Standard_Integer anY = 0; anY < aHeight1; anY++)
1414     {
1415       Standard_Byte* anImageLine = theImage1->ChangeRow (anY);
1416       Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset1 + anY);
1417       for (Standard_Integer aX = 0; aX < aWidth1; aX++)
1418       {
1419         aResultImageLine[aXOffset1 + aX] |= anImageLine[aX];
1420       }
1421     }
1422   }
1423
1424   if (!theImage2.IsNull())
1425   {
1426     const Standard_Integer aXOffset2  = Abs (aWidth2  - aMaxWidth)  / 2;
1427     const Standard_Integer anYOffset2 = Abs (aHeight2 - aMaxHeight) / 2;
1428     for (Standard_Integer anY = 0; anY < aHeight2; anY++)
1429     {
1430       Standard_Byte* anImageLine = theImage2->ChangeRow (anY);
1431       Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset2 + anY);
1432       for (Standard_Integer aX = 0; aX < aWidth2; aX++)
1433       {
1434         aResultImageLine[aXOffset2 + aX] |= anImageLine[aX];
1435       }
1436     }
1437   }
1438
1439   return aResultImage;
1440 }
1441
1442 // =======================================================================
1443 // function : OpenGl_AspectMarker
1444 // purpose  :
1445 // =======================================================================
1446 OpenGl_AspectMarker::OpenGl_AspectMarker()
1447  : myColor (myDefaultColor),
1448    myType  (Aspect_TOM_PLUS),
1449    myScale (1.0f),
1450    myMarkerSize (1.0f),
1451    mySpriteKey  (""),
1452    mySpriteAKey ("")
1453 {}
1454
1455 // =======================================================================
1456 // function : Init
1457 // purpose  :
1458 // =======================================================================
1459 void OpenGl_AspectMarker::Init (const Handle(OpenGl_Context)& theCtx,
1460                                 const CALL_DEF_CONTEXTMARKER& theAspect)
1461 {
1462   myColor.rgb[0] = (float )theAspect.Color.r;
1463   myColor.rgb[1] = (float )theAspect.Color.g;
1464   myColor.rgb[2] = (float )theAspect.Color.b;
1465   myColor.rgb[3] = 1.0f;
1466   myType  = theAspect.MarkerType;
1467   myScale = myMarkerSize = theAspect.Scale;
1468
1469   // generate key for shared resource
1470   TCollection_AsciiString aNewKey, aNewKeyA;
1471   if (myType == Aspect_TOM_USERDEFINED)
1472   {
1473     if (!theAspect.MarkerImage.IsNull())
1474     {
1475       aNewKey  = theAspect.MarkerImage->GetImageId();
1476       aNewKeyA = theAspect.MarkerImage->GetImageAlphaId();
1477     }
1478   }
1479   else if (myType != Aspect_TOM_POINT)
1480   {
1481     // pre-defined markers
1482     const Standard_Integer aScale = Standard_Integer(myScale + 0.5f);
1483     aNewKey  = TCollection_AsciiString ("OpenGl_AspectMarker") + myType + "_" + aScale;
1484     aNewKeyA = aNewKey + "A";
1485     if (myType == Aspect_TOM_BALL)
1486     {
1487       unsigned int aColor[3] =
1488       {
1489         (unsigned int )(255.0f * myColor.rgb[0]),
1490         (unsigned int )(255.0f * myColor.rgb[1]),
1491         (unsigned int )(255.0f * myColor.rgb[2])
1492       };
1493       char aBytes[8];
1494       sprintf (aBytes, "%02X%02X%02X", aColor[0], aColor[1], aColor[2]);
1495       aNewKey += aBytes;
1496     }
1497   }
1498
1499   // release old shared resources
1500   const Standard_Boolean aNewResource = aNewKey.IsEmpty() || mySpriteKey != aNewKey;
1501   if (aNewResource)
1502   {
1503     if (!mySprite.IsNull())
1504     {
1505       if (mySpriteKey.IsEmpty())
1506       {
1507         theCtx->DelayedRelease (mySprite);
1508         mySprite.Nullify();
1509       }
1510       else
1511       {
1512         mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
1513         theCtx->ReleaseResource (mySpriteKey);
1514       }
1515     }
1516     mySpriteKey = aNewKey;
1517   }
1518   if (aNewKeyA.IsEmpty()
1519    || mySpriteAKey != aNewKeyA)
1520   {
1521     if (!mySpriteA.IsNull())
1522     {
1523       if (mySpriteAKey.IsEmpty())
1524       {
1525         theCtx->DelayedRelease (mySpriteA);
1526         mySpriteA.Nullify();
1527       }
1528       else
1529       {
1530         mySpriteA.Nullify(); // we need nullify all handles before ReleaseResource() call
1531         theCtx->ReleaseResource (mySpriteKey);
1532       }
1533     }
1534     mySpriteAKey = aNewKeyA;
1535   }
1536   if (myType == Aspect_TOM_POINT
1537    || !aNewResource
1538    || (myType == Aspect_TOM_USERDEFINED && theAspect.MarkerImage.IsNull()))
1539   {
1540     // nothing to do - just simple point
1541     return;
1542   }
1543
1544   if (!aNewKey.IsEmpty()
1545    && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, mySpriteA) // alpha sprite could be shared
1546    && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey,  mySprite))
1547   {
1548     // reuse shared resource
1549     if (!mySprite->IsDisplayList())
1550     {
1551       myMarkerSize = Standard_ShortReal (Max (mySprite->SizeX(), mySprite->SizeY()));
1552     }
1553     return;
1554   }
1555
1556   const bool hadAlreadyAlpha = !mySpriteA.IsNull();
1557   if (!hadAlreadyAlpha)
1558   {
1559     mySpriteA = new OpenGl_PointSprite();
1560   }
1561   mySprite  = new OpenGl_PointSprite();
1562   if (!aNewKey.IsEmpty())
1563   {
1564     theCtx->ShareResource (aNewKey,  mySprite);
1565     if (!hadAlreadyAlpha)
1566     {
1567       theCtx->ShareResource (aNewKeyA, mySpriteA);
1568     }
1569   }
1570
1571   if (!theCtx.IsNull()
1572    && theCtx->IsGlGreaterEqual (2, 0)
1573    && !theCtx->caps->pntSpritesDisable)
1574   {
1575     // Creating texture resource for using it with point sprites
1576     Handle(Graphic3d_MarkerImage) aNewMarkerImage;
1577     Handle(Image_PixMap) anImage, anImageA;
1578
1579     if (myType == Aspect_TOM_USERDEFINED && !theAspect.MarkerImage.IsNull())
1580     {
1581       aNewMarkerImage = theAspect.MarkerImage;
1582       anImage = aNewMarkerImage->GetImage();
1583     }
1584     else
1585     {
1586       // Creating image from default bitmap
1587       Handle(TColStd_HArray1OfByte) aBitMap;
1588       Handle(Graphic3d_MarkerImage) aMarkerImage1, aMarkerImage2;
1589
1590       const Standard_ShortReal aDelta = 0.1F;
1591       Standard_ShortReal aScale = myScale;
1592       Standard_ShortReal aLimit = 0.0F;
1593
1594       switch (myType)
1595       {
1596         case Aspect_TOM_O_POINT:
1597         {
1598           const Standard_Integer aSize = myScale > 7 ? 7 : (Standard_Integer )(myScale + 0.5F);
1599           const Standard_Integer aNumOfBytes = (aSize / 8 + (aSize % 8 ? 1 : 0)) * aSize;
1600           aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
1601           for (Standard_Integer anIter = 0; anIter < aBitMap->Length(); anIter++)
1602           {
1603             aBitMap->SetValue (anIter, 255);
1604           }
1605           aMarkerImage2 = new Graphic3d_MarkerImage (aBitMap, aSize, aSize);
1606         }
1607         case Aspect_TOM_O_PLUS:
1608         case Aspect_TOM_O_STAR:
1609         case Aspect_TOM_O_X:
1610         {
1611           // For this type of markers we merge two base bitmaps into one
1612           // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
1613           aMarkerImage1 = GetTextureImage (Aspect_TOM_O, myScale);
1614           if (myType != Aspect_TOM_O_POINT)
1615           {
1616             aMarkerImage2 = GetTextureImage (Aspect_TypeOfMarker (myType - Aspect_TOM_O_POINT), myScale);
1617           }
1618           anImage = MergeImages (aMarkerImage1->GetImage(), aMarkerImage2->GetImage());
1619           aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
1620           break;
1621         }
1622         case Aspect_TOM_RING1:
1623           if (aLimit == 0.0f) aLimit = aScale * 0.2f;
1624         case Aspect_TOM_RING2:
1625           if (aLimit == 0.0f) aLimit = aScale * 0.5f;
1626         case Aspect_TOM_RING3:
1627         {
1628           if (aLimit == 0.0f) aLimit = aScale * 0.8f;
1629           for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
1630           {
1631             anImage = MergeImages (anImage, GetTextureImage (Aspect_TOM_O, aScale)->GetImage());
1632           }
1633           aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
1634           break;
1635         }
1636         case Aspect_TOM_BALL:
1637         {
1638           Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1639           GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1640
1641           const Standard_ShortReal aDelta = 0.1f;
1642           NCollection_Vec4<Standard_Real> aColor (Standard_Real (myColor.rgb[0]),
1643                                                   Standard_Real (myColor.rgb[1]),
1644                                                   Standard_Real (myColor.rgb[2]),
1645                                                   Standard_Real (myColor.rgb[3]));
1646
1647           const Standard_Integer aSize = Max (aWidth + 2, aHeight + 2); // includes extra margin
1648           anImage  = new Image_PixMap();
1649           anImageA = new Image_PixMap();
1650           anImage ->InitZero (Image_PixMap::ImgBGRA, aSize, aSize);
1651           anImageA->InitZero (Image_PixMap::ImgGray, aSize, aSize);
1652           Image_PixMapData<Image_ColorBGRA>& aDataBGRA = anImage->EditData<Image_ColorBGRA>();
1653           Image_PixMapData<Standard_Byte>&   aDataGray = anImageA->EditData<Standard_Byte>();
1654
1655           // we draw a set of circles
1656           Image_ColorBGRA aColor32;
1657           aColor32.a() = 255;
1658           Standard_Real aHLS[3];
1659           while (aScale >= 1.0f)
1660           {
1661             Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
1662             aHLS[2] *= 0.95; // 5% saturation change
1663             Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
1664             aColor32.r() = Standard_Byte(255.0 * aColor.r());
1665             aColor32.g() = Standard_Byte(255.0 * aColor.g());
1666             aColor32.b() = Standard_Byte(255.0 * aColor.b());
1667
1668             const Handle(Graphic3d_MarkerImage) aMarker = GetTextureImage (Aspect_TOM_O, aScale);
1669             const Handle(Image_PixMap)& aCircle = aMarker->GetImage();
1670
1671             const Standard_Size aDiffX = (aDataBGRA.SizeX() - aCircle->SizeX()) / 2;
1672             const Standard_Size aDiffY = (aDataBGRA.SizeY() - aCircle->SizeY()) / 2;
1673             for (Standard_Size aRow = 0; aRow < aCircle->SizeY(); ++aRow)
1674             {
1675               const Standard_Byte* aRowData = aCircle->Row (aRow);
1676               for (Standard_Size aCol = 0; aCol < aCircle->SizeX(); ++aCol)
1677               {
1678                 if (aRowData[aCol] != 0)
1679                 {
1680                   aDataBGRA.ChangeValue (aDiffX + aRow, aDiffY + aCol) = aColor32;
1681                   aDataGray.ChangeValue (aDiffX + aRow, aDiffY + aCol) = 255;
1682                 }
1683               }
1684             }
1685             aScale -= aDelta;
1686           }
1687           break;
1688         }
1689         default:
1690         {
1691           aNewMarkerImage = GetTextureImage (myType, myScale);
1692           anImage = aNewMarkerImage->GetImage();
1693           break;
1694         }
1695       }
1696     }
1697
1698     myMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
1699
1700     mySprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
1701     if (!hadAlreadyAlpha)
1702     {
1703       if (anImageA.IsNull()
1704        && mySprite->GetFormat() != GL_ALPHA8
1705        && !aNewMarkerImage.IsNull())
1706       {
1707         anImageA = aNewMarkerImage->GetImageAlpha();
1708       }
1709       if (!anImageA.IsNull())
1710       {
1711         mySpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
1712       }
1713     }
1714   }
1715   else
1716   {
1717     // Creating list with bitmap for using it in compatibility mode
1718     GLuint aBitmapList = glGenLists (1);
1719     mySprite->SetDisplayList (theCtx, aBitmapList);
1720
1721     Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1722     if (myType == Aspect_TOM_USERDEFINED && !theAspect.MarkerImage.IsNull())
1723     {
1724       // Reading userdefined marker
1725       Handle(TColStd_HArray1OfByte) aBitMap = theAspect.MarkerImage->GetBitMapArray();
1726       Standard_Byte* aBitMapArray = new Standard_Byte[aBitMap->Length()];
1727       theAspect.MarkerImage->GetTextureSize (aWidth, aHeight);
1728
1729       // We should pass bitmap to glBitmap with reversed line order as it draws it from
1730       // bottom to top
1731       const Standard_Integer aNumOfBytesInRow = aWidth / 8 + (aWidth % 8 ? 1 : 0);
1732       const Standard_Integer anUpperIndex = aBitMap->Upper();
1733       for (Standard_Integer aRow = 0; aRow < aHeight; aRow++)
1734       {
1735         for (Standard_Integer aByteIter = 0; aByteIter < aNumOfBytesInRow; aByteIter++)
1736         {
1737           aBitMapArray[aRow * aNumOfBytesInRow + aByteIter] =
1738             aBitMap->Value (anUpperIndex + 1 - (aRow + 1) * aNumOfBytesInRow + aByteIter);
1739         }
1740       }
1741
1742       if (aBitMapArray != NULL)
1743       {
1744         glNewList (aBitmapList, GL_COMPILE);
1745         glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1746                   0.f, 0.f, (const GLubyte* )aBitMapArray);
1747         glEndList();
1748       }
1749     }
1750     else
1751     {
1752       // Creating list for default marker
1753       const Standard_ShortReal aDelta = 0.1f;
1754       Standard_ShortReal aScale = myScale;
1755       Standard_ShortReal aLimit = 0.0f;
1756
1757       glNewList (aBitmapList, GL_COMPILE);
1758       switch (myType)
1759       {
1760         case Aspect_TOM_O_PLUS:
1761         case Aspect_TOM_O_STAR:
1762         case Aspect_TOM_O_X:
1763         {
1764           // For this type of markers we merge two base bitmaps into one
1765           // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
1766           GetMarkerBitMapParam (Aspect_TOM_O, myScale, aWidth, aHeight, anOffset, aNumOfBytes);
1767           glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1768                     0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1769           GetMarkerBitMapParam (Aspect_TypeOfMarker (myType - Aspect_TOM_O_POINT), myScale, aWidth, aHeight, anOffset, aNumOfBytes);
1770           glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1771                     0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1772           break;
1773         }
1774         case Aspect_TOM_BALL:
1775         {
1776           const Standard_ShortReal aDelta = 0.1f;
1777           NCollection_Vec4<Standard_Real> aColor (Standard_Real (myColor.rgb[0]),
1778                                                   Standard_Real (myColor.rgb[1]),
1779                                                   Standard_Real (myColor.rgb[2]),
1780                                                   Standard_Real (myColor.rgb[3]));
1781
1782           // we draw a set of circles
1783           while (aScale >= 1.0f)
1784           {
1785             Standard_Real aHLS[3];
1786             Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
1787             // 5% saturation change
1788             aHLS[2] *= 0.95;
1789             Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
1790
1791             glColor4dv (aColor);
1792             GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1793             glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1794                       0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1795
1796             aScale -= aDelta;
1797           }
1798           break;
1799         }
1800         case Aspect_TOM_RING1:
1801           if (aLimit == 0.0f) aLimit = aScale * 0.2f;
1802         case Aspect_TOM_RING2:
1803           if (aLimit == 0.0f) aLimit = aScale * 0.5f;
1804         case Aspect_TOM_RING3:
1805         {
1806           if (aLimit == 0.0f) aLimit = aScale * 0.8f;
1807           for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
1808           {
1809             GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1810             glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1811                       0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1812           }
1813           break;
1814         }
1815         default:
1816         {
1817           GetMarkerBitMapParam (myType, myScale, aWidth, aHeight, anOffset, aNumOfBytes);
1818           glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1819                     0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1820           break;
1821         }
1822       }
1823       glEndList();
1824     }
1825   }
1826 }
1827
1828 // =======================================================================
1829 // function : Render
1830 // purpose  :
1831 // =======================================================================
1832 void OpenGl_AspectMarker::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
1833 {
1834   theWorkspace->SetAspectMarker (this);
1835 }
1836
1837 // =======================================================================
1838 // function : Release
1839 // purpose  :
1840 // =======================================================================
1841 void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
1842 {
1843   if (!mySprite.IsNull())
1844   {
1845     if (!theCtx.IsNull())
1846     {
1847       if (mySpriteKey.IsEmpty())
1848       {
1849         theCtx->DelayedRelease (mySprite);
1850         theCtx->DelayedRelease (mySpriteA);
1851       }
1852       else
1853       {
1854         mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
1855         mySpriteA.Nullify();
1856         theCtx->ReleaseResource (mySpriteKey,  Standard_True);
1857         theCtx->ReleaseResource (mySpriteAKey, Standard_True);
1858       }
1859     }
1860     mySprite.Nullify();
1861     mySpriteA.Nullify();
1862   }
1863   mySpriteKey.Clear();
1864   mySpriteAKey.Clear();
1865 }