Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTreeViewer.cxx
Go to the documentation of this file.
1// @(#)root/treeviewer:$Id: c8e226dde2f9b6f39946bfe90cabcb778d63dc4f $
2//Author : Andrei Gheata 16/08/00
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TTreeViewer
13A graphic user interface designed to handle ROOT trees and to take advantage of
14TTree class features.
15
16It uses ROOT native GUI widgets adapted for "drag and drop" functionality.
17in the same session.
18
19### The following capabilities are making the viewer a helpful tool for analysis:
20
21 - several trees may be opened in the same session;
22 - branches and leaves can be easily browsed or scanned;
23 - fast drawing of branch expressions by double-clicking;
24 - new variables/selections easy to compose with the built-in editor;
25 - histograms can be composed by dragging leaves or user-defined expressions
26 to X, Y and Z axis items;
27 - the tree entries to be processed can be selected with a double slider;
28 - selections can be defined and activated by dragging them to the 'Cut' item;
29 - all expressions can be aliased and aliases can be used in composing others;
30 - input/output event lists easy to handle;
31 - menu with histogram drawing options;
32 - user commands may be executed within the viewer and the current command
33 can be echoed;
34 - current 'Draw' event loop is reflected by a progress bar and may be
35 interrupted by the user;
36 - all widgets have self-explaining tool tips and/or context menus;
37 - expressions/leaves can be dragged to a 'scan box' and scanned by
38 double-clicking this item. The result can be redirected to an ASCII file;
39
40### The layout has the following items:
41
42 - a menu bar with entries : File, Edit, Run, Options and Help;
43 - a toolbar in the upper part where you can issue user commands, change
44 the drawing option and the histogram name, three check buttons Hist, Rec
45 and Scan.HIST toggles histogram drawing mode, REC enables recording of the
46 last command issued and SCAN enables redirecting of TTree::Scan command in
47 an ASCII file (see -Scanning expressions-);
48 - a button bar in the lower part with : buttons DRAW/STOP that issue histogram
49 drawing and stop the current command respectively, two text widgets where
50 input and output event lists can be specified, a message box and a RESET
51 button on the right that clear edited expression content (see Editing...)
52 - a tree-type list on the main left panel where you can select among trees or
53 branches. The tree/branch will be detailed in the right panel.
54 Mapped trees are provided with context menus, activated by right-clicking;
55 - a view-type list on the right panel. The first column contain X, Y and
56 Z expression items, an optional cut and ten optional editable expressions.
57 Expressions and leaf-type items can be dragged or deleted. A right click on
58 the list-box or item activates context menus.
59
60### Opening a new tree and saving a session :
61
62 To open a new tree in the viewer use `<File/Open tree file>` menu
63The content of the file (keys) will be listed. Use `<SetTreeName>` function
64from the context menu of the right panel, entering a tree name among those
65listed.
66
67 To save the current session, use `<File/Save>` menu or the `<SaveSource>`
68function from the context menu of the right panel (to specify the name of the
69file - name.C)
70
71 To open a previously saved session for the tree MyTree, first open MyTree
72in the browser, then use `<File/Open session>` menu.
73
74### Dragging items:
75
76Items that can be dragged from the list in the right : expressions and
77leaves. Dragging an item and dropping to another will copy the content of first
78to the last (leaf->expression, expression->expression). Items far to the right
79side of the list can be easily dragged to the left (where expressions are
80placed) by dragging them to the left at least 10 pixels.
81
82### Editing expressions:
83
84 Any editable expression from the right panel has two components : a
85true name (that will be used when TTree::Draw() commands are issued) and an
86alias. The visible name is the alias. Aliases of user defined expressions have
87a leading ~ and may be used in new expressions. Expressions containing boolean
88operators have a specific icon and may be dragged to the active cut (scissors
89item) position.
90
91 The expression editor can be activated by double-clicking empty expression,
92using `<EditExpression>` from the selected expression context menu or using
93`<Edit/Expression>` menu.
94
95 The editor will pop-up in the left part, but it can be moved.
96The editor usage is the following :
97
98 - you can write C expressions made of leaf names by hand or you can insert
99 any item from the right panel by clicking on it (recommandable);
100 - you can click on other expressions/leaves to paste them in the editor;
101 - you should write the item alias by hand since it not only make the
102 expression meaningful, but it also highly improve the layout for big
103 expressions
104 - you may redefine an old alias - the other expressions depending on it will
105 be modified accordingly. An alias must not be the leading string of other
106 aliases. When Draw commands are issued, the name of the corresponding
107 histogram axes will become the aliases of the expressions.
108
109User commands can be issued directly from the textbox labeled "Command"
110from the upper-left toolbar by typing and pressing Enter at the end.
111
112 Another way is from the right panel context menu : ExecuteCommand.
113All commands can be interrupted at any time by pressing the STOP button
114from the bottom-left
115You can toggle recording of the current command in the history file by
116checking the Rec button from the top-right
117
118### Context menus
119
120 You can activate context menus by right-clicking on items or inside the
121right panel.
122
123Context menus for mapped items from the left tree-type list :
124 The items from the left that are provided with context menus are tree and
125branch items. You can directly activate the *MENU* marked methods of TTree
126from this menu.
127
128Context menu for the right panel:
129
130 A general context menu is activated if the user right-clicks the right panel.
131
132 Commands are :
133 - EmptyAll : clears the content of all expressions;
134 - ExecuteCommand : execute a ROOT command;
135 - MakeSelector : equivalent of TTree::MakeSelector();
136 - NewExpression : add an expression item in the right panel;
137 - Process : equivalent of TTree::Process();
138 - SaveSource : save the current session as a C++ macro;
139 - SetScanFileName : define a name for the file where TTree::Scan command
140 is redirected when the `<Scan>` button is checked;
141 - SetTreeName : open a new tree with this name in the viewer;
142
143 A specific context menu is activated if expressions/leaves are right-clicked.
144
145 Commands are :
146 - Draw : draw a histogram for this item;
147 - EditExpression : pops-up the expression editor;
148 - Empty : empty the name and alias of this item;
149 - RemoveItem : removes clicked item from the list;
150 - Scan : scan this expression;
151 - SetExpression : edit name and alias for this item by hand;
152
153Starting the viewer
154
155 1. From the TBrowser: Select a tree in the TBrowser, then call the
156 StartViewer() method from its context menu (right-click on the tree).
157 2. From the command line: Start a ROOT session in the directory where you have
158 your tree. You will need first to load the library for TTreeViewer and
159 optionally other libraries for user defined classes (you can do this later in
160 the session) :
161~~~ {.cpp}
162 root [0] gSystem->Load(\"TTreeViewer\");
163~~~
164Supposing you have the tree MyTree in the file MyFile, you can do :
165~~~ {.cpp}
166 root [1] TFile file("Myfile");
167 root [2] new TTreeViewer("Mytree");
168~~~
169or :
170~~~ {.cpp}
171 root [2] TTreeViewer *tv = new TTreeViewer();
172 root [3] tv->SetTreeName("Mytree");
173~~~
174\image html ttree_treeview.png
175*/
176
177#include "RConfigure.h"
178
179#include <iostream>
180#include <fstream>
181#include "TTreeViewer.h"
182#include "HelpText.h"
183#include "HelpTextTV.h"
184#include "TTVLVContainer.h"
185#include "TTVSession.h"
186
187#include "TROOT.h"
188#include "TError.h"
189#include "TGMsgBox.h"
190#include "TTreePlayer.h"
191#include "TContextMenu.h"
192#include "TInterpreter.h"
193#include "TLeaf.h"
194#include "TBranch.h"
195#include "TRootHelpDialog.h"
196#include "TSystem.h"
197#include "TApplication.h"
198#include "TVirtualX.h"
199#include "TGClient.h"
200#include "TKey.h"
201#include "TFile.h"
202#include "TGMenu.h"
203#include "TVirtualPad.h"
204#include "TH1.h"
205#include "TFriendElement.h"
206#include "TObjArray.h"
207#include "TObjString.h"
208#include "TGButton.h"
209#include "TGButtonGroup.h"
210#include "TGTextEntry.h"
211#include "TGComboBox.h"
212#include "TGLabel.h"
213#include "TGListView.h"
214#include "TGListTree.h"
215#include "TGMimeTypes.h"
216#include "TGSplitter.h"
217#include "TGDoubleSlider.h"
218#include "TGToolBar.h"
219#include "TGStatusBar.h"
220#include "Getline.h"
221#include "TTimer.h"
222#include "TG3DLine.h"
223#include "TGFileDialog.h"
224#include "TGProgressBar.h"
225#include "TSpider.h"
226#include "strlcpy.h"
227#include "snprintf.h"
228
229#include <filesystem>
230
231#ifdef WIN32
232#include "TWin32SplashThread.h"
233#endif
234
235// drawing options
236static const char* gOptgen[16] =
237{
238 "","AXIS","HIST","SAME","CYL","POL","SPH","PSR","LEGO","LEGO1","LEGO2",
239 "SURF","SURF1","SURF2","SURF3","SURF4"
240};
241static const char* gOpt1D[12] =
242{
243 "","AH","B","C","E","E1","E2","E3","E4","L","P","*H"
244};
245static const char* gOpt2D[14] =
246{
247 "","ARR","BOX","COL","COL2","CONT","CONT0","CONT1","CONT2","CONT3",
248 "FB","BB","SCAT","PROF"
249};
250
251static const char* gOpenTypes[] = {"Root files", "*.root",
252 nullptr, nullptr };
253
254static const char* gMacroTypes[] = {"C++ macros", "*.C",
255 nullptr, nullptr };
256
257// Menu command id's
267
272
275
280
293
297 kAxis
299
300// button Id's
311 kBGLast
313
315
316////////////////////////////////////////////////////////////////////////////////
317/// TTreeViewer default constructor
318
319TTreeViewer::TTreeViewer(const char* treeName) :
320 TGMainFrame(nullptr,10,10,kVerticalFrame),
321 fDimension(0), fVarDraw(false), fScanMode(false),
322 fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
323 fCounting(false), fStopMapping(false), fEnableCut(false),fNexpressions(0)
324{
325 fTree = nullptr;
326 if (!gClient) return;
327 char command[128];
328 gROOT->ProcessLine("#ifndef GTV_DEFINED\n\
329 TTreeViewer *gTV = 0;\n\
330 TTree *tv__tree = 0;\n\
331 TList *tv__tree_list = 0;\n\
332 TFile *tv__tree_file = 0;\n\
333 #define GTV_DEFINED\n\
334 #endif");
335 snprintf(command,128, "gTV = (TTreeViewer*)0x%zx", (size_t)this);
336 gROOT->ProcessLine(command);
337 fTreeList = new TList;
338 gROOT->ProcessLine("tv__tree_list = new TList;");
339 fFilename = "";
340 gInterpreter->SaveContext();
342 SetTreeName(treeName);
343}
344
345////////////////////////////////////////////////////////////////////////////////
346
347TTreeViewer::TTreeViewer(const TTree *tree) :
348 TGMainFrame(nullptr, 10, 10, kVerticalFrame),
349 fDimension(0), fVarDraw(false), fScanMode(false),
350 fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
351 fCounting(false), fStopMapping(false), fEnableCut(false),fNexpressions(0)
352
353{
354 // TTreeViewer constructor with a pointer to a Tree
355
356 fTree = nullptr;
357 char command[128];
358 gROOT->ProcessLine("#ifndef GTV_DEFINED\n\
359 TTreeViewer *gTV = 0;\n\
360 TTree *tv__tree = 0;\n\
361 TList *tv__tree_list = 0;\n\
362 TFile *tv__tree_file = 0;\n\
363 #define GTV_DEFINED\n\
364 #endif");
365 snprintf(command,128, "gTV = (TTreeViewer*)0x%zx", (size_t)this);
366 gROOT->ProcessLine(command);
367 if (!tree) return;
368 fTreeList = new TList;
369 gROOT->ProcessLine("tv__tree_list = new TList;");
370 fFilename = "";
371 gInterpreter->SaveContext();
373 TDirectory *dirsav = gDirectory;
374 TDirectory *cdir = tree->GetDirectory();
375 if (cdir) cdir->cd();
376
377 SetTree((TTree *)tree);
378 // If the tree is a chain, the tree directory will be changed by SwitchTree
379 // (called by SetTreeName)
380 cdir = tree->GetDirectory();
381 if (cdir) {
382 if (cdir->GetFile()) fFilename = cdir->GetFile()->GetName();
383 }
384 if (dirsav) dirsav->cd();
385}
386////////////////////////////////////////////////////////////////////////////////
387/// Allow geting the tree from the context menu.
388
390{
391 if (!tree) return;
392 TTree *ftree;
393 if (fTreeList) {
394 if (fTreeList->FindObject(tree)) {
395 printf("Tree found\n");
396 TIter next(fTreeList);
397 Int_t index = 0;
398 while ((ftree = (TTree*)next())) {
399 if (ftree==tree) {printf("found at index %i\n", index);break;}
400 index++;
401 }
403 if (fTree != fMappedTree) {
404 // switch also the global "tree" variable
406 // map it on the right panel
407 MapTree(fTree);
408 fListView->Layout();
409 TGListTreeItem *base = nullptr;
410 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
411 TGListTreeItem *item = fLt->FindChildByName(parent, fTree->GetName());
413 fLt->HighlightItem(item);
415 }
416 return;
417 }
418 }
419 if (fTree != tree) {
420 fTree = tree;
421 // load the tree via the interpreter
422 char command[100];
423 command[0] = 0;
424 // define a global "tree" variable for the same tree
425 snprintf(command,100, "tv__tree = (TTree *)0x%zx;", (size_t)tree);
426 ExecuteCommand(command);
427 }
428 //--- add the tree to the list if it is not already in
430 ExecuteCommand("tv__tree_list->Add(tv__tree);");
431 //--- map this tree
432 TGListTreeItem *base = nullptr;
433 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
434 if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
435 ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
436 fTreeIndex++;
437 TGListTreeItem *lTreeItem = fLt->AddItem(parent, tree->GetName(), itemType,
438 gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
439 MapTree(fTree, lTreeItem, false);
440 fLt->OpenItem(parent);
441 fLt->HighlightItem(lTreeItem);
443
444 //--- map slider and list view
447 MapTree(fTree);
448 fListView->Layout();
449 SetFile();
450}
451////////////////////////////////////////////////////////////////////////////////
452/// Change the number of expression widgets.
453
455{
456 Int_t diff = expr - fNexpressions;
457 if (diff <= 0) return;
458 if (!fLVContainer) return;
459 for (Int_t i=0; i<TMath::Abs(diff); i++) NewExpression();
460}
461////////////////////////////////////////////////////////////////////////////////
462/// Set the name of the file where to redirect `<Scan>` output.
463
464void TTreeViewer::SetScanFileName(const char *name)
465{
467}
468////////////////////////////////////////////////////////////////////////////////
469/// Set the state of Scan check button.
470
472{
473 if (mode)
475 else
477}
478////////////////////////////////////////////////////////////////////////////////
479/// Assign the fTree member from existing tree, e.g. when calling
480/// tree->StartViewer() from the browser, or even from the command line.
481
482void TTreeViewer::SetTree(TTree *tree)
483{
484 if (!tree) return;
485 if (fTree != tree) {
486 fTree = tree;
487 // load the tree via the interpreter
488 // define a global "tree" variable for the same tree
489 TString command = TString::Format("tv__tree = (TTree *)0x%zx;", (size_t)tree);
490 ExecuteCommand(command.Data());
491 }
492 //--- add the tree to the list if it is not already in
494 ExecuteCommand("tv__tree_list->Add(tv__tree);");
495 //--- map this tree
496 TGListTreeItem *base = nullptr;
497 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
498 if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
499 ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
500 fTreeIndex++;
501 TGListTreeItem *lTreeItem = fLt->AddItem(parent, tree->GetName(), itemType,
502 gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
503 MapTree(fTree, lTreeItem, false);
504 fLt->OpenItem(parent);
505 fLt->HighlightItem(lTreeItem);
507
508 //--- map slider and list view
511 MapTree(fTree);
512 fListView->Layout();
513 SetFile();
514}
515////////////////////////////////////////////////////////////////////////////////
516/// Allow geting the tree from the context menu.
517
518void TTreeViewer::SetTreeName(const char* treeName)
519{
520 if (!treeName) return;
521 TTree *tree = (TTree *) gROOT->FindObject(treeName);
522 if (fTreeList) {
523 if (fTreeList->FindObject(treeName)) {
524 printf("Tree found\n");
525 TIter next(fTreeList);
526 Int_t index = 0;
527 while ((tree = (TTree*)next())) {
528 if (!strcmp(treeName, tree->GetName())) {printf("found at index %i\n", index);break;}
529 index++;
530 }
532 if (fTree != fMappedTree) {
533 // switch also the global "tree" variable
535 // map it on the right panel
536 MapTree(fTree);
537 fListView->Layout();
538 TGListTreeItem *base = nullptr;
539 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
540 TGListTreeItem *item = fLt->FindChildByName(parent, fTree->GetName());
542 fLt->HighlightItem(item);
544 }
545 return;
546 }
547 }
548 if (!tree) return;
549// ((TTreePlayer *)tree->GetPlayer())->SetViewer(this);
550 if (fTree != tree) {
551 fTree = tree;
552 // load the tree via the interpreter
553 // define a global "tree" variable for the same tree
554 TString command = TString::Format("tv__tree = (TTree *) gROOT->FindObject(\"%s\");", treeName);
555 ExecuteCommand(command.Data());
556 }
557 //--- add the tree to the list if it is not already in
559 ExecuteCommand("tv__tree_list->Add(tv__tree);");
560 //--- map this tree
561 TGListTreeItem *base = nullptr;
562 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
563 if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
564 ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
565 fTreeIndex++;
566 TGListTreeItem *lTreeItem = fLt->AddItem(parent, treeName, itemType,
567 gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
568 MapTree(fTree, lTreeItem, false);
569 fLt->OpenItem(parent);
570 fLt->HighlightItem(lTreeItem);
572
573 //--- map slider and list view
576 MapTree(fTree);
577 fListView->Layout();
578 SetFile();
579}
580////////////////////////////////////////////////////////////////////////////////
581/// Set file name containing the tree.
582
584{
585 if (!fTree) return;
586 TSeqCollection *list = gROOT->GetListOfFiles();
587 TTree *tree;
588 TIter next(list);
589 TObject *obj;
590 TFile *file;
591 while ((obj=next())) {
592 file = (TFile*)obj;
593 if (file) {
594 tree = (TTree*)file->Get(fTree->GetName());
595 if (tree) {
596 fFilename = file->GetName();
597 std::cout << "File name : "<< fFilename << std::endl;
598 return;
599 } else {
600 fFilename = "";
601 }
602 }
603 }
604 fFilename = "";
605}
606////////////////////////////////////////////////////////////////////////////////
607/// Create all viewer widgets.
608
610{
611 //--- timer & misc
612 fCounting = false;
613 fScanMode = false;
614 fEnableCut = true;
615 fTimer = new TTimer(this, 20, true);
616 fLastOption = "";
617 fSession = new TTVSession(this);
618 //--- cursors
619 fDefaultCursor = gVirtualX->CreateCursor(kPointer);
620 fWatchCursor = gVirtualX->CreateCursor(kWatch);
621 //--- colours
622 ULong_t color;
623 gClient->GetColorByName("blue",color);
624 //--- pictures for X, Y and Z expression items
625 fPicX = gClient->GetPicture("x_pic.xpm");
626 fPicY = gClient->GetPicture("y_pic.xpm");
627 fPicZ = gClient->GetPicture("z_pic.xpm");
628
629 //--- general context menu
630 fContextMenu = new TContextMenu("TreeViewer context menu","");
631 fMappedTree = nullptr;
632 fMappedBranch = nullptr;
633 fDialogBox = nullptr;
634 fDimension = 0;
635 fVarDraw = false;
636 fStopMapping = false;
637// fFilename = "";
638 fSourceFile = "treeviewer.C";
639 //--- lists : trees and widgets to be removed
640// fTreeList = 0;
641 fTreeIndex = 0;
642 fWidgets = new TList();
643 //--- create menus --------------------------------------------------------
644 //--- File menu
646 fFileMenu->AddEntry("&New canvas", kFileCanvas);
647 fFileMenu->AddEntry("Open &tree file...", kFileBrowse);
648 fFileMenu->AddEntry("&Load Library...", kFileLoadLibrary);
649 fFileMenu->AddEntry("&Open session", kFileOpenSession);
650 fFileMenu->AddEntry("&Save source...", kFileSaveMacro);
652 fFileMenu->AddEntry("&Print", kFilePrint);
653 fFileMenu->AddEntry("&Close", kFileClose);
655 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
656
658
659 //--- Edit menu
660 fEditMenu = new TGPopupMenu(gClient->GetRoot());
661 fEditMenu->AddEntry("&Expression...", kEditExpression);
662 fEditMenu->AddEntry("&Cut...", kEditCut);
663 fEditMenu->AddEntry("&Macro...", kEditMacro);
664 fEditMenu->AddEntry("E&Vent...", kEditEvent);
665
668 //---Run menu
669 fRunMenu = new TGPopupMenu(gClient->GetRoot());
670 fRunMenu->AddEntry("&Macro...", kRunMacro);
672 //--- Options menu
673 //--- General options
674 fOptionsGen = new TGPopupMenu(gClient->GetRoot());
677 fOptionsGen->AddEntry("Axis only", kOptionsGeneral+1); // "AXIS"
678 fOptionsGen->AddEntry("Contour only", kOptionsGeneral+2); // "HIST"
679 fOptionsGen->AddEntry("Superimpose", kOptionsGeneral+3); //"SAME"
680 fOptionsGen->AddEntry("Cylindrical", kOptionsGeneral+4); //"CYL"
681 fOptionsGen->AddEntry("Polar", kOptionsGeneral+5); //"POL"
682 fOptionsGen->AddEntry("Spherical", kOptionsGeneral+6); //"SPH"
683 fOptionsGen->AddEntry("PsRap/Phi", kOptionsGeneral+7); //"PSR"
684 fOptionsGen->AddEntry("Lego HLR", kOptionsGeneral+8); //"LEGO"
685 fOptionsGen->AddEntry("Lego HSR", kOptionsGeneral+9); //"LEGO1"
686 fOptionsGen->AddEntry("Lego Color", kOptionsGeneral+10); //"LEGO2"
687 fOptionsGen->AddEntry("Surface HLR", kOptionsGeneral+11); //"SURF"
688 fOptionsGen->AddEntry("Surface HSR", kOptionsGeneral+12); //"SURF1"
689 fOptionsGen->AddEntry("Surface Col", kOptionsGeneral+13); //"SURF2"
690 fOptionsGen->AddEntry("Surf+Cont", kOptionsGeneral+14); //"SURF3"
691 fOptionsGen->AddEntry("Gouraud", kOptionsGeneral+15); //"SURF4"
692 fOptionsGen->Associate(this);
693 //--- 1D options
694 fOptions1D = new TGPopupMenu(gClient->GetRoot());
695 fOptions1D->AddEntry("Default", kOptions1D);
697 fOptions1D->AddEntry("No labels/ticks", kOptions1D+1); // "AH"
698 fOptions1D->AddEntry("Bar chart", kOptions1D+2); // "B"
699 fOptions1D->AddEntry("Smooth curve", kOptions1D+3); // "C"
700 fOptions1D->AddEntry("Errors", kOptions1D+4); // "E"
701 fOptions1D->AddEntry("Errors 1", kOptions1D+5); // "E1"
702 fOptions1D->AddEntry("Errors 2", kOptions1D+6); // "E2"
703 fOptions1D->AddEntry("Errors 3", kOptions1D+7); // "E3"
704 fOptions1D->AddEntry("Errors 4", kOptions1D+8); // "E4"
705 fOptions1D->AddEntry("Line", kOptions1D+9); // "L"
706 fOptions1D->AddEntry("Markers", kOptions1D+10); // "P"
707 fOptions1D->AddEntry("Stars", kOptions1D+11); // "*H"
708 fOptions1D->Associate(this);
709 //--- 2D options
710 fOptions2D = new TGPopupMenu(gClient->GetRoot());
711 fOptions2D->AddEntry("Default", kOptions2D);
713 fOptions2D->AddEntry("Arrows", kOptions2D+1); // "ARR"
714 fOptions2D->AddEntry("Box/Surf", kOptions2D+2); // "BOX"
715 fOptions2D->AddEntry("Box/Color", kOptions2D+3); // "COL"
716 fOptions2D->AddEntry("Box/ColMap", kOptions2D+4); // "COLZ"
717 fOptions2D->AddEntry("Contour", kOptions2D+5); // "CONT"
718 fOptions2D->AddEntry("Contour 0", kOptions2D+6); // "CONT0"
719 fOptions2D->AddEntry("Contour 1", kOptions2D+7); // "CONT1"
720 fOptions2D->AddEntry("Contour 2", kOptions2D+8); // "CONT2"
721 fOptions2D->AddEntry("Contour 3", kOptions2D+9); // "CONT3"
722 fOptions2D->AddEntry("No front-box", kOptions2D+10); // "FB"
723 fOptions2D->AddEntry("No back-box", kOptions2D+11); // "BB"
724 fOptions2D->AddEntry("Scatter", kOptions2D+12); // "SCAT"
725 fOptions2D->AddEntry("Profile", kOptions2D+13); // "SCAT"
726 fOptions2D->Associate(this);
727
728 fOptionsMenu = new TGPopupMenu(gClient->GetRoot());
729 fOptionsMenu->AddPopup("&General Options...", fOptionsGen);
730 fOptionsMenu->AddPopup("&1D Options", fOptions1D);
731 fOptionsMenu->AddPopup("&2D Options", fOptions2D);
733 fOptionsMenu->AddEntry("&Reset options", kOptionsReset);
734 //--- Help menu
735 fHelpMenu = new TGPopupMenu(gClient->GetRoot());
736 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
737 fHelpMenu->AddEntry("&About TreeViewer...", kHelpAboutTV);
739 fHelpMenu->AddEntry("&Starting...", kHelpStart);
740 fHelpMenu->AddEntry("&Layout...", kHelpLayout);
741 fHelpMenu->AddEntry("&Open/Save", kHelpOpenSave);
742 fHelpMenu->AddEntry("&Dragging...", kHelpDragging);
743 fHelpMenu->AddEntry("&Editing expressions...",kHelpEditing);
744 fHelpMenu->AddEntry("&Session...", kHelpSession);
745 fHelpMenu->AddEntry("&User commands...", kHelpCommands);
746 fHelpMenu->AddEntry("&Context menus...", kHelpContext);
747 fHelpMenu->AddEntry("D&rawing...", kHelpDrawing);
748 fHelpMenu->AddEntry("&Macros...", kHelpMacros);
749
750 fFileMenu->Associate(this);
751 fEditMenu->Associate(this);
752 fRunMenu->Associate(this);
753 fOptionsMenu->Associate(this);
754 fHelpMenu->Associate(this);
755
756 //--- menubar layout hints
760 //--- create menubar and add popup menus
761 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
762
768
770 //--- toolbar ----------------------------------------------------------------
771 fToolBar = new TGToolBar(this, 10, 10, kHorizontalFrame);
773
774 TGLayoutHints *lo;
775 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
776 fWidgets->Add(lo);
777 //--- label for Command text entry
778 fBarLbl1 = new TGLabel(fToolBar,"Command");
780 //--- command text entry
782 fBarCommand->SetWidth(120);
783 fBarCommand->Associate(this);
784 fBarCommand->SetToolTipText("User commands executed via interpreter. Type <ENTER> to execute");
786 //--- first vertical separator
787 TGVertical3DLine *vSeparator = new TGVertical3DLine(fToolBar);
788 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,4,0,0);
789 fWidgets->Add(lo);
790 fWidgets->Add(vSeparator);
791 fToolBar->AddFrame(vSeparator, lo);
792
793 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
794 fWidgets->Add(lo);
795 //--- label for Option text entry
796 fBarLbl2 = new TGLabel(fToolBar,"Option");
798 //--- drawing option text entry
800 fBarOption->SetWidth(100);
801 fBarOption->Associate(this);
802 fBarOption->SetToolTipText("Histogram graphics option. Type option here and click <Draw> (or <ENTER> to update current histogram).");
804 //--- second vertical separator
805 vSeparator = new TGVertical3DLine(fToolBar);
806 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,4,0,0);
807 fWidgets->Add(lo);
808 fWidgets->Add(vSeparator);
809 fToolBar->AddFrame(vSeparator, lo);
810
811 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
812 fWidgets->Add(lo);
813 //--- label for Histogram text entry
814 fBarLbl3 = new TGLabel(fToolBar,"Histogram");
816
817 //--- histogram name text entry
818 lo = new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 4,4,0,0);
819 fWidgets->Add(lo);
820 fBarHist = new TGTextEntry(fToolBar, new TGTextBuffer(100));
823 fBarHist->SetText("htemp");
825
826 //--- Hist check button
827 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
828 fWidgets->Add(lo);
829 fBarH = new TGCheckButton(fToolBar, "Hist");
830 fBarH->SetToolTipText("Checked : redraw only current histogram");
832 fToolBar->AddFrame(fBarH, lo);
833 //--- Scan check button
834 fBarScan = new TGCheckButton(fToolBar, "Scan");
836 fBarScan->SetToolTipText("Check to redirect TTree::Scan command in a file");
838 //--- Rec check button
839 fBarRec = new TGCheckButton(fToolBar, "Rec");
841 fBarRec->SetToolTipText("Check to record commands in history file and be verbose");
843 //--- 1'st horizontal tool bar separator ----------------------------------------
844 TGHorizontal3DLine *toolBarSep = new TGHorizontal3DLine(this);
845 fWidgets->Add(toolBarSep);
846 AddFrame(toolBarSep, fBarLayout);
848 //--- 2'nd horizontal tool bar separator ----------------------------------------
849 toolBarSep = new TGHorizontal3DLine(this);
850 fWidgets->Add(toolBarSep);
851 AddFrame(toolBarSep, fBarLayout);
852
853 //--- Horizontal mother frame ---------------------------------------------------
854 fHf = new TGHorizontalFrame(this, 10, 10);
855 //--- Vertical frames
857// fSlider->SetBackgroundColor(color);
858 fSlider->Associate(this);
859
860 //--- fV1 -----------------------------------------------------------------------
861 fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
863
864 fLbl1 = new TGLabel(fTreeHdr, "Current Folder");
865 lo = new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY, 3, 0, 0, 0);
866 fWidgets->Add(lo);
867 fTreeHdr->AddFrame(fLbl1, lo);
868
869 lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 1, 0);
870 fWidgets->Add(lo);
871 fV1->AddFrame(fTreeHdr, lo);
872
873 //--- tree view canvas on the left
875 //--- container frame
877 GetWhitePixel());
878 fLt->Associate(this);
880
881 lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2,0,0,0);
882 fWidgets->Add(lo);
883 fV1->AddFrame(fTreeView, lo);
884
885 //--- button horizontal frame
887
888 //--- DRAW button
889 fPicDraw = gClient->GetPicture("draw_t.xpm");
891 fDRAW->SetToolTipText("Draw current selection");
892 fDRAW->Associate(this);
893
894 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
895 fWidgets->Add(lo);
896 fHpb->AddFrame(fDRAW, lo);
897
898 //--- SPIDER button
899 fSPIDER = new TGTextButton(fHpb,"SPIDER");
900 fSPIDER->SetToolTipText("Scan current selection using a spider plot");
901 fSPIDER->Associate(this);
902
903 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
904 fWidgets->Add(lo);
905 fHpb->AddFrame(fSPIDER,lo);
906 //---connect SPIDER button to ExecuteScan() method
907 fSPIDER->Connect("Clicked()","TTreeViewer",this,"ExecuteSpider()");
908
909 //--- STOP button (breaks current operation)
910// fPicStop = gClient->GetPicture("mb_stop_s.xpm");
911 fPicStop = gClient->GetPicture("stop_t.xpm");
913 fSTOP->SetToolTipText("Abort current operation");
914 fSTOP->Associate(this);
915
916 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
917 fWidgets->Add(lo);
918 fHpb->AddFrame(fSTOP, lo);
919
920 //--- REFR button (breaks current operation)
921 fPicRefr = gClient->GetPicture("refresh2.xpm");
923 fREFR->SetToolTipText("Update the tree viewer");
924 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
925 fWidgets->Add(lo);
926 fHpb->AddFrame(fREFR, lo);
927 //---connect REFR button to DoRefresh() method
928 fREFR->Connect("Clicked()", "TTreeViewer", this, "DoRefresh()");
929
930 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,2,2);
931 fWidgets->Add(lo);
932 fV1->AddFrame(fHpb, lo);
933
934 //--- fV2
935 fV2 = new TGVerticalFrame(fHf, 10, 10);
937 fLbl2 = new TGLabel(fListHdr, "Current Tree: ");
938 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 0, 0, 0);
939 fWidgets->Add(lo);
940 fListHdr->AddFrame(fLbl2, lo);
941
942 //--- progress bar
946 lo = new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 2,2,4,2);
947 fWidgets->Add(lo);
950 fWidgets->Add(lo);
951 fV2->AddFrame(fListHdr, lo);
952
955 fWidgets->Add(lo);
956 fHf->AddFrame(fSlider, lo);
958 fWidgets->Add(lo);
959 fHf->AddFrame(fV1, lo);
960
961 //--- vertical splitter
962 TGVSplitter *splitter = new TGVSplitter(fHf);
963 splitter->SetFrame(fV1,true);
965 fWidgets->Add(splitter);
966 fWidgets->Add(lo);
967 fHf->AddFrame(splitter,lo);
968
969
970
971 //-- listview for the content of the tree/branch -----------------------------
972 fListView = new TGListView(fListHdr,400,300);
973 //--- container frame
975 fLVContainer->Associate(this);
977 fLVContainer->SetViewer(this);
983 fWidgets->Add(lo);
984
986
988 fWidgets->Add(lo);
989 fHf->AddFrame(fV2,lo);
990
991 AddFrame(fHf, lo);
992 //--- 3rd horizontal tool bar separator ----------------------------------------
993 toolBarSep = new TGHorizontal3DLine(this);
994 fWidgets->Add(toolBarSep);
995 AddFrame(toolBarSep, fBarLayout);
996
997 //--- label for IList text entry
998 fBFrame = new TGHorizontalFrame(this,10,10);
999 fBLbl4 = new TGLabel(fBFrame,"IList");
1000 lo = new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2,2,2,2);
1001 fWidgets->Add(lo);
1002 fBFrame->AddFrame(fBLbl4, lo);
1003 //--- IList text entry
1004 fBarListIn = new TGTextEntry(fBFrame, new TGTextBuffer(100));
1005 fBarListIn->SetWidth(60);
1006 fBarListIn->SetToolTipText("Name of a previously created event list");
1008 //--- label for OList text entry
1009 fBLbl5 = new TGLabel(fBFrame,"OList");
1010 fBFrame->AddFrame(fBLbl5, lo);
1011 //--- OList text entry
1013 fBarListOut->SetWidth(60);
1014 fBarListOut->SetToolTipText("Output event list. Use <Draw> to generate it.");
1016 //--- Status bar
1017 fStatusBar = new TGStatusBar(fBFrame, 10, 10);
1018 fStatusBar->SetWidth(200);
1019 fStatusBar->Draw3DCorner(false);
1021 fWidgets->Add(lo);
1023 //--- RESET button
1024 fReset = new TGTextButton(fBFrame,"RESET",kRESET);
1025 fReset->SetToolTipText("Reset variable's fields and drawing options");
1026 fReset->Associate(this);
1027 lo = new TGLayoutHints(kLHintsTop | kLHintsRight, 2,2,2,2);
1028 fWidgets->Add(lo);
1029 fBFrame->AddFrame(fReset,lo);
1030 //--- group of buttons for session handling
1032 gClient->GetPicture("first_t.xpm"), kBGFirst);
1033 fBGFirst->SetToolTipText("First record");
1034 fBGFirst->Associate(this);
1036 gClient->GetPicture("previous_t.xpm"), kBGPrevious);
1037 fBGPrevious->SetToolTipText("Previous record");
1038 fBGPrevious->Associate(this);
1040 gClient->GetPicture("record_t.xpm"), kBGRecord);
1041 fBGRecord->SetToolTipText("Record");
1042 fBGRecord->Associate(this);
1044 gClient->GetPicture("next_t.xpm"), kBGNext);
1045 fBGNext->SetToolTipText("Next record");
1046 fBGNext->Associate(this);
1048 gClient->GetPicture("last_t.xpm"), kBGLast);
1049 fBGLast->SetToolTipText("Last record");
1050 fBGLast->Associate(this);
1051
1052 fCombo = new TGComboBox(fBFrame, 0);
1054 fCombo->SetWidth(100);
1055 fCombo->Associate(this);
1056
1057 lo = new TGLayoutHints(kLHintsCenterY | kLHintsRight, 0,0,2,0);
1058 fWidgets->Add(lo);
1059 fBFrame->AddFrame(fCombo, lo);
1060 fBFrame->AddFrame(fBGLast, lo);
1061 fBFrame->AddFrame(fBGNext, lo);
1065 lo = new TGLayoutHints(kLHintsExpandX,2,2,2,0);
1066 fWidgets->Add(lo);
1067 AddFrame(fBFrame,lo);
1068
1069 // map the window
1070 SetWindowName("TreeViewer");
1071 MapSubwindows();
1073 MapWindow();
1074
1075 // put default items in the listview on the right
1076 const TGPicture *pic, *spic;
1077
1079 TTVLVEntry* entry;
1080 Char_t symbol;
1081 entry = new TTVLVEntry(fLVContainer,fPicX,fPicX,new TGString(),nullptr,kLVSmallIcons);
1082 symbol = 'X';
1083 entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1084 entry->SetToolTipText("X expression. Drag and drop expressions here");
1085 //--- X item
1086 fLVContainer->AddThisItem(entry);
1087 entry->Empty();
1088 entry->MapWindow();
1089
1090 entry = new TTVLVEntry(fLVContainer,fPicY,fPicY,new TGString(),nullptr,kLVSmallIcons);
1091 symbol = 'Y';
1092 entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1093 entry->SetToolTipText("Y expression. Drag and drop expressions here");
1094 //--- Y item
1095 fLVContainer->AddThisItem(entry);
1096 entry->Empty();
1097 entry->MapWindow();
1098
1099 entry = new TTVLVEntry(fLVContainer,fPicZ,fPicZ,new TGString(),nullptr,kLVSmallIcons);
1100 symbol = 'Z';
1101 entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1102 entry->SetToolTipText("Z expression. Drag and drop expressions here");
1103 //--- Z item
1104 fLVContainer->AddThisItem(entry);
1105 entry->Empty();
1106 entry->MapWindow();
1107
1108 pic = gClient->GetPicture("cut_t.xpm");
1109 spic = gClient->GetPicture("cut_t.xpm");
1110 entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString(),nullptr,kLVSmallIcons);
1112 entry->SetToolTipText("Active cut. Double-click to enable/disable");
1113 //--- Cut item (scissors icon)
1114 fLVContainer->AddThisItem(entry);
1115 entry->Empty();
1116 entry->MapWindow();
1117
1118 pic = gClient->GetPicture("pack_t.xpm");
1119 spic = gClient->GetPicture("pack-empty_t.xpm");
1120 entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString("Scan box"),nullptr,kLVSmallIcons);
1122 entry->SetToolTipText("Drag and drop expressions/leaves here. Double-click to scan. Check <Scan> to redirect on file.");
1123 //--- Scan Box
1124 fLVContainer->AddThisItem(entry);
1125 entry->MapWindow();
1126 entry->SetTrueName("");
1127
1128 //--- 10 expression items
1129 fNexpressions = 10;
1130 for (Int_t i=0; i<fNexpressions; i++) {
1131 pic = gClient->GetPicture("expression_t.xpm");
1132 spic = gClient->GetPicture("expression_t.xpm");
1133 entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString(),nullptr,kLVSmallIcons);
1135 entry->SetToolTipText("User defined expression/cut. Double-click to edit");
1136 fLVContainer->AddThisItem(entry);
1137 entry->Empty();
1138 entry->MapWindow();
1139 }
1140
1141 fListView->Layout();
1142 fListView->Resize();
1143// EmptyAll();
1144 // map the tree if it was supplied in the constructor
1145
1146 if (!fTree) {
1147 fSlider->SetRange(0LL,1000000LL);
1148 fSlider->SetPosition(0LL,1000000LL);
1149 } else {
1150 fSlider->SetRange(0LL,fTree->GetEntries()-1);
1152 }
1153 PrintEntries();
1156 ActivateButtons(false, false, false, false);
1157
1158 // map the window
1159 ///SetWindowName("TreeViewer");
1160 MapSubwindows();
1162 MapWindow();
1163}
1164
1165////////////////////////////////////////////////////////////////////////////////
1166/// TTreeViewer destructor.
1167
1169{
1170 if (!gClient) return;
1171 gClient->FreePicture(fPicX);
1172 gClient->FreePicture(fPicY);
1173 gClient->FreePicture(fPicZ);
1174 gClient->FreePicture(fPicDraw);
1175 gClient->FreePicture(fPicStop);
1176 gClient->FreePicture(fPicRefr);
1177
1179 if (fDialogBox) delete fDialogBox;
1180
1181 delete fContextMenu;
1182
1183 delete fBarLbl1;
1184 delete fBarLbl2;
1185 delete fBarLbl3;
1186 delete fBLbl4;
1187 delete fBLbl5;
1188 delete fBarCommand;
1189 delete fBarOption;
1190 delete fBarHist;
1191 delete fBarListIn;
1192 delete fBarListOut;
1193
1194 delete fBarH;
1195 delete fBarScan;
1196 delete fBarRec;
1197
1198 delete fToolBar;
1199
1200 delete fSlider;
1201 delete fV1;
1202 delete fV2;
1203 delete fLbl1;
1204 delete fLbl2;
1205 delete fHf;
1206 delete fTreeHdr;
1207 delete fListHdr;
1208 delete fLt;
1209 delete fTreeView;
1210 delete fLVContainer;
1211 delete fListView;
1212
1213 delete fProgressBar;
1214 delete fHpb;
1215
1216 delete fDRAW;
1217 delete fSPIDER;
1218 delete fSTOP;
1219 delete fReset;
1220 delete fBGFirst;
1221 delete fBGPrevious;
1222 delete fBGRecord;
1223 delete fBGNext;
1224 delete fBGLast;
1225 delete fCombo;
1226 delete fBFrame;
1227
1228 delete fMenuBar;
1229 delete fFileMenu;
1230 delete fEditMenu;
1231
1232 delete fOptionsGen;
1233 delete fOptions1D;
1234 delete fOptions2D;
1235 delete fOptionsMenu;
1236 delete fHelpMenu;
1237 delete fMenuBarLayout;
1238 delete fMenuBarItemLayout;
1239 delete fMenuBarHelpLayout;
1240 delete fBarLayout;
1241
1242 fWidgets->Delete();
1243 delete fWidgets;
1244 if (fTreeList) {
1245 delete fTreeList;
1246 }
1247 delete fTimer;
1248 delete fSession;
1249}
1250
1251////////////////////////////////////////////////////////////////////////////////
1252/// Enable/disable session buttons.
1253
1254void TTreeViewer::ActivateButtons(bool first, bool previous,
1255 bool next, bool last)
1256{
1257 if (first) fBGFirst->SetState(kButtonUp);
1259 if (previous) fBGPrevious->SetState(kButtonUp);
1261 if (next) fBGNext->SetState(kButtonUp);
1263 if (last) fBGLast->SetState(kButtonUp);
1265}
1266
1267////////////////////////////////////////////////////////////////////////////////
1268/// Apply Cut
1269
1270const char* TTreeViewer::Cut()
1271{
1272 return fLVContainer->Cut();
1273}
1274
1275////////////////////////////////////////////////////////////////////////////////
1276/// returns scanlist
1277
1278const char* TTreeViewer::ScanList()
1279{
1280 return fLVContainer->ScanList();
1281}
1282
1283////////////////////////////////////////////////////////////////////////////////
1284/// Set current session
1285
1287{
1288 if (session) {
1289 delete fSession;
1290 fSession = session;
1291 }
1292}
1293
1294////////////////////////////////////////////////////////////////////////////////
1295/// Empty the bracket content of a string.
1296
1297const char* TTreeViewer::EmptyBrackets(const char* name)
1298{
1299 TString stripped(name);
1300 if (!stripped.Contains("[")) return name;
1301 TString retstr(name);
1302 TObjString *objstr;
1303 Int_t index = 0;
1304 while (stripped.Index("[", index) != kNPOS) {
1305 Int_t start = stripped.Index("[", index);
1306 Int_t end = stripped.Index("]", index);
1307 if (end == kNPOS) {
1308 objstr = new TObjString(retstr.Data());
1309 fWidgets->Add(objstr);
1310 return (objstr->String()).Data();
1311 }
1312 index = start+2;
1313 retstr = stripped.Remove(start+1, end-start-1);
1314 stripped = retstr;
1315 }
1316 objstr = new TObjString(retstr.Data());
1317 fWidgets->Add(objstr);
1318 return (objstr->String()).Data();
1319}
1320
1321////////////////////////////////////////////////////////////////////////////////
1322/// Clear the content of all items in the list view.
1323
1325{
1327}
1328
1329////////////////////////////////////////////////////////////////////////////////
1330/// Empty the content of the selected expression.
1331
1332void TTreeViewer::Empty()
1333{
1334 void *p = nullptr;
1335 TTVLVEntry *item = nullptr;
1336 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == nullptr) {
1337 Warning("Empty", "No item selected.");
1338 return;
1339 }
1340 ULong_t *itemType = (ULong_t *) item->GetUserData();
1341 if (!(*itemType & kLTExpressionType)) {
1342 Warning("Empty", "Not expression type.");
1343 return;
1344 }
1345 if (*itemType & kLTPackType) {
1346 item->SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
1347 item->SetTrueName("");
1348 return;
1349 }
1350 item->Empty();
1351}
1352
1353////////////////////////////////////////////////////////////////////////////////
1354/// Get the item from a specific position.
1355
1357{
1359}
1360
1361////////////////////////////////////////////////////////////////////////////////
1362/// Get the list of expression items.
1363
1365{
1366 return fLVContainer->ExpressionList();
1367}
1368
1369////////////////////////////////////////////////////////////////////////////////
1370/// Compute dimension of the histogram.
1371
1373{
1374 fDimension = 0;
1375 if (Ex() && strlen(Ex())) fDimension++;
1376 if (Ey() && strlen(Ey())) fDimension++;
1377 if (Ez() && strlen(Ez())) fDimension++;
1378 return fDimension;
1379}
1380
1381////////////////////////////////////////////////////////////////////////////////
1382/// Called when the DRAW button is executed.
1383
1385{
1386 TString varexp;
1387 TString command;
1388 Int_t dimension = 0;
1389 TString alias[3];
1390 TTVLVEntry *item;
1391 Int_t i;
1392 // fill in expressions
1393 if (fVarDraw) {
1394 void *p = nullptr;
1395 dimension = 1;
1396 if (!(item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p))) return;
1397 alias[0] = item->GetAlias();
1398 if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1399 varexp = item->ConvertAliases();
1400 } else {
1401 if (Ez() && strlen(Ez())) {
1402 dimension++;
1403 varexp = Ez();
1404 item = ExpressionItem(2);
1405 alias[2] = item->GetAlias();
1406 if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1407 }
1408 if ((Ez() && strlen(Ez())) && ((Ex() &&strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1409 if (Ey() && strlen(Ey())) {
1410 dimension++;
1411 varexp += Ey();
1412 item = ExpressionItem(1);
1413 alias[1] = item->GetAlias();
1414 if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1415 }
1416 if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1417 if (Ex () && strlen(Ex())) {
1418 dimension++;
1419 varexp += Ex();
1420 item = ExpressionItem(0);
1421 alias[0] = item->GetAlias();
1422 if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1423 }
1424 }
1425 if (!dimension && !fScanMode) {
1426 Warning("ExecuteDraw", "Nothing to draw on X,Y,Z.");
1427 return;
1428 }
1429 // find ListIn
1430 fTree->SetEventList(nullptr);
1431 TEventList *elist = nullptr;
1432 if (strlen(fBarListIn->GetText())) {
1433 elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1434 if (elist) fTree->SetEventList(elist);
1435 }
1436 // find ListOut
1437 if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1438 // find histogram name
1439 if (strcmp("htemp", fBarHist->GetText())) {
1440 varexp += ">>";
1441 varexp += fBarHist->GetText();
1442 }
1443 // find canvas/pad where to draw
1444 auto pad = gROOT->GetSelectedPad();
1445 if (pad) pad->cd();
1446 // find graphics option
1447 const char* gopt = fBarOption->GetText();
1448 // just in case a previous interrupt was posted
1449 gROOT->SetInterrupt(false);
1450 // check if cut is enabled
1451 const char *cut = "";
1452 if (fEnableCut) cut = Cut();
1453
1454 // get entries to be processed
1456 fSlider->GetMinPositionD() + 1);
1457 Long64_t firstentry = fSlider->GetMinPositionL();
1458//printf("firstentry=%lld, nentries=%lld\n",firstentry,nentries);
1459 // check if Scan is checked and if there is something in the box
1460 if (fScanMode) {
1461// fBarScan->SetState(kButtonUp);
1462 fScanMode = false;
1463 if (ScanList() && strlen(ScanList())) varexp = ScanList();
1464 command = TString::Format("tv__tree->Scan(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1465 varexp.Data(), cut, gopt, nentries, firstentry);
1466 if (fBarScan->GetState() == kButtonDown) {
1468 } else {
1470 }
1471 ExecuteCommand(command.Data(), true);
1472 return;
1473 }
1474 // check if only histogram has to be updated
1475 if (fBarH->GetState() == kButtonDown) {
1476 // reset 'Hist' mode
1478 TH1 *hist = fTree->GetHistogram();
1479 if (hist && gPad) {
1480 //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1481 if (hist) {
1482 // check if graphic option was modified
1483 TString last(fLastOption);
1484 TString current(gopt);
1485 current.ToUpper();
1486 last.ToUpper();
1487 if (current == last) {
1488 gPad->Update();
1489 return;
1490 }
1491 if (dimension == 3 && strlen(gopt)) {
1492 std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1493 return;
1494 }
1495 std::cout << " Graphics option for current histogram changed to " << gopt << std::endl;
1496 hist->Draw(gopt);
1498 gPad->Update();
1499 return;
1500 }
1501 }
1502 }
1503 // send draw command
1505 //if (!gopt[0] && dimension!=3) {
1506 // gopt = "hist";
1507 // fLastOption = "hist";
1508 //}
1509 if (dimension == 3 && strlen(gopt)) {
1510 std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1511 gopt = "";
1512 fLastOption = "";
1513 }
1514 command = TString::Format("tv__tree->Draw(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1515 varexp.Data(), cut, gopt, nentries, firstentry);
1516 if (fCounting) return;
1517 fCounting = true;
1518 fTree->SetTimerInterval(200);
1519 fTimer->TurnOn();
1520 ExecuteCommand(command.Data());
1522 fTimer->TurnOff();
1524 fCounting = false;
1527 TH1 *hist = fTree->GetHistogram();
1528 if (hist) {
1529 // put expressions aliases on axes
1530 Int_t current = 0;
1531 for (i=0; i<3; i++) {
1532 if (alias[i].Length()) {
1533 if (i != current) {
1534 alias[current] = alias[i];
1535 alias[i] = "";
1536 }
1537 current++;
1538 }
1539 }
1540 //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1541 TAxis *axis[3];
1542 axis[0] = hist->GetXaxis();
1543 axis[1] = hist->GetYaxis();
1544 axis[2] = hist->GetZaxis();
1545 for (Int_t ind=0; ind<3; ind++) axis[ind]->SetTitle(alias[ind].Data());
1546 }
1547 if (gPad) gPad->Update();
1548}
1549
1550////////////////////////////////////////////////////////////////////////////////
1551/// Draw a spider plot for the selected entries.
1552
1554{
1555 TString varexp;
1556 Int_t dimension = 0;
1557 TString alias[3];
1558 TTVLVEntry *item;
1559 bool previousexp = false;
1560 // fill in expressions
1561 if (Ez() && strlen(Ez())) {
1562 previousexp = true;
1563 dimension++;
1564 varexp = Ez();
1565 item = ExpressionItem(2);
1566 alias[2] = item->GetAlias();
1567 if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1568 }
1569 if ((Ez() && strlen(Ez())) && ((Ex() && strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1570 if (Ey() && strlen(Ey())) {
1571 previousexp = true;
1572 dimension++;
1573 varexp += Ey();
1574 item = ExpressionItem(1);
1575 alias[1] = item->GetAlias();
1576 if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1577 }
1578 if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1579 if (Ex() && strlen(Ex())) {
1580 previousexp = true;
1581 dimension++;
1582 varexp += Ex();
1583 item = ExpressionItem(0);
1584 alias[0] = item->GetAlias();
1585 if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1586 }
1587 for(Int_t i=0;i<10;++i){
1588 if(En(i+5) && strlen(En(i+5))){
1589 ++dimension;
1590 if(previousexp){
1591 varexp += ":";
1592 varexp += En(i+5);
1593 } else varexp = En(i+5);
1594 previousexp = true;
1595 }
1596 }
1597 if (dimension<3) {
1598 Warning("ExecuteSpider", "Need at least 3 variables");
1599 return;
1600 }
1601 // find ListIn
1602 fTree->SetEventList(nullptr);
1603 TEventList *elist = nullptr;
1604 if (strlen(fBarListIn->GetText())) {
1605 elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1606 if (elist) fTree->SetEventList(elist);
1607 }
1608 // find ListOut
1609 if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1610 // find canvas/pad where to draw
1611 auto pad = gROOT->GetSelectedPad();
1612 if (pad) pad->cd();
1613 // find graphics option
1614 const char* gopt = fBarOption->GetText();
1615 // just in case a previous interrupt was posted
1616 gROOT->SetInterrupt(false);
1617 // check if cut is enabled
1618 const char *cut = "";
1619 if (fEnableCut) cut = Cut();
1620
1621 // get entries to be processed
1623 fSlider->GetMinPositionD() + 1);
1624 Long64_t firstentry = fSlider->GetMinPositionL();
1625
1626 // create the spider plot
1627
1628 TSpider* spider = new TSpider(fTree,varexp.Data(),cut,Form("%s spider average",gopt),nentries,firstentry);
1629 spider->Draw();
1630
1631 if (gPad) gPad->Update();
1632}
1633
1634////////////////////////////////////////////////////////////////////////////////
1635/// Get the expression to be drawn on X axis.
1636
1637const char* TTreeViewer::Ex()
1638{
1639 return fLVContainer->Ex();
1640}
1641
1642////////////////////////////////////////////////////////////////////////////////
1643/// Get the expression to be drawn on Y axis.
1644
1645const char* TTreeViewer::Ey()
1646{
1647 return fLVContainer->Ey();
1648}
1649
1650////////////////////////////////////////////////////////////////////////////////
1651/// Get the expression to be drawn on Z axis.
1652
1653const char* TTreeViewer::Ez()
1654{
1655 return fLVContainer->Ez();
1656}
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Get the n'th expression
1660
1661const char* TTreeViewer::En(Int_t n)
1662{
1664 if(e) return e->ConvertAliases();
1665 return "";
1666}
1667
1668////////////////////////////////////////////////////////////////////////////////
1669/// Start the expression editor.
1670
1672{
1673 void *p = nullptr;
1674 // get the selected item
1675 TTVLVEntry *item = nullptr;
1676 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == nullptr) {
1677 Warning("EditExpression", "No item selected.");
1678 return;
1679 }
1680 // check if it is an expression
1681 ULong_t *itemType = (ULong_t *) item->GetUserData();
1682 if (!(*itemType & kLTExpressionType)) {
1683 Warning("EditExpression", "Not expression type.");
1684 return;
1685 }
1686 // check if the editor is already active
1688 if (!fDialogBox) {
1689 fDialogBox = new TGSelectBox(fClient->GetRoot(), this, fV1->GetWidth() - 10);
1690 }
1691 // copy current item data into editor boxes
1692 fDialogBox->SetEntry(item);
1693 fDialogBox->SetWindowName("Expression editor");
1694 // check if you are editing the cut expression
1695 if (*itemType & kLTCutType || item->IsCut()) {
1696 fDialogBox->SetLabel("Selection");
1697 } else {
1698 fDialogBox->SetLabel("Expression");
1699 }
1700}
1701
1702////////////////////////////////////////////////////////////////////////////////
1703/// Get use of TTree::MakeSelector() via the context menu.
1704
1705Int_t TTreeViewer::MakeSelector(const char* selector)
1706{
1707 if (!fTree) return 0;
1708 return fTree->MakeSelector(selector);
1709}
1710
1711////////////////////////////////////////////////////////////////////////////////
1712/// Get use of TTree::Process() via the context menu.
1713
1715{
1716 if (!fTree) return 0;
1717 return fTree->Process(filename, option, nentries, firstentry);
1718}
1719
1720////////////////////////////////////////////////////////////////////////////////
1721/// Get graph option
1722
1723const char *TTreeViewer::GetGrOpt()
1724{
1725 return fBarOption->GetText();
1726}
1727
1728////////////////////////////////////////////////////////////////////////////////
1729/// Set graph option
1730
1731void TTreeViewer::SetGrOpt(const char *option)
1732{
1734}
1735
1736////////////////////////////////////////////////////////////////////////////////
1737/// Return true if scan is redirected
1738
1740{
1741 return (fBarScan->GetState()==kButtonDown);
1742}
1743
1744////////////////////////////////////////////////////////////////////////////////
1745/// Remove the selected item from the list.
1746
1748{
1749 void *p = nullptr;
1750 TTVLVEntry *item = nullptr;
1751 // get the selected item
1752 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == nullptr) {
1753 Warning("RemoveItem", "No item selected.");
1754 return;
1755 }
1756 // check if it is removable
1757 ULong_t *itemType = (ULong_t *) item->GetUserData();
1758 if (!(*itemType & kLTDragType)) {
1759 Warning("RemoveItem", "Not removable type.");
1760 return;
1761 }
1762 fLVContainer->RemoveItem(item);
1763 fListView->Layout();
1764}
1765
1766////////////////////////////////////////////////////////////////////////////////
1767/// Remove the current record.
1768
1770{
1772}
1773
1774////////////////////////////////////////////////////////////////////////////////
1775/// This function is called by the fTimer object.
1776
1778{
1779 if (fCounting) {
1780 Double_t first = fSlider->GetMinPositionD();
1782 Double_t current = (Double_t)fTree->GetReadEntry();
1783 Double_t percent = (current-first+1)/(last-first+1);
1786 }
1787 timer->Reset();
1788 return false;
1789}
1790
1791////////////////////////////////////////////////////////////////////////////////
1792/// Handle menu and other commands generated.
1793
1795{
1796 TRootHelpDialog *hd;
1797 TTVRecord *record;
1798
1799 switch (GET_MSG(msg)) {
1800 case kC_VSLIDER :
1801 // handle slider messages
1802 PrintEntries();
1803 break;
1804 case kC_TEXTENTRY:
1805 switch (GET_SUBMSG(msg)) {
1806 // handle enter posted by the Command text entry
1807 case kTE_ENTER:
1808 if ((ERootTreeViewerCommands)parm1 == kBarCommand) {
1810 fBarCommand->Clear();
1811 }
1812 if ((ERootTreeViewerCommands)parm1 == kBarOption) {
1813 fVarDraw = false;
1815 ExecuteDraw();
1817 }
1818 break;
1819 default:
1820 break;
1821 }
1822 break;
1823 case kC_LISTTREE:
1824 switch (GET_SUBMSG(msg)) {
1825 // handle mouse messages in the list-tree (left panel)
1826 case kCT_ITEMCLICK :
1827 // tell coverity that parm1 is a Long_t, and not an enum (even
1828 // if we compare it with an enum value) and the meaning of
1829 // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
1830 // coverity[mixed_enums]
1831 if (((EMouseButton)parm1==kButton1) ||
1832 ((EMouseButton)parm1==kButton3)) {
1833 TGListTreeItem *ltItem = nullptr;
1834 // get item that sent this
1835 if ((ltItem = fLt->GetSelected()) != nullptr) {
1836 // get item type
1837 ULong_t *itemType = (ULong_t *)ltItem->GetUserData();
1838 if (!itemType)
1839 break;
1840 if (*itemType & kLTTreeType) {
1841 // already mapped tree item clicked
1842 Int_t index = (Int_t)(*itemType >> 8);
1844 if (fTree != fMappedTree) {
1845 // switch also the global "tree" variable
1847 // map it on the right panel
1848 MapTree(fTree);
1849 fListView->Layout();
1850 }
1851 // activate context menu for this tree
1852 if (parm1 == kButton3) {
1853 Int_t x = (Int_t)(parm2 &0xffff);
1854 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1856 }
1857 }
1858
1859 if (*itemType & kLTBranchType) {
1860 // branch item clicked
1861 SetParentTree(ltItem);
1862 if (!fTree) break; // really needed ?
1863 TBranch *branch = fTree->GetBranch(ltItem->GetText());
1864 if (!branch) break;
1865 // check if it is mapped on the right panel
1866 if (branch != fMappedBranch) {
1868 MapBranch(branch);
1869 fStopMapping = false;
1870 fListView->Layout();
1871 }
1872 // activate context menu for this branch (no *MENU* methods ):)
1873 if (parm1 == kButton3) {
1874 Int_t x = (Int_t)(parm2 &0xffff);
1875 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1876 fContextMenu->Popup(x, y, branch);
1877 }
1878 }
1879
1880 if (*itemType & kLTLeafType) {
1881 // leaf item clicked
1882 SetParentTree(ltItem);
1883 if (!fTree) break;
1884 // find parent branch
1885 TBranch *branch = fTree->GetBranch(ltItem->GetParent()->GetText());
1886 if (!branch) {
1887 if (fTree != fMappedTree) {
1889 MapTree(fTree);
1890 fListView->Layout();
1891 }
1892 } else {
1893 // check if it is already mapped
1894 if (branch!=fMappedBranch) {
1896 MapBranch(branch);
1897 fStopMapping = false;
1898 fListView->Layout();
1899 }
1900 }
1901 // select corresponding leaf on the right panel
1902 fLVContainer->SelectItem(ltItem->GetText());
1903 if (parm1 == kButton3) {
1904 // activate context menu for this leaf
1906 }
1907 }
1908 }
1909 }
1910 break;
1911 case kCT_ITEMDBLCLICK :
1913 if (parm1 == kButton1) {
1914 // execute double-click action for corresponding item in the right panel
1916 }
1917 break;
1918 default:
1919 break;
1920 }
1921 break;
1922 case kC_COMMAND:
1923 switch (GET_SUBMSG(msg)) {
1924 case kCM_COMBOBOX:
1925 if ((record = fSession->GetRecord((Int_t)parm2)))
1926 fSession->Show(record);
1927 break;
1928 case kCM_BUTTON:
1929 switch (parm1) {
1930 // handle button messages
1931 case kRESET:
1932 EmptyAll();
1933 break;
1934 case kDRAW:
1935 fVarDraw = false;
1936 ExecuteDraw();
1937 break;
1938 case kSTOP:
1939 if (fCounting)
1940 gROOT->SetInterrupt(true);
1941 break;
1942 case kCLOSE:
1944 break;
1945 case kBGFirst:
1946 if ((record = fSession->First()))
1947 fSession->Show(record);
1948 break;
1949 case kBGPrevious:
1950 if ((record = fSession->Previous()))
1951 fSession->Show(record);
1952 break;
1953 case kBGRecord:
1955 break;
1956 case kBGNext:
1957 if ((record = fSession->Next()))
1958 fSession->Show(record);
1959 break;
1960 case kBGLast:
1961 if ((record = fSession->Last()))
1962 fSession->Show(record);
1963 break;
1964 default:
1965 break;
1966 }
1967 break;
1968 case kCM_MENU:
1969 // handle menu messages
1970 // check if sent by Options menu
1971 if ((parm1>=kOptionsReset) && (parm1<kHelpAbout)) {
1972 Dimension();
1973 if ((fDimension==0) && (parm1>=kOptions1D)) {
1974 Warning("ProcessMessage", "Edit expressions first.");
1975 break;
1976 }
1977 if ((fDimension==1) && (parm1>=kOptions2D)) {
1978 Warning("ProcessMessage", "You have only one expression active.");
1979 break;
1980 }
1981 if ((fDimension==2) && (parm1>=kOptions1D) &&(parm1<kOptions2D)) {
1982 Warning("ProcessMessage", "1D drawing options not apply to 2D histograms.");
1983 break;
1984 }
1985 // make composed option
1986 MapOptions(parm1);
1987 break;
1988 }
1989 switch (parm1) {
1990 case kFileCanvas:
1991 gROOT->MakeDefCanvas();
1992 break;
1993 case kFileBrowse:
1994 if (true) {
1995 static TString dir(".");
1996 TGFileInfo info;
1997 info.fFileTypes = gOpenTypes;
1998 info.SetIniDir(dir);
1999 new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
2000 if (!info.fFilename) return true;
2001 dir = info.fIniDir;
2002 TString command = TString::Format("tv__tree_file = new TFile(\"%s\");",
2004 ExecuteCommand(command.Data());
2005 ExecuteCommand("tv__tree_file->ls();");
2006 std::cout << "Use SetTreeName() from context menu and supply a tree name" << std::endl;
2007 std::cout << "The context menu is activated by right-clicking the panel from right" << std::endl;
2008 }
2009 break;
2010 case kFileLoadLibrary:
2011 fBarCommand->SetText("gSystem->Load(\"\");");
2012 if (true) {
2013 Event_t event;
2014 event.fType = kButtonPress;
2015 event.fCode = kButton1;
2016 event.fX = event.fY = 1;
2017 fBarCommand->HandleButton(&event);
2018 }
2020 break;
2021 case kFileOpenSession:
2022 if (true) {
2023 static TString dir(".");
2024 TGFileInfo info;
2025 info.fFileTypes = gMacroTypes;
2026 info.SetIniDir(dir);
2027 new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
2028 if (!info.fFilename) return true;
2029 dir = info.fIniDir;
2030 gInterpreter->Reset();
2031 if (!gInterpreter->IsLoaded(info.fFilename)) gInterpreter->LoadMacro(info.fFilename);
2032 char command[1024];
2033 command[0] = 0;
2034 snprintf(command,1024,"open_session((void*)0x%zx);", (size_t)this);
2035 ExecuteCommand(command);
2036 }
2037 break;
2038 case kFileSaveMacro:
2039 fContextMenu->Action(this,(TMethod*)IsA()->GetListOfMethods()->FindObject("SaveSource"));
2040 break;
2041 case kFilePrint:
2042 break;
2043 case kFileClose:
2045 break;
2046 case kFileQuit:
2048 break;
2049 case kEditExpression:
2051 break;
2052 case kEditCut:
2054 break;
2055 case kEditMacro:
2056 break;
2057 case kEditEvent:
2058 break;
2059 case kRunMacro:
2060 break;
2061 case kHelpAbout:
2062 {
2063#ifdef R__UNIX
2064 TString rootx = TROOT::GetBinDir() + "/root -a &";
2065 gSystem->Exec(rootx);
2066#else
2067#ifdef WIN32
2068 new TWin32SplashThread(true);
2069#else
2070 char str[32];
2071 snprintf(str,32, "About ROOT %s...", gROOT->GetVersion());
2072 hd = new TRootHelpDialog(this, str, 600, 400);
2073 hd->SetText(gHelpAbout);
2074 hd->Popup();
2075#endif
2076#endif
2077 }
2078 break;
2079 case kHelpAboutTV:
2080 hd = new TRootHelpDialog(this, "About TreeViewer...", 600, 400);
2081 hd->SetText(gTVHelpAbout);
2082 hd->Resize(hd->GetDefaultSize());
2083 hd->Popup();
2084 break;
2085 case kHelpStart:
2086 hd = new TRootHelpDialog(this, "Quick start...", 600, 400);
2087 hd->SetText(gTVHelpStart);
2088 hd->Popup();
2089 break;
2090 case kHelpLayout:
2091 hd = new TRootHelpDialog(this, "Layout...", 600, 400);
2093 hd->Popup();
2094 break;
2095 case kHelpOpenSave:
2096 hd = new TRootHelpDialog(this, "Open/Save...", 600, 400);
2098 hd->Popup();
2099 break;
2100 case kHelpDragging:
2101 hd = new TRootHelpDialog(this, "Dragging items...", 600, 400);
2103 hd->Popup();
2104 break;
2105 case kHelpEditing:
2106 hd = new TRootHelpDialog(this, "Editing expressions...", 600, 400);
2108 hd->Popup();
2109 break;
2110 case kHelpSession:
2111 hd = new TRootHelpDialog(this, "Session...", 600, 400);
2113 hd->Popup();
2114 break;
2115 case kHelpCommands:
2116 hd = new TRootHelpDialog(this, "Executing user commands...", 600, 400);
2118 hd->Popup();
2119 break;
2120 case kHelpContext:
2121 hd = new TRootHelpDialog(this, "Context menus...", 600, 400);
2123 hd->Popup();
2124 break;
2125 case kHelpDrawing:
2126 hd = new TRootHelpDialog(this, "Drawing histograms...", 600, 400);
2128 hd->Popup();
2129 break;
2130 case kHelpMacros:
2131 hd = new TRootHelpDialog(this, "Using macros...", 600, 400);
2133 hd->Popup();
2134 break;
2135 default:
2136 break;
2137 }
2138 break;
2139 default:
2140 break;
2141 }
2142 break;
2143 case kC_CONTAINER:
2144 switch (GET_SUBMSG(msg)) {
2145 // handle messages sent from the listview (right panel)
2146 case kCT_SELCHANGED:
2147 break;
2148 case kCT_ITEMCLICK:
2149 // handle mouse messages
2150 switch (parm1) {
2151 case kButton1:
2152 if (fLVContainer->NumSelected()) {
2153 // get item that sent this
2154 void *p = nullptr;
2155 TTVLVEntry *item;
2156 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != nullptr) {
2157 const char* vname = item->GetTrueName();
2158 TString trueName(vname);
2159 if (trueName.Contains("[]")) {
2160 TIter next(fTree->GetListOfLeaves());
2161 TLeaf *leaf;
2162 while((leaf=(TLeaf*)next())) {
2163 if (!strcmp(vname, EmptyBrackets(leaf->GetName())))
2164 vname = leaf->GetName();
2165 }
2166 }
2167 char* msg2 = new char[2000];
2168 // get item type
2169 ULong_t *itemType = (ULong_t *) item->GetUserData();
2170 if (*itemType & kLTTreeType) {
2171 // X, Y or Z clicked
2172 char symbol = (char)((*itemType) >> 8);
2173 snprintf(msg2,2000, "%c expression : %s", symbol, vname);
2174 } else {
2175 if (*itemType & kLTCutType) {
2176 // scissors clicked
2177 snprintf(msg2,2000, "Cut : %s", vname);
2178 } else {
2179 if (*itemType & kLTPackType) {
2180 snprintf(msg2,2000, "Box : %s", vname);
2181 } else {
2182 if (*itemType & kLTExpressionType) {
2183 // expression clicked
2184 snprintf(msg2,2000, "Expression : %s", vname);
2185 } else {
2186 if (*itemType & kLTBranchType) {
2187 snprintf(msg2,2000, "Branch : %s", vname);
2188 } else {
2189 snprintf(msg2,2000, "Leaf : %s", vname);
2190 }
2191 }
2192 }
2193 }
2194 }
2195 // write who is responsable for this
2196 TString message = msg2;
2197 message = message(0,150);
2198 Message(msg2);
2199 delete[] msg2;
2200 // check if this should be pasted into the expression editor
2201 if ((*itemType & kLTBranchType) || (*itemType & kLTCutType)) break;
2203 if (!fDialogBox || !vname[0]) break;
2204 if (item == fDialogBox->EditedEntry()) break;
2205 // paste it
2206// char first = (char) vname[0];
2207 TString insert(item->GetAlias());
2208// if (first != '(') insert += "(";
2209// insert += item->GetAlias();
2210// if (first != '(') insert += ")";
2211
2213 fDialogBox->InsertText(insert.Data());
2214 // put the cursor at the right position
2215 }
2216 }
2217 break;
2218 case kButton2:
2219 break;
2220 case kButton3:
2221 // activate general context menu
2222 if (fLVContainer->NumSelected()) {
2223 void *p = nullptr;
2224 Int_t x = (Int_t)(parm2 &0xffff);
2225 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2226 TTVLVEntry *item = nullptr;
2227 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != nullptr) {
2228 fContextMenu->Popup(x, y, item->GetContext());
2229 }
2230 } else { // empty click
2231 Int_t x = (Int_t)(parm2 &0xffff);
2232 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2233 fContextMenu->Popup(x, y, this);
2234 }
2235 break;
2236 default:
2237 break;
2238 }
2239 break;
2240 case kCT_ITEMDBLCLICK:
2241 switch (parm1) {
2242 case kButton1:
2243 if (fLVContainer->NumSelected()) {
2244 // get item that sent this
2245 void *p = nullptr;
2246 TTVLVEntry *item;
2247 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != nullptr) {
2248 // get item type
2249 ULong_t *itemType = (ULong_t *) item->GetUserData();
2250 if (!(*itemType & kLTCutType) && !(*itemType & kLTBranchType)
2251 && !(*itemType & kLTPackType)) {
2252 if (strlen(item->GetTrueName())) {
2253 fVarDraw = true;
2254 // draw on double-click
2255 ExecuteDraw();
2256 break;
2257 } else {
2258 // open expression in editor
2260 }
2261 }
2262 if (*itemType & kLTCutType) {
2264 if (fEnableCut) {
2265 item->SetSmallPic(gClient->GetPicture("cut_t.xpm"));
2266 } else {
2267 item->SetSmallPic(gClient->GetPicture("cut-disable_t.xpm"));
2268 }
2269 }
2270 if (*itemType & kLTPackType) {
2271 fScanMode = true;
2272 ExecuteDraw();
2273 }
2274 }
2275 }
2276 break;
2277 case kButton2:
2278 break;
2279 case kButton3:
2280 break;
2281 default:
2282 break;
2283 }
2284 break;
2285 case 4:
2286// std::cout << "Dragging Item" << std::endl;
2287 default:
2288 break;
2289 }
2290 break;
2291 default:
2292 break;
2293 }
2294 return true;
2295}
2296
2297////////////////////////////////////////////////////////////////////////////////
2298/// Close the viewer.
2299
2301{
2302 DeleteWindow();
2303}
2304
2305////////////////////////////////////////////////////////////////////////////////
2306/// Execute all user commands.
2307
2308void TTreeViewer::ExecuteCommand(const char* command, bool fast)
2309{
2310 // Execute the command, write it to history file and echo it to output
2311 if (fBarRec->GetState() == kButtonDown) {
2312 // show the command on the command line
2313 //printf("%s\n", command);
2314 char comm[2000];
2315 comm[0] = 0;
2316 if (strlen(command) > 1999) {
2317 Warning("ExecuteCommand", "Command too long: aborting.");
2318 return;
2319 }
2320 snprintf(comm,2000, "%s", command);
2321 // print the command to history file
2322 Gl_histadd(comm);
2323 }
2324 // execute it
2325 if (fast) {
2326 gROOT->ProcessLineFast(command);
2327 } else {
2328 gROOT->ProcessLine(command);
2329 }
2330 // make sure that 'draw on double-click' flag is reset
2331 fVarDraw = false;
2332}
2333
2334////////////////////////////////////////////////////////////////////////////////
2335/// Scan the selected options from option menu.
2336
2338{
2339 Int_t ind;
2340 if (parm1 == kOptionsReset) {
2341 for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++)
2343 for (ind=kOptions1D; ind<kOptions1D+12; ind++)
2345 for (ind=kOptions2D; ind<kOptions2D+14; ind++)
2347 }
2348 if ((parm1 < kOptions1D) && (parm1 != kOptionsReset)) {
2349 if (fOptionsGen->IsEntryChecked((Int_t)parm1)) {
2351 } else {
2352 fOptionsGen->CheckEntry((Int_t)parm1);
2354 }
2356 // uncheck all in this menu
2357 for (ind=kOptionsGeneral+1; ind<kOptionsGeneral+16; ind++) {
2359 }
2360 }
2361 }
2362
2363 if ((parm1 < kOptions2D) && (parm1 >= kOptions1D)) {
2364 if (fOptions1D->IsEntryChecked((Int_t)parm1)) {
2365 fOptions1D->UnCheckEntry((Int_t)parm1);
2366 } else {
2367 fOptions1D->CheckEntry((Int_t)parm1);
2369 }
2371 // uncheck all in this menu
2372 for (ind=kOptions1D+1; ind<kOptions1D+12; ind++) {
2374 }
2375 }
2376 }
2377
2378 if (parm1 >= kOptions2D) {
2379 if (fOptions2D->IsEntryChecked((Int_t)parm1)) {
2380 fOptions2D->UnCheckEntry((Int_t)parm1);
2381 } else {
2382 fOptions2D->CheckEntry((Int_t)parm1);
2384 }
2386 // uncheck all in this menu
2387 for (ind=kOptions2D+1; ind<kOptions2D+14; ind++) {
2389 }
2390 }
2391 }
2392 // concatenate options
2393 fBarOption->SetText("");
2394 for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++) {
2395 if (fOptionsGen->IsEntryChecked(ind))
2397 }
2398 if (Dimension() == 1) {
2399 for (ind=kOptions1D; ind<kOptions1D+12; ind++) {
2400 if (fOptions1D->IsEntryChecked(ind))
2402 }
2403 }
2404 if (Dimension() == 2) {
2405 for (ind=kOptions2D; ind<kOptions2D+14; ind++) {
2406 if (fOptions2D->IsEntryChecked(ind))
2408 }
2409 }
2410}
2411
2412////////////////////////////////////////////////////////////////////////////////
2413/// Map current tree and expand its content (including friends) in the lists.
2414
2415void TTreeViewer::MapTree(TTree *tree, TGListTreeItem *parent, bool listIt)
2416{
2417 if (!tree) return;
2418 TObjArray *branches = tree->GetListOfBranches();
2419 if (!branches) return; // A Chain with no underlying trees.
2420 TBranch *branch;
2421 // loop on branches
2422 Int_t id;
2423 for (id=0; id<branches->GetEntries(); id++) {
2424 branch = (TBranch *)branches->At(id);
2425 if (branch->TestBit(kDoNotProcess)) continue;
2426 TString name = branch->GetName();
2427 if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2428 // now map sub-branches
2429 MapBranch(branch, "", parent, listIt);
2430 fStopMapping = false;
2431 }
2432 //Map branches of friend Trees (if any)
2433 //Look at tree->GetTree() to insure we see both the friends of a chain
2434 //and the friends of the chain members
2435 TIter nextf( tree->GetTree()->GetListOfFriends() );
2436 TFriendElement *fr;
2437 while ((fr = (TFriendElement*)nextf())) {
2438 TTree * t = fr->GetTree();
2439 branches = t->GetListOfBranches();
2440 for (id=0; id<branches->GetEntries(); id++) {
2441 branch = (TBranch *)branches->At(id);
2442 if (branch->TestBit(kDoNotProcess)) continue;
2443 TString name = branch->GetName();
2444 if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2445 // now map sub-branches
2446 MapBranch(branch, fr->GetName(), parent, listIt);
2447 fStopMapping = false;
2448 }
2449 }
2450
2451 // tell who was last mapped
2452 if (listIt) {
2453 fMappedTree = tree;
2454 fMappedBranch = nullptr;
2455 }
2456}
2457
2458////////////////////////////////////////////////////////////////////////////////
2459/// Map current branch and expand its content in the list view.
2460
2461void TTreeViewer::MapBranch(TBranch *branch, const char *prefix, TGListTreeItem *parent, bool listIt)
2462{
2463 if (!branch) return;
2464 TString name;
2465 if (prefix && strlen(prefix) > 0) {
2466 name = prefix;
2467 if (!name.EndsWith(".")) name += ".";
2468 name += branch->GetName();
2469 }
2470 else name = branch->GetName();
2471 Int_t ind;
2472 TGListTreeItem *branchItem = nullptr;
2473 ULong_t *itemType;
2474 // map this branch
2475 if (name.Contains("fBits") || name.Contains("fUniqueID")) return;
2476 if (parent) {
2477 // make list tree items for each branch according to the type
2478 const TGPicture *pic, *spic;
2479 if ((branch->GetListOfBranches()->GetEntries()) ||
2480 (branch->GetNleaves())) {
2481 if (branch->GetListOfBranches()->GetEntries()) {
2482 itemType = new ULong_t(kLTBranchType);
2483 if (branch->InheritsFrom("TBranchObject")) {
2484 pic = gClient->GetPicture("branch-ob_t.xpm");
2485 spic = gClient->GetPicture("branch-ob_t.xpm");
2486 } else {
2487 if (branch->InheritsFrom("TBranchClones")) {
2488 pic = gClient->GetPicture("branch-cl_t.xpm");
2489 spic = gClient->GetPicture("branch-cl_t.xpm");
2490 } else {
2491 pic = gClient->GetPicture("branch_t.xpm");
2492 spic = gClient->GetPicture("branch_t.xpm");
2493 }
2494 }
2495 branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2496 } else {
2497 if (branch->GetNleaves() > 1) {
2498 itemType = new ULong_t(kLTBranchType);
2499 pic = gClient->GetPicture("branch_t.xpm");
2500 spic = gClient->GetPicture("branch_t.xpm");
2501 branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType,pic, spic);
2502 TObjArray *leaves = branch->GetListOfLeaves();
2503 TLeaf *leaf = nullptr;
2504 TString leafName;
2505 for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2506 leaf = (TLeaf *)leaves->At(lf);
2507 leafName = name;
2508 if (!leafName.EndsWith(".")) leafName.Append(".");
2509 leafName.Append(EmptyBrackets(leaf->GetName()));
2510 itemType = new ULong_t(kLTLeafType);
2511 pic = gClient->GetPicture("leaf_t.xpm");
2512 spic = gClient->GetPicture("leaf_t.xpm");
2513 fLt->AddItem(branchItem, leafName.Data(), itemType, pic, spic);
2514 }
2515 } else {
2516 itemType = new ULong_t(kLTLeafType);
2517 pic = gClient->GetPicture("leaf_t.xpm");
2518 spic = gClient->GetPicture("leaf_t.xpm");
2519 branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2520 }
2521 }
2522 }
2523 }
2524 // list branch in list view if necessary
2525 if (listIt) {
2526 TGString *textEntry = nullptr;
2527 const TGPicture *pic, *spic;
2528 TTVLVEntry *entry;
2529 // make list view items in the right frame
2530 if (!fStopMapping) {
2531 fMappedBranch = branch;
2532 fMappedTree = nullptr;
2533 fStopMapping = true;
2534 }
2535 if ((branch->GetListOfBranches()->GetEntries()) ||
2536 (branch->GetNleaves())) {
2537 textEntry = new TGString(EmptyBrackets(name.Data()));
2538 if (branch->GetListOfBranches()->GetEntries()) {
2539 if (branch->InheritsFrom("TBranchObject")) {
2540 pic = gClient->GetPicture("branch-ob_t.xpm");
2541 spic = gClient->GetPicture("branch-ob_t.xpm");
2542 } else {
2543 if (branch->InheritsFrom("TBranchClones")) {
2544 pic = gClient->GetPicture("branch-cl_t.xpm");
2545 spic = gClient->GetPicture("branch-cl_t.xpm");
2546 } else {
2547 pic = gClient->GetPicture("branch_t.xpm");
2548 spic = gClient->GetPicture("branch_t.xpm");
2549 }
2550 }
2551 entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,nullptr,kLVSmallIcons);
2552 entry->SetUserData(new UInt_t(kLTBranchType));
2553 entry->SetToolTipText("Branch with sub-branches. Can not be dragged");
2554 fLVContainer->AddThisItem(entry);
2555 entry->MapWindow();
2556 entry->SetAlias(textEntry->GetString());
2557 } else {
2558 if (branch->GetNleaves() > 1) {
2559 if (textEntry) delete textEntry;
2560 textEntry = new TGString(EmptyBrackets(name.Data()));
2561 pic = gClient->GetPicture("branch_t.xpm");
2562 spic = gClient->GetPicture("branch_t.xpm");
2563 entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,nullptr,kLVSmallIcons);
2564 entry->SetUserData(new UInt_t(kLTBranchType));
2565 entry->SetToolTipText("Branch with more than one leaf. Can not be dragged");
2566 fLVContainer->AddThisItem(entry);
2567 entry->MapWindow();
2568 entry->SetAlias(textEntry->GetString());
2569
2570 TObjArray *leaves = branch->GetListOfLeaves();
2571 TLeaf *leaf = nullptr;
2572 TString leafName;
2573 for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2574 leaf = (TLeaf *)leaves->At(lf);
2575 leafName = name;
2576 if (!leafName.EndsWith(".")) leafName.Append(".");
2577 leafName.Append(EmptyBrackets(leaf->GetName()));
2578 textEntry = new TGString(leafName.Data());
2579 pic = gClient->GetPicture("leaf_t.xpm");
2580 spic = gClient->GetPicture("leaf_t.xpm");
2581 entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,nullptr,kLVSmallIcons);
2583 entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2584 fLVContainer->AddThisItem(entry);
2585 entry->MapWindow();
2586 entry->SetAlias(textEntry->GetString());
2587 }
2588 } else {
2589 pic = (gClient->GetMimeTypeList())->GetIcon("TLeaf",false);
2590 if (!pic) pic = gClient->GetPicture("leaf_t.xpm");
2591 spic = gClient->GetMimeTypeList()->GetIcon("TLeaf",true);
2592 if (!spic) spic = gClient->GetPicture("leaf_t.xpm");
2593 entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,nullptr,kLVSmallIcons);
2595 entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2596 fLVContainer->AddThisItem(entry);
2597 entry->MapWindow();
2598 entry->SetAlias(textEntry->GetString());
2599 }
2600 }
2601 }
2602 }
2603
2604 TObjArray *branches = branch->GetListOfBranches();
2605 TBranch *branchDaughter = nullptr;
2606
2607 // loop all sub-branches
2608 for (ind=0; ind<branches->GetEntries(); ind++) {
2609 branchDaughter = (TBranch *)branches->UncheckedAt(ind);
2610 // map also all sub-branches
2611 MapBranch(branchDaughter, "", branchItem, listIt);
2612 }
2613}
2614
2615////////////////////////////////////////////////////////////////////////////////
2616/// Create new expression
2617
2619{
2621 const TGPicture *pic = gClient->GetPicture("expression_t.xpm");
2622 const TGPicture *spic = gClient->GetPicture("expression_t.xpm");
2623
2624 TTVLVEntry *entry = new TTVLVEntry(fLVContainer,pic,spic,
2625 new TGString(),nullptr,kLVSmallIcons);
2627 fLVContainer->AddThisItem(entry);
2628 entry->MapWindow();
2629 entry->Empty();
2632 fListView->Layout();
2633 fNexpressions++;
2634}
2635
2636////////////////////////////////////////////////////////////////////////////////
2637/// Find parent tree of a clicked item.
2638
2640{
2641 if (!item) return;
2642 ULong_t *itemType = (ULong_t *)item->GetUserData();
2643 if (!itemType) return;
2644 TGListTreeItem *parent = nullptr;
2645 Int_t index;
2646 if (!(*itemType & kLTTreeType)) {
2647 parent = item->GetParent();
2648 SetParentTree(parent);
2649 } else {
2650 index = (Int_t)(*itemType >> 8);
2652 }
2653}
2654
2655////////////////////////////////////////////////////////////////////////////////
2656/// Send a message on the status bar.
2657
2658void TTreeViewer::Message(const char* msg)
2659{
2660 fStatusBar->SetText(msg);
2661}
2662
2663////////////////////////////////////////////////////////////////////////////////
2664/// Put error/warning into TMsgBox and also forward to console.
2665
2666void TTreeViewer::DoError(int level, const char *location, const char *fmt, va_list va) const
2667{
2668 TObject::DoError(level, location, fmt, va);
2669
2670 // in case level will abort we will not come here...
2671
2672 static const int buf_size = 2048;
2673 char buf[buf_size], *bp;
2674
2675 int n = vsnprintf(buf, buf_size, fmt, va);
2676 // old vsnprintf's return -1 if string is truncated new ones return
2677 // total number of characters that would have been written
2678 if (n == -1 || n >= buf_size) {
2679 TObject::Warning("DoError", "Error message string truncated...");
2680 }
2681 if (level >= kSysError && level < kFatal)
2682 bp = Form("%s (%s)", buf, gSystem->GetError());
2683 else
2684 bp = buf;
2685
2686 const char *title = "";
2687 if (level == kInfo)
2688 title = "Info";
2689 if (level == kWarning)
2690 title = "Warning";
2691 if (level == kError)
2692 title = "Error";
2693 if (level == kSysError)
2694 title = "System Error";
2695
2696 new TGMsgBox(fClient->GetRoot(), this, title, bp, kMBIconExclamation);
2697}
2698
2699////////////////////////////////////////////////////////////////////////////////
2700/// Print the number of selected entries on status-bar.
2701
2703{
2704 if (!fTree) return;
2705 char * msg = new char[100];
2706 snprintf(msg,100, "First entry : %lld Last entry : %lld",
2708 Message(msg);
2709 delete[] msg;
2710}
2711
2712////////////////////////////////////////////////////////////////////////////////
2713/// Save current session as a C++ macro file.
2714
2715void TTreeViewer::SaveSource(const char* filename, Option_t *)
2716{
2717 if (!fTree) return;
2718 char quote = '"';
2719 std::ofstream out;
2720 Int_t lenfile = strlen(filename);
2721 char * fname;
2722 if (!lenfile) {
2723 fname = (char*)fSourceFile;
2724 lenfile = strlen(fname);
2725 } else {
2726 fname = (char*)filename;
2728 }
2729 // if filename is given, open this file, otherwise create a file
2730 // with a name : treeviewer.C
2731 if (lenfile) {
2732 out.open(fname, std::ios::out);
2733 } else {
2734 fname = new char[13];
2735 strlcpy(fname, "treeviewer.C",13);
2736 out.open(fname, std::ios::out);
2737 }
2738 if (!out.good ()) {
2739 printf("SaveSource cannot open file : %s\n", fname);
2740 fSourceFile = "treeviewer.C";
2741 if (!lenfile) delete [] fname;
2742 return;
2743 }
2744 // Write macro header and date/time stamp
2745 TDatime t;
2746 out <<"void open_session(void *p = 0);"<<std::endl<<std::endl;
2747 out <<"void "<<std::filesystem::path(fname).stem()<<"() {"<<std::endl;
2748 out <<"//=========Macro generated by ROOT version"<<gROOT->GetVersion()<<std::endl;
2749 out <<"//=========for tree "<<quote<<fTree->GetName()<<quote<<" ("<<t.AsString()<<")"<<std::endl;
2750 out <<"//===This macro can be opened from a TreeViewer session after loading"<<std::endl;
2751 out <<"//===the corresponding tree, or by running root with the macro name argument"<<std::endl<<std::endl;
2752 out <<" open_session();"<<std::endl;
2753 out <<"}"<<std::endl<<std::endl;
2754 out <<"void open_session(void *p = 0) {"<<std::endl;
2755 out <<" gSystem->Load("<<quote<<"libTreeViewer"<<quote<<");"<<std::endl;
2756 out <<" TTreeViewer *treeview = (TTreeViewer *) p;"<<std::endl;
2757 out <<" if (!treeview) treeview = new TTreeViewer();"<<std::endl;
2758 out <<" TTree *tv_tree = (TTree*)gROOT->FindObject("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2759 out <<" TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("<<quote<<fFilename<<quote<<");"<<std::endl;
2760 out <<" if (!tv_tree) {"<<std::endl;
2761 out <<" if (!tv_file) tv_file = new TFile("<<quote<<fFilename<<quote<<");"<<std::endl;
2762 out <<" if (tv_file) tv_tree = (TTree*)tv_file->Get("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2763 out <<" if(!tv_tree) {"<<std::endl;
2764 out <<" printf(\"Tree %s not found\", "<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2765 out <<" return;"<<std::endl;
2766 out <<" }"<<std::endl;
2767 out <<" }"<<std::endl<<std::endl;
2768 out <<" treeview->SetTreeName("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2769 out <<" treeview->SetNexpressions("<<fNexpressions<<");"<<std::endl;
2770 // get expressions
2771 TTVLVEntry *item;
2772 out <<"// Set expressions on axis and cut"<<std::endl;
2773 out <<" TTVLVEntry *item;"<<std::endl;
2774 for (Int_t i=0; i<4; i++) {
2775 switch (i) {
2776 case 0:
2777 out <<"// X expression"<<std::endl;
2778 break;
2779 case 1:
2780 out <<"// Y expression"<<std::endl;
2781 break;
2782 case 2:
2783 out <<"// Z expression"<<std::endl;
2784 break;
2785 case 3:
2786 out <<"// Cut expression"<<std::endl;
2787 break;
2788 default:
2789 break;
2790 }
2791 item = ExpressionItem(i);
2792 out <<" item = treeview->ExpressionItem("<<i<<");"<<std::endl;
2793 out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2794 <<", "<<quote<<item->GetAlias()<<quote<<");"<<std::endl;
2795 }
2796 out <<"// Scan list"<<std::endl;
2797 item = ExpressionItem(4);
2798 out <<" item = treeview->ExpressionItem(4);"<<std::endl;
2799 out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2800 <<", "<<quote<<"Scan box"<<quote<<");"<<std::endl;
2801 out <<"// User defined expressions"<<std::endl;
2802 TString itemType;
2803 for (Int_t crt=5; crt<fNexpressions+5; crt++) {
2804 item = ExpressionItem(crt);
2805 if (item->IsCut())
2806 itemType = "true";
2807 else
2808 itemType = "false";
2809 out <<" item = treeview->ExpressionItem("<<crt<<");"<<std::endl;
2810 out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2811 <<", "<<quote<<item->GetAlias()<<quote<<", "<<itemType.Data()<<");"<<std::endl;
2812 }
2813 fSession->SaveSource(out);
2814 out <<"}"<<std::endl;
2815 out.close();
2816 printf("C++ Macro file: %s has been generated\n", fname);
2817 if (!lenfile) delete [] fname;
2818}
2819
2820////////////////////////////////////////////////////////////////////////////////
2821/// Makes current the tree at a given index in the list.
2822
2824{
2825 TTree *tree = (TTree *) fTreeList->At(index);
2826 if (!tree) {
2827 Warning("SwitchTree", "No tree found.");
2828 return false;
2829 }
2830 if ((tree == fTree) && (tree == fMappedTree)) return false; // nothing to switch
2831 std::string command;
2832 if (tree != fTree) {
2833 command = "tv__tree = (TTree *) tv__tree_list->At";
2834 command += Form("(%i)",index);
2835 ExecuteCommand(command.c_str());
2836 }
2837
2838 fTree = tree;
2839 fSlider->SetRange(0LL,fTree->GetEntries()-1);
2841 command = "Current Tree : ";
2842 command += fTree->GetName();
2843 fLbl2->SetText(new TGString(command.c_str()));
2844 fTreeHdr->Layout();
2845 MapSubwindows();
2847 MapWindow();
2848 ///Resize(); //ia
2849 PrintEntries();
2850 return true;
2851}
2852
2853////////////////////////////////////////////////////////////////////////////////
2854/// Set record name
2855
2856void TTreeViewer::SetRecordName(const char *name)
2857{
2859}
2860
2861////////////////////////////////////////////////////////////////////////////////
2862/// Set current record
2863
2865{
2866 fCombo->Select(entry);
2867}
2868
2869////////////////////////////////////////////////////////////////////////////////
2870/// Set title of Histogram
2871
2872void TTreeViewer::SetHistogramTitle(const char *title)
2873{
2874 if (!gPad) return;
2875 TH1 *hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
2876 if (hist) {
2877 hist->SetTitle(title);
2878 gPad->Update();
2879 }
2880}
2881
2882////////////////////////////////////////////////////////////////////////////////
2883/// user defined command for current record
2884
2885void TTreeViewer::SetUserCode(const char *code, bool autoexec)
2886{
2888 if (rec) rec->SetUserCode(code, autoexec);
2889}
2890
2891////////////////////////////////////////////////////////////////////////////////
2892/// Updates combo box to current session entries.
2893
2895{
2896 TTVRecord *record;
2897 fCombo->RemoveEntries(0, 1000);
2898 for (Long64_t entry=0; entry<fSession->GetEntries(); entry++) {
2899 if ((record = fSession->GetRecord(entry)))
2900 fCombo->AddEntry(record->GetName(), entry);
2901 }
2902}
2903
2904////////////////////////////////////////////////////////////////////////////////
2905/// Updates current record to new X, Y, Z items.
2906
2907void TTreeViewer::UpdateRecord(const char *name)
2908{
2910}
2911
2912////////////////////////////////////////////////////////////////////////////////
2913/// This slot is called when button REFR is clicked
2914
2916{
2917 fTree->Refresh();
2920 fSlider->SetRange(min,max);
2921 fSlider->SetPosition(min,max);
2922 ExecuteDraw();
2923}
@ kButtonPress
Definition GuiTypes.h:60
@ kWatch
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:375
@ kFitHeight
Definition GuiTypes.h:388
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
EMouseButton
Button names.
Definition GuiTypes.h:214
@ kButton2
Definition GuiTypes.h:214
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
R__EXTERN const char gTVHelpLayout[]
Definition HelpTextTV.h:19
R__EXTERN const char gTVHelpStart[]
Definition HelpTextTV.h:18
R__EXTERN const char gTVHelpDrawing[]
Definition HelpTextTV.h:26
R__EXTERN const char gTVHelpOpenSave[]
Definition HelpTextTV.h:20
R__EXTERN const char gTVHelpMacros[]
Definition HelpTextTV.h:27
R__EXTERN const char gTVHelpEditExpressions[]
Definition HelpTextTV.h:22
R__EXTERN const char gTVHelpAbout[]
Definition HelpTextTV.h:17
R__EXTERN const char gTVHelpDraggingItems[]
Definition HelpTextTV.h:21
R__EXTERN const char gTVHelpUserCommands[]
Definition HelpTextTV.h:24
R__EXTERN const char gTVHelpSession[]
Definition HelpTextTV.h:23
R__EXTERN const char gTVHelpContext[]
Definition HelpTextTV.h:25
R__EXTERN const char gHelpAbout[]
Definition HelpText.h:17
@ kCLOSE
Definition Match.cxx:47
#define e(i)
Definition RSha256.hxx:103
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
char Char_t
Definition RtypesCore.h:37
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
double Double_t
Definition RtypesCore.h:59
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
R__EXTERN TApplication * gApplication
const Int_t kDoNotProcess
Definition TBranch.h:56
#define gDirectory
Definition TDirectory.h:384
constexpr Int_t kError
Definition TError.h:47
constexpr Int_t kFatal
Definition TError.h:50
constexpr Int_t kWarning
Definition TError.h:46
constexpr Int_t kInfo
Definition TError.h:45
constexpr Int_t kSysError
Definition TError.h:49
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:156
@ kDoubleScaleBoth
@ kFDOpen
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kLVSmallIcons
Definition TGListView.h:23
@ kLVList
Definition TGListView.h:24
@ kMBIconExclamation
Definition TGMsgBox.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint percent
char name[80]
Definition TGX11.cxx:110
int nentries
#define gInterpreter
#define gROOT
Definition TROOT.h:406
@ kFilePrint
@ kFileQuit
@ kHelpAbout
static const char * gOpenTypes[]
@ kEditCut
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
static const char * gOpt2D[14]
EButtonIdentifiers
@ kBGFirst
@ kSLIDER
@ kSTOP
@ kBGLast
@ kRESET
@ kBGRecord
@ kCLOSE
@ kDRAW
@ kBGNext
@ kBGPrevious
static const char * gOptgen[16]
static const char * gOpenTypes[]
static const char * gOpt1D[12]
static const char * gMacroTypes[]
ERootTreeViewerCommands
@ kBarCommand
@ kHelpDragging
@ kFilePrint
@ kOptionsGeneral
@ kHelpContext
@ kFileClose
@ kHelpStart
@ kHelpCommands
@ kHelpMacros
@ kOptions2D
@ kFileQuit
@ kEditMacro
@ kHelpDrawing
@ kFileCanvas
@ kFileLoadLibrary
@ kFileSaveMacro
@ kFileBrowse
@ kFileOpenSession
@ kOptionsReset
@ kBarOption
@ kRunMacro
@ kAxis
@ kHelpEditing
@ kBarCut
@ kRunCommand
@ kHelpOpenSave
@ kHelpSession
@ kEditCut
@ kHelpAboutTV
@ kOptions1D
@ kEditEvent
@ kHelpLayout
@ kHelpAbout
@ kEditExpression
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kCT_SELCHANGED
@ kCM_COMBOBOX
@ kCM_MENU
@ kTE_ENTER
@ kCT_ITEMCLICK
@ kC_COMMAND
@ kCM_BUTTON
@ kC_TEXTENTRY
@ kC_LISTTREE
@ kC_VSLIDER
@ kCT_ITEMDBLCLICK
@ kC_CONTAINER
Int_t GET_SUBMSG(Long_t val)
#define snprintf
Definition civetweb.c:1540
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Class to manage histogram axis.
Definition TAxis.h:31
A TTree is a list of TBranches.
Definition TBranch.h:93
TObjArray * GetListOfBranches()
Definition TBranch.h:246
Int_t GetNleaves() const
Definition TBranch.h:249
TObjArray * GetListOfLeaves()
Definition TBranch.h:247
This class provides an interface to context sensitive popup menus.
virtual void Action(TObject *object, TMethod *method)
Action to be performed when this menu item is selected.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:102
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Describe directory structure in memory.
Definition TDirectory.h:45
virtual TFile * GetFile() const
Definition TDirectory.h:220
virtual Bool_t cd()
Change current directory to "this" directory.
<div class="legacybox"><h2>Legacy Code</h2> TEventList is a legacy interface: there will be no bug fi...
Definition TEventList.h:31
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
A TFriendElement TF describes a TTree object TF in a file.
virtual TTree * GetTree()
Return pointer to friend TTree.
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:235
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:222
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Definition TGComboBox.h:105
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:316
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:312
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:314
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
virtual void Associate(const TGWindow *w)
Definition TGCanvas.h:89
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition TGCanvas.cxx:660
virtual const TGFrame * GetNextSelected(void **current)
Return the next selected item.
Definition TGCanvas.cxx:681
virtual Int_t NumSelected() const
Definition TGCanvas.h:104
void RemoveAll() override
Remove all items from the container.
Definition TGCanvas.cxx:641
virtual Double_t GetMaxPositionD() const
virtual Long64_t GetMinPositionL() const
virtual Double_t GetMinPositionD() const
virtual void SetRange(Float_t min, Float_t max)
virtual Long64_t GetMaxPositionL() const
virtual void SetPosition(Float_t min, Float_t max)
Dragging the slider will generate the event:
This class creates a file selection dialog.
char * fFilename
selected file name
const char ** fFileTypes
file types used to filter selectable files
char * fIniDir
on input: initial directory, on output: new directory
void SetIniDir(const char *inidir)
Set directory name.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:312
void MapWindow() override
map window
Definition TGFrame.h:204
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:246
UInt_t GetWidth() const
Definition TGFrame.h:224
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:247
void ShowPosition(Bool_t set=kTRUE, Bool_t percent=kTRUE, const char *format="%.2f")
Show postion text, either in percent or formatted according format.
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
void * GetUserData() const
Definition TGListView.h:95
void SetUserData(void *userData)
Definition TGListView.h:94
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:180
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
virtual const char * GetText() const =0
TGListTreeItem * GetParent() const
Definition TGListTree.h:58
virtual void * GetUserData() const =0
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:195
void ClearHighlighted()
Un highlight items.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
TGListTreeItem * GetSelected() const
Definition TGListTree.h:382
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
void HighlightItem(TGListTreeItem *item)
Highlight item.
A list view is a widget that can contain a number of items arranged in a grid or list.
Definition TGListView.h:115
void Layout() override
Layout list view components (container and contents of container).
void SetContainer(TGFrame *f) override
Set list view container.
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1744
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
The TGMenu.h header contains all different menu classes.
Definition TGMenu.h:282
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup menu to menu bar.
Definition TGMenu.cxx:418
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Yield an action as soon as it is clicked.
Definition TGButton.h:228
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Pixmap_t GetPicture() const
Definition TGPicture.h:54
This class creates a popup menu object.
Definition TGMenu.h:110
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition TGMenu.cxx:1845
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=nullptr, const TGPicture *p=nullptr)
Add a (cascading) popup menu to a popup menu.
Definition TGMenu.cxx:1152
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition TGMenu.cxx:1782
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1724
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition TGMenu.cxx:1807
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:206
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1060
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:990
void SetPosition(Float_t pos)
Set progress position between [min,max].
void SetFillType(EFillType type)
Set fill type.
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
This class represent a specialized expression editor for TTVLVEntry 'true name' and 'alias' data memb...
TTVLVEntry * EditedEntry()
void InsertText(const char *text)
Insert text in text entry.
void GrabPointer()
Just focus the cursor inside.
void SetLabel(const char *title)
Set label of selection box.
void SetEntry(TTVLVEntry *entry)
Connect one entry.
static TGSelectBox * GetInstance()
Return the pointer to the instantiated singleton.
Provides a StatusBar widget.
Definition TGStatusBar.h:21
void Draw3DCorner(Bool_t corner)
Definition TGStatusBar.h:59
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
const char * GetString() const
Definition TGString.h:30
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
void Clear(Option_t *option="") override
Clears up the text entry.
const char * GetText() const
virtual void SetCursorPosition(Int_t pos)
Set the cursor position to newPos.
virtual void AppendText(const char *text)
Appends text to the end of text entry, clears the selection and moves the cursor to the end of the li...
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text entry widget.
A toolbar is a composite frame that contains TGPictureButtons.
Definition TGToolBar.h:33
void SetFrame(TGFrame *frame, Bool_t left) override
Set frame to be resized.
A vertical 3D line is a line that can be used to separate groups of widgets.
Definition TG3DLine.h:33
A composite frame that layout their children in vertical way.
Definition TGFrame.h:374
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
TAxis * GetZaxis()
Definition TH1.h:326
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6739
TAxis * GetXaxis()
Definition TH1.h:324
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:3857
TAxis * GetYaxis()
Definition TH1.h:325
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
Collectable string class.
Definition TObjString.h:28
TString & String()
Definition TObjString.h:48
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
Definition TObject.cxx:954
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:979
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:408
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:530
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:2992
A TRootHelpDialog is used to display help text (or any text in a dialog window).
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
void Popup()
Show help dialog.
Sequenceable collection abstract base class.
Spider class.
Definition TSpider.h:40
void Draw(Option_t *options="") override
Draw the spider.
Definition TSpider.cxx:454
Basic string class.
Definition TString.h:139
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
const char * Data() const
Definition TString.h:376
TString & Remove(Ssiz_t pos)
Definition TString.h:685
TString & Append(const char *cs)
Definition TString.h:572
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1063
virtual const char * GetError()
Return system error string.
Definition TSystem.cxx:254
This class represent the list view container for the TreeView class.
void SelectItem(const char *name)
Select an item.
void SetViewer(TTreeViewer *viewer)
TList * ExpressionList()
Return the list of user-defined expressions.
const char * Cut()
Return the cut entry.
const char * Ez()
Return the expression on Z.
const char * Ey()
Return the expression on Y.
const char * ScanList()
Return the cut entry.
virtual void AddThisItem(TTVLVEntry *item)
TTVLVEntry * ExpressionItem(Int_t index)
Return the expression item at specific position.
void SetListView(TGListView *lv) override
const char * Ex()
Return the expression on X.
void EmptyAll()
Clear all names and aliases for expression type items.
void RemoveNonStatic()
Remove all non-static items from the list view, except expressions.
This class represent entries that goes into the TreeViewer listview container.
TGItemContext * GetContext()
void SetSmallPic(const TGPicture *spic)
Set small picture.
void SetAlias(const char *alias)
void SetToolTipText(const char *text, Long_t delayms=1000)
Set tool tip text associated with this item.
void SetTrueName(const char *name)
const char * ConvertAliases()
Convert all aliases into true names.
const char * GetAlias()
void Empty()
Clear all names and alias.
const char * GetTrueName()
I/O classes for TreeViewer session handling.
Definition TTVSession.h:29
const char * GetName() const override
Returns name of object.
Definition TTVSession.h:57
I/O classes for TreeViewer session handling.
Definition TTVSession.h:75
TTVRecord * Last()
Definition TTVSession.h:95
void SaveSource(std::ofstream &out)
Save the TTVSession in a C++ macro file.
TTVRecord * GetRecord(Int_t i)
Return record at index i.
void SetRecordName(const char *name)
Set record name.
void Show(TTVRecord *rec)
Display record rec.
TTVRecord * GetCurrent()
Definition TTVSession.h:92
TTVRecord * AddRecord(bool fromFile=false)
Add a record.
TTVRecord * Previous()
Definition TTVSession.h:97
Int_t GetEntries()
Definition TTVSession.h:91
TTVRecord * First()
Definition TTVSession.h:94
void RemoveLastRecord()
Remove current record from list.
TTVRecord * Next()
Definition TTVSession.h:96
void UpdateRecord(const char *name)
Updates current record according to new X, Y, Z settings.
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
virtual void TurnOff()
Remove timer from system timer list.
Definition TTimer.cxx:231
virtual void TurnOn()
Add the timer to the system timer list.
Definition TTimer.cxx:243
void Reset()
Reset the timer.
Definition TTimer.cxx:159
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition TTreePlayer.h:37
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features.
Definition TTreeViewer.h:54
void SetScanRedirect(bool mode)
TGLabel * fBarLbl2
Label of option text entry.
TGSelectBox * fDialogBox
Expression editor.
Definition TTreeViewer.h:87
void SetCurrentRecord(Long64_t entry)
TGCheckButton * fBarRec
Command recording toggle.
TGHProgressBar * fProgressBar
Progress bar.
bool HandleTimer(TTimer *timer) override
Execute action in response of a timer timing out.
void SetHistogramTitle(const char *title)
const char * Ez()
void UpdateRecord(const char *name="new name")
TGTextEntry * fBarOption
Histogram drawing option entry.
TGLabel * fBLbl4
Label for input list entry.
TGTextEntry * fBarCommand
User command entry.
TGPopupMenu * fOptions2D
TGListView * fListView
ListView with branches and leaves.
TGComboBox * fCombo
Combo box with session records.
void EditExpression()
TGListTree * fLt
ListTree with file and tree items.
TList * fWidgets
List of widgets to be deleted.
~TTreeViewer() override
void SetNexpressions(Int_t expr)
TTreeViewer(const char *treeName=nullptr)
TTreeViewer default constructor.
TGCheckButton * fBarH
Checked for drawing current histogram with different graphic option.
TGPictureButton * fBGFirst
void SetUserCode(const char *code, bool autoexec=true)
Cursor_t fDefaultCursor
Default cursor.
Definition TTreeViewer.h:96
void MapOptions(Long_t parm1)
TGLabel * fBLbl5
Label for output list entry.
TGCanvas * fTreeView
ListTree canvas container.
Int_t fTreeIndex
Index of current tree in list.
Definition TTreeViewer.h:89
void NewExpression()
TGPictureButton * fSTOP
Interrupt current command (not yet)
void SetSession(TTVSession *session)
void SetParentTree(TGListTreeItem *item)
const char * EmptyBrackets(const char *name)
const TGPicture * fPicStop
Pictures for Stop buttons.
Definition TTreeViewer.h:94
void CloseWindow() override
Close and delete main frame.
const TGPicture * fPicY
Pictures for Y expressions.
Definition TTreeViewer.h:91
TGMenuBar * fMenuBar
TGLabel * fLbl2
Label for list view.
TTVLVEntry * ExpressionItem(Int_t index)
Cursor_t fWatchCursor
Watch cursor.
Definition TTreeViewer.h:97
void AppendTree(TTree *tree)
TGPopupMenu * fRunMenu
TGTextEntry * fBarListIn
Tree input event list name entry.
void ActivateButtons(bool first, bool previous, bool next, bool last)
TTimer * fTimer
Tree viewer timer.
Definition TTreeViewer.h:98
void MapTree(TTree *tree, TGListTreeItem *parent=nullptr, bool listIt=true)
Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0)
TGCheckButton * fBarScan
Checked for tree scan.
void ExecuteDraw()
const TGPicture * fPicRefr
Pictures for Refresh buttons ///<ia.
Definition TTreeViewer.h:95
const char * fSourceFile
Name of the C++ source file - default treeviewer.C.
Definition TTreeViewer.h:79
Int_t MakeSelector(const char *selector=nullptr)
TGPopupMenu * fOptions1D
bool fCounting
True if timer is counting.
Definition TTreeViewer.h:99
const TGPicture * fPicX
Pictures for X expressions.
Definition TTreeViewer.h:90
bool fScanMode
Flag activated when Scan Box is double-clicked.
Definition TTreeViewer.h:85
void DoError(int level, const char *location, const char *fmt, va_list va) const override
Interface to ErrorHandler (protected).
void SetRecordName(const char *name)
TGPictureButton * fDRAW
DRAW button.
const char * Cut()
TString fLastOption
Last graphic option.
Definition TTreeViewer.h:80
TList * fTreeList
List of mapped trees.
Definition TTreeViewer.h:88
const char * fFilename
Name of the file containing the tree.
Definition TTreeViewer.h:78
void RemoveItem()
TGTextEntry * fBarHist
Histogram name entry.
TGLayoutHints * fBarLayout
TContextMenu * fContextMenu
Context menu for tree viewer.
Definition TTreeViewer.h:86
void EmptyAll()
TGHorizontalFrame * fHpb
Progress bar frame.
TGPopupMenu * fHelpMenu
TGPictureButton * fBGNext
Int_t fNexpressions
Number of expression widgets.
void SetTreeName(const char *treeName)
TGVerticalFrame * fV2
List view mother.
void Empty()
const char * En(Int_t n)
void MapBranch(TBranch *branch, const char *prefix="", TGListTreeItem *parent=nullptr, bool listIt=true)
TGLayoutHints * fMenuBarItemLayout
void SaveSource(const char *filename="", Option_t *option="") override
Save the GUI main frame widget in a C++ macro file.
void BuildInterface()
void UpdateCombo()
TClass * IsA() const override
TTree * fTree
Selected tree.
Definition TTreeViewer.h:76
const char * GetGrOpt()
TGCompositeFrame * fTreeHdr
Header for list tree.
TGLabel * fBarLbl3
Label of histogram name text entry.
Int_t Dimension()
bool fEnableCut
True if cuts are enabled.
bool SwitchTree(Int_t index)
void SetTree(TTree *tree)
bool fVarDraw
True if an item is double-clicked.
Definition TTreeViewer.h:84
TGDoubleVSlider * fSlider
Vertical slider to select processed tree entries;.
TTree * fMappedTree
Listed tree.
Definition TTreeViewer.h:81
TGVerticalFrame * fV1
List tree mother.
void DoRefresh()
void Message(const char *msg) override
void ExecuteCommand(const char *command, bool fast=false)
const TGPicture * fPicDraw
Pictures for Draw buttons.
Definition TTreeViewer.h:93
TGPictureButton * fBGLast
const char * Ex()
TList * ExpressionList()
void SetFile()
TGPopupMenu * fOptionsMenu
void RemoveLastRecord()
TGLayoutHints * fMenuBarHelpLayout
TGPictureButton * fBGPrevious
void PrintEntries()
TTVLVContainer * fLVContainer
Container for listview.
TGLabel * fLbl1
Label for list tree.
void SetGrOpt(const char *option)
TGPopupMenu * fOptionsGen
TGLayoutHints * fMenuBarLayout
TGLabel * fBarLbl1
Label of command text entry.
TGPictureButton * fREFR
REFRESH button ///<ia.
TGHorizontalFrame * fHf
Main horizontal frame.
const TGPicture * fPicZ
Pictures for Z expressions.
Definition TTreeViewer.h:92
const char * Ey()
TGToolBar * fToolBar
TGHorizontalFrame * fBFrame
Button frame.
const char * ScanList()
TGPopupMenu * fEditMenu
TBranch * fMappedBranch
Listed branch.
Definition TTreeViewer.h:82
TTVSession * fSession
Current tree-viewer session.
Definition TTreeViewer.h:77
Int_t fDimension
Histogram dimension.
Definition TTreeViewer.h:83
TGCompositeFrame * fListHdr
Header for list view.
bool fStopMapping
True if branch don't need remapping.
TGPopupMenu * fFileMenu
TGTextEntry * fBarListOut
Pree output event list name entry.
TGTextButton * fReset
clear expression's entries
bool ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
void ExecuteSpider()
bool IsScanRedirected()
TGPictureButton * fBGRecord
void SetScanFileName(const char *name="")
TGStatusBar * fStatusBar
Status bar.
TGTextButton * fSPIDER
SPIDER button.
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual void SetTimerInterval(Int_t msec=333)
Definition TTree.h:693
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition TTree.cxx:5294
virtual TObjArray * GetListOfLeaves()
Definition TTree.h:529
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition TTree.cxx:6305
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Process this tree executing the TSelector code in the specified filename.
Definition TTree.cxx:7450
virtual void SetEventList(TEventList *list)
This function transfroms the given TEventList into a TEntryList The new TEntryList is owned by the TT...
Definition TTree.cxx:9069
virtual Long64_t GetEntries() const
Definition TTree.h:463
virtual Int_t MakeSelector(const char *selector=nullptr, Option_t *option="")
Generate skeleton selector class for this tree.
Definition TTree.cxx:6822
virtual Long64_t GetReadEntry() const
Definition TTree.h:549
virtual TObjArray * GetListOfBranches()
Definition TTree.h:528
TH1 * GetHistogram()
Definition TTree.h:519
virtual void Refresh()
Refresh contents of this tree and its branches from the current status on disk.
Definition TTree.cxx:7916
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
__device__ AFloat max(AFloat x, AFloat y)
Definition Kernels.cuh:207
UInt_t GetListOfMethods(TList &methods, TDirectory *dir=nullptr)
Definition tmvaglob.cxx:590
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175