Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:50

0001 /*************************************************************************
0002  * Copyright (C) 1995-2017, 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_TObjectDrawable
0010 #define ROOT7_TObjectDrawable
0011 
0012 #include <ROOT/RDrawable.hxx>
0013 #include <ROOT/RAttrValue.hxx>
0014 #include <ROOT/RAttrLine.hxx>
0015 #include <ROOT/RAttrText.hxx>
0016 #include <ROOT/RAttrMarker.hxx>
0017 #include <ROOT/RAttrFill.hxx>
0018 
0019 class TObject;
0020 class TColor;
0021 class TClass;
0022 
0023 namespace ROOT {
0024 namespace Experimental {
0025 
0026 class RPadBase;
0027 class TObjectDisplayItem;
0028 
0029 /** \class TObjectDrawable
0030 \ingroup GpadROOT7
0031 \brief Provides v7 drawing facilities for TObject types (TGraph, TH1, TH2, etc).
0032 \author Sergey Linev
0033 \date 2017-05-31
0034 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0035 */
0036 
0037 class TObjectDrawable final : public RDrawable {
0038 private:
0039 
0040    enum {
0041       kNone = 0,     ///< empty container
0042       kObject = 1,   ///< plain object
0043    };
0044 
0045    int fKind{kNone};                           ///< object kind
0046    Internal::RIOShared<TObject> fObj;          ///< The object to be painted, owned by the drawable
0047    const TObject *fExtObj{nullptr};            ///<! external object, managed outside of the drawable, not persistent
0048 
0049    static std::string GetColorCode(TColor *col);
0050 
0051    std::unique_ptr<TObject> CreateSpecials(int kind);
0052 
0053 protected:
0054 
0055    void CollectShared(Internal::RIOSharedVector_t &vect) final { vect.emplace_back(&fObj); }
0056 
0057    std::unique_ptr<RDisplayItem> Display(const RDisplayContext &) override;
0058 
0059    void PopulateMenu(RMenuItems &) final;
0060 
0061    void Execute(const std::string &) final;
0062 
0063    static void ExtractObjectColors(std::unique_ptr<TObjectDisplayItem> &item, const TObject *obj);
0064 
0065    static void CheckOwnership(TObject *obj);
0066 
0067    static const char *DetectCssType(const TObject *obj);
0068 
0069 public:
0070    // special kinds, see TWebSnapshot enums
0071    enum EKind {
0072       kColors = 4,   ///< list of ROOT colors
0073       kStyle = 5,    ///< instance of TStyle object
0074       kPalette = 6   ///< list of colors from palette
0075    };
0076 
0077    RAttrLine line{this, "line"};          ///<! object line attributes
0078    RAttrFill fill{this, "fill"};          ///<! object fill attributes
0079    RAttrMarker marker{this, "marker"};    ///<! object marker attributes
0080    RAttrText text{this, "text"};          ///<! object text attributes
0081    RAttrValue<std::string> options{this, "options"};  ///<! object draw options
0082 
0083    TObjectDrawable();
0084    TObjectDrawable(TObject *obj, bool isowner = false);
0085    TObjectDrawable(TObject *obj, const std::string &opt, bool isowner = false);
0086    TObjectDrawable(const std::shared_ptr<TObject> &obj);
0087    TObjectDrawable(const std::shared_ptr<TObject> &obj, const std::string &opt);
0088    TObjectDrawable(EKind kind, bool persistent = false);
0089    ~TObjectDrawable() override;
0090 
0091    void Reset();
0092 
0093    void Set(TObject *obj, bool isowner = false);
0094    void Set(TObject *obj, const std::string &opt, bool isowner = false);
0095 
0096    const TObject *Get();
0097 };
0098 
0099 } // namespace Experimental
0100 } // namespace ROOT
0101 
0102 
0103 #endif