Logo ROOT   6.12/07
Reference Guide
THistDrawingOpts.hxx
Go to the documentation of this file.
1 /// \file ROOT/THistDrawingOpts.h
2 /// \ingroup HistDraw ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2015-09-04
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT7_THistDrawingOpts
17 #define ROOT7_THistDrawingOpts
18 
20 
21 namespace ROOT {
22 namespace Experimental {
23 
24 /** \class ROOT::Experimental::THistCoreAttrs
25 
26 Stores drawing attributes for a histogram. This class contains the properties
27 that are independent of the histogram dimensionality, and used by at least one of
28 the visualizations (scatter, bar, etc).
29 
30 Customize the defaults with `THistDrawingOpts<1>::Default().SetLineColor(TColor::kRed);` or by modifying the
31 style configuration file `rootstylerc` (e.g. $ROOTSYS/etc/system.rootstylerc or ~/.rootstylerc).
32  */
34  /// Index of the line color in TCanvas's color table.
35  //TDrawingAttrRef<TColor> fLineColorIndex{*this, "Hist.Line.Color"};
36  //TDrawingAttrRef<long long> fLineColorIndex{*this, "Hist.Line.Width"};
37  TLineAttrs fLine; ///< The histogram line attributes
38  TFillAttrs fFill; ///< The histogram fill attributes
39 
40  THistCoreAttrs() = default;
41  THistCoreAttrs(TDrawingOptsBaseNoDefault &opts, const std::string &name):
42  fLine{opts, name + ".Line", TColor::kBlack, TLineAttrs::Width{3}},
43  fFill{opts, name + ".Fill", TColor::kWhite}
44  {}
45 };
46 
47 template <int DIMENSION>
49  static_assert(DIMENSION != 0, "Cannot draw 0-dimensional histograms!");
50  static_assert(DIMENSION > 3, "Cannot draw histograms with more than 3 dimensions!");
51  static_assert(DIMENSION < 3, "This should have been handled by the specializations below?!");
52 };
53 
54 /** \class THistDrawingOptsBase
55  Core ingredients (that do not depend on the dimensionality) or histogram drawing options.
56  */
57 
58 template <class DERIVED>
59 class THistDrawingOptsBase: public TDrawingOptsBase<DERIVED> {
60  THistCoreAttrs fHistAttrs{*this, "Hist"}; ///< Basic histogram attributes (line, fill etc)
61 
62 protected:
63  THistDrawingOptsBase() = default;
64  THistDrawingOptsBase(TPadBase &pad, const std::string &name):
65  TDrawingOptsBase<DERIVED>(pad, name + ".Hist") {}
66 
67 public:
68  /// The color of the histogram line.
69  void SetLineColor(const TColor &col) { this->Update(fHistAttrs.fLine.fColor, col); }
70  TColor &GetLineColor() { return this->Get(fHistAttrs.fLine.fColor); }
71  const TColor &GetLineColor() const { return this->Get(fHistAttrs.fLine.fColor); }
72 
73  /// The width of the histogram line.
74  void SetLineWidth(TLineAttrs::Width width) { this->Update(fHistAttrs.fLine.fWidth, width); }
75  TLineAttrs::Width &GetLineWidth() { return this->Get(fHistAttrs.fLine.fWidth); }
76  const TLineAttrs::Width GetLineWidth() const { return this->Get(fHistAttrs.fLine.fWidth); }
77 
78  /// The color of the histogram line.
79  void SetFillColor(const TColor &col) { this->Update(fHistAttrs.fFill.fColor, col); }
80  TColor &GetFillColor() { return this->Get(fHistAttrs.fFill.fColor); }
81  const TColor &GetFillColor() const { return this->Get(fHistAttrs.fFill.fColor); }
82 };
83 
84 /** \class THistDrawingOpts<1>
85  Drawing options for a 1D histogram.
86  */
87 template <>
88 class THistDrawingOpts<1>: public THistDrawingOptsBase<THistDrawingOpts<1>> {
89  enum class EStyle { kBar, kText };
90  TDrawingAttrRef<long long> fStyle{*this, "Style", 0, {"hist", "bar", "text"}};
91 
92 public:
93  THistDrawingOpts() = default;
95 
96 };
97 
98 /** \class THistDrawingOpts<2>
99  Drawing options for a 1D histogram.
100  */
101 template <>
102 class THistDrawingOpts<2>: public THistDrawingOptsBase<THistDrawingOpts<2>> {
103  enum class EStyle { kBox, kSurf, kText };
104  TDrawingAttrRef<long long> fStyle{*this, "Style", 0, {"box", "surf", "text"}};
105 
106 public:
107  THistDrawingOpts() = default;
109 };
110 
111 /** \class THistDrawingOpts<3>
112  Drawing options for a 1D histogram.
113  */
114 template <>
115 class THistDrawingOpts<3>: public THistDrawingOptsBase<THistDrawingOpts<3>> {
116  enum class EStyle { kBox, kIso };
117  TDrawingAttrRef<long long> fStyle{*this, "Style", 0, {"box", "iso"}};
118 
119 public:
120  THistDrawingOpts() = default;
122 };
123 
124 } // namespace Experimental
125 } // namespace ROOT
126 
127 #endif
Definition: Buttons.h:29
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Base class for drawing options.
const TLineAttrs::Width GetLineWidth() const
TFillAttrs fFill
The histogram fill attributes.
Definition: Buttons.h:30
void SetLineWidth(TLineAttrs::Width width)
The width of the histogram line.
Base class for graphic containers for TDrawable-s.
Definition: TPad.hxx:41
static constexpr PredefinedRGB kBlack
Definition: TColor.hxx:189
THistDrawingOptsBase(TPadBase &pad, const std::string &name)
Stores drawing attributes for a histogram.
TLineAttrs fLine
Index of the line color in TCanvas&#39;s color table.
void SetLineColor(const TColor &col)
The color of the histogram line.
THistCoreAttrs(TDrawingOptsBaseNoDefault &opts, const std::string &name)
Core ingredients (that do not depend on the dimensionality) or histogram drawing options.
static constexpr PredefinedRGB kWhite
Definition: TColor.hxx:188
void SetFillColor(const TColor &col)
The color of the histogram line.
A color: Red|Green|Blue|Alpha, or a position in a TPalette.
Definition: TColor.hxx:27
char name[80]
Definition: TGX11.cxx:109