Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:26

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 NewWidgetMsg(std::shared_ptr<RBrowserWidget> &widget);
0061    void ProcessRunMacro(const std::string &file_path);
0062    void ProcessSaveFile(const std::string &fname, const std::string &content);
0063    std::string GetCurrentWorkingDirectory();
0064 
0065    std::vector<std::string> GetRootHistory();
0066    std::vector<std::string> GetRootLogs();
0067 
0068    void SendInitMsg(unsigned connid);
0069    void ProcessMsg(unsigned connid, const std::string &arg);
0070    void SendProgress(unsigned connid, float progr);
0071 
0072    void AddInitWidget(const std::string &kind);
0073 
0074    void CheckWidgtesModified();
0075 
0076    void ProcessPostponedRequests();
0077 
0078 public:
0079    RBrowser(bool use_rcanvas = false);
0080    virtual ~RBrowser();
0081 
0082    bool GetUseRCanvas() const { return fUseRCanvas; }
0083    void SetUseRCanvas(bool on = true) { fUseRCanvas = on; }
0084 
0085    void AddTCanvas() { AddInitWidget("tcanvas"); }
0086    void AddRCanvas() { AddInitWidget("rcanvas"); }
0087 
0088    /// show Browser in specified place
0089    void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
0090 
0091    /// hide Browser
0092    void Hide();
0093 
0094    std::string GetWindowUrl(bool remote);
0095 
0096    void SetWorkingPath(const std::string &path);
0097 
0098    /// Enable/disable catch of RWebWindow::Show calls to embed created widgets, default on
0099    void SetCatchWindowShow(bool on = true) { fCatchWindowShow = on; }
0100 
0101    /// Is RWebWindow::Show calls catched for embeding of created widgets
0102    bool GetCatchWindowShow() const { return fCatchWindowShow; }
0103 
0104    bool ActivateWidget(const std::string &title, const std::string &kind = "");
0105 
0106    void ClearOnClose(const std::shared_ptr<void> &handle);
0107 
0108 };
0109 
0110 } // namespace ROOT
0111 
0112 #endif