Logo ROOT  
Reference Guide
REveDataClasses.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 #ifndef ROOT7_REveDataClasses
14 #define ROOT7_REveDataClasses
15 
16 #include <ROOT/REveElement.hxx>
17 
18 #include <functional>
19 #include <vector>
20 #include <iostream>
21 
22 class TClass;
23 
24 namespace ROOT {
25 namespace Experimental {
26 
27 class REveDataItem;
28 
29 //==============================================================================
30 
32 {
33 public:
34  typedef std::vector<int> Ids_t;
35 
36 private:
39 
40 public:
42 
43  TClass *fItemClass{nullptr}; // so far only really need class name
44 
45  struct ItemInfo_t
46  {
47  void *fDataPtr{nullptr};
49 
50  ItemInfo_t() = default;
51  ItemInfo_t(void *dp, REveDataItem *di) : fDataPtr(dp), fItemPtr(di) {}
52  };
53 
54  std::vector<ItemInfo_t> fItems;
55 
57  std::function<bool(void *)> fFilterFoo = [](void *) { return true; };
58 
59  REveDataCollection(const std::string& n = "REveDataCollection", const std::string& t = "");
60  virtual ~REveDataCollection() {}
61 
62  Bool_t SingleRnrState() const override { return kTRUE; }
63  Bool_t SetRnrState(Bool_t) override;
64 
65  TClass *GetItemClass() const { return fItemClass; }
66  void SetItemClass(TClass *cls) { fItemClass = cls; }
67 
68  void ReserveItems(Int_t items_size) { fItems.reserve(items_size); }
69  void AddItem(void *data_ptr, const std::string& n, const std::string& t);
70  void ClearItems() { fItems.clear(); }
71 
72  void SetFilterExpr(const TString &filter);
73  void ApplyFilter();
74 
75  Int_t GetNItems() const { return (Int_t)fItems.size(); }
76  void *GetDataPtr(Int_t i) const { return fItems[i].fDataPtr; }
77  REveDataItem *GetDataItem(Int_t i) const { return fItems[i].fItemPtr; }
78 
79  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
80 
81  void SetMainColor(Color_t) override;
82  virtual void ItemChanged(REveDataItem *item);
83 
84  void SetHandlerFunc (std::function<void (REveDataCollection*)> handler_func)
85  {
86  _handler_func = handler_func;
87  }
88  void SetHandlerFuncIds (std::function<void (REveDataCollection*, const Ids_t&)> handler_func)
89  {
90  _handler_func_ids= handler_func;
91  }
92 };
93 
94 //==============================================================================
95 
96 class REveDataItem : public REveElement,
97  public REveAuntAsList
98 {
99 protected:
101 
102 public:
103  REveDataItem(const std::string& n = "REveDataItem", const std::string& t = "");
104  virtual ~REveDataItem() {}
105 
106  Bool_t GetFiltered() const { return fFiltered; }
107  void SetFiltered(Bool_t f);
108 
109  virtual void SetItemColorRGB(UChar_t r, UChar_t g, UChar_t b);
110  Bool_t SetRnrSelf(Bool_t) override;
111 
112  virtual void FillImpliedSelectedSet(Set_t& impSelSet) override;
113 
114  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
115 };
116 
117 //==============================================================================
118 
120 {
121 protected:
123 
124 public:
125  REveDataTable(const std::string& n = "REveDataTable", const std::string& t = "");
126  virtual ~REveDataTable() {}
127 
128  void SetCollection(const REveDataCollection *col) { fCollection = col; }
129  const REveDataCollection *GetCollection() const { return fCollection; }
130 
131  void PrintTable();
132  virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset);
133 
134  void AddNewColumn(const std::string& expr, const std::string& title, int prec = 2);
135 };
136 
137 //==============================================================================
138 
140 {
141 public:
143 
144 protected:
145 public:
147  FieldType_e fType; // can we auto detect this?
149 
150  std::string fTrue{"*"};
151  std::string fFalse{" "};
152 
155  std::function<std::string(void *)> fStringFoo;
156 
157 public:
158  REveDataColumn(const std::string& n = "REveDataColumn", const std::string& t = "");
159  virtual ~REveDataColumn() {}
160 
161  void SetExpressionAndType(const std::string &expr, FieldType_e type);
162  void SetPrecision(Int_t prec);
163 
164  std::string EvalExpr(void *iptr);
165 };
166 
167 
168 } // namespace Experimental
169 } // namespace ROOT
170 
171 #endif
ROOT::Experimental::REveDataItem::GetFiltered
Bool_t GetFiltered() const
Definition: REveDataClasses.hxx:106
n
const Int_t n
Definition: legend1.C:16
ROOT::Experimental::REveDataCollection
Definition: REveDataClasses.hxx:31
ROOT::Experimental::REveDataColumn::fDoubleFoo
std::function< double(void *)> fDoubleFoo
Definition: REveDataClasses.hxx:153
ROOT::Experimental::REveDataCollection::Ids_t
std::vector< int > Ids_t
Definition: REveDataClasses.hxx:34
ROOT::Experimental::REveDataCollection::GetDataItem
REveDataItem * GetDataItem(Int_t i) const
Definition: REveDataClasses.hxx:77
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
ROOT::Experimental::REveDataTable::GetCollection
const REveDataCollection * GetCollection() const
Definition: REveDataClasses.hxx:129
f
#define f(i)
Definition: RSha256.hxx:122
nlohmann::json
basic_json<> json
Definition: REveElement.hxx:58
ROOT::Experimental::REveDataCollection::GetItemClass
TClass * GetItemClass() const
Definition: REveDataClasses.hxx:65
ROOT::Experimental::REveDataCollection::GetDataPtr
void * GetDataPtr(Int_t i) const
Definition: REveDataClasses.hxx:76
ROOT::Experimental::REveDataCollection::ApplyFilter
void ApplyFilter()
Definition: REveDataClasses.cxx:84
ROOT::Experimental::REveDataCollection::ItemInfo_t
Definition: REveDataClasses.hxx:45
ROOT::Experimental::REveDataColumn::SetPrecision
void SetPrecision(Int_t prec)
Definition: REveDataClasses.cxx:393
r
ROOT::R::TRInterface & r
Definition: Object.C:4
ROOT::Experimental::REveDataCollection::_handler_func
std::function< void(REveDataCollection *)> _handler_func
Definition: REveDataClasses.hxx:37
ROOT::Experimental::REveDataColumn::fType
FieldType_e fType
Definition: REveDataClasses.hxx:147
ROOT::Experimental::REveDataColumn::fPrecision
Int_t fPrecision
Definition: REveDataClasses.hxx:148
ROOT::Experimental::REveDataItem::fFiltered
Bool_t fFiltered
Definition: REveDataClasses.hxx:100
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::Experimental::REveDataColumn
Definition: REveDataClasses.hxx:139
ROOT::Experimental::REveDataItem::SetRnrSelf
Bool_t SetRnrSelf(Bool_t) override
Set render state of this element, i.e.
Definition: REveDataClasses.cxx:255
ROOT::Experimental::REveDataCollection::ItemInfo_t::ItemInfo_t
ItemInfo_t(void *dp, REveDataItem *di)
Definition: REveDataClasses.hxx:51
TString
Definition: TString.h:136
ROOT::Experimental::REveElement
Definition: REveElement.hxx:79
ROOT::Experimental::REveDataCollection::fItemClass
TClass * fItemClass
Definition: REveDataClasses.hxx:43
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
ROOT::Experimental::REveDataTable::AddNewColumn
void AddNewColumn(const std::string &expr, const std::string &title, int prec=2)
Definition: REveDataClasses.cxx:339
Color_t
short Color_t
Definition: RtypesCore.h:83
b
#define b(i)
Definition: RSha256.hxx:118
ROOT::Experimental::REveDataColumn::FieldType_e
FieldType_e
Definition: REveDataClasses.hxx:142
bool
ROOT::Experimental::REveDataCollection::~REveDataCollection
virtual ~REveDataCollection()
Definition: REveDataClasses.hxx:60
ROOT::Experimental::REveDataCollection::REveDataCollection
REveDataCollection(const std::string &n="REveDataCollection", const std::string &t="")
Definition: REveDataClasses.cxx:37
ROOT::Experimental::REveDataTable::fCollection
const REveDataCollection * fCollection
Definition: REveDataClasses.hxx:122
ROOT::Experimental::REveDataCollection::fFilterFoo
std::function< bool(void *)> fFilterFoo
Definition: REveDataClasses.hxx:57
ROOT::Experimental::REveDataTable::SetCollection
void SetCollection(const REveDataCollection *col)
Definition: REveDataClasses.hxx:128
ROOT::Experimental::REveDataCollection::ItemInfo_t::fItemPtr
REveDataItem * fItemPtr
Definition: REveDataClasses.hxx:48
ROOT::Experimental::REveDataTable::REveDataTable
REveDataTable(const std::string &n="REveDataTable", const std::string &t="")
Definition: REveDataClasses.cxx:291
ROOT::Experimental::REveDataColumn::fExpression
TString fExpression
Definition: REveDataClasses.hxx:146
ROOT::Experimental::REveDataColumn::FT_String
@ FT_String
Definition: REveDataClasses.hxx:142
ROOT::Experimental::REveDataTable::PrintTable
void PrintTable()
Definition: REveDataClasses.cxx:297
ROOT::Experimental::REveDataCollection::fFilterExpr
TString fFilterExpr
Definition: REveDataClasses.hxx:56
REveElement.hxx
ROOT::Experimental::REveDataCollection::SetHandlerFunc
void SetHandlerFunc(std::function< void(REveDataCollection *)> handler_func)
Definition: REveDataClasses.hxx:84
ROOT::Experimental::REveDataItem::WriteCoreJson
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
Definition: REveDataClasses.cxx:240
ROOT::Experimental::REveDataCollection::SetMainColor
void SetMainColor(Color_t) override
Set main color of the element.
Definition: REveDataClasses.cxx:177
ROOT::R::function
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
ROOT::Experimental::REveDataCollection::SetFilterExpr
void SetFilterExpr(const TString &filter)
Definition: REveDataClasses.cxx:58
ROOT::Experimental::REveDataColumn::fFalse
std::string fFalse
Definition: REveDataClasses.hxx:151
ROOT::Experimental::REveDataCollection::SetRnrState
Bool_t SetRnrState(Bool_t) override
Set render state of this element and of its children to the same value.
Definition: REveDataClasses.cxx:195
double
double
Definition: Converters.cxx:921
ROOT::Experimental::REveDataColumn::fStringFoo
std::function< std::string(void *)> fStringFoo
Definition: REveDataClasses.hxx:155
ROOT::Experimental::REveDataCollection::_handler_func_ids
std::function< void(REveDataCollection *, const Ids_t &)> _handler_func_ids
Definition: REveDataClasses.hxx:38
ROOT::Experimental::REveDataItem::REveDataItem
REveDataItem(const std::string &n="REveDataItem", const std::string &t="")
Definition: REveDataClasses.cxx:234
ROOT::Experimental::REveDataCollection::SetItemClass
void SetItemClass(TClass *cls)
Definition: REveDataClasses.hxx:66
ROOT::Experimental::REveDataColumn::fBoolFoo
std::function< bool(void *)> fBoolFoo
Definition: REveDataClasses.hxx:154
ROOT::Experimental::REveElement::Set_t
std::set< REveElement * > Set_t
Definition: REveElement.hxx:89
ROOT::Experimental::REveDataTable::~REveDataTable
virtual ~REveDataTable()
Definition: REveDataClasses.hxx:126
ROOT::Experimental::REveDataItem::~REveDataItem
virtual ~REveDataItem()
Definition: REveDataClasses.hxx:104
void
typedef void((*Func_t)())
ROOT::Experimental::REveDataColumn::REveDataColumn
REveDataColumn(const std::string &n="REveDataColumn", const std::string &t="")
Definition: REveDataClasses.cxx:354
ROOT::Experimental::REveDataCollection::ItemInfo_t::ItemInfo_t
ItemInfo_t()=default
ROOT::Experimental::REveDataCollection::SingleRnrState
Bool_t SingleRnrState() const override
Definition: REveDataClasses.hxx:62
ROOT::Experimental::REveDataColumn::FT_Bool
@ FT_Bool
Definition: REveDataClasses.hxx:142
ROOT::Experimental::REveDataCollection::AddItem
void AddItem(void *data_ptr, const std::string &n, const std::string &t)
Definition: REveDataClasses.cxx:48
ROOT::Experimental::REveDataTable::WriteCoreJson
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
Definition: REveDataClasses.cxx:318
ROOT::Experimental::REveDataItem::SetFiltered
void SetFiltered(Bool_t f)
Definition: REveDataClasses.cxx:263
ROOT::Experimental::REveDataCollection::ItemChanged
virtual void ItemChanged(REveDataItem *item)
Definition: REveDataClasses.cxx:215
TClass
Definition: TClass.h:80
ROOT::Experimental::REveDataTable
Definition: REveDataClasses.hxx:119
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
ROOT::Experimental::REveDataCollection::GetNItems
Int_t GetNItems() const
Definition: REveDataClasses.hxx:75
ROOT::Experimental::REveDataItem::FillImpliedSelectedSet
virtual void FillImpliedSelectedSet(Set_t &impSelSet) override
Populate set impSelSet with derived / dependant elements.
Definition: REveDataClasses.cxx:272
ROOT::Experimental::REveDataCollection::SetHandlerFuncIds
void SetHandlerFuncIds(std::function< void(REveDataCollection *, const Ids_t &)> handler_func)
Definition: REveDataClasses.hxx:88
ROOT::Experimental::REveDataCollection::fItems
std::vector< ItemInfo_t > fItems
Definition: REveDataClasses.hxx:54
ROOT::Experimental::REveAuntAsList
Definition: REveElement.hxx:434
ROOT::Experimental::REveDataColumn::EvalExpr
std::string EvalExpr(void *iptr)
Definition: REveDataClasses.cxx:398
type
int type
Definition: TGX11.cxx:121
ROOT::Experimental::REveDataCollection::WriteCoreJson
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
Definition: REveDataClasses.cxx:104
ROOT::Experimental::REveDataColumn::SetExpressionAndType
void SetExpressionAndType(const std::string &expr, FieldType_e type)
Definition: REveDataClasses.cxx:359
ROOT::Experimental::REveDataCollection::ReserveItems
void ReserveItems(Int_t items_size)
Definition: REveDataClasses.hxx:68
ROOT::Experimental::REveDataColumn::fTrue
std::string fTrue
Definition: REveDataClasses.hxx:150
ROOT::Experimental::REveDataColumn::~REveDataColumn
virtual ~REveDataColumn()
Definition: REveDataClasses.hxx:159
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveDataCollection::ClearItems
void ClearItems()
Definition: REveDataClasses.hxx:70
ROOT::Experimental::REveDataItem
Definition: REveDataClasses.hxx:96
ROOT::Experimental::REveDataCollection::ItemInfo_t::fDataPtr
void * fDataPtr
Definition: REveDataClasses.hxx:47
ROOT::Experimental::REveDataColumn::FT_Double
@ FT_Double
Definition: REveDataClasses.hxx:142
ROOT::Experimental::REveDataItem::SetItemColorRGB
virtual void SetItemColorRGB(UChar_t r, UChar_t g, UChar_t b)
Definition: REveDataClasses.cxx:247
ROOT::Experimental::REveDataCollection::fgDefaultColor
static Color_t fgDefaultColor
Definition: REveDataClasses.hxx:41
int
g
#define g(i)
Definition: RSha256.hxx:123