1 // Created on: 2011-07-14
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
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.
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.
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.
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>
26 #include <Image_PixMap.hxx>
27 #include <Graphic3d_MarkerImage.hxx>
28 #include <NCollection_Vec4.hxx>
29 #include <TColStd_HArray1OfByte.hxx>
31 static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
33 // Following Section relates to default markers
35 #define TEL_NO_OF_SIZES 13
36 #define TEL_PM_START_SIZE 1.0
37 #define TEL_PM_END_SIZE 7.0
44 typedef PM_FONT_INFO* pm_font_info;
46 #define PM_PLUS_10_NUM 9*2
47 #define PM_PLUS_15_NUM 11*2
48 #define PM_PLUS_20_NUM 13*2
49 #define PM_PLUS_25_NUM 15*2
50 #define PM_PLUS_30_NUM 17*3
51 #define PM_PLUS_35_NUM 19*3
52 #define PM_PLUS_40_NUM 21*3
53 #define PM_PLUS_45_NUM 23*3
54 #define PM_PLUS_50_NUM 25*4
55 #define PM_PLUS_55_NUM 27*4
56 #define PM_PLUS_60_NUM 29*4
57 #define PM_PLUS_65_NUM 31*4
58 #define PM_PLUS_70_NUM 32*4
60 #define PM_STAR_10_NUM 9
61 #define PM_STAR_15_NUM 11*2
62 #define PM_STAR_20_NUM 13*2
63 #define PM_STAR_25_NUM 15*2
64 #define PM_STAR_30_NUM 17*2
65 #define PM_STAR_35_NUM 19*2
66 #define PM_STAR_40_NUM 21*3
67 #define PM_STAR_45_NUM 23*3
68 #define PM_STAR_50_NUM 25*3
69 #define PM_STAR_55_NUM 27*3
70 #define PM_STAR_60_NUM 29*4
71 #define PM_STAR_65_NUM 32*4
72 #define PM_STAR_70_NUM 32*4
74 #define PM_CIRC_10_NUM 7
75 #define PM_CIRC_15_NUM 9*2
76 #define PM_CIRC_20_NUM 9*2
77 #define PM_CIRC_25_NUM 11*2
78 #define PM_CIRC_30_NUM 13*2
79 #define PM_CIRC_35_NUM 15*2
80 #define PM_CIRC_40_NUM 17*3
81 #define PM_CIRC_45_NUM 19*3
82 #define PM_CIRC_50_NUM 21*3
83 #define PM_CIRC_55_NUM 23*3
84 #define PM_CIRC_60_NUM 25*4
85 #define PM_CIRC_65_NUM 27*4
86 #define PM_CIRC_70_NUM 29*4
88 #define PM_CROSS_10_NUM 7
89 #define PM_CROSS_15_NUM 9*2
90 #define PM_CROSS_20_NUM 11*2
91 #define PM_CROSS_25_NUM 13*2
92 #define PM_CROSS_30_NUM 15*2
93 #define PM_CROSS_35_NUM 17*3
94 #define PM_CROSS_40_NUM 19*3
95 #define PM_CROSS_45_NUM 21*3
96 #define PM_CROSS_50_NUM 23*3
97 #define PM_CROSS_55_NUM 25*4
98 #define PM_CROSS_60_NUM 27*4
99 #define PM_CROSS_65_NUM 32*4
100 #define PM_CROSS_70_NUM 32*4
102 #define PM_PLUS_10_OFT 0
103 #define PM_PLUS_15_OFT PM_PLUS_10_OFT + PM_PLUS_10_NUM
104 #define PM_PLUS_20_OFT PM_PLUS_15_OFT + PM_PLUS_15_NUM
105 #define PM_PLUS_25_OFT PM_PLUS_20_OFT + PM_PLUS_20_NUM
106 #define PM_PLUS_30_OFT PM_PLUS_25_OFT + PM_PLUS_25_NUM
107 #define PM_PLUS_35_OFT PM_PLUS_30_OFT + PM_PLUS_30_NUM
108 #define PM_PLUS_40_OFT PM_PLUS_35_OFT + PM_PLUS_35_NUM
109 #define PM_PLUS_45_OFT PM_PLUS_40_OFT + PM_PLUS_40_NUM
110 #define PM_PLUS_50_OFT PM_PLUS_45_OFT + PM_PLUS_45_NUM
111 #define PM_PLUS_55_OFT PM_PLUS_50_OFT + PM_PLUS_50_NUM
112 #define PM_PLUS_60_OFT PM_PLUS_55_OFT + PM_PLUS_55_NUM
113 #define PM_PLUS_65_OFT PM_PLUS_60_OFT + PM_PLUS_60_NUM
114 #define PM_PLUS_70_OFT PM_PLUS_65_OFT + PM_PLUS_65_NUM
116 #define PM_STAR_10_OFT PM_PLUS_70_OFT + PM_PLUS_70_NUM
117 #define PM_STAR_15_OFT PM_STAR_10_OFT + PM_STAR_10_NUM
118 #define PM_STAR_20_OFT PM_STAR_15_OFT + PM_STAR_15_NUM
119 #define PM_STAR_25_OFT PM_STAR_20_OFT + PM_STAR_20_NUM
120 #define PM_STAR_30_OFT PM_STAR_25_OFT + PM_STAR_25_NUM
121 #define PM_STAR_35_OFT PM_STAR_30_OFT + PM_STAR_30_NUM
122 #define PM_STAR_40_OFT PM_STAR_35_OFT + PM_STAR_35_NUM
123 #define PM_STAR_45_OFT PM_STAR_40_OFT + PM_STAR_40_NUM
124 #define PM_STAR_50_OFT PM_STAR_45_OFT + PM_STAR_45_NUM
125 #define PM_STAR_55_OFT PM_STAR_50_OFT + PM_STAR_50_NUM
126 #define PM_STAR_60_OFT PM_STAR_55_OFT + PM_STAR_55_NUM
127 #define PM_STAR_65_OFT PM_STAR_60_OFT + PM_STAR_60_NUM
128 #define PM_STAR_70_OFT PM_STAR_65_OFT + PM_STAR_65_NUM
130 #define PM_CIRC_10_OFT PM_STAR_70_OFT + PM_STAR_70_NUM
131 #define PM_CIRC_15_OFT PM_CIRC_10_OFT + PM_CIRC_10_NUM
132 #define PM_CIRC_20_OFT PM_CIRC_15_OFT + PM_CIRC_15_NUM
133 #define PM_CIRC_25_OFT PM_CIRC_20_OFT + PM_CIRC_20_NUM
134 #define PM_CIRC_30_OFT PM_CIRC_25_OFT + PM_CIRC_25_NUM
135 #define PM_CIRC_35_OFT PM_CIRC_30_OFT + PM_CIRC_30_NUM
136 #define PM_CIRC_40_OFT PM_CIRC_35_OFT + PM_CIRC_35_NUM
137 #define PM_CIRC_45_OFT PM_CIRC_40_OFT + PM_CIRC_40_NUM
138 #define PM_CIRC_50_OFT PM_CIRC_45_OFT + PM_CIRC_45_NUM
139 #define PM_CIRC_55_OFT PM_CIRC_50_OFT + PM_CIRC_50_NUM
140 #define PM_CIRC_60_OFT PM_CIRC_55_OFT + PM_CIRC_55_NUM
141 #define PM_CIRC_65_OFT PM_CIRC_60_OFT + PM_CIRC_60_NUM
142 #define PM_CIRC_70_OFT PM_CIRC_65_OFT + PM_CIRC_65_NUM
144 #define PM_CROSS_10_OFT PM_CIRC_70_OFT + PM_CIRC_70_NUM
145 #define PM_CROSS_15_OFT PM_CROSS_10_OFT + PM_CROSS_10_NUM
146 #define PM_CROSS_20_OFT PM_CROSS_15_OFT + PM_CROSS_15_NUM
147 #define PM_CROSS_25_OFT PM_CROSS_20_OFT + PM_CROSS_20_NUM
148 #define PM_CROSS_30_OFT PM_CROSS_25_OFT + PM_CROSS_25_NUM
149 #define PM_CROSS_35_OFT PM_CROSS_30_OFT + PM_CROSS_30_NUM
150 #define PM_CROSS_40_OFT PM_CROSS_35_OFT + PM_CROSS_35_NUM
151 #define PM_CROSS_45_OFT PM_CROSS_40_OFT + PM_CROSS_40_NUM
152 #define PM_CROSS_50_OFT PM_CROSS_45_OFT + PM_CROSS_45_NUM
153 #define PM_CROSS_55_OFT PM_CROSS_50_OFT + PM_CROSS_50_NUM
154 #define PM_CROSS_60_OFT PM_CROSS_55_OFT + PM_CROSS_55_NUM
155 #define PM_CROSS_65_OFT PM_CROSS_60_OFT + PM_CROSS_60_NUM
156 #define PM_CROSS_70_OFT PM_CROSS_65_OFT + PM_CROSS_65_NUM
158 static const PM_FONT_INFO arrPMFontInfo[][TEL_NO_OF_SIZES] =
160 // TOM_POINT - not used
176 {{ 9.f, 9.f, PM_PLUS_10_OFT},
177 {11.f, 11.f, PM_PLUS_15_OFT},
178 {13.f, 13.f, PM_PLUS_20_OFT},
179 {15.f, 15.f, PM_PLUS_25_OFT},
180 {17.f, 17.f, PM_PLUS_30_OFT},
181 {19.f, 19.f, PM_PLUS_35_OFT},
182 {21.f, 21.f, PM_PLUS_40_OFT},
183 {23.f, 23.f, PM_PLUS_45_OFT},
184 {25.f, 25.f, PM_PLUS_50_OFT},
185 {27.f, 27.f, PM_PLUS_55_OFT},
186 {29.f, 29.f, PM_PLUS_60_OFT},
187 {31.f, 31.f, PM_PLUS_65_OFT},
188 {32.f, 32.f, PM_PLUS_70_OFT}},
191 {{ 7.f, 9.f, PM_STAR_10_OFT},
192 {9.f, 11.f, PM_STAR_15_OFT},
193 {11.f, 13.f, PM_STAR_20_OFT},
194 {13.f, 15.f, PM_STAR_25_OFT},
195 {13.f, 17.f, PM_STAR_30_OFT},
196 {15.f, 19.f, PM_STAR_35_OFT},
197 {17.f, 21.f, PM_STAR_40_OFT},
198 {19.f, 23.f, PM_STAR_45_OFT},
199 {21.f, 25.f, PM_STAR_50_OFT},
200 {23.f, 27.f, PM_STAR_55_OFT},
201 {25.f, 29.f, PM_STAR_60_OFT},
202 {32.f, 32.f, PM_STAR_65_OFT},
203 {32.f, 32.f, PM_STAR_70_OFT}},
206 {{ 7.f, 7.f, PM_CROSS_10_OFT},
207 { 9.f, 9.f, PM_CROSS_15_OFT},
208 {11.f, 11.f, PM_CROSS_20_OFT},
209 {13.f, 13.f, PM_CROSS_25_OFT},
210 {15.f, 15.f, PM_CROSS_30_OFT},
211 {17.f, 17.f, PM_CROSS_35_OFT},
212 {19.f, 19.f, PM_CROSS_40_OFT},
213 {21.f, 21.f, PM_CROSS_45_OFT},
214 {23.f, 23.f, PM_CROSS_50_OFT},
215 {25.f, 25.f, PM_CROSS_55_OFT},
216 {27.f, 27.f, PM_CROSS_60_OFT},
217 {32.f, 32.f, PM_CROSS_65_OFT},
218 {32.f, 32.f, PM_CROSS_70_OFT}},
221 {{ 7.f, 7.f, PM_CIRC_10_OFT},
222 { 9.f, 9.f, PM_CIRC_15_OFT},
223 { 9.f, 9.f, PM_CIRC_20_OFT},
224 {11.f, 11.f, PM_CIRC_25_OFT},
225 {13.f, 13.f, PM_CIRC_30_OFT},
226 {15.f, 15.f, PM_CIRC_35_OFT},
227 {17.f, 17.f, PM_CIRC_40_OFT},
228 {19.f, 19.f, PM_CIRC_45_OFT},
229 {21.f, 21.f, PM_CIRC_50_OFT},
230 {23.f, 23.f, PM_CIRC_55_OFT},
231 {25.f, 25.f, PM_CIRC_60_OFT},
232 {27.f, 27.f, PM_CIRC_65_OFT},
233 {29.f, 29.f, PM_CIRC_70_OFT}}
236 static const Standard_Byte OpenGl_AspectMarker_myMarkerRaster[] =
248 0x08,0x00, // PLUS 9x9 = 1.0
260 0x04,0x00, // PLUS 11x11 = 1.5
274 0x02,0x00, // PLUS 13x13 = 2.0
290 0x01,0x00, // PLUS 15x15 = 2.5
308 0x00,0x80, 0x00, // PLUS 17x17 = 3.0
328 0x00,0x40, 0x00, // PLUS 19x19 = 3.5
350 0x00,0x20, 0x00, // PLUS 21x21 = 4.0
374 0x00,0x10, 0x00, // PLUS 23x23 = 4.5
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 0x00,0x08, 0x00,0x00,
388 0xff,0xff, 0xff,0x80,
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,
400 0x00,0x08, 0x00,0x00, // PLUS 25x25 = 5.0
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 0x00,0x04, 0x00,0x00,
415 0xff,0xff, 0xff,0xe0,
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,
428 0x00,0x04, 0x00,0x00, // PLUS 27x27 = 5.5
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 0x00,0x02, 0x00,0x00,
444 0xff,0xff, 0xff,0xf8,
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,
458 0x00,0x02, 0x00,0x00, // PLUS 29x29 = 6.0
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 0x00,0x01, 0x00,0x00,
475 0xff,0xff, 0xff,0xfd,
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, // PLUS 31x31 = 6.5
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 0x00,0x00, 0x80,0x00,
508 0xff,0xff, 0xff,0xff,
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, // PLUS 32x32 = 7.0
535 0x10, // STAR 7x9 = 1.0
547 0x08,0x00, // STAR 9x11 = 1.5
561 0x04,0x00, // STAR 11x13 = 2.0
577 0x02,0x00, // STAR 13x15 = 2.5
595 0x02,0x00, // STAR 13x17 = 3.0
615 0x01,0x00, // STAR 15x19 = 3.5
637 0x00,0x80, 0x00, // STAR 17x21 = 4.0
661 0x00,0x40, 0x00, // STAR 19x23 = 4.5
687 0x00,0x20, 0x00, // STAR 21x25 = 5.0
715 0x00,0x10, 0x00, // STAR 23x27 = 5.5
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 0x00,0x08, 0x00,0x00,
724 0x80,0x08, 0x00,0x80,
725 0x60,0x08, 0x03,0x00,
726 0x18,0x08, 0x0c,0x00,
727 0x04,0x08, 0x30,0x00,
728 0x03,0x08, 0x40,0x00,
729 0x00,0xc9, 0x80,0x00,
730 0x00,0x3e, 0x00,0x00,
731 0x00,0x08, 0x00,0x00,
732 0x00,0x3e, 0x00,0x00,
733 0x00,0xc9, 0x80,0x00,
734 0x03,0x08, 0x40,0x00,
735 0x04,0x08, 0x30,0x00,
736 0x18,0x08, 0x0c,0x00,
737 0x60,0x08, 0x03,0x00,
738 0x80,0x08, 0x00,0x80,
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,
745 0x00,0x08, 0x00,0x00, // STAR 25x29 = 6.0
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 0x00,0x00, 0x80,0x00,
756 0x30,0x00, 0x80,0x06,
757 0x0c,0x00, 0x80,0x18,
758 0x03,0x00, 0x80,0x60,
759 0x00,0xc0, 0x81,0x80,
760 0x00,0x30, 0x86,0x00,
761 0x00,0x0c, 0x98,0x00,
762 0x00,0x03, 0xe0,0x00,
763 0x00,0x03, 0xe0,0x00,
764 0x00,0x0c, 0x98,0x00,
765 0x00,0x30, 0x86,0x00,
766 0x00,0xc0, 0x81,0x80,
767 0x03,0x00, 0x80,0x60,
768 0x0c,0x00, 0x80,0x18,
769 0x30,0x00, 0x80,0x06,
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, 0x80,0x00,
777 0x00,0x00, 0x00,0x00,
778 0x00,0x00, 0x00,0x00, // STAR 32x32 = 6.5
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 0x00, 0x00, 0x80, 0x00,
788 0x10, 0x00, 0x80, 0x04,
789 0x0c, 0x00, 0x80, 0x18,
790 0x02, 0x00, 0x80, 0x20,
791 0x01, 0x80, 0x80, 0xc0,
792 0x00, 0x40, 0x81, 0x00,
793 0x00, 0x30, 0x86, 0x00,
794 0x00, 0x08, 0x88, 0x00,
795 0x00, 0x06, 0xb0, 0x00,
796 0x00, 0x01, 0xc0, 0x00,
797 0x00, 0x06, 0xb0, 0x00,
798 0x00, 0x08, 0x88, 0x00,
799 0x00, 0x30, 0x86, 0x00,
800 0x00, 0x40, 0x81, 0x00,
801 0x01, 0x80, 0x80, 0xc0,
802 0x02, 0x00, 0x80, 0x20,
803 0x0c, 0x00, 0x80, 0x18,
804 0x10, 0x00, 0x80, 0x04,
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,
811 0x00, 0x00, 0x80, 0x00, // STAR 32x32 = 7.0
821 0x38, // CIRC 7x7 = 1.0
831 0x00,0x00, //CIRC 9x9 = 1.5
841 0x3e,0x00, // CIRC 9x9 = 2.0
853 0x1f,0x00, // CIRC 11x11 = 2.5
867 0x0f,0x80, // CIRC 13x13 = 3.0
883 0x07,0xc0, // CIRC 15x15 = 3.5
901 0x03,0xe0, 0x00, // CIRC 17x17 = 4.0
921 0x03,0xf8, 0x00, // CIRC 19x19 = 4.5
943 0x01,0xfc, 0x00, // CIRC 21x21 = 5.0
967 0x00,0xfe, 0x00, // CIRC 23x23 = 5.5
969 0x00,0x7f, 0x00,0x00,
970 0x01,0x80, 0xc0,0x00,
971 0x06,0x00, 0x30,0x00,
972 0x08,0x00, 0x08,0x00,
973 0x10,0x00, 0x04,0x00,
974 0x20,0x00, 0x02,0x00,
975 0x20,0x00, 0x02,0x00,
976 0x40,0x00, 0x01,0x00,
977 0x40,0x00, 0x01,0x00,
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 0x80,0x00, 0x00,0x80,
985 0x40,0x00, 0x01,0x00,
986 0x40,0x00, 0x01,0x00,
987 0x20,0x00, 0x02,0x00,
988 0x20,0x00, 0x02,0x00,
989 0x10,0x00, 0x04,0x00,
990 0x08,0x00, 0x08,0x00,
991 0x06,0x00, 0x30,0x00,
992 0x01,0x80, 0xc0,0x00,
993 0x00,0x7f, 0x00,0x00, // CIRC 25x25 = 6.0
995 0x00,0x3f, 0x80,0x00,
996 0x01,0xc0, 0x70,0x00,
997 0x03,0x00, 0x18,0x00,
998 0x0c,0x00, 0x06,0x00,
999 0x18,0x00, 0x03,0x00,
1000 0x10,0x00, 0x01,0x00,
1001 0x20,0x00, 0x00,0x80,
1002 0x60,0x00, 0x00,0xc0,
1003 0x40,0x00, 0x00,0x40,
1004 0x40,0x00, 0x00,0x40,
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 0x80,0x00, 0x00,0x20,
1012 0x40,0x00, 0x00,0x40,
1013 0x40,0x00, 0x00,0x40,
1014 0x60,0x00, 0x00,0xc0,
1015 0x20,0x00, 0x00,0x80,
1016 0x10,0x00, 0x01,0x00,
1017 0x18,0x00, 0x03,0x00,
1018 0x0c,0x00, 0x06,0x00,
1019 0x03,0x00, 0x18,0x00,
1020 0x01,0xc0, 0x70,0x00,
1021 0x00,0x3f, 0x80,0x00, // CIRC 27x27 = 6.5
1023 0x00,0x1f, 0xc0,0x00,
1024 0x00,0xe0, 0x38,0x00,
1025 0x01,0x00, 0x04,0x00,
1026 0x06,0x00, 0x03,0x00,
1027 0x08,0x00, 0x00,0x80,
1028 0x10,0x00, 0x00,0x40,
1029 0x10,0x00, 0x00,0x40,
1030 0x20,0x00, 0x00,0x20,
1031 0x40,0x00, 0x00,0x10,
1032 0x40,0x00, 0x00,0x10,
1033 0x40,0x00, 0x00,0x10,
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 0x80,0x00, 0x00,0x08,
1041 0x40,0x00, 0x00,0x10,
1042 0x40,0x00, 0x00,0x10,
1043 0x40,0x00, 0x00,0x10,
1044 0x20,0x00, 0x00,0x20,
1045 0x10,0x00, 0x00,0x40,
1046 0x10,0x00, 0x00,0x40,
1047 0x08,0x00, 0x00,0x80,
1048 0x06,0x00, 0x03,0x00,
1049 0x01,0x00, 0x04,0x00,
1050 0x00,0xe0, 0x38,0x00,
1051 0x00,0x1f, 0xc0,0x00, // CIRC 29x29 = 7.0
1061 0x82, // CROSS 7x7 = 1.0
1071 0x80,0x80, // CROSS 9x9 = 1.5
1083 0x80,0x20, // CROSS 11x11 = 2.0
1097 0x80,0x08, // CROSS 13x13 = 2.5
1113 0x80,0x02, // CROSS 15x15 = 3.0
1131 0x80,0x00, 0x80, // CROSS 17x17 = 3.5
1151 0x80,0x00, 0x20, // CROSS 19x19 = 4.0
1173 0x80,0x00, 0x08,/* CROSS 21x21 = 4.5 */
1197 0x80,0x00, 0x02, // CROSS 23x23 = 5.0
1199 0x80,0x00, 0x00,0x80,
1200 0x40,0x00, 0x01,0x00,
1201 0x20,0x00, 0x02,0x00,
1202 0x10,0x00, 0x04,0x00,
1203 0x08,0x00, 0x08,0x00,
1204 0x04,0x00, 0x10,0x00,
1205 0x02,0x00, 0x20,0x00,
1206 0x01,0x00, 0x40,0x00,
1207 0x00,0x80, 0x80,0x00,
1208 0x00,0x41, 0x00,0x00,
1209 0x00,0x22, 0x00,0x00,
1210 0x00,0x14, 0x00,0x00,
1211 0x00,0x08, 0x00,0x00,
1212 0x00,0x14, 0x00,0x00,
1213 0x00,0x22, 0x00,0x00,
1214 0x00,0x41, 0x00,0x00,
1215 0x00,0x80, 0x80,0x00,
1216 0x01,0x00, 0x40,0x00,
1217 0x02,0x00, 0x20,0x00,
1218 0x04,0x00, 0x10,0x00,
1219 0x08,0x00, 0x08,0x00,
1220 0x10,0x00, 0x04,0x00,
1221 0x20,0x00, 0x02,0x00,
1222 0x40,0x00, 0x01,0x00,
1223 0x80,0x00, 0x00,0x80, // CROSS 25x25 = 5.5
1225 0x80,0x00, 0x00,0x20,
1226 0x40,0x00, 0x00,0x40,
1227 0x20,0x00, 0x00,0x80,
1228 0x10,0x00, 0x01,0x00,
1229 0x08,0x00, 0x02,0x00,
1230 0x04,0x00, 0x04,0x00,
1231 0x02,0x00, 0x08,0x00,
1232 0x01,0x00, 0x10,0x00,
1233 0x00,0x80, 0x20,0x00,
1234 0x00,0x40, 0x40,0x00,
1235 0x00,0x20, 0x80,0x00,
1236 0x00,0x11, 0x00,0x00,
1237 0x00,0x0a, 0x00,0x00,
1238 0x00,0x04, 0x00,0x00,
1239 0x00,0x0a, 0x00,0x00,
1240 0x00,0x11, 0x00,0x00,
1241 0x00,0x20, 0x80,0x00,
1242 0x00,0x40, 0x40,0x00,
1243 0x00,0x80, 0x20,0x00,
1244 0x01,0x00, 0x10,0x00,
1245 0x02,0x00, 0x08,0x00,
1246 0x04,0x00, 0x04,0x00,
1247 0x08,0x00, 0x02,0x00,
1248 0x10,0x00, 0x01,0x00,
1249 0x20,0x00, 0x00,0x80,
1250 0x40,0x00, 0x00,0x40,
1251 0x80,0x00, 0x00,0x20, // CROSS 27x27 = 6.0
1253 0x00,0x00, 0x00,0x00,
1254 0x00,0x00, 0x00,0x00,
1255 0x20,0x00, 0x00,0x04,
1256 0x10,0x00, 0x00,0x08,
1257 0x08,0x00, 0x00,0x10,
1258 0x04,0x00, 0x00,0x20,
1259 0x02,0x00, 0x00,0x40,
1260 0x01,0x00, 0x00,0x80,
1261 0x00,0x80, 0x01,0x00,
1262 0x00,0x40, 0x02,0x00,
1263 0x00,0x20, 0x04,0x00,
1264 0x00,0x10, 0x08,0x00,
1265 0x00,0x08, 0x10,0x00,
1266 0x00,0x04, 0x20,0x00,
1267 0x00,0x02, 0x40,0x00,
1268 0x00,0x01, 0x80,0x00,
1269 0x00,0x01, 0x80,0x00,
1270 0x00,0x02, 0x40,0x00,
1271 0x00,0x04, 0x20,0x00,
1272 0x00,0x08, 0x10,0x00,
1273 0x00,0x10, 0x08,0x00,
1274 0x00,0x20, 0x04,0x00,
1275 0x00,0x40, 0x02,0x00,
1276 0x00,0x80, 0x01,0x00,
1277 0x01,0x00, 0x00,0x80,
1278 0x02,0x00, 0x00,0x40,
1279 0x04,0x00, 0x00,0x20,
1280 0x08,0x00, 0x00,0x10,
1281 0x10,0x00, 0x00,0x08,
1282 0x20,0x00, 0x00,0x04,
1283 0x00,0x00, 0x00,0x00,
1284 0x00,0x00, 0x00,0x00, // CROSS 32x32 = 6.5
1286 0x00,0x00, 0x00,0x00,
1287 0x40,0x00, 0x00,0x02,
1288 0x20,0x00, 0x00,0x04,
1289 0x10,0x00, 0x00,0x08,
1290 0x08,0x00, 0x00,0x10,
1291 0x04,0x00, 0x00,0x20,
1292 0x02,0x00, 0x00,0x40,
1293 0x01,0x00, 0x00,0x80,
1294 0x00,0x80, 0x01,0x00,
1295 0x00,0x40, 0x02,0x00,
1296 0x00,0x20, 0x04,0x00,
1297 0x00,0x10, 0x08,0x00,
1298 0x00,0x08, 0x10,0x00,
1299 0x00,0x04, 0x20,0x00,
1300 0x00,0x02, 0x40,0x00,
1301 0x00,0x01, 0x80,0x00,
1302 0x00,0x01, 0x80,0x00,
1303 0x00,0x02, 0x40,0x00,
1304 0x00,0x04, 0x20,0x00,
1305 0x00,0x08, 0x10,0x00,
1306 0x00,0x10, 0x08,0x00,
1307 0x00,0x20, 0x04,0x00,
1308 0x00,0x40, 0x02,0x00,
1309 0x00,0x80, 0x01,0x00,
1310 0x01,0x00, 0x00,0x80,
1311 0x02,0x00, 0x00,0x40,
1312 0x04,0x00, 0x00,0x20,
1313 0x08,0x00, 0x00,0x10,
1314 0x10,0x00, 0x00,0x08,
1315 0x20,0x00, 0x00,0x04,
1316 0x40,0x00, 0x00,0x02,
1317 0x00,0x00, 0x00,0x00 // CROSS 32x32 = 7.0
1320 // =======================================================================
1321 // function : GetMarkerBitMapArray
1322 // purpose : Returns a parameters for the marker of the specified
1324 // =======================================================================
1325 void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
1326 const Standard_ShortReal& theScale,
1327 Standard_Integer& theWidth,
1328 Standard_Integer& theHeight,
1329 Standard_Integer& theOffset,
1330 Standard_Integer& theNumOfBytes)
1332 const Standard_Integer aType = (Standard_Integer )((theMarkerType > Aspect_TOM_O) ? Aspect_TOM_O : theMarkerType);
1333 const Standard_Real anIndex = (Standard_Real )(TEL_NO_OF_SIZES - 1) * (theScale - (Standard_Real )TEL_PM_START_SIZE)
1334 / (Standard_Real )(TEL_PM_END_SIZE - TEL_PM_START_SIZE);
1335 Standard_Integer anId = (Standard_Integer )(anIndex + 0.5);
1340 else if (anId >= TEL_NO_OF_SIZES)
1342 anId = TEL_NO_OF_SIZES - 1;
1345 theWidth = (Standard_Integer )arrPMFontInfo[aType][anId].width;
1346 theHeight = (Standard_Integer )arrPMFontInfo[aType][anId].height;
1347 theOffset = arrPMFontInfo[aType][anId].offset;
1348 const Standard_Integer aNumOfBytesInRow = theWidth / 8 + (theWidth % 8 ? 1 : 0);
1349 theNumOfBytes = theHeight * aNumOfBytesInRow;
1352 // =======================================================================
1353 // function : GetTextureImage
1354 // purpose : Returns a marker image for the marker of the specified
1356 // =======================================================================
1357 Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
1358 const Standard_ShortReal& theScale)
1360 Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1361 GetMarkerBitMapParam (theMarkerType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
1363 Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
1364 for (Standard_Integer anIter = 0; anIter < aNumOfBytes; anIter++)
1366 aBitMap->ChangeValue (anIter) = OpenGl_AspectMarker_myMarkerRaster[anOffset + anIter];
1369 Handle(Graphic3d_MarkerImage) aTexture = new Graphic3d_MarkerImage (aBitMap, aWidth, aHeight);
1373 // =======================================================================
1374 // function : MergeImages
1375 // purpose : Merge two image pixmap into one. Used for creating image for
1376 // following markers: Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS,
1377 // Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1,
1378 // Aspect_TOM_RING2, Aspect_TOM_RING3
1379 // =======================================================================
1380 Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
1381 const Handle(Image_PixMap)& theImage2)
1383 if (theImage1.IsNull() && theImage2.IsNull())
1385 return Handle(Image_PixMap)();
1388 Handle(Image_PixMap) aResultImage = new Image_PixMap();
1390 Standard_Integer aWidth1 (0), aHeight1 (0);
1391 if (!theImage1.IsNull())
1393 aWidth1 = (Standard_Integer )theImage1->Width();
1394 aHeight1 = (Standard_Integer )theImage1->Height();
1397 Standard_Integer aWidth2 (0), aHeight2 (0);
1398 if (!theImage2.IsNull())
1400 aWidth2 = (Standard_Integer )theImage2->Width();
1401 aHeight2 = (Standard_Integer )theImage2->Height();
1404 const Standard_Integer aMaxWidth = Max (aWidth1, aWidth2);
1405 const Standard_Integer aMaxHeight = Max (aHeight1, aHeight2);
1406 const Standard_Integer aSize = Max (aMaxWidth, aMaxHeight);
1408 aResultImage->InitZero (Image_PixMap::ImgGray, aSize, aSize);
1410 if (!theImage1.IsNull())
1412 const Standard_Integer aXOffset1 = Abs (aWidth1 - aMaxWidth) / 2;
1413 const Standard_Integer anYOffset1 = Abs (aHeight1 - aMaxHeight) / 2;
1414 for (Standard_Integer anY = 0; anY < aHeight1; anY++)
1416 Standard_Byte* anImageLine = theImage1->ChangeRow (anY);
1417 Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset1 + anY);
1418 for (Standard_Integer aX = 0; aX < aWidth1; aX++)
1420 aResultImageLine[aXOffset1 + aX] |= anImageLine[aX];
1425 if (!theImage2.IsNull())
1427 const Standard_Integer aXOffset2 = Abs (aWidth2 - aMaxWidth) / 2;
1428 const Standard_Integer anYOffset2 = Abs (aHeight2 - aMaxHeight) / 2;
1429 for (Standard_Integer anY = 0; anY < aHeight2; anY++)
1431 Standard_Byte* anImageLine = theImage2->ChangeRow (anY);
1432 Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset2 + anY);
1433 for (Standard_Integer aX = 0; aX < aWidth2; aX++)
1435 aResultImageLine[aXOffset2 + aX] |= anImageLine[aX];
1440 return aResultImage;
1443 // =======================================================================
1444 // function : OpenGl_AspectMarker
1446 // =======================================================================
1447 OpenGl_AspectMarker::OpenGl_AspectMarker()
1448 : myColor (myDefaultColor),
1449 myType (Aspect_TOM_PLUS),
1452 myMarkerSize (1.0f),
1455 myIsSpriteInit (Standard_False)
1458 // =======================================================================
1459 // function : SetAspect
1461 // =======================================================================
1462 void OpenGl_AspectMarker::SetAspect (const CALL_DEF_CONTEXTMARKER& theAspect)
1464 myColor.rgb[0] = (float )theAspect.Color.r;
1465 myColor.rgb[1] = (float )theAspect.Color.g;
1466 myColor.rgb[2] = (float )theAspect.Color.b;
1467 myColor.rgb[3] = 1.0f;
1468 myMarkerImage = theAspect.MarkerImage;
1469 myType = theAspect.MarkerType;
1470 myScale = myMarkerSize = theAspect.Scale;
1472 // check that the resources need to be renewed
1473 TCollection_AsciiString aNewKey, aNewKeyA;
1474 resourceKeys (myMarkerImage, myType, myScale, myColor, aNewKey, aNewKeyA);
1475 myIsSpriteInit = !aNewKey.IsEmpty() && mySpriteKey == aNewKey;
1476 myIsSpriteInit &= !aNewKeyA.IsEmpty() && mySpriteAKey == aNewKeyA;
1479 // =======================================================================
1480 // function : buildSprites
1482 // =======================================================================
1483 void OpenGl_AspectMarker::buildSprites (const Handle(OpenGl_Workspace)& theWorkspace) const
1485 const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
1487 TCollection_AsciiString aNewKey, aNewKeyA;
1488 resourceKeys (myMarkerImage, myType, myMarkerSize, myColor, aNewKey, aNewKeyA);
1490 // release old shared resources
1491 const Standard_Boolean aNewResource = aNewKey.IsEmpty() || mySpriteKey != aNewKey;
1494 if (!mySprite.IsNull())
1496 if (mySpriteKey.IsEmpty())
1498 aContext->DelayedRelease (mySprite);
1503 mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
1504 aContext->ReleaseResource (mySpriteKey);
1507 mySpriteKey = aNewKey;
1509 if (aNewKeyA.IsEmpty()
1510 || mySpriteAKey != aNewKeyA)
1512 if (!mySpriteA.IsNull())
1514 if (mySpriteAKey.IsEmpty())
1516 aContext->DelayedRelease (mySpriteA);
1517 mySpriteA.Nullify();
1521 mySpriteA.Nullify(); // we need nullify all handles before ReleaseResource() call
1522 aContext->ReleaseResource (mySpriteKey);
1525 mySpriteAKey = aNewKeyA;
1527 if (myType == Aspect_TOM_POINT
1529 || (myType == Aspect_TOM_USERDEFINED && myMarkerImage.IsNull()))
1531 // nothing to do - just simple point
1535 if (!aNewKey.IsEmpty()
1536 && aContext->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, mySpriteA) // alpha sprite could be shared
1537 && aContext->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, mySprite))
1539 // reuse shared resource
1540 if (!mySprite->IsDisplayList())
1542 myMarkerSize = Standard_ShortReal (Max (mySprite->SizeX(), mySprite->SizeY()));
1547 const bool hadAlreadyAlpha = !mySpriteA.IsNull();
1548 if (!hadAlreadyAlpha)
1550 mySpriteA = new OpenGl_PointSprite();
1552 mySprite = new OpenGl_PointSprite();
1553 if (!aNewKey.IsEmpty())
1555 aContext->ShareResource (aNewKey, mySprite);
1556 if (!hadAlreadyAlpha)
1558 aContext->ShareResource (aNewKeyA, mySpriteA);
1562 if (!aContext.IsNull()
1563 && aContext->IsGlGreaterEqual (2, 0)
1564 && !aContext->caps->pntSpritesDisable)
1566 // Creating texture resource for using it with point sprites
1567 Handle(Graphic3d_MarkerImage) aNewMarkerImage;
1568 Handle(Image_PixMap) anImage, anImageA;
1570 if (myType == Aspect_TOM_USERDEFINED && !myMarkerImage.IsNull())
1572 aNewMarkerImage = myMarkerImage;
1573 anImage = aNewMarkerImage->GetImage();
1577 // Creating image from default bitmap
1578 Handle(TColStd_HArray1OfByte) aBitMap;
1579 Handle(Graphic3d_MarkerImage) aMarkerImage1, aMarkerImage2;
1581 const Standard_ShortReal aDelta = 0.1F;
1582 Standard_ShortReal aScale = myScale;
1583 Standard_ShortReal aLimit = 0.0F;
1587 case Aspect_TOM_O_POINT:
1589 const Standard_Integer aSize = myScale > 7 ? 7 : (Standard_Integer )(myScale + 0.5F);
1590 const Standard_Integer aNumOfBytes = (aSize / 8 + (aSize % 8 ? 1 : 0)) * aSize;
1591 aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
1592 for (Standard_Integer anIter = 0; anIter < aBitMap->Length(); anIter++)
1594 aBitMap->SetValue (anIter, 255);
1596 aMarkerImage2 = new Graphic3d_MarkerImage (aBitMap, aSize, aSize);
1598 case Aspect_TOM_O_PLUS:
1599 case Aspect_TOM_O_STAR:
1600 case Aspect_TOM_O_X:
1602 // For this type of markers we merge two base bitmaps into one
1603 // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
1604 aMarkerImage1 = GetTextureImage (Aspect_TOM_O, myScale);
1605 if (myType != Aspect_TOM_O_POINT)
1607 aMarkerImage2 = GetTextureImage (Aspect_TypeOfMarker (myType - Aspect_TOM_O_POINT), myScale);
1609 anImage = MergeImages (aMarkerImage1->GetImage(), aMarkerImage2->GetImage());
1610 aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
1613 case Aspect_TOM_RING1:
1614 if (aLimit == 0.0f) aLimit = aScale * 0.2f;
1615 case Aspect_TOM_RING2:
1616 if (aLimit == 0.0f) aLimit = aScale * 0.5f;
1617 case Aspect_TOM_RING3:
1619 if (aLimit == 0.0f) aLimit = aScale * 0.8f;
1620 for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
1622 anImage = MergeImages (anImage, GetTextureImage (Aspect_TOM_O, aScale)->GetImage());
1624 aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
1627 case Aspect_TOM_BALL:
1629 Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1630 GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1632 const Standard_ShortReal aDelta = 0.1f;
1633 NCollection_Vec4<Standard_Real> aColor (Standard_Real (myColor.rgb[0]),
1634 Standard_Real (myColor.rgb[1]),
1635 Standard_Real (myColor.rgb[2]),
1636 Standard_Real (myColor.rgb[3]));
1638 const Standard_Integer aSize = Max (aWidth + 2, aHeight + 2); // includes extra margin
1639 anImage = new Image_PixMap();
1640 anImageA = new Image_PixMap();
1641 anImage ->InitZero (Image_PixMap::ImgBGRA, aSize, aSize);
1642 anImageA->InitZero (Image_PixMap::ImgGray, aSize, aSize);
1643 Image_PixMapData<Image_ColorBGRA>& aDataBGRA = anImage->EditData<Image_ColorBGRA>();
1644 Image_PixMapData<Standard_Byte>& aDataGray = anImageA->EditData<Standard_Byte>();
1646 // we draw a set of circles
1647 Image_ColorBGRA aColor32;
1649 Standard_Real aHLS[3];
1650 while (aScale >= 1.0f)
1652 Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
1653 aHLS[2] *= 0.95; // 5% saturation change
1654 Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
1655 aColor32.r() = Standard_Byte(255.0 * aColor.r());
1656 aColor32.g() = Standard_Byte(255.0 * aColor.g());
1657 aColor32.b() = Standard_Byte(255.0 * aColor.b());
1659 const Handle(Graphic3d_MarkerImage) aMarker = GetTextureImage (Aspect_TOM_O, aScale);
1660 const Handle(Image_PixMap)& aCircle = aMarker->GetImage();
1662 const Standard_Size aDiffX = (aDataBGRA.SizeX() - aCircle->SizeX()) / 2;
1663 const Standard_Size aDiffY = (aDataBGRA.SizeY() - aCircle->SizeY()) / 2;
1664 for (Standard_Size aRow = 0; aRow < aCircle->SizeY(); ++aRow)
1666 const Standard_Byte* aRowData = aCircle->Row (aRow);
1667 for (Standard_Size aCol = 0; aCol < aCircle->SizeX(); ++aCol)
1669 if (aRowData[aCol] != 0)
1671 aDataBGRA.ChangeValue (aDiffX + aRow, aDiffY + aCol) = aColor32;
1672 aDataGray.ChangeValue (aDiffX + aRow, aDiffY + aCol) = 255;
1682 aNewMarkerImage = GetTextureImage (myType, myScale);
1683 anImage = aNewMarkerImage->GetImage();
1689 myMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
1691 mySprite->Init (aContext, *anImage.operator->(), Graphic3d_TOT_2D);
1692 if (!hadAlreadyAlpha)
1694 if (anImageA.IsNull()
1695 && mySprite->GetFormat() != GL_ALPHA8
1696 && !aNewMarkerImage.IsNull())
1698 anImageA = aNewMarkerImage->GetImageAlpha();
1700 if (!anImageA.IsNull())
1702 mySpriteA->Init (aContext, *anImageA.operator->(), Graphic3d_TOT_2D);
1708 // Creating list with bitmap for using it in compatibility mode
1709 GLuint aBitmapList = glGenLists (1);
1710 mySprite->SetDisplayList (aContext, aBitmapList);
1712 Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
1713 if (myType == Aspect_TOM_USERDEFINED && !myMarkerImage.IsNull())
1715 // Reading user defined marker
1716 Handle(TColStd_HArray1OfByte) aBitMap = myMarkerImage->GetBitMapArray();
1717 Standard_Byte* aBitMapArray = new Standard_Byte[aBitMap->Length()];
1718 myMarkerImage->GetTextureSize (aWidth, aHeight);
1720 // We should pass bitmap to glBitmap with reversed line order as it draws it from
1722 const Standard_Integer aNumOfBytesInRow = aWidth / 8 + (aWidth % 8 ? 1 : 0);
1723 const Standard_Integer anUpperIndex = aBitMap->Upper();
1724 for (Standard_Integer aRow = 0; aRow < aHeight; aRow++)
1726 for (Standard_Integer aByteIter = 0; aByteIter < aNumOfBytesInRow; aByteIter++)
1728 aBitMapArray[aRow * aNumOfBytesInRow + aByteIter] =
1729 aBitMap->Value (anUpperIndex + 1 - (aRow + 1) * aNumOfBytesInRow + aByteIter);
1733 if (aBitMapArray != NULL)
1735 glNewList (aBitmapList, GL_COMPILE);
1736 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1737 0.f, 0.f, (const GLubyte* )aBitMapArray);
1743 // Creating list for default marker
1744 const Standard_ShortReal aDelta = 0.1f;
1745 Standard_ShortReal aScale = myScale;
1746 Standard_ShortReal aLimit = 0.0f;
1748 glNewList (aBitmapList, GL_COMPILE);
1751 case Aspect_TOM_O_PLUS:
1752 case Aspect_TOM_O_STAR:
1753 case Aspect_TOM_O_X:
1755 // For this type of markers we merge two base bitmaps into one
1756 // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
1757 GetMarkerBitMapParam (Aspect_TOM_O, myScale, aWidth, aHeight, anOffset, aNumOfBytes);
1758 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1759 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1760 GetMarkerBitMapParam (Aspect_TypeOfMarker (myType - Aspect_TOM_O_POINT), myScale, aWidth, aHeight, anOffset, aNumOfBytes);
1761 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
1762 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1765 case Aspect_TOM_BALL:
1767 const Standard_ShortReal aDelta = 0.1f;
1768 NCollection_Vec4<Standard_Real> aColor (Standard_Real (myColor.rgb[0]),
1769 Standard_Real (myColor.rgb[1]),
1770 Standard_Real (myColor.rgb[2]),
1771 Standard_Real (myColor.rgb[3]));
1773 // we draw a set of circles
1774 while (aScale >= 1.0f)
1776 Standard_Real aHLS[3];
1777 Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
1778 // 5% saturation change
1780 Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
1782 glColor4dv (aColor);
1783 GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1784 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1785 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1791 case Aspect_TOM_RING1:
1792 if (aLimit == 0.0f) aLimit = aScale * 0.2f;
1793 case Aspect_TOM_RING2:
1794 if (aLimit == 0.0f) aLimit = aScale * 0.5f;
1795 case Aspect_TOM_RING3:
1797 if (aLimit == 0.0f) aLimit = aScale * 0.8f;
1798 for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
1800 GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
1801 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1802 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1808 GetMarkerBitMapParam (myType, myScale, aWidth, aHeight, anOffset, aNumOfBytes);
1809 glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
1810 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
1819 // =======================================================================
1820 // function : resourceKeys
1822 // =======================================================================
1823 void OpenGl_AspectMarker::resourceKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
1824 const Aspect_TypeOfMarker theType,
1825 const Standard_ShortReal theScale,
1826 const TEL_COLOUR& theColor,
1827 TCollection_AsciiString& theKey,
1828 TCollection_AsciiString& theKeyA) const
1830 // generate key for shared resource
1831 if (theType == Aspect_TOM_USERDEFINED)
1833 if (!theMarkerImage.IsNull())
1835 theKey = theMarkerImage->GetImageId();
1836 theKeyA = theMarkerImage->GetImageAlphaId();
1839 else if (theType != Aspect_TOM_POINT)
1841 // predefined markers
1842 const Standard_Integer aScale = Standard_Integer(theScale + 0.5f);
1843 theKey = TCollection_AsciiString ("OpenGl_AspectMarker") + theType + "_" + aScale;
1844 theKeyA = theKey + "A";
1845 if (theType == Aspect_TOM_BALL)
1847 unsigned int aColor[3] =
1849 (unsigned int )(255.0f * theColor.rgb[0]),
1850 (unsigned int )(255.0f * theColor.rgb[1]),
1851 (unsigned int )(255.0f * theColor.rgb[2])
1854 sprintf (aBytes, "%02X%02X%02X", aColor[0], aColor[1], aColor[2]);
1860 // =======================================================================
1861 // function : Render
1863 // =======================================================================
1864 void OpenGl_AspectMarker::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
1866 theWorkspace->SetAspectMarker (this);
1869 // =======================================================================
1870 // function : Release
1872 // =======================================================================
1873 void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
1875 if (!mySprite.IsNull())
1877 if (!theCtx.IsNull())
1879 if (mySpriteKey.IsEmpty())
1881 theCtx->DelayedRelease (mySprite);
1882 theCtx->DelayedRelease (mySpriteA);
1886 mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
1887 mySpriteA.Nullify();
1888 theCtx->ReleaseResource (mySpriteKey, Standard_True);
1889 theCtx->ReleaseResource (mySpriteAKey, Standard_True);
1893 mySpriteA.Nullify();
1895 mySpriteKey.Clear();
1896 mySpriteAKey.Clear();