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//______________________________________________________________________________
23void DrawPolyMarker(CGContextRef ctx, unsigned nPoints, const TPoint *xy,
24 const TAttMarker &attmark, float scaleFactor)
25{
26 Int_t markerSize = 0;
27 std::vector<TPoint> markerShape;
28
29 auto markerType = attmark.GetMarkerShape(markerSize, markerShape, scaleFactor);
30 auto markerLineWidth = TAttMarker::GetMarkerLineWidth(attmark.GetMarkerStyle());
31
32 if (!Quartz::SetFillColor(ctx, attmark.GetMarkerColor()))
33 return;
34
35 Quartz::SetLineColor(ctx, attmark.GetMarkerColor()); //Can not fail (for coverity).
37 Quartz::SetLineWidth(ctx, markerLineWidth);
38
39 if (scaleFactor > 1.)
40 CGContextScaleCTM(ctx, 1. / scaleFactor, 1. / scaleFactor);
41
42 // The fast pixel markers need to be treated separately
43 if (markerType == TAttMarker::kShapeSegments) {
46 } else {
49 }
50
51 switch(markerType) {
53 for (unsigned i = 0; i < nPoints; ++i)
54 CGContextFillRect(ctx, CGRectMake(xy[i].fX, xy[i].fY, 1, 1));
55 break;
58 for (unsigned i = 0; i < nPoints; ++i) {
59 const CGRect rect = CGRectMake(xy[i].fX - markerSize * 0.5, xy[i].fY - markerSize * 0.5, markerSize, markerSize);
60 if (markerType == TAttMarker::kShapeCircle)
62 else
64 }
65 break;
66 }
69 for (unsigned i = 0; i < nPoints; ++i) {
70 const Double_t x = xy[i].fX;
71 const Double_t y = xy[i].fY;
73 CGContextMoveToPoint(ctx, x + markerShape[0].fX, y + markerShape[0].fY);
74 for (std::size_t p = 1; p < markerShape.size(); p++)
75 CGContextAddLineToPoint(ctx, x + markerShape[p].fX, y + markerShape[p].fY);
76
77 if (markerType == TAttMarker::kShapePolyLine)
79 else
81 }
82 break;
84 for (unsigned i = 0; i < nPoints; ++i) {
85 const Double_t x = xy[i].fX;
86 const Double_t y = xy[i].fY;
87 for (std::size_t p = 0; p < markerShape.size(); p += 2) {
89 CGContextMoveToPoint(ctx, x + markerShape[p].fX, y + markerShape[p].fY);
90 CGContextAddLineToPoint(ctx, x + markerShape[p + 1].fX, y + markerShape[p + 1].fY);
92 }
93 }
94 break;
96 // filled triangles
97 for (unsigned i = 0; i < nPoints; ++i) {
98 const Double_t x = xy[i].fX;
99 const Double_t y = xy[i].fY;
100 for(std::size_t t = 0; t < markerShape.size(); t += 3) {
102 CGContextMoveToPoint(ctx, x + markerShape[t].fX, y + markerShape[t].fY);
103 for (std::size_t p = t + 1; p < t + 3; p++)
104 CGContextAddLineToPoint(ctx, x + markerShape[p].fX, y + markerShape[p].fY);
106 }
107 }
108 break;
109 }
110
113}
114
115} //namespace Quartz
116} //namespace ROOT
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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:22
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
@ kShapeTriangles
Definition TAttMarker.h:48
@ kShapeFilledArea
Definition TAttMarker.h:48
@ kShapeFilledCircle
Definition TAttMarker.h:48
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
Bool_t SetLineColor(CGContextRef ctx, Color_t colorIndex)
Definition QuartzLine.mm:29
Bool_t SetFillColor(CGContextRef ctx, Color_t colorIndex)
void SetLineWidth(CGContextRef ctx, Int_t width)
void SetLineStyle(CGContextRef ctx, Int_t lstyle)
Definition QuartzLine.mm:75