Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TObjectDisplayItem.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, 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_TObjectDisplayItem
10#define ROOT7_TObjectDisplayItem
11
12#include <ROOT/RDisplayItem.hxx>
13#include <ROOT/RDrawable.hxx>
14
15#include <string>
16#include <vector>
17#include <algorithm>
18
19#include "TObject.h"
20
21namespace ROOT {
22namespace Experimental {
23
24
25/** \class TObjectDisplayItem
26\ingroup GpadROOT7
27\brief Display item for TObject with drawing options
28\author Sergey Linev <s.linev@gsi.de>
29\date 2017-05-31
30\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
31*/
32
34protected:
35
36 int fKind{0}; ///< object kind
37 const TObject *fObject{nullptr}; ///< ROOT6 object
38 std::string fCssType; ///< CSS type
39 bool fOwner{false}; ///<! if object must be deleted
40 std::vector<int> fColIndex; ///< stored color index
41 std::vector<std::string> fColValue; ///< stored color value
42
43public:
44
45 /// normal constructor, also copies drawable id and csstype
46 TObjectDisplayItem(const RDrawable &dr, int kind, const TObject *obj) : RIndirectDisplayItem(dr)
47 {
48 fCssType = dr.GetCssType();
49 fKind = kind;
50 fObject = obj;
51 }
52
53 /// constructor for special objects like palette, takes ownership!!
55 {
56 fKind = kind;
57 fObject = obj;
58 fOwner = true;
59 }
60
62 {
63 if (fOwner) delete fObject;
64 }
65
66 void UpdateColor(int color_indx, const std::string &color_value)
67 {
68 auto pos = std::find(fColIndex.begin(), fColIndex.end(), color_indx);
69 if (pos == fColIndex.end()) {
70 fColIndex.emplace_back(color_indx);
71 fColValue.emplace_back(color_value);
72 } else {
73 auto indx = pos - fColIndex.begin();
74 fColValue[indx] = color_value;
75 }
76 }
77
78};
79
80} // namespace Experimental
81} // namespace ROOT
82
83#endif
Base class for drawable entities: objects that can be painted on a RPad.
const char * GetCssType() const
Extract (reference) only basic attributes from drawable, but not drawable itself.
Display item for TObject with drawing options.
void UpdateColor(int color_indx, const std::string &color_value)
TObjectDisplayItem(const RDrawable &dr, int kind, const TObject *obj)
normal constructor, also copies drawable id and csstype
std::vector< std::string > fColValue
stored color value
TObjectDisplayItem(int kind, const TObject *obj)
constructor for special objects like palette, takes ownership!!
std::vector< int > fColIndex
stored color index
bool fOwner
! if object must be deleted
Mother of all ROOT objects.
Definition TObject.h:41
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...