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