Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TAttMarker.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 12/05/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2026, 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 <iostream>
15#include <cmath>
16#include "TVirtualPad.h"
17#include "TVirtualPadPainter.h"
18#include "TVirtualPadEditor.h"
19#include "TStyle.h"
20#include "TColor.h"
21#include "TPoint.h"
22
23
24/** \class TAttMarker
25\ingroup Base
26\ingroup GraphicsAtt
27
28Marker Attributes class.
29
30This class is used (in general by secondary inheritance)
31by many other classes (graphics, histograms). It holds all the markers
32attributes.
33
34## Marker attributes
35The marker attributes are:
36
37 - [Marker color](\ref ATTMARKER1)
38 - [Marker style](\ref ATTMARKER2)
39 - [Marker line width](\ref ATTMARKER21)
40 - [Marker size](\ref M3)
41
42\anchor ATTMARKER1
43## Marker color
44The marker color is a color index (integer) pointing in the ROOT color
45table.
46The marker color of any class inheriting from `TAttMarker` can
47be changed using the method `SetMarkerColor` and retrieved using the
48method `GetMarkerColor`.
49The following table shows the first 50 default colors.
50
51Begin_Macro
52{
53 TCanvas *c = new TCanvas("c","Fill Area colors",0,0,500,200);
54 c->DrawColorTable();
55 return c;
56}
57End_Macro
58
59### Color transparency
60
61`SetMarkerColorAlpha()`, allows to set a transparent color.
62In the following example the marker color of the histogram `histo`
63is set to blue with an opacity of 35% (i.e. a transparency of 65%).
64(The color `kBlue` itself is internally stored as fully opaque.)
65
66~~~ {.cpp}
67histo->SetMarkerColorAlpha(kBlue, 0.35);
68~~~
69
70The transparency is available on all platforms when the flag `OpenGL.CanvasPreferGL` is set to `1`
71in `$ROOTSYS/etc/system.rootrc`, or on Mac with the Cocoa backend. On the file output
72it is visible with PDF, PNG, Gif, JPEG, SVG, TeX ... but not PostScript.
73
74Alternatively, you can call at the top of your script `gSytle->SetCanvasPreferGL();`.
75Or if you prefer to activate GL for a single canvas `c`, then use `c->SetSupportGL(true);`.
76
77\anchor ATTMARKER2
78## Marker style
79
80The Marker style defines the markers' shape.
81The marker style of any class inheriting from `TAttMarker` can
82be changed using the method `SetMarkerStyle` and retrieved using the
83method `GetMarkerStyle`.
84
85The following list gives the currently supported markers (screen
86and PostScript) style. Each marker style is identified by an integer number
87(first column) corresponding to a marker shape (second column) and can be also
88accessed via a global name (third column).
89
90~~~ {.cpp}
91 Marker number Marker shape Marker name
92 1 dot kDot
93 2 + kPlus
94 3 * kStar
95 4 o kCircle
96 5 x kMultiply
97 6 small dot kFullDotSmall
98 7 medium dot kFullDotMedium
99 8 large scalable dot kFullDotLarge
100 9 -->19 large scalable dot
101 20 full circle kFullCircle
102 21 full square kFullSquare
103 22 full triangle up kFullTriangleUp
104 23 full triangle down kFullTriangleDown
105 24 open circle kOpenCircle
106 25 open square kOpenSquare
107 26 open triangle up kOpenTriangleUp
108 27 open diamond kOpenDiamond
109 28 open cross kOpenCross
110 29 full star kFullStar
111 30 open star kOpenStar
112 31 * kStar2
113 32 open triangle down kOpenTriangleDown
114 33 full diamond kFullDiamond
115 34 full cross kFullCross
116 35 open diamond cross kOpenDiamondCross
117 36 open square diagonal kOpenSquareDiagonal
118 37 open three triangle kOpenThreeTriangles
119 38 octagon with cross kOctagonCross
120 39 full three triangles kFullThreeTriangles
121 40 open four triangleX kOpenFourTrianglesX
122 41 full four triangleX kFullFourTrianglesX
123 42 open double diamond kOpenDoubleDiamond
124 43 full double diamond kFullDoubleDiamond
125 44 open four triangle+ kOpenFourTrianglesPlus
126 45 full four triangle+ kFullFourTrianglesPlus
127 46 open cross X kOpenCrossX
128 47 full cross X kFullCrossX
129 48 four squares X kFourSquaresX
130 49 four squares+ kFourSquaresPlus
131~~~
132
133Begin_Macro
134{
135 TCanvas *c = new TCanvas("c","Marker types",0,0,500,200);
136 TMarker::DisplayMarkerTypes();
137}
138End_Macro
139
140\warning Non-symmetric symbols should be used carefully. See markerwarning.C
141
142\anchor ATTMARKER21
143### Marker line width
144
145The line width of a marker is not actually a marker attribute since it does
146only apply to open marker symbols and marker symbols consisting of lines. All
147of these marker symbols are redefined with thicker lines by style numbers
148starting from 50:
149
150~~~ {.cpp}
151 Marker numbers Line width
152 50 - 67 2
153 68 - 85 3
154 86 - 103 4
155 104 - 121 5
156 ...
157~~~
158
159Begin_Macro
160{
161 TCanvas *c = new TCanvas("c","Marker line widths",0,0,600,266);
162 TMarker::DisplayMarkerLineWidths();
163}
164End_Macro
165
166\anchor M3
167## Marker size
168
169Various marker sizes are shown in the figure below. The default marker size=1
170is shown in the top left corner. Marker sizes smaller than 1 can be
171specified. The marker size does not refer to any coordinate systems, it is an
172absolute value. Therefore the marker size is not affected by any change
173in TPad's scale. A marker size equal to 1 correspond to 8 pixels.
174That is, a square marker with size 1 will be drawn with a side equal to 8
175pixels on the screen.
176
177The marker size of any class inheriting from `TAttMarker` can
178be changed using the method `SetMarkerSize` and retrieved using the
179method `GetMarkerSize`.
180
181Begin_Macro
182{
183 auto c = new TCanvas("c","Marker sizes",0,0,500,200);
184 TMarker marker;
185 marker.SetMarkerStyle(3);
186 Double_t x = 0;
187 Double_t dx = 1/6.0;
188 for (Int_t i=1; i<6; i++) {
189 x += dx;
190 marker.SetMarkerSize(i*0.2); marker.DrawMarker(x,.165);
191 marker.SetMarkerSize(i*0.8); marker.DrawMarker(x,.495);
192 marker.SetMarkerSize(i*1.0); marker.DrawMarker(x,.835);
193 }
194}
195End_Macro
196
197Note that the marker styles number 1 6 and 7 (the dots), cannot be scaled. They
198are meant to be very fast to draw and are always drawn with the same number of
199pixels; therefore `SetMarkerSize` does not apply on them. To have a
200"scalable dot" a filled circle should be used instead, i.e. the marker style
201number 20. By default (if `SetMarkerStyle` is not specified), the marker
202style used is 1. That's the most common one to draw scatter plots.
203*/
204
205////////////////////////////////////////////////////////////////////////////////
206/// TAttMarker default constructor.
207///
208/// Default text attributes are taking from the current style.
209
211{
212 if (!gStyle) {
213 fMarkerColor = 1;
215 fMarkerSize = 1;
216 } else {
220 }
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// TAttMarker normal constructor.
225///
226/// Text attributes are taking from the argument list
227/// - color : Marker Color Index
228/// - style : Marker style (from 1 to 30)
229/// - size : marker size (float)
230
237
238////////////////////////////////////////////////////////////////////////////////
239/// TAttMarker destructor.
240
244
245////////////////////////////////////////////////////////////////////////////////
246/// Copy this marker attributes to a new TAttMarker.
247
249{
250 attmarker.fMarkerColor = fMarkerColor;
251 attmarker.fMarkerStyle = fMarkerStyle;
252 attmarker.fMarkerSize = fMarkerSize;
253}
254
255////////////////////////////////////////////////////////////////////////////////
256/// Internal helper function that returns the corresponding marker style with
257/// line width 1 for the given style.
258
260{
261 if (style <= kFourSquaresPlus)
262 return style;
263
264 switch ((style - 50) % 18) {
265 case 0: return kPlus;
266 case 1: return kStar;
267 case 2: return kMultiply;
268 case 3: return kOpenCircle;
269 case 4: return kOpenSquare;
270 case 5: return kOpenTriangleUp;
271 case 6: return kOpenDiamond;
272 case 7: return kOpenCross;
273 case 8: return kOpenStar;
274 case 9: return kOpenTriangleDown;
275 case 10: return kOpenDiamondCross;
276 case 11: return kOpenSquareDiagonal;
277 case 12: return kOpenThreeTriangles;
278 case 13: return kOctagonCross;
279 case 14: return kOpenFourTrianglesX;
280 case 15: return kOpenDoubleDiamond;
281 case 16: return kOpenFourTrianglesPlus;
282 case 17: return kOpenCrossX;
283 }
284
285 return kDot;
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Internal helper function that returns the line width of the given marker
290/// style (0 = filled marker)
291
306
307////////////////////////////////////////////////////////////////////////////////
308/// Change current marker attributes if necessary.
309
311{
312 if (gPad)
313 ModifyOn(*gPad);
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Change current marker attributes if necessary on specified pad.
318
320{
321 auto pp = pad.GetPainter();
322 if (pp)
323 pp->SetAttMarker(*this);
324}
325
326
327////////////////////////////////////////////////////////////////////////////////
328/// Reset this marker attributes to the default values.
329
336
337////////////////////////////////////////////////////////////////////////////////
338/// Save line attributes as C++ statement(s) on output stream out.
339
341{
342 if (fMarkerColor != coldef)
343 out << " " << name << "->SetMarkerColor(" << TColor::SavePrimitiveColor(fMarkerColor) << ");\n";
344 if (fMarkerStyle != stydef)
345 out << " " << name << "->SetMarkerStyle(" << fMarkerStyle << ");\n";
346 if (fMarkerSize != sizdef)
347 out << " " << name << "->SetMarkerSize(" << fMarkerSize << ");\n";
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Invoke the DialogCanvas Marker attributes.
352
357
358////////////////////////////////////////////////////////////////////////////////
359/// Set a transparent marker color.
360/// \param mcolor defines the marker color
361/// \param malpha defines the percentage of opacity from 0. (fully transparent) to 1. (fully opaque).
362/// \note malpha is used only on the [supported platforms](\ref col_trans_available).
363
368
369////////////////////////////////////////////////////////////////////////////////
370/// Set the marker color.
371
376
377////////////////////////////////////////////////////////////////////////////////
378/// Set the marker color.
379
384
385////////////////////////////////////////////////////////////////////////////////
386/// Set the marker style.
387
392
393////////////////////////////////////////////////////////////////////////////////
394/// Set the marker size.
395/// Note that the marker styles number 1 6 and 7 (the dots), cannot be scaled.
396/// They are meant to be very fast to draw and are always drawn with the same number of pixels;
397/// therefore this method does not apply on them.
398
403
404////////////////////////////////////////////////////////////////////////////////
405/// Return marker shape.
406/// Depending from configured marker style different marker shapes are returned
407/// \param sz return pixel size of the marker shape is returned (diamter for circle shapes)
408/// \param shape will contains vector of shape points
409/// \param scale defines scaling factor for size and shape coordinates
410/// \param flags let configure following options:
411/// kPreferTriangles - return kShapeTriangles instead of kShapeFilledArea, used when graphics engine not able to fill complex area
412/// kDotAsLines - convert small and medium dot into lines/fillrec which are directly drawn by pixel devices
413/// kDotAsCircle - automatically convert small and medium dots into circles
414/// kUsePSWidthScale - use gStyle->GetLineScalePS() for marker size calculations
415
417{
419 Int_t markerLineWidth = GetMarkerLineWidth(GetMarkerStyle());
420
421 Float_t wscale = (flags & kUsePSWidthScale) ? gStyle->GetLineScalePS() / 4. : 1.;
422
423 Float_t markerSizeReduced = scale * (GetMarkerSize() - std::floor(markerLineWidth/2.)/4. * wscale);
424 const auto im = std::round(4*markerSizeReduced);
425 const auto im2 = std::round(2*markerSizeReduced);
426
427 auto addTriangle = [&shape](Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t x3 = 0, Int_t y3 = 0) {
428 shape.emplace_back(x1, y1);
429 shape.emplace_back(x2, y2);
430 shape.emplace_back(x3, y3);
431 };
432
433 auto addSquare = [&shape](Int_t x1, Int_t y1, Int_t x2, Int_t y2) {
434 shape.emplace_back(x1, y1);
435 shape.emplace_back(x1, y2);
436 shape.emplace_back(x2, y2);
437
438 shape.emplace_back(x1, y1);
439 shape.emplace_back(x2, y2);
440 shape.emplace_back(x2, y1);
441 };
442
443 sz = 2 * im;
444 shape.clear();
445
446 switch (markerStyle) {
447 case kDot:
448 sz = 1;
449 return kShapeDot;
450 case kPlus:
451 shape.resize(4);
452 shape[0].fX = -im; shape[0].fY = 0;
453 shape[1].fX = im; shape[1].fY = 0;
454 shape[2].fX = 0; shape[2].fY = -im;
455 shape[3].fX = 0; shape[3].fY = im;
456 return kShapeSegments;
457 case kStar:
458 case kStar2: {
459 const auto imx = std::round(0.707*4*markerSizeReduced);
460 shape.resize(8);
461 shape[0].fX = -im; shape[0].fY = 0;
462 shape[1].fX = im; shape[1].fY = 0;
463 shape[2].fX = 0 ; shape[2].fY = -im;
464 shape[3].fX = 0 ; shape[3].fY = im;
465 shape[4].fX = -imx; shape[4].fY = -imx;
466 shape[5].fX = imx; shape[5].fY = imx;
467 shape[6].fX = -imx; shape[6].fY = imx;
468 shape[7].fX = imx; shape[7].fY = -imx;
469 return kShapeSegments;
470 }
471 case kCircle:
472 case kOpenCircle:
473 sz = im * 2;
474 return kShapeCircle;
475 case kMultiply: {
476 const auto imx = std::round(0.707*4*markerSizeReduced);
477 shape.reserve(4);
478 shape.emplace_back(-imx, -imx);
479 shape.emplace_back( imx, imx);
480 shape.emplace_back(-imx, imx);
481 shape.emplace_back( imx, -imx);
482 return kShapeSegments;
483 }
484 case kFullDotSmall:
485 if (flags & kDotAsLines) {
486 shape.resize(4);
487 shape[0].fX = -1; shape[0].fY = 0;
488 shape[1].fX = 1; shape[1].fY = 0;
489 shape[2].fX = 0; shape[2].fY = -1;
490 shape[3].fX = 0; shape[3].fY = 1;
491 return kShapeSegments;
492 } else if (flags & kDotAsCircle) {
493 sz = 4;
494 return kShapeFilledCircle;
495 } else {
496 sz = 2;
497 return kShapeDot;
498 }
499 case kFullDotMedium:
500 if (flags & kDotAsLines) {
501 shape.resize(5);
502 shape[0].fX = -1; shape[0].fY = -1;
503 shape[1].fX = 1; shape[1].fY = -1;
504 shape[2].fX = 1; shape[2].fY = 1;
505 shape[3].fX = -1; shape[3].fY = 1;
506 shape[4].fX = -1; shape[4].fY = -1;
507 return kShapeFilledArea;
508 } else if (flags & kDotAsCircle) {
509 sz = 6;
510 return kShapeFilledCircle;
511 } else {
512 sz = 3;
513 return kShapeDot;
514 }
515 case kFullDotLarge:
516 case kFullCircle:
517 sz = im * 2;
518 return kShapeFilledCircle;
519 case kFullSquare:
520 shape.resize(5);
521 shape[0].fX = -im; shape[0].fY = -im;
522 shape[1].fX = im; shape[1].fY = -im;
523 shape[2].fX = im; shape[2].fY = im;
524 shape[3].fX = -im; shape[3].fY = im;
525 shape[4].fX = -im; shape[4].fY = -im;
526 return kShapeFilledArea;
527 case kFullTriangleUp:
528 case kOpenTriangleUp:
529 shape.resize(4);
530 shape[0].fX = -im; shape[0].fY = im;
531 shape[1].fX = im; shape[1].fY = im;
532 shape[2].fX = 0; shape[2].fY = -im;
533 shape[3].fX = -im; shape[3].fY = im;
537 shape.resize(4);
538 shape[0].fX = 0; shape[0].fY = im;
539 shape[1].fX = im; shape[1].fY = -im;
540 shape[2].fX = -im; shape[2].fY = -im;
541 shape[3].fX = 0; shape[3].fY = im;
543 case kOpenSquare:
544 shape.resize(5);
545 shape[0].fX = -im; shape[0].fY = -im;
546 shape[1].fX = im; shape[1].fY = -im;
547 shape[2].fX = im; shape[2].fY = im;
548 shape[3].fX = -im; shape[3].fY = im;
549 shape[4].fX = -im; shape[4].fY = -im;
550 return kShapePolyLine;
551 case kOpenDiamond:
552 case kFullDiamond: {
553 shape.resize(5);
554 const auto imx = std::round(2.66*markerSizeReduced);
555 shape[0].fX =-imx; shape[0].fY = 0;
556 shape[1].fX = 0; shape[1].fY = -im;
557 shape[2].fX = imx; shape[2].fY = 0;
558 shape[3].fX = 0; shape[3].fY = im;
559 shape[4].fX =-imx; shape[4].fY = 0;
561 }
562 case kFullCross:
563 if (flags & kPreferTriangles) {
564 const auto imx = std::round(1.33*markerSizeReduced);
565 shape.reserve(3 * 6);
566 addSquare( -im, -imx, -imx, imx);
567 addSquare(-imx, -im, imx, im);
568 addSquare( imx, -imx, im, imx);
569 return kShapeTriangles;
570 }
571 case kOpenCross: {
572 shape.resize(13);
573 const auto imx = std::round(1.33*markerSizeReduced);
574 shape[0].fX = -im; shape[0].fY =-imx;
575 shape[1].fX =-imx; shape[1].fY =-imx;
576 shape[2].fX =-imx; shape[2].fY = -im;
577 shape[3].fX = imx; shape[3].fY = -im;
578 shape[4].fX = imx; shape[4].fY =-imx;
579 shape[5].fX = im; shape[5].fY =-imx;
580 shape[6].fX = im; shape[6].fY = imx;
581 shape[7].fX = imx; shape[7].fY = imx;
582 shape[8].fX = imx; shape[8].fY = im;
583 shape[9].fX =-imx; shape[9].fY = im;
584 shape[10].fX=-imx; shape[10].fY= imx;
585 shape[11].fX= -im; shape[11].fY= imx;
586 shape[12].fX= -im; shape[12].fY=-imx;
588 }
589 case kFullStar:
590 if (flags & kPreferTriangles) {
591 const auto im1 = std::round(0.66*markerSizeReduced);
592 const auto im3 = std::round(2.66*markerSizeReduced);
593 const auto im4 = std::round(1.33*markerSizeReduced);
594 shape.reserve(8 * 3);
595
596 addTriangle( -im, im4, -im2, -im1, -im4, im4);
597 addTriangle(-im2, -im1, -im3, -im, 0, -im2);
598 addTriangle( 0, -im2, im3, -im, im2, -im1);
599 addTriangle( im2, -im1, im, im4, im4, im4);
600 addTriangle( im4, im4, 0, im, -im4, im4);
601 addTriangle(-im4, im4, -im2, -im1, 0, -im2);
602 addTriangle(-im4, im4, 0, -im2, im2, -im1);
603 addTriangle(-im4, im4, im2, -im1, im4, im4);
604 return kShapeTriangles;
605 }
606 case kOpenStar: {
607 const auto im1 = std::round(0.66*markerSizeReduced);
608 const auto im3 = std::round(2.66*markerSizeReduced);
609 const auto im4 = std::round(1.33*markerSizeReduced);
610 shape.resize(11);
611 shape[0].fX = -im; shape[0].fY = im4;
612 shape[1].fX =-im2; shape[1].fY =-im1;
613 shape[2].fX =-im3; shape[2].fY = -im;
614 shape[3].fX = 0; shape[3].fY =-im2;
615 shape[4].fX = im3; shape[4].fY = -im;
616 shape[5].fX = im2; shape[5].fY =-im1;
617 shape[6].fX = im; shape[6].fY = im4;
618 shape[7].fX = im4; shape[7].fY = im4;
619 shape[8].fX = 0; shape[8].fY = im;
620 shape[9].fX =-im4; shape[9].fY = im4;
621 shape[10].fX= -im; shape[10].fY= im4;
623 }
625 shape.resize(12);
626 shape[0].fX =-im; shape[0].fY = 0;
627 shape[1].fX = 0; shape[1].fY = -im;
628 shape[2].fX = 0; shape[2].fY = -im;
629 shape[3].fX = im; shape[3].fY = 0;
630 shape[4].fX = im; shape[4].fY = 0;
631 shape[5].fX = 0; shape[5].fY = im;
632 shape[6].fX = 0; shape[6].fY = im;
633 shape[7].fX =-im; shape[7].fY = 0;
634 shape[8].fX =-im; shape[8].fY = 0;
635 shape[9].fX = im; shape[9].fY = 0;
636 shape[10].fX = 0; shape[10].fY = im;
637 shape[11].fX = 0; shape[11].fY =-im;
638 return kShapeSegments;
640 shape.resize(12);
641 shape[0].fX = -im; shape[0].fY = -im;
642 shape[1].fX = im; shape[1].fY = -im;
643 shape[2].fX = im; shape[2].fY = -im;
644 shape[3].fX = im; shape[3].fY = im;
645 shape[4].fX = im; shape[4].fY = im;
646 shape[5].fX = -im; shape[5].fY = im;
647 shape[6].fX = -im; shape[6].fY = im;
648 shape[7].fX = -im; shape[7].fY = -im;
649 shape[8].fX = -im; shape[8].fY = -im;
650 shape[9].fX = im; shape[9].fY = im;
651 shape[10].fX = -im; shape[10].fY = im;
652 shape[11].fX = im; shape[11].fY = -im;
653 return kShapeSegments;
655 shape.resize(10);
656 shape[0].fX = 0; shape[0].fY = 0;
657 shape[1].fX =-im2; shape[1].fY = im;
658 shape[2].fX = im2; shape[2].fY = im;
659 shape[3].fX = 0; shape[3].fY = 0;
660 shape[4].fX =-im2; shape[4].fY = -im;
661 shape[5].fX = -im; shape[5].fY = 0;
662 shape[6].fX = 0; shape[6].fY = 0;
663 shape[7].fX = im; shape[7].fY = 0;
664 shape[8].fX = im2; shape[8].fY = -im;
665 shape[9].fX = 0; shape[9].fY = 0;
666 return kShapePolyLine;
667 case kOctagonCross:
668 shape.resize(15);
669 shape[0].fX = -im; shape[0].fY = 0;
670 shape[1].fX = -im; shape[1].fY =-im2;
671 shape[2].fX =-im2; shape[2].fY = -im;
672 shape[3].fX = im2; shape[3].fY = -im;
673 shape[4].fX = im; shape[4].fY =-im2;
674 shape[5].fX = im; shape[5].fY = im2;
675 shape[6].fX = im2; shape[6].fY = im;
676 shape[7].fX =-im2; shape[7].fY = im;
677 shape[8].fX = -im; shape[8].fY = im2;
678 shape[9].fX = -im; shape[9].fY = 0;
679 shape[10].fX = im; shape[10].fY = 0;
680 shape[11].fX = 0; shape[11].fY = 0;
681 shape[12].fX = 0; shape[12].fY = -im;
682 shape[13].fX = 0; shape[13].fY = im;
683 shape[14].fX = 0; shape[14].fY = 0;
684 return kShapePolyLine;
686 shape.reserve(3 * 3);
687 addTriangle( -im, 0, -im2, im);
688 addTriangle( im2, im, im, 0);
689 addTriangle( im2, -im, -im2, -im);
690 return kShapeTriangles;
692 shape.resize(13);
693 shape[0].fX = 0; shape[0].fY = 0;
694 shape[1].fX = im2; shape[1].fY = im;
695 shape[2].fX = im; shape[2].fY = im2;
696 shape[3].fX = 0; shape[3].fY = 0;
697 shape[4].fX = im; shape[4].fY = -im2;
698 shape[5].fX = im2; shape[5].fY = -im;
699 shape[6].fX = 0; shape[6].fY = 0;
700 shape[7].fX = -im2; shape[7].fY = -im;
701 shape[8].fX = -im; shape[8].fY = -im2;
702 shape[9].fX = 0; shape[9].fY = 0;
703 shape[10].fX = -im; shape[10].fY = im2;
704 shape[11].fX = -im2; shape[11].fY = im;
705 shape[12].fX = 0; shape[12].fY = 0;
706 return kShapePolyLine;
708 shape.reserve(4 * 3);
709 addTriangle( -im, im2, -im2, im);
710 addTriangle( im2, im, im, im2);
711 addTriangle( im, -im2, im2, -im);
712 addTriangle(-im2, -im, -im, -im2);
713 return kShapeTriangles;
715 if (flags & kPreferTriangles) {
716 const auto im4 = std::round(markerSizeReduced);
717 shape.reserve(8 * 3);
718 addTriangle( 0, im, -im4, im4);
719 addTriangle(-im4, im4, -im, 0);
720 addTriangle( -im, 0, -im4, -im4);
721 addTriangle(-im4, -im4, 0, -im);
722 addTriangle( 0, -im, im4, -im4);
723 addTriangle( im4, -im4, im, 0);
724 addTriangle( im, 0, im4, im4);
725 addTriangle( im4, im4, 0, im);
726 return kShapeTriangles;
727 }
728 case kOpenDoubleDiamond: {
729 const auto im4 = std::round(markerSizeReduced);
730 shape.resize(9);
731 shape[0].fX= 0; shape[0].fY= im;
732 shape[1].fX= -im4; shape[1].fY= im4;
733 shape[2].fX = -im; shape[2].fY = 0;
734 shape[3].fX = -im4; shape[3].fY = -im4;
735 shape[4].fX = 0; shape[4].fY = -im;
736 shape[5].fX = im4; shape[5].fY = -im4;
737 shape[6].fX = im; shape[6].fY = 0;
738 shape[7].fX= im4; shape[7].fY= im4;
739 shape[8].fX= 0; shape[8].fY= im;
741 }
743 shape.resize(11);
744 shape[0].fX = 0; shape[0].fY = 0;
745 shape[1].fX = im2; shape[1].fY = im;
746 shape[2].fX = -im2; shape[2].fY = im;
747 shape[3].fX = im2; shape[3].fY = -im;
748 shape[4].fX = -im2; shape[4].fY = -im;
749 shape[5].fX = 0; shape[5].fY = 0;
750 shape[6].fX = im; shape[6].fY = im2;
751 shape[7].fX = im; shape[7].fY = -im2;
752 shape[8].fX = -im; shape[8].fY = im2;
753 shape[9].fX = -im; shape[9].fY = -im2;
754 shape[10].fX = 0; shape[10].fY = 0;
755 return kShapePolyLine;
757 shape.reserve(4 * 3);
758 addTriangle(-im2, im, im2, im);
759 addTriangle( im, im2, im, -im2);
760 addTriangle( im2, -im, -im2, -im);
761 addTriangle( -im, -im2, -im, im2);
762 return kShapeTriangles;
763 case kFullCrossX:
764 if (flags & kPreferTriangles) {
765 shape.reserve(6 * 3);
766 addTriangle(-im2, 0, -im, im2, -im2, im);
767 addTriangle(-im2, 0, -im2, im, 0, im2);
768 addTriangle(-im2, -im, -im, -im2, im2, im);
769 addTriangle(-im2, -im, im2, im, im, im2);
770 addTriangle( im2, -im, 0, -im2, im2, 0);
771 addTriangle( im2, -im, im2, 0, im,-im2);
772 return kShapeTriangles;
773 }
774 case kOpenCrossX:
775 shape.resize(13);
776 shape[0].fX = 0; shape[0].fY = im2;
777 shape[1].fX = -im2; shape[1].fY = im;
778 shape[2].fX = -im; shape[2].fY = im2;
779 shape[3].fX = -im2; shape[3].fY = 0;
780 shape[4].fX = -im; shape[4].fY = -im2;
781 shape[5].fX = -im2; shape[5].fY = -im;
782 shape[6].fX = 0; shape[6].fY = -im2;
783 shape[7].fX = im2; shape[7].fY = -im;
784 shape[8].fX = im; shape[8].fY = -im2;
785 shape[9].fX = im2; shape[9].fY = 0;
786 shape[10].fX = im; shape[10].fY = im2;
787 shape[11].fX = im2; shape[11].fY = im;
788 shape[12].fX = 0; shape[12].fY = im2;
790 case kFourSquaresX:
791 shape.reserve(8 * 3);
792 addTriangle( -im2, 0, -im, im2, -im2, im);
793 addTriangle( -im2, 0, -im2, im, 0, im2);
794 addTriangle( im2, 0, 0, im2, im2, im);
795 addTriangle( im2, 0, im2, im, im, im2);
796 addTriangle( -im2, -im, -im, -im2, -im2, 0);
797 addTriangle( -im2, -im, -im2, 0, 0, -im2);
798 addTriangle( im2, -im, 0, -im2, im2, 0);
799 addTriangle( im2, -im, im2, 0, im, -im2);
800 return kShapeTriangles;
801 case kFourSquaresPlus: {
802 const auto imx = std::round(1.33*markerSizeReduced);
803 shape.reserve(4 * 2 * 3);
804 addSquare(-imx, imx, imx, im);
805 addSquare( imx, -imx, im, imx);
806 addSquare( -im, -imx,-imx, imx);
807 addSquare(-imx, -im, imx, -imx);
808 return kShapeTriangles;
809 }
810 }
811
812 sz = 1;
813 return kShapeDot;
814}
short Style_t
Style number (short)
Definition RtypesCore.h:97
short Color_t
Color number (short)
Definition RtypesCore.h:100
float Size_t
Attribute size (float)
Definition RtypesCore.h:104
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
@ kOpenDoubleDiamond
Definition TAttMarker.h:95
@ kStar
Definition TAttMarker.h:67
@ kFullDotLarge
Definition TAttMarker.h:72
@ kFullDoubleDiamond
Definition TAttMarker.h:96
@ kOpenFourTrianglesX
Definition TAttMarker.h:93
@ kOpenSquare
Definition TAttMarker.h:78
@ kFullThreeTriangles
Definition TAttMarker.h:92
@ kOpenTriangleUp
Definition TAttMarker.h:79
@ kFourSquaresPlus
Definition TAttMarker.h:102
@ kFullDotSmall
Definition TAttMarker.h:70
@ kFullDotMedium
Definition TAttMarker.h:71
@ kOpenTriangleDown
Definition TAttMarker.h:85
@ kOpenThreeTriangles
Definition TAttMarker.h:90
@ kFullCrossX
Definition TAttMarker.h:100
@ kFullFourTrianglesX
Definition TAttMarker.h:94
@ kFullTriangleDown
Definition TAttMarker.h:76
@ kCircle
Definition TAttMarker.h:68
@ kOpenCrossX
Definition TAttMarker.h:99
@ kFullFourTrianglesPlus
Definition TAttMarker.h:98
@ kFullSquare
Definition TAttMarker.h:74
@ kOpenSquareDiagonal
Definition TAttMarker.h:89
@ kFullStar
Definition TAttMarker.h:82
@ kOpenDiamond
Definition TAttMarker.h:80
@ kStar2
Definition TAttMarker.h:84
@ kFullTriangleUp
Definition TAttMarker.h:75
@ kOpenDiamondCross
Definition TAttMarker.h:88
@ kOpenFourTrianglesPlus
Definition TAttMarker.h:97
@ kMultiply
Definition TAttMarker.h:69
@ kPlus
Definition TAttMarker.h:66
@ kOctagonCross
Definition TAttMarker.h:91
@ kFullCircle
Definition TAttMarker.h:73
@ kDot
Definition TAttMarker.h:65
@ kOpenCross
Definition TAttMarker.h:81
@ kFourSquaresX
Definition TAttMarker.h:101
@ kOpenCircle
Definition TAttMarker.h:77
@ kFullCross
Definition TAttMarker.h:87
@ kOpenStar
Definition TAttMarker.h:83
@ kFullDiamond
Definition TAttMarker.h:86
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 x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t style
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:148
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
Marker Attributes class.
Definition TAttMarker.h:22
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void Modify()
Change current marker attributes if necessary.
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:35
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:34
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:25
@ kUsePSWidthScale
Definition TAttMarker.h:53
@ kPreferTriangles
Definition TAttMarker.h:50
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:36
EMarkerShape GetMarkerShape(Int_t &sz, std::vector< TPoint > &points, Float_t scale=1., UInt_t flags=0) const
Return marker shape.
virtual void ModifyOn(TVirtualPad &pad)
Change current marker attributes if necessary on specified pad.
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
virtual ~TAttMarker()
TAttMarker destructor.
virtual void SetMarkerAttributes()
Invoke the DialogCanvas Marker attributes.
virtual void ResetAttMarker(Option_t *toption="")
Reset this marker attributes to the default values.
void Copy(TAttMarker &attmarker) const
Copy this marker attributes to a new TAttMarker.
TAttMarker()
TAttMarker default constructor.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerColorAlpha(Color_t mcolor, Float_t malpha)
Set a transparent marker color.
Size_t fMarkerSize
Marker size.
Definition TAttMarker.h:27
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:26
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
@ kShapeTriangles
Definition TAttMarker.h:48
@ kShapeFilledArea
Definition TAttMarker.h:48
@ kShapeFilledCircle
Definition TAttMarker.h:48
static TString SavePrimitiveColor(Int_t ci)
Convert color in C++ statement which can be used in SetColor directives Produced statement either inc...
Definition TColor.cxx:2569
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition TColor.cxx:2195
Float_t GetLineScalePS() const
Definition TStyle.h:291
static void UpdateMarkerAttributes(Int_t col, Int_t sty, Float_t msiz)
Update marker attributes via the pad editor.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51