Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Author: Sergey Linev, 13.12.2018
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2023, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT7_RGeomViewer
0012 #define ROOT7_RGeomViewer
0013 
0014 #include <ROOT/RWebDisplayArgs.hxx>
0015 #include <ROOT/RGeomData.hxx>
0016 
0017 #include <memory>
0018 
0019 class TGeoManager;
0020 class TGeoVolume;
0021 
0022 namespace ROOT {
0023 
0024 class RWebWindow;
0025 class RGeomHierarchy;
0026 
0027 class RGeomViewer {
0028 
0029 protected:
0030 
0031    TGeoManager *fGeoManager{nullptr};        ///<! geometry to show
0032    std::string fSelectedVolume;              ///<! name of selected volume
0033    RGeomDescription fDesc;                   ///<! geometry description, send to the client as first message
0034    bool fShowHierarchy{true};                ///<! if hierarchy visible by default
0035    bool fShowColumns{true};                  ///<! show columns in hierarchy
0036    std::string fTitle;                       ///<! title of geometry viewer
0037    bool fInfoActive{false};                  ///<! true when info page active and node info need to be provided
0038 
0039    std::shared_ptr<RWebWindow> fWebWindow;   ///<! web window to show geometry
0040 
0041    std::shared_ptr<RGeomHierarchy> fWebHierarchy; ///<! web handle for hierarchy part
0042 
0043    void WebWindowCallback(unsigned connid, const std::string &arg);
0044 
0045    void WebWindowDisconnect(unsigned connid);
0046 
0047    std::vector<int> GetStackFromJson(const std::string &json, bool node_ids = false);
0048 
0049    void SendGeometry(unsigned connid = 0, bool first_time = false);
0050 
0051    void ProcessSignal(const std::string &);
0052 
0053 public:
0054 
0055    RGeomViewer(TGeoManager *mgr = nullptr, const std::string &volname = "");
0056    virtual ~RGeomViewer();
0057 
0058    void SetTitle(const std::string &title) { fTitle = title; }
0059    const std::string &GetTitle() const { return fTitle; }
0060 
0061    std::string GetWindowAddr() const;
0062 
0063    std::string GetWindowUrl(bool remote);
0064 
0065    void SetGeometry(TGeoManager *mgr, const std::string &volname = "");
0066 
0067    void SelectVolume(const std::string &volname);
0068 
0069    void SetOnlyVolume(TGeoVolume *vol);
0070 
0071    /** Configures maximal number of visible nodes and faces */
0072    void SetLimits(int nnodes = 5000, int nfaces = 100000)
0073    {
0074       fDesc.SetMaxVisNodes(nnodes);
0075       fDesc.SetMaxVisFaces(nfaces);
0076    }
0077 
0078    /** Configures maximal visible level */
0079    void SetVisLevel(int lvl = 3)
0080    {
0081       fDesc.SetVisLevel(lvl);
0082    }
0083 
0084    void SetTopVisible(bool on = true)
0085    {
0086       fDesc.SetTopVisible(on);
0087    }
0088 
0089    /** Configures default hierarchy browser visibility, only has effect before showing web window */
0090    void SetShowHierarchy(bool on = true) { fShowHierarchy = on; }
0091 
0092    /** Returns default hierarchy browser visibility */
0093    bool GetShowHierarchy() const { return fShowHierarchy; }
0094 
0095    void SetShowColumns(bool on = true) { fShowColumns = on; }
0096 
0097    bool GetShowColumns() const { return fShowColumns; }
0098 
0099    void SetDrawOptions(const std::string &opt);
0100 
0101    void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
0102 
0103    void Update();
0104 
0105    void SaveImage(const std::string &fname = "geometry.png", int width = 0, int height = 0);
0106 
0107    RGeomDescription &Description() { return fDesc; }
0108 
0109    void SaveAsMacro(const std::string &fname);
0110 
0111    void ClearOnClose(const std::shared_ptr<void> &handle);
0112 
0113 };
0114 
0115 } // namespace ROOT
0116 
0117 #endif