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