Logo ROOT   6.14/05
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 
19 #include <ROOT/TDrawingAttr.hxx>
20 #include <ROOT/TDrawingOptsBase.hxx>
21 #include <ROOT/TStringEnumAttr.hxx>
22 
23 namespace ROOT {
24 namespace Experimental {
25 
26 template <int DIMENSION>
28  static_assert(DIMENSION != 0, "Cannot draw 0-dimensional histograms!");
29  static_assert(DIMENSION > 3, "Cannot draw histograms with more than 3 dimensions!");
30  static_assert(DIMENSION < 3, "This should have been handled by the specializations below?!");
31 };
32 
33 /** \class THistDrawingOpts<1>
34  Drawing options for a 1D histogram.
35  */
36 template <>
37 class THistDrawingOpts<1>: public TDrawingOptsBase {
38 public:
39  enum class EStyle { kBar, kText };
40 
41 private:
42  static const TStringEnumAttrSet &Styles() {
43  static const TStringEnumAttrSet styles{"hist", "bar", "text"};
44  return styles;
45  }
46  TDrawingAttr<TStringEnumAttr<EStyle>> fStyle{*this, "Hist.1D.Style", EStyle::kBar, Styles()};
47  TDrawingAttr<TColor> fLineColor{*this, "Hist.1D.Line.Color"};
48  TDrawingAttr<int> fLineWidth{*this, "Hist.1D.Line.Width"};
49 
50 public:
51  EStyle GetStyle() const { return fStyle.Get().GetIndex(); }
52  TDrawingAttr<TStringEnumAttr<EStyle>> &GetStyle() { return fStyle; }
53  void SetStyle(EStyle style) { fStyle.Get().SetIndex(style); }
54 
55  TColor GetLineColor() const { return fLineColor.Get(); }
56  TDrawingAttr<TColor> &GetLineColor() { return fLineColor; }
57  void SetLineColor(const TColor& col) { fLineColor = col; }
58 
59  int GetLineWidth() const { return fLineWidth.Get(); }
60  TDrawingAttr<int> &GetLineWidth() { return fLineWidth; }
61  void SetLineWidth(int width) { fLineWidth = width; }
62 };
63 
64 /** \class THistDrawingOpts<2>
65  Drawing options for a 2D histogram.
66  */
67 template <>
68 class THistDrawingOpts<2>: public TDrawingOptsBase {
69 public:
70  enum class EStyle { kBox, kSurf, kText };
71 
72 private:
73  static const TStringEnumAttrSet &Styles() {
74  static const TStringEnumAttrSet styles{"box", "surf", "text"};
75  return styles;
76  }
77  TDrawingAttr<TStringEnumAttr<EStyle>> fStyle{*this, "Hist.2D.Style", EStyle::kBox, Styles()};
78  TDrawingAttr<TColor> fLineColor{*this, "Hist.2D.Line.Color"};
79  TDrawingAttr<int> fLineWidth{*this, "Hist.2D.Line.Width"};
80 
81 public:
82  EStyle GetStyle() const { return fStyle.Get().GetIndex(); }
83  TDrawingAttr<TStringEnumAttr<EStyle>> &GetStyle() { return fStyle; }
84  void SetStyle(EStyle style) { fStyle.Get().SetIndex(style); }
85 
86  TColor GetLineColor() const { return fLineColor.Get(); }
87  TDrawingAttr<TColor> &GetLineColor() { return fLineColor; }
88  void SetLineColor(const TColor& col) { fLineColor = col; }
89 
90  int GetLineWidth() const { return fLineWidth.Get(); }
91  TDrawingAttr<int> &GetLineWidth() { return fLineWidth; }
92  void SetLineWidth(int width) { fLineWidth = width; }
93 };
94 
95 /** \class THistDrawingOpts<3>
96  Drawing options for a 3D histogram.
97  */
98 template <>
99 class THistDrawingOpts<3>: public TDrawingOptsBase {
100 public:
101  enum class EStyle { kBox, kIso };
102 
103 private:
104  static const TStringEnumAttrSet &Styles() {
105  static const TStringEnumAttrSet styles{"box", "iso"};
106  return styles;
107  }
108  TDrawingAttr<TStringEnumAttr<EStyle>> fStyle{*this, "Hist.3D.Style", EStyle::kBox, Styles()};
109  TDrawingAttr<TColor> fLineColor{*this, "Hist.3D.Line.Color"};
110  TDrawingAttr<int> fLineWidth{*this, "Hist.3D.Line.Width"};
111 
112 public:
113  EStyle GetStyle() const { return fStyle.Get().GetIndex(); }
114  TDrawingAttr<TStringEnumAttr<EStyle>> &GetStyle() { return fStyle; }
115  void SetStyle(EStyle style) { fStyle.Get().SetIndex(style); }
116 
117  TColor GetLineColor() const { return fLineColor.Get(); }
118  TDrawingAttr<TColor> &GetLineColor() { return fLineColor; }
119  void SetLineColor(const TColor& col) { fLineColor = col; }
120 
121  int GetLineWidth() const { return fLineWidth.Get(); }
122  TDrawingAttr<int> &GetLineWidth() { return fLineWidth; }
123  void SetLineWidth(int width) { fLineWidth = width; }
124 };
125 
126 } // namespace Experimental
127 } // namespace ROOT
128 
129 #endif
Definition: Buttons.h:29
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
static const TStringEnumAttrSet & Styles()
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
static const TStringEnumAttrSet & Styles()
Definition: Buttons.h:30
static const TStringEnumAttrSet & Styles()
TDrawingAttr< TStringEnumAttr< EStyle > > & GetStyle()
TCanvas * style()
Definition: style.C:1
The color creation and management class.
Definition: TColor.h:19
TDrawingAttr< TStringEnumAttr< EStyle > > & GetStyle()
TDrawingAttr< TStringEnumAttr< EStyle > > & GetStyle()