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
175### The HISTOGRAM and OPTION boxes
176
177As explained before, in the top bar, there is the "Histogram" box, prepopulated with the string "htemp",
178which will be the variable name where the drawn histogram will be stored. You can modify it to specify
179e.g. a specific 2D binning "htemp(100,0,10, 20,0,5)", in the same way that you would do it when calling
180TTree::Draw ( "x >> htemp(...)" ).
181Likewise, there is the "Option" box, where you can specify drawing options such as "SAME", "COLZ", etc.
182In fact, once you click on the Draw icon, the resulting behind-the-scenes executed command will be added
183to the ROOT history. You can go back to the command line and press arrow-up, to be able to edit it further
184if you prefer the command line rather than the GUI.
185
186### Comparing different cuts
187
188It's a common use case to define different cuts on your data and compare them in the same canvas. To do so,
189define an expression e1 and e2 by double clicking on the empty "E<>" icons. Drag-and-drop e1 into the scissors
190icon, click then on the Draw icon. Then, add the "same" to the "Option" box, and change "htemp" to "htemp2",
191finally drag-and-drop e2 to the scissors, and click on the Draw icon again. Finally, right click on the resulting
192histogram (htemp2), choose "DrawPanel" and change the color to make it distinguishable.
193You can also define, directly by double-clicking on the scissors icons, or by generating a third expression e3,
194more complex cuts such as (~e1) && (~e2), or (~e1) || !(~e2). Parentheses are important.
195
196\image html ttree_treeview.png
197*/
198
199#include "RConfigure.h"
200
201#include <iostream>
202#include <fstream>
203#include "TTreeViewer.h"
204#include "HelpText.h"
205#include "HelpTextTV.h"
206#include "TTVLVContainer.h"
207#include "TTVSession.h"
208
209#include "TROOT.h"
210#include "TError.h"
211#include "TGMsgBox.h"
212#include "TTreePlayer.h"
213#include "TContextMenu.h"
214#include "TInterpreter.h"
215#include "TLeaf.h"
216#include "TBranch.h"
217#include "TRootHelpDialog.h"
218#include "TSystem.h"
219#include "TApplication.h"
220#include "TVirtualX.h"
221#include "TGClient.h"
222#include "TKey.h"
223#include "TFile.h"
224#include "TGMenu.h"
225#include "TVirtualPad.h"
226#include "TH1.h"
227#include "TFriendElement.h"
228#include "TObjArray.h"
229#include "TObjString.h"
230#include "TGButton.h"
231#include "TGButtonGroup.h"
232#include "TGTextEntry.h"
233#include "TGComboBox.h"
234#include "TGLabel.h"
235#include "TGListView.h"
236#include "TGListTree.h"
237#include "TGMimeTypes.h"
238#include "TGSplitter.h"
239#include "TGDoubleSlider.h"
240#include "TGToolBar.h"
241#include "TGStatusBar.h"
242#include "Getline.h"
243#include "TTimer.h"
244#include "TG3DLine.h"
245#include "TGFileDialog.h"
246#include "TGProgressBar.h"
247#include "TSpider.h"
248#include "strlcpy.h"
249#include "snprintf.h"
250
251#include <filesystem>
252
253#ifdef WIN32
254#include "TWin32SplashThread.h"
255#endif
256
257// drawing options
258static const char* gOptgen[16] =
259{
260 "","AXIS","HIST","SAME","CYL","POL","SPH","PSR","LEGO","LEGO1","LEGO2",
261 "SURF","SURF1","SURF2","SURF3","SURF4"
262};
263static const char* gOpt1D[12] =
264{
265 "","AH","B","C","E","E1","E2","E3","E4","L","P","*H"
266};
267static const char* gOpt2D[14] =
268{
269 "","ARR","BOX","COL","COL2","CONT","CONT0","CONT1","CONT2","CONT3",
270 "FB","BB","SCAT","PROF"
271};
272
273static const char* gOpenTypes[] = {"Root files", "*.root",
274 nullptr, nullptr };
275
276static const char* gMacroTypes[] = {"C++ macros", "*.C",
277 nullptr, nullptr };
278
279// Menu command id's
321
322// button Id's
335
336
337////////////////////////////////////////////////////////////////////////////////
338/// TTreeViewer default constructor
339
340TTreeViewer::TTreeViewer(const char* treeName) :
341 TGMainFrame(nullptr,10,10,kVerticalFrame),
342 fDimension(0), fVarDraw(false), fScanMode(false),
344 fCounting(false), fStopMapping(false), fEnableCut(false),fNexpressions(0)
345{
346 fTree = nullptr;
347 if (!gClient) return;
348 char command[128];
349 gROOT->ProcessLine("#ifndef GTV_DEFINED\n\
350 TTreeViewer *gTV = 0;\n\
351 TTree *tv__tree = 0;\n\
352 TList *tv__tree_list = 0;\n\
353 TFile *tv__tree_file = 0;\n\
354 #define GTV_DEFINED\n\
355 #endif");
356 snprintf(command,128, "gTV = (TTreeViewer*)0x%zx", (size_t)this);
357 gROOT->ProcessLine(command);
358 fTreeList = new TList;
359 gROOT->ProcessLine("tv__tree_list = new TList;");
360 fFilename = "";
361 gInterpreter->SaveContext();
363 SetTreeName(treeName);
364}
365
366////////////////////////////////////////////////////////////////////////////////
367
368TTreeViewer::TTreeViewer(const TTree *tree) :
369 TGMainFrame(nullptr, 10, 10, kVerticalFrame),
370 fDimension(0), fVarDraw(false), fScanMode(false),
371 fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
372 fCounting(false), fStopMapping(false), fEnableCut(false),fNexpressions(0)
373
374{
375 // TTreeViewer constructor with a pointer to a Tree
376
377 fTree = nullptr;
378 char command[128];
379 gROOT->ProcessLine("#ifndef GTV_DEFINED\n\
380 TTreeViewer *gTV = 0;\n\
381 TTree *tv__tree = 0;\n\
382 TList *tv__tree_list = 0;\n\
383 TFile *tv__tree_file = 0;\n\
384 #define GTV_DEFINED\n\
385 #endif");
386 snprintf(command,128, "gTV = (TTreeViewer*)0x%zx", (size_t)this);
387 gROOT->ProcessLine(command);
388 if (!tree) return;
389 fTreeList = new TList;
390 gROOT->ProcessLine("tv__tree_list = new TList;");
391 fFilename = "";
392 gInterpreter->SaveContext();
394 TDirectory *dirsav = gDirectory;
395 TDirectory *cdir = tree->GetDirectory();
396 if (cdir) cdir->cd();
397
398 SetTree((TTree *)tree);
399 // If the tree is a chain, the tree directory will be changed by SwitchTree
400 // (called by SetTreeName)
401 cdir = tree->GetDirectory();
402 if (cdir) {
403 if (cdir->GetFile()) fFilename = cdir->GetFile()->GetName();
404 }
405 if (dirsav) dirsav->cd();
406}
407////////////////////////////////////////////////////////////////////////////////
408/// Allow geting the tree from the context menu.
409
411{
412 if (!tree) return;
413 TTree *ftree;
414 if (fTreeList) {
415 if (fTreeList->FindObject(tree)) {
416 printf("Tree found\n");
417 TIter next(fTreeList);
418 Int_t index = 0;
419 while ((ftree = (TTree*)next())) {
420 if (ftree==tree) {printf("found at index %i\n", index);break;}
421 index++;
422 }
423 SwitchTree(index);
424 if (fTree != fMappedTree) {
425 // switch also the global "tree" variable
426 fLVContainer->RemoveNonStatic();
427 // map it on the right panel
428 MapTree(fTree);
429 fListView->Layout();
430 TGListTreeItem *base = nullptr;
431 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
432 TGListTreeItem *item = fLt->FindChildByName(parent, fTree->GetName());
433 fLt->ClearHighlighted();
434 fLt->HighlightItem(item);
435 fClient->NeedRedraw(fLt);
436 }
437 return;
438 }
439 }
440 if (fTree != tree) {
441 fTree = tree;
442 // load the tree via the interpreter
443 char command[100];
444 command[0] = 0;
445 // define a global "tree" variable for the same tree
446 snprintf(command,100, "tv__tree = (TTree *)0x%zx;", (size_t)tree);
447 ExecuteCommand(command);
448 }
449 //--- add the tree to the list if it is not already in
450 if (fTreeList) fTreeList->Add(fTree);
451 ExecuteCommand("tv__tree_list->Add(tv__tree);");
452 //--- map this tree
453 TGListTreeItem *base = nullptr;
454 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
455 if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
456 ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
457 fTreeIndex++;
458 TGListTreeItem *lTreeItem = fLt->AddItem(parent, tree->GetName(), itemType,
459 gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
460 MapTree(fTree, lTreeItem, false);
461 fLt->OpenItem(parent);
462 fLt->HighlightItem(lTreeItem);
463 fClient->NeedRedraw(fLt);
464
465 //--- map slider and list view
467 fLVContainer->RemoveNonStatic();
468 MapTree(fTree);
469 fListView->Layout();
470 SetFile();
471}
472////////////////////////////////////////////////////////////////////////////////
473/// Change the number of expression widgets.
474
476{
477 Int_t diff = expr - fNexpressions;
478 if (diff <= 0) return;
479 if (!fLVContainer) return;
480 for (Int_t i=0; i<std::abs(diff); i++) NewExpression();
481}
482////////////////////////////////////////////////////////////////////////////////
483/// Set the name of the file where to redirect `<Scan>` output.
484
485void TTreeViewer::SetScanFileName(const char *name)
486{
487 if (fTree) ((TTreePlayer *)fTree->GetPlayer())->SetScanFileName(name);
488}
489////////////////////////////////////////////////////////////////////////////////
490/// Set the state of Scan check button.
491
492void TTreeViewer::SetScanRedirect(bool mode)
493{
494 if (mode)
495 fBarScan->SetState(kButtonDown);
496 else
497 fBarScan->SetState(kButtonUp);
498}
499////////////////////////////////////////////////////////////////////////////////
500/// Assign the fTree member from existing tree, e.g. when calling
501/// tree->StartViewer() from the browser, or even from the command line.
502
503void TTreeViewer::SetTree(TTree *tree)
504{
505 if (!tree) return;
506 if (fTree != tree) {
507 fTree = tree;
508 // load the tree via the interpreter
509 // define a global "tree" variable for the same tree
510 TString command = TString::Format("tv__tree = (TTree *)0x%zx;", (size_t)tree);
511 ExecuteCommand(command.Data());
512 }
513 //--- add the tree to the list if it is not already in
514 if (fTreeList) fTreeList->Add(fTree);
515 ExecuteCommand("tv__tree_list->Add(tv__tree);");
516 //--- map this tree
517 TGListTreeItem *base = nullptr;
518 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
519 if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
520 ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
521 fTreeIndex++;
522 TGListTreeItem *lTreeItem = fLt->AddItem(parent, tree->GetName(), itemType,
523 gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
524 MapTree(fTree, lTreeItem, false);
525 fLt->OpenItem(parent);
526 fLt->HighlightItem(lTreeItem);
527 fClient->NeedRedraw(fLt);
528
529 //--- map slider and list view
531 fLVContainer->RemoveNonStatic();
532 MapTree(fTree);
533 fListView->Layout();
534 SetFile();
535}
536////////////////////////////////////////////////////////////////////////////////
537/// Allow geting the tree from the context menu.
538
539void TTreeViewer::SetTreeName(const char* treeName)
540{
541 if (!treeName) return;
542 TTree *tree = (TTree *) gROOT->FindObject(treeName);
543 if (fTreeList) {
544 if (fTreeList->FindObject(treeName)) {
545 printf("Tree found\n");
546 TIter next(fTreeList);
547 Int_t index = 0;
548 while ((tree = (TTree*)next())) {
549 if (!strcmp(treeName, tree->GetName())) {printf("found at index %i\n", index);break;}
550 index++;
551 }
552 SwitchTree(index);
553 if (fTree != fMappedTree) {
554 // switch also the global "tree" variable
555 fLVContainer->RemoveNonStatic();
556 // map it on the right panel
557 MapTree(fTree);
558 fListView->Layout();
559 TGListTreeItem *base = nullptr;
560 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
561 TGListTreeItem *item = fLt->FindChildByName(parent, fTree->GetName());
562 fLt->ClearHighlighted();
563 fLt->HighlightItem(item);
564 fClient->NeedRedraw(fLt);
565 }
566 return;
567 }
568 }
569 if (!tree) return;
570// ((TTreePlayer *)tree->GetPlayer())->SetViewer(this);
571 if (fTree != tree) {
572 fTree = tree;
573 // load the tree via the interpreter
574 // define a global "tree" variable for the same tree
575 TString command = TString::Format("tv__tree = (TTree *) gROOT->FindObject(\"%s\");", treeName);
576 ExecuteCommand(command.Data());
577 }
578 //--- add the tree to the list if it is not already in
579 if (fTreeList) fTreeList->Add(fTree);
580 ExecuteCommand("tv__tree_list->Add(tv__tree);");
581 //--- map this tree
582 TGListTreeItem *base = nullptr;
583 TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
584 if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
585 ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
586 fTreeIndex++;
587 TGListTreeItem *lTreeItem = fLt->AddItem(parent, treeName, itemType,
588 gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
589 MapTree(fTree, lTreeItem, false);
590 fLt->OpenItem(parent);
591 fLt->HighlightItem(lTreeItem);
592 fClient->NeedRedraw(fLt);
593
594 //--- map slider and list view
596 fLVContainer->RemoveNonStatic();
597 MapTree(fTree);
598 fListView->Layout();
599 SetFile();
600}
601////////////////////////////////////////////////////////////////////////////////
602/// Set file name containing the tree.
603
605{
606 if (!fTree) return;
607 TSeqCollection *list = gROOT->GetListOfFiles();
608 TTree *tree;
609 TIter next(list);
610 TObject *obj;
611 TFile *file;
612 while ((obj=next())) {
613 file = (TFile*)obj;
614 if (file) {
615 tree = (TTree*)file->Get(fTree->GetName());
616 if (tree) {
617 fFilename = file->GetName();
618 std::cout << "File name : "<< fFilename << std::endl;
619 return;
620 } else {
621 fFilename = "";
622 }
623 }
624 }
625 fFilename = "";
626}
627////////////////////////////////////////////////////////////////////////////////
628/// Create all viewer widgets.
629
631{
632 //--- timer & misc
633 fCounting = false;
634 fScanMode = false;
635 fEnableCut = true;
636 fTimer = new TTimer(this, 20, true);
637 fLastOption = "";
638 fSession = new TTVSession(this);
639 //--- cursors
640 fDefaultCursor = gVirtualX->CreateCursor(kPointer);
641 fWatchCursor = gVirtualX->CreateCursor(kWatch);
642 //--- colours
643 ULong_t color;
644 gClient->GetColorByName("blue",color);
645 //--- pictures for X, Y and Z expression items
646 fPicX = gClient->GetPicture("x_pic.xpm");
647 fPicY = gClient->GetPicture("y_pic.xpm");
648 fPicZ = gClient->GetPicture("z_pic.xpm");
649
650 //--- general context menu
651 fContextMenu = new TContextMenu("TreeViewer context menu","");
652 fMappedTree = nullptr;
653 fMappedBranch = nullptr;
654 fDialogBox = nullptr;
655 fDimension = 0;
656 fVarDraw = false;
657 fStopMapping = false;
658// fFilename = "";
659 fSourceFile = "treeviewer.C";
660 //--- lists : trees and widgets to be removed
661// fTreeList = 0;
662 fTreeIndex = 0;
663 fWidgets = new TList();
664 //--- create menus --------------------------------------------------------
665 //--- File menu
666 fFileMenu = new TGPopupMenu(fClient->GetRoot());
667 fFileMenu->AddEntry("&New canvas", kFileCanvas);
668 fFileMenu->AddEntry("Open &tree file...", kFileBrowse);
669 fFileMenu->AddEntry("&Load Library...", kFileLoadLibrary);
670 fFileMenu->AddEntry("&Open session", kFileOpenSession);
671 fFileMenu->AddEntry("&Save source...", kFileSaveMacro);
672 fFileMenu->AddSeparator();
673 fFileMenu->AddEntry("&Print", kFilePrint);
674 fFileMenu->AddEntry("&Close", kFileClose);
675 fFileMenu->AddSeparator();
676 fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
677
678 fFileMenu->DisableEntry(kFilePrint);
679
680 //--- Edit menu
681 fEditMenu = new TGPopupMenu(gClient->GetRoot());
682 fEditMenu->AddEntry("&Expression...", kEditExpression);
683 fEditMenu->AddEntry("&Cut...", kEditCut);
684 fEditMenu->AddEntry("&Macro...", kEditMacro);
685 fEditMenu->AddEntry("E&Vent...", kEditEvent);
686
687 fEditMenu->DisableEntry(kEditMacro);
688 fEditMenu->DisableEntry(kEditEvent);
689 //---Run menu
690 fRunMenu = new TGPopupMenu(gClient->GetRoot());
691 fRunMenu->AddEntry("&Macro...", kRunMacro);
692 fRunMenu->DisableEntry(kRunMacro);
693 //--- Options menu
694 //--- General options
695 fOptionsGen = new TGPopupMenu(gClient->GetRoot());
696 fOptionsGen->AddEntry("Default", kOptionsGeneral);
697 fOptionsGen->AddSeparator();
698 fOptionsGen->AddEntry("Axis only", kOptionsGeneral+1); // "AXIS"
699 fOptionsGen->AddEntry("Contour only", kOptionsGeneral+2); // "HIST"
700 fOptionsGen->AddEntry("Superimpose", kOptionsGeneral+3); //"SAME"
701 fOptionsGen->AddEntry("Cylindrical", kOptionsGeneral+4); //"CYL"
702 fOptionsGen->AddEntry("Polar", kOptionsGeneral+5); //"POL"
703 fOptionsGen->AddEntry("Spherical", kOptionsGeneral+6); //"SPH"
704 fOptionsGen->AddEntry("PsRap/Phi", kOptionsGeneral+7); //"PSR"
705 fOptionsGen->AddEntry("Lego HLR", kOptionsGeneral+8); //"LEGO"
706 fOptionsGen->AddEntry("Lego HSR", kOptionsGeneral+9); //"LEGO1"
707 fOptionsGen->AddEntry("Lego Color", kOptionsGeneral+10); //"LEGO2"
708 fOptionsGen->AddEntry("Surface HLR", kOptionsGeneral+11); //"SURF"
709 fOptionsGen->AddEntry("Surface HSR", kOptionsGeneral+12); //"SURF1"
710 fOptionsGen->AddEntry("Surface Col", kOptionsGeneral+13); //"SURF2"
711 fOptionsGen->AddEntry("Surf+Cont", kOptionsGeneral+14); //"SURF3"
712 fOptionsGen->AddEntry("Gouraud", kOptionsGeneral+15); //"SURF4"
713 fOptionsGen->Associate(this);
714 //--- 1D options
715 fOptions1D = new TGPopupMenu(gClient->GetRoot());
716 fOptions1D->AddEntry("Default", kOptions1D);
717 fOptions1D->AddSeparator();
718 fOptions1D->AddEntry("No labels/ticks", kOptions1D+1); // "AH"
719 fOptions1D->AddEntry("Bar chart", kOptions1D+2); // "B"
720 fOptions1D->AddEntry("Smooth curve", kOptions1D+3); // "C"
721 fOptions1D->AddEntry("Errors", kOptions1D+4); // "E"
722 fOptions1D->AddEntry("Errors 1", kOptions1D+5); // "E1"
723 fOptions1D->AddEntry("Errors 2", kOptions1D+6); // "E2"
724 fOptions1D->AddEntry("Errors 3", kOptions1D+7); // "E3"
725 fOptions1D->AddEntry("Errors 4", kOptions1D+8); // "E4"
726 fOptions1D->AddEntry("Line", kOptions1D+9); // "L"
727 fOptions1D->AddEntry("Markers", kOptions1D+10); // "P"
728 fOptions1D->AddEntry("Stars", kOptions1D+11); // "*H"
729 fOptions1D->Associate(this);
730 //--- 2D options
731 fOptions2D = new TGPopupMenu(gClient->GetRoot());
732 fOptions2D->AddEntry("Default", kOptions2D);
733 fOptions2D->AddSeparator();
734 fOptions2D->AddEntry("Arrows", kOptions2D+1); // "ARR"
735 fOptions2D->AddEntry("Box/Surf", kOptions2D+2); // "BOX"
736 fOptions2D->AddEntry("Box/Color", kOptions2D+3); // "COL"
737 fOptions2D->AddEntry("Box/ColMap", kOptions2D+4); // "COLZ"
738 fOptions2D->AddEntry("Contour", kOptions2D+5); // "CONT"
739 fOptions2D->AddEntry("Contour 0", kOptions2D+6); // "CONT0"
740 fOptions2D->AddEntry("Contour 1", kOptions2D+7); // "CONT1"
741 fOptions2D->AddEntry("Contour 2", kOptions2D+8); // "CONT2"
742 fOptions2D->AddEntry("Contour 3", kOptions2D+9); // "CONT3"
743 fOptions2D->AddEntry("No front-box", kOptions2D+10); // "FB"
744 fOptions2D->AddEntry("No back-box", kOptions2D+11); // "BB"
745 fOptions2D->AddEntry("Scatter", kOptions2D+12); // "SCAT"
746 fOptions2D->AddEntry("Profile", kOptions2D+13); // "SCAT"
747 fOptions2D->Associate(this);
748
749 fOptionsMenu = new TGPopupMenu(gClient->GetRoot());
750 fOptionsMenu->AddPopup("&General Options...", fOptionsGen);
751 fOptionsMenu->AddPopup("&1D Options", fOptions1D);
752 fOptionsMenu->AddPopup("&2D Options", fOptions2D);
753 fOptionsMenu->AddSeparator();
754 fOptionsMenu->AddEntry("&Reset options", kOptionsReset);
755 //--- Help menu
756 fHelpMenu = new TGPopupMenu(gClient->GetRoot());
757 fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
758 fHelpMenu->AddEntry("&About TreeViewer...", kHelpAboutTV);
759 fHelpMenu->AddSeparator();
760 fHelpMenu->AddEntry("&Starting...", kHelpStart);
761 fHelpMenu->AddEntry("&Layout...", kHelpLayout);
762 fHelpMenu->AddEntry("&Open/Save", kHelpOpenSave);
763 fHelpMenu->AddEntry("&Dragging...", kHelpDragging);
764 fHelpMenu->AddEntry("&Editing expressions...",kHelpEditing);
765 fHelpMenu->AddEntry("&Session...", kHelpSession);
766 fHelpMenu->AddEntry("&User commands...", kHelpCommands);
767 fHelpMenu->AddEntry("&Context menus...", kHelpContext);
768 fHelpMenu->AddEntry("D&rawing...", kHelpDrawing);
769 fHelpMenu->AddEntry("&Macros...", kHelpMacros);
770
771 fFileMenu->Associate(this);
772 fEditMenu->Associate(this);
773 fRunMenu->Associate(this);
774 fOptionsMenu->Associate(this);
775 fHelpMenu->Associate(this);
776
777 //--- menubar layout hints
778 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0,0,1,1);
779 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
780 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
781 //--- create menubar and add popup menus
782 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
783
784 fMenuBar->AddPopup("&File", fFileMenu, fMenuBarItemLayout);
785 fMenuBar->AddPopup("&Edit", fEditMenu, fMenuBarItemLayout);
786 fMenuBar->AddPopup("&Run", fRunMenu, fMenuBarItemLayout);
787 fMenuBar->AddPopup("&Options", fOptionsMenu, fMenuBarItemLayout);
788 fMenuBar->AddPopup("&Help", fHelpMenu, fMenuBarHelpLayout);
789
791 //--- toolbar ----------------------------------------------------------------
792 fToolBar = new TGToolBar(this, 10, 10, kHorizontalFrame);
793 fBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
794
795 TGLayoutHints *lo;
796 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
797 fWidgets->Add(lo);
798 //--- label for Command text entry
799 fBarLbl1 = new TGLabel(fToolBar,"Command");
800 fToolBar->AddFrame(fBarLbl1,lo);
801 //--- command text entry
802 fBarCommand = new TGTextEntry(fToolBar, new TGTextBuffer(250),kBarCommand);
803 fBarCommand->SetWidth(120);
804 fBarCommand->Associate(this);
805 fBarCommand->SetToolTipText("User commands executed via interpreter. Type <ENTER> to execute");
806 fToolBar->AddFrame(fBarCommand, lo);
807 //--- first vertical separator
808 TGVertical3DLine *vSeparator = new TGVertical3DLine(fToolBar);
809 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,4,0,0);
810 fWidgets->Add(lo);
811 fWidgets->Add(vSeparator);
812 fToolBar->AddFrame(vSeparator, lo);
813
814 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
815 fWidgets->Add(lo);
816 //--- label for Option text entry
817 fBarLbl2 = new TGLabel(fToolBar,"Option");
818 fToolBar->AddFrame(fBarLbl2, lo);
819 //--- drawing option text entry
820 fBarOption = new TGTextEntry(fToolBar, new TGTextBuffer(200),kBarOption);
821 fBarOption->SetWidth(100);
822 fBarOption->Associate(this);
823 fBarOption->SetToolTipText("Histogram graphics option. Type option here and click <Draw> (or <ENTER> to update current histogram).");
824 fToolBar->AddFrame(fBarOption, lo);
825 //--- second vertical separator
826 vSeparator = new TGVertical3DLine(fToolBar);
827 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,4,0,0);
828 fWidgets->Add(lo);
829 fWidgets->Add(vSeparator);
830 fToolBar->AddFrame(vSeparator, lo);
831
832 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
833 fWidgets->Add(lo);
834 //--- label for Histogram text entry
835 fBarLbl3 = new TGLabel(fToolBar,"Histogram");
836 fToolBar->AddFrame(fBarLbl3, lo);
837
838 //--- histogram name text entry
839 lo = new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 4,4,0,0);
840 fWidgets->Add(lo);
841 fBarHist = new TGTextEntry(fToolBar, new TGTextBuffer(100));
842 fBarHist->Resize(50, fBarHist->GetDefaultHeight());
843 fBarHist->SetDefaultSize(50, fBarHist->GetDefaultHeight());
844 fBarHist->SetText("htemp");
845 fToolBar->AddFrame(fBarHist, lo);
846
847 //--- Hist check button
848 lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
849 fWidgets->Add(lo);
850 fBarH = new TGCheckButton(fToolBar, "Hist");
851 fBarH->SetToolTipText("Checked : redraw only current histogram");
852 fBarH->SetState(kButtonUp);
853 fToolBar->AddFrame(fBarH, lo);
854 //--- Scan check button
855 fBarScan = new TGCheckButton(fToolBar, "Scan");
856 fBarScan->SetState(kButtonUp);
857 fBarScan->SetToolTipText("Check to redirect TTree::Scan command in a file");
858 fToolBar->AddFrame(fBarScan, lo);
859 //--- Rec check button
860 fBarRec = new TGCheckButton(fToolBar, "Rec");
861 fBarRec->SetState(kButtonDown);
862 fBarRec->SetToolTipText("Check to record commands in history file and be verbose");
863 fToolBar->AddFrame(fBarRec, lo);
864 //--- 1'st horizontal tool bar separator ----------------------------------------
865 TGHorizontal3DLine *toolBarSep = new TGHorizontal3DLine(this);
866 fWidgets->Add(toolBarSep);
867 AddFrame(toolBarSep, fBarLayout);
869 //--- 2'nd horizontal tool bar separator ----------------------------------------
870 toolBarSep = new TGHorizontal3DLine(this);
871 fWidgets->Add(toolBarSep);
872 AddFrame(toolBarSep, fBarLayout);
873
874 //--- Horizontal mother frame ---------------------------------------------------
875 fHf = new TGHorizontalFrame(this, 10, 10);
876 //--- Vertical frames
877 fSlider = new TGDoubleVSlider(fHf, 10, kDoubleScaleBoth, kSLIDER);
878// fSlider->SetBackgroundColor(color);
879 fSlider->Associate(this);
880
881 //--- fV1 -----------------------------------------------------------------------
882 fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
884
885 fLbl1 = new TGLabel(fTreeHdr, "Current Folder");
886 lo = new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY, 3, 0, 0, 0);
887 fWidgets->Add(lo);
888 fTreeHdr->AddFrame(fLbl1, lo);
889
890 lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 1, 0);
891 fWidgets->Add(lo);
892 fV1->AddFrame(fTreeHdr, lo);
893
894 //--- tree view canvas on the left
895 fTreeView = new TGCanvas(fV1, fV1->GetWidth(), 10, kSunkenFrame | kDoubleBorder);
896 //--- container frame
897 fLt = new TGListTree(fTreeView->GetViewPort(), 10, 10, kHorizontalFrame,
898 GetWhitePixel());
899 fLt->Associate(this);
900 fTreeView->SetContainer(fLt);
901
902 lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2,0,0,0);
903 fWidgets->Add(lo);
904 fV1->AddFrame(fTreeView, lo);
905
906 //--- button horizontal frame
907 fHpb = new TGHorizontalFrame(fV1, fTreeHdr->GetWidth(), 10, kSunkenFrame);
908
909 //--- DRAW button
910 fPicDraw = gClient->GetPicture("draw_t.xpm");
911 fDRAW = new TGPictureButton(fHpb,fPicDraw,kDRAW);
912 fDRAW->SetToolTipText("Draw current selection");
913 fDRAW->Associate(this);
914
915 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
916 fWidgets->Add(lo);
917 fHpb->AddFrame(fDRAW, lo);
918
919 //--- SPIDER button
920 fSPIDER = new TGTextButton(fHpb,"SPIDER");
921 fSPIDER->SetToolTipText("Scan current selection using a spider plot");
922 fSPIDER->Associate(this);
923
924 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
925 fWidgets->Add(lo);
926 fHpb->AddFrame(fSPIDER,lo);
927 //---connect SPIDER button to ExecuteScan() method
928 fSPIDER->Connect("Clicked()","TTreeViewer",this,"ExecuteSpider()");
929
930 //--- STOP button (breaks current operation)
931// fPicStop = gClient->GetPicture("mb_stop_s.xpm");
932 fPicStop = gClient->GetPicture("stop_t.xpm");
933 fSTOP = new TGPictureButton(fHpb,fPicStop,kSTOP);
934 fSTOP->SetToolTipText("Abort current operation");
935 fSTOP->Associate(this);
936
937 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
938 fWidgets->Add(lo);
939 fHpb->AddFrame(fSTOP, lo);
940
941 //--- REFR button (breaks current operation)
942 fPicRefr = gClient->GetPicture("refresh2.xpm");
943 fREFR = new TGPictureButton(fHpb,fPicRefr,kDRAW);
944 fREFR->SetToolTipText("Update the tree viewer");
945 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
946 fWidgets->Add(lo);
947 fHpb->AddFrame(fREFR, lo);
948 //---connect REFR button to DoRefresh() method
949 fREFR->Connect("Clicked()", "TTreeViewer", this, "DoRefresh()");
950
951 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,2,2);
952 fWidgets->Add(lo);
953 fV1->AddFrame(fHpb, lo);
954
955 //--- fV2
956 fV2 = new TGVerticalFrame(fHf, 10, 10);
958 fLbl2 = new TGLabel(fListHdr, "Current Tree: ");
959 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 0, 0, 0);
960 fWidgets->Add(lo);
961 fListHdr->AddFrame(fLbl2, lo);
962
963 //--- progress bar
964 fProgressBar = new TGHProgressBar(fListHdr);
965 fProgressBar->SetBarColor("red");
967 lo = new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 2,2,4,2);
968 fWidgets->Add(lo);
969 fListHdr->AddFrame(fProgressBar, lo);
970 lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 2,0,1,2);
971 fWidgets->Add(lo);
972 fV2->AddFrame(fListHdr, lo);
973
974 fV1->Resize(fTreeHdr->GetDefaultWidth()+100, fV1->GetDefaultHeight());
975 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY);
976 fWidgets->Add(lo);
977 fHf->AddFrame(fSlider, lo);
978 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY);
979 fWidgets->Add(lo);
980 fHf->AddFrame(fV1, lo);
981
982 //--- vertical splitter
983 TGVSplitter *splitter = new TGVSplitter(fHf);
984 splitter->SetFrame(fV1,true);
985 lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY);
986 fWidgets->Add(splitter);
987 fWidgets->Add(lo);
988 fHf->AddFrame(splitter,lo);
989
990
991
992 //-- listview for the content of the tree/branch -----------------------------
993 fListView = new TGListView(fListHdr,400,300);
994 //--- container frame
995 fLVContainer = new TTVLVContainer(fListView->GetViewPort(),400,300);
996 fLVContainer->Associate(this);
997 fLVContainer->SetListView(fListView);
998 fLVContainer->SetViewer(this);
999 fLVContainer->SetBackgroundColor(GetWhitePixel());
1000 fListView->GetViewPort()->SetBackgroundColor(GetWhitePixel());
1001 fListView->SetContainer(fLVContainer);
1002 fListView->SetViewMode(kLVList);
1003 lo = new TGLayoutHints(kLHintsRight | kLHintsTop | kLHintsExpandX | kLHintsExpandY);
1004 fWidgets->Add(lo);
1005
1006 fListHdr->AddFrame(fListView,lo);
1007
1008 lo = new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY);
1009 fWidgets->Add(lo);
1010 fHf->AddFrame(fV2,lo);
1011
1012 AddFrame(fHf, lo);
1013 //--- 3rd horizontal tool bar separator ----------------------------------------
1014 toolBarSep = new TGHorizontal3DLine(this);
1015 fWidgets->Add(toolBarSep);
1016 AddFrame(toolBarSep, fBarLayout);
1017
1018 //--- label for IList text entry
1019 fBFrame = new TGHorizontalFrame(this,10,10);
1020 fBLbl4 = new TGLabel(fBFrame,"IList");
1021 lo = new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2,2,2,2);
1022 fWidgets->Add(lo);
1023 fBFrame->AddFrame(fBLbl4, lo);
1024 //--- IList text entry
1025 fBarListIn = new TGTextEntry(fBFrame, new TGTextBuffer(100));
1026 fBarListIn->SetWidth(60);
1027 fBarListIn->SetToolTipText("Name of a previously created event list");
1028 fBFrame->AddFrame(fBarListIn, lo);
1029 //--- label for OList text entry
1030 fBLbl5 = new TGLabel(fBFrame,"OList");
1031 fBFrame->AddFrame(fBLbl5, lo);
1032 //--- OList text entry
1033 fBarListOut = new TGTextEntry(fBFrame, new TGTextBuffer(100));
1034 fBarListOut->SetWidth(60);
1035 fBarListOut->SetToolTipText("Output event list. Use <Draw> to generate it.");
1036 fBFrame->AddFrame(fBarListOut, lo);
1037 //--- Status bar
1038 fStatusBar = new TGStatusBar(fBFrame, 10, 10);
1039 fStatusBar->SetWidth(200);
1040 fStatusBar->Draw3DCorner(false);
1041 lo = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsLeft | kLHintsExpandX, 2,2,2,2);
1042 fWidgets->Add(lo);
1043 fBFrame->AddFrame(fStatusBar, lo);
1044 //--- RESET button
1045 fReset = new TGTextButton(fBFrame,"RESET",kRESET);
1046 fReset->SetToolTipText("Reset variable's fields and drawing options");
1047 fReset->Associate(this);
1048 lo = new TGLayoutHints(kLHintsTop | kLHintsRight, 2,2,2,2);
1049 fWidgets->Add(lo);
1050 fBFrame->AddFrame(fReset,lo);
1051 //--- group of buttons for session handling
1052 fBGFirst = new TGPictureButton(fBFrame,
1053 gClient->GetPicture("first_t.xpm"), kBGFirst);
1054 fBGFirst->SetToolTipText("First record");
1055 fBGFirst->Associate(this);
1056 fBGPrevious = new TGPictureButton(fBFrame,
1057 gClient->GetPicture("previous_t.xpm"), kBGPrevious);
1058 fBGPrevious->SetToolTipText("Previous record");
1059 fBGPrevious->Associate(this);
1060 fBGRecord = new TGPictureButton(fBFrame,
1061 gClient->GetPicture("record_t.xpm"), kBGRecord);
1062 fBGRecord->SetToolTipText("Record");
1063 fBGRecord->Associate(this);
1064 fBGNext = new TGPictureButton(fBFrame,
1065 gClient->GetPicture("next_t.xpm"), kBGNext);
1066 fBGNext->SetToolTipText("Next record");
1067 fBGNext->Associate(this);
1068 fBGLast = new TGPictureButton(fBFrame,
1069 gClient->GetPicture("last_t.xpm"), kBGLast);
1070 fBGLast->SetToolTipText("Last record");
1071 fBGLast->Associate(this);
1072
1073 fCombo = new TGComboBox(fBFrame, 0);
1074 fCombo->SetHeight(fReset->GetDefaultHeight());
1075 fCombo->SetWidth(100);
1076 fCombo->Associate(this);
1077
1078 lo = new TGLayoutHints(kLHintsCenterY | kLHintsRight, 0,0,2,0);
1079 fWidgets->Add(lo);
1080 fBFrame->AddFrame(fCombo, lo);
1081 fBFrame->AddFrame(fBGLast, lo);
1082 fBFrame->AddFrame(fBGNext, lo);
1083 fBFrame->AddFrame(fBGRecord, lo);
1084 fBFrame->AddFrame(fBGPrevious, lo);
1085 fBFrame->AddFrame(fBGFirst, lo);
1086 lo = new TGLayoutHints(kLHintsExpandX,2,2,2,0);
1087 fWidgets->Add(lo);
1088 AddFrame(fBFrame,lo);
1089
1090 // map the window
1091 SetWindowName("TreeViewer");
1092 MapSubwindows();
1094 MapWindow();
1095
1096 // put default items in the listview on the right
1097 const TGPicture *pic, *spic;
1098
1099 fLVContainer->RemoveAll();
1100 TTVLVEntry* entry;
1101 Char_t symbol;
1102 entry = new TTVLVEntry(fLVContainer,fPicX,fPicX,new TGString(),nullptr,kLVSmallIcons);
1103 symbol = 'X';
1104 entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1105 entry->SetToolTipText("X expression. Drag and drop expressions here");
1106 //--- X item
1107 fLVContainer->AddThisItem(entry);
1108 entry->Empty();
1109 entry->MapWindow();
1110
1111 entry = new TTVLVEntry(fLVContainer,fPicY,fPicY,new TGString(),nullptr,kLVSmallIcons);
1112 symbol = 'Y';
1113 entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1114 entry->SetToolTipText("Y expression. Drag and drop expressions here");
1115 //--- Y item
1116 fLVContainer->AddThisItem(entry);
1117 entry->Empty();
1118 entry->MapWindow();
1119
1120 entry = new TTVLVEntry(fLVContainer,fPicZ,fPicZ,new TGString(),nullptr,kLVSmallIcons);
1121 symbol = 'Z';
1122 entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1123 entry->SetToolTipText("Z expression. Drag and drop expressions here");
1124 //--- Z item
1125 fLVContainer->AddThisItem(entry);
1126 entry->Empty();
1127 entry->MapWindow();
1128
1129 pic = gClient->GetPicture("cut_t.xpm");
1130 spic = gClient->GetPicture("cut_t.xpm");
1131 entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString(),nullptr,kLVSmallIcons);
1133 entry->SetToolTipText("Active cut. Double-click to enable/disable");
1134 //--- Cut item (scissors icon)
1135 fLVContainer->AddThisItem(entry);
1136 entry->Empty();
1137 entry->MapWindow();
1138
1139 pic = gClient->GetPicture("pack_t.xpm");
1140 spic = gClient->GetPicture("pack-empty_t.xpm");
1141 entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString("Scan box"),nullptr,kLVSmallIcons);
1143 entry->SetToolTipText("Drag and drop expressions/leaves here. Double-click to scan. Check <Scan> to redirect on file.");
1144 //--- Scan Box
1145 fLVContainer->AddThisItem(entry);
1146 entry->MapWindow();
1147 entry->SetTrueName("");
1148
1149 //--- 10 expression items
1150 fNexpressions = 10;
1151 for (Int_t i=0; i<fNexpressions; i++) {
1152 pic = gClient->GetPicture("expression_t.xpm");
1153 spic = gClient->GetPicture("expression_t.xpm");
1154 entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString(),nullptr,kLVSmallIcons);
1156 entry->SetToolTipText("User defined expression/cut. Double-click to edit");
1157 fLVContainer->AddThisItem(entry);
1158 entry->Empty();
1159 entry->MapWindow();
1160 }
1161
1162 fListView->Layout();
1163 fListView->Resize();
1164// EmptyAll();
1165 // map the tree if it was supplied in the constructor
1166
1167 if (!fTree) {
1168 fSlider->SetRange(0LL,1000000LL);
1169 fSlider->SetPosition(0LL,1000000LL);
1170 } else {
1171 fSlider->SetRange(0LL,fTree->GetEntries()-1);
1172 fSlider->SetPosition(0LL,fTree->GetEntries()-1);
1173 }
1174 PrintEntries();
1175 fProgressBar->SetPosition(0);
1176 fProgressBar->ShowPosition();
1177 ActivateButtons(false, false, false, false);
1178
1179 // map the window
1180 ///SetWindowName("TreeViewer");
1181 MapSubwindows();
1183 MapWindow();
1184}
1185
1186////////////////////////////////////////////////////////////////////////////////
1187/// TTreeViewer destructor.
1188
1190{
1191 if (!gClient) return;
1192 gClient->FreePicture(fPicX);
1193 gClient->FreePicture(fPicY);
1194 gClient->FreePicture(fPicZ);
1195 gClient->FreePicture(fPicDraw);
1196 gClient->FreePicture(fPicStop);
1197 gClient->FreePicture(fPicRefr);
1198
1200 if (fDialogBox) delete fDialogBox;
1201
1202 delete fContextMenu;
1203
1204 delete fBarLbl1;
1205 delete fBarLbl2;
1206 delete fBarLbl3;
1207 delete fBLbl4;
1208 delete fBLbl5;
1209 delete fBarCommand;
1210 delete fBarOption;
1211 delete fBarHist;
1212 delete fBarListIn;
1213 delete fBarListOut;
1214
1215 delete fBarH;
1216 delete fBarScan;
1217 delete fBarRec;
1218
1219 delete fToolBar;
1220
1221 delete fSlider;
1222 delete fV1;
1223 delete fV2;
1224 delete fLbl1;
1225 delete fLbl2;
1226 delete fHf;
1227 delete fTreeHdr;
1228 delete fListHdr;
1229 delete fLt;
1230 delete fTreeView;
1231 delete fLVContainer;
1232 delete fListView;
1233
1234 delete fProgressBar;
1235 delete fHpb;
1236
1237 delete fDRAW;
1238 delete fSPIDER;
1239 delete fSTOP;
1240 delete fReset;
1241 delete fBGFirst;
1242 delete fBGPrevious;
1243 delete fBGRecord;
1244 delete fBGNext;
1245 delete fBGLast;
1246 delete fCombo;
1247 delete fBFrame;
1248
1249 delete fMenuBar;
1250 delete fFileMenu;
1251 delete fEditMenu;
1252
1253 delete fOptionsGen;
1254 delete fOptions1D;
1255 delete fOptions2D;
1256 delete fOptionsMenu;
1257 delete fHelpMenu;
1258 delete fMenuBarLayout;
1259 delete fMenuBarItemLayout;
1260 delete fMenuBarHelpLayout;
1261 delete fBarLayout;
1262
1263 fWidgets->Delete();
1264 delete fWidgets;
1265 if (fTreeList) {
1266 delete fTreeList;
1267 }
1268 delete fTimer;
1269 delete fSession;
1270}
1271
1272////////////////////////////////////////////////////////////////////////////////
1273/// Enable/disable session buttons.
1274
1275void TTreeViewer::ActivateButtons(bool first, bool previous,
1276 bool next, bool last)
1277{
1278 if (first) fBGFirst->SetState(kButtonUp);
1279 else fBGFirst->SetState(kButtonDisabled);
1280 if (previous) fBGPrevious->SetState(kButtonUp);
1281 else fBGPrevious->SetState(kButtonDisabled);
1282 if (next) fBGNext->SetState(kButtonUp);
1283 else fBGNext->SetState(kButtonDisabled);
1284 if (last) fBGLast->SetState(kButtonUp);
1285 else fBGLast->SetState(kButtonDisabled);
1286}
1287
1288////////////////////////////////////////////////////////////////////////////////
1289/// Apply Cut
1290
1291const char* TTreeViewer::Cut()
1292{
1293 return fLVContainer->Cut();
1294}
1295
1296////////////////////////////////////////////////////////////////////////////////
1297/// returns scanlist
1298
1299const char* TTreeViewer::ScanList()
1300{
1301 return fLVContainer->ScanList();
1302}
1303
1304////////////////////////////////////////////////////////////////////////////////
1305/// Set current session
1306
1308{
1309 if (session) {
1310 delete fSession;
1311 fSession = session;
1312 }
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Empty the bracket content of a string.
1317
1318const char* TTreeViewer::EmptyBrackets(const char* name)
1319{
1320 TString stripped(name);
1321 if (!stripped.Contains("[")) return name;
1322 TString retstr(name);
1323 TObjString *objstr;
1324 Int_t index = 0;
1325 while (stripped.Index("[", index) != kNPOS) {
1326 Int_t start = stripped.Index("[", index);
1327 Int_t end = stripped.Index("]", index);
1328 if (end == kNPOS) {
1329 objstr = new TObjString(retstr.Data());
1330 fWidgets->Add(objstr);
1331 return (objstr->String()).Data();
1332 }
1333 index = start+2;
1334 retstr = stripped.Remove(start+1, end-start-1);
1335 stripped = retstr;
1336 }
1337 objstr = new TObjString(retstr.Data());
1338 fWidgets->Add(objstr);
1339 return (objstr->String()).Data();
1340}
1341
1342////////////////////////////////////////////////////////////////////////////////
1343/// Clear the content of all items in the list view.
1344
1346{
1347 fLVContainer->EmptyAll();
1348}
1349
1350////////////////////////////////////////////////////////////////////////////////
1351/// Empty the content of the selected expression.
1352
1353void TTreeViewer::Empty()
1354{
1355 void *p = nullptr;
1356 TTVLVEntry *item = nullptr;
1357 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == nullptr) {
1358 Warning("Empty", "No item selected.");
1359 return;
1360 }
1361 ULong_t *itemType = (ULong_t *) item->GetUserData();
1362 if (!(*itemType & kLTExpressionType)) {
1363 Warning("Empty", "Not expression type.");
1364 return;
1365 }
1366 if (*itemType & kLTPackType) {
1367 item->SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
1368 item->SetTrueName("");
1369 return;
1370 }
1371 item->Empty();
1372}
1373
1374////////////////////////////////////////////////////////////////////////////////
1375/// Get the item from a specific position.
1376
1378{
1379 return fLVContainer->ExpressionItem(index);
1380}
1381
1382////////////////////////////////////////////////////////////////////////////////
1383/// Get the list of expression items.
1384
1386{
1387 return fLVContainer->ExpressionList();
1388}
1389
1390////////////////////////////////////////////////////////////////////////////////
1391/// Compute dimension of the histogram.
1392
1394{
1395 fDimension = 0;
1396 if (Ex() && strlen(Ex())) fDimension++;
1397 if (Ey() && strlen(Ey())) fDimension++;
1398 if (Ez() && strlen(Ez())) fDimension++;
1399 return fDimension;
1400}
1401
1402////////////////////////////////////////////////////////////////////////////////
1403/// Called when the DRAW button is executed.
1404
1406{
1407 TString varexp;
1408 TString command;
1409 Int_t dimension = 0;
1410 TString alias[3];
1411 TTVLVEntry *item;
1412 Int_t i;
1413 // fill in expressions
1414 if (fVarDraw) {
1415 void *p = nullptr;
1416 dimension = 1;
1417 if (!(item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p))) return;
1418 alias[0] = item->GetAlias();
1419 if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1420 varexp = item->ConvertAliases();
1421 } else {
1422 if (Ez() && strlen(Ez())) {
1423 dimension++;
1424 varexp = Ez();
1425 item = ExpressionItem(2);
1426 alias[2] = item->GetAlias();
1427 if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1428 }
1429 if ((Ez() && strlen(Ez())) && ((Ex() &&strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1430 if (Ey() && strlen(Ey())) {
1431 dimension++;
1432 varexp += Ey();
1433 item = ExpressionItem(1);
1434 alias[1] = item->GetAlias();
1435 if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1436 }
1437 if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1438 if (Ex () && strlen(Ex())) {
1439 dimension++;
1440 varexp += Ex();
1441 item = ExpressionItem(0);
1442 alias[0] = item->GetAlias();
1443 if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1444 }
1445 }
1446 if (!dimension && !fScanMode) {
1447 Warning("ExecuteDraw", "Nothing to draw on X,Y,Z.");
1448 return;
1449 }
1450 // find ListIn
1451 fTree->SetEventList(nullptr);
1452 TEventList *elist = nullptr;
1453 if (strlen(fBarListIn->GetText())) {
1454 elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1455 if (elist) fTree->SetEventList(elist);
1456 }
1457 // find ListOut
1458 if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1459 // find histogram name
1460 if (strcmp("htemp", fBarHist->GetText())) {
1461 varexp += ">>";
1462 varexp += fBarHist->GetText();
1463 }
1464 // find canvas/pad where to draw
1465 auto pad = gROOT->GetSelectedPad();
1466 if (pad) pad->cd();
1467 // find graphics option
1468 const char* gopt = fBarOption->GetText();
1469 // just in case a previous interrupt was posted
1470 gROOT->SetInterrupt(false);
1471 // check if cut is enabled
1472 const char *cut = "";
1473 if (fEnableCut) cut = Cut();
1474
1475 // get entries to be processed
1476 Long64_t nentries = (Long64_t)(fSlider->GetMaxPositionD() -
1477 fSlider->GetMinPositionD() + 1);
1478 Long64_t firstentry = fSlider->GetMinPositionL();
1479//printf("firstentry=%lld, nentries=%lld\n",firstentry,nentries);
1480 // check if Scan is checked and if there is something in the box
1481 if (fScanMode) {
1482// fBarScan->SetState(kButtonUp);
1483 fScanMode = false;
1484 if (ScanList() && strlen(ScanList())) varexp = ScanList();
1485 command = TString::Format("tv__tree->Scan(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1486 varexp.Data(), cut, gopt, nentries, firstentry);
1487 if (fBarScan->GetState() == kButtonDown) {
1488 ((TTreePlayer *)fTree->GetPlayer())->SetScanRedirect(true);
1489 } else {
1490 ((TTreePlayer *)fTree->GetPlayer())->SetScanRedirect(false);
1491 }
1492 ExecuteCommand(command.Data(), true);
1493 return;
1494 }
1495 // check if only histogram has to be updated
1496 if (fBarH->GetState() == kButtonDown) {
1497 // reset 'Hist' mode
1498 fBarH->SetState(kButtonUp);
1499 TH1 *hist = fTree->GetHistogram();
1500 if (hist && gPad) {
1501 //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1502 if (hist) {
1503 // check if graphic option was modified
1504 TString last(fLastOption);
1505 TString current(gopt);
1506 current.ToUpper();
1507 last.ToUpper();
1508 if (current == last) {
1509 gPad->Update();
1510 return;
1511 }
1512 if (dimension == 3 && strlen(gopt)) {
1513 std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1514 return;
1515 }
1516 std::cout << " Graphics option for current histogram changed to " << gopt << std::endl;
1517 hist->Draw(gopt);
1518 fLastOption = fBarOption->GetText();
1519 gPad->Update();
1520 return;
1521 }
1522 }
1523 }
1524 // send draw command
1525 fLastOption = fBarOption->GetText();
1526 //if (!gopt[0] && dimension!=3) {
1527 // gopt = "hist";
1528 // fLastOption = "hist";
1529 //}
1530 if (dimension == 3 && strlen(gopt)) {
1531 std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1532 gopt = "";
1533 fLastOption = "";
1534 }
1535 command = TString::Format("tv__tree->Draw(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1536 varexp.Data(), cut, gopt, nentries, firstentry);
1537 if (fCounting) return;
1538 fCounting = true;
1539 fTree->SetTimerInterval(200);
1540 fTimer->TurnOn();
1541 ExecuteCommand(command.Data());
1543 fTimer->TurnOff();
1544 fTree->SetTimerInterval(0);
1545 fCounting = false;
1546 fProgressBar->SetPosition(0);
1547 fProgressBar->ShowPosition();
1548 TH1 *hist = fTree->GetHistogram();
1549 if (hist) {
1550 // put expressions aliases on axes
1551 Int_t current = 0;
1552 for (i=0; i<3; i++) {
1553 if (alias[i].Length()) {
1554 if (i != current) {
1555 alias[current] = alias[i];
1556 alias[i] = "";
1557 }
1558 current++;
1559 }
1560 }
1561 //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1562 TAxis *axis[3];
1563 axis[0] = hist->GetXaxis();
1564 axis[1] = hist->GetYaxis();
1565 axis[2] = hist->GetZaxis();
1566 for (Int_t ind=0; ind<3; ind++) axis[ind]->SetTitle(alias[ind].Data());
1567 }
1568 if (gPad) gPad->Update();
1569}
1570
1571////////////////////////////////////////////////////////////////////////////////
1572/// Draw a spider plot for the selected entries.
1573
1575{
1576 TString varexp;
1577 Int_t dimension = 0;
1578 TString alias[3];
1579 TTVLVEntry *item;
1580 bool previousexp = false;
1581 // fill in expressions
1582 if (Ez() && strlen(Ez())) {
1583 previousexp = true;
1584 dimension++;
1585 varexp = Ez();
1586 item = ExpressionItem(2);
1587 alias[2] = item->GetAlias();
1588 if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1589 }
1590 if ((Ez() && strlen(Ez())) && ((Ex() && strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1591 if (Ey() && strlen(Ey())) {
1592 previousexp = true;
1593 dimension++;
1594 varexp += Ey();
1595 item = ExpressionItem(1);
1596 alias[1] = item->GetAlias();
1597 if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1598 }
1599 if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1600 if (Ex() && strlen(Ex())) {
1601 previousexp = true;
1602 dimension++;
1603 varexp += Ex();
1604 item = ExpressionItem(0);
1605 alias[0] = item->GetAlias();
1606 if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1607 }
1608 for(Int_t i=0;i<10;++i){
1609 if(En(i+5) && strlen(En(i+5))){
1610 ++dimension;
1611 if(previousexp){
1612 varexp += ":";
1613 varexp += En(i+5);
1614 } else varexp = En(i+5);
1615 previousexp = true;
1616 }
1617 }
1618 if (dimension<3) {
1619 Warning("ExecuteSpider", "Need at least 3 variables");
1620 return;
1621 }
1622 // find ListIn
1623 fTree->SetEventList(nullptr);
1624 TEventList *elist = nullptr;
1625 if (strlen(fBarListIn->GetText())) {
1626 elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1627 if (elist) fTree->SetEventList(elist);
1628 }
1629 // find ListOut
1630 if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1631 // find canvas/pad where to draw
1632 auto pad = gROOT->GetSelectedPad();
1633 if (pad) pad->cd();
1634 // find graphics option
1635 const char* gopt = fBarOption->GetText();
1636 // just in case a previous interrupt was posted
1637 gROOT->SetInterrupt(false);
1638 // check if cut is enabled
1639 const char *cut = "";
1640 if (fEnableCut) cut = Cut();
1641
1642 // get entries to be processed
1643 Long64_t nentries = (Long64_t)(fSlider->GetMaxPositionD() -
1644 fSlider->GetMinPositionD() + 1);
1645 Long64_t firstentry = fSlider->GetMinPositionL();
1646
1647 // create the spider plot
1648
1649 TSpider* spider = new TSpider(fTree,varexp.Data(),cut,Form("%s spider average",gopt),nentries,firstentry);
1650 spider->Draw();
1651
1652 if (gPad) gPad->Update();
1653}
1654
1655////////////////////////////////////////////////////////////////////////////////
1656/// Get the expression to be drawn on X axis.
1657
1658const char* TTreeViewer::Ex()
1659{
1660 return fLVContainer->Ex();
1661}
1662
1663////////////////////////////////////////////////////////////////////////////////
1664/// Get the expression to be drawn on Y axis.
1665
1666const char* TTreeViewer::Ey()
1667{
1668 return fLVContainer->Ey();
1669}
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Get the expression to be drawn on Z axis.
1673
1674const char* TTreeViewer::Ez()
1675{
1676 return fLVContainer->Ez();
1677}
1678
1679////////////////////////////////////////////////////////////////////////////////
1680/// Get the n'th expression
1681
1682const char* TTreeViewer::En(Int_t n)
1683{
1684 TTVLVEntry *e = fLVContainer->ExpressionItem(n);
1685 if(e) return e->ConvertAliases();
1686 return "";
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Start the expression editor.
1691
1693{
1694 void *p = nullptr;
1695 // get the selected item
1696 TTVLVEntry *item = nullptr;
1697 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == nullptr) {
1698 Warning("EditExpression", "No item selected.");
1699 return;
1700 }
1701 // check if it is an expression
1702 ULong_t *itemType = (ULong_t *) item->GetUserData();
1703 if (!(*itemType & kLTExpressionType)) {
1704 Warning("EditExpression", "Not expression type.");
1705 return;
1706 }
1707 // check if the editor is already active
1709 if (!fDialogBox) {
1710 fDialogBox = new TGSelectBox(fClient->GetRoot(), this, fV1->GetWidth() - 10);
1711 }
1712 // copy current item data into editor boxes
1713 fDialogBox->SetEntry(item);
1714 fDialogBox->SetWindowName("Expression editor");
1715 // check if you are editing the cut expression
1716 if (*itemType & kLTCutType || item->IsCut()) {
1717 fDialogBox->SetLabel("Selection");
1718 } else {
1719 fDialogBox->SetLabel("Expression");
1720 }
1721}
1722
1723////////////////////////////////////////////////////////////////////////////////
1724/// Get use of TTree::MakeSelector() via the context menu.
1725
1726Int_t TTreeViewer::MakeSelector(const char* selector)
1727{
1728 if (!fTree) return 0;
1729 return fTree->MakeSelector(selector);
1730}
1731
1732////////////////////////////////////////////////////////////////////////////////
1733/// Get use of TTree::Process() via the context menu.
1734
1735Long64_t TTreeViewer::Process(const char* filename, Option_t *option, Long64_t nentries, Long64_t firstentry)
1736{
1737 if (!fTree) return 0;
1738 return fTree->Process(filename, option, nentries, firstentry);
1739}
1740
1741////////////////////////////////////////////////////////////////////////////////
1742/// Get graph option
1743
1744const char *TTreeViewer::GetGrOpt()
1745{
1746 return fBarOption->GetText();
1747}
1748
1749////////////////////////////////////////////////////////////////////////////////
1750/// Set graph option
1751
1752void TTreeViewer::SetGrOpt(const char *option)
1753{
1754 fBarOption->SetText(option);
1755}
1756
1757////////////////////////////////////////////////////////////////////////////////
1758/// Return true if scan is redirected
1759
1761{
1762 return (fBarScan->GetState()==kButtonDown);
1763}
1764
1765////////////////////////////////////////////////////////////////////////////////
1766/// Remove the selected item from the list.
1767
1769{
1770 void *p = nullptr;
1771 TTVLVEntry *item = nullptr;
1772 // get the selected item
1773 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == nullptr) {
1774 Warning("RemoveItem", "No item selected.");
1775 return;
1776 }
1777 // check if it is removable
1778 ULong_t *itemType = (ULong_t *) item->GetUserData();
1779 if (!(*itemType & kLTDragType)) {
1780 Warning("RemoveItem", "Not removable type.");
1781 return;
1782 }
1783 fLVContainer->RemoveItem(item);
1784 fListView->Layout();
1785}
1786
1787////////////////////////////////////////////////////////////////////////////////
1788/// Remove the current record.
1789
1791{
1792 fSession->RemoveLastRecord();
1793}
1794
1795////////////////////////////////////////////////////////////////////////////////
1796/// This function is called by the fTimer object.
1797
1799{
1800 if (fCounting) {
1801 Double_t first = fSlider->GetMinPositionD();
1802 Double_t last = fSlider->GetMaxPositionD();
1803 Double_t current = (Double_t)fTree->GetReadEntry();
1804 Double_t percent = (current-first+1)/(last-first+1);
1805 fProgressBar->SetPosition(100.*percent);
1806 fProgressBar->ShowPosition();
1807 }
1808 timer->Reset();
1809 return false;
1810}
1811
1812////////////////////////////////////////////////////////////////////////////////
1813/// Handle menu and other commands generated.
1814
1816{
1817 TRootHelpDialog *hd;
1818 TTVRecord *record;
1819
1820 switch (GET_MSG(msg)) {
1821 case kC_VSLIDER :
1822 // handle slider messages
1823 PrintEntries();
1824 break;
1825 case kC_TEXTENTRY:
1826 switch (GET_SUBMSG(msg)) {
1827 // handle enter posted by the Command text entry
1828 case kTE_ENTER:
1829 if ((ERootTreeViewerCommands)parm1 == kBarCommand) {
1830 ExecuteCommand(fBarCommand->GetText());
1831 fBarCommand->Clear();
1832 }
1833 if ((ERootTreeViewerCommands)parm1 == kBarOption) {
1834 fVarDraw = false;
1835 fBarH->SetState(kButtonDown);
1836 ExecuteDraw();
1837 fBarH->SetState(kButtonUp);
1838 }
1839 break;
1840 default:
1841 break;
1842 }
1843 break;
1844 case kC_LISTTREE:
1845 switch (GET_SUBMSG(msg)) {
1846 // handle mouse messages in the list-tree (left panel)
1847 case kCT_ITEMCLICK :
1848 // tell coverity that parm1 is a Long_t, and not an enum (even
1849 // if we compare it with an enum value) and the meaning of
1850 // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
1851 // coverity[mixed_enums]
1852 if (((EMouseButton)parm1==kButton1) ||
1853 ((EMouseButton)parm1==kButton3)) {
1854 TGListTreeItem *ltItem = nullptr;
1855 // get item that sent this
1856 if ((ltItem = fLt->GetSelected()) != nullptr) {
1857 // get item type
1858 ULong_t *itemType = (ULong_t *)ltItem->GetUserData();
1859 if (!itemType)
1860 break;
1861 if (*itemType & kLTTreeType) {
1862 // already mapped tree item clicked
1863 Int_t index = (Int_t)(*itemType >> 8);
1864 SwitchTree(index);
1865 if (fTree != fMappedTree) {
1866 // switch also the global "tree" variable
1867 fLVContainer->RemoveNonStatic();
1868 // map it on the right panel
1869 MapTree(fTree);
1870 fListView->Layout();
1871 }
1872 // activate context menu for this tree
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, fTree);
1877 }
1878 }
1879
1880 if (*itemType & kLTBranchType) {
1881 // branch item clicked
1882 SetParentTree(ltItem);
1883 if (!fTree) break; // really needed ?
1884 TBranch *branch = fTree->GetBranch(ltItem->GetText());
1885 if (!branch) break;
1886 // check if it is mapped on the right panel
1887 if (branch != fMappedBranch) {
1888 fLVContainer->RemoveNonStatic();
1889 MapBranch(branch);
1890 fStopMapping = false;
1891 fListView->Layout();
1892 }
1893 // activate context menu for this branch (no *MENU* methods ):)
1894 if (parm1 == kButton3) {
1895 Int_t x = (Int_t)(parm2 &0xffff);
1896 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1897 fContextMenu->Popup(x, y, branch);
1898 }
1899 }
1900
1901 if (*itemType & kLTLeafType) {
1902 // leaf item clicked
1903 SetParentTree(ltItem);
1904 if (!fTree) break;
1905 // find parent branch
1906 TBranch *branch = fTree->GetBranch(ltItem->GetParent()->GetText());
1907 if (!branch) {
1908 if (fTree != fMappedTree) {
1909 fLVContainer->RemoveNonStatic();
1910 MapTree(fTree);
1911 fListView->Layout();
1912 }
1913 } else {
1914 // check if it is already mapped
1915 if (branch!=fMappedBranch) {
1916 fLVContainer->RemoveNonStatic();
1917 MapBranch(branch);
1918 fStopMapping = false;
1919 fListView->Layout();
1920 }
1921 }
1922 // select corresponding leaf on the right panel
1923 fLVContainer->SelectItem(ltItem->GetText());
1924 if (parm1 == kButton3) {
1925 // activate context menu for this leaf
1927 }
1928 }
1929 }
1930 }
1931 break;
1932 case kCT_ITEMDBLCLICK :
1933 fClient->NeedRedraw(fLt);
1934 if (parm1 == kButton1) {
1935 // execute double-click action for corresponding item in the right panel
1937 }
1938 break;
1939 default:
1940 break;
1941 }
1942 break;
1943 case kC_COMMAND:
1944 switch (GET_SUBMSG(msg)) {
1945 case kCM_COMBOBOX:
1946 if ((record = fSession->GetRecord((Int_t)parm2)))
1947 fSession->Show(record);
1948 break;
1949 case kCM_BUTTON:
1950 switch (parm1) {
1951 // handle button messages
1952 case kRESET:
1953 EmptyAll();
1954 break;
1955 case kDRAW:
1956 fVarDraw = false;
1957 ExecuteDraw();
1958 break;
1959 case kSTOP:
1960 if (fCounting)
1961 gROOT->SetInterrupt(true);
1962 break;
1963 case kCLOSE:
1965 break;
1966 case kBGFirst:
1967 if ((record = fSession->First()))
1968 fSession->Show(record);
1969 break;
1970 case kBGPrevious:
1971 if ((record = fSession->Previous()))
1972 fSession->Show(record);
1973 break;
1974 case kBGRecord:
1975 fSession->AddRecord();
1976 break;
1977 case kBGNext:
1978 if ((record = fSession->Next()))
1979 fSession->Show(record);
1980 break;
1981 case kBGLast:
1982 if ((record = fSession->Last()))
1983 fSession->Show(record);
1984 break;
1985 default:
1986 break;
1987 }
1988 break;
1989 case kCM_MENU:
1990 // handle menu messages
1991 // check if sent by Options menu
1992 if ((parm1>=kOptionsReset) && (parm1<kHelpAbout)) {
1993 Dimension();
1994 if ((fDimension==0) && (parm1>=kOptions1D)) {
1995 Warning("ProcessMessage", "Edit expressions first.");
1996 break;
1997 }
1998 if ((fDimension==1) && (parm1>=kOptions2D)) {
1999 Warning("ProcessMessage", "You have only one expression active.");
2000 break;
2001 }
2002 if ((fDimension==2) && (parm1>=kOptions1D) &&(parm1<kOptions2D)) {
2003 Warning("ProcessMessage", "1D drawing options not apply to 2D histograms.");
2004 break;
2005 }
2006 // make composed option
2007 MapOptions(parm1);
2008 break;
2009 }
2010 switch (parm1) {
2011 case kFileCanvas:
2012 gROOT->MakeDefCanvas();
2013 break;
2014 case kFileBrowse:
2015 if (true) {
2016 static TString dir(".");
2017 TGFileInfo info;
2018 info.fFileTypes = gOpenTypes;
2019 info.SetIniDir(dir);
2020 new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
2021 if (!info.fFilename) return true;
2022 dir = info.fIniDir;
2023 TString command = TString::Format("tv__tree_file = new TFile(\"%s\");",
2024 gSystem->UnixPathName(info.fFilename));
2025 ExecuteCommand(command.Data());
2026 ExecuteCommand("tv__tree_file->ls();");
2027 std::cout << "Use SetTreeName() from context menu and supply a tree name" << std::endl;
2028 std::cout << "The context menu is activated by right-clicking the panel from right" << std::endl;
2029 }
2030 break;
2031 case kFileLoadLibrary:
2032 fBarCommand->SetText("gSystem->Load(\"\");");
2033 if (true) {
2034 Event_t event;
2035 event.fType = kButtonPress;
2036 event.fCode = kButton1;
2037 event.fX = event.fY = 1;
2038 fBarCommand->HandleButton(&event);
2039 }
2040 fBarCommand->SetCursorPosition(15);
2041 break;
2042 case kFileOpenSession:
2043 if (true) {
2044 static TString dir(".");
2045 TGFileInfo info;
2046 info.fFileTypes = gMacroTypes;
2047 info.SetIniDir(dir);
2048 new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
2049 if (!info.fFilename) return true;
2050 dir = info.fIniDir;
2051 gInterpreter->Reset();
2052 if (!gInterpreter->IsLoaded(info.fFilename)) gInterpreter->LoadMacro(info.fFilename);
2053 char command[1024];
2054 command[0] = 0;
2055 snprintf(command,1024,"open_session((void*)0x%zx);", (size_t)this);
2056 ExecuteCommand(command);
2057 }
2058 break;
2059 case kFileSaveMacro:
2060 fContextMenu->Action(this,(TMethod*)IsA()->GetListOfMethods()->FindObject("SaveSource"));
2061 break;
2062 case kFilePrint:
2063 break;
2064 case kFileClose:
2066 break;
2067 case kFileQuit:
2068 gApplication->Terminate(0);
2069 break;
2070 case kEditExpression:
2072 break;
2073 case kEditCut:
2075 break;
2076 case kEditMacro:
2077 break;
2078 case kEditEvent:
2079 break;
2080 case kRunMacro:
2081 break;
2082 case kHelpAbout:
2083 {
2084#ifdef WIN32
2085 new TWin32SplashThread(true);
2086#else
2087 char str[32];
2088 snprintf(str,32, "About ROOT %s...", gROOT->GetVersion());
2089 hd = new TRootHelpDialog(this, str, 600, 400);
2090 hd->SetText(gHelpAbout);
2091 hd->Popup();
2092#endif
2093 }
2094 break;
2095 case kHelpAboutTV:
2096 hd = new TRootHelpDialog(this, "About TreeViewer...", 600, 400);
2097 hd->SetText(gTVHelpAbout);
2098 hd->Resize(hd->GetDefaultSize());
2099 hd->Popup();
2100 break;
2101 case kHelpStart:
2102 hd = new TRootHelpDialog(this, "Quick start...", 600, 400);
2103 hd->SetText(gTVHelpStart);
2104 hd->Popup();
2105 break;
2106 case kHelpLayout:
2107 hd = new TRootHelpDialog(this, "Layout...", 600, 400);
2109 hd->Popup();
2110 break;
2111 case kHelpOpenSave:
2112 hd = new TRootHelpDialog(this, "Open/Save...", 600, 400);
2114 hd->Popup();
2115 break;
2116 case kHelpDragging:
2117 hd = new TRootHelpDialog(this, "Dragging items...", 600, 400);
2119 hd->Popup();
2120 break;
2121 case kHelpEditing:
2122 hd = new TRootHelpDialog(this, "Editing expressions...", 600, 400);
2124 hd->Popup();
2125 break;
2126 case kHelpSession:
2127 hd = new TRootHelpDialog(this, "Session...", 600, 400);
2129 hd->Popup();
2130 break;
2131 case kHelpCommands:
2132 hd = new TRootHelpDialog(this, "Executing user commands...", 600, 400);
2134 hd->Popup();
2135 break;
2136 case kHelpContext:
2137 hd = new TRootHelpDialog(this, "Context menus...", 600, 400);
2139 hd->Popup();
2140 break;
2141 case kHelpDrawing:
2142 hd = new TRootHelpDialog(this, "Drawing histograms...", 600, 400);
2144 hd->Popup();
2145 break;
2146 case kHelpMacros:
2147 hd = new TRootHelpDialog(this, "Using macros...", 600, 400);
2149 hd->Popup();
2150 break;
2151 default:
2152 break;
2153 }
2154 break;
2155 default:
2156 break;
2157 }
2158 break;
2159 case kC_CONTAINER:
2160 switch (GET_SUBMSG(msg)) {
2161 // handle messages sent from the listview (right panel)
2162 case kCT_SELCHANGED:
2163 break;
2164 case kCT_ITEMCLICK:
2165 // handle mouse messages
2166 switch (parm1) {
2167 case kButton1:
2168 if (fLVContainer->NumSelected()) {
2169 // get item that sent this
2170 void *p = nullptr;
2171 TTVLVEntry *item;
2172 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != nullptr) {
2173 const char* vname = item->GetTrueName();
2174 TString trueName(vname);
2175 if (trueName.Contains("[]")) {
2176 TIter next(fTree->GetListOfLeaves());
2177 TLeaf *leaf;
2178 while((leaf=(TLeaf*)next())) {
2179 if (!strcmp(vname, EmptyBrackets(leaf->GetName())))
2180 vname = leaf->GetName();
2181 }
2182 }
2183 char* msg2 = new char[2000];
2184 // get item type
2185 ULong_t *itemType = (ULong_t *) item->GetUserData();
2186 if (*itemType & kLTTreeType) {
2187 // X, Y or Z clicked
2188 char symbol = (char)((*itemType) >> 8);
2189 snprintf(msg2,2000, "%c expression : %s", symbol, vname);
2190 } else {
2191 if (*itemType & kLTCutType) {
2192 // scissors clicked
2193 snprintf(msg2,2000, "Cut : %s", vname);
2194 } else {
2195 if (*itemType & kLTPackType) {
2196 snprintf(msg2,2000, "Box : %s", vname);
2197 } else {
2198 if (*itemType & kLTExpressionType) {
2199 // expression clicked
2200 snprintf(msg2,2000, "Expression : %s", vname);
2201 } else {
2202 if (*itemType & kLTBranchType) {
2203 snprintf(msg2,2000, "Branch : %s", vname);
2204 } else {
2205 snprintf(msg2,2000, "Leaf : %s", vname);
2206 }
2207 }
2208 }
2209 }
2210 }
2211 // write who is responsable for this
2212 TString message = msg2;
2213 message = message(0,150);
2214 Message(msg2);
2215 delete[] msg2;
2216 // check if this should be pasted into the expression editor
2217 if ((*itemType & kLTBranchType) || (*itemType & kLTCutType)) break;
2219 if (!fDialogBox || !vname[0]) break;
2220 if (item == fDialogBox->EditedEntry()) break;
2221 // paste it
2222// char first = (char) vname[0];
2223 TString insert(item->GetAlias());
2224// if (first != '(') insert += "(";
2225// insert += item->GetAlias();
2226// if (first != '(') insert += ")";
2227
2228 fDialogBox->GrabPointer();
2229 fDialogBox->InsertText(insert.Data());
2230 // put the cursor at the right position
2231 }
2232 }
2233 break;
2234 case kButton2:
2235 break;
2236 case kButton3:
2237 // activate general context menu
2238 if (fLVContainer->NumSelected()) {
2239 void *p = nullptr;
2240 Int_t x = (Int_t)(parm2 &0xffff);
2241 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2242 TTVLVEntry *item = nullptr;
2243 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != nullptr) {
2244 fContextMenu->Popup(x, y, item->GetContext());
2245 }
2246 } else { // empty click
2247 Int_t x = (Int_t)(parm2 &0xffff);
2248 Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2249 fContextMenu->Popup(x, y, this);
2250 }
2251 break;
2252 default:
2253 break;
2254 }
2255 break;
2256 case kCT_ITEMDBLCLICK:
2257 switch (parm1) {
2258 case kButton1:
2259 if (fLVContainer->NumSelected()) {
2260 // get item that sent this
2261 void *p = nullptr;
2262 TTVLVEntry *item;
2263 if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != nullptr) {
2264 // get item type
2265 ULong_t *itemType = (ULong_t *) item->GetUserData();
2266 if (!(*itemType & kLTCutType) && !(*itemType & kLTBranchType)
2267 && !(*itemType & kLTPackType)) {
2268 if (strlen(item->GetTrueName())) {
2269 fVarDraw = true;
2270 // draw on double-click
2271 ExecuteDraw();
2272 break;
2273 } else {
2274 // open expression in editor
2276 }
2277 }
2278 if (*itemType & kLTCutType) {
2280 if (fEnableCut) {
2281 item->SetSmallPic(gClient->GetPicture("cut_t.xpm"));
2282 } else {
2283 item->SetSmallPic(gClient->GetPicture("cut-disable_t.xpm"));
2284 }
2285 }
2286 if (*itemType & kLTPackType) {
2287 fScanMode = true;
2288 ExecuteDraw();
2289 }
2290 }
2291 }
2292 break;
2293 case kButton2:
2294 break;
2295 case kButton3:
2296 break;
2297 default:
2298 break;
2299 }
2300 break;
2301 case 4:
2302// std::cout << "Dragging Item" << std::endl;
2303 default:
2304 break;
2305 }
2306 break;
2307 default:
2308 break;
2309 }
2310 return true;
2311}
2312
2313////////////////////////////////////////////////////////////////////////////////
2314/// Close the viewer.
2315
2317{
2318 DeleteWindow();
2319}
2320
2321////////////////////////////////////////////////////////////////////////////////
2322/// Execute all user commands.
2323
2324void TTreeViewer::ExecuteCommand(const char* command, bool fast)
2325{
2326 // Execute the command, write it to history file and echo it to output
2327 if (fBarRec->GetState() == kButtonDown) {
2328 // show the command on the command line
2329 //printf("%s\n", command);
2330 char comm[2000];
2331 comm[0] = 0;
2332 if (strlen(command) > 1999) {
2333 Warning("ExecuteCommand", "Command too long: aborting.");
2334 return;
2335 }
2336 snprintf(comm,2000, "%s", command);
2337 // print the command to history file
2338 Gl_histadd(comm);
2339 }
2340 // execute it
2341 if (fast) {
2342 gROOT->ProcessLineFast(command);
2343 } else {
2344 gROOT->ProcessLine(command);
2345 }
2346 // make sure that 'draw on double-click' flag is reset
2347 fVarDraw = false;
2348}
2349
2350////////////////////////////////////////////////////////////////////////////////
2351/// Scan the selected options from option menu.
2352
2354{
2355 Int_t ind;
2356 if (parm1 == kOptionsReset) {
2357 for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++)
2358 fOptionsGen->UnCheckEntry(ind);
2359 for (ind=kOptions1D; ind<kOptions1D+12; ind++)
2360 fOptions1D->UnCheckEntry(ind);
2361 for (ind=kOptions2D; ind<kOptions2D+14; ind++)
2362 fOptions2D->UnCheckEntry(ind);
2363 }
2364 if ((parm1 < kOptions1D) && (parm1 != kOptionsReset)) {
2365 if (fOptionsGen->IsEntryChecked((Int_t)parm1)) {
2366 fOptionsGen->UnCheckEntry((Int_t)parm1);
2367 } else {
2368 fOptionsGen->CheckEntry((Int_t)parm1);
2369 if ((Int_t)parm1 != kOptionsGeneral) fOptionsGen->UnCheckEntry((Int_t)kOptionsGeneral);
2370 }
2371 if (fOptionsGen->IsEntryChecked((Int_t)kOptionsGeneral)) {
2372 // uncheck all in this menu
2373 for (ind=kOptionsGeneral+1; ind<kOptionsGeneral+16; ind++) {
2374 fOptionsGen->UnCheckEntry(ind);
2375 }
2376 }
2377 }
2378
2379 if ((parm1 < kOptions2D) && (parm1 >= kOptions1D)) {
2380 if (fOptions1D->IsEntryChecked((Int_t)parm1)) {
2381 fOptions1D->UnCheckEntry((Int_t)parm1);
2382 } else {
2383 fOptions1D->CheckEntry((Int_t)parm1);
2384 if ((Int_t)parm1 != kOptions1D) fOptions1D->UnCheckEntry((Int_t)kOptions1D);
2385 }
2386 if (fOptions1D->IsEntryChecked((Int_t)kOptions1D)) {
2387 // uncheck all in this menu
2388 for (ind=kOptions1D+1; ind<kOptions1D+12; ind++) {
2389 fOptions1D->UnCheckEntry(ind);
2390 }
2391 }
2392 }
2393
2394 if (parm1 >= kOptions2D) {
2395 if (fOptions2D->IsEntryChecked((Int_t)parm1)) {
2396 fOptions2D->UnCheckEntry((Int_t)parm1);
2397 } else {
2398 fOptions2D->CheckEntry((Int_t)parm1);
2399 if ((Int_t)parm1 != kOptions2D) fOptions2D->UnCheckEntry((Int_t)kOptions2D);
2400 }
2401 if (fOptions2D->IsEntryChecked((Int_t)kOptions2D)) {
2402 // uncheck all in this menu
2403 for (ind=kOptions2D+1; ind<kOptions2D+14; ind++) {
2404 fOptions2D->UnCheckEntry(ind);
2405 }
2406 }
2407 }
2408 // concatenate options
2409 fBarOption->SetText("");
2410 for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++) {
2411 if (fOptionsGen->IsEntryChecked(ind))
2412 fBarOption->AppendText(gOptgen[ind-kOptionsGeneral]);
2413 }
2414 if (Dimension() == 1) {
2415 for (ind=kOptions1D; ind<kOptions1D+12; ind++) {
2416 if (fOptions1D->IsEntryChecked(ind))
2417 fBarOption->AppendText(gOpt1D[ind-kOptions1D]);
2418 }
2419 }
2420 if (Dimension() == 2) {
2421 for (ind=kOptions2D; ind<kOptions2D+14; ind++) {
2422 if (fOptions2D->IsEntryChecked(ind))
2423 fBarOption->AppendText(gOpt2D[ind-kOptions2D]);
2424 }
2425 }
2426}
2427
2428////////////////////////////////////////////////////////////////////////////////
2429/// Map current tree and expand its content (including friends) in the lists.
2430
2431void TTreeViewer::MapTree(TTree *tree, TGListTreeItem *parent, bool listIt)
2432{
2433 if (!tree) return;
2434 TObjArray *branches = tree->GetListOfBranches();
2435 if (!branches) return; // A Chain with no underlying trees.
2436 TBranch *branch;
2437 // loop on branches
2438 Int_t id;
2439 for (id=0; id<branches->GetEntries(); id++) {
2440 branch = (TBranch *)branches->At(id);
2441 if (branch->TestBit(kDoNotProcess)) continue;
2442 TString name = branch->GetName();
2443 if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2444 // now map sub-branches
2445 MapBranch(branch, "", parent, listIt);
2446 fStopMapping = false;
2447 }
2448 //Map branches of friend Trees (if any)
2449 //Look at tree->GetTree() to insure we see both the friends of a chain
2450 //and the friends of the chain members
2451 TIter nextf( tree->GetTree()->GetListOfFriends() );
2452 TFriendElement *fr;
2453 while ((fr = (TFriendElement*)nextf())) {
2454 TTree * t = fr->GetTree();
2455 branches = t->GetListOfBranches();
2456 for (id=0; id<branches->GetEntries(); id++) {
2457 branch = (TBranch *)branches->At(id);
2458 if (branch->TestBit(kDoNotProcess)) continue;
2459 TString name = branch->GetName();
2460 if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2461 // now map sub-branches
2462 MapBranch(branch, fr->GetName(), parent, listIt);
2463 fStopMapping = false;
2464 }
2465 }
2466
2467 // tell who was last mapped
2468 if (listIt) {
2469 fMappedTree = tree;
2470 fMappedBranch = nullptr;
2471 }
2472}
2473
2474////////////////////////////////////////////////////////////////////////////////
2475/// Map current branch and expand its content in the list view.
2476
2477void TTreeViewer::MapBranch(TBranch *branch, const char *prefix, TGListTreeItem *parent, bool listIt)
2478{
2479 if (!branch) return;
2480 TString name;
2481 if (prefix && strlen(prefix) > 0) {
2482 name = prefix;
2483 if (!name.EndsWith(".")) name += ".";
2484 name += branch->GetName();
2485 }
2486 else name = branch->GetName();
2487 Int_t ind;
2488 TGListTreeItem *branchItem = nullptr;
2489 ULong_t *itemType;
2490 // map this branch
2491 if (name.Contains("fBits") || name.Contains("fUniqueID")) return;
2492 if (parent) {
2493 // make list tree items for each branch according to the type
2494 const TGPicture *pic, *spic;
2495 if ((branch->GetListOfBranches()->GetEntries()) ||
2496 (branch->GetNleaves())) {
2497 if (branch->GetListOfBranches()->GetEntries()) {
2498 itemType = new ULong_t(kLTBranchType);
2499 if (branch->InheritsFrom("TBranchObject")) {
2500 pic = gClient->GetPicture("branch-ob_t.xpm");
2501 spic = gClient->GetPicture("branch-ob_t.xpm");
2502 } else {
2503 if (branch->InheritsFrom("TBranchClones")) {
2504 pic = gClient->GetPicture("branch-cl_t.xpm");
2505 spic = gClient->GetPicture("branch-cl_t.xpm");
2506 } else {
2507 pic = gClient->GetPicture("branch_t.xpm");
2508 spic = gClient->GetPicture("branch_t.xpm");
2509 }
2510 }
2511 branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2512 } else {
2513 if (branch->GetNleaves() > 1) {
2514 itemType = new ULong_t(kLTBranchType);
2515 pic = gClient->GetPicture("branch_t.xpm");
2516 spic = gClient->GetPicture("branch_t.xpm");
2517 branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType,pic, spic);
2518 TObjArray *leaves = branch->GetListOfLeaves();
2519 TLeaf *leaf = nullptr;
2520 TString leafName;
2521 for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2522 leaf = (TLeaf *)leaves->At(lf);
2523 leafName = name;
2524 if (!leafName.EndsWith(".")) leafName.Append(".");
2525 leafName.Append(EmptyBrackets(leaf->GetName()));
2526 itemType = new ULong_t(kLTLeafType);
2527 pic = gClient->GetPicture("leaf_t.xpm");
2528 spic = gClient->GetPicture("leaf_t.xpm");
2529 fLt->AddItem(branchItem, leafName.Data(), itemType, pic, spic);
2530 }
2531 } else {
2532 itemType = new ULong_t(kLTLeafType);
2533 pic = gClient->GetPicture("leaf_t.xpm");
2534 spic = gClient->GetPicture("leaf_t.xpm");
2535 branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2536 }
2537 }
2538 }
2539 }
2540 // list branch in list view if necessary
2541 if (listIt) {
2542 TGString *textEntry = nullptr;
2543 const TGPicture *pic, *spic;
2544 TTVLVEntry *entry;
2545 // make list view items in the right frame
2546 if (!fStopMapping) {
2547 fMappedBranch = branch;
2548 fMappedTree = nullptr;
2549 fStopMapping = true;
2550 }
2551 if ((branch->GetListOfBranches()->GetEntries()) ||
2552 (branch->GetNleaves())) {
2553 textEntry = new TGString(EmptyBrackets(name.Data()));
2554 if (branch->GetListOfBranches()->GetEntries()) {
2555 if (branch->InheritsFrom("TBranchObject")) {
2556 pic = gClient->GetPicture("branch-ob_t.xpm");
2557 spic = gClient->GetPicture("branch-ob_t.xpm");
2558 } else {
2559 if (branch->InheritsFrom("TBranchClones")) {
2560 pic = gClient->GetPicture("branch-cl_t.xpm");
2561 spic = gClient->GetPicture("branch-cl_t.xpm");
2562 } else {
2563 pic = gClient->GetPicture("branch_t.xpm");
2564 spic = gClient->GetPicture("branch_t.xpm");
2565 }
2566 }
2567 entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,nullptr,kLVSmallIcons);
2568 entry->SetUserData(new UInt_t(kLTBranchType));
2569 entry->SetToolTipText("Branch with sub-branches. Can not be dragged");
2570 fLVContainer->AddThisItem(entry);
2571 entry->MapWindow();
2572 entry->SetAlias(textEntry->GetString());
2573 } else {
2574 if (branch->GetNleaves() > 1) {
2575 if (textEntry) delete textEntry;
2576 textEntry = new TGString(EmptyBrackets(name.Data()));
2577 pic = gClient->GetPicture("branch_t.xpm");
2578 spic = gClient->GetPicture("branch_t.xpm");
2579 entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,nullptr,kLVSmallIcons);
2580 entry->SetUserData(new UInt_t(kLTBranchType));
2581 entry->SetToolTipText("Branch with more than one leaf. Can not be dragged");
2582 fLVContainer->AddThisItem(entry);
2583 entry->MapWindow();
2584 entry->SetAlias(textEntry->GetString());
2585
2586 TObjArray *leaves = branch->GetListOfLeaves();
2587 TLeaf *leaf = nullptr;
2588 TString leafName;
2589 for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2590 leaf = (TLeaf *)leaves->At(lf);
2591 leafName = name;
2592 if (!leafName.EndsWith(".")) leafName.Append(".");
2593 leafName.Append(EmptyBrackets(leaf->GetName()));
2594 textEntry = new TGString(leafName.Data());
2595 pic = gClient->GetPicture("leaf_t.xpm");
2596 spic = gClient->GetPicture("leaf_t.xpm");
2597 entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,nullptr,kLVSmallIcons);
2599 entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2600 fLVContainer->AddThisItem(entry);
2601 entry->MapWindow();
2602 entry->SetAlias(textEntry->GetString());
2603 }
2604 } else {
2605 pic = (gClient->GetMimeTypeList())->GetIcon("TLeaf",false);
2606 if (!pic) pic = gClient->GetPicture("leaf_t.xpm");
2607 spic = gClient->GetMimeTypeList()->GetIcon("TLeaf",true);
2608 if (!spic) spic = gClient->GetPicture("leaf_t.xpm");
2609 entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,nullptr,kLVSmallIcons);
2611 entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2612 fLVContainer->AddThisItem(entry);
2613 entry->MapWindow();
2614 entry->SetAlias(textEntry->GetString());
2615 }
2616 }
2617 }
2618 }
2619
2620 TObjArray *branches = branch->GetListOfBranches();
2621 TBranch *branchDaughter = nullptr;
2622
2623 // loop all sub-branches
2624 for (ind=0; ind<branches->GetEntries(); ind++) {
2625 branchDaughter = (TBranch *)branches->UncheckedAt(ind);
2626 // map also all sub-branches
2627 MapBranch(branchDaughter, "", branchItem, listIt);
2628 }
2629}
2630
2631////////////////////////////////////////////////////////////////////////////////
2632/// Create new expression
2633
2635{
2636 fLVContainer->RemoveNonStatic();
2637 const TGPicture *pic = gClient->GetPicture("expression_t.xpm");
2638 const TGPicture *spic = gClient->GetPicture("expression_t.xpm");
2639
2640 TTVLVEntry *entry = new TTVLVEntry(fLVContainer,pic,spic,
2641 new TGString(),nullptr,kLVSmallIcons);
2643 fLVContainer->AddThisItem(entry);
2644 entry->MapWindow();
2645 entry->Empty();
2648 fListView->Layout();
2649 fNexpressions++;
2650}
2651
2652////////////////////////////////////////////////////////////////////////////////
2653/// Find parent tree of a clicked item.
2654
2656{
2657 if (!item) return;
2658 ULong_t *itemType = (ULong_t *)item->GetUserData();
2659 if (!itemType) return;
2660 TGListTreeItem *parent = nullptr;
2661 Int_t index;
2662 if (!(*itemType & kLTTreeType)) {
2663 parent = item->GetParent();
2664 SetParentTree(parent);
2665 } else {
2666 index = (Int_t)(*itemType >> 8);
2667 SwitchTree(index);
2668 }
2669}
2670
2671////////////////////////////////////////////////////////////////////////////////
2672/// Send a message on the status bar.
2673
2674void TTreeViewer::Message(const char* msg)
2675{
2676 fStatusBar->SetText(msg);
2677}
2678
2679////////////////////////////////////////////////////////////////////////////////
2680/// Put error/warning into TMsgBox and also forward to console.
2681
2682void TTreeViewer::DoError(int level, const char *location, const char *fmt, va_list va) const
2683{
2684 TObject::DoError(level, location, fmt, va);
2685
2686 // in case level will abort we will not come here...
2687
2688 static const int buf_size = 2048;
2689 char buf[buf_size], *bp;
2690
2691 int n = vsnprintf(buf, buf_size, fmt, va);
2692 // old vsnprintf's return -1 if string is truncated new ones return
2693 // total number of characters that would have been written
2694 if (n == -1 || n >= buf_size) {
2695 TObject::Warning("DoError", "Error message string truncated...");
2696 }
2697 if (level >= kSysError && level < kFatal)
2698 bp = Form("%s (%s)", buf, gSystem->GetError());
2699 else
2700 bp = buf;
2701
2702 const char *title = "";
2703 if (level == kInfo)
2704 title = "Info";
2705 if (level == kWarning)
2706 title = "Warning";
2707 if (level == kError)
2708 title = "Error";
2709 if (level == kSysError)
2710 title = "System Error";
2711
2712 new TGMsgBox(fClient->GetRoot(), this, title, bp, kMBIconExclamation);
2713}
2714
2715////////////////////////////////////////////////////////////////////////////////
2716/// Print the number of selected entries on status-bar.
2717
2719{
2720 if (!fTree) return;
2721 char * msg = new char[100];
2722 snprintf(msg,100, "First entry : %lld Last entry : %lld",
2723 fSlider->GetMinPositionL(), fSlider->GetMaxPositionL());
2724 Message(msg);
2725 delete[] msg;
2726}
2727
2728////////////////////////////////////////////////////////////////////////////////
2729/// Save current session as a C++ macro file.
2730
2731void TTreeViewer::SaveSource(const char* filename, Option_t *)
2732{
2733 if (!fTree) return;
2734 char quote = '"';
2735 std::ofstream out;
2736 Int_t lenfile = strlen(filename);
2737 char * fname;
2738 if (!lenfile) {
2739 fname = (char*)fSourceFile;
2740 lenfile = strlen(fname);
2741 } else {
2742 fname = (char*)filename;
2743 fSourceFile = filename;
2744 }
2745 // if filename is given, open this file, otherwise create a file
2746 // with a name : treeviewer.C
2747 if (lenfile) {
2748 out.open(fname, std::ios::out);
2749 } else {
2750 fname = new char[13];
2751 strlcpy(fname, "treeviewer.C",13);
2752 out.open(fname, std::ios::out);
2753 }
2754 if (!out.good ()) {
2755 printf("SaveSource cannot open file : %s\n", fname);
2756 fSourceFile = "treeviewer.C";
2757 if (!lenfile) delete [] fname;
2758 return;
2759 }
2760 // Write macro header and date/time stamp
2761 TDatime t;
2762 out <<"void open_session(void *p = 0);"<<std::endl<<std::endl;
2763 out <<"void "<<std::filesystem::path(fname).stem()<<"() {"<<std::endl;
2764 out <<"//=========Macro generated by ROOT version"<<gROOT->GetVersion()<<std::endl;
2765 out <<"//=========for tree "<<quote<<fTree->GetName()<<quote<<" ("<<t.AsString()<<")"<<std::endl;
2766 out <<"//===This macro can be opened from a TreeViewer session after loading"<<std::endl;
2767 out <<"//===the corresponding tree, or by running root with the macro name argument"<<std::endl<<std::endl;
2768 out <<" open_session();"<<std::endl;
2769 out <<"}"<<std::endl<<std::endl;
2770 out <<"void open_session(void *p = 0) {"<<std::endl;
2771 out <<" gSystem->Load("<<quote<<"libTreeViewer"<<quote<<");"<<std::endl;
2772 out <<" TTreeViewer *treeview = (TTreeViewer *) p;"<<std::endl;
2773 out <<" if (!treeview) treeview = new TTreeViewer();"<<std::endl;
2774 out <<" TTree *tv_tree = (TTree*)gROOT->FindObject("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2775 out <<" TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("<<quote<<fFilename<<quote<<");"<<std::endl;
2776 out <<" if (!tv_tree) {"<<std::endl;
2777 out <<" if (!tv_file) tv_file = new TFile("<<quote<<fFilename<<quote<<");"<<std::endl;
2778 out <<" if (tv_file) tv_tree = (TTree*)tv_file->Get("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2779 out <<" if(!tv_tree) {"<<std::endl;
2780 out <<" printf(\"Tree %s not found\", "<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2781 out <<" return;"<<std::endl;
2782 out <<" }"<<std::endl;
2783 out <<" }"<<std::endl<<std::endl;
2784 out <<" treeview->SetTreeName("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2785 out <<" treeview->SetNexpressions("<<fNexpressions<<");"<<std::endl;
2786 // get expressions
2787 TTVLVEntry *item;
2788 out <<"// Set expressions on axis and cut"<<std::endl;
2789 out <<" TTVLVEntry *item;"<<std::endl;
2790 for (Int_t i=0; i<4; i++) {
2791 switch (i) {
2792 case 0:
2793 out <<"// X expression"<<std::endl;
2794 break;
2795 case 1:
2796 out <<"// Y expression"<<std::endl;
2797 break;
2798 case 2:
2799 out <<"// Z expression"<<std::endl;
2800 break;
2801 case 3:
2802 out <<"// Cut expression"<<std::endl;
2803 break;
2804 default:
2805 break;
2806 }
2807 item = ExpressionItem(i);
2808 out <<" item = treeview->ExpressionItem("<<i<<");"<<std::endl;
2809 out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2810 <<", "<<quote<<item->GetAlias()<<quote<<");"<<std::endl;
2811 }
2812 out <<"// Scan list"<<std::endl;
2813 item = ExpressionItem(4);
2814 out <<" item = treeview->ExpressionItem(4);"<<std::endl;
2815 out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2816 <<", "<<quote<<"Scan box"<<quote<<");"<<std::endl;
2817 out <<"// User defined expressions"<<std::endl;
2818 TString itemType;
2819 for (Int_t crt=5; crt<fNexpressions+5; crt++) {
2820 item = ExpressionItem(crt);
2821 if (item->IsCut())
2822 itemType = "true";
2823 else
2824 itemType = "false";
2825 out <<" item = treeview->ExpressionItem("<<crt<<");"<<std::endl;
2826 out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2827 <<", "<<quote<<item->GetAlias()<<quote<<", "<<itemType.Data()<<");"<<std::endl;
2828 }
2829 fSession->SaveSource(out);
2830 out <<"}"<<std::endl;
2831 out.close();
2832 printf("C++ Macro file: %s has been generated\n", fname);
2833 if (!lenfile) delete [] fname;
2834}
2835
2836////////////////////////////////////////////////////////////////////////////////
2837/// Makes current the tree at a given index in the list.
2838
2840{
2841 TTree *tree = (TTree *) fTreeList->At(index);
2842 if (!tree) {
2843 Warning("SwitchTree", "No tree found.");
2844 return false;
2845 }
2846 if ((tree == fTree) && (tree == fMappedTree)) return false; // nothing to switch
2847 std::string command;
2848 if (tree != fTree) {
2849 command = "tv__tree = (TTree *) tv__tree_list->At";
2850 command += Form("(%i)",index);
2851 ExecuteCommand(command.c_str());
2852 }
2853
2854 fTree = tree;
2855 fSlider->SetRange(0LL,fTree->GetEntries()-1);
2856 fSlider->SetPosition(0LL,fTree->GetEntries()-1);
2857 command = "Current Tree : ";
2858 command += fTree->GetName();
2859 fLbl2->SetText(new TGString(command.c_str()));
2860 fTreeHdr->Layout();
2861 MapSubwindows();
2863 MapWindow();
2864 ///Resize(); //ia
2865 PrintEntries();
2866 return true;
2867}
2868
2869////////////////////////////////////////////////////////////////////////////////
2870/// Set record name
2871
2872void TTreeViewer::SetRecordName(const char *name)
2873{
2874 fSession->SetRecordName(name);
2875}
2876
2877////////////////////////////////////////////////////////////////////////////////
2878/// Set current record
2879
2881{
2882 fCombo->Select(entry);
2883}
2884
2885////////////////////////////////////////////////////////////////////////////////
2886/// Set title of Histogram
2887
2888void TTreeViewer::SetHistogramTitle(const char *title)
2889{
2890 if (!gPad) return;
2891 TH1 *hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
2892 if (hist) {
2893 hist->SetTitle(title);
2894 gPad->Update();
2895 }
2896}
2897
2898////////////////////////////////////////////////////////////////////////////////
2899/// user defined command for current record
2900
2901void TTreeViewer::SetUserCode(const char *code, bool autoexec)
2902{
2903 TTVRecord *rec = fSession->GetCurrent();
2904 if (rec) rec->SetUserCode(code, autoexec);
2905}
2906
2907////////////////////////////////////////////////////////////////////////////////
2908/// Updates combo box to current session entries.
2909
2911{
2912 TTVRecord *record;
2913 fCombo->RemoveEntries(0, 1000);
2914 for (Long64_t entry=0; entry<fSession->GetEntries(); entry++) {
2915 if ((record = fSession->GetRecord(entry)))
2916 fCombo->AddEntry(record->GetName(), entry);
2917 }
2918}
2919
2920////////////////////////////////////////////////////////////////////////////////
2921/// Updates current record to new X, Y, Z items.
2922
2923void TTreeViewer::UpdateRecord(const char *name)
2924{
2925 fSession->UpdateRecord(name);
2926}
2927
2928////////////////////////////////////////////////////////////////////////////////
2929/// This slot is called when button REFR is clicked
2930
2932{
2933 fTree->Refresh();
2934 Double_t min = fSlider->GetMinPositionD();
2935 Double_t max = (Double_t)fTree->GetEntries()-1;
2936 fSlider->SetRange(min,max);
2937 fSlider->SetPosition(min,max);
2938 ExecuteDraw();
2939}
@ kButtonPress
Definition GuiTypes.h:61
@ kFitHeight
Definition GuiTypes.h:389
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kWatch
Definition GuiTypes.h:376
@ kPointer
Definition GuiTypes.h:376
EMouseButton
Button names.
Definition GuiTypes.h:215
@ kButton2
Definition GuiTypes.h:215
@ kButton3
Definition GuiTypes.h:215
@ kButton1
Definition GuiTypes.h:215
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
start
Definition Rotated.cxx:223
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
Definition RtypesCore.h:89
char Char_t
Character 1 byte (char).
Definition RtypesCore.h:51
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
externTApplication * gApplication
const Int_t kDoNotProcess
Definition TBranch.h:56
#define gDirectory
Definition TDirectory.h:385
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:252
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ 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
XFontStruct * id
Definition TGX11.cxx:147
char name[80]
Definition TGX11.cxx:148
int nentries
#define gInterpreter
#define gROOT
Definition TROOT.h:417
@ kFilePrint
@ kFileQuit
@ kHelpAbout
static const char * gOpenTypes[]
@ kEditCut
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
externTSystem * gSystem
Definition TSystem.h:582
TTVSession and TTVRecord - I/O classes for TreeViewer session handling.
static const char * gOpt2D[14]
EButtonIdentifiers
@ kBGFirst
@ kSLIDER
@ kSTOP
@ kBGLast
@ kBGRecord
@ kDRAW
@ kBGNext
@ kBGPrevious
static const char * gOptgen[16]
static const char * gOpt1D[12]
static const char * gMacroTypes[]
ERootTreeViewerCommands
@ kBarCommand
@ kHelpDragging
@ kOptionsGeneral
@ kHelpContext
@ kFileClose
@ kHelpStart
@ kHelpCommands
@ kHelpMacros
@ kOptions2D
@ kEditMacro
@ kHelpDrawing
@ kFileCanvas
@ kFileLoadLibrary
@ kFileSaveMacro
@ kFileBrowse
@ kFileOpenSession
@ kOptionsReset
@ kBarOption
@ kRunMacro
@ kAxis
@ kHelpEditing
@ kBarCut
@ kRunCommand
@ kHelpOpenSave
@ kHelpSession
@ kHelpAboutTV
@ kOptions1D
@ kEditEvent
@ kHelpLayout
@ kEditExpression
#define gPad
#define gVirtualX
Definition TVirtualX.h:375
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:1579
A TTree is a list of TBranches.
Definition TBranch.h:93
TObjArray * GetListOfBranches()
Definition TBranch.h:255
Int_t GetNleaves() const
Definition TBranch.h:258
TObjArray * GetListOfLeaves()
Definition TBranch.h:256
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:101
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:221
virtual Bool_t cd()
Change current directory to "this" directory.
virtual TTree * GetTree()
Return pointer to friend TTree.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TGCompositeFrame(const TGCompositeFrame &)=delete
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:597
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:701
void MapWindow() override
map window
Definition TGFrame.h:206
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:268
void * GetUserData() const
Definition TGListView.h:95
void SetUserData(void *userData)
Definition TGListView.h:94
virtual const char * GetText() const =0
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
virtual void * GetUserData() const =0
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
TGMainFrame(const TGMainFrame &)=delete
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1736
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1780
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Pixmap_t GetPicture() const
Definition TGPicture.h:54
static TGSelectBox * GetInstance()
Return the pointer to the instantiated singleton.
const char * GetString() const
Definition TGString.h:30
void SetFrame(TGFrame *frame, Bool_t left) override
Set frame to be resized.
TAxis * GetZaxis()
Definition TH1.h:573
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6836
TAxis * GetXaxis()
Definition TH1.h:571
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:3912
TAxis * GetYaxis()
Definition TH1.h:572
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3097
A doubly linked list.
Definition TList.h:38
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:90
TString & String()
Definition TObjString.h:48
Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
Definition TObject.cxx:1059
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1084
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:425
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:549
TObject()
TObject constructor.
Definition TObject.h:259
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
void Popup()
Show help dialog.
void Draw(Option_t *options="") override
Draw the spider.
Definition TSpider.cxx:453
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2250
const char * Data() const
Definition TString.h:384
TString & Remove(Ssiz_t pos)
Definition TString.h:694
TString & Append(const char *cs)
Definition TString.h:581
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:2385
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()
void SetUserCode(const char *code, bool autoexec=true)
Definition TTVSession.h:65
const char * GetName() const override
Returns name of object.
Definition TTVSession.h:53
I/O classes for TreeViewer session handling.
Definition TTVSession.h:71
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
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:89
TDirectory * GetDirectory() const
Definition TTree.h:509
virtual TObjArray * GetListOfBranches()
Definition TTree.h:575
virtual TTree * GetTree() const
Definition TTree.h:604
virtual TList * GetListOfFriends() const
Definition TTree.h:577
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