Logo ROOT  
Reference Guide
RDisplayItem.hxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2019, 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_RDisplayItem
10 #define ROOT7_RDisplayItem
11 
12 #include <string>
13 
14 class TObject;
15 
16 namespace ROOT {
17 namespace Experimental {
18 
19 class RDrawable;
20 class RStyle;
21 class RAttrMap;
22 
23 /** \class RDisplayItem
24 \ingroup GpadROOT7
25 \brief Base class for painting data for JS.
26 \author Sergey Linev <s.linev@gsi.de>
27 \date 2017-05-31
28 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
29 */
30 
31 class RDisplayItem {
32 protected:
33  std::string fObjectID; ///< unique object identifier
34  RStyle *fStyle{nullptr}; ///< style object
35  unsigned fIndex{0}; ///<! index inside current pad, used to produce fully-qualified id, not send to client
36  bool fDummy{false}; ///< if true, just placeholder for drawable which does not changed
37 
38 public:
39  RDisplayItem() = default;
40  RDisplayItem(bool dummy) : RDisplayItem() { fDummy = dummy; }
41  virtual ~RDisplayItem() {}
42 
43  void SetObjectID(const std::string &id) { fObjectID = id; }
44  std::string GetObjectID() const { return fObjectID; }
45 
46  void SetObjectIDAsPtr(const void *ptr);
47 
49 
50  void SetIndex(unsigned indx) { fIndex = indx; }
51  unsigned GetIndex() const { return fIndex; }
52 
53  virtual void BuildFullId(const std::string &prefix);
54 
55  static std::string ObjectIDFromPtr(const void *ptr);
56 };
57 
58 
59 /** \class RDrawableDisplayItem
60 \ingroup GpadROOT7
61 \brief Generic display item for RDrawable, just reference drawable itself
62 \author Sergey Linev <s.linev@gsi.de>
63 \date 2017-05-31
64 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
65 */
66 
68 protected:
69 
70  const RDrawable *fDrawable{nullptr}; ///< drawable
71 
72 public:
73 
74  template <class DRAWABLE>
75  RDrawableDisplayItem(const DRAWABLE &dr)
76  {
77  fDrawable = &dr;
78  }
79 
80  const RDrawable *GetDrawable() const { return fDrawable; }
81 
82  virtual ~RDrawableDisplayItem();
83 
84 };
85 
86 
87 /** \class RIndirectDisplayItem
88 \ingroup GpadROOT7
89 \brief Extract (reference) only basic attributes from drawable, but not drawable itself
90 \author Sergey Linev <s.linev@gsi.de>
91 \date 2020-04-02
92 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
93 */
94 
96 protected:
97 
98  const RAttrMap *fAttr{nullptr}; ///< pointer on drawable attributes
99  const std::string *fCssClass{nullptr}; ///< pointer on drawable class
100  const std::string *fId{nullptr}; ///< pointer on drawable id
101 
102 public:
103 
104  RIndirectDisplayItem() = default;
105 
106  RIndirectDisplayItem(const RDrawable &dr);
107 };
108 
109 
110 /** \class TObjectDisplayItem
111 \ingroup GpadROOT7
112 \brief Display item for TObject with drawing options
113 \author Sergey Linev <s.linev@gsi.de>
114 \date 2017-05-31
115 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
116 */
117 
119 protected:
120 
121  int fKind{0}; ///< object kind
122  const TObject *fObject{nullptr}; ///< ROOT6 object
123  std::string fOption; ///< drawing options
124  bool fOwner{false}; ///<! if object must be deleted
125 
126 public:
127 
128  TObjectDisplayItem(int kind, const TObject *obj, const std::string &opt, bool owner = false)
129  {
130  fKind = kind;
131  fObject = obj;
132  fOption = opt;
133  fOwner = owner;
134  }
135 
136  virtual ~TObjectDisplayItem();
137 
138 };
139 
140 } // namespace Experimental
141 } // namespace ROOT
142 
143 #endif
ROOT::Experimental::RDrawableDisplayItem::RDrawableDisplayItem
RDrawableDisplayItem(const DRAWABLE &dr)
Definition: RDisplayItem.hxx:75
ROOT::Experimental::RIndirectDisplayItem::RIndirectDisplayItem
RIndirectDisplayItem()=default
ROOT::Experimental::RDrawableDisplayItem
Generic display item for RDrawable, just reference drawable itself.
Definition: RDisplayItem.hxx:67
ROOT::Experimental::TObjectDisplayItem
Display item for TObject with drawing options.
Definition: RDisplayItem.hxx:118
ROOT::Experimental::RDisplayItem::SetIndex
void SetIndex(unsigned indx)
Definition: RDisplayItem.hxx:50
ROOT::Experimental::TObjectDisplayItem::fOption
std::string fOption
drawing options
Definition: RDisplayItem.hxx:123
ROOT::Experimental::TObjectDisplayItem::fKind
int fKind
object kind
Definition: RDisplayItem.hxx:121
ROOT::Experimental::RAttrMap
Definition: RAttrMap.hxx:33
ROOT::Experimental::RDisplayItem::ObjectIDFromPtr
static std::string ObjectIDFromPtr(const void *ptr)
Construct fillid using pointer value.
Definition: RDisplayItem.cxx:38
ROOT::Experimental::RDisplayItem::SetObjectID
void SetObjectID(const std::string &id)
Definition: RDisplayItem.hxx:43
ROOT::Experimental::RIndirectDisplayItem::fAttr
const RAttrMap * fAttr
pointer on drawable attributes
Definition: RDisplayItem.hxx:98
ROOT::Experimental::TObjectDisplayItem::fOwner
bool fOwner
! if object must be deleted
Definition: RDisplayItem.hxx:124
ROOT::Experimental::RDisplayItem::SetObjectIDAsPtr
void SetObjectIDAsPtr(const void *ptr)
Assign id using arbitrary pointer value Typically drawable pointer should be used here.
Definition: RDisplayItem.cxx:22
ROOT::Experimental::RDisplayItem::SetStyle
void SetStyle(RStyle *style)
Definition: RDisplayItem.hxx:48
ROOT::Experimental::RDrawableDisplayItem::~RDrawableDisplayItem
virtual ~RDrawableDisplayItem()
destructor
Definition: RDisplayItem.cxx:47
id
XFontStruct * id
Definition: TGX11.cxx:109
ROOT::Experimental::RDisplayItem::fStyle
RStyle * fStyle
style object
Definition: RDisplayItem.hxx:34
style
TCanvas * style()
Definition: style.C:1
ROOT::Experimental::RDrawableDisplayItem::fDrawable
const RDrawable * fDrawable
drawable
Definition: RDisplayItem.hxx:70
ROOT::Experimental::RDisplayItem::GetIndex
unsigned GetIndex() const
Definition: RDisplayItem.hxx:51
ROOT::Experimental::RDisplayItem::~RDisplayItem
virtual ~RDisplayItem()
Definition: RDisplayItem.hxx:41
ROOT::Experimental::RDisplayItem::fIndex
unsigned fIndex
! index inside current pad, used to produce fully-qualified id, not send to client
Definition: RDisplayItem.hxx:35
ROOT::Experimental::TObjectDisplayItem::fObject
const TObject * fObject
ROOT6 object.
Definition: RDisplayItem.hxx:122
ROOT::Experimental::RDisplayItem
Base class for painting data for JS.
Definition: RDisplayItem.hxx:31
ROOT::Experimental::RIndirectDisplayItem::fId
const std::string * fId
pointer on drawable id
Definition: RDisplayItem.hxx:100
ROOT::Experimental::RDisplayItem::fObjectID
std::string fObjectID
unique object identifier
Definition: RDisplayItem.hxx:33
ROOT::Experimental::TObjectDisplayItem::~TObjectDisplayItem
virtual ~TObjectDisplayItem()
destructor
Definition: RDisplayItem.cxx:67
ROOT::Experimental::RDisplayItem::BuildFullId
virtual void BuildFullId(const std::string &prefix)
Build full id, including prefix and object index.
Definition: RDisplayItem.cxx:30
ROOT::Experimental::RDrawable
Base class for drawable entities: objects that can be painted on a RPad.
Definition: RDrawable.hxx:109
ROOT::Experimental::RDisplayItem::RDisplayItem
RDisplayItem()=default
ROOT::Experimental::TObjectDisplayItem::TObjectDisplayItem
TObjectDisplayItem(int kind, const TObject *obj, const std::string &opt, bool owner=false)
Definition: RDisplayItem.hxx:128
ROOT::Experimental::RDrawableDisplayItem::GetDrawable
const RDrawable * GetDrawable() const
Definition: RDisplayItem.hxx:80
ROOT::Experimental::RDisplayItem::fDummy
bool fDummy
if true, just placeholder for drawable which does not changed
Definition: RDisplayItem.hxx:36
ROOT::Experimental::RIndirectDisplayItem
Extract (reference) only basic attributes from drawable, but not drawable itself.
Definition: RDisplayItem.hxx:95
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ROOT::Experimental::RDisplayItem::RDisplayItem
RDisplayItem(bool dummy)
Definition: RDisplayItem.hxx:40
ROOT::Experimental::RStyle
A set of defaults for graphics attributes, e.g.
Definition: RStyle.hxx:32
ROOT::Experimental::RDisplayItem::GetObjectID
std::string GetObjectID() const
Definition: RDisplayItem.hxx:44
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::RIndirectDisplayItem::fCssClass
const std::string * fCssClass
pointer on drawable class
Definition: RDisplayItem.hxx:99