Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/eve7:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT7_REveScene
0013 #define ROOT7_REveScene
0014 
0015 #include <ROOT/REveElement.hxx>
0016 
0017 #include "TClass.h"
0018 
0019 #include <vector>
0020 #include <memory>
0021 
0022 namespace ROOT {
0023 namespace Experimental {
0024 
0025 class REveClient;
0026 class REveManager;
0027 
0028 /******************************************************************************/
0029 // REveScene
0030 // REve representation of TGLScene.
0031 /******************************************************************************/
0032 
0033 class REveScene : public REveElement
0034 {
0035    friend class REveManager;
0036 
0037 private:
0038    REveScene(const REveScene &) = delete;
0039    REveScene &operator=(const REveScene &) = delete;
0040 
0041 protected:
0042    struct SceneCommand
0043    {
0044       std::string fName;
0045       std::string fIcon;
0046       std::string fElementClass;
0047       std::string fAction;
0048       ElementId_t fElementId{0};
0049 
0050       SceneCommand(const std::string& name, const std::string& icon,
0051                    const REveElement* element, const std::string& action) :
0052          fName(name),
0053          fIcon(icon),
0054          fElementClass(element->IsA()->GetName()),
0055          fAction(action),
0056          fElementId(element->GetElementId())
0057       {}
0058    };
0059 
0060    Bool_t fSmartRefresh{kTRUE};            ///<!
0061    Bool_t fHierarchical{kFALSE};           ///<!
0062 
0063    Bool_t fAcceptingChanges{kFALSE};       ///<!
0064    Bool_t fChanged{kFALSE};                ///<!
0065    // Changed or/and added.
0066    // XXXX can change to vector (element checks if already registered now).
0067    List_t  fChangedElements;               ///<!
0068    // For the following two have to re-think how the hierarchy will be handled.
0069    // If I remove a parent, i have to remove all the children.
0070    // So this has to be done right on both sides (on eve element and here).
0071    // I might need a set, so i can easily check if parent is in the removed / added list already.
0072    std::vector<ElementId_t> fRemovedElements; ///<!
0073 
0074    std::vector<std::unique_ptr<REveClient>> fSubscribers; ///<!
0075 
0076    List_t fElsWithBinaryData;
0077    std::string fOutputJson;               ///<!
0078    std::vector<char> fOutputBinary;       ///<!
0079    Int_t fTotalBinarySize;                ///<!
0080 
0081    std::vector<SceneCommand> fCommands;   ///<!
0082 
0083    bool fMandatory{true};
0084    // void RetransHierarchicallyRecurse(REveElement* el, const REveTrans& tp);
0085 
0086 public:
0087    REveScene(const std::string &n = "REveScene", const std::string &t = "");
0088    ~REveScene() override;
0089 
0090    Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset) override;
0091    Bool_t SingleRnrState() const override { return kTRUE; }
0092 
0093    void   SetHierarchical(Bool_t h) { fHierarchical = h; }
0094    Bool_t GetHierarchical() const { return fHierarchical; }
0095 
0096    void   Changed() { fChanged = kTRUE; } // AMT ??? depricated
0097    Bool_t IsChanged() const;
0098 
0099    Bool_t IsAcceptingChanges() const { return fAcceptingChanges; }
0100    void BeginAcceptingChanges();
0101    void SceneElementChanged(REveElement *element);
0102    void SceneElementRemoved(ElementId_t id);
0103    void EndAcceptingChanges();
0104 
0105    void StreamElements();
0106    void StreamJsonRecurse(REveElement *el, nlohmann::json &jobj);
0107 
0108    // void   Repaint(Bool_t dropLogicals=kFALSE);
0109    // void   RetransHierarchically();
0110 
0111    // virtual void Paint(Option_t* option = "");
0112 
0113    // void DestroyElementRenderers(REveElement* element);
0114    // void DestroyElementRenderers(TObject* rnrObj);
0115    void StreamRepresentationChanges();
0116    void SendChangesToSubscribers();
0117 
0118    Bool_t HasSubscribers() const { return !fSubscribers.empty(); }
0119    void AddSubscriber(std::unique_ptr<REveClient> &&sub);
0120    void RemoveSubscriber(unsigned int);
0121 
0122    bool GetMandatory() { return fMandatory; }
0123    void SetMandatory(bool x) { fMandatory = x; }
0124 
0125    void AddCommand(const std::string &name, const std::string &icon, const REveElement *element, const std::string &action);
0126 };
0127 
0128 /******************************************************************************/
0129 // REveSceneList
0130 // List of Scenes providing common operations on REveScene collections.
0131 /******************************************************************************/
0132 
0133 class REveSceneList : public REveElement
0134 {
0135 private:
0136    REveSceneList(const REveSceneList &) = delete;
0137    REveSceneList &operator=(const REveSceneList &) = delete;
0138 
0139 protected:
0140 public:
0141    REveSceneList(const std::string &n = "REveSceneList", const std::string &t = "");
0142    ~REveSceneList() override {}
0143 
0144    void DestroyScenes();
0145 
0146    // void RepaintChangedScenes(Bool_t dropLogicals);
0147    // void RepaintAllScenes(Bool_t dropLogicals);
0148 
0149    // void DestroyElementRenderers(REveElement* element);
0150    void AcceptChanges(bool);
0151    bool AnyChanges() const;
0152 };
0153 
0154 } // namespace Experimental
0155 } // namespace ROOT
0156 
0157 #endif