Logo ROOT  
Reference Guide
RHistStatBox.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RHistStatBox
10#define ROOT7_RHistStatBox
11
12#include <ROOT/RDrawable.hxx>
14#include <ROOT/RAttrText.hxx>
15#include <ROOT/RAttrLine.hxx>
16#include <ROOT/RAttrFill.hxx>
17#include <ROOT/RPadPos.hxx>
18#include "ROOT/RPadBase.hxx"
19#include <ROOT/RDisplayItem.hxx>
20#include <ROOT/RHist.hxx>
21#include <ROOT/RHistImpl.hxx>
22#include "ROOT/RFrame.hxx"
23
24#include <memory>
25#include <string>
26#include <vector>
27
28namespace ROOT {
29namespace Experimental {
30
31/** \class ROOT::Experimental::RHistStatReply
32\ingroup GrafROOT7
33\brief Reply of stat box on RHistStatRequest, contains text lines to display
34\author Sergey Linev <s.linev@gsi.de>
35\date 2020-04-17
36\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
37*/
38
39/** \class ROOT::Experimental::RDisplayHistStat
40\ingroup GrafROOT7
41\brief Object send to client for display of RHistStat, required to avoid sending histogram to the client
42\author Sergey Linev <s.linev@gsi.de>
43\date 2020-04-17
44\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
45*/
46
48 unsigned fShowMask{0}; ///< initial show mask
49 std::vector<std::string> fEntries; ///< names of entries for context menu
50 std::vector<std::string> fLines; ///< filled lines to show in stat box
51public:
52 RDisplayHistStat() = default;
53 RDisplayHistStat(const RDrawable &dr, unsigned mask, const std::vector<std::string> &entries, const std::vector<std::string> &lines) :
54 RIndirectDisplayItem(dr), fShowMask(mask), fEntries(entries), fLines(lines) {}
55 virtual ~RDisplayHistStat() = default;
56
57 unsigned GetShowMask() const { return fShowMask; }
58 const std::vector<std::string> &GetEntries() const { return fEntries; }
59};
60
61
62/** \class ROOT::Experimental::RHistStatBoxBase
63\ingroup GrafROOT7
64\brief Base class for histogram statistic box, provides graphics attributes and virtual method for fill statistic
65\author Sergey Linev <s.linev@gsi.de>
66\date 2020-04-01
67\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
68*/
69
71
73 friend class RHistStatBoxBase;
74 R__ATTR_CLASS(RHistStatBoxAttrs, "", AddPadLength("cornerx",0.02).AddPadLength("cornery",0.02).AddPadLength("width",0.5).AddPadLength("height",0.2));
75 };
76
77 std::string fTitle; ///< stat box title
78 unsigned fShowMask{0xff}; ///< show stat box lines
79
80 RAttrText fAttrText{this, "text_"}; ///<! text attributes
81 RAttrLine fAttrBorder{this, "border_"}; ///<! border attributes
82 RAttrFill fAttrFill{this, "fill_"}; ///<! line attributes
83 RHistStatBoxAttrs fAttr{this, ""}; ///<! stat box direct attributes
84
85protected:
86
87 enum EShowBits { kShowTitle = 0x1, kShowEntries = 0x2, kShowMean = 0x4, kShowDev = 0x8, kShowRange = 0x10 };
88
89 bool IsFrameRequired() const final { return true; }
90
91 virtual void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const {}
92
93 virtual const std::vector<std::string> &GetEntriesNames() const;
94
95 std::unique_ptr<RDisplayItem> Display(const RDisplayContext &) override;
96
97public:
98
99 class RReply : public RDrawableReply {
100 unsigned mask{0}; ///< mask used to create lines
101 std::vector<std::string> lines; ///< text lines displayed in the stat box
102 public:
103 std::vector<std::string> &GetLines() { return lines; }
104 void SetMask(unsigned _mask) { mask = _mask; }
105 // virtual destructor - required to pin vtable
106 virtual ~RReply() = default;
107 };
108
109
110 class RRequest : public RDrawableRequest {
111 unsigned mask{0xff}; // mask of items to show
112 public:
113 RRequest() = default;
114 unsigned GetMask() const { return mask; }
115 std::unique_ptr<RDrawableReply> Process() override
116 {
117 auto stat = dynamic_cast<RHistStatBoxBase *>(GetContext().GetDrawable());
118
119 auto frame = GetContext().GetPad()->GetFrame();
120 RFrame::RUserRanges ranges;
121 if (frame) frame->GetClientRanges(GetContext().GetConnId(), ranges);
122
123 auto reply = std::make_unique<RReply>();
124
125 if (stat) {
126 stat->fShowMask = GetMask();
127
128 reply->SetMask(GetMask());
129
131 reply->GetLines().emplace_back(stat->GetTitle());
132
133 stat->FillStatistic(GetMask(), ranges, reply->GetLines());
134 }
135 return reply;
136 }
137 };
138
140
141 void SetTitle(const std::string &title) { fTitle = title; }
142 const std::string &GetTitle() const { return fTitle; }
143
145 {
146 fAttr.SetValue("cornerx", pos);
147 return *this;
148 }
149
151 {
152 return fAttr.template GetValue<RPadLength>("cornerx");
153 }
154
156 {
157 fAttr.SetValue("cornery", pos);
158 return *this;
159 }
160
162 {
163 return fAttr.template GetValue<RPadLength>("cornery");
164 }
165
167 {
168 fAttr.SetValue("width", width);
169 return *this;
170 }
171
173 {
174 return fAttr.template GetValue<RPadLength>("width");
175 }
176
178 {
179 fAttr.SetValue("height", height);
180 return *this;
181 }
182
184 {
185 return fAttr.template GetValue<RPadLength>("height");
186 }
187
188 const RAttrText &GetAttrText() const { return fAttrText; }
189 RHistStatBoxBase &SetAttrText(const RAttrText &attr) { fAttrText = attr; return *this; }
191
192 const RAttrLine &GetAttrBorder() const { return fAttrBorder; }
193 RHistStatBoxBase &SetAttrBorder(const RAttrLine &border) { fAttrBorder = border; return *this; }
195
196 const RAttrFill &GetAttrFill() const { return fAttrFill; }
199};
200
201
202
203/** \class ROOT::Experimental::RHistStatBox
204\ingroup GrafROOT7
205\brief Template class for statistic box for RHist class
206\author Sergey Linev <s.linev@gsi.de>
207\date 2020-04-01
208\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
209*/
210
211
212template <int DIMENSIONS>
214public:
216
217private:
218 Internal::RIOShared<HistImpl_t> fHistImpl; ///< I/O capable reference on histogram
219
220protected:
221
222 void CollectShared(Internal::RIOSharedVector_t &vect) override { vect.emplace_back(&fHistImpl); }
223
224public:
225
226 template <class HIST>
227 RHistStatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "")
228 {
229 fHistImpl = std::shared_ptr<HistImpl_t>(hist, hist->GetImpl());
230 SetTitle(title);
231 }
232
233 std::shared_ptr<HistImpl_t> GetHist() const { return fHistImpl.get_shared(); }
234};
235
236
237class RHist1StatBox final : public RHistStatBox<1> {
238protected:
239 void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const override;
240public:
241 template <class HIST>
242 RHist1StatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "") : RHistStatBox<1>(hist, title) {}
243};
244
245class RHist2StatBox final : public RHistStatBox<2> {
246protected:
247 void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const override;
248public:
249 template <class HIST>
250 RHist2StatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "") : RHistStatBox<2>(hist, title) {}
251};
252
253class RHist3StatBox final : public RHistStatBox<3> {
254protected:
255 void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const override;
256public:
257 template <class HIST>
258 RHist3StatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "") : RHistStatBox<3>(hist, title) {}
259};
260
261} // namespace Experimental
262} // namespace ROOT
263
264#endif
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
Base class for RHistImplBase that abstracts out the histogram's PRECISION.
Definition: RHistImpl.hxx:71
Base class for all attributes, used with RDrawable.
Definition: RAttrBase.hxx:27
void SetValue(const std::string &name, bool value)
Set boolean value.
Definition: RAttrBase.cxx:133
Drawing fill attributes for different objects.
Definition: RAttrFill.hxx:26
Drawing line attributes for different objects.
Definition: RAttrLine.hxx:26
A text.attributes.
Definition: RAttrText.hxx:29
Object send to client for display of RHistStat, required to avoid sending histogram to the client.
unsigned fShowMask
initial show mask
std::vector< std::string > fLines
filled lines to show in stat box
std::vector< std::string > fEntries
names of entries for context menu
RDisplayHistStat(const RDrawable &dr, unsigned mask, const std::vector< std::string > &entries, const std::vector< std::string > &lines)
const std::vector< std::string > & GetEntries() const
Base class for replies on RDrawableRequest.
Base class for requests which can be submitted from the clients.
const RDrawable::RDisplayContext & GetContext() const
Base class for drawable entities: objects that can be painted on a RPad.
Definition: RDrawable.hxx:102
RHist1StatBox(const std::shared_ptr< HIST > &hist, const std::string &title="")
void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const override
RHist2StatBox(const std::shared_ptr< HIST > &hist, const std::string &title="")
void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const override
RHist3StatBox(const std::shared_ptr< HIST > &hist, const std::string &title="")
void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const override
R__ATTR_CLASS(RHistStatBoxAttrs, "", AddPadLength("cornerx", 0.02).AddPadLength("cornery", 0.02).AddPadLength("width", 0.5).AddPadLength("height", 0.2))
std::vector< std::string > lines
text lines displayed in the stat box
unsigned mask
mask used to create lines
std::vector< std::string > & GetLines()
std::unique_ptr< RDrawableReply > Process() override
Base class for histogram statistic box, provides graphics attributes and virtual method for fill stat...
RHistStatBoxBase & SetCornerX(const RPadLength &pos)
const RAttrFill & GetAttrFill() const
RHistStatBoxBase & SetWidth(const RPadLength &width)
RHistStatBoxAttrs fAttr
! stat box direct attributes
const RAttrText & GetAttrText() const
void SetTitle(const std::string &title)
RHistStatBoxBase & SetAttrFill(const RAttrFill &fill)
RAttrText fAttrText
! text attributes
const RAttrLine & GetAttrBorder() const
virtual const std::vector< std::string > & GetEntriesNames() const
virtual void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const
RHistStatBoxBase & SetAttrBorder(const RAttrLine &border)
RAttrFill fAttrFill
! line attributes
RHistStatBoxBase & SetHeight(const RPadLength &height)
std::string fTitle
stat box title
RAttrLine fAttrBorder
! border attributes
RHistStatBoxBase & SetCornerY(const RPadLength &pos)
RHistStatBoxBase & SetAttrText(const RAttrText &attr)
std::unique_ptr< RDisplayItem > Display(const RDisplayContext &) override
Creates display item for drawable By default item contains drawable data itself.
unsigned fShowMask
show stat box lines
const std::string & GetTitle() const
Template class for statistic box for RHist class.
RHistStatBox(const std::shared_ptr< HIST > &hist, const std::string &title="")
void CollectShared(Internal::RIOSharedVector_t &vect) override
Internal::RIOShared< HistImpl_t > fHistImpl
I/O capable reference on histogram.
std::shared_ptr< HistImpl_t > GetHist() const
std::shared_ptr< RFrame > GetFrame()
Get a frame object if exists.
Definition: RPadBase.cxx:229
std::vector< RIOSharedBase * > RIOSharedVector_t
Definition: RDrawable.hxx:51
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
fill
Definition: fit1_py.py:6