31namespace Experimental {
53using namespace std::string_literals;
62 fWebWindow->SetDefaultPage(
"file:rootui5sys/tree/index.html");
115 if ((
const_cast<TBranch *
>(branch)->GetListOfBranches()->GetLast() < 0) && (branch->
GetNleaves() == 1)) {
116 std::string brname = branch->
GetName();
148 if (!
fTree || expr.empty())
165 std::string user_args =
"";
172 if ((
fWebWindow->NumConnections(
true) == 0) || always_start_new_browser)
218 if (arg ==
"GETCFG"s) {
222 }
else if (arg ==
"QUIT_ROOT"s) {
226 }
if (arg.compare(0, 5,
"DRAW:"s) == 0) {
237 std::string res =
name;
239 std::string from =
"/";
240 std::string to =
"\/";
242 size_t start_pos = 0;
243 while((start_pos = res.find(from, start_pos)) != std::string::npos) {
244 res.replace(start_pos, from.length(), to);
245 start_pos += to.length();
256 if (!branches || (branches->
GetLast() < 0))
259 TIter iter(branches);
261 while (
auto br =
dynamic_cast<TBranch *
>(iter())) {
263 auto leaves = br->GetListOfLeaves();
265 auto subbr = br->GetListOfBranches();
267 std::string brname = br->GetName();
269 TLeaf *leaf0 = (leaves->GetLast() == 0) ?
dynamic_cast<TLeaf *
>(leaves->At(0)) :
nullptr;
275 if ((subbr->GetLast() < 0) && leaf0 && (brname == leaf0->
GetName())) {
278 if (brelem && (brelem->GetStreamerType() < 1 || brelem->GetStreamerType() > 59))
286 while (
auto leaf =
dynamic_cast<TLeaf *
>(liter())) {
288 std::string leaffullname = leaf->GetFullName().Data();
291 if (brelem && brelem->GetStreamerType() ==
TStreamerInfo::kSTL && (leaves->GetLast() == 0) && (leaffullname == brfullname +
"_"))
328 auto newcfg = TBufferJSON::FromJSON<RConfig>(
json);
330 if (!newcfg || !
fTree)
return;
350 fProgrTimer = std::make_unique<TProgressTimer>(*
this, 50);
367 std::string canv_name;
370 if ((expr.find(
"\") != std::string::npos) || (expr.find(
"#") != std::string::npos)) {
371 auto FixTitle = [](
TNamed *obj) {
373 TString title = obj->GetTitle();
376 obj->SetTitle(title.
Data());
379 while (
auto obj = iter()) {
380 if (expr == obj->GetTitle()) {
381 FixTitle(
dynamic_cast<TNamed *
> (obj));
382 TH1 *hist =
dynamic_cast<TH1 *
> (obj);
393 canv_name =
gPad->GetName();
408 std::string progress =
"100";
421 progress = std::to_string((current -
first + 1.) / ( last -
first + 0. ) * 100.);
void Show(const RWebDisplayArgs &args="", bool always_start_new_browser=false)
Show or update viewer in web window If web browser already started - just refresh drawing like "reloa...
void UpdateConfig()
Update RConfig data.
std::string FormatItemName(const std::string &name)
Format item name used in draw expression.
bool SuggestLeaf(const TLeaf *leaf)
Suggest to use leaf in the gui Normally just assign as last edited expression.
std::string fLastSendProgress
! last send progress to client
void SetTree(TTree *tree)
assign new TTree to the viewer
void SendProgress(bool completed=false)
Send progress to the client.
std::string GetWindowAddr() const
Return URL address of web window used for tree viewer.
bool GetShowHierarchy() const
Returns default hierarchy browser visibility.
void Update()
Update tree viewer in all web displays.
void InvokeTreeDraw(const std::string &json)
Invoke tree drawing.
static RTreeViewer * NewViewer(TTree *)
Create new viewer Method used for plugin.
PerformDrawCallback_t fCallback
! callback invoked when tree draw performed
void SendCfg(unsigned connid)
Send data for initialize viewer.
bool SuggestExpression(const std::string &expr)
Suggest to use expression in the gui Normally just assign as last edited expression.
virtual ~RTreeViewer()
destructor
void WebWindowConnect(unsigned connid)
react on new connection
std::unique_ptr< TProgressTimer > fProgrTimer
! timer used to get draw progress
void AddBranches(TObjArray *branches)
Add branches to config.
std::shared_ptr< RWebWindow > fWebWindow
! web window
void WebWindowCallback(unsigned connid, const std::string &arg)
receive data from client
RConfig fCfg
! configuration, exchanged between client and server
RTreeViewer(TTree *tree=nullptr)
constructor
TTree * fTree
! TTree to show
bool SuggestBranch(const TBranch *branch)
Suggest to use branch in the gui Normally just assign as last edited expression.
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
const std::string & GetWidgetKind() const
returns widget kind
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
Bool_t Notify() override
This method must be overridden to handle object notification.
TProgressTimer(RTreeViewer &viewer, Int_t period)
A Branch for the case of an object.
TString GetFullName() const override
Return the 'full' name of the branch.
A TTree is a list of TBranches.
virtual TString GetFullName() const
Return the 'full' name of the branch.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
@ kSkipTypeInfo
do not store typenames in JSON
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
TH1 is the base class of all histogram classes in ROOT.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual const char * GetTypeName() const
TBranch * GetBranch() const
virtual TString GetFullName() const
Return the full name (including the parent's branch names) of the leaf.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
Int_t GetLast() const override
Return index of last object in array.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Handles synchronous and a-synchronous timer events.
A TTree represents a columnar dataset.
virtual void SetTimerInterval(Int_t msec=333)
void Draw(Option_t *opt) override
Default Draw method for all objects.
virtual Long64_t GetEntries() const
virtual Long64_t GetReadEntry() const
virtual TObjArray * GetListOfBranches()
static constexpr Long64_t kMaxEntries
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
std::vector< RBranchInfo > fBranches