Logo ROOT   6.16/01
Reference Guide
RHistDrawingOpts.hxx
Go to the documentation of this file.
1/// \file ROOT/RHistDrawingOpts.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_RHistDrawingOpts
17#define ROOT7_RHistDrawingOpts
18
19#include <ROOT/RDrawingAttr.hxx>
20#include <ROOT/RDrawingOptsBase.hxx>
21#include <ROOT/RStringEnumAttr.hxx>
22
23namespace ROOT {
24namespace Experimental {
25
26template <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 RHistDrawingOpts<1>
34 Drawing options for a 1D histogram.
35 */
36template <>
37class RHistDrawingOpts<1>: public RDrawingOptsBase {
38public:
39 enum class EStyle { kBar, kText };
40
41private:
42 static const RStringEnumAttrSet &Styles() {
43 static const RStringEnumAttrSet styles{"hist", "bar", "text"};
44 return styles;
45 }
46 RDrawingAttr<RStringEnumAttr<EStyle>> fStyle{*this, "Hist.1D.Style", EStyle::kBar, Styles()};
47 RDrawingAttr<RColor> fLineColor{*this, "Hist.1D.Line.Color"};
48 RDrawingAttr<int> fLineWidth{*this, "Hist.1D.Line.Width"};
49
50public:
51 EStyle GetStyle() const { return fStyle.Get().GetIndex(); }
52 RDrawingAttr<RStringEnumAttr<EStyle>> &GetStyle() { return fStyle; }
53 void SetStyle(EStyle style) { fStyle.Get().SetIndex(style); }
54
55 RColor GetLineColor() const { return fLineColor.Get(); }
56 RDrawingAttr<RColor> &GetLineColor() { return fLineColor; }
57 void SetLineColor(const RColor& col) { fLineColor = col; }
58
59 int GetLineWidth() const { return fLineWidth.Get(); }
60 RDrawingAttr<int> &GetLineWidth() { return fLineWidth; }
61 void SetLineWidth(int width) { fLineWidth = width; }
62};
63
64/** \class RHistDrawingOpts<2>
65 Drawing options for a 2D histogram.
66 */
67template <>
68class RHistDrawingOpts<2>: public RDrawingOptsBase {
69public:
70 enum class EStyle { kBox, kSurf, kText };
71
72private:
73 static const RStringEnumAttrSet &Styles() {
74 static const RStringEnumAttrSet styles{"box", "surf", "text"};
75 return styles;
76 }
77 RDrawingAttr<RStringEnumAttr<EStyle>> fStyle{*this, "Hist.2D.Style", EStyle::kBox, Styles()};
78 RDrawingAttr<RColor> fLineColor{*this, "Hist.2D.Line.Color"};
79 RDrawingAttr<int> fLineWidth{*this, "Hist.2D.Line.Width"};
80
81public:
82 EStyle GetStyle() const { return fStyle.Get().GetIndex(); }
83 RDrawingAttr<RStringEnumAttr<EStyle>> &GetStyle() { return fStyle; }
84 void SetStyle(EStyle style) { fStyle.Get().SetIndex(style); }
85
86 RColor GetLineColor() const { return fLineColor.Get(); }
87 RDrawingAttr<RColor> &GetLineColor() { return fLineColor; }
88 void SetLineColor(const RColor& col) { fLineColor = col; }
89
90 int GetLineWidth() const { return fLineWidth.Get(); }
91 RDrawingAttr<int> &GetLineWidth() { return fLineWidth; }
92 void SetLineWidth(int width) { fLineWidth = width; }
93};
94
95/** \class RHistDrawingOpts<3>
96 Drawing options for a 3D histogram.
97 */
98template <>
99class RHistDrawingOpts<3>: public RDrawingOptsBase {
100public:
101 enum class EStyle { kBox, kIso };
102
103private:
104 static const RStringEnumAttrSet &Styles() {
105 static const RStringEnumAttrSet styles{"box", "iso"};
106 return styles;
107 }
108 RDrawingAttr<RStringEnumAttr<EStyle>> fStyle{*this, "Hist.3D.Style", EStyle::kBox, Styles()};
109 RDrawingAttr<RColor> fLineColor{*this, "Hist.3D.Line.Color"};
110 RDrawingAttr<int> fLineWidth{*this, "Hist.3D.Line.Width"};
111
112public:
113 EStyle GetStyle() const { return fStyle.Get().GetIndex(); }
114 RDrawingAttr<RStringEnumAttr<EStyle>> &GetStyle() { return fStyle; }
115 void SetStyle(EStyle style) { fStyle.Get().SetIndex(style); }
116
117 RColor GetLineColor() const { return fLineColor.Get(); }
118 RDrawingAttr<RColor> &GetLineColor() { return fLineColor; }
119 void SetLineColor(const RColor& col) { fLineColor = col; }
120
121 int GetLineWidth() const { return fLineWidth.Get(); }
122 RDrawingAttr<int> &GetLineWidth() { return fLineWidth; }
123 void SetLineWidth(int width) { fLineWidth = width; }
124};
125
126} // namespace Experimental
127} // namespace ROOT
128
129#endif
@ kBox
Definition: Buttons.h:29
@ kText
Definition: Buttons.h:30
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
static const RStringEnumAttrSet & Styles()
RDrawingAttr< RStringEnumAttr< EStyle > > & GetStyle()
RDrawingAttr< RStringEnumAttr< EStyle > > & GetStyle()
static const RStringEnumAttrSet & Styles()
RDrawingAttr< RStringEnumAttr< EStyle > > & GetStyle()
static const RStringEnumAttrSet & Styles()
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
TCanvas * style()
Definition: style.C:1