Back to home page

EIC code displayed by LXR

 
 

    


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

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_RPadDisplayItem
0010 #define ROOT7_RPadDisplayItem
0011 
0012 #include <ROOT/RDisplayItem.hxx>
0013 #include <ROOT/RPad.hxx>
0014 #include "ROOT/RStyle.hxx"
0015 
0016 namespace ROOT {
0017 namespace Experimental {
0018 
0019 
0020 /** class RPadBaseDisplayItem
0021 \ingroup GpadROOT7
0022 \brief Display item for the RPadBase class, includes primitives, attributes and frame
0023 \author Sergey Linev
0024 \date 2017-05-31
0025 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0026 */
0027 
0028 class RPadBaseDisplayItem : public RDisplayItem {
0029 public:
0030    // list of snapshot for primitives in pad
0031    using PadPrimitives_t = std::vector<std::unique_ptr<RDisplayItem>>;
0032 
0033 protected:
0034    const RAttrMap *fAttr{nullptr};      ///< temporary pointer on attributes
0035    PadPrimitives_t fPrimitives;         ///< display items for all primitives in the pad
0036    std::vector<std::shared_ptr<RStyle>> fStyles; ///<! locked styles of the objects and pad until streaming is performed
0037 public:
0038    RPadBaseDisplayItem() = default;
0039    ~RPadBaseDisplayItem() override = default;
0040    void SetAttributes(const RAttrMap *f) { fAttr = f; }
0041    /// Add display item and style which should be used for it
0042    void Add(std::unique_ptr<RDisplayItem> &&item, std::shared_ptr<RStyle> &&style)
0043    {
0044       if (style) {
0045          item->SetStyle(style.get());
0046          fStyles.emplace_back(std::move(style));
0047       }
0048       fPrimitives.push_back(std::move(item));
0049    }
0050    /// Assign style for the pad
0051    void SetPadStyle(std::shared_ptr<RStyle> &&style)
0052    {
0053       if (style) {
0054          SetStyle(style.get());
0055          fStyles.emplace_back(std::move(style));
0056       }
0057    }
0058 };
0059 
0060 /** class RPadDisplayItem
0061 \ingroup GpadROOT7
0062 \brief Display item for the RPad class, add pad position and size
0063 \author Sergey Linev
0064 \date 2017-05-31
0065 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0066 */
0067 
0068 class RPadDisplayItem : public RPadBaseDisplayItem {
0069 
0070 protected:
0071    const RPadPos *fPos{nullptr};        ///< pad position
0072    const RPadExtent *fSize{nullptr};    ///< pad size
0073 public:
0074    RPadDisplayItem() = default;
0075    ~RPadDisplayItem() override {}
0076    void SetPadPosSize(const RPadPos *pos, const RPadExtent *size) { fPos = pos; fSize = size; }
0077 
0078    void BuildFullId(const std::string &prefix) override
0079    {
0080       RDisplayItem::BuildFullId(prefix);
0081       std::string subprefix = prefix + std::to_string(GetIndex()) + "_";
0082       for (auto &item : fPrimitives)
0083          item->BuildFullId(subprefix);
0084    }
0085 };
0086 
0087 
0088 /** class RCanvasDisplayItem
0089 \ingroup GpadROOT7
0090 \brief Display item for the RCanvas class, add canvas title and size
0091 \author Sergey Linev
0092 \date 2017-05-31
0093 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0094 */
0095 
0096 class RCanvasDisplayItem : public RPadBaseDisplayItem {
0097 
0098 protected:
0099    std::string fTitle;                  ///< title of the canvas
0100    std::array<int, 2> fWinSize;         ///< canvas window size
0101 public:
0102    RCanvasDisplayItem() = default;
0103    ~RCanvasDisplayItem() override = default;
0104    void SetTitle(const std::string &title) { fTitle = title; }
0105    void SetWindowSize(int width, int height) { fWinSize[0] = width; fWinSize[1] = height; }
0106 
0107    void BuildFullId(const std::string &prefix) override
0108    {
0109       for (auto &item : fPrimitives)
0110          item->BuildFullId(prefix);
0111    }
0112 };
0113 
0114 
0115 
0116 } // Experimental
0117 } // ROOT
0118 
0119 #endif