Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
QuartzMarker.mm
Go to the documentation of this file.
1// @(#)root/graf2d:$Id$
2// Author: Timur Pocheptsov, 14/8/2011
3
4/*************************************************************************
5 * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TAttMarker.h"
13
14#include "QuartzMarker.h"
15#include "QuartzLine.h"
16#include "QuartzFillArea.h"
17#include "TMath.h"
18
19namespace ROOT {
20namespace Quartz {
21
22
23//______________________________________________________________________________
24void DrawMarkerDot(CGContextRef ctx, unsigned n, const TPoint *xy,
25 Size_t markerSize)
26{
27 for (unsigned i = 0; i < n; ++i)
28 CGContextFillRect(ctx, CGRectMake(xy[i].fX, xy[i].fY, markerSize, markerSize));
29}
30
31
32//______________________________________________________________________________
33void DrawMarkerPlus(CGContextRef ctx, unsigned n, const TPoint *xy,
34 Size_t markerSize)
35{
36 const Double_t im = 4 * markerSize + 0.5;
37
38 for (UInt_t i = 0; i < n; ++i) {
39 const Double_t x = xy[i].fX;
40 const Double_t y = xy[i].fY;
41
43 CGContextMoveToPoint(ctx, -im + x, y);
46
48 CGContextMoveToPoint(ctx, x, -im + y);
51 }
52}
53
54
55//______________________________________________________________________________
56void DrawMarkerStar(CGContextRef ctx, unsigned n, const TPoint *xy,
57 Size_t markerSize)
58{
59 Double_t im = 4 * markerSize + 0.5;
60
61 TPoint star[8];
62 star[0].fX = -im; star[0].fY = 0;
63 star[1].fX = im; star[1].fY = 0;
64 star[2].fX = 0 ; star[2].fY = -im;
65 star[3].fX = 0 ; star[3].fY = im;
66
67 im = 0.707 * im + 0.5;
68 star[4].fX = -im; star[4].fY = -im;
69 star[5].fX = im; star[5].fY = im;
70 star[6].fX = -im; star[6].fY = im;
71 star[7].fX = im; star[7].fY = -im;
72
73 for (UInt_t i = 0; i < n; ++i) {
74 const Double_t x = xy[i].fX;
75 const Double_t y = xy[i].fY;
76
78 CGContextMoveToPoint(ctx, star[0].fX + x, star[0].fY + y);
79 CGContextAddLineToPoint(ctx, star[1].fX + x, star[1].fY + y);
81
83 CGContextMoveToPoint(ctx, star[2].fX + x, star[2].fY + y);
84 CGContextAddLineToPoint(ctx, star[3].fX + x, star[3].fY + y);
86
88 CGContextMoveToPoint(ctx, star[4].fX + x, star[4].fY + y);
89 CGContextAddLineToPoint(ctx, star[5].fX + x, star[5].fY + y);
91
93 CGContextMoveToPoint(ctx, star[6].fX + x, star[6].fY + y);
94 CGContextAddLineToPoint(ctx, star[7].fX + x, star[7].fY + y);
96 }
97}
98
99
100//______________________________________________________________________________
101void DrawMarkerOpenCircle(CGContextRef ctx, unsigned n, const TPoint *xy,
102 Size_t markerSize)
103{
104 Double_t r = 4 * markerSize + 0.5;
105 if (r > 100.)
106 r = 100.;//as in TGX11.
107
108 const Double_t d = 2 * r;
109
110 for (unsigned i = 0; i < n; ++i) {
111 const Double_t x = xy[i].fX;
112 const Double_t y = xy[i].fY;
113
114 const CGRect rect = CGRectMake(x - r, y - r, d, d);
116 }
117}
118
119
120//______________________________________________________________________________
121void DrawMarkerX(CGContextRef ctx, unsigned n, const TPoint *xy,
122 Size_t markerSize)
123{
124 const Double_t im = 0.707 * (4 * markerSize + 0.5) + 0.5;
125 for (unsigned i = 0; i < n; ++i) {
126 const Double_t x = xy[i].fX;
127 const Double_t y = xy[i].fY;
128
130 CGContextMoveToPoint(ctx, -im + x, -im + y);
131 CGContextAddLineToPoint(ctx, im + x, im + y);
133
135 CGContextMoveToPoint(ctx, -im + x, im + y);
136 CGContextAddLineToPoint(ctx, im + x, -im + y);
138 }
139}
140
141
142//______________________________________________________________________________
143void DrawMarkerFullDotSmall(CGContextRef ctx, unsigned n, const TPoint *xy)
144{
145 for (unsigned i = 0; i < n; ++i) {
146 const Double_t x = xy[i].fX;
147 const Double_t y = xy[i].fY;
148
150 CGContextMoveToPoint(ctx, -1. + x, y);
151 CGContextAddLineToPoint(ctx, x + 1., y);
153
155 CGContextMoveToPoint(ctx, x, -1. + y);
156 CGContextAddLineToPoint(ctx, x, 1. + y);
158 }
159}
160
161
162//______________________________________________________________________________
163void DrawMarkerFullDotMedium(CGContextRef ctx, unsigned n, const TPoint *xy)
164{
165 for (unsigned i = 0; i < n; ++i)
166 CGContextFillRect(ctx, CGRectMake(xy[i].fX - 1, xy[i].fY - 1, 3.f, 3.f));
167}
168
169
170//______________________________________________________________________________
171void DrawMarkerFullDotLarge(CGContextRef ctx, unsigned n, const TPoint *xy,
172 Size_t markerSize)
173{
174 Double_t radius = 4 * markerSize + 0.5;
175 if (radius > 100.)
176 radius = 100;//as in TGX11.
177
178 const Double_t d = 2 * radius;
179
180 for (unsigned i = 0; i < n; ++i) {
181 const Double_t x = xy[i].fX;
182 const Double_t y = xy[i].fY;
183
184 const CGRect rect = CGRectMake(x - radius, y - radius, d, d);
186 }
187}
188
189
190//______________________________________________________________________________
191void DrawMarkerFullSquare(CGContextRef ctx, unsigned n, const TPoint *xy,
192 Size_t markerSize)
193{
194 const Double_t im = 4 * markerSize + 0.5;
195 for (unsigned i = 0; i < n; ++i) {
196 const CGRect rect = CGRectMake(xy[i].fX - im, xy[i].fY - im, im * 2, im * 2);
198 }
199}
200
201
202//______________________________________________________________________________
203void DrawMarkerOpenSquare(CGContextRef ctx, unsigned n, const TPoint *xy,
204 Size_t markerSize)
205{
206 const Double_t im = 4 * markerSize + 0.5;
207 for (unsigned i = 0; i < n; ++i) {
208 const CGRect rect = CGRectMake(xy[i].fX - im, xy[i].fY - im, im * 2, im * 2);
210 }
211}
212
213
214//______________________________________________________________________________
216 Size_t markerSize)
217{
218 const Double_t im = 4 * markerSize + 0.5;
219 for (unsigned i = 0; i < n; ++i) {
220 const Double_t x = xy[i].fX;
221 const Double_t y = xy[i].fY;
223 CGContextMoveToPoint(ctx, x - im, y - im);
224 CGContextAddLineToPoint(ctx, x + im, y - im);
225 CGContextAddLineToPoint(ctx, x, im + y);
227 }
228}
229
230
231//______________________________________________________________________________
233 Size_t markerSize)
234{
235 const Double_t im = 4 * markerSize + 0.5;
236 for (unsigned i = 0; i < n; ++i) {
237 const Double_t x = xy[i].fX;
238 const Double_t y = xy[i].fY;
240 CGContextMoveToPoint(ctx, x - im, y - im);
241 CGContextAddLineToPoint(ctx, x + im, y - im);
242 CGContextAddLineToPoint(ctx, x, im + y);
243 CGContextAddLineToPoint(ctx, x - im, y - im);
245 }
246}
247
248
249//______________________________________________________________________________
251 Size_t markerSize)
252{
253 const Int_t im = Int_t(4 * markerSize + 0.5);
254 for (unsigned i = 0; i < n; ++i) {
255 const Double_t x = xy[i].fX;
256 const Double_t y = xy[i].fY;
257
259 CGContextMoveToPoint(ctx, x - im, y + im);
260 CGContextAddLineToPoint(ctx, x, y - im);
261 CGContextAddLineToPoint(ctx, im + x, y + im);
262 CGContextAddLineToPoint(ctx, x - im, y + im);
264 }
265}
266
267
268//______________________________________________________________________________
270 Size_t markerSize)
271{
272 const Int_t im = Int_t(4 * markerSize + 0.5);
273 for (unsigned i = 0; i < n; ++i) {
274 const Double_t x = xy[i].fX;
275 const Double_t y = xy[i].fY;
276
278 CGContextMoveToPoint(ctx, x - im, y + im);
279 CGContextAddLineToPoint(ctx, x, y - im);
280 CGContextAddLineToPoint(ctx, im + x, y + im);
282 }
283}
284
285
286//______________________________________________________________________________
287void DrawMarkerFullDiamond(CGContextRef ctx, unsigned n, const TPoint *xy,
288 Size_t markerSize)
289{
290 const Int_t im = Int_t(4 * markerSize + 0.5);
291 const Int_t imx = Int_t(2.66 * markerSize + 0.5);
292
293 for (unsigned i = 0; i < n; ++i) {
294 const Double_t x = xy[i].fX;
295 const Double_t y = xy[i].fY;
296
298 CGContextMoveToPoint(ctx, x - imx, y);
299 CGContextAddLineToPoint(ctx, x, y - im);
301 CGContextAddLineToPoint(ctx, x, y + im);
303 }
304}
305
306
307//______________________________________________________________________________
308void DrawMarkerOpenDiamond(CGContextRef ctx, unsigned n, const TPoint *xy,
309 Size_t markerSize)
310{
311 const Int_t im = Int_t(4 * markerSize + 0.5);
312 const Int_t imx = Int_t(2.66 * markerSize + 0.5);
313
314 for (unsigned i = 0; i < n; ++i) {
315 const Double_t x = xy[i].fX;
316 const Double_t y = xy[i].fY;
317
319 CGContextMoveToPoint(ctx, x - imx, y);
320 CGContextAddLineToPoint(ctx, x, y - im);
322 CGContextAddLineToPoint(ctx, x, y + im);
325 }
326}
327
328
329//______________________________________________________________________________
330void DrawMarkerFullCross(CGContextRef ctx, unsigned n, const TPoint *xy,
331 Size_t markerSize)
332{
333 const Int_t im = Int_t(4 * markerSize + 0.5);
334 const Int_t imx = Int_t(1.33 * markerSize + 0.5);
335
336 for (unsigned i = 0; i < n; ++i) {
337 const Double_t x = xy[i].fX;
338 const Double_t y = xy[i].fY;
339
341 CGContextMoveToPoint(ctx, x - im, y - imx);
342 CGContextAddLineToPoint(ctx, x - imx, y - imx);
343 CGContextAddLineToPoint(ctx, x - imx, y - im);
344 CGContextAddLineToPoint(ctx, x + imx, y - im);
345 CGContextAddLineToPoint(ctx, x + imx, y - imx);
346 CGContextAddLineToPoint(ctx, x + im, y - imx);
347 CGContextAddLineToPoint(ctx, x + im, y + imx);
348 CGContextAddLineToPoint(ctx, x + imx, y + imx);
349 CGContextAddLineToPoint(ctx, x + imx, y + im);
350 CGContextAddLineToPoint(ctx, x - imx, y + im);
351 CGContextAddLineToPoint(ctx, x - imx, y + imx);
352 CGContextAddLineToPoint(ctx, x - im, y + imx);
353 CGContextAddLineToPoint(ctx, x - im, y - imx);
355 }
356}
357
358
359//______________________________________________________________________________
360void DrawMarkerOpenCross(CGContextRef ctx, unsigned n, const TPoint *xy,
361 Size_t markerSize)
362{
363 const Int_t im = Int_t(4 * markerSize + 0.5);
364 const Int_t imx = Int_t(1.33 * markerSize + 0.5);
365
366 for (unsigned i = 0; i < n; ++i) {
367 const Double_t x = xy[i].fX;
368 const Double_t y = xy[i].fY;
369
371 CGContextMoveToPoint(ctx, x - im, y - imx);
372 CGContextAddLineToPoint(ctx, x - imx, y - imx);
373 CGContextAddLineToPoint(ctx, x - imx, y - im);
374 CGContextAddLineToPoint(ctx, x + imx, y - im);
375 CGContextAddLineToPoint(ctx, x + imx, y - imx);
376 CGContextAddLineToPoint(ctx, x + im, y - imx);
377 CGContextAddLineToPoint(ctx, x + im, y + imx);
378 CGContextAddLineToPoint(ctx, x + imx, y + imx);
379 CGContextAddLineToPoint(ctx, x + imx, y + im);
380 CGContextAddLineToPoint(ctx, x - imx, y + im);
381 CGContextAddLineToPoint(ctx, x - imx, y + imx);
382 CGContextAddLineToPoint(ctx, x - im, y + imx);
383 CGContextAddLineToPoint(ctx, x - im, y - imx);
385 }
386}
387
388
389//______________________________________________________________________________
390void DrawMarkerFullStar(CGContextRef ctx, unsigned n, const TPoint *xy,
391 Size_t markerSize)
392{
393 // HIGZ full star pentagone
394 const Int_t im = Int_t(4 * markerSize + 0.5);
395 const Int_t im1 = Int_t(0.66 * markerSize + 0.5);
396 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
397 const Int_t im3 = Int_t(2.66 * markerSize + 0.5);
398 const Int_t im4 = Int_t(1.33 * markerSize + 0.5);
399
400 for (unsigned i = 0; i < n; ++i) {
401 const Double_t x = xy[i].fX;
402 const Double_t y = xy[i].fY;
403
405 CGContextMoveToPoint(ctx, x - im, y - im4);
406 CGContextAddLineToPoint(ctx, x - im2, y + im1);
407 CGContextAddLineToPoint(ctx, x - im4, y - im4);
409
411 CGContextMoveToPoint(ctx, x - im2, y + im1);//1
412 CGContextAddLineToPoint(ctx, x - im3, y + im);//2
413 CGContextAddLineToPoint(ctx, x, y + im2);//3
415
417 CGContextMoveToPoint(ctx, x, y + im2);//3
418 CGContextAddLineToPoint(ctx, x + im3, y + im);//4
419 CGContextAddLineToPoint(ctx, x + im2, y + im1);//5
421
423 CGContextMoveToPoint(ctx, x + im2, y + im1);//5
424 CGContextAddLineToPoint(ctx, x + im, y - im4);//6
425 CGContextAddLineToPoint(ctx,x + im4, y - im4);//7
427
429 CGContextMoveToPoint(ctx, x + im4, y - im4);//7
430 CGContextAddLineToPoint(ctx, x, y - im);//8
431 CGContextAddLineToPoint(ctx, x - im4, y - im4);//9
433
435 CGContextMoveToPoint(ctx, x - im4, y - im4);//9
436 CGContextAddLineToPoint(ctx, x - im2, y + im1);//1
437 CGContextAddLineToPoint(ctx, x, y + im2);//3
439
441 CGContextMoveToPoint(ctx, x - im4, y - im4);//9
442 CGContextAddLineToPoint(ctx, x, y + im2);//3
443 CGContextAddLineToPoint(ctx, x + im2, y + im1);//5
445
447 CGContextMoveToPoint(ctx, x - im4, y - im4);//9
448 CGContextAddLineToPoint(ctx, x + im2, y + im1);//5
449 CGContextAddLineToPoint(ctx, x + im4, y - im4);//7
451 }
452}
453
454
455//______________________________________________________________________________
456void DrawMarkerOpenStar(CGContextRef ctx, unsigned n, const TPoint *xy,
457 Size_t markerSize)
458{
459 const Int_t im = Int_t(4 * markerSize + 0.5);
460 const Int_t im1 = Int_t(0.66 * markerSize + 0.5);
461 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
462 const Int_t im3 = Int_t(2.66 * markerSize + 0.5);
463 const Int_t im4 = Int_t(1.33 * markerSize + 0.5);
464
465 for (unsigned i = 0; i < n; ++i) {
466 const Double_t x = xy[i].fX;
467 const Double_t y = xy[i].fY;
468
470 CGContextMoveToPoint(ctx, x - im, y - im4);
471 CGContextAddLineToPoint(ctx, x - im2, y + im1);
472 CGContextAddLineToPoint(ctx, x - im3, y + im);
474 CGContextAddLineToPoint(ctx, x + im3, y + im);
475 CGContextAddLineToPoint(ctx, x + im2, y + im1);
476 CGContextAddLineToPoint(ctx, x + im, y - im4);
477 CGContextAddLineToPoint(ctx, x + im4, y - im4);
478 CGContextAddLineToPoint(ctx, x, y - im);
479 CGContextAddLineToPoint(ctx, x - im4, y - im4);
480 CGContextAddLineToPoint(ctx, x - im, y - im4);
482 }
483}
484
485//______________________________________________________________________________
487 Size_t markerSize)
488{
489 const Int_t im = Int_t(4 * markerSize + 0.5);
490
491 for (unsigned i = 0; i < n; ++i) {
492 const Double_t x = xy[i].fX;
493 const Double_t y = xy[i].fY;
494
496 CGContextMoveToPoint(ctx, x - im, y - im);
497 CGContextAddLineToPoint(ctx, x + im, y - im);
498 CGContextAddLineToPoint(ctx, x + im, y + im);
499 CGContextAddLineToPoint(ctx, x - im, y + im);
500 CGContextAddLineToPoint(ctx, x - im, y - im);
501 CGContextAddLineToPoint(ctx, x + im, y + im);
503
505 CGContextMoveToPoint(ctx, x - im, y + im);
506 CGContextAddLineToPoint(ctx, x + im, y - im);
508 }
509}
510
511//______________________________________________________________________________
513 Size_t markerSize)
514{
515 const Int_t im = Int_t(4 * markerSize + 0.5);
516
517 for (unsigned i = 0; i < n; ++i) {
518 const Double_t x = xy[i].fX;
519 const Double_t y = xy[i].fY;
520
522 CGContextMoveToPoint(ctx, x - im, y );
523 CGContextAddLineToPoint(ctx, x , y - im);
524 CGContextAddLineToPoint(ctx, x + im, y );
525 CGContextAddLineToPoint(ctx, x , y + im);
526 CGContextAddLineToPoint(ctx, x - im, y );
527 CGContextAddLineToPoint(ctx, x + im, y );
529
531 CGContextMoveToPoint(ctx, x , y + im);
532 CGContextAddLineToPoint(ctx, x , y - im);
534 }
535}
536
537//______________________________________________________________________________
539 Size_t markerSize)
540{
541 const Int_t im = Int_t(4 * markerSize + 0.5);
542 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
543
544 for (unsigned i = 0; i < n; ++i) {
545 const Double_t x = xy[i].fX;
546 const Double_t y = xy[i].fY;
547
549 CGContextMoveToPoint(ctx, x , y );
550 CGContextAddLineToPoint(ctx, x -im2, y + im);
551 CGContextAddLineToPoint(ctx, x - im, y );
552 CGContextAddLineToPoint(ctx, x , y );
553 CGContextAddLineToPoint(ctx, x -im2, y - im);
554 CGContextAddLineToPoint(ctx, x +im2, y - im);
555 CGContextAddLineToPoint(ctx, x , y );
556 CGContextAddLineToPoint(ctx, x + im, y );
557 CGContextAddLineToPoint(ctx, x +im2, y + im);
558 CGContextAddLineToPoint(ctx, x , y );
560 }
561}
562
563//______________________________________________________________________________
564void DrawMarkerOctagonCross(CGContextRef ctx, unsigned n, const TPoint *xy,
565 Size_t markerSize)
566{
567 const Int_t im = Int_t(4 * markerSize + 0.5);
568 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
569
570 for (unsigned i = 0; i < n; ++i) {
571 const Double_t x = xy[i].fX;
572 const Double_t y = xy[i].fY;
573
575 CGContextMoveToPoint(ctx, x - im, y );
576 CGContextAddLineToPoint(ctx, x - im, y -im2);
577 CGContextAddLineToPoint(ctx, x -im2, y - im);
578 CGContextAddLineToPoint(ctx, x +im2, y - im);
579 CGContextAddLineToPoint(ctx, x + im, y -im2);
580 CGContextAddLineToPoint(ctx, x + im, y +im2);
581 CGContextAddLineToPoint(ctx, x +im2, y + im);
582 CGContextAddLineToPoint(ctx, x -im2, y + im);
583 CGContextAddLineToPoint(ctx, x - im, y +im2);
584 CGContextAddLineToPoint(ctx, x - im, y );
585 CGContextAddLineToPoint(ctx, x + im, y );
587
589 CGContextMoveToPoint(ctx, x , y - im);
590 CGContextAddLineToPoint(ctx, x , y + im);
592 }
593}
594
595//______________________________________________________________________________
597 Size_t markerSize)
598{
599 const Int_t im = Int_t(4 * markerSize + 0.5);
600 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
601
602 for (unsigned i = 0; i < n; ++i) {
603 const Double_t x = xy[i].fX;
604 const Double_t y = xy[i].fY;
605
607 CGContextMoveToPoint(ctx, x , y );
608 CGContextAddLineToPoint(ctx, x -im2, y + im);
609 CGContextAddLineToPoint(ctx, x - im, y );
610 CGContextAddLineToPoint(ctx, x , y );
611 CGContextAddLineToPoint(ctx, x -im2, y - im);
612 CGContextAddLineToPoint(ctx, x +im2, y - im);
613 CGContextAddLineToPoint(ctx, x , y );
614 CGContextAddLineToPoint(ctx, x + im, y );
615 CGContextAddLineToPoint(ctx, x +im2, y + im);
616 CGContextAddLineToPoint(ctx, x , y );
618 }
619}
620
621//______________________________________________________________________________
623 Size_t markerSize)
624{
625 const Int_t im = Int_t(4 * markerSize + 0.5);
626 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
627
628 for (unsigned i = 0; i < n; ++i) {
629 const Double_t x = xy[i].fX;
630 const Double_t y = xy[i].fY;
631
633 CGContextMoveToPoint(ctx, x , y );
634 CGContextAddLineToPoint(ctx, x +im2, y + im);
635 CGContextAddLineToPoint(ctx, x + im, y +im2);
636 CGContextAddLineToPoint(ctx, x , y );
637 CGContextAddLineToPoint(ctx, x + im, y -im2);
638 CGContextAddLineToPoint(ctx, x +im2, y - im);
639 CGContextAddLineToPoint(ctx, x , y );
640 CGContextAddLineToPoint(ctx, x -im2, y - im);
641 CGContextAddLineToPoint(ctx, x - im, y -im2);
642 CGContextAddLineToPoint(ctx, x , y );
643 CGContextAddLineToPoint(ctx, x - im, y +im2);
644 CGContextAddLineToPoint(ctx, x -im2, y + im);
645 CGContextAddLineToPoint(ctx, x , y );
647 }
648}
649
650//______________________________________________________________________________
652 Size_t markerSize)
653{
654 const Int_t im = Int_t(4 * markerSize + 0.5);
655 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
656
657 for (unsigned i = 0; i < n; ++i) {
658 const Double_t x = xy[i].fX;
659 const Double_t y = xy[i].fY;
660
662 CGContextMoveToPoint(ctx, x , y );
663 CGContextAddLineToPoint(ctx, x +im2, y + im);
664 CGContextAddLineToPoint(ctx, x + im, y +im2);
665 CGContextAddLineToPoint(ctx, x , y );
666 CGContextAddLineToPoint(ctx, x + im, y -im2);
667 CGContextAddLineToPoint(ctx, x +im2, y - im);
668 CGContextAddLineToPoint(ctx, x , y );
669 CGContextAddLineToPoint(ctx, x -im2, y - im);
670 CGContextAddLineToPoint(ctx, x - im, y -im2);
671 CGContextAddLineToPoint(ctx, x , y );
672 CGContextAddLineToPoint(ctx, x - im, y +im2);
673 CGContextAddLineToPoint(ctx, x -im2, y + im);
674 CGContextAddLineToPoint(ctx, x , y );
676 }
677}
678
679//______________________________________________________________________________
681 Size_t markerSize)
682{
683 const Int_t im = Int_t(4 * markerSize + 0.5);
684 const Int_t im4 = Int_t(markerSize + 0.5);
685
686 for (unsigned i = 0; i < n; ++i) {
687 const Double_t x = xy[i].fX;
688 const Double_t y = xy[i].fY;
689
691 CGContextMoveToPoint(ctx, x , y + im);
693 CGContextAddLineToPoint(ctx, x - im, y );
695 CGContextAddLineToPoint(ctx, x , y - im);
697 CGContextAddLineToPoint(ctx, x + im, y );
699 CGContextAddLineToPoint(ctx, x , y + im);
701 }
702}
703
704//______________________________________________________________________________
706 Size_t markerSize)
707{
708 const Int_t im = Int_t(4 * markerSize + 0.5);
709 const Int_t im4 = Int_t( markerSize + 0.5);
710
711 for (unsigned i = 0; i < n; ++i) {
712 const Double_t x = xy[i].fX;
713 const Double_t y = xy[i].fY;
714
716 CGContextMoveToPoint(ctx, x , y + im);
718 CGContextAddLineToPoint(ctx, x - im, y );
720 CGContextAddLineToPoint(ctx, x , y - im);
722 CGContextAddLineToPoint(ctx, x + im, y );
724 CGContextAddLineToPoint(ctx, x , y + im);
726 }
727}
728
729//______________________________________________________________________________
731 Size_t markerSize)
732{
733 const Int_t im = Int_t(4 * markerSize + 0.5);
734 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
735
736 for (unsigned i = 0; i < n; ++i) {
737 const Double_t x = xy[i].fX;
738 const Double_t y = xy[i].fY;
739
741 CGContextMoveToPoint(ctx, x , y );
742 CGContextAddLineToPoint(ctx, x +im2, y + im);
743 CGContextAddLineToPoint(ctx, x -im2, y + im);
744 CGContextAddLineToPoint(ctx, x +im2, y - im);
745 CGContextAddLineToPoint(ctx, x -im2, y - im);
746 CGContextAddLineToPoint(ctx, x , y );
747 CGContextAddLineToPoint(ctx, x + im, y +im2);
748 CGContextAddLineToPoint(ctx, x + im, y -im2);
749 CGContextAddLineToPoint(ctx, x - im, y +im2);
750 CGContextAddLineToPoint(ctx, x - im, y -im2);
751 CGContextAddLineToPoint(ctx, x , y );
753 }
754}
755
756//______________________________________________________________________________
758 Size_t markerSize)
759{
760 const Int_t im = Int_t(4 * markerSize + 0.5);
761 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
762 const Int_t im4 = Int_t(0.2 * markerSize + 0.5);
763
764 for (unsigned i = 0; i < n; ++i) {
765 const Double_t x = xy[i].fX;
766 const Double_t y = xy[i].fY;
767
769 CGContextMoveToPoint(ctx, x +im4, y +im4);
770 CGContextAddLineToPoint(ctx, x +im2, y + im);
771 CGContextAddLineToPoint(ctx, x -im2, y + im);
773 CGContextAddLineToPoint(ctx, x - im, y +im2);
774 CGContextAddLineToPoint(ctx, x - im, y -im2);
776 CGContextAddLineToPoint(ctx, x -im2, y - im);
777 CGContextAddLineToPoint(ctx, x +im2, y - im);
779 CGContextAddLineToPoint(ctx, x + im, y -im2);
780 CGContextAddLineToPoint(ctx, x + im, y +im2);
783 }
784}
785
786//______________________________________________________________________________
787void DrawMarkerOpenCrossX(CGContextRef ctx, unsigned n, const TPoint *xy,
788 Size_t markerSize)
789{
790 const Int_t im = Int_t(4 * markerSize + 0.5);
791 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
792
793 for (unsigned i = 0; i < n; ++i) {
794 const Double_t x = xy[i].fX;
795 const Double_t y = xy[i].fY;
796
798 CGContextMoveToPoint(ctx, x , y + im2);
799 CGContextAddLineToPoint(ctx, x -im2, y + im);
800 CGContextAddLineToPoint(ctx, x - im, y +im2);
802 CGContextAddLineToPoint(ctx, x - im, y -im2);
803 CGContextAddLineToPoint(ctx, x -im2, y - im);
805 CGContextAddLineToPoint(ctx, x +im2, y - im);
806 CGContextAddLineToPoint(ctx, x + im, y -im2);
808 CGContextAddLineToPoint(ctx, x + im, y +im2);
809 CGContextAddLineToPoint(ctx, x +im2, y + im);
812 }
813}
814
815//______________________________________________________________________________
816void DrawMarkerFullCrossX(CGContextRef ctx, unsigned n, const TPoint *xy,
817 Size_t markerSize)
818{
819 const Int_t im = Int_t(4 * markerSize + 0.5);
820 const Int_t im2 = Int_t(2.0 * markerSize + 0.5);
821
822 for (unsigned i = 0; i < n; ++i) {
823 const Double_t x = xy[i].fX;
824 const Double_t y = xy[i].fY;
825
827 CGContextMoveToPoint(ctx, x , y + im2);
828 CGContextAddLineToPoint(ctx, x -im2, y + im);
829 CGContextAddLineToPoint(ctx, x - im, y +im2);
831 CGContextAddLineToPoint(ctx, x - im, y -im2);
832 CGContextAddLineToPoint(ctx, x -im2, y - im);
834 CGContextAddLineToPoint(ctx, x +im2, y - im);
835 CGContextAddLineToPoint(ctx, x + im, y -im2);
837 CGContextAddLineToPoint(ctx, x + im, y +im2);
838 CGContextAddLineToPoint(ctx, x +im2, y + im);
841 }
842}
843
844//______________________________________________________________________________
845void DrawMarkerFourSquaresX(CGContextRef ctx, unsigned n, const TPoint *xy,
846 Size_t markerSize)
847{
848 const Int_t im = Int_t(4 * markerSize + 0.5);
849 const Int_t im2 = Int_t(2.00 * markerSize + 0.5);
850
851 for (unsigned i = 0; i < n; ++i) {
852 const Double_t x = xy[i].fX;
853 const Double_t y = xy[i].fY;
854
856 CGContextMoveToPoint(ctx, x , y + im2*1.01);
857 CGContextAddLineToPoint(ctx, x -im2, y + im);
858 CGContextAddLineToPoint(ctx, x - im, y +im2);
860 CGContextAddLineToPoint(ctx, x - im, y -im2);
861 CGContextAddLineToPoint(ctx, x -im2, y - im);
863 CGContextAddLineToPoint(ctx, x +im2, y - im);
864 CGContextAddLineToPoint(ctx, x + im, y -im2);
866 CGContextAddLineToPoint(ctx, x + im, y +im2);
867 CGContextAddLineToPoint(ctx, x +im2, y + im);
868 CGContextAddLineToPoint(ctx, x , y +im2*0.99);
869 CGContextAddLineToPoint(ctx, x +im2*0.99, y );
870 CGContextAddLineToPoint(ctx, x , y -im2*0.99);
871 CGContextAddLineToPoint(ctx, x -im2*0.99, y );
872 CGContextAddLineToPoint(ctx, x , y +im2*0.99);
874 }
875}
876
877//______________________________________________________________________________
879 Size_t markerSize)
880{
881 const Int_t im = Int_t(4 * markerSize + 0.5);
882 const Int_t im2 = Int_t(1.33 * markerSize + 0.5);
883
884 for (unsigned i = 0; i < n; ++i) {
885 const Double_t x = xy[i].fX;
886 const Double_t y = xy[i].fY;
887
889 CGContextMoveToPoint(ctx, x -im2, y - im2*1.005);
890 CGContextAddLineToPoint(ctx, x -im2, y - im);
891 CGContextAddLineToPoint(ctx, x +im2, y - im);
893 CGContextAddLineToPoint(ctx, x + im, y -im2);
894 CGContextAddLineToPoint(ctx, x + im, y +im2);
896 CGContextAddLineToPoint(ctx, x +im2, y + im);
897 CGContextAddLineToPoint(ctx, x -im2, y + im);
899 CGContextAddLineToPoint(ctx, x - im, y +im2);
900 CGContextAddLineToPoint(ctx, x - im, y -im2);
901 CGContextAddLineToPoint(ctx, x -im2, y -im2*0.995);
905 CGContextAddLineToPoint(ctx, x -im2, y -im2*1.005);
907 }
908}
909
910//______________________________________________________________________________
911void DrawPolyMarker(CGContextRef ctx, unsigned nPoints, const TPoint *xy,
912 const TAttMarker &attmark, float scaleFactor)
913{
914 if (!Quartz::SetFillColor(ctx, attmark.GetMarkerColor()))
915 return;
916
917 Quartz::SetLineColor(ctx, attmark.GetMarkerColor());//Can not fail (for coverity).
918 Quartz::SetLineStyle(ctx, 1);
920
921 if (scaleFactor > 1.)
922 CGContextScaleCTM(ctx, 1. / scaleFactor, 1. / scaleFactor);
923
925
926 // The fast pixel markers need to be treated separately
927 if (markerStyle == 1 || markerStyle == 6 || markerStyle == 7) {
930 } else {
933 }
934
935 Float_t markerSize = attmark.GetMarkerSize() - TMath::Floor(TAttMarker::GetMarkerLineWidth(attmark.GetMarkerStyle())/2.)/4.;
936 markerSize *= scaleFactor;
937
938 switch (markerStyle) {
939 case kDot:
940 DrawMarkerDot(ctx, nPoints, xy, markerSize);
941 break;
942 case kPlus:
943 DrawMarkerPlus(ctx, nPoints, xy, markerSize);
944 break;
945 case kStar:
946 case 31:
947 DrawMarkerStar(ctx, nPoints, xy, markerSize);
948 break;
949 case kCircle:
950 case kOpenCircle:
951 DrawMarkerOpenCircle(ctx, nPoints, xy, markerSize);
952 break;
953 case kMultiply:
954 DrawMarkerX(ctx, nPoints, xy, markerSize);
955 break;
956 case kFullDotSmall:
958 break;
959 case kFullDotMedium:
961 break;
962 case kFullDotLarge:
963 case kFullCircle:
964 DrawMarkerFullDotLarge(ctx, nPoints, xy, markerSize);
965 break;
966 case kFullSquare:
967 DrawMarkerFullSquare(ctx, nPoints, xy, markerSize);
968 break;
969 case kFullTriangleUp:
970 DrawMarkerFullTriangleUp(ctx, nPoints, xy, markerSize);
971 break;
973 DrawMarkerFullTriangleDown(ctx, nPoints, xy, markerSize);
974 break;
975 case kOpenSquare:
976 DrawMarkerOpenSquare(ctx, nPoints, xy, markerSize);
977 break;
978 case kOpenTriangleUp:
979 DrawMarkerOpenTriangleUp(ctx, nPoints, xy, markerSize);
980 break;
982 DrawMarkerOpenTriangleDown(ctx, nPoints, xy, markerSize);
983 break;
984 case kOpenDiamond:
985 DrawMarkerOpenDiamond(ctx, nPoints, xy, markerSize);
986 break;
987 case kFullDiamond:
988 DrawMarkerFullDiamond(ctx, nPoints, xy, markerSize);
989 break;
990 case kOpenCross:
991 DrawMarkerOpenCross(ctx, nPoints, xy, markerSize);
992 break;
993 case kFullCross:
994 DrawMarkerFullCross(ctx, nPoints, xy, markerSize);
995 break;
996 case kFullStar:
997 DrawMarkerFullStar(ctx, nPoints, xy, markerSize);
998 break;
999 case kOpenStar:
1000 DrawMarkerOpenStar(ctx, nPoints, xy, markerSize);
1001 break;
1002 case kOpenDiamondCross:
1003 DrawMarkerOpenDiamondCross(ctx, nPoints, xy, markerSize);
1004 break;
1006 DrawMarkerOpenSquareDiagonal(ctx, nPoints, xy, markerSize);
1007 break;
1009 DrawMarkerOpenThreeTriangles(ctx, nPoints, xy, markerSize);
1010 break;
1011 case kOctagonCross:
1012 DrawMarkerOctagonCross(ctx, nPoints, xy, markerSize);
1013 break;
1015 DrawMarkerFullThreeTriangles(ctx, nPoints, xy, markerSize);
1016 break;
1018 DrawMarkerOpenFourTrianglesX(ctx, nPoints, xy, markerSize);
1019 break;
1021 DrawMarkerFullFourTrianglesX(ctx, nPoints, xy, markerSize);
1022 break;
1023 case kOpenDoubleDiamond:
1024 DrawMarkerOpenDoubleDiamond(ctx, nPoints, xy, markerSize);
1025 break;
1026 case kFullDoubleDiamond:
1027 DrawMarkerFullDoubleDiamond(ctx, nPoints, xy, markerSize);
1028 break;
1030 DrawMarkerOpenFourTrianglesPlus(ctx, nPoints, xy, markerSize);
1031 break;
1033 DrawMarkerFullFourTrianglesPlus(ctx, nPoints, xy, markerSize);
1034 break;
1035 case kOpenCrossX:
1036 DrawMarkerOpenCrossX(ctx, nPoints, xy, markerSize);
1037 break;
1038 case kFullCrossX:
1039 DrawMarkerFullCrossX(ctx, nPoints, xy, markerSize);
1040 break;
1041 case kFourSquaresX:
1042 DrawMarkerFourSquaresX(ctx, nPoints, xy, markerSize);
1043 break;
1044 case kFourSquaresPlus:
1045 DrawMarkerFourSquaresPlus(ctx, nPoints, xy, markerSize);
1046 break;
1047 }
1048
1051}
1052
1053
1054}//namespace Quartz
1055}//namespace ROOT
#define d(i)
Definition RSha256.hxx:102
short Style_t
Style number (short)
Definition RtypesCore.h:96
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
float Size_t
Attribute size (float)
Definition RtypesCore.h:103
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
@ kOpenDoubleDiamond
Definition TAttMarker.h:68
@ kStar
Definition TAttMarker.h:58
@ kFullDotLarge
Definition TAttMarker.h:59
@ kFullDoubleDiamond
Definition TAttMarker.h:68
@ kOpenFourTrianglesX
Definition TAttMarker.h:67
@ kOpenSquare
Definition TAttMarker.h:61
@ kFullThreeTriangles
Definition TAttMarker.h:66
@ kOpenTriangleUp
Definition TAttMarker.h:62
@ kFourSquaresPlus
Definition TAttMarker.h:71
@ kFullDotSmall
Definition TAttMarker.h:59
@ kFullDotMedium
Definition TAttMarker.h:59
@ kOpenTriangleDown
Definition TAttMarker.h:63
@ kOpenThreeTriangles
Definition TAttMarker.h:65
@ kFullCrossX
Definition TAttMarker.h:70
@ kFullFourTrianglesX
Definition TAttMarker.h:67
@ kFullTriangleDown
Definition TAttMarker.h:61
@ kCircle
Definition TAttMarker.h:58
@ kOpenCrossX
Definition TAttMarker.h:70
@ kFullFourTrianglesPlus
Definition TAttMarker.h:69
@ kFullSquare
Definition TAttMarker.h:60
@ kOpenSquareDiagonal
Definition TAttMarker.h:65
@ kFullStar
Definition TAttMarker.h:63
@ kOpenDiamond
Definition TAttMarker.h:62
@ kFullTriangleUp
Definition TAttMarker.h:60
@ kOpenDiamondCross
Definition TAttMarker.h:64
@ kOpenFourTrianglesPlus
Definition TAttMarker.h:69
@ kMultiply
Definition TAttMarker.h:58
@ kPlus
Definition TAttMarker.h:58
@ kOctagonCross
Definition TAttMarker.h:66
@ kFullCircle
Definition TAttMarker.h:60
@ kDot
Definition TAttMarker.h:58
@ kOpenCross
Definition TAttMarker.h:62
@ kFourSquaresX
Definition TAttMarker.h:70
@ kOpenCircle
Definition TAttMarker.h:61
@ kFullCross
Definition TAttMarker.h:64
@ kOpenStar
Definition TAttMarker.h:63
@ kFullDiamond
Definition TAttMarker.h:64
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint xy
Option_t Option_t TPoint DrawPolyMarker
Marker Attributes class.
Definition TAttMarker.h:21
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
void DrawMarkerOpenSquare(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerStar(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullTriangleDown(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerPlus(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullDotLarge(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenDiamond(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullFourTrianglesPlus(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenSquareDiagonal(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOctagonCross(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullDotSmall(CGContextRef ctx, unsigned n, const TPoint *xy)
void DrawMarkerFullTriangleUp(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullCrossX(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenCrossX(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
Bool_t SetLineColor(CGContextRef ctx, Color_t colorIndex)
Definition QuartzLine.mm:29
void DrawMarkerDot(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenDiamondCross(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenThreeTriangles(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenTriangleUp(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFourSquaresPlus(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullStar(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenFourTrianglesPlus(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFourSquaresX(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
Bool_t SetFillColor(CGContextRef ctx, Color_t colorIndex)
void DrawMarkerOpenCross(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullSquare(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenStar(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerX(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullDoubleDiamond(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullDiamond(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullThreeTriangles(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenDoubleDiamond(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullFourTrianglesX(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenCircle(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullCross(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerOpenTriangleDown(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void SetLineWidth(CGContextRef ctx, Int_t width)
void SetLineStyle(CGContextRef ctx, Int_t lstyle)
Definition QuartzLine.mm:75
void DrawMarkerOpenFourTrianglesX(CGContextRef ctx, unsigned n, const TPoint *xy, Size_t markerSize)
void DrawMarkerFullDotMedium(CGContextRef ctx, unsigned n, const TPoint *xy)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:691