File indexing completed on 2025-01-30 10:22:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_TObjectDisplayItem
0010 #define ROOT7_TObjectDisplayItem
0011
0012 #include <ROOT/RDisplayItem.hxx>
0013 #include <ROOT/RDrawable.hxx>
0014
0015 #include <string>
0016 #include <vector>
0017 #include <algorithm>
0018
0019 #include "TObject.h"
0020
0021 namespace ROOT {
0022 namespace Experimental {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class TObjectDisplayItem : public RIndirectDisplayItem {
0034 protected:
0035
0036 int fKind{0};
0037 const TObject *fObject{nullptr};
0038 std::string fCssType;
0039 bool fOwner{false};
0040 std::vector<int> fColIndex;
0041 std::vector<std::string> fColValue;
0042
0043 public:
0044
0045
0046 TObjectDisplayItem(const RDrawable &dr, int kind, const TObject *obj) : RIndirectDisplayItem(dr)
0047 {
0048 fCssType = dr.GetCssType();
0049 fKind = kind;
0050 fObject = obj;
0051 }
0052
0053
0054 TObjectDisplayItem(int kind, const TObject *obj) : RIndirectDisplayItem()
0055 {
0056 fKind = kind;
0057 fObject = obj;
0058 fOwner = true;
0059 }
0060
0061 ~TObjectDisplayItem() override
0062 {
0063 if (fOwner) delete fObject;
0064 }
0065
0066 void UpdateColor(int color_indx, const std::string &color_value)
0067 {
0068 auto pos = std::find(fColIndex.begin(), fColIndex.end(), color_indx);
0069 if (pos == fColIndex.end()) {
0070 fColIndex.emplace_back(color_indx);
0071 fColValue.emplace_back(color_value);
0072 } else {
0073 auto indx = pos - fColIndex.begin();
0074 fColValue[indx] = color_value;
0075 }
0076 }
0077
0078 };
0079
0080 }
0081 }
0082
0083 #endif