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 ignored (treated as 1) if the TCanvas has no GL support activated.
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/// For simple shape like circle just size is assigned, for other points vector is filled as well
408/// For special applications (like GL) one can create set of triangles instead of complex filled shapes
409/// This is required while GL not always able to correctly fill closed shape
410
412{
414 Int_t markerLineWidth = GetMarkerLineWidth(GetMarkerStyle());
415
416 Float_t markerSizeReduced = scale * (GetMarkerSize() - std::floor(markerLineWidth/2.)/4.);
417 const auto im = std::round(4*markerSizeReduced);
418 const auto im2 = std::round(2*markerSizeReduced);
419
420 auto addTriangle = [&shape](Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t x3 = 0, Int_t y3 = 0) {
421 shape.emplace_back(x1, y1);
422 shape.emplace_back(x2, y2);
423 shape.emplace_back(x3, y3);
424 };
425
426 auto addSquare = [&shape](Int_t x1, Int_t y1, Int_t x2, Int_t y2) {
427 shape.emplace_back(x1, y1);
428 shape.emplace_back(x1, y2);
429 shape.emplace_back(x2, y2);
430
431 shape.emplace_back(x1, y1);
432 shape.emplace_back(x2, y2);
433 shape.emplace_back(x2, y1);
434 };
435
436 sz = 0;
437 shape.clear();
438
439 switch (markerStyle) {
440 case kDot:
441 return kShapeDot;
442 case kPlus:
443 shape.resize(4);
444 shape[0].fX = -im; shape[0].fY = 0;
445 shape[1].fX = im; shape[1].fY = 0;
446 shape[2].fX = 0; shape[2].fY = -im;
447 shape[3].fX = 0; shape[3].fY = im;
448 return kShapeSegments;
449 case kStar:
450 case kStar2: {
451 const auto imx = std::round(0.707*4*markerSizeReduced);
452 shape.resize(8);
453 shape[0].fX = -im; shape[0].fY = 0;
454 shape[1].fX = im; shape[1].fY = 0;
455 shape[2].fX = 0 ; shape[2].fY = -im;
456 shape[3].fX = 0 ; shape[3].fY = im;
457 shape[4].fX = -imx; shape[4].fY = -imx;
458 shape[5].fX = imx; shape[5].fY = imx;
459 shape[6].fX = -imx; shape[6].fY = imx;
460 shape[7].fX = imx; shape[7].fY = -imx;
461 return kShapeSegments;
462 }
463 case kCircle:
464 case kOpenCircle:
465 sz = im * 2;
466 return kShapeCircle;
467 case kMultiply: {
468 const auto imx = std::round(0.707*4*markerSizeReduced);
469 shape.reserve(4);
470 shape.emplace_back(-imx, -imx);
471 shape.emplace_back( imx, imx);
472 shape.emplace_back(-imx, imx);
473 shape.emplace_back( imx, -imx);
474 return kShapeSegments;
475 }
476 case kFullDotSmall:
477 shape.resize(4);
478 shape[0].fX = -1; shape[0].fY = 0;
479 shape[1].fX = 1; shape[1].fY = 0;
480 shape[2].fX = 0; shape[2].fY = -1;
481 shape[3].fX = 0; shape[3].fY = 1;
482 return kShapeSegments;
483 case kFullDotMedium:
484 shape.resize(5);
485 shape[0].fX = -1; shape[0].fY = -1;
486 shape[1].fX = 1; shape[1].fY = -1;
487 shape[2].fX = 1; shape[2].fY = 1;
488 shape[3].fX = -1; shape[3].fY = 1;
489 shape[4].fX = -1; shape[4].fY = -1;
490 return kShapeFilledArea;
491 case kFullDotLarge:
492 case kFullCircle:
493 sz = im * 2;
494 return kShapeFilledCircle;
495 case kFullSquare:
496 shape.resize(5);
497 shape[0].fX = -im; shape[0].fY = -im;
498 shape[1].fX = im; shape[1].fY = -im;
499 shape[2].fX = im; shape[2].fY = im;
500 shape[3].fX = -im; shape[3].fY = im;
501 shape[4].fX = -im; shape[4].fY = -im;
502 return kShapeFilledArea;
503 case kFullTriangleUp:
504 case kOpenTriangleUp:
505 shape.resize(4);
506 shape[0].fX = -im; shape[0].fY = im;
507 shape[1].fX = im; shape[1].fY = im;
508 shape[2].fX = 0; shape[2].fY = -im;
509 shape[3].fX = -im; shape[3].fY = im;
513 shape.resize(4);
514 shape[0].fX = 0; shape[0].fY = im;
515 shape[1].fX = im; shape[1].fY = -im;
516 shape[2].fX = -im; shape[2].fY = -im;
517 shape[3].fX = 0; shape[3].fY = im;
519 case kOpenSquare:
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 kShapePolyLine;
527 case kOpenDiamond:
528 case kFullDiamond: {
529 shape.resize(5);
530 const auto imx = std::round(2.66*markerSizeReduced);
531 shape[0].fX =-imx; shape[0].fY = 0;
532 shape[1].fX = 0; shape[1].fY = -im;
533 shape[2].fX = imx; shape[2].fY = 0;
534 shape[3].fX = 0; shape[3].fY = im;
535 shape[4].fX =-imx; shape[4].fY = 0;
537 }
538 case kFullCross:
539 if (prefer_triangles) {
540 const auto imx = std::round(1.33*markerSizeReduced);
541 shape.reserve(3 * 6);
542 addSquare( -im, -imx, -imx, imx);
543 addSquare(-imx, -im, imx, im);
544 addSquare( imx, -imx, im, imx);
545 return kShapeTriangles;
546 }
547 case kOpenCross: {
548 shape.resize(13);
549 const auto imx = std::round(1.33*markerSizeReduced);
550 shape[0].fX = -im; shape[0].fY =-imx;
551 shape[1].fX =-imx; shape[1].fY =-imx;
552 shape[2].fX =-imx; shape[2].fY = -im;
553 shape[3].fX = imx; shape[3].fY = -im;
554 shape[4].fX = imx; shape[4].fY =-imx;
555 shape[5].fX = im; shape[5].fY =-imx;
556 shape[6].fX = im; shape[6].fY = imx;
557 shape[7].fX = imx; shape[7].fY = imx;
558 shape[8].fX = imx; shape[8].fY = im;
559 shape[9].fX =-imx; shape[9].fY = im;
560 shape[10].fX=-imx; shape[10].fY= imx;
561 shape[11].fX= -im; shape[11].fY= imx;
562 shape[12].fX= -im; shape[12].fY=-imx;
564 }
565 case kFullStar:
566 if (prefer_triangles) {
567 const auto im1 = std::round(0.66*markerSizeReduced);
568 const auto im3 = std::round(2.66*markerSizeReduced);
569 const auto im4 = std::round(1.33*markerSizeReduced);
570 shape.reserve(8 * 3);
571
572 addTriangle( -im, im4, -im2, -im1, -im4, im4);
573 addTriangle(-im2, -im1, -im3, -im, 0, -im2);
574 addTriangle( 0, -im2, im3, -im, im2, -im1);
575 addTriangle( im2, -im1, im, im4, im4, im4);
576 addTriangle( im4, im4, 0, im, -im4, im4);
577 addTriangle(-im4, im4, -im2, -im1, 0, -im2);
578 addTriangle(-im4, im4, 0, -im2, im2, -im1);
579 addTriangle(-im4, im4, im2, -im1, im4, im4);
580 return kShapeTriangles;
581 }
582 case kOpenStar: {
583 const auto im1 = std::round(0.66*markerSizeReduced);
584 const auto im3 = std::round(2.66*markerSizeReduced);
585 const auto im4 = std::round(1.33*markerSizeReduced);
586 shape.resize(11);
587 shape[0].fX = -im; shape[0].fY = im4;
588 shape[1].fX =-im2; shape[1].fY =-im1;
589 shape[2].fX =-im3; shape[2].fY = -im;
590 shape[3].fX = 0; shape[3].fY =-im2;
591 shape[4].fX = im3; shape[4].fY = -im;
592 shape[5].fX = im2; shape[5].fY =-im1;
593 shape[6].fX = im; shape[6].fY = im4;
594 shape[7].fX = im4; shape[7].fY = im4;
595 shape[8].fX = 0; shape[8].fY = im;
596 shape[9].fX =-im4; shape[9].fY = im4;
597 shape[10].fX= -im; shape[10].fY= im4;
599 }
601 shape.resize(8);
602 shape[0].fX =-im; shape[0].fY = 0;
603 shape[1].fX = 0; shape[1].fY = -im;
604 shape[2].fX = im; shape[2].fY = 0;
605 shape[3].fX = 0; shape[3].fY = im;
606 shape[4].fX =-im; shape[4].fY = 0;
607 shape[5].fX = im; shape[5].fY = 0;
608 shape[6].fX = 0; shape[6].fY = im;
609 shape[7].fX = 0; shape[7].fY =-im;
610 return kShapePolyLine;
612 shape.resize(8);
613 shape[0].fX = -im; shape[0].fY = -im;
614 shape[1].fX = im; shape[1].fY = -im;
615 shape[2].fX = im; shape[2].fY = im;
616 shape[3].fX = -im; shape[3].fY = im;
617 shape[4].fX = -im; shape[4].fY = -im;
618 shape[5].fX = im; shape[5].fY = im;
619 shape[6].fX = -im; shape[6].fY = im;
620 shape[7].fX = im; shape[7].fY = -im;
621 return kShapePolyLine;
623 shape.resize(10);
624 shape[0].fX = 0; shape[0].fY = 0;
625 shape[1].fX =-im2; shape[1].fY = im;
626 shape[2].fX = im2; shape[2].fY = im;
627 shape[3].fX = 0; shape[3].fY = 0;
628 shape[4].fX =-im2; shape[4].fY = -im;
629 shape[5].fX = -im; shape[5].fY = 0;
630 shape[6].fX = 0; shape[6].fY = 0;
631 shape[7].fX = im; shape[7].fY = 0;
632 shape[8].fX = im2; shape[8].fY = -im;
633 shape[9].fX = 0; shape[9].fY = 0;
634 return kShapePolyLine;
635 case kOctagonCross:
636 shape.resize(15);
637 shape[0].fX = -im; shape[0].fY = 0;
638 shape[1].fX = -im; shape[1].fY =-im2;
639 shape[2].fX =-im2; shape[2].fY = -im;
640 shape[3].fX = im2; shape[3].fY = -im;
641 shape[4].fX = im; shape[4].fY =-im2;
642 shape[5].fX = im; shape[5].fY = im2;
643 shape[6].fX = im2; shape[6].fY = im;
644 shape[7].fX =-im2; shape[7].fY = im;
645 shape[8].fX = -im; shape[8].fY = im2;
646 shape[9].fX = -im; shape[9].fY = 0;
647 shape[10].fX = im; shape[10].fY = 0;
648 shape[11].fX = 0; shape[11].fY = 0;
649 shape[12].fX = 0; shape[12].fY = -im;
650 shape[13].fX = 0; shape[13].fY = im;
651 shape[14].fX = 0; shape[14].fY = 0;
652 return kShapePolyLine;
654 shape.reserve(3 * 3);
655 addTriangle( -im, 0, -im2, im);
656 addTriangle( im2, im, im, 0);
657 addTriangle( im2, -im, -im2, -im);
658 return kShapeTriangles;
660 shape.resize(13);
661 shape[0].fX = 0; shape[0].fY = 0;
662 shape[1].fX = im2; shape[1].fY = im;
663 shape[2].fX = im; shape[2].fY = im2;
664 shape[3].fX = 0; shape[3].fY = 0;
665 shape[4].fX = im; shape[4].fY = -im2;
666 shape[5].fX = im2; shape[5].fY = -im;
667 shape[6].fX = 0; shape[6].fY = 0;
668 shape[7].fX = -im2; shape[7].fY = -im;
669 shape[8].fX = -im; shape[8].fY = -im2;
670 shape[9].fX = 0; shape[9].fY = 0;
671 shape[10].fX = -im; shape[10].fY = im2;
672 shape[11].fX = -im2; shape[11].fY = im;
673 shape[12].fX = 0; shape[12].fY = 0;
674 return kShapePolyLine;
676 shape.reserve(4 * 3);
677 addTriangle( -im, im2, -im2, im);
678 addTriangle( im2, im, im, im2);
679 addTriangle( im, -im2, im2, -im);
680 addTriangle(-im2, -im, -im, -im2);
681 return kShapeTriangles;
683 if (prefer_triangles) {
684 const auto im4 = std::round(markerSizeReduced);
685 shape.reserve(8 * 3);
686 addTriangle( 0, im, -im4, im4);
687 addTriangle(-im4, im4, -im, 0);
688 addTriangle( -im, 0, -im4, -im4);
689 addTriangle(-im4, -im4, 0, -im);
690 addTriangle( 0, -im, im4, -im4);
691 addTriangle( im4, -im4, im, 0);
692 addTriangle( im, 0, im4, im4);
693 addTriangle( im4, im4, 0, im);
694 return kShapeTriangles;
695 }
696 case kOpenDoubleDiamond: {
697 const auto im4 = std::round(markerSizeReduced);
698 shape.resize(9);
699 shape[0].fX= 0; shape[0].fY= im;
700 shape[1].fX= -im4; shape[1].fY= im4;
701 shape[2].fX = -im; shape[2].fY = 0;
702 shape[3].fX = -im4; shape[3].fY = -im4;
703 shape[4].fX = 0; shape[4].fY = -im;
704 shape[5].fX = im4; shape[5].fY = -im4;
705 shape[6].fX = im; shape[6].fY = 0;
706 shape[7].fX= im4; shape[7].fY= im4;
707 shape[8].fX= 0; shape[8].fY= im;
709 }
711 shape.resize(11);
712 shape[0].fX = 0; shape[0].fY = 0;
713 shape[1].fX = im2; shape[1].fY = im;
714 shape[2].fX = -im2; shape[2].fY = im;
715 shape[3].fX = im2; shape[3].fY = -im;
716 shape[4].fX = -im2; shape[4].fY = -im;
717 shape[5].fX = 0; shape[5].fY = 0;
718 shape[6].fX = im; shape[6].fY = im2;
719 shape[7].fX = im; shape[7].fY = -im2;
720 shape[8].fX = -im; shape[8].fY = im2;
721 shape[9].fX = -im; shape[9].fY = -im2;
722 shape[10].fX = 0; shape[10].fY = 0;
723 return kShapePolyLine;
725 shape.reserve(4 * 3);
726 addTriangle(-im2, im, im2, im);
727 addTriangle( im, im2, im, -im2);
728 addTriangle( im2, -im, -im2, -im);
729 addTriangle( -im, -im2, -im, im2);
730 return kShapeTriangles;
731 case kFullCrossX:
732 if (prefer_triangles) {
733 shape.reserve(6 * 3);
734 addTriangle(-im2, 0, -im, im2, -im2, im);
735 addTriangle(-im2, 0, -im2, im, 0, im2);
736 addTriangle(-im2, -im, -im, -im2, im2, im);
737 addTriangle(-im2, -im, im2, im, im, im2);
738 addTriangle( im2, -im, 0, -im2, im2, 0);
739 addTriangle( im2, -im, im2, 0, im,-im2);
740 return kShapeTriangles;
741 }
742 case kOpenCrossX:
743 shape.resize(13);
744 shape[0].fX = 0; shape[0].fY = im2;
745 shape[1].fX = -im2; shape[1].fY = im;
746 shape[2].fX = -im; shape[2].fY = im2;
747 shape[3].fX = -im2; shape[3].fY = 0;
748 shape[4].fX = -im; shape[4].fY = -im2;
749 shape[5].fX = -im2; shape[5].fY = -im;
750 shape[6].fX = 0; shape[6].fY = -im2;
751 shape[7].fX = im2; shape[7].fY = -im;
752 shape[8].fX = im; shape[8].fY = -im2;
753 shape[9].fX = im2; shape[9].fY = 0;
754 shape[10].fX = im; shape[10].fY = im2;
755 shape[11].fX = im2; shape[11].fY = im;
756 shape[12].fX = 0; shape[12].fY = im2;
758 case kFourSquaresX:
759 shape.reserve(8 * 3);
760 addTriangle( -im2, 0, -im, im2, -im2, im);
761 addTriangle( -im2, 0, -im2, im, 0, im2);
762 addTriangle( im2, 0, 0, im2, im2, im);
763 addTriangle( im2, 0, im2, im, im, im2);
764 addTriangle( -im2, -im, -im, -im2, -im2, 0);
765 addTriangle( -im2, -im, -im2, 0, 0, -im2);
766 addTriangle( im2, -im, 0, -im2, im2, 0);
767 addTriangle( im2, -im, im2, 0, im, -im2);
768 return kShapeTriangles;
769 case kFourSquaresPlus: {
770 const auto imx = std::round(1.33*markerSizeReduced);
771 shape.reserve(4 * 2 * 3);
772 addSquare(-imx, imx, imx, im);
773 addSquare( imx, -imx, im, imx);
774 addSquare( -im, -imx,-imx, imx);
775 addSquare(-imx, -im, imx, -imx);
776 return kShapeTriangles;
777 }
778 }
779
780 return kShapeDot;
781}
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:89
@ kStar
Definition TAttMarker.h:61
@ kFullDotLarge
Definition TAttMarker.h:66
@ kFullDoubleDiamond
Definition TAttMarker.h:90
@ kOpenFourTrianglesX
Definition TAttMarker.h:87
@ kOpenSquare
Definition TAttMarker.h:72
@ kFullThreeTriangles
Definition TAttMarker.h:86
@ kOpenTriangleUp
Definition TAttMarker.h:73
@ kFourSquaresPlus
Definition TAttMarker.h:96
@ kFullDotSmall
Definition TAttMarker.h:64
@ kFullDotMedium
Definition TAttMarker.h:65
@ kOpenTriangleDown
Definition TAttMarker.h:79
@ kOpenThreeTriangles
Definition TAttMarker.h:84
@ kFullCrossX
Definition TAttMarker.h:94
@ kFullFourTrianglesX
Definition TAttMarker.h:88
@ kFullTriangleDown
Definition TAttMarker.h:70
@ kCircle
Definition TAttMarker.h:62
@ kOpenCrossX
Definition TAttMarker.h:93
@ kFullFourTrianglesPlus
Definition TAttMarker.h:92
@ kFullSquare
Definition TAttMarker.h:68
@ kOpenSquareDiagonal
Definition TAttMarker.h:83
@ kFullStar
Definition TAttMarker.h:76
@ kOpenDiamond
Definition TAttMarker.h:74
@ kStar2
Definition TAttMarker.h:78
@ kFullTriangleUp
Definition TAttMarker.h:69
@ kOpenDiamondCross
Definition TAttMarker.h:82
@ kOpenFourTrianglesPlus
Definition TAttMarker.h:91
@ kMultiply
Definition TAttMarker.h:63
@ kPlus
Definition TAttMarker.h:60
@ kOctagonCross
Definition TAttMarker.h:85
@ kFullCircle
Definition TAttMarker.h:67
@ kDot
Definition TAttMarker.h:59
@ kOpenCross
Definition TAttMarker.h:75
@ kFourSquaresX
Definition TAttMarker.h:95
@ kOpenCircle
Definition TAttMarker.h:71
@ kFullCross
Definition TAttMarker.h:81
@ kOpenStar
Definition TAttMarker.h:77
@ kFullDiamond
Definition TAttMarker.h:80
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
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:36
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
EMarkerShape GetMarkerShape(Int_t &sz, std::vector< TPoint > &points, Float_t scale=1., Bool_t prefer_triangles=kFALSE) const
Return marker shape.
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:2556
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition TColor.cxx:2182
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