Logo ROOT  
Reference Guide
REveDataCollection.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel and Alja Mrak Tadel: 2006, 2007, 2018
3//
4// Based of initial implementation of generic collection access interface
5// for CMS framework and Fireworks event display by Christopher D. Jones.
6
7/*************************************************************************
8 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15
16#ifndef ROOT7_REveDataCollection
17#define ROOT7_REveDataCollection
18
19#include <ROOT/REveElement.hxx>
20#include <ROOT/REveCompound.hxx>
23
24#include <functional>
25#include <vector>
26#include <iostream>
27
28class TClass;
29
30namespace ROOT {
31namespace Experimental {
32
33//==============================================================================
35{
36private:
37 void* fDataPtr{nullptr};
38
42
43public:
44
46
47 Bool_t GetRnrSelf() const { return fRnrSelf; }
48 Color_t GetMainColor() const { return fColor; }
49 Bool_t GetFiltered() const { return fFiltered; }
50 Bool_t GetVisible() const { return (!fFiltered) && fRnrSelf; }
51
52 void* GetDataPtr() { return fDataPtr; }
53
54 void SetFiltered(Bool_t i) { fFiltered = i; }
55 void SetMainColor(Color_t i) { fColor = i; }
56 void SetRnrSelf(Bool_t i) { fRnrSelf = i; }
57};
58
59//==============================================================================
62{
63 friend class REveDataCollection;
64
65public:
66 typedef std::function<void (REveDataItemList*, const std::vector<int>&)> ItemsChangeFunc_t;
68
69 struct TTip {
70 std::string fTooltipTitle;
72 };
73
74private:
75 std::vector<REveDataItem*> fItems;
78
79 std::vector< std::unique_ptr<TTip> > fTooltipExpressions;
80
81public:
82 REveDataItemList(const std::string& n = "Items", const std::string& t = "");
83 virtual ~REveDataItemList() {}
84 Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
85
86 virtual void ItemChanged(REveDataItem *item);
87 virtual void ItemChanged(Int_t idx);
88 void FillImpliedSelectedSet(Set_t &impSelSet, const std::set<int>& sec_idcs) override;
89
90 void SetItemVisible(Int_t idx, Bool_t visible);
92
93 Bool_t SingleRnrState() const override { return kTRUE; }
94 Bool_t SetRnrState(Bool_t) override;
95
96 void ProcessSelectionStr(ElementId_t id, bool multi, bool secondary, const char* in_secondary_idcs);
97 void ProcessSelection(ElementId_t id, bool multi, bool secondary, const std::set<int>& in_secondary_idcs);
98
99 void AddTooltipExpression(const std::string &title, const std::string &expr, bool init = true);
100
102 std::string GetHighlightTooltip(const std::set<int>& secondary_idcs) const override;
103
106
107 static void DummyItemsChange(REveDataItemList*, const std::vector<int>&);
108 static void DummyFillImpliedSelected(REveDataItemList*, Set_t& impSelSet, const std::set<int>& sec_idcs);
109
110 std::vector< std::unique_ptr<TTip> >& RefToolTipExpressions() {return fTooltipExpressions;}
111};
112
113//==============================================================================
114
116{
117private:
119
120public:
121 typedef std::vector<int> Ids_t;
123
124 TClass *fItemClass{nullptr}; // so far only really need class name
125
127 std::function<bool(void *)> fFilterFoo = [](void *) { return true; };
128
129 REveDataCollection(const std::string& n = "REveDataCollection", const std::string& t = "");
131
132 void ReserveItems(Int_t items_size) { fItemList->fItems.reserve(items_size); }
133 void AddItem(void *data_ptr, const std::string& n, const std::string& t);
134 void ClearItems() { fItemList->fItems.clear(); }
135
136 Bool_t SingleRnrState() const override { return kTRUE; }
137 Bool_t SetRnrState(Bool_t) override;
138
139
140 TClass *GetItemClass() const { return fItemClass; }
141 void SetItemClass(TClass *cls) { fItemClass = cls;
142 }
144
145 void SetFilterExpr(const char* filter);
146 void ApplyFilter();
147
148 const char* GetFilterExpr(){return fFilterExpr.Data();}
149
150 Int_t GetNItems() const { return (Int_t) fItemList->fItems.size(); }
151 void *GetDataPtr(Int_t i) const { return fItemList->fItems[i]->GetDataPtr(); }
152 const REveDataItem* GetDataItem(Int_t i) const { return fItemList->fItems[i]; }
153
154 void StreamPublicMethods(nlohmann::json &cj) const;
155 Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
156
157 void SetMainColor(Color_t) override;
158
159};
160
161} // namespace Experimental
162} // namespace ROOT
163
164#endif
#define d(i)
Definition: RSha256.hxx:102
#define c(i)
Definition: RSha256.hxx:101
bool Bool_t
Definition: RtypesCore.h:63
short Color_t
Definition: RtypesCore.h:92
unsigned char UChar_t
Definition: RtypesCore.h:38
const Bool_t kTRUE
Definition: RtypesCore.h:100
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 b
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 r
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 g
std::function< bool(void *)> fFilterFoo
void StreamPublicMethods(nlohmann::json &cj) const
void AddItem(void *data_ptr, const std::string &n, const std::string &t)
Bool_t SetRnrState(Bool_t) override
Set render state of this element and of its children to the same value.
void SetMainColor(Color_t) override
Set main color of the element.
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
const REveDataItem * GetDataItem(Int_t i) const
REveDataCollection(const std::string &n="REveDataCollection", const std::string &t="")
REveDataItemList(const std::string &n="Items", const std::string &t="")
std::function< void(REveDataItemList *, Set_t &, const std::set< int > &)> FillImpliedSelectedFunc_t
virtual void ItemChanged(REveDataItem *item)
Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override
Write core json.
void AddTooltipExpression(const std::string &title, const std::string &expr, bool init=true)
FillImpliedSelectedFunc_t fHandlerFillImplied
void ProcessSelection(ElementId_t id, bool multi, bool secondary, const std::set< int > &in_secondary_idcs)
void ProcessSelectionStr(ElementId_t id, bool multi, bool secondary, const char *in_secondary_idcs)
void SetItemColorRGB(Int_t idx, UChar_t r, UChar_t g, UChar_t b)
std::vector< std::unique_ptr< TTip > > fTooltipExpressions
Bool_t SetRnrState(Bool_t) override
Set render state of this element and of its children to the same value.
std::string GetHighlightTooltip(const std::set< int > &secondary_idcs) const override
void SetItemsChangeDelegate(ItemsChangeFunc_t)
void SetFillImpliedSelectedDelegate(FillImpliedSelectedFunc_t)
std::vector< REveDataItem * > fItems
void FillImpliedSelectedSet(Set_t &impSelSet, const std::set< int > &sec_idcs) override
Populate set impSelSet with derived / dependant elements.
static void DummyItemsChange(REveDataItemList *, const std::vector< int > &)
static void DummyFillImpliedSelected(REveDataItemList *, Set_t &impSelSet, const std::set< int > &sec_idcs)
std::vector< std::unique_ptr< TTip > > & RefToolTipExpressions()
void SetItemVisible(Int_t idx, Bool_t visible)
std::function< void(REveDataItemList *, const std::vector< int > &)> ItemsChangeFunc_t
virtual std::string GetHighlightTooltip(const std::set< int > &) const
std::set< REveElement * > Set_t
Definition: REveElement.hxx:64
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
const Int_t n
Definition: legend1.C:16
unsigned int ElementId_t
Definition: REveTypes.hxx:25
void(off) SmallVectorTemplateBase< T
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:167
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.
basic_json< std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, adl_serializer, std::vector< std::uint8_t > > json
Definition: REveElement.hxx:36