Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:42

0001 /*************************************************************************
0002  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 /** \class TObjectDisplayItem
0026 \ingroup GpadROOT7
0027 \brief Display item for TObject with drawing options
0028 \author Sergey Linev <s.linev@gsi.de>
0029 \date 2017-05-31
0030 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0031 */
0032 
0033 class TObjectDisplayItem : public RIndirectDisplayItem {
0034 protected:
0035 
0036    int fKind{0};                           ///< object kind
0037    const TObject *fObject{nullptr};        ///< ROOT6 object
0038    std::string fCssType;                   ///< CSS type
0039    bool fOwner{false};                     ///<! if object must be deleted
0040    std::vector<int> fColIndex;             ///< stored color index
0041    std::vector<std::string> fColValue;     ///< stored color value
0042 
0043 public:
0044 
0045    /// normal constructor, also copies drawable id and csstype
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    /// constructor for special objects like palette, takes ownership!!
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 } // namespace Experimental
0081 } // namespace ROOT
0082 
0083 #endif