Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-04 10:15:37

0001 // Authors: Bertrand Bellenot <bertrand.bellenot@cern.ch> Sergey Linev <S.Linev@gsi.de>
0002 // Date: 2019-02-28
0003 // Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0004 
0005 /*************************************************************************
0006  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0007  * All rights reserved.                                                  *
0008  *                                                                       *
0009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0011  *************************************************************************/
0012 
0013 #ifndef ROOT7_RBrowser
0014 #define ROOT7_RBrowser
0015 
0016 #include <ROOT/RWebWindow.hxx>
0017 #include <ROOT/RBrowserData.hxx>
0018 
0019 #include <vector>
0020 #include <memory>
0021 
0022 namespace ROOT {
0023 
0024 class RBrowserWidget;
0025 class RBrowserTimer;
0026 
0027 class RBrowser {
0028 
0029    friend class RBrowserTimer;
0030 
0031 protected:
0032 
0033    std::string fTitle;  ///<! title
0034    unsigned fConnId{0}; ///<! default connection id
0035 
0036    bool fUseRCanvas{false};              ///<!  which canvas should be used
0037    bool fCatchWindowShow{true};          ///<! if arbitrary RWebWindow::Show calls should be catched by browser
0038    std::string fActiveWidgetName;        ///<! name of active widget
0039    std::vector<std::shared_ptr<RBrowserWidget>> fWidgets; ///<!  all browser widgets
0040    int fWidgetCnt{0};                                     ///<! counter for created widgets
0041    std::string fPromptFileOutput;        ///<! file name for prompt output
0042    float fLastProgressSend{0};           ///<! last value of send progress
0043    long long fLastProgressSendTm{0};      ///<! time when last progress message was send
0044 
0045    std::shared_ptr<RWebWindow> fWebWindow;   ///<! web window to browser
0046 
0047    RBrowserData  fBrowsable;                 ///<! central browsing element
0048    std::unique_ptr<RBrowserTimer>    fTimer; ///<!  timer to handle postponed requests
0049    std::vector<std::vector<std::string>> fPostponed; ///<! postponed messages, handled in timer
0050 
0051    std::shared_ptr<RBrowserWidget> AddWidget(const std::string &kind);
0052    std::shared_ptr<RBrowserWidget> AddCatchedWidget(RWebWindow *win, const std::string &kind);
0053    std::shared_ptr<RBrowserWidget> FindWidget(const std::string &name, const std::string &kind = "") const;
0054    std::shared_ptr<RBrowserWidget> GetActiveWidget() const { return FindWidget(fActiveWidgetName); }
0055 
0056    void CloseTab(const std::string &name);
0057 
0058    std::string ProcessBrowserRequest(const std::string &msg);
0059    std::string ProcessDblClick(unsigned connid, std::vector<std::string> &args);
0060    std::string ProcessDrop(unsigned connid, std::vector<std::string> &args);
0061    std::string NewWidgetMsg(std::shared_ptr<RBrowserWidget> &widget);
0062    void ProcessRunMacro(const std::string &file_path);
0063    void ProcessSaveFile(const std::string &fname, const std::string &content);
0064    std::string GetCurrentWorkingDirectory();
0065 
0066    std::vector<std::string> GetRootHistory();
0067    std::vector<std::string> GetRootLogs();
0068 
0069    void SendInitMsg(unsigned connid);
0070    void ProcessMsg(unsigned connid, const std::string &arg);
0071    void SendProgress(unsigned connid, float progr);
0072 
0073    void AddInitWidget(const std::string &kind);
0074 
0075    void CheckWidgtesModified(unsigned connid);
0076 
0077    void ProcessPostponedRequests();
0078 
0079 public:
0080    RBrowser(bool use_rcanvas = false);
0081    virtual ~RBrowser();
0082 
0083    bool GetUseRCanvas() const { return fUseRCanvas; }
0084    void SetUseRCanvas(bool on = true) { fUseRCanvas = on; }
0085 
0086    void AddTCanvas() { AddInitWidget("tcanvas"); }
0087    void AddRCanvas() { AddInitWidget("rcanvas"); }
0088 
0089    /// show Browser in specified place
0090    void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
0091 
0092    /// hide Browser
0093    void Hide();
0094 
0095    std::string GetWindowUrl(bool remote);
0096 
0097    void SetWorkingPath(const std::string &path);
0098 
0099    /// Enable/disable catch of RWebWindow::Show calls to embed created widgets, default on
0100    void SetCatchWindowShow(bool on = true) { fCatchWindowShow = on; }
0101 
0102    /// Is RWebWindow::Show calls catched for embeding of created widgets
0103    bool GetCatchWindowShow() const { return fCatchWindowShow; }
0104 
0105    bool ActivateWidget(const std::string &title, const std::string &kind = "");
0106 
0107    void ClearOnClose(const std::shared_ptr<void> &handle);
0108 
0109 };
0110 
0111 } // namespace ROOT
0112 
0113 #endif