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