Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
22 /** \class RDisplayItem
23 \ingroup GpadROOT7
24 \brief Base class for painting data for JS.
25 \author Sergey Linev <s.linev@gsi.de>
26 \date 2017-05-31
27 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
28 */
29 
30 class RDisplayItem {
31 protected:
32  std::string fObjectID; ///< unique object identifier
33  RStyle *fStyle{nullptr}; ///< style object
34  unsigned fIndex{0}; ///<! index inside current pad, used to produce fully-qualified id, not send to client
35 
36 public:
37  RDisplayItem() = default;
38  virtual ~RDisplayItem() {}
39 
40  void SetObjectID(const std::string &id) { fObjectID = id; }
41  std::string GetObjectID() const { return fObjectID; }
42 
43  void SetObjectIDAsPtr(const void *ptr);
44 
45  void SetStyle(RStyle *style) { fStyle = style; }
46 
47  void SetIndex(unsigned indx) { fIndex = indx; }
48  unsigned GetIndex() const { return fIndex; }
49 
50  virtual void BuildFullId(const std::string &prefix);
51 
52  static std::string ObjectIDFromPtr(const void *ptr);
53 };
54 
55 
56 /** \class RDrawableDisplayItem
57 \ingroup GpadROOT7
58 \brief Generic display item for RDrawable, just reference drawable itself
59 \author Sergey Linev <s.linev@gsi.de>
60 \date 2017-05-31
61 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
62 */
63 
64 class RDrawableDisplayItem : public RDisplayItem {
65 protected:
66 
67  const RDrawable *fDrawable{nullptr}; ///< drawable
68 
69 public:
70 
71  template <class DRAWABLE>
72  RDrawableDisplayItem(const DRAWABLE &dr)
73  {
74  fDrawable = &dr;
75  }
76 
77 };
78 
79 /** \class RObjectDisplayItem
80 \ingroup GpadROOT7
81 \brief Display item for TObject with drawing options
82 \author Sergey Linev <s.linev@gsi.de>
83 \date 2017-05-31
84 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
85 */
86 
87 class RObjectDisplayItem : public RDisplayItem {
88 protected:
89 
90  const TObject *fObject{nullptr}; ///< ROOT6 object
91  std::string fOption; ///< drawing options
92 
93 public:
94 
95  RObjectDisplayItem(const TObject *obj, const std::string &opt)
96  {
97  fObject = obj;
98  fOption = opt;
99  }
100 
101 };
102 
103 } // namespace Experimental
104 } // namespace ROOT
105 
106 #endif