Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/RPave.hxx>
14#include <ROOT/RPadBase.hxx>
15#include <ROOT/RDisplayItem.hxx>
16#include <ROOT/RHist.hxx>
17#include <ROOT/RHistImpl.hxx>
18#include <ROOT/RFrame.hxx>
19
20#include <memory>
21#include <string>
22#include <vector>
23
24namespace ROOT {
25namespace Experimental {
26
27/** \class ROOT::Experimental::RDisplayHistStat
28\ingroup GrafROOT7
29\brief Object send to client for display of RHistStat, required to avoid sending histogram to the client
30\author Sergey Linev <s.linev@gsi.de>
31\date 2020-04-17
32\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
33*/
34
36 unsigned fShowMask{0}; ///< initial show mask
37 std::vector<std::string> fEntries; ///< names of entries for context menu
38 std::vector<std::string> fLines; ///< filled lines to show in stat box
39public:
40 RDisplayHistStat() = default;
41 RDisplayHistStat(const RDrawable &dr, unsigned mask, const std::vector<std::string> &entries, const std::vector<std::string> &lines) :
42 RIndirectDisplayItem(dr), fShowMask(mask), fEntries(entries), fLines(lines) {}
43 ~RDisplayHistStat() override = default;
44
45 unsigned GetShowMask() const { return fShowMask; }
46 const std::vector<std::string> &GetEntries() const { return fEntries; }
47};
48
49
50/** \class ROOT::Experimental::RHistStatBoxBase
51\ingroup GrafROOT7
52\brief Base class for histogram statistic box, provides graphics attributes and virtual method for fill statistic
53\author Sergey Linev <s.linev@gsi.de>
54\date 2020-04-01
55\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
56*/
57
58class RHistStatBoxBase : public RPave {
59
60 std::string fTitle; ///< stat box title
61 unsigned fShowMask{0xff}; ///< show stat box lines
62
63protected:
64
65 enum EShowBits { kShowTitle = 0x1, kShowEntries = 0x2, kShowMean = 0x4, kShowDev = 0x8, kShowRange = 0x10 };
66
67 virtual void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const {}
68
69 virtual const std::vector<std::string> &GetEntriesNames() const;
70
71 std::unique_ptr<RDisplayItem> Display(const RDisplayContext &) override;
72
73public:
74
75 class RReply : public RDrawableReply {
76 unsigned mask{0}; ///< mask used to create lines
77 std::vector<std::string> lines; ///< text lines displayed in the stat box
78 public:
79 std::vector<std::string> &GetLines() { return lines; }
80 void SetMask(unsigned _mask) { mask = _mask; }
81 // virtual destructor - required to pin vtable
82 ~RReply() override = default;
83 };
84
85 class RRequest : public RDrawableRequest {
86 unsigned mask{0xff}; // mask of items to show
87 public:
88 RRequest() = default;
89 unsigned GetMask() const { return mask; }
90 std::unique_ptr<RDrawableReply> Process() override
91 {
92 auto stat = dynamic_cast<RHistStatBoxBase *>(GetContext().GetDrawable());
93
94 auto frame = GetContext().GetPad()->GetFrame();
96 if (frame) frame->GetClientRanges(GetContext().GetConnId(), ranges);
97
98 auto reply = std::make_unique<RReply>();
99
100 if (stat) {
101 stat->fShowMask = GetMask();
102
103 reply->SetMask(GetMask());
104
106 reply->GetLines().emplace_back(stat->GetTitle());
107
108 stat->FillStatistic(GetMask(), ranges, reply->GetLines());
109 }
110 return reply;
111 }
112 };
113
114 RHistStatBoxBase() : RPave("stats") {}
115
116 void SetTitle(const std::string &title) { fTitle = title; }
117 const std::string &GetTitle() const { return fTitle; }
118};
119
120
121
122/** \class ROOT::Experimental::RHistStatBox
123\ingroup GrafROOT7
124\brief Template class for statistic box for RHist class
125\author Sergey Linev <s.linev@gsi.de>
126\date 2020-04-01
127\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
128*/
129
130
131template <int DIMENSIONS>
133public:
135
136private:
137 Internal::RIOShared<HistImpl_t> fHistImpl; ///< I/O capable reference on histogram
138
139protected:
140
141 void CollectShared(Internal::RIOSharedVector_t &vect) override { vect.emplace_back(&fHistImpl); }
142
143public:
144
145 template <class HIST>
146 RHistStatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "")
147 {
148 fHistImpl = std::shared_ptr<HistImpl_t>(hist, hist->GetImpl());
149 SetTitle(title);
150 }
151
152 std::shared_ptr<HistImpl_t> GetHist() const { return fHistImpl.get_shared(); }
153};
154
155
156class RHist1StatBox final : public RHistStatBox<1> {
157protected:
158 void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const override;
159public:
160 template <class HIST>
161 RHist1StatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "") : RHistStatBox<1>(hist, title) {}
162};
163
164class RHist2StatBox final : public RHistStatBox<2> {
165protected:
166 void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const override;
167public:
168 template <class HIST>
169 RHist2StatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "") : RHistStatBox<2>(hist, title) {}
170};
171
172class RHist3StatBox final : public RHistStatBox<3> {
173protected:
174 void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector<std::string> &) const override;
175public:
176 template <class HIST>
177 RHist3StatBox(const std::shared_ptr<HIST> &hist, const std::string &title = "") : RHistStatBox<3>(hist, title) {}
178};
179
180} // namespace Experimental
181} // namespace ROOT
182
183#endif
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Base class for RHistImplBase that abstracts out the histogram's PRECISION.
Definition RHistImpl.hxx:72
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.
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
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...
void SetTitle(const std::string &title)
virtual const std::vector< std::string > & GetEntriesNames() const
virtual void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const
std::string fTitle
stat box title
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
Extract (reference) only basic attributes from drawable, but not drawable itself.
std::shared_ptr< RFrame > GetFrame()
Get a frame object if exists.
Definition RPadBase.cxx:214
Base class for paves with text, statistic, legends, placed relative to RFrame position and adjustable...
Definition RPave.hxx:32
std::vector< RIOSharedBase * > RIOSharedVector_t
Definition RDrawable.hxx:52
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.