File indexing completed on 2025-03-19 09:07:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT7_RTreeViewer
0012 #define ROOT7_RTreeViewer
0013
0014 #include <ROOT/RWebDisplayArgs.hxx>
0015
0016 #include "Rtypes.h"
0017
0018 #include <memory>
0019 #include <vector>
0020 #include <string>
0021 #include <functional>
0022
0023 class TTree;
0024 class TBranch;
0025 class TLeaf;
0026 class TObjArray;
0027
0028 namespace ROOT {
0029
0030 class RWebWindow;
0031 class RTreeDrawMonitoring;
0032 class RTreeDrawInvokeTimer;
0033
0034 class RTreeViewer {
0035
0036 friend class RTreeDrawMonitoring;
0037 friend class RTreeDrawInvokeTimer;
0038
0039 public:
0040
0041 using PerformDrawCallback_t = std::function<void(const std::string &)>;
0042
0043 struct RBranchInfo {
0044 std::string fName, fTitle;
0045 RBranchInfo() = default;
0046 RBranchInfo(const std::string &_name, const std::string &_title) : fName(_name), fTitle(_title) {}
0047 };
0048
0049 struct RConfig {
0050 std::string fTreeName, fExprX, fExprY, fExprZ, fExprCut, fOption;
0051 std::vector<RBranchInfo> fBranches;
0052 Long64_t fNumber{0}, fFirst{0}, fStep{1}, fLargerStep{2}, fTreeEntries{0};
0053 };
0054
0055 RTreeViewer(TTree *tree = nullptr);
0056 virtual ~RTreeViewer();
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 SetTree(TTree *tree);
0066
0067 bool SuggestLeaf(const TLeaf *leaf);
0068
0069 bool SuggestBranch(const TBranch *branch);
0070
0071 bool SuggestExpression(const std::string &expr);
0072
0073 void SetCallback(PerformDrawCallback_t func) { fCallback = func; }
0074
0075
0076 void SetShowHierarchy(bool on = true) { fShowHierarchy = on; }
0077
0078
0079 bool GetShowHierarchy() const { return fShowHierarchy; }
0080
0081 void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
0082
0083 void Update();
0084
0085 static RTreeViewer *NewViewer(TTree *);
0086
0087 private:
0088
0089 TTree *fTree{nullptr};
0090 std::string fTitle;
0091 std::shared_ptr<ROOT::RWebWindow> fWebWindow;
0092 bool fShowHierarchy{false};
0093 RConfig fCfg;
0094 PerformDrawCallback_t fCallback;
0095 std::string fLastSendProgress;
0096 std::unique_ptr<RTreeDrawInvokeTimer> fTimer;
0097
0098 void WebWindowConnect(unsigned connid);
0099 void WebWindowCallback(unsigned connid, const std::string &arg);
0100
0101 void SendCfg(unsigned connid);
0102
0103 std::string FormatItemName(const std::string &name);
0104
0105 void AddBranches(TObjArray *branches);
0106
0107 void UpdateConfig();
0108
0109 void SendProgress(Double_t nevent = 0.);
0110
0111 void InvokeTreeDraw();
0112 };
0113
0114 }
0115
0116 #endif