Logo ROOT  
Reference Guide
REveDataCollection.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_REveDataCollection
14 #define ROOT7_REveDataCollection
15 
16 #include <ROOT/REveElement.hxx>
17 #include <ROOT/REveCompound.hxx>
19 #include <ROOT/REveDataTable.hxx>
20 
21 #include <functional>
22 #include <vector>
23 #include <iostream>
24 
25 class TClass;
26 
27 namespace ROOT {
28 namespace Experimental {
29 
30 //==============================================================================
32 {
33 private:
34  void* fDataPtr{nullptr};
35 
38  Bool_t fFiltered{false};
39 
40 public:
42 
43  Bool_t GetRnrSelf() const { return fRnrSelf; }
44  Color_t GetMainColor() const { return fColor; }
45  Bool_t GetFiltered() const { return fFiltered; }
46  Bool_t GetVisible() const { return (!fFiltered) && fRnrSelf; }
47 
48  void* GetDataPtr() { return fDataPtr; }
49 
50  void SetFiltered(Bool_t i) { fFiltered = i; }
51  void SetMainColor(Color_t i) { fColor = i; }
52  void SetRnrSelf(Bool_t i) { fRnrSelf = i; }
53 };
54 
55 //==============================================================================
58 {
59  friend class REveDataCollection;
60 
61 public:
62  struct TTip {
63  std::string fTooltipTitle;
65  };
66 
67 private:
68  std::vector<REveDataItem*> fItems;
71 
72  std::vector<TTip> fTooltipExpressions;
73 
74 public:
75  REveDataItemList(const std::string& n = "Items", const std::string& t = "");
76  virtual ~REveDataItemList() {}
77  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
78 
79  virtual void ItemChanged(REveDataItem *item);
80  virtual void ItemChanged(Int_t idx);
81  void FillImpliedSelectedSet(Set_t &impSelSet) override;
82 
83  void SetItemVisible(Int_t idx, Bool_t visible);
85 
86  void SetItemsChangeDelegate (std::function<void (REveDataItemList*, const std::vector<int>&)> handler_func)
87  {
88  _handler_items_change = handler_func;
89  }
90  void SetFillImpliedSelectedDelegate (std::function<void (REveDataItemList*, Set_t& impSelSet)> handler_func)
91  {
92  _handler_fillimp = handler_func;
93  }
94 
95  Bool_t SingleRnrState() const override { return kTRUE; }
96  Bool_t SetRnrState(Bool_t) override;
97 
98  void ProcessSelection(ElementId_t id, bool multi, bool secondary, const std::set<int>& in_secondary_idcs);
99 
100  void AddTooltipExpression(const std::string &title, const std::string &expr);
101 
103  std::string GetHighlightTooltip(const std::set<int>& secondary_idcs) const override;
104 };
105 
106 //==============================================================================
107 
109 {
110 private:
112 
113 public:
114  typedef std::vector<int> Ids_t;
116 
117  TClass *fItemClass{nullptr}; // so far only really need class name
118 
120  std::function<bool(void *)> fFilterFoo = [](void *) { return true; };
121 
122  REveDataCollection(const std::string& n = "REveDataCollection", const std::string& t = "");
123  virtual ~REveDataCollection() {}
124 
125  void ReserveItems(Int_t items_size) { fItemList->fItems.reserve(items_size); }
126  void AddItem(void *data_ptr, const std::string& n, const std::string& t);
127  void ClearItems() { fItemList->fItems.clear(); }
128 
129  Bool_t SingleRnrState() const override { return kTRUE; }
130  Bool_t SetRnrState(Bool_t) override;
131 
132 
133  TClass *GetItemClass() const { return fItemClass; }
134  void SetItemClass(TClass *cls) { fItemClass = cls;
135  }
137 
138  void SetFilterExpr(const TString &filter);
139  void ApplyFilter();
140 
141  Int_t GetNItems() const { return (Int_t) fItemList->fItems.size(); }
142  void *GetDataPtr(Int_t i) const { return fItemList->fItems[i]->GetDataPtr(); }
143  const REveDataItem* GetDataItem(Int_t i) const { return fItemList->fItems[i]; }
144 
145  void StreamPublicMethods(nlohmann::json &cj) const;
146  Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
147 
148  void SetMainColor(Color_t) override;
149 
150 };
151 
152 } // namespace Experimental
153 } // namespace ROOT
154 
155 #endif
ROOT::Experimental::REveDataItemList::TTip::fTooltipFunction
REveDataColumn fTooltipFunction
Definition: REveDataCollection.hxx:64
c
#define c(i)
Definition: RSha256.hxx:101
ROOT::Experimental::REveDataItem::GetDataPtr
void * GetDataPtr()
Definition: REveDataCollection.hxx:48
ROOT::Experimental::REveDataItem::GetFiltered
Bool_t GetFiltered() const
Definition: REveDataCollection.hxx:45
n
const Int_t n
Definition: legend1.C:16
ROOT::Experimental::REveDataCollection
Definition: REveDataCollection.hxx:109
ROOT::Experimental::REveDataCollection::Ids_t
std::vector< int > Ids_t
Definition: REveDataCollection.hxx:114
ROOT::Experimental::REveDataItem::GetVisible
Bool_t GetVisible() const
Definition: REveDataCollection.hxx:46
ROOT::Experimental::REveDataItemList
Definition: REveDataCollection.hxx:58
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
ROOT::Experimental::REveDataItemList::AddTooltipExpression
void AddTooltipExpression(const std::string &title, const std::string &expr)
Definition: REveDataCollection.cxx:176
REveDataTable.hxx
ROOT::Experimental::REveDataItemList::ItemChanged
virtual void ItemChanged(REveDataItem *item)
Definition: REveDataCollection.cxx:64
ROOT::Experimental::REveSecondarySelectable
Definition: REveSecondarySelectable.hxx:25
ROOT::Experimental::REveDataCollection::GetItemClass
TClass * GetItemClass() const
Definition: REveDataCollection.hxx:133
ROOT::Experimental::REveDataCollection::GetDataItem
const REveDataItem * GetDataItem(Int_t i) const
Definition: REveDataCollection.hxx:143
ROOT::Experimental::REveElement::GetHighlightTooltip
virtual std::string GetHighlightTooltip(const std::set< int > &) const
Definition: REveElement.cxx:139
ROOT::Experimental::REveDataCollection::GetDataPtr
void * GetDataPtr(Int_t i) const
Definition: REveDataCollection.hxx:142
ROOT::Experimental::REveDataItem::SetMainColor
void SetMainColor(Color_t i)
Definition: REveDataCollection.hxx:51
ROOT::Experimental::ElementId_t
unsigned int ElementId_t
Definition: REveTypes.hxx:25
ROOT::Experimental::REveDataCollection::ApplyFilter
void ApplyFilter()
Definition: REveDataCollection.cxx:235
r
ROOT::R::TRInterface & r
Definition: Object.C:4
ROOT::Experimental::REveDataItemList::TTip::fTooltipTitle
std::string fTooltipTitle
Definition: REveDataCollection.hxx:63
REveSecondarySelectable.hxx
ROOT::Experimental::REveDataItem::fFiltered
Bool_t fFiltered
Definition: REveDataCollection.hxx:38
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::Experimental::REveDataItem::fColor
Color_t fColor
Definition: REveDataCollection.hxx:37
ROOT::Experimental::REveDataItemList::TTip
Definition: REveDataCollection.hxx:62
ROOT::Experimental::REveDataColumn
Definition: REveDataTable.hxx:44
ROOT::Experimental::REveDataItem::REveDataItem
REveDataItem(void *d, Color_t c)
Definition: REveDataCollection.hxx:41
ROOT::Experimental::REveDataItemList::SingleRnrState
Bool_t SingleRnrState() const override
Definition: REveDataCollection.hxx:95
ROOT::Experimental::REveDataCollection::StreamPublicMethods
void StreamPublicMethods(nlohmann::json &cj) const
Definition: REveDataCollection.cxx:256
TString
Basic string class.
Definition: TString.h:136
ROOT::Experimental::REveDataItemList::SetItemVisible
void SetItemVisible(Int_t idx, Bool_t visible)
Definition: REveDataCollection.cxx:46
ROOT::Experimental::REveElement
Definition: REveElement.hxx:41
ROOT::Experimental::REveDataCollection::fItemClass
TClass * fItemClass
Definition: REveDataCollection.hxx:117
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
Color_t
short Color_t
Definition: RtypesCore.h:83
b
#define b(i)
Definition: RSha256.hxx:100
bool
ROOT::Experimental::REveDataCollection::~REveDataCollection
virtual ~REveDataCollection()
Definition: REveDataCollection.hxx:123
ROOT::Experimental::REveDataCollection::REveDataCollection
REveDataCollection(const std::string &n="REveDataCollection", const std::string &t="")
Definition: REveDataCollection.cxx:192
ROOT::Experimental::REveDataCollection::fFilterFoo
std::function< bool(void *)> fFilterFoo
Definition: REveDataCollection.hxx:120
ROOT::Experimental::REveDataItemList::~REveDataItemList
virtual ~REveDataItemList()
Definition: REveDataCollection.hxx:76
ROOT::Experimental::REveDataItemList::GetHighlightTooltip
virtual std::string GetHighlightTooltip(const std::set< int > &) const
Definition: REveElement.cxx:139
ROOT::Experimental::REveDataItemList::_handler_items_change
std::function< void(REveDataItemList *, const std::vector< int > &)> _handler_items_change
Definition: REveDataCollection.hxx:69
ROOT::Experimental::REveDataCollection::fFilterExpr
TString fFilterExpr
Definition: REveDataCollection.hxx:119
REveElement.hxx
ROOT::Experimental::REveDataItem::fDataPtr
void * fDataPtr
Definition: REveDataCollection.hxx:34
ROOT::Experimental::REveDataItemList::fItems
std::vector< REveDataItem * > fItems
Definition: REveDataCollection.hxx:68
ROOT::Experimental::REveDataItem::SetRnrSelf
void SetRnrSelf(Bool_t i)
Definition: REveDataCollection.hxx:52
ROOT::Experimental::REveDataItem::GetRnrSelf
Bool_t GetRnrSelf() const
Definition: REveDataCollection.hxx:43
ROOT::Experimental::REveDataCollection::SetMainColor
void SetMainColor(Color_t) override
Set main color of the element.
Definition: REveDataCollection.cxx:324
ROOT::Experimental::REveDataItemList::fTooltipExpressions
std::vector< TTip > fTooltipExpressions
Definition: REveDataCollection.hxx:72
ROOT::R::function
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
REveCompound.hxx
ROOT::Experimental::REveDataItemList::SetFillImpliedSelectedDelegate
void SetFillImpliedSelectedDelegate(std::function< void(REveDataItemList *, Set_t &impSelSet)> handler_func)
Definition: REveDataCollection.hxx:90
ROOT::Experimental::REveDataCollection::SetFilterExpr
void SetFilterExpr(const TString &filter)
Definition: REveDataCollection.cxx:210
ROOT::Experimental::REveDataItemList::WriteCoreJson
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
Definition: REveDataCollection.cxx:103
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: REveDataCollection.cxx:347
ROOT::Experimental::REveDataCollection::SetItemClass
void SetItemClass(TClass *cls)
Definition: REveDataCollection.hxx:134
ROOT::Experimental::REveElement::Set_t
std::set< REveElement * > Set_t
Definition: REveElement.hxx:50
void
typedef void((*Func_t)())
ROOT::Experimental::REveDataItemList::SetItemColorRGB
void SetItemColorRGB(Int_t idx, UChar_t r, UChar_t g, UChar_t b)
Definition: REveDataCollection.cxx:55
ROOT::Experimental::REveDataCollection::SingleRnrState
Bool_t SingleRnrState() const override
Definition: REveDataCollection.hxx:129
ROOT::Experimental::REveDataCollection::AddItem
void AddItem(void *data_ptr, const std::string &n, const std::string &t)
Definition: REveDataCollection.cxx:202
ROOT::Experimental::REveDataItemList::_handler_fillimp
std::function< void(REveDataItemList *, Set_t &impSel)> _handler_fillimp
Definition: REveDataCollection.hxx:70
ROOT::Experimental::REveDataCollection::GetItemList
REveDataItemList * GetItemList()
Definition: REveDataCollection.hxx:136
ROOT::Experimental::REveDataItem::SetFiltered
void SetFiltered(Bool_t i)
Definition: REveDataCollection.hxx:50
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
ROOT::Experimental::REveDataCollection::GetNItems
Int_t GetNItems() const
Definition: REveDataCollection.hxx:141
ROOT::Experimental::REveDataItemList::SetRnrState
Bool_t SetRnrState(Bool_t) override
Set render state of this element and of its children to the same value.
Definition: REveDataCollection.cxx:121
ROOT::Experimental::REveDataCollection::fItemList
REveDataItemList * fItemList
Definition: REveDataCollection.hxx:111
d
#define d(i)
Definition: RSha256.hxx:102
ROOT::Experimental::REveDataItemList::SetItemsChangeDelegate
void SetItemsChangeDelegate(std::function< void(REveDataItemList *, const std::vector< int > &)> handler_func)
Definition: REveDataCollection.hxx:86
ROOT::Experimental::REveDataItem::GetMainColor
Color_t GetMainColor() const
Definition: REveDataCollection.hxx:44
ROOT::Experimental::REveDataCollection::WriteCoreJson
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
Definition: REveDataCollection.cxx:365
ROOT::Experimental::REveDataCollection::ReserveItems
void ReserveItems(Int_t items_size)
Definition: REveDataCollection.hxx:125
ROOT::Experimental::REveDataItemList::REveDataItemList
REveDataItemList(const std::string &n="Items", const std::string &t="")
Definition: REveDataCollection.cxx:35
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveDataCollection::ClearItems
void ClearItems()
Definition: REveDataCollection.hxx:127
ROOT::Experimental::REveDataItem
Definition: REveDataCollection.hxx:32
ROOT::Experimental::REveDataItem::fRnrSelf
Bool_t fRnrSelf
Definition: REveDataCollection.hxx:36
ROOT::Experimental::REveDataItemList::ProcessSelection
void ProcessSelection(ElementId_t id, bool multi, bool secondary, const std::set< int > &in_secondary_idcs)
Definition: REveDataCollection.cxx:139
ROOT::Experimental::REveDataItemList::FillImpliedSelectedSet
void FillImpliedSelectedSet(Set_t &impSelSet) override
Populate set impSelSet with derived / dependant elements.
Definition: REveDataCollection.cxx:90
ROOT::Experimental::REveDataCollection::fgDefaultColor
static Color_t fgDefaultColor
Definition: REveDataCollection.hxx:115
int
g
#define g(i)
Definition: RSha256.hxx:105