1 // Created on: 2011-07-14
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_AspectMarker.hxx>
17 #include <OpenGl_Context.hxx>
18 #include <OpenGl_GraphicDriver.hxx>
19 #include <OpenGl_PointSprite.hxx>
20 #include <OpenGl_ShaderManager.hxx>
21 #include <OpenGl_ShaderProgram.hxx>
22 #include <OpenGl_Workspace.hxx>
24 #include <Image_PixMap.hxx>
25 #include <Graphic3d_MarkerImage.hxx>
26 #include <Graphic3d_ShaderProgram.hxx>
27 #include <NCollection_Vec4.hxx>
28 #include <TColStd_HArray1OfByte.hxx>
32 static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
33 static const TCollection_AsciiString THE_EMPTY_KEY;
35 //! Draw inner point as filled rectangle
36 static Handle(TColStd_HArray1OfByte) fillPointBitmap (const Standard_Integer theSize)
38 // draw inner point as filled rectangle
39 const Standard_Integer aNumOfBytes = (theSize / 8 + (theSize % 8 ? 1 : 0)) * theSize;
40 Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
41 for (Standard_Integer anIter = 0; anIter < aBitMap->Length(); ++anIter)
43 aBitMap->SetValue (anIter, 255);
49 // Following Section relates to default markers
51 #define TEL_NO_OF_SIZES 13
52 #define TEL_PM_START_SIZE 1.0
53 #define TEL_PM_END_SIZE 7.0
60 typedef PM_FONT_INFO* pm_font_info;
62 #define PM_PLUS_10_NUM 9*2
63 #define PM_PLUS_15_NUM 11*2
64 #define PM_PLUS_20_NUM 13*2
65 #define PM_PLUS_25_NUM 15*2
66 #define PM_PLUS_30_NUM 17*3
67 #define PM_PLUS_35_NUM 19*3
68 #define PM_PLUS_40_NUM 21*3
69 #define PM_PLUS_45_NUM 23*3
70 #define PM_PLUS_50_NUM 25*4
71 #define PM_PLUS_55_NUM 27*4
72 #define PM_PLUS_60_NUM 29*4
73 #define PM_PLUS_65_NUM 31*4
74 #define PM_PLUS_70_NUM 32*4
76 #define PM_STAR_10_NUM 9
77 #define PM_STAR_15_NUM 11*2
78 #define PM_STAR_20_NUM 13*2
79 #define PM_STAR_25_NUM 15*2
80 #define PM_STAR_30_NUM 17*2
81 #define PM_STAR_35_NUM 19*2
82 #define PM_STAR_40_NUM 21*3
83 #define PM_STAR_45_NUM 23*3
84 #define PM_STAR_50_NUM 25*3
85 #define PM_STAR_55_NUM 27*3
86 #define PM_STAR_60_NUM 29*4
87 #define PM_STAR_65_NUM 32*4
88 #define PM_STAR_70_NUM 32*4
90 #define PM_CIRC_10_NUM 7
91 #define PM_CIRC_15_NUM 9*2
92 #define PM_CIRC_20_NUM 9*2
93 #define PM_CIRC_25_NUM 11*2
94 #define PM_CIRC_30_NUM 13*2
95 #define PM_CIRC_35_NUM 15*2
96 #define PM_CIRC_40_NUM 17*3
97 #define PM_CIRC_45_NUM 19*3
98 #define PM_CIRC_50_NUM 21*3
99 #define PM_CIRC_55_NUM 23*3
100 #define PM_CIRC_60_NUM 25*4
101 #define PM_CIRC_65_NUM 27*4
102 #define PM_CIRC_70_NUM 29*4
104 #define PM_CROSS_10_NUM 7
105 #define PM_CROSS_15_NUM 9*2
106 #define PM_CROSS_20_NUM 11*2
107 #define PM_CROSS_25_NUM 13*2
108 #define PM_CROSS_30_NUM 15*2
109 #define PM_CROSS_35_NUM 17*3
110 #define PM_CROSS_40_NUM 19*3
111 #define PM_CROSS_45_NUM 21*3
112 #define PM_CROSS_50_NUM 23*3
113 #define PM_CROSS_55_NUM 25*4
114 #define PM_CROSS_60_NUM 27*4
115 #define PM_CROSS_65_NUM 32*4
116 #define PM_CROSS_70_NUM 32*4
118 #define PM_PLUS_10_OFT 0
119 #define PM_PLUS_15_OFT PM_PLUS_10_OFT + PM_PLUS_10_NUM
120 #define PM_PLUS_20_OFT PM_PLUS_15_OFT + PM_PLUS_15_NUM
121 #define PM_PLUS_25_OFT PM_PLUS_20_OFT + PM_PLUS_20_NUM
122 #define PM_PLUS_30_OFT PM_PLUS_25_OFT + PM_PLUS_25_NUM
123 #define PM_PLUS_35_OFT PM_PLUS_30_OFT + PM_PLUS_30_NUM
124 #define PM_PLUS_40_OFT PM_PLUS_35_OFT + PM_PLUS_35_NUM
125 #define PM_PLUS_45_OFT PM_PLUS_40_OFT + PM_PLUS_40_NUM
126 #define PM_PLUS_50_OFT PM_PLUS_45_OFT + PM_PLUS_45_NUM
127 #define PM_PLUS_55_OFT PM_PLUS_50_OFT + PM_PLUS_50_NUM
128 #define PM_PLUS_60_OFT PM_PLUS_55_OFT + PM_PLUS_55_NUM
129 #define PM_PLUS_65_OFT PM_PLUS_60_OFT + PM_PLUS_60_NUM
130 #define PM_PLUS_70_OFT PM_PLUS_65_OFT + PM_PLUS_65_NUM
132 #define PM_STAR_10_OFT PM_PLUS_70_OFT + PM_PLUS_70_NUM
133 #define PM_STAR_15_OFT PM_STAR_10_OFT + PM_STAR_10_NUM
134 #define PM_STAR_20_OFT PM_STAR_15_OFT + PM_STAR_15_NUM
135 #define PM_STAR_25_OFT PM_STAR_20_OFT + PM_STAR_20_NUM
136 #define PM_STAR_30_OFT PM_STAR_25_OFT + PM_STAR_25_NUM
137 #define PM_STAR_35_OFT PM_STAR_30_OFT + PM_STAR_30_NUM
138 #define PM_STAR_40_OFT PM_STAR_35_OFT + PM_STAR_35_NUM
139 #define PM_STAR_45_OFT PM_STAR_40_OFT + PM_STAR_40_NUM
140 #define PM_STAR_50_OFT PM_STAR_45_OFT + PM_STAR_45_NUM
141 #define PM_STAR_55_OFT PM_STAR_50_OFT + PM_STAR_50_NUM
142 #define PM_STAR_60_OFT PM_STAR_55_OFT + PM_STAR_55_NUM
143 #define PM_STAR_65_OFT PM_STAR_60_OFT + PM_STAR_60_NUM
144 #define PM_STAR_70_OFT PM_STAR_65_OFT + PM_STAR_65_NUM
146 #define PM_CIRC_10_OFT PM_STAR_70_OFT + PM_STAR_70_NUM
147 #define PM_CIRC_15_OFT PM_CIRC_10_OFT + PM_CIRC_10_NUM
148 #define PM_CIRC_20_OFT PM_CIRC_15_OFT + PM_CIRC_15_NUM
149 #define PM_CIRC_25_OFT PM_CIRC_20_OFT + PM_CIRC_20_NUM
150 #define PM_CIRC_30_OFT PM_CIRC_25_OFT + PM_CIRC_25_NUM
151 #define PM_CIRC_35_OFT PM_CIRC_30_OFT + PM_CIRC_30_NUM
152 #define PM_CIRC_40_OFT PM_CIRC_35_OFT + PM_CIRC_35_NUM
153 #define PM_CIRC_45_OFT PM_CIRC_40_OFT + PM_CIRC_40_NUM
154 #define PM_CIRC_50_OFT PM_CIRC_45_OFT + PM_CIRC_45_NUM
155 #define PM_CIRC_55_OFT PM_CIRC_50_OFT + PM_CIRC_50_NUM
156 #define PM_CIRC_60_OFT PM_CIRC_55_OFT + PM_CIRC_55_NUM
157 #define PM_CIRC_65_OFT PM_CIRC_60_OFT + PM_CIRC_60_NUM
158 #define PM_CIRC_70_OFT PM_CIRC_65_OFT + PM_CIRC_65_NUM
160 #define PM_CROSS_10_OFT PM_CIRC_70_OFT + PM_CIRC_70_NUM
161 #define PM_CROSS_15_OFT PM_CROSS_10_OFT + PM_CROSS_10_NUM
162 #define PM_CROSS_20_OFT PM_CROSS_15_OFT + PM_CROSS_15_NUM
163 #define PM_CROSS_25_OFT PM_CROSS_20_OFT + PM_CROSS_20_NUM
164 #define PM_CROSS_30_OFT PM_CROSS_25_OFT + PM_CROSS_25_NUM
165 #define PM_CROSS_35_OFT PM_CROSS_30_OFT + PM_CROSS_30_NUM
166 #define PM_CROSS_40_OFT PM_CROSS_35_OFT + PM_CROSS_35_NUM
167 #define PM_CROSS_45_OFT PM_CROSS_40_OFT + PM_CROSS_40_NUM
168 #define PM_CROSS_50_OFT PM_CROSS_45_OFT + PM_CROSS_45_NUM
169 #define PM_CROSS_55_OFT PM_CROSS_50_OFT + PM_CROSS_50_NUM
170 #define PM_CROSS_60_OFT PM_CROSS_55_OFT + PM_CROSS_55_NUM
171 #define PM_CROSS_65_OFT PM_CROSS_60_OFT + PM_CROSS_60_NUM
172 #define PM_CROSS_70_OFT PM_CROSS_65_OFT + PM_CROSS_65_NUM
174 static const PM_FONT_INFO arrPMFontInfo[][TEL_NO_OF_SIZES] =
176 // TOM_POINT - not used
192 {{ 9.f, 9.f, PM_PLUS_10_OFT},
193 {11.f, 11.f, PM_PLUS_15_OFT},
194 {13.f, 13.f, PM_PLUS_20_OFT},
195 {15.f, 15.f, PM_PLUS_25_OFT},
196 {17.f, 17.f, PM_PLUS_30_OFT},
197 {19.f, 19.f, PM_PLUS_35_OFT},
198 {21.f, 21.f, PM_PLUS_40_OFT},
199 {23.f, 23.f, PM_PLUS_45_OFT},
200 {25.f, 25.f, PM_PLUS_50_OFT},
201 {27.f, 27.f, PM_PLUS_55_OFT},
202 {29.f, 29.f, PM_PLUS_60_OFT},
203 {31.f, 31.f, PM_PLUS_65_OFT},
204 {32.f, 32.f, PM_PLUS_70_OFT}},
207 {{ 7.f, 9.f, PM_STAR_10_OFT},
208 {9.f, 11.f, PM_STAR_15_OFT},
209 {11.f, 13.f, PM_STAR_20_OFT},
210 {13.f, 15.f, PM_STAR_25_OFT},
211 {13.f, 17.f, PM_STAR_30_OFT},
212 {15.f, 19.f, PM_STAR_35_OFT},
213 {17.f, 21.f, PM_STAR_40_OFT},
214 {19.f, 23.f, PM_STAR_45_OFT},
215 {21.f, 25.f, PM_STAR_50_OFT},
216 {23.f, 27.f, PM_STAR_55_OFT},
217 {25.f, 29.f, PM_STAR_60_OFT},
218 {32.f, 32.f, PM_STAR_65_OFT},
219 {32.f, 32.f, PM_STAR_70_OFT}},
222 {{ 7.f, 7.f, PM_CROSS_10_OFT},
223 { 9.f, 9.f, PM_CROSS_15_OFT},
224 {11.f, 11.f, PM_CROSS_20_OFT},
225 {13.f, 13.f, PM_CROSS_25_OFT},
226 {15.f, 15.f, PM_CROSS_30_OFT},
227 {17.f, 17.f, PM_CROSS_35_OFT},
228 {19.f, 19.f, PM_CROSS_40_OFT},
229 {21.f, 21.f, PM_CROSS_45_OFT},
230 {23.f, 23.f, PM_CROSS_50_OFT},
231 {25.f, 25.f, PM_CROSS_55_OFT},
232 {27.f, 27.f, PM_CROSS_60_OFT},
233 {32.f, 32.f, PM_CROSS_65_OFT},
234 {32.f, 32.f, PM_CROSS_70_OFT}},
237 {{ 7.f, 7.f, PM_CIRC_10_OFT},
238 { 9.f, 9.f, PM_CIRC_15_OFT},
239 { 9.f, 9.f, PM_CIRC_20_OFT},
240 {11.f, 11.f, PM_CIRC_25_OFT},
241 {13.f, 13.f, PM_CIRC_30_OFT},
242 {15.f, 15.f, PM_CIRC_35_OFT},
243 {17.f, 17.f, PM_CIRC_40_OFT},
244 {19.f, 19.f, PM_CIRC_45_OFT},
245 {21.f, 21.f, PM_CIRC_50_OFT},
246 {23.f, 23.f, PM_CIRC_55_OFT},
247 {25.f, 25.f, PM_CIRC_60_OFT},
248 {27.f, 27.f, PM_CIRC_65_OFT},
249 {29.f, 29.f, PM_CIRC_70_OFT}}
252 static const Standard_Byte OpenGl_AspectMarker_myMarkerRaster[] =
264 0x08,0x00, // PLUS 9x9 = 1.0
276 0x04,0x00, // PLUS 11x11 = 1.5
290 0x02,0x00, // PLUS 13x13 = 2.0
306 0x01,0x00, // PLUS 15x15 = 2.5
324 0x00,0x80, 0x00, // PLUS 17x17 = 3.0
344 0x00,0x40, 0x00, // PLUS 19x19 = 3.5
366 0x00,0x20, 0x00, // PLUS 21x21 = 4.0
390 0x00,0x10, 0x00, // PLUS 23x23 = 4.5
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,
400 0x00,0x08, 0x00,0x00,
401 0x00,0x08, 0x00,0x00,
402 0x00,0x08, 0x00,0x00,
403 0x00,0x08, 0x00,0x00,
404 0xff,0xff, 0xff,0x80,
405 0x00,0x08, 0x00,0x00,
406 0x00,0x08, 0x00,0x00,
407 0x00,0x08, 0x00,0x00,
408 0x00,0x08, 0x00,0x00,
409 0x00,0x08, 0x00,0x00,
410 0x00,0x08, 0x00,0x00,
411 0x00,0x08, 0x00,0x00,
412 0x00,0x08, 0x00,0x00,
413 0x00,0x08, 0x00,0x00,
414 0x00,0x08, 0x00,0x00,
415 0x00,0x08, 0x00,0x00,
416 0x00,0x08, 0x00,0x00, // PLUS 25x25 = 5.0
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,
428 0x00,0x04, 0x00,0x00,
429 0x00,0x04, 0x00,0x00,
430 0x00,0x04, 0x00,0x00,
431 0xff,0xff, 0xff,0xe0,
432 0x00,0x04, 0x00,0x00,
433 0x00,0x04, 0x00,0x00,
434 0x00,0x04, 0x00,0x00,
435 0x00,0x04, 0x00,0x00,
436 0x00,0x04, 0x00,0x00,
437 0x00,0x04, 0x00,0x00,
438 0x00,0x04, 0x00,0x00,
439 0x00,0x04, 0x00,0x00,
440 0x00,0x04, 0x00,0x00,
441 0x00,0x04, 0x00,0x00,
442 0x00,0x04, 0x00,0x00,
443 0x00,0x04, 0x00,0x00,
444 0x00,0x04, 0x00,0x00, // PLUS 27x27 = 5.5
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,
458 0x00,0x02, 0x00,0x00,
459 0x00,0x02, 0x00,0x00,
460 0xff,0xff, 0xff,0xf8,
461 0x00,0x02, 0x00,0x00,
462 0x00,0x02, 0x00,0x00,
463 0x00,0x02, 0x00,0x00,
464 0x00,0x02, 0x00,0x00,
465 0x00,0x02, 0x00,0x00,
466 0x00,0x02, 0x00,0x00,
467 0x00,0x02, 0x00,0x00,
468 0x00,0x02, 0x00,0x00,
469 0x00,0x02, 0x00,0x00,
470 0x00,0x02, 0x00,0x00,
471 0x00,0x02, 0x00,0x00,
472 0x00,0x02, 0x00,0x00,
473 0x00,0x02, 0x00,0x00,
474 0x00,0x02, 0x00,0x00, // PLUS 29x29 = 6.0
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,
490 0x00,0x01, 0x00,0x00,
491 0xff,0xff, 0xff,0xfd,
492 0x00,0x01, 0x00,0x00,
493 0x00,0x01, 0x00,0x00,
494 0x00,0x01, 0x00,0x00,
495 0x00,0x01, 0x00,0x00,
496 0x00,0x01, 0x00,0x00,
497 0x00,0x01, 0x00,0x00,
498 0x00,0x01, 0x00,0x00,
499 0x00,0x01, 0x00,0x00,
500 0x00,0x01, 0x00,0x00,
501 0x00,0x01, 0x00,0x00,
502 0x00,0x01, 0x00,0x00,
503 0x00,0x01, 0x00,0x00,
504 0x00,0x01, 0x00,0x00,
505 0x00,0x01, 0x00,0x00,
506 0x00,0x01, 0x00,0x00, // PLUS 31x31 = 6.5
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,
523 0x00,0x00, 0x80,0x00,
524 0xff,0xff, 0xff,0xff,
525 0x00,0x00, 0x80,0x00,
526 0x00,0x00, 0x80,0x00,
527 0x00,0x00, 0x80,0x00,
528 0x00,0x00, 0x80,0x00,
529 0x00,0x00, 0x80,0x00,
530 0x00,0x00, 0x80,0x00,
531 0x00,0x00, 0x80,0x00,
532 0x00,0x00, 0x80,0x00,
533 0x00,0x00, 0x80,0x00,
534 0x00,0x00, 0x80,0x00,
535 0x00,0x00, 0x80,0x00,
536 0x00,0x00, 0x80,0x00,
537 0x00,0x00, 0x80,0x00,
538 0x00,0x00, 0x80,0x00,
539 0x00,0x00, 0x80,0x00, // PLUS 32x32 = 7.0
551 0x10, // STAR 7x9 = 1.0
563 0x08,0x00, // STAR 9x11 = 1.5
577 0x04,0x00, // STAR 11x13 = 2.0
593 0x02,0x00, // STAR 13x15 = 2.5
611 0x02,0x00, // STAR 13x17 = 3.0
631 0x01,0x00, // STAR 15x19 = 3.5
653 0x00,0x80, 0x00, // STAR 17x21 = 4.0
677 0x00,0x40, 0x00, // STAR 19x23 = 4.5
703 0x00,0x20, 0x00, // STAR 21x25 = 5.0
731 0x00,0x10, 0x00, // STAR 23x27 = 5.5
733 0x00,0x08, 0x00,0x00,
734 0x00,0x08, 0x00,0x00,
735 0x00,0x08, 0x00,0x00,
736 0x00,0x08, 0x00,0x00,
737 0x00,0x08, 0x00,0x00,
738 0x00,0x08, 0x00,0x00,
739 0x00,0x08, 0x00,0x00,
740 0x80,0x08, 0x00,0x80,
741 0x60,0x08, 0x03,0x00,
742 0x18,0x08, 0x0c,0x00,
743 0x04,0x08, 0x30,0x00,
744 0x03,0x08, 0x40,0x00,
745 0x00,0xc9, 0x80,0x00,
746 0x00,0x3e, 0x00,0x00,
747 0x00,0x08, 0x00,0x00,
748 0x00,0x3e, 0x00,0x00,
749 0x00,0xc9, 0x80,0x00,
750 0x03,0x08, 0x40,0x00,
751 0x04,0x08, 0x30,0x00,
752 0x18,0x08, 0x0c,0x00,
753 0x60,0x08, 0x03,0x00,
754 0x80,0x08, 0x00,0x80,
755 0x00,0x08, 0x00,0x00,
756 0x00,0x08, 0x00,0x00,
757 0x00,0x08, 0x00,0x00,
758 0x00,0x08, 0x00,0x00,
759 0x00,0x08, 0x00,0x00,
760 0x00,0x08, 0x00,0x00,
761 0x00,0x08, 0x00,0x00, // STAR 25x29 = 6.0
763 0x00,0x00, 0x80,0x00,
764 0x00,0x00, 0x80,0x00,
765 0x00,0x00, 0x80,0x00,
766 0x00,0x00, 0x80,0x00,
767 0x00,0x00, 0x80,0x00,
768 0x00,0x00, 0x80,0x00,
769 0x00,0x00, 0x80,0x00,
770 0x00,0x00, 0x80,0x00,
771 0x00,0x00, 0x80,0x00,
772 0x30,0x00, 0x80,0x06,
773 0x0c,0x00, 0x80,0x18,
774 0x03,0x00, 0x80,0x60,
775 0x00,0xc0, 0x81,0x80,
776 0x00,0x30, 0x86,0x00,
777 0x00,0x0c, 0x98,0x00,
778 0x00,0x03, 0xe0,0x00,
779 0x00,0x03, 0xe0,0x00,
780 0x00,0x0c, 0x98,0x00,
781 0x00,0x30, 0x86,0x00,
782 0x00,0xc0, 0x81,0x80,
783 0x03,0x00, 0x80,0x60,
784 0x0c,0x00, 0x80,0x18,
785 0x30,0x00, 0x80,0x06,
786 0x00,0x00, 0x80,0x00,
787 0x00,0x00, 0x80,0x00,
788 0x00,0x00, 0x80,0x00,
789 0x00,0x00, 0x80,0x00,
790 0x00,0x00, 0x80,0x00,
791 0x00,0x00, 0x80,0x00,
792 0x00,0x00, 0x80,0x00,
793 0x00,0x00, 0x00,0x00,
794 0x00,0x00, 0x00,0x00, // STAR 32x32 = 6.5
796 0x00, 0x00, 0x80, 0x00,
797 0x00, 0x00, 0x80, 0x00,
798 0x00, 0x00, 0x80, 0x00,
799 0x00, 0x00, 0x80, 0x00,
800 0x00, 0x00, 0x80, 0x00,
801 0x00, 0x00, 0x80, 0x00,
802 0x00, 0x00, 0x80, 0x00,
803 0x00, 0x00, 0x80, 0x00,
804 0x10, 0x00, 0x80, 0x04,
805 0x0c, 0x00, 0x80, 0x18,
806 0x02, 0x00, 0x80, 0x20,
807 0x01, 0x80, 0x80, 0xc0,
808 0x00, 0x40, 0x81, 0x00,
809 0x00, 0x30, 0x86, 0x00,
810 0x00, 0x08, 0x88, 0x00,
811 0x00, 0x06, 0xb0, 0x00,
812 0x00, 0x01, 0xc0, 0x00,
813 0x00, 0x06, 0xb0, 0x00,
814 0x00, 0x08, 0x88, 0x00,
815 0x00, 0x30, 0x86, 0x00,
816 0x00, 0x40, 0x81, 0x00,
817 0x01, 0x80, 0x80, 0xc0,
818 0x02, 0x00, 0x80, 0x20,
819 0x0c, 0x00, 0x80, 0x18,
820 0x10, 0x00, 0x80, 0x04,
821 0x00, 0x00, 0x80, 0x00,
822 0x00, 0x00, 0x80, 0x00,
823 0x00, 0x00, 0x80, 0x00,
824 0x00, 0x00, 0x80, 0x00,
825 0x00, 0x00, 0x80, 0x00,
826 0x00, 0x00, 0x80, 0x00,
827 0x00, 0x00, 0x80, 0x00, // STAR 32x32 = 7.0
837 0x38, // CIRC 7x7 = 1.0
847 0x00,0x00, //CIRC 9x9 = 1.5
857 0x3e,0x00, // CIRC 9x9 = 2.0
869 0x1f,0x00, // CIRC 11x11 = 2.5
883 0x0f,0x80, // CIRC 13x13 = 3.0
899 0x07,0xc0, // CIRC 15x15 = 3.5
917 0x03,0xe0, 0x00, // CIRC 17x17 = 4.0
937 0x03,0xf8, 0x00, // CIRC 19x19 = 4.5
959 0x01,0xfc, 0x00, // CIRC 21x21 = 5.0
983 0x00,0xfe, 0x00, // CIRC 23x23 = 5.5
985 0x00,0x7f, 0x00,0x00,
986 0x01,0x80, 0xc0,0x00,
987 0x06,0x00, 0x30,0x00,
988 0x08,0x00, 0x08,0x00,
989 0x10,0x00, 0x04,0x00,
990 0x20,0x00, 0x02,0x00,
991 0x20,0x00, 0x02,0x00,
992 0x40,0x00, 0x01,0x00,
993 0x40,0x00, 0x01,0x00,
994 0x80,0x00, 0x00,0x80,
995 0x80,0x00, 0x00,0x80,
996 0x80,0x00, 0x00,0x80,
997 0x80,0x00, 0x00,0x80,
998 0x80,0x00, 0x00,0x80,
999 0x80,0x00, 0x00,0x80,
1000 0x80,0x00, 0x00,0x80,
1001 0x40,0x00, 0x01,0x00,
1002 0x40,0x00, 0x01,0x00,
1003 0x20,0x00, 0x02,0x00,
1004 0x20,0x00, 0x02,0x00,
1005 0x10,0x00, 0x04,0x00,
1006 0x08,0x00, 0x08,0x00,
1007 0x06,0x00, 0x30,0x00,
1008 0x01,0x80, 0xc0,0x00,
1009 0x00,0x7f, 0x00,0x00, // CIRC 25x25 = 6.0
1011 0x00,0x3f, 0x80,0x00,
1012 0x01,0xc0, 0x70,0x00,
1013 0x03,0x00, 0x18,0x00,
1014 0x0c,0x00, 0x06,0x00,
1015 0x18,0x00, 0x03,0x00,
1016 0x10,0x00, 0x01,0x00,
1017 0x20,0x00, 0x00,0x80,
1018 0x60,0x00, 0x00,0xc0,
1019 0x40,0x00, 0x00,0x40,
1020 0x40,0x00, 0x00,0x40,
1021 0x80,0x00, 0x00,0x20,
1022 0x80,0x00, 0x00,0x20,
1023 0x80,0x00, 0x00,0x20,
1024 0x80,0x00, 0x00,0x20,
1025 0x80,0x00, 0x00,0x20,
1026 0x80,0x00, 0x00,0x20,
1027 0x80,0x00, 0x00,0x20,
1028 0x40,0x00, 0x00,0x40,
1029 0x40,0x00, 0x00,0x40,
1030 0x60,0x00, 0x00,0xc0,
1031 0x20,0x00, 0x00,0x80,
1032 0x10,0x00, 0x01,0x00,
1033 0x18,0x00, 0x03,0x00,
1034 0x0c,0x00, 0x06,0x00,
1035 0x03,0x00, 0x18,0x00,
1036 0x01,0xc0, 0x70,0x00,
1037 0x00,0x3f, 0x80,0x00, // CIRC 27x27 = 6.5
1039 0x00,0x1f, 0xc0,0x00,
1040 0x00,0xe0, 0x38,0x00,
1041 0x01,0x00, 0x04,0x00,
1042 0x06,0x00, 0x03,0x00,
1043 0x08,0x00, 0x00,0x80,
1044 0x10,0x00, 0x00,0x40,
1045 0x10,0x00, 0x00,0x40,
1046 0x20,0x00, 0x00,0x20,
1047 0x40,0x00, 0x00,0x10,
1048 0x40,0x00, 0x00,0x10,
1049 0x40,0x00, 0x00,0x10,
1050 0x80,0x00, 0x00,0x08,
1051 0x80,0x00, 0x00,0x08,
1052 0x80,0x00, 0x00,0x08,
1053 0x80,0x00, 0x00,0x08,
1054 0x80,0x00, 0x00,0x08,
1055 0x80,0x00, 0x00,0x08,
1056 0x80,0x00, 0x00,0x08,
1057 0x40,0x00, 0x00,0x10,
1058 0x40,0x00, 0x00,0x10,
1059 0x40,0x00, 0x00,0x10,
1060 0x20,0x00, 0x00,0x20,
1061 0x10,0x00, 0x00,0x40,
1062 0x10,0x00, 0x00,0x40,
1063 0x08,0x00, 0x00,0x80,
1064 0x06,0x00, 0x03,0x00,
1065 0x01,0x00, 0x04,0x00,
1066 0x00,0xe0, 0x38,0x00,
1067 0x00,0x1f, 0xc0,0x00, // CIRC 29x29 = 7.0
1077 0x82, // CROSS 7x7 = 1.0
1087 0x80,0x80, // CROSS 9x9 = 1.5
1099 0x80,0x20, // CROSS 11x11 = 2.0
1113 0x80,0x08, // CROSS 13x13 = 2.5
1129 0x80,0x02, // CROSS 15x15 = 3.0
1147 0x80,0x00, 0x80, // CROSS 17x17 = 3.5
1167 0x80,0x00, 0x20, // CROSS 19x19 = 4.0
1189 0x80,0x00, 0x08,/* CROSS 21x21 = 4.5 */
1213 0x80,0x00, 0x02, // CROSS 23x23 = 5.0
1215 0x80,0x00, 0x00,0x80,
1216 0x40,0x00, 0x01,0x00,
1217 0x20,0x00, 0x02,0x00,
1218 0x10,0x00, 0x04,0x00,
1219 0x08,0x00, 0x08,0x00,
1220 0x04,0x00, 0x10,0x00,
1221 0x02,0x00, 0x20,0x00,
1222 0x01,0x00, 0x40,0x00,
1223 0x00,0x80, 0x80,0x00,
1224 0x00,0x41, 0x00,0x00,
1225 0x00,0x22, 0x00,0x00,
1226 0x00,0x14, 0x00,0x00,
1227 0x00,0x08, 0x00,0x00,
1228 0x00,0x14, 0x00,0x00,
1229 0x00,0x22, 0x00,0x00,
1230 0x00,0x41, 0x00,0x00,
1231 0x00,0x80, 0x80,0x00,
1232 0x01,0x00, 0x40,0x00,
1233 0x02,0x00, 0x20,0x00,
1234 0x04,0x00, 0x10,0x00,
1235 0x08,0x00, 0x08,0x00,
1236 0x10,0x00, 0x04,0x00,
1237 0x20,0x00, 0x02,0x00,
1238 0x40,0x00, 0x01,0x00,
1239 0x80,0x00, 0x00,0x80, // CROSS 25x25 = 5.5
1241 0x80,0x00, 0x00,0x20,
1242 0x40,0x00, 0x00,0x40,
1243 0x20,0x00, 0x00,0x80,
1244 0x10,0x00, 0x01,0x00,
1245 0x08,0x00, 0x02,0x00,
1246 0x04,0x00, 0x04,0x00,
1247 0x02,0x00, 0x08,0x00,
1248 0x01,0x00, 0x10,0x00,
1249 0x00,0x80, 0x20,0x00,
1250 0x00,0x40, 0x40,0x00,
1251 0x00,0x20, 0x80,0x00,
1252 0x00,0x11, 0x00,0x00,
1253 0x00,0x0a, 0x00,0x00,
1254 0x00,0x04, 0x00,0x00,
1255 0x00,0x0a, 0x00,0x00,
1256 0x00,0x11, 0x00,0x00,
1257 0x00,0x20, 0x80,0x00,
1258 0x00,0x40, 0x40,0x00,
1259 0x00,0x80, 0x20,0x00,
1260 0x01,0x00, 0x10,0x00,
1261 0x02,0x00, 0x08,0x00,
1262 0x04,0x00, 0x04,0x00,
1263 0x08,0x00, 0x02,0x00,
1264 0x10,0x00, 0x01,0x00,
1265 0x20,0x00, 0x00,0x80,
1266 0x40,0x00, 0x00,0x40,
1267 0x80,0x00, 0x00,0x20, // CROSS 27x27 = 6.0
1269 0x00,0x00, 0x00,0x00,
1270 0x00,0x00, 0x00,0x00,
1271 0x20,0x00, 0x00,0x04,
1272 0x10,0x00, 0x00,0x08,
1273 0x08,0x00, 0x00,0x10,
1274 0x04,0x00, 0x00,0x20,
1275 0x02,0x00, 0x00,0x40,
1276 0x01,0x00, 0x00,0x80,
1277 0x00,0x80, 0x01,0x00,
1278 0x00,0x40, 0x02,0x00,
1279 0x00,0x20, 0x04,0x00,
1280 0x00,0x10, 0x08,0x00,
1281 0x00,0x08, 0x10,0x00,
1282 0x00,0x04, 0x20,0x00,
1283 0x00,0x02, 0x40,0x00,
1284 0x00,0x01, 0x80,0x00,
1285 0x00,0x01, 0x80,0x00,
1286 0x00,0x02, 0x40,0x00,
1287 0x00,0x04, 0x20,0x00,
1288 0x00,0x08, 0x10,0x00,
1289 0x00,0x10, 0x08,0x00,
1290 0x00,0x20, 0x04,0x00,
1291 0x00,0x40, 0x02,0x00,
1292 0x00,0x80, 0x01,0x00,
1293 0x01,0x00, 0x00,0x80,
1294 0x02,0x00, 0x00,0x40,
1295 0x04,0x00, 0x00,0x20,
1296 0x08,0x00, 0x00,0x10,
1297 0x10,0x00, 0x00,0x08,
1298 0x20,0x00, 0x00,0x04,
1299 0x00,0x00, 0x00,0x00,
1300 0x00,0x00, 0x00,0x00, // CROSS 32x32 = 6.5
1302 0x00,0x00, 0x00,0x00,
1303 0x40,0x00, 0x00,0x02,
1304 0x20,0x00, 0x00,0x04,
1305 0x10,0x00, 0x00,0x08,
1306 0x08,0x00, 0x00,0x10,
1307 0x04,0x00, 0x00,0x20,
1308 0x02,0x00, 0x00,0x40,
1309 0x01,0x00, 0x00,0x80,
1310 0x00,0x80, 0x01,0x00,
1311 0x00,0x40, 0x02,0x00,
1312 0x00,0x20, 0x04,0x00,
1313 0x00,0x10, 0x08,0x00,
1314 0x00,0x08, 0x10,0x00,
1315 0x00,0x04, 0x20,0x00,
1316 0x00,0x02, 0x40,0x00,
1317 0x00,0x01, 0x80,0x00,
1318 0x00,0x01, 0x80,0x00,
1319 0x00,0x02, 0x40,0x00,
1320 0x00,0x04, 0x20,0x00,
1321 0x00,0x08, 0x10,0x00,
1322 0x00,0x10, 0x08,0x00,
1323 0x00,0x20, 0x04,0x00,
1324 0x00,0x40, 0x02,0x00,
1325 0x00,0x80, 0x01,0x00,
1326 0x01,0x00, 0x00,0x80,
1327 0x02,0x00, 0x00,0x40,
1328 0x04,0x00, 0x00,0x20,
1329 0x08,0x00, 0x00,0x10,
1330 0x10,0x00, 0x00,0x08,
1331 0x20,0x00, 0x00,0x04,
1332 0x40,0x00, 0x00,0x02,
1333 0x00,0x00, 0x00,0x00 // CROSS 32x32 = 7.0
1336 // =======================================================================
1337 // function : GetMarkerBitMapArray
1338 // purpose : Returns a parameters for the marker of the specified
1340 // =======================================================================
1341 void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
1342 const Standard_ShortReal& theScale,
1343 Standard_Integer& theWidth,
1344 Standard_Integer& theHeight,
1345 Standard_Integer& theOffset,
1346 Standard_Integer& theNumOfBytes)
1348 const Standard_Integer aType = (Standard_Integer )((theMarkerType > Aspect_TOM_O) ? Aspect_TOM_O : theMarkerType);
1349 const Standard_Real anIndex = (Standard_Real )(TEL_NO_OF_SIZES - 1) * (theScale - (Standard_Real )TEL_PM_START_SIZE)
1350 / (Standard_Real )(TEL_PM_END_SIZE - TEL_PM_START_SIZE);
1351 Standard_Integer anId = (Standard_Integer )(anIndex + 0.5);
1356 else if (anId >= TEL_NO_OF_SIZES)
1358 anId = TEL_NO_OF_SIZES - 1;
1361 theWidth = (Standard_Integer )arrPMFontInfo[aType][anId].width;
1362 theHeight = (Standard_Integer )arrPMFontInfo[aType][anId].height;
1363 theOffset = arrPMFontInfo[aType][anId].offset;
1364 const Standard_Integer aNumOfBytesInRow = theWidth / 8 + (theWidth % 8 ? 1 : 0);
1365 theNumOfBytes = theHeight * aNumOfBytesInRow;
1368 // =======================================================================
1369 // function : GetTextureImage
1370 // purpose : Returns a marker image for the marker of the specified
1372 // =======================================================================
1373 Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
1374 const Standard_ShortReal& theScale)
1376 Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1377 GetMarkerBitMapParam (theMarkerType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
1379 Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
1380 for (Standard_Integer anIter = 0; anIter < aNumOfBytes; anIter++)
1382 aBitMap->ChangeValue (anIter) = OpenGl_AspectMarker_myMarkerRaster[anOffset + anIter];
1385 Handle(Graphic3d_MarkerImage) aTexture = new Graphic3d_MarkerImage (aBitMap, aWidth, aHeight);
1389 // =======================================================================
1390 // function : MergeImages
1391 // purpose : Merge two image pixmap into one. Used for creating image for
1392 // following markers: Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS,
1393 // Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1,
1394 // Aspect_TOM_RING2, Aspect_TOM_RING3
1395 // =======================================================================
1396 Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
1397 const Handle(Image_PixMap)& theImage2)
1399 if (theImage1.IsNull() && theImage2.IsNull())
1401 return Handle(Image_PixMap)();
1404 Handle(Image_PixMap) aResultImage = new Image_PixMap();
1406 Standard_Integer aWidth1 (0), aHeight1 (0);
1407 if (!theImage1.IsNull())
1409 aWidth1 = (Standard_Integer )theImage1->Width();
1410 aHeight1 = (Standard_Integer )theImage1->Height();
1413 Standard_Integer aWidth2 (0), aHeight2 (0);
1414 if (!theImage2.IsNull())
1416 aWidth2 = (Standard_Integer )theImage2->Width();
1417 aHeight2 = (Standard_Integer )theImage2->Height();
1420 const Standard_Integer aMaxWidth = Max (aWidth1, aWidth2);
1421 const Standard_Integer aMaxHeight = Max (aHeight1, aHeight2);
1422 const Standard_Integer aSize = Max (aMaxWidth, aMaxHeight);
1424 aResultImage->InitZero (Image_PixMap::ImgGray, aSize, aSize);
1426 if (!theImage1.IsNull())
1428 const Standard_Integer aXOffset1 = Abs (aWidth1 - aMaxWidth) / 2;
1429 const Standard_Integer anYOffset1 = Abs (aHeight1 - aMaxHeight) / 2;
1430 for (Standard_Integer anY = 0; anY < aHeight1; anY++)
1432 Standard_Byte* anImageLine = theImage1->ChangeRow (anY);
1433 Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset1 + anY);
1434 for (Standard_Integer aX = 0; aX < aWidth1; aX++)
1436 aResultImageLine[aXOffset1 + aX] |= anImageLine[aX];
1441 if (!theImage2.IsNull())
1443 const Standard_Integer aXOffset2 = Abs (aWidth2 - aMaxWidth) / 2;
1444 const Standard_Integer anYOffset2 = Abs (aHeight2 - aMaxHeight) / 2;
1445 for (Standard_Integer anY = 0; anY < aHeight2; anY++)
1447 Standard_Byte* anImageLine = theImage2->ChangeRow (anY);
1448 Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset2 + anY);
1449 for (Standard_Integer aX = 0; aX < aWidth2; aX++)
1451 aResultImageLine[aXOffset2 + aX] |= anImageLine[aX];
1456 return aResultImage;
1459 // =======================================================================
1460 // function : OpenGl_AspectMarker
1462 // =======================================================================
1463 OpenGl_AspectMarker::OpenGl_AspectMarker()
1464 : myColor (myDefaultColor),
1465 myType (Aspect_TOM_PLUS),
1467 myMarkerSize (1.0f),
1472 // =======================================================================
1473 // function : SetAspect
1475 // =======================================================================
1476 void OpenGl_AspectMarker::SetAspect (const CALL_DEF_CONTEXTMARKER& theAspect)
1478 myColor.rgb[0] = (float )theAspect.Color.r;
1479 myColor.rgb[1] = (float )theAspect.Color.g;
1480 myColor.rgb[2] = (float )theAspect.Color.b;
1481 myColor.rgb[3] = 1.0f;
1482 myMarkerImage = theAspect.MarkerImage;
1483 myType = theAspect.MarkerType;
1484 myScale = theAspect.Scale;
1485 myShaderProgram = theAspect.ShaderProgram;
1487 // update sprite resource bindings
1488 TCollection_AsciiString aSpriteKey = THE_EMPTY_KEY;
1489 TCollection_AsciiString aSpriteAKey = THE_EMPTY_KEY;
1490 myResources.SpriteKeys (myMarkerImage, myType, myScale, myColor, aSpriteKey, aSpriteAKey);
1492 if (aSpriteKey.IsEmpty() || myResources.SpriteKey != aSpriteKey
1493 || aSpriteAKey.IsEmpty() || myResources.SpriteAKey != aSpriteAKey)
1495 myResources.ResetSpriteReadiness();
1496 myMarkerSize = theAspect.Scale;
1499 // update shader program resource bindings
1500 const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId();
1502 if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
1504 myResources.ResetShaderReadiness();
1508 // =======================================================================
1509 // function : Render
1511 // =======================================================================
1512 void OpenGl_AspectMarker::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
1514 theWorkspace->SetAspectMarker (this);
1517 // =======================================================================
1518 // function : Release
1520 // =======================================================================
1521 void OpenGl_AspectMarker::Release (OpenGl_Context* theCtx)
1523 if (!myResources.Sprite.IsNull())
1527 if (myResources.SpriteKey.IsEmpty())
1529 theCtx->DelayedRelease (myResources.Sprite);
1530 theCtx->DelayedRelease (myResources.SpriteA);
1534 myResources.Sprite.Nullify(); // we need nullify all handles before ReleaseResource() call
1535 myResources.SpriteA.Nullify();
1536 theCtx->ReleaseResource (myResources.SpriteKey, Standard_True);
1537 theCtx->ReleaseResource (myResources.SpriteAKey, Standard_True);
1540 myResources.Sprite.Nullify();
1541 myResources.SpriteA.Nullify();
1543 myResources.SpriteKey.Clear();
1544 myResources.SpriteAKey.Clear();
1545 myResources.ResetSpriteReadiness();
1547 if (!myResources.ShaderProgram.IsNull() && theCtx)
1549 theCtx->ShaderManager()->Unregister (myResources.ShaderProgramId,
1550 myResources.ShaderProgram);
1552 myResources.ShaderProgramId.Clear();
1553 myResources.ResetShaderReadiness();
1556 // =======================================================================
1557 // function : BuildSprites
1559 // =======================================================================
1560 void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Context)& theCtx,
1561 const Handle(Graphic3d_MarkerImage)& theMarkerImage,
1562 const Aspect_TypeOfMarker theType,
1563 const Standard_ShortReal theScale,
1564 const TEL_COLOUR& theColor,
1565 Standard_ShortReal& theMarkerSize)
1567 // generate key for shared resource
1568 TCollection_AsciiString aNewKey = THE_EMPTY_KEY;
1569 TCollection_AsciiString aNewKeyA = THE_EMPTY_KEY;
1570 SpriteKeys (theMarkerImage, theType, theScale, theColor, aNewKey, aNewKeyA);
1572 // release old shared resources
1573 const Standard_Boolean aNewResource = aNewKey.IsEmpty() || SpriteKey != aNewKey;
1576 if (!Sprite.IsNull())
1578 if (SpriteKey.IsEmpty())
1580 theCtx->DelayedRelease (Sprite);
1585 Sprite.Nullify(); // we need nullify all handles before ReleaseResource() call
1586 theCtx->ReleaseResource (SpriteKey, Standard_True);
1589 SpriteKey = aNewKey;
1591 if (aNewKeyA.IsEmpty() || SpriteAKey != aNewKeyA)
1593 if (!SpriteA.IsNull())
1595 if (SpriteAKey.IsEmpty())
1597 theCtx->DelayedRelease (SpriteA);
1602 SpriteA.Nullify(); // we need nullify all handles before ReleaseResource() call
1603 theCtx->ReleaseResource (SpriteAKey, Standard_True);
1606 SpriteAKey = aNewKeyA;
1608 if (theType == Aspect_TOM_POINT
1610 || (theType == Aspect_TOM_USERDEFINED && theMarkerImage.IsNull()))
1612 // nothing to do - just simple point
1616 if (!aNewKey.IsEmpty()
1617 && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, SpriteA) // alpha sprite could be shared
1618 && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, Sprite))
1620 // reuse shared resource
1621 if (!Sprite->IsDisplayList())
1623 theMarkerSize = Standard_ShortReal (Max (Sprite->SizeX(), Sprite->SizeY()));
1628 const bool hadAlreadyAlpha = !SpriteA.IsNull();
1629 if (!hadAlreadyAlpha)
1631 SpriteA = new OpenGl_PointSprite();
1633 Sprite = new OpenGl_PointSprite();
1634 if (!aNewKey.IsEmpty())
1636 theCtx->ShareResource (aNewKey, Sprite);
1637 if (!hadAlreadyAlpha)
1639 theCtx->ShareResource (aNewKeyA, SpriteA);
1643 if (!theCtx.IsNull()
1644 && theCtx->IsGlGreaterEqual (2, 0)
1645 && !theCtx->caps->pntSpritesDisable)
1647 // Creating texture resource for using it with point sprites
1648 Handle(Graphic3d_MarkerImage) aNewMarkerImage;
1649 Handle(Image_PixMap) anImage, anImageA;
1651 if (theType == Aspect_TOM_USERDEFINED && !theMarkerImage.IsNull())
1653 aNewMarkerImage = theMarkerImage;
1654 anImage = aNewMarkerImage->GetImage();
1658 // Creating image from default bitmap
1659 Handle(Graphic3d_MarkerImage) aMarkerImage1, aMarkerImage2;
1661 const Standard_ShortReal aDelta = 0.1F;
1662 Standard_ShortReal aScale = theScale;
1663 Standard_ShortReal aLimit = 0.0F;
1667 case Aspect_TOM_O_POINT:
1669 // draw inner point as filled rectangle
1670 const Standard_Integer aSize = theScale > 7 ? 7 : (Standard_Integer )(theScale + 0.5F);
1671 Handle(TColStd_HArray1OfByte) aBitMap = fillPointBitmap (aSize);
1672 aMarkerImage2 = new Graphic3d_MarkerImage (aBitMap, aSize, aSize);
1674 case Aspect_TOM_O_PLUS:
1675 case Aspect_TOM_O_STAR:
1676 case Aspect_TOM_O_X:
1678 // For this type of markers we merge two base bitmaps into one
1679 // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
1680 aMarkerImage1 = GetTextureImage (Aspect_TOM_O, theScale);
1681 if (theType != Aspect_TOM_O_POINT)
1683 aMarkerImage2 = GetTextureImage (Aspect_TypeOfMarker (theType - Aspect_TOM_O_POINT), theScale);
1685 anImage = MergeImages (aMarkerImage1->GetImage(), aMarkerImage2->GetImage());
1686 aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
1689 case Aspect_TOM_RING1:
1690 if (aLimit == 0.0f) aLimit = aScale * 0.2f;
1691 case Aspect_TOM_RING2:
1692 if (aLimit == 0.0f) aLimit = aScale * 0.5f;
1693 case Aspect_TOM_RING3:
1695 if (aLimit == 0.0f) aLimit = aScale * 0.8f;
1696 for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
1698 anImage = MergeImages (anImage, GetTextureImage (Aspect_TOM_O, aScale)->GetImage());
1700 aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
1703 case Aspect_TOM_BALL:
1705 Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1706 GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1708 const Standard_ShortReal aDelta = 0.1f;
1709 NCollection_Vec4<Standard_Real> aColor (Standard_Real (theColor.rgb[0]),
1710 Standard_Real (theColor.rgb[1]),
1711 Standard_Real (theColor.rgb[2]),
1712 Standard_Real (theColor.rgb[3]));
1714 const Standard_Integer aSize = Max (aWidth + 2, aHeight + 2); // includes extra margin
1715 anImage = new Image_PixMap();
1716 anImageA = new Image_PixMap();
1717 anImage ->InitZero (Image_PixMap::ImgBGRA, aSize, aSize);
1718 anImageA->InitZero (Image_PixMap::ImgGray, aSize, aSize);
1720 // we draw a set of circles
1721 Image_ColorBGRA aColor32;
1723 Standard_Real aHLS[3];
1724 while (aScale >= 1.0f)
1726 Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
1727 aHLS[2] *= 0.95; // 5% saturation change
1728 Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
1729 aColor32.r() = Standard_Byte(255.0 * aColor.r());
1730 aColor32.g() = Standard_Byte(255.0 * aColor.g());
1731 aColor32.b() = Standard_Byte(255.0 * aColor.b());
1733 const Handle(Graphic3d_MarkerImage) aMarker = GetTextureImage (Aspect_TOM_O, aScale);
1734 const Handle(Image_PixMap)& aCircle = aMarker->GetImage();
1736 const Standard_Size aDiffX = (anImage->SizeX() - aCircle->SizeX()) / 2;
1737 const Standard_Size aDiffY = (anImage->SizeY() - aCircle->SizeY()) / 2;
1738 for (Standard_Size aRow = 0; aRow < aCircle->SizeY(); ++aRow)
1740 const Standard_Byte* aRowData = aCircle->Row (aRow);
1741 for (Standard_Size aCol = 0; aCol < aCircle->SizeX(); ++aCol)
1743 if (aRowData[aCol] != 0)
1745 anImage ->ChangeValue<Image_ColorBGRA> (aDiffX + aRow, aDiffY + aCol) = aColor32;
1746 anImageA->ChangeValue<Standard_Byte> (aDiffX + aRow, aDiffY + aCol) = 255;
1756 aNewMarkerImage = GetTextureImage (theType, theScale);
1757 anImage = aNewMarkerImage->GetImage();
1763 theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
1765 Sprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
1766 if (!hadAlreadyAlpha)
1768 if (anImageA.IsNull()
1769 && Sprite->GetFormat() != GL_ALPHA
1770 && !aNewMarkerImage.IsNull())
1772 anImageA = aNewMarkerImage->GetImageAlpha();
1774 if (!anImageA.IsNull())
1776 SpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
1782 #if !defined(GL_ES_VERSION_2_0)
1783 // Creating list with bitmap for using it in compatibility mode
1784 GLuint aBitmapList = glGenLists (1);
1785 Sprite->SetDisplayList (theCtx, aBitmapList);
1787 Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1788 if (theType == Aspect_TOM_USERDEFINED && !theMarkerImage.IsNull())
1790 // Reading user defined marker
1791 Handle(TColStd_HArray1OfByte) aBitMap = theMarkerImage->GetBitMapArray();
1792 Standard_Byte* aBitMapArray = new Standard_Byte[aBitMap->Length()];
1793 theMarkerImage->GetTextureSize (aWidth, aHeight);
1795 // We should pass bitmap to glBitmap with reversed line order as it draws it from
1797 const Standard_Integer aNumOfBytesInRow = aWidth / 8 + (aWidth % 8 ? 1 : 0);
1798 const Standard_Integer anUpperIndex = aBitMap->Upper();
1799 for (Standard_Integer aRow = 0; aRow < aHeight; aRow++)
1801 for (Standard_Integer aByteIter = 0; aByteIter < aNumOfBytesInRow; aByteIter++)
1803 aBitMapArray[aRow * aNumOfBytesInRow + aByteIter] =
1804 aBitMap->Value (anUpperIndex + 1 - (aRow + 1) * aNumOfBytesInRow + aByteIter);
1808 if (aBitMapArray != NULL)
1810 glNewList (aBitmapList, GL_COMPILE);
1811 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1812 0.f, 0.f, (const GLubyte* )aBitMapArray);
1818 // Creating list for default marker
1819 const Standard_ShortReal aDelta = 0.1f;
1820 Standard_ShortReal aScale = theScale;
1821 Standard_ShortReal aLimit = 0.0f;
1823 glNewList (aBitmapList, GL_COMPILE);
1826 case Aspect_TOM_O_POINT:
1828 // draw inner point as filled rectangle
1829 const Standard_Integer aSize = theScale > 7 ? 7 : (Standard_Integer )(theScale + 0.5F);
1830 Handle(TColStd_HArray1OfByte) aBitMap = fillPointBitmap (aSize);
1831 glBitmap (aSize, aSize, (GLfloat )(0.5f * aSize), (GLfloat )(0.5f * aSize),
1832 0.0f, 0.0f, &aBitMap->Array1().Value (aBitMap->Lower()));
1834 case Aspect_TOM_O_PLUS:
1835 case Aspect_TOM_O_STAR:
1836 case Aspect_TOM_O_X:
1838 // For this type of markers we merge two base bitmaps into one
1839 // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
1840 GetMarkerBitMapParam (Aspect_TOM_O, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
1841 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1842 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1843 if (theType != Aspect_TOM_O_POINT)
1845 GetMarkerBitMapParam (Aspect_TypeOfMarker (theType - Aspect_TOM_O_POINT), theScale, aWidth, aHeight, anOffset, aNumOfBytes);
1846 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1847 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1851 case Aspect_TOM_BALL:
1853 const Standard_ShortReal aDelta = 0.1f;
1854 NCollection_Vec4<Standard_Real> aColor (Standard_Real (theColor.rgb[0]),
1855 Standard_Real (theColor.rgb[1]),
1856 Standard_Real (theColor.rgb[2]),
1857 Standard_Real (theColor.rgb[3]));
1859 // we draw a set of circles
1860 while (aScale >= 1.0f)
1862 Standard_Real aHLS[3];
1863 Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
1864 // 5% saturation change
1866 Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
1868 glColor4dv (aColor);
1869 GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1870 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1871 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1877 case Aspect_TOM_RING1:
1878 if (aLimit == 0.0f) aLimit = aScale * 0.2f;
1879 case Aspect_TOM_RING2:
1880 if (aLimit == 0.0f) aLimit = aScale * 0.5f;
1881 case Aspect_TOM_RING3:
1883 if (aLimit == 0.0f) aLimit = aScale * 0.8f;
1884 for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
1886 GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1887 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1888 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1894 GetMarkerBitMapParam (theType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
1895 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1896 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1906 // =======================================================================
1907 // function : BuildShader
1909 // =======================================================================
1910 void OpenGl_AspectMarker::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
1911 const Handle(Graphic3d_ShaderProgram)& theShader)
1913 if (!theCtx->IsGlGreaterEqual (2, 0))
1918 // release old shader program resources
1919 if (!ShaderProgram.IsNull())
1921 theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
1922 ShaderProgramId.Clear();
1923 ShaderProgram.Nullify();
1925 if (theShader.IsNull())
1930 theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
1933 // =======================================================================
1934 // function : resourceKeys
1936 // =======================================================================
1937 void OpenGl_AspectMarker::Resources::SpriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
1938 const Aspect_TypeOfMarker theType,
1939 const Standard_ShortReal theScale,
1940 const TEL_COLOUR& theColor,
1941 TCollection_AsciiString& theKey,
1942 TCollection_AsciiString& theKeyA)
1944 // generate key for shared resource
1945 if (theType == Aspect_TOM_USERDEFINED)
1947 if (!theMarkerImage.IsNull())
1949 theKey = theMarkerImage->GetImageId();
1950 theKeyA = theMarkerImage->GetImageAlphaId();
1953 else if (theType != Aspect_TOM_POINT)
1955 // predefined markers
1956 const Standard_Integer aScale = Standard_Integer(theScale + 0.5f);
1957 theKey = TCollection_AsciiString ("OpenGl_AspectMarker") + theType + "_" + aScale;
1958 theKeyA = theKey + "A";
1959 if (theType == Aspect_TOM_BALL)
1961 unsigned int aColor[3] =
1963 (unsigned int )(255.0f * theColor.rgb[0]),
1964 (unsigned int )(255.0f * theColor.rgb[1]),
1965 (unsigned int )(255.0f * theColor.rgb[2])
1968 sprintf (aBytes, "%02X%02X%02X", aColor[0], aColor[1], aColor[2]);