ROOT  6.06/09
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
13 A graphic user interface designed to handle ROOT trees and to take advantage of
14 TTree class features.
15 
16 It uses ROOT native GUI widgets adapted for 'drag and drop' functionality.
17 in 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
63 The content of the file (keys) will be listed. Use <SetTreeName> function
64 from the context menu of the right panel, entering a tree name among those
65 listed.
66 
67  To save the current session, use <File/Save> menu or the <SaveSource>
68 function from the context menu of the right panel (to specify the name of the
69 file - name.C)
70 
71  To open a previously saved session for the tree MyTree, first open MyTree
72 in the browser, then use <File/Open session> menu.
73 
74 ### Dragging items:
75 
76 Items that can be dragged from the list in the right : expressions and
77 leaves. Dragging an item and dropping to another will copy the content of first
78 to the last (leaf->expression, expression->expression). Items far to the right
79 side of the list can be easily dragged to the left (where expressions are
80 placed) 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
85 true name (that will be used when TTree::Draw() commands are issued) and an
86 alias. The visible name is the alias. Aliases of user defined expressions have
87 a leading ~ and may be used in new expressions. Expressions containing boolean
88 operators have a specific icon and may be dragged to the active cut (scissors
89 item) position.
90 
91  The expression editor can be activated by double-clicking empty expression,
92 using <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.
96 The 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 
109 User commands can be issued directly from the textbox labeled "Command"
110 from the upper-left toolbar by typing and pressing Enter at the end.
111 
112  Another way is from the right panel context menu : ExecuteCommand.
113 All commands can be interrupted at any time by pressing the STOP button
114 from the bottom-left
115 You can toggle recording of the current command in the history file by
116 checking 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
121 right panel.
122 
123 Context 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
125 branch items. You can directly activate the *MENU* marked methods of TTree
126 from this menu.
127 
128 Context 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 
153 Starting 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 ~~~
164 Supposing 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 ~~~
169 or :
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 "TTree.h"
205 #include "TFriendElement.h"
206 #include "TObjArray.h"
207 #include "TObjString.h"
208 #include "TGButton.h"
209 #include "TGButtonGroup.h"
210 #include "TGTextEntry.h"
211 #include "TGComboBox.h"
212 #include "TGLabel.h"
213 #include "TGListView.h"
214 #include "TGListTree.h"
215 #include "TGMimeTypes.h"
216 #include "TGSplitter.h"
217 #include "TGDoubleSlider.h"
218 #include "TGToolBar.h"
219 #include "TGStatusBar.h"
220 #include "Getline.h"
221 #include "TTimer.h"
222 #include "TG3DLine.h"
223 #include "TGFileDialog.h"
224 #include "TGProgressBar.h"
225 #include "TClonesArray.h"
226 #include "TSpider.h"
227 
228 #ifdef WIN32
229 #include "TWin32SplashThread.h"
230 #endif
231 
232 // drawing options
233 static const char* gOptgen[16] =
234 {
235  "","AXIS","HIST","SAME","CYL","POL","SPH","PSR","LEGO","LEGO1","LEGO2",
236  "SURF","SURF1","SURF2","SURF3","SURF4"
237 };
238 static const char* gOpt1D[12] =
239 {
240  "","AH","B","C","E","E1","E2","E3","E4","L","P","*H"
241 };
242 static const char* gOpt2D[14] =
243 {
244  "","ARR","BOX","COL","COL2","CONT","CONT0","CONT1","CONT2","CONT3",
245  "FB","BB","SCAT","PROF"
246 };
247 
248 static const char* gOpenTypes[] = {"Root files", "*.root",
249  0, 0 };
250 
251 static const char* gMacroTypes[] = {"C++ macros", "*.C",
252  0, 0 };
253 
254 // Menu command id's
264 
269 
272 
277 
278  kHelpAbout = 100,
290 
295 };
296 
297 // button Id's
309 };
310 
312 
313 ////////////////////////////////////////////////////////////////////////////////
314 /// TTreeViewer default constructor
315 
316 TTreeViewer::TTreeViewer(const char* treeName) :
317  TGMainFrame(0,10,10,kVerticalFrame),
318  fDimension(0), fVarDraw(0), fScanMode(0),
319  fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
320  fCounting(0), fStopMapping(0), fEnableCut(0),fNexpressions(0)
321 {
322  fTree = 0;
323  if (!gClient) return;
324  char command[128];
325  snprintf(command,128, "TTreeViewer *gTV = (TTreeViewer*)0x%lx", (ULong_t)this);
326  gROOT->ProcessLine(command);
327  gROOT->ProcessLine("TTree *tv__tree = 0;");
328  fTreeList = new TList;
329  gROOT->ProcessLine("TList *tv__tree_list = new TList;");
330  fFilename = "";
331  gROOT->ProcessLine("TFile *tv__tree_file = 0;");
332  gInterpreter->SaveContext();
333  BuildInterface();
334  SetTreeName(treeName);
335 }
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 
340  TGMainFrame(0, 10, 10, kVerticalFrame),
341  fDimension(0), fVarDraw(0), fScanMode(0),
342  fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
343  fCounting(0), fStopMapping(0), fEnableCut(0),fNexpressions(0)
344 
345 {
346  // TTreeViewer constructor with a pointer to a Tree
347 
348  fTree = 0;
349  char command[128];
350  snprintf(command,128, "TTreeViewer *gTV = (TTreeViewer*)0x%lx", (ULong_t)this);
351  gROOT->ProcessLine(command);
352  if (!tree) return;
353  gROOT->ProcessLine("TTree *tv__tree = 0;");
354  fTreeList = new TList;
355  gROOT->ProcessLine("TList *tv__tree_list = new TList;");
356  fFilename = "";
357  gROOT->ProcessLine("TFile *tv__tree_file = 0;");
358  gInterpreter->SaveContext();
359  BuildInterface();
360  TDirectory *dirsav = gDirectory;
361  TDirectory *cdir = tree->GetDirectory();
362  if (cdir) cdir->cd();
363 
364  SetTree((TTree *)tree);
365  // If the tree is a chain, the tree directory will be changed by SwitchTree
366  // (called by SetTreeName)
367  cdir = tree->GetDirectory();
368  if (cdir) {
369  if (cdir->GetFile()) fFilename = cdir->GetFile()->GetName();
370  }
371  if (dirsav) dirsav->cd();
372 }
373 ////////////////////////////////////////////////////////////////////////////////
374 /// Allow geting the tree from the context menu.
375 
377 {
378  if (!tree) return;
379  TTree *ftree;
380  if (fTreeList) {
381  if (fTreeList->FindObject(tree)) {
382  printf("Tree found\n");
384  Int_t index = 0;
385  while ((ftree = (TTree*)next())) {
386  if (ftree==tree) {printf("found at index %i\n", index);break;}
387  index++;
388  }
389  SwitchTree(index);
390  if (fTree != fMappedTree) {
391  // switch also the global "tree" variable
393  // map it on the right panel
394  MapTree(fTree);
395  fListView->Layout();
396  TGListTreeItem *base = 0;
397  TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
398  TGListTreeItem *item = fLt->FindChildByName(parent, fTree->GetName());
400  fLt->HighlightItem(item);
402  }
403  return;
404  }
405  }
406  if (fTree != tree) {
407  fTree = tree;
408  // load the tree via the interpreter
409  char command[100];
410  command[0] = 0;
411  // define a global "tree" variable for the same tree
412  snprintf(command,100, "tv__tree = (TTree *)0x%lx;", (ULong_t)tree);
413  ExecuteCommand(command);
414  }
415  //--- add the tree to the list if it is not already in
416  if (fTreeList) fTreeList->Add(fTree);
417  ExecuteCommand("tv__tree_list->Add(tv__tree);");
418  //--- map this tree
419  TGListTreeItem *base = 0;
420  TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
421  if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
422  ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
423  fTreeIndex++;
424  TGListTreeItem *lTreeItem = fLt->AddItem(parent, tree->GetName(), itemType,
425  gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
426  MapTree(fTree, lTreeItem, kFALSE);
427  fLt->OpenItem(parent);
428  fLt->HighlightItem(lTreeItem);
430 
431  //--- map slider and list view
434  MapTree(fTree);
435  fListView->Layout();
436  SetFile();
437 }
438 ////////////////////////////////////////////////////////////////////////////////
439 /// Change the number of expression widgets.
440 
442 {
443  Int_t diff = expr - fNexpressions;
444  if (diff <= 0) return;
445  if (!fLVContainer) return;
446  for (Int_t i=0; i<TMath::Abs(diff); i++) NewExpression();
447 }
448 ////////////////////////////////////////////////////////////////////////////////
449 /// Set the name of the file where to redirect <Scan> output.
450 
452 {
453  if (fTree) ((TTreePlayer *)fTree->GetPlayer())->SetScanFileName(name);
454 }
455 ////////////////////////////////////////////////////////////////////////////////
456 /// Set the state of Scan check button.
457 
459 {
460  if (mode)
462  else
464 }
465 ////////////////////////////////////////////////////////////////////////////////
466 /// Assign the fTree member from existing tree, e.g. when calling
467 /// tree->StartViewer() from the browser, or even from the command line.
468 
470 {
471  if (!tree) return;
472  if (fTree != tree) {
473  fTree = tree;
474  // load the tree via the interpreter
475  // define a global "tree" variable for the same tree
476  TString command = TString::Format("tv__tree = (TTree *)0x%lx;", (ULong_t)tree);
477  ExecuteCommand(command.Data());
478  }
479  //--- add the tree to the list if it is not already in
480  if (fTreeList) fTreeList->Add(fTree);
481  ExecuteCommand("tv__tree_list->Add(tv__tree);");
482  //--- map this tree
483  TGListTreeItem *base = 0;
484  TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
485  if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
486  ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
487  fTreeIndex++;
488  TGListTreeItem *lTreeItem = fLt->AddItem(parent, tree->GetName(), itemType,
489  gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
490  MapTree(fTree, lTreeItem, kFALSE);
491  fLt->OpenItem(parent);
492  fLt->HighlightItem(lTreeItem);
494 
495  //--- map slider and list view
498  MapTree(fTree);
499  fListView->Layout();
500  SetFile();
501 }
502 ////////////////////////////////////////////////////////////////////////////////
503 /// Allow geting the tree from the context menu.
504 
505 void TTreeViewer::SetTreeName(const char* treeName)
506 {
507  if (!treeName) return;
508  TTree *tree = (TTree *) gROOT->FindObject(treeName);
509  if (fTreeList) {
510  if (fTreeList->FindObject(treeName)) {
511  printf("Tree found\n");
513  Int_t index = 0;
514  while ((tree = (TTree*)next())) {
515  if (!strcmp(treeName, tree->GetName())) {printf("found at index %i\n", index);break;}
516  index++;
517  }
518  SwitchTree(index);
519  if (fTree != fMappedTree) {
520  // switch also the global "tree" variable
522  // map it on the right panel
523  MapTree(fTree);
524  fListView->Layout();
525  TGListTreeItem *base = 0;
526  TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
527  TGListTreeItem *item = fLt->FindChildByName(parent, fTree->GetName());
529  fLt->HighlightItem(item);
531  }
532  return;
533  }
534  }
535  if (!tree) return;
536 // ((TTreePlayer *)tree->GetPlayer())->SetViewer(this);
537  if (fTree != tree) {
538  fTree = tree;
539  // load the tree via the interpreter
540  // define a global "tree" variable for the same tree
541  TString command = TString::Format("tv__tree = (TTree *) gROOT->FindObject(\"%s\");", treeName);
542  ExecuteCommand(command.Data());
543  }
544  //--- add the tree to the list if it is not already in
545  if (fTreeList) fTreeList->Add(fTree);
546  ExecuteCommand("tv__tree_list->Add(tv__tree);");
547  //--- map this tree
548  TGListTreeItem *base = 0;
549  TGListTreeItem *parent = fLt->FindChildByName(base, "TreeList");
550  if (!parent) parent = fLt->AddItem(base, "TreeList", new ULong_t(kLTNoType));
551  ULong_t *itemType = new ULong_t((fTreeIndex << 8) | kLTTreeType);
552  fTreeIndex++;
553  TGListTreeItem *lTreeItem = fLt->AddItem(parent, treeName, itemType,
554  gClient->GetPicture("tree_t.xpm"), gClient->GetPicture("tree_t.xpm"));
555  MapTree(fTree, lTreeItem, kFALSE);
556  fLt->OpenItem(parent);
557  fLt->HighlightItem(lTreeItem);
559 
560  //--- map slider and list view
563  MapTree(fTree);
564  fListView->Layout();
565  SetFile();
566 }
567 ////////////////////////////////////////////////////////////////////////////////
568 /// Set file name containing the tree.
569 
571 {
572  if (!fTree) return;
573  TSeqCollection *list = gROOT->GetListOfFiles();
574  TTree *tree;
575  TIter next(list);
576  TObject *obj;
577  TFile *file;
578  while ((obj=next())) {
579  file = (TFile*)obj;
580  if (file) {
581  tree = (TTree*)file->Get(fTree->GetName());
582  if (tree) {
583  fFilename = file->GetName();
584  std::cout << "File name : "<< fFilename << std::endl;
585  return;
586  } else {
587  fFilename = "";
588  }
589  }
590  }
591  fFilename = "";
592 }
593 ////////////////////////////////////////////////////////////////////////////////
594 /// Create all viewer widgets.
595 
597 {
598  //--- timer & misc
599  fCounting = kFALSE;
600  fScanMode = kFALSE;
601  fEnableCut = kTRUE;
602  fTimer = new TTimer(this, 20, kTRUE);
603  fLastOption = "";
604  fSession = new TTVSession(this);
605  //--- cursors
606  fDefaultCursor = gVirtualX->CreateCursor(kPointer);
607  fWatchCursor = gVirtualX->CreateCursor(kWatch);
608  //--- colours
609  ULong_t color;
610  gClient->GetColorByName("blue",color);
611  //--- pictures for X, Y and Z expression items
612  fPicX = gClient->GetPicture("x_pic.xpm");
613  fPicY = gClient->GetPicture("y_pic.xpm");
614  fPicZ = gClient->GetPicture("z_pic.xpm");
615 
616  //--- general context menu
617  fContextMenu = new TContextMenu("TreeViewer context menu","");
618  fMappedTree = 0;
619  fMappedBranch = 0;
620  fDialogBox = 0;
621  fDimension = 0;
622  fVarDraw = kFALSE;
624 // fFilename = "";
625  fSourceFile = "treeviewer.C";
626  //--- lists : trees and widgets to be removed
627 // fTreeList = 0;
628  fTreeIndex = 0;
629  fWidgets = new TList();
630  //--- create menus --------------------------------------------------------
631  //--- File menu
633  fFileMenu->AddEntry("&New canvas", kFileCanvas);
634  fFileMenu->AddEntry("Open &tree file...", kFileBrowse);
635  fFileMenu->AddEntry("&Load Library...", kFileLoadLibrary);
636  fFileMenu->AddEntry("&Open session", kFileOpenSession);
637  fFileMenu->AddEntry("&Save source", kFileSaveMacro);
639  fFileMenu->AddEntry("&Print", kFilePrint);
640  fFileMenu->AddEntry("&Close", kFileClose);
642  fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
643 
645 
646  //--- Edit menu
647  fEditMenu = new TGPopupMenu(gClient->GetRoot());
648  fEditMenu->AddEntry("&Expression...", kEditExpression);
649  fEditMenu->AddEntry("&Cut...", kEditCut);
650  fEditMenu->AddEntry("&Macro...", kEditMacro);
651  fEditMenu->AddEntry("E&Vent...", kEditEvent);
652 
655  //---Run menu
656  fRunMenu = new TGPopupMenu(gClient->GetRoot());
657  fRunMenu->AddEntry("&Macro...", kRunMacro);
659  //--- Options menu
660  //--- General options
661  fOptionsGen = new TGPopupMenu(gClient->GetRoot());
662  fOptionsGen->AddEntry("Default", kOptionsGeneral);
664  fOptionsGen->AddEntry("Axis only", kOptionsGeneral+1); // "AXIS"
665  fOptionsGen->AddEntry("Contour only", kOptionsGeneral+2); // "HIST"
666  fOptionsGen->AddEntry("Superimpose", kOptionsGeneral+3); //"SAME"
667  fOptionsGen->AddEntry("Cylindrical", kOptionsGeneral+4); //"CYL"
668  fOptionsGen->AddEntry("Polar", kOptionsGeneral+5); //"POL"
669  fOptionsGen->AddEntry("Spherical", kOptionsGeneral+6); //"SPH"
670  fOptionsGen->AddEntry("PsRap/Phi", kOptionsGeneral+7); //"PSR"
671  fOptionsGen->AddEntry("Lego HLR", kOptionsGeneral+8); //"LEGO"
672  fOptionsGen->AddEntry("Lego HSR", kOptionsGeneral+9); //"LEGO1"
673  fOptionsGen->AddEntry("Lego Color", kOptionsGeneral+10); //"LEGO2"
674  fOptionsGen->AddEntry("Surface HLR", kOptionsGeneral+11); //"SURF"
675  fOptionsGen->AddEntry("Surface HSR", kOptionsGeneral+12); //"SURF1"
676  fOptionsGen->AddEntry("Surface Col", kOptionsGeneral+13); //"SURF2"
677  fOptionsGen->AddEntry("Surf+Cont", kOptionsGeneral+14); //"SURF3"
678  fOptionsGen->AddEntry("Gouraud", kOptionsGeneral+15); //"SURF4"
679  fOptionsGen->Associate(this);
680  //--- 1D options
681  fOptions1D = new TGPopupMenu(gClient->GetRoot());
682  fOptions1D->AddEntry("Default", kOptions1D);
684  fOptions1D->AddEntry("No labels/ticks", kOptions1D+1); // "AH"
685  fOptions1D->AddEntry("Bar chart", kOptions1D+2); // "B"
686  fOptions1D->AddEntry("Smooth curve", kOptions1D+3); // "C"
687  fOptions1D->AddEntry("Errors", kOptions1D+4); // "E"
688  fOptions1D->AddEntry("Errors 1", kOptions1D+5); // "E1"
689  fOptions1D->AddEntry("Errors 2", kOptions1D+6); // "E2"
690  fOptions1D->AddEntry("Errors 3", kOptions1D+7); // "E3"
691  fOptions1D->AddEntry("Errors 4", kOptions1D+8); // "E4"
692  fOptions1D->AddEntry("Line", kOptions1D+9); // "L"
693  fOptions1D->AddEntry("Markers", kOptions1D+10); // "P"
694  fOptions1D->AddEntry("Stars", kOptions1D+11); // "*H"
695  fOptions1D->Associate(this);
696  //--- 2D options
697  fOptions2D = new TGPopupMenu(gClient->GetRoot());
698  fOptions2D->AddEntry("Default", kOptions2D);
700  fOptions2D->AddEntry("Arrows", kOptions2D+1); // "ARR"
701  fOptions2D->AddEntry("Box/Surf", kOptions2D+2); // "BOX"
702  fOptions2D->AddEntry("Box/Color", kOptions2D+3); // "COL"
703  fOptions2D->AddEntry("Box/ColMap", kOptions2D+4); // "COLZ"
704  fOptions2D->AddEntry("Contour", kOptions2D+5); // "CONT"
705  fOptions2D->AddEntry("Contour 0", kOptions2D+6); // "CONT0"
706  fOptions2D->AddEntry("Contour 1", kOptions2D+7); // "CONT1"
707  fOptions2D->AddEntry("Contour 2", kOptions2D+8); // "CONT2"
708  fOptions2D->AddEntry("Contour 3", kOptions2D+9); // "CONT3"
709  fOptions2D->AddEntry("No front-box", kOptions2D+10); // "FB"
710  fOptions2D->AddEntry("No back-box", kOptions2D+11); // "BB"
711  fOptions2D->AddEntry("Scatter", kOptions2D+12); // "SCAT"
712  fOptions2D->AddEntry("Profile", kOptions2D+13); // "SCAT"
713  fOptions2D->Associate(this);
714 
715  fOptionsMenu = new TGPopupMenu(gClient->GetRoot());
716  fOptionsMenu->AddPopup("&General Options...", fOptionsGen);
717  fOptionsMenu->AddPopup("&1D Options", fOptions1D);
718  fOptionsMenu->AddPopup("&2D Options", fOptions2D);
720  fOptionsMenu->AddEntry("&Reset options", kOptionsReset);
721  //--- Help menu
722  fHelpMenu = new TGPopupMenu(gClient->GetRoot());
723  fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
724  fHelpMenu->AddEntry("&About TreeViewer...", kHelpAboutTV);
726  fHelpMenu->AddEntry("&Starting...", kHelpStart);
727  fHelpMenu->AddEntry("&Layout...", kHelpLayout);
728  fHelpMenu->AddEntry("&Open/Save", kHelpOpenSave);
729  fHelpMenu->AddEntry("&Dragging...", kHelpDragging);
730  fHelpMenu->AddEntry("&Editing expressions...",kHelpEditing);
731  fHelpMenu->AddEntry("&Session...", kHelpSession);
732  fHelpMenu->AddEntry("&User commands...", kHelpCommands);
733  fHelpMenu->AddEntry("&Context menus...", kHelpContext);
734  fHelpMenu->AddEntry("D&rawing...", kHelpDrawing);
735  fHelpMenu->AddEntry("&Macros...", kHelpMacros);
736 
737  fFileMenu->Associate(this);
738  fEditMenu->Associate(this);
739  fRunMenu->Associate(this);
740  fOptionsMenu->Associate(this);
741  fHelpMenu->Associate(this);
742 
743  //--- menubar layout hints
747  //--- create menubar and add popup menus
748  fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
749 
755 
757  //--- toolbar ----------------------------------------------------------------
758  fToolBar = new TGToolBar(this, 10, 10, kHorizontalFrame);
760 
761  TGLayoutHints *lo;
762  lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
763  fWidgets->Add(lo);
764  //--- label for Command text entry
765  fBarLbl1 = new TGLabel(fToolBar,"Command");
767  //--- command text entry
769  fBarCommand->SetWidth(120);
770  fBarCommand->Associate(this);
771  fBarCommand->SetToolTipText("User commands executed via interpreter. Type <ENTER> to execute");
773  //--- first vertical separator
774  TGVertical3DLine *vSeparator = new TGVertical3DLine(fToolBar);
775  lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,4,0,0);
776  fWidgets->Add(lo);
777  fWidgets->Add(vSeparator);
778  fToolBar->AddFrame(vSeparator, lo);
779 
780  lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
781  fWidgets->Add(lo);
782  //--- label for Option text entry
783  fBarLbl2 = new TGLabel(fToolBar,"Option");
784  fToolBar->AddFrame(fBarLbl2, lo);
785  //--- drawing option text entry
787  fBarOption->SetWidth(100);
788  fBarOption->Associate(this);
789  fBarOption->SetToolTipText("Histogram graphics option. Type option here and click <Draw> (or <ENTER> to update current histogram).");
791  //--- second vertical separator
792  vSeparator = new TGVertical3DLine(fToolBar);
793  lo = new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 4,4,0,0);
794  fWidgets->Add(lo);
795  fWidgets->Add(vSeparator);
796  fToolBar->AddFrame(vSeparator, lo);
797 
798  lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
799  fWidgets->Add(lo);
800  //--- label for Histogram text entry
801  fBarLbl3 = new TGLabel(fToolBar,"Histogram");
802  fToolBar->AddFrame(fBarLbl3, lo);
803 
804  //--- histogram name text entry
805  lo = new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 4,4,0,0);
806  fWidgets->Add(lo);
807  fBarHist = new TGTextEntry(fToolBar, new TGTextBuffer(100));
810  fBarHist->SetText("htemp");
811  fToolBar->AddFrame(fBarHist, lo);
812 
813  //--- Hist check button
814  lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4,4,0,0);
815  fWidgets->Add(lo);
816  fBarH = new TGCheckButton(fToolBar, "Hist");
817  fBarH->SetToolTipText("Checked : redraw only current histogram");
819  fToolBar->AddFrame(fBarH, lo);
820  //--- Scan check button
821  fBarScan = new TGCheckButton(fToolBar, "Scan");
823  fBarScan->SetToolTipText("Check to redirect TTree::Scan command in a file");
824  fToolBar->AddFrame(fBarScan, lo);
825  //--- Rec check button
826  fBarRec = new TGCheckButton(fToolBar, "Rec");
828  fBarRec->SetToolTipText("Check to record commands in history file and be verbose");
829  fToolBar->AddFrame(fBarRec, lo);
830  //--- 1'st horizontal tool bar separator ----------------------------------------
831  TGHorizontal3DLine *toolBarSep = new TGHorizontal3DLine(this);
832  fWidgets->Add(toolBarSep);
833  AddFrame(toolBarSep, fBarLayout);
835  //--- 2'nd horizontal tool bar separator ----------------------------------------
836  toolBarSep = new TGHorizontal3DLine(this);
837  fWidgets->Add(toolBarSep);
838  AddFrame(toolBarSep, fBarLayout);
839 
840  //--- Horizontal mother frame ---------------------------------------------------
841  fHf = new TGHorizontalFrame(this, 10, 10);
842  //--- Vertical frames
844 // fSlider->SetBackgroundColor(color);
845  fSlider->Associate(this);
846 
847  //--- fV1 -----------------------------------------------------------------------
848  fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
850 
851  fLbl1 = new TGLabel(fTreeHdr, "Current Folder");
852  lo = new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY, 3, 0, 0, 0);
853  fWidgets->Add(lo);
854  fTreeHdr->AddFrame(fLbl1, lo);
855 
856  lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 1, 0);
857  fWidgets->Add(lo);
858  fV1->AddFrame(fTreeHdr, lo);
859 
860  //--- tree view canvas on the left
862  //--- container frame
864  GetWhitePixel());
865  fLt->Associate(this);
866  fTreeView->SetContainer(fLt);
867 
868  lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2,0,0,0);
869  fWidgets->Add(lo);
870  fV1->AddFrame(fTreeView, lo);
871 
872  //--- button horizontal frame
874 
875  //--- DRAW button
876  fPicDraw = gClient->GetPicture("draw_t.xpm");
877  fDRAW = new TGPictureButton(fHpb,fPicDraw,kDRAW);
878  fDRAW->SetToolTipText("Draw current selection");
879  fDRAW->Associate(this);
880 
881  lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
882  fWidgets->Add(lo);
883  fHpb->AddFrame(fDRAW, lo);
884 
885  //--- SPIDER button
886  fSPIDER = new TGTextButton(fHpb,"SPIDER");
887  fSPIDER->SetToolTipText("Scan current selection using a spider plot");
888  fSPIDER->Associate(this);
889 
890  lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
891  fWidgets->Add(lo);
892  fHpb->AddFrame(fSPIDER,lo);
893  //---connect SPIDER button to ExecuteScan() method
894  fSPIDER->Connect("Clicked()","TTreeViewer",this,"ExecuteSpider()");
895 
896  //--- STOP button (breaks current operation)
897 // fPicStop = gClient->GetPicture("mb_stop_s.xpm");
898  fPicStop = gClient->GetPicture("stop_t.xpm");
900  fSTOP->SetToolTipText("Abort current operation");
901  fSTOP->Associate(this);
902 
903  lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
904  fWidgets->Add(lo);
905  fHpb->AddFrame(fSTOP, lo);
906 
907  //--- REFR button (breaks current operation)
908  fPicRefr = gClient->GetPicture("refresh2.xpm");
910  fREFR->SetToolTipText("Update the tree viewer");
911  lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,4,2);
912  fWidgets->Add(lo);
913  fHpb->AddFrame(fREFR, lo);
914  //---connect REFR button to DoRefresh() method
915  fREFR->Connect("Clicked()", "TTreeViewer", this, "DoRefresh()");
916 
917  lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,2,2);
918  fWidgets->Add(lo);
919  fV1->AddFrame(fHpb, lo);
920 
921  //--- fV2
922  fV2 = new TGVerticalFrame(fHf, 10, 10);
924  fLbl2 = new TGLabel(fListHdr, "Current Tree: ");
925  lo = new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 0, 0, 0);
926  fWidgets->Add(lo);
927  fListHdr->AddFrame(fLbl2, lo);
928 
929  //--- progress bar
931  fProgressBar->SetBarColor("red");
933  lo = new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 2,2,4,2);
934  fWidgets->Add(lo);
936  lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 2,0,1,2);
937  fWidgets->Add(lo);
938  fV2->AddFrame(fListHdr, lo);
939 
942  fWidgets->Add(lo);
943  fHf->AddFrame(fSlider, lo);
945  fWidgets->Add(lo);
946  fHf->AddFrame(fV1, lo);
947 
948  //--- vertical splitter
950  splitter->SetFrame(fV1,kTRUE);
952  fWidgets->Add(splitter);
953  fWidgets->Add(lo);
954  fHf->AddFrame(splitter,lo);
955 
956 
957 
958  //-- listview for the content of the tree/branch -----------------------------
959  fListView = new TGListView(fListHdr,400,300);
960  //--- container frame
962  fLVContainer->Associate(this);
964  fLVContainer->SetViewer(this);
970  fWidgets->Add(lo);
971 
973 
975  fWidgets->Add(lo);
976  fHf->AddFrame(fV2,lo);
977 
978  AddFrame(fHf, lo);
979  //--- 3rd horizontal tool bar separator ----------------------------------------
980  toolBarSep = new TGHorizontal3DLine(this);
981  fWidgets->Add(toolBarSep);
982  AddFrame(toolBarSep, fBarLayout);
983 
984  //--- label for IList text entry
985  fBFrame = new TGHorizontalFrame(this,10,10);
986  fBLbl4 = new TGLabel(fBFrame,"IList");
987  lo = new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2,2,2,2);
988  fWidgets->Add(lo);
989  fBFrame->AddFrame(fBLbl4, lo);
990  //--- IList text entry
991  fBarListIn = new TGTextEntry(fBFrame, new TGTextBuffer(100));
992  fBarListIn->SetWidth(60);
993  fBarListIn->SetToolTipText("Name of a previously created event list");
995  //--- label for OList text entry
996  fBLbl5 = new TGLabel(fBFrame,"OList");
997  fBFrame->AddFrame(fBLbl5, lo);
998  //--- OList text entry
999  fBarListOut = new TGTextEntry(fBFrame, new TGTextBuffer(100));
1000  fBarListOut->SetWidth(60);
1001  fBarListOut->SetToolTipText("Output event list. Use <Draw> to generate it.");
1003  //--- Status bar
1004  fStatusBar = new TGStatusBar(fBFrame, 10, 10);
1005  fStatusBar->SetWidth(200);
1008  fWidgets->Add(lo);
1009  fBFrame->AddFrame(fStatusBar, lo);
1010  //--- RESET button
1011  fReset = new TGTextButton(fBFrame,"RESET",kRESET);
1012  fReset->SetToolTipText("Reset variable's fields and drawing options");
1013  fReset->Associate(this);
1014  lo = new TGLayoutHints(kLHintsTop | kLHintsRight, 2,2,2,2);
1015  fWidgets->Add(lo);
1016  fBFrame->AddFrame(fReset,lo);
1017  //--- group of buttons for session handling
1019  gClient->GetPicture("first_t.xpm"), kBGFirst);
1020  fBGFirst->SetToolTipText("First record");
1021  fBGFirst->Associate(this);
1023  gClient->GetPicture("previous_t.xpm"), kBGPrevious);
1024  fBGPrevious->SetToolTipText("Previous record");
1025  fBGPrevious->Associate(this);
1027  gClient->GetPicture("record_t.xpm"), kBGRecord);
1028  fBGRecord->SetToolTipText("Record");
1029  fBGRecord->Associate(this);
1031  gClient->GetPicture("next_t.xpm"), kBGNext);
1032  fBGNext->SetToolTipText("Next record");
1033  fBGNext->Associate(this);
1035  gClient->GetPicture("last_t.xpm"), kBGLast);
1036  fBGLast->SetToolTipText("Last record");
1037  fBGLast->Associate(this);
1038 
1039  fCombo = new TGComboBox(fBFrame, 0);
1041  fCombo->SetWidth(100);
1042  fCombo->Associate(this);
1043 
1044  lo = new TGLayoutHints(kLHintsCenterY | kLHintsRight, 0,0,2,0);
1045  fWidgets->Add(lo);
1046  fBFrame->AddFrame(fCombo, lo);
1047  fBFrame->AddFrame(fBGLast, lo);
1048  fBFrame->AddFrame(fBGNext, lo);
1049  fBFrame->AddFrame(fBGRecord, lo);
1051  fBFrame->AddFrame(fBGFirst, lo);
1052  lo = new TGLayoutHints(kLHintsExpandX,2,2,2,0);
1053  fWidgets->Add(lo);
1054  AddFrame(fBFrame,lo);
1055 
1056  // map the window
1057  SetWindowName("TreeViewer");
1058  MapSubwindows();
1060  MapWindow();
1061 
1062  // put default items in the listview on the right
1063  const TGPicture *pic, *spic;
1064 
1066  TTVLVEntry* entry;
1067  Char_t symbol;
1069  symbol = 'X';
1070  entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1071  entry->SetToolTipText("X expression. Drag and drop expressions here");
1072  //--- X item
1073  fLVContainer->AddThisItem(entry);
1074  entry->Empty();
1075  entry->MapWindow();
1076 
1078  symbol = 'Y';
1079  entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1080  entry->SetToolTipText("Y expression. Drag and drop expressions here");
1081  //--- Y item
1082  fLVContainer->AddThisItem(entry);
1083  entry->Empty();
1084  entry->MapWindow();
1085 
1087  symbol = 'Z';
1088  entry->SetUserData(new ULong_t((symbol << 8) | kLTExpressionType | kLTTreeType));
1089  entry->SetToolTipText("Z expression. Drag and drop expressions here");
1090  //--- Z item
1091  fLVContainer->AddThisItem(entry);
1092  entry->Empty();
1093  entry->MapWindow();
1094 
1095  pic = gClient->GetPicture("cut_t.xpm");
1096  spic = gClient->GetPicture("cut_t.xpm");
1097  entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString(),0,kLVSmallIcons);
1099  entry->SetToolTipText("Active cut. Double-click to enable/disable");
1100  //--- Cut item (scissors icon)
1101  fLVContainer->AddThisItem(entry);
1102  entry->Empty();
1103  entry->MapWindow();
1104 
1105  pic = gClient->GetPicture("pack_t.xpm");
1106  spic = gClient->GetPicture("pack-empty_t.xpm");
1107  entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString("Scan box"),0,kLVSmallIcons);
1109  entry->SetToolTipText("Drag and drop expressions/leaves here. Double-click to scan. Check <Scan> to redirect on file.");
1110  //--- Scan Box
1111  fLVContainer->AddThisItem(entry);
1112  entry->MapWindow();
1113  entry->SetTrueName("");
1114 
1115  //--- 10 expression items
1116  fNexpressions = 10;
1117  for (Int_t i=0; i<fNexpressions; i++) {
1118  pic = gClient->GetPicture("expression_t.xpm");
1119  spic = gClient->GetPicture("expression_t.xpm");
1120  entry = new TTVLVEntry(fLVContainer,pic,spic,new TGString(),0,kLVSmallIcons);
1122  entry->SetToolTipText("User defined expression/cut. Double-click to edit");
1123  fLVContainer->AddThisItem(entry);
1124  entry->Empty();
1125  entry->MapWindow();
1126  }
1127 
1128  fListView->Layout();
1129  fListView->Resize();
1130 // EmptyAll();
1131  // map the tree if it was supplied in the constructor
1132 
1133  if (!fTree) {
1134  fSlider->SetRange(0,1000000);
1135  fSlider->SetPosition(0,1000000);
1136  } else {
1137  fSlider->SetRange(0,fTree->GetEntries()-1);
1139  }
1140  PrintEntries();
1144 
1145  // map the window
1146  ///SetWindowName("TreeViewer");
1147  MapSubwindows();
1149  MapWindow();
1150 }
1151 
1152 ////////////////////////////////////////////////////////////////////////////////
1153 /// TTreeViewer destructor.
1154 
1156 {
1157  if (!gClient) return;
1158  gClient->FreePicture(fPicX);
1159  gClient->FreePicture(fPicY);
1160  gClient->FreePicture(fPicZ);
1161  gClient->FreePicture(fPicDraw);
1162  gClient->FreePicture(fPicStop);
1163  gClient->FreePicture(fPicRefr);
1164 
1166  if (fDialogBox) delete fDialogBox;
1167 
1168  delete fContextMenu;
1169 
1170  delete fBarLbl1;
1171  delete fBarLbl2;
1172  delete fBarLbl3;
1173  delete fBLbl4;
1174  delete fBLbl5;
1175  delete fBarCommand;
1176  delete fBarOption;
1177  delete fBarHist;
1178  delete fBarListIn;
1179  delete fBarListOut;
1180 
1181  delete fBarH;
1182  delete fBarScan;
1183  delete fBarRec;
1184 
1185  delete fToolBar;
1186 
1187  delete fSlider;
1188  delete fV1;
1189  delete fV2;
1190  delete fLbl1;
1191  delete fLbl2;
1192  delete fHf;
1193  delete fTreeHdr;
1194  delete fListHdr;
1195  delete fLt;
1196  delete fTreeView;
1197  delete fLVContainer;
1198  delete fListView;
1199 
1200  delete fProgressBar;
1201  delete fHpb;
1202 
1203  delete fDRAW;
1204  delete fSPIDER;
1205  delete fSTOP;
1206  delete fReset;
1207  delete fBGFirst;
1208  delete fBGPrevious;
1209  delete fBGRecord;
1210  delete fBGNext;
1211  delete fBGLast;
1212  delete fCombo;
1213  delete fBFrame;
1214 
1215  delete fMenuBar;
1216  delete fFileMenu;
1217  delete fEditMenu;
1218 
1219  delete fOptionsGen;
1220  delete fOptions1D;
1221  delete fOptions2D;
1222  delete fOptionsMenu;
1223  delete fHelpMenu;
1224  delete fMenuBarLayout;
1225  delete fMenuBarItemLayout;
1226  delete fMenuBarHelpLayout;
1227  delete fBarLayout;
1228 
1229  fWidgets->Delete();
1230  delete fWidgets;
1231  if (fTreeList) {
1232  delete fTreeList;
1233  }
1234  delete fTimer;
1235  delete fSession;
1236 }
1237 
1238 ////////////////////////////////////////////////////////////////////////////////
1239 /// Enable/disable session buttons.
1240 
1242  Bool_t next, Bool_t last)
1243 {
1244  if (first) fBGFirst->SetState(kButtonUp);
1246  if (previous) fBGPrevious->SetState(kButtonUp);
1248  if (next) fBGNext->SetState(kButtonUp);
1250  if (last) fBGLast->SetState(kButtonUp);
1252 }
1253 
1254 ////////////////////////////////////////////////////////////////////////////////
1255 /// Apply Cut
1256 
1257 const char* TTreeViewer::Cut()
1258 {
1259  return fLVContainer->Cut();
1260 }
1261 
1262 ////////////////////////////////////////////////////////////////////////////////
1263 /// returns scanlist
1264 
1266 {
1267  return fLVContainer->ScanList();
1268 }
1269 
1270 ////////////////////////////////////////////////////////////////////////////////
1271 /// Set current session
1272 
1274 {
1275  if (session) {
1276  delete fSession;
1277  fSession = session;
1278  }
1279 }
1280 
1281 ////////////////////////////////////////////////////////////////////////////////
1282 /// Empty the bracket content of a string.
1283 
1284 const char* TTreeViewer::EmptyBrackets(const char* name)
1285 {
1286  TString stripped(name);
1287  if (!stripped.Contains("[")) return name;
1288  TString retstr(name);
1289  TObjString *objstr;
1290  Int_t index = 0;
1291  while (stripped.Index("[", index) != kNPOS) {
1292  Int_t start = stripped.Index("[", index);
1293  Int_t end = stripped.Index("]", index);
1294  if (end == kNPOS) {
1295  objstr = new TObjString(retstr.Data());
1296  fWidgets->Add(objstr);
1297  return (objstr->String()).Data();
1298  }
1299  index = start+2;
1300  retstr = stripped.Remove(start+1, end-start-1);
1301  stripped = retstr;
1302  }
1303  objstr = new TObjString(retstr.Data());
1304  fWidgets->Add(objstr);
1305  return (objstr->String()).Data();
1306 }
1307 
1308 ////////////////////////////////////////////////////////////////////////////////
1309 /// Clear the content of all items in the list view.
1310 
1312 {
1314 }
1315 
1316 ////////////////////////////////////////////////////////////////////////////////
1317 /// Empty the content of the selected expression.
1318 
1320 {
1321  void *p = 0;
1322  TTVLVEntry *item = 0;
1323  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == 0) {
1324  Warning("Empty", "No item selected.");
1325  return;
1326  }
1327  ULong_t *itemType = (ULong_t *) item->GetUserData();
1328  if (!(*itemType & kLTExpressionType)) {
1329  Warning("Empty", "Not expression type.");
1330  return;
1331  }
1332  if (*itemType & kLTPackType) {
1333  item->SetSmallPic(fClient->GetPicture("pack-empty_t.xpm"));
1334  item->SetTrueName("");
1335  return;
1336  }
1337  item->Empty();
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Get the item from a specific position.
1342 
1344 {
1345  return fLVContainer->ExpressionItem(index);
1346 }
1347 
1348 ////////////////////////////////////////////////////////////////////////////////
1349 /// Get the list of expression items.
1350 
1352 {
1353  return fLVContainer->ExpressionList();
1354 }
1355 
1356 ////////////////////////////////////////////////////////////////////////////////
1357 /// Compute dimension of the histogram.
1358 
1360 {
1361  fDimension = 0;
1362  if (Ex() && strlen(Ex())) fDimension++;
1363  if (Ey() && strlen(Ey())) fDimension++;
1364  if (Ez() && strlen(Ez())) fDimension++;
1365  return fDimension;
1366 }
1367 
1368 ////////////////////////////////////////////////////////////////////////////////
1369 /// Called when the DRAW button is executed.
1370 
1372 {
1373  TString varexp;
1374  TString command;
1375  Int_t dimension = 0;
1376  TString alias[3];
1377  TTVLVEntry *item;
1378  Int_t i;
1379  // fill in expressions
1380  if (fVarDraw) {
1381  void *p = 0;
1382  dimension = 1;
1383  if (!(item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p))) return;
1384  alias[0] = item->GetAlias();
1385  if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1386  varexp = item->ConvertAliases();
1387  } else {
1388  if (Ez() && strlen(Ez())) {
1389  dimension++;
1390  varexp = Ez();
1391  item = ExpressionItem(2);
1392  alias[2] = item->GetAlias();
1393  if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1394  }
1395  if ((Ez() && strlen(Ez())) && ((Ex() &&strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1396  if (Ey() && strlen(Ey())) {
1397  dimension++;
1398  varexp += Ey();
1399  item = ExpressionItem(1);
1400  alias[1] = item->GetAlias();
1401  if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1402  }
1403  if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1404  if (Ex () && strlen(Ex())) {
1405  dimension++;
1406  varexp += Ex();
1407  item = ExpressionItem(0);
1408  alias[0] = item->GetAlias();
1409  if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1410  }
1411  }
1412  if (!dimension && !fScanMode) {
1413  Warning("ExecuteDraw", "Nothing to draw on X,Y,Z.");
1414  return;
1415  }
1416  // find ListIn
1417  fTree->SetEventList(0);
1418  TEventList *elist = 0;
1419  if (strlen(fBarListIn->GetText())) {
1420  elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1421  if (elist) fTree->SetEventList(elist);
1422  }
1423  // find ListOut
1424  if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1425  // find histogram name
1426  if (strcmp("htemp", fBarHist->GetText())) {
1427  varexp += ">>";
1428  varexp += fBarHist->GetText();
1429  }
1430  // find canvas/pad where to draw
1431  TPad *pad = (TPad*)gROOT->GetSelectedPad();
1432  if (pad) pad->cd();
1433  // find graphics option
1434  const char* gopt = fBarOption->GetText();
1435  // just in case a previous interrupt was posted
1436  gROOT->SetInterrupt(kFALSE);
1437  // check if cut is enabled
1438  const char *cut = "";
1439  if (fEnableCut) cut = Cut();
1440 
1441  // get entries to be processed
1443  fSlider->GetMinPosition() + 1);
1444  Long64_t firstentry =(Long64_t) fSlider->GetMinPosition();
1445 //printf("firstentry=%lld, nentries=%lld\n",firstentry,nentries);
1446  // check if Scan is checked and if there is something in the box
1447  if (fScanMode) {
1448 // fBarScan->SetState(kButtonUp);
1449  fScanMode = kFALSE;
1450  if (ScanList() && strlen(ScanList())) varexp = ScanList();
1451  command = TString::Format("tv__tree->Scan(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1452  varexp.Data(), cut, gopt, nentries, firstentry);
1453  if (fBarScan->GetState() == kButtonDown) {
1455  } else {
1457  }
1458  ExecuteCommand(command.Data(), kTRUE);
1459  return;
1460  }
1461  // check if only histogram has to be updated
1462  if (fBarH->GetState() == kButtonDown) {
1463  // reset 'Hist' mode
1465  TH1 *hist = fTree->GetHistogram();
1466  if (hist && gPad) {
1467  //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1468  if (hist) {
1469  // check if graphic option was modified
1470  TString last(fLastOption);
1471  TString current(gopt);
1472  current.ToUpper();
1473  last.ToUpper();
1474  if (current == last) {
1475  gPad->Update();
1476  return;
1477  }
1478  if (dimension == 3 && strlen(gopt)) {
1479  std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1480  return;
1481  }
1482  std::cout << " Graphics option for current histogram changed to " << gopt << std::endl;
1483  hist->Draw(gopt);
1485  gPad->Update();
1486  return;
1487  }
1488  }
1489  }
1490  // send draw command
1492  if (!gopt[0] && dimension!=3)
1493  //{
1494  // gopt = "hist";
1495  // fLastOption = "hist";
1496  //}
1497  if (dimension == 3 && strlen(gopt)) {
1498  std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1499  gopt = "";
1500  fLastOption = "";
1501  }
1502  command = TString::Format("tv__tree->Draw(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1503  varexp.Data(), cut, gopt, nentries, firstentry);
1504  if (fCounting) return;
1505  fCounting = kTRUE;
1506  fTree->SetTimerInterval(200);
1507  fTimer->TurnOn();
1508  ExecuteCommand(command.Data());
1510  fTimer->TurnOff();
1511  fTree->SetTimerInterval(0);
1512  fCounting = kFALSE;
1515  TH1 *hist = fTree->GetHistogram();
1516  if (hist) {
1517  // put expressions aliases on axes
1518  Int_t current = 0;
1519  for (i=0; i<3; i++) {
1520  if (alias[i].Length()) {
1521  if (i != current) {
1522  alias[current] = alias[i];
1523  alias[i] = "";
1524  }
1525  current++;
1526  }
1527  }
1528  //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1529  TAxis *axis[3];
1530  axis[0] = hist->GetXaxis();
1531  axis[1] = hist->GetYaxis();
1532  axis[2] = hist->GetZaxis();
1533  for (Int_t ind=0; ind<3; ind++) axis[ind]->SetTitle(alias[ind].Data());
1534  }
1535  if (gPad) gPad->Update();
1536 }
1537 
1538 ////////////////////////////////////////////////////////////////////////////////
1539 /// Draw a spider plot for the selected entries.
1540 
1542 {
1543  TString varexp;
1544  Int_t dimension = 0;
1545  TString alias[3];
1546  TTVLVEntry *item;
1547  Bool_t previousexp = kFALSE;
1548  // fill in expressions
1549  if (Ez() && strlen(Ez())) {
1550  previousexp = kTRUE;
1551  dimension++;
1552  varexp = Ez();
1553  item = ExpressionItem(2);
1554  alias[2] = item->GetAlias();
1555  if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1556  }
1557  if ((Ez() && strlen(Ez())) && ((Ex() && strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1558  if (Ey() && strlen(Ey())) {
1559  previousexp = kTRUE;
1560  dimension++;
1561  varexp += Ey();
1562  item = ExpressionItem(1);
1563  alias[1] = item->GetAlias();
1564  if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1565  }
1566  if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1567  if (Ex() && strlen(Ex())) {
1568  previousexp = kTRUE;
1569  dimension++;
1570  varexp += Ex();
1571  item = ExpressionItem(0);
1572  alias[0] = item->GetAlias();
1573  if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1574  }
1575  for(Int_t i=0;i<10;++i){
1576  if(En(i+5) && strlen(En(i+5))){
1577  ++dimension;
1578  if(previousexp){
1579  varexp += ":";
1580  varexp += En(i+5);
1581  } else varexp = En(i+5);
1582  previousexp = kTRUE;
1583  }
1584  }
1585  if (dimension<3) {
1586  Warning("ExecuteSpider", "Need at least 3 variables");
1587  return;
1588  }
1589  // find ListIn
1590  fTree->SetEventList(0);
1591  TEventList *elist = 0;
1592  if (strlen(fBarListIn->GetText())) {
1593  elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1594  if (elist) fTree->SetEventList(elist);
1595  }
1596  // find ListOut
1597  if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1598  // find canvas/pad where to draw
1599  TPad *pad = (TPad*)gROOT->GetSelectedPad();
1600  if (pad) pad->cd();
1601  // find graphics option
1602  const char* gopt = fBarOption->GetText();
1603  // just in case a previous interrupt was posted
1604  gROOT->SetInterrupt(kFALSE);
1605  // check if cut is enabled
1606  const char *cut = "";
1607  if (fEnableCut) cut = Cut();
1608 
1609  // get entries to be processed
1611  fSlider->GetMinPosition() + 1);
1612  Long64_t firstentry =(Long64_t) fSlider->GetMinPosition();
1613 
1614  // create the spider plot
1615 
1616  TSpider* spider = new TSpider(fTree,varexp.Data(),cut,Form("%s spider average",gopt),nentries,firstentry);
1617  spider->Draw();
1618 
1619  if (gPad) gPad->Update();
1620 }
1621 
1622 ////////////////////////////////////////////////////////////////////////////////
1623 /// Get the expression to be drawn on X axis.
1624 
1625 const char* TTreeViewer::Ex()
1626 {
1627  return fLVContainer->Ex();
1628 }
1629 
1630 ////////////////////////////////////////////////////////////////////////////////
1631 /// Get the expression to be drawn on Y axis.
1632 
1633 const char* TTreeViewer::Ey()
1634 {
1635  return fLVContainer->Ey();
1636 }
1637 
1638 ////////////////////////////////////////////////////////////////////////////////
1639 /// Get the expression to be drawn on Z axis.
1640 
1641 const char* TTreeViewer::Ez()
1642 {
1643  return fLVContainer->Ez();
1644 }
1645 
1646 ////////////////////////////////////////////////////////////////////////////////
1647 /// Get the n'th expression
1648 
1650 {
1652  if(e) return e->ConvertAliases();
1653  return "";
1654 }
1655 
1656 ////////////////////////////////////////////////////////////////////////////////
1657 /// Start the expression editor.
1658 
1660 {
1661  void *p = 0;
1662  // get the selected item
1663  TTVLVEntry *item = 0;
1664  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == 0) {
1665  Warning("EditExpression", "No item selected.");
1666  return;
1667  }
1668  // check if it is an expression
1669  ULong_t *itemType = (ULong_t *) item->GetUserData();
1670  if (!(*itemType & kLTExpressionType)) {
1671  Warning("EditExpression", "Not expression type.");
1672  return;
1673  }
1674  // check if the editor is already active
1676  if (!fDialogBox) {
1677  fDialogBox = new TGSelectBox(fClient->GetRoot(), this, fV1->GetWidth() - 10);
1678  }
1679  // copy current item data into editor boxes
1680  fDialogBox->SetEntry(item);
1681  fDialogBox->SetWindowName("Expression editor");
1682  // check if you are editing the cut expression
1683  if (*itemType & kLTCutType || item->IsCut()) {
1684  fDialogBox->SetLabel("Selection");
1685  } else {
1686  fDialogBox->SetLabel("Expression");
1687  }
1688 }
1689 
1690 ////////////////////////////////////////////////////////////////////////////////
1691 /// Get use of TTree::MakeSelector() via the context menu.
1692 
1693 Int_t TTreeViewer::MakeSelector(const char* selector)
1694 {
1695  if (!fTree) return 0;
1696  return fTree->MakeSelector(selector);
1697 }
1698 
1699 ////////////////////////////////////////////////////////////////////////////////
1700 /// Get use of TTree::Process() via the context menu.
1701 
1703 {
1704  if (!fTree) return 0;
1705  return fTree->Process(filename, option, nentries, firstentry);
1706 }
1707 
1708 ////////////////////////////////////////////////////////////////////////////////
1709 /// Get graph option
1710 
1712 {
1713  return fBarOption->GetText();
1714 }
1715 
1716 ////////////////////////////////////////////////////////////////////////////////
1717 /// Set graph option
1718 
1719 void TTreeViewer::SetGrOpt(const char *option)
1720 {
1721  fBarOption->SetText(option);
1722 }
1723 
1724 ////////////////////////////////////////////////////////////////////////////////
1725 /// Return kTRUE if scan is redirected
1726 
1728 {
1729  return (fBarScan->GetState()==kButtonDown);
1730 }
1731 
1732 ////////////////////////////////////////////////////////////////////////////////
1733 /// Remove the selected item from the list.
1734 
1736 {
1737  void *p = 0;
1738  TTVLVEntry *item = 0;
1739  // get the selected item
1740  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == 0) {
1741  Warning("RemoveItem", "No item selected.");
1742  return;
1743  }
1744  // check if it is removable
1745  ULong_t *itemType = (ULong_t *) item->GetUserData();
1746  if (!(*itemType & kLTDragType)) {
1747  Warning("RemoveItem", "Not removable type.");
1748  return;
1749  }
1750  fLVContainer->RemoveItem(item);
1751  fListView->Layout();
1752 }
1753 
1754 ////////////////////////////////////////////////////////////////////////////////
1755 /// Remove the current record.
1756 
1758 {
1760 }
1761 
1762 ////////////////////////////////////////////////////////////////////////////////
1763 /// This function is called by the fTimer object.
1764 
1766 {
1767  if (fCounting) {
1768  Float_t first = fSlider->GetMinPosition();
1769  Float_t last = fSlider->GetMaxPosition();
1770  Float_t current = (Float_t)fTree->GetReadEntry();
1771  Float_t percent = (current-first+1)/(last-first+1);
1772  fProgressBar->SetPosition(100.*percent);
1774  }
1775  timer->Reset();
1776  return kFALSE;
1777 }
1778 
1779 ////////////////////////////////////////////////////////////////////////////////
1780 /// Handle menu and other commands generated.
1781 
1783 {
1784  TRootHelpDialog *hd;
1785  TTVRecord *record;
1786 
1787  switch (GET_MSG(msg)) {
1788  case kC_VSLIDER :
1789  // handle slider messages
1790  PrintEntries();
1791  break;
1792  case kC_TEXTENTRY:
1793  switch (GET_SUBMSG(msg)) {
1794  // handle enter posted by the Command text entry
1795  case kTE_ENTER:
1796  if ((ERootTreeViewerCommands)parm1 == kBarCommand) {
1798  fBarCommand->Clear();
1799  }
1800  if ((ERootTreeViewerCommands)parm1 == kBarOption) {
1801  fVarDraw = kFALSE;
1803  ExecuteDraw();
1805  }
1806  break;
1807  default:
1808  break;
1809  }
1810  break;
1811  case kC_LISTTREE:
1812  switch (GET_SUBMSG(msg)) {
1813  // handle mouse messages in the list-tree (left panel)
1814  case kCT_ITEMCLICK :
1815  // tell coverity that parm1 is a Long_t, and not an enum (even
1816  // if we compare it with an enum value) and the meaning of
1817  // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
1818  // coverity[mixed_enums]
1819  if (((EMouseButton)parm1==kButton1) ||
1820  ((EMouseButton)parm1==kButton3)) {
1821  TGListTreeItem *ltItem = 0;
1822  // get item that sent this
1823  if ((ltItem = fLt->GetSelected()) != 0) {
1824  // get item type
1825  ULong_t *itemType = (ULong_t *)ltItem->GetUserData();
1826  if (!itemType)
1827  break;
1828  if (*itemType & kLTTreeType) {
1829  // already mapped tree item clicked
1830  Int_t index = (Int_t)(*itemType >> 8);
1831  SwitchTree(index);
1832  if (fTree != fMappedTree) {
1833  // switch also the global "tree" variable
1835  // map it on the right panel
1836  MapTree(fTree);
1837  fListView->Layout();
1838  }
1839  // activate context menu for this tree
1840  if (parm1 == kButton3) {
1841  Int_t x = (Int_t)(parm2 &0xffff);
1842  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1843  fContextMenu->Popup(x, y, fTree);
1844  }
1845  }
1846 
1847  if (*itemType & kLTBranchType) {
1848  // branch item clicked
1849  SetParentTree(ltItem);
1850  if (!fTree) break; // really needed ?
1851  TBranch *branch = fTree->GetBranch(ltItem->GetText());
1852  if (!branch) break;
1853  // check if it is mapped on the right panel
1854  if (branch != fMappedBranch) {
1856  MapBranch(branch);
1857  fStopMapping = kFALSE;
1858  fListView->Layout();
1859  }
1860  // activate context menu for this branch (no *MENU* methods ):)
1861  if (parm1 == kButton3) {
1862  Int_t x = (Int_t)(parm2 &0xffff);
1863  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1864  fContextMenu->Popup(x, y, branch);
1865  }
1866  }
1867 
1868  if (*itemType & kLTLeafType) {
1869  // leaf item clicked
1870  SetParentTree(ltItem);
1871  if (!fTree) break;
1872  // find parent branch
1873  TBranch *branch = fTree->GetBranch(ltItem->GetParent()->GetText());
1874  if (!branch) {
1875  if (fTree != fMappedTree) {
1877  MapTree(fTree);
1878  fListView->Layout();
1879  }
1880  } else {
1881  // check if it is already mapped
1882  if (branch!=fMappedBranch) {
1884  MapBranch(branch);
1885  fStopMapping = kFALSE;
1886  fListView->Layout();
1887  }
1888  }
1889  // select corresponding leaf on the right panel
1890  fLVContainer->SelectItem(ltItem->GetText());
1891  if (parm1 == kButton3) {
1892  // activate context menu for this leaf
1894  }
1895  }
1896  }
1897  }
1898  break;
1899  case kCT_ITEMDBLCLICK :
1901  if (parm1 == kButton1) {
1902  // execute double-click action for corresponding item in the right panel
1904  }
1905  break;
1906  default:
1907  break;
1908  }
1909  break;
1910  case kC_COMMAND:
1911  switch (GET_SUBMSG(msg)) {
1912  case kCM_COMBOBOX:
1913  if ((record = fSession->GetRecord((Int_t)parm2)))
1914  fSession->Show(record);
1915  break;
1916  case kCM_BUTTON:
1917  switch (parm1) {
1918  // handle button messages
1919  case kRESET:
1920  EmptyAll();
1921  break;
1922  case kDRAW:
1923  fVarDraw = kFALSE;
1924  ExecuteDraw();
1925  break;
1926  case kSTOP:
1927  if (fCounting)
1928  gROOT->SetInterrupt(kTRUE);
1929  break;
1930  case kCLOSE:
1931  SendCloseMessage();
1932  break;
1933  case kBGFirst:
1934  if ((record = fSession->First()))
1935  fSession->Show(record);
1936  break;
1937  case kBGPrevious:
1938  if ((record = fSession->Previous()))
1939  fSession->Show(record);
1940  break;
1941  case kBGRecord:
1942  fSession->AddRecord();
1943  break;
1944  case kBGNext:
1945  if ((record = fSession->Next()))
1946  fSession->Show(record);
1947  break;
1948  case kBGLast:
1949  if ((record = fSession->Last()))
1950  fSession->Show(record);
1951  break;
1952  default:
1953  break;
1954  }
1955  break;
1956  case kCM_MENU:
1957  // handle menu messages
1958  // check if sent by Options menu
1959  if ((parm1>=kOptionsReset) && (parm1<kHelpAbout)) {
1960  Dimension();
1961  if ((fDimension==0) && (parm1>=kOptions1D)) {
1962  Warning("ProcessMessage", "Edit expressions first.");
1963  break;
1964  }
1965  if ((fDimension==1) && (parm1>=kOptions2D)) {
1966  Warning("ProcessMessage", "You have only one expression active.");
1967  break;
1968  }
1969  if ((fDimension==2) && (parm1>=kOptions1D) &&(parm1<kOptions2D)) {
1970  Warning("ProcessMessage", "1D drawing options not apply to 2D histograms.");
1971  break;
1972  }
1973  // make composed option
1974  MapOptions(parm1);
1975  break;
1976  }
1977  switch (parm1) {
1978  case kFileCanvas:
1979  gROOT->MakeDefCanvas();
1980  break;
1981  case kFileBrowse:
1982  if (1) {
1983  static TString dir(".");
1984  TGFileInfo info;
1985  info.fFileTypes = gOpenTypes;
1986  info.fIniDir = StrDup(dir);
1987  new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
1988  if (!info.fFilename) return kTRUE;
1989  dir = info.fIniDir;
1990  TString command = TString::Format("tv__tree_file = new TFile(\"%s\");",
1991  gSystem->UnixPathName(info.fFilename));
1992  ExecuteCommand(command.Data());
1993  ExecuteCommand("tv__tree_file->ls();");
1994  std::cout << "Use SetTreeName() from context menu and supply a tree name" << std::endl;
1995  std::cout << "The context menu is activated by right-clicking the panel from right" << std::endl;
1996  }
1997  break;
1998  case kFileLoadLibrary:
1999  fBarCommand->SetText("gSystem->Load(\"\");");
2000  if (1) {
2001  Event_t event;
2002  event.fType = kButtonPress;
2003  event.fCode = kButton1;
2004  event.fX = event.fY = 1;
2005  fBarCommand->HandleButton(&event);
2006  }
2008  break;
2009  case kFileOpenSession:
2010  if (1) {
2011  static TString dir(".");
2012  TGFileInfo info;
2013  info.fFileTypes = gMacroTypes;
2014  info.fIniDir = StrDup(dir);
2015  new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
2016  if (!info.fFilename) return kTRUE;
2017  dir = info.fIniDir;
2018  gInterpreter->Reset();
2019  if (!gInterpreter->IsLoaded(info.fFilename)) gInterpreter->LoadMacro(info.fFilename);
2020  char command[1024];
2021  command[0] = 0;
2022  snprintf(command,1024,"open_session((void*)0x%lx);", (Long_t)this);
2023  ExecuteCommand(command);
2024  }
2025  break;
2026  case kFileSaveMacro:
2027  SaveSource();
2028  break;
2029  case kFilePrint:
2030  break;
2031  case kFileClose:
2032  SendCloseMessage();
2033  break;
2034  case kFileQuit:
2035  gApplication->Terminate(0);
2036  break;
2037  case kEditExpression:
2038  EditExpression();
2039  break;
2040  case kEditCut:
2041  EditExpression();
2042  break;
2043  case kEditMacro:
2044  break;
2045  case kEditEvent:
2046  break;
2047  case kRunMacro:
2048  break;
2049  case kHelpAbout:
2050  {
2051 #ifdef R__UNIX
2052  TString rootx;
2053 # ifdef ROOTBINDIR
2054  rootx = ROOTBINDIR;
2055 # else
2056  rootx = gSystem->Getenv("ROOTSYS");
2057  if (!rootx.IsNull()) rootx += "/bin";
2058 # endif
2059  rootx += "/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);
2087  hd->SetText(gTVHelpLayout);
2088  hd->Popup();
2089  break;
2090  case kHelpOpenSave:
2091  hd = new TRootHelpDialog(this, "Open/Save...", 600, 400);
2092  hd->SetText(gTVHelpOpenSave);
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);
2107  hd->SetText(gTVHelpSession);
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);
2117  hd->SetText(gTVHelpContext);
2118  hd->Popup();
2119  break;
2120  case kHelpDrawing:
2121  hd = new TRootHelpDialog(this, "Drawing histograms...", 600, 400);
2122  hd->SetText(gTVHelpDrawing);
2123  hd->Popup();
2124  break;
2125  case kHelpMacros:
2126  hd = new TRootHelpDialog(this, "Using macros...", 600, 400);
2127  hd->SetText(gTVHelpMacros);
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("[]")) {
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
2254  EditExpression();
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 
2303 void 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++)
2337  fOptionsGen->UnCheckEntry(ind);
2338  for (ind=kOptions1D; ind<kOptions1D+12; ind++)
2339  fOptions1D->UnCheckEntry(ind);
2340  for (ind=kOptions2D; ind<kOptions2D+14; ind++)
2341  fOptions2D->UnCheckEntry(ind);
2342  }
2343  if ((parm1 < kOptions1D) && (parm1 != kOptionsReset)) {
2344  if (fOptionsGen->IsEntryChecked((Int_t)parm1)) {
2345  fOptionsGen->UnCheckEntry((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++) {
2353  fOptionsGen->UnCheckEntry(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++) {
2368  fOptions1D->UnCheckEntry(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++) {
2383  fOptions2D->UnCheckEntry(ind);
2384  }
2385  }
2386  }
2387  // concatenate options
2388  fBarOption->SetText("");
2389  for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++) {
2390  if (fOptionsGen->IsEntryChecked(ind))
2391  fBarOption->AppendText(gOptgen[ind-kOptionsGeneral]);
2392  }
2393  if (Dimension() == 1) {
2394  for (ind=kOptions1D; ind<kOptions1D+12; ind++) {
2395  if (fOptions1D->IsEntryChecked(ind))
2396  fBarOption->AppendText(gOpt1D[ind-kOptions1D]);
2397  }
2398  }
2399  if (Dimension() == 2) {
2400  for (ind=kOptions2D; ind<kOptions2D+14; ind++) {
2401  if (fOptions2D->IsEntryChecked(ind))
2402  fBarOption->AppendText(gOpt2D[ind-kOptions2D]);
2403  }
2404  }
2405 }
2406 
2407 ////////////////////////////////////////////////////////////////////////////////
2408 /// Map current tree and expand its content (including friends) in the lists.
2409 
2410 void 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);
2425  fStopMapping = kFALSE;
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);
2442  fStopMapping = kFALSE;
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 
2456 void 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) name = Form("%s.%s",prefix,branch->GetName());
2461  else name = branch->GetName();
2462  Int_t ind;
2463  TGListTreeItem *branchItem = 0;
2464  ULong_t *itemType;
2465  // map this branch
2466  if (name.Contains("fBits") || name.Contains("fUniqueID")) return;
2467  if (parent) {
2468  // make list tree items for each branch according to the type
2469  const TGPicture *pic, *spic;
2470  if ((branch->GetListOfBranches()->GetEntries()) ||
2471  (branch->GetNleaves())) {
2472  if (branch->GetListOfBranches()->GetEntries()) {
2473  itemType = new ULong_t(kLTBranchType);
2474  if (branch->InheritsFrom("TBranchObject")) {
2475  pic = gClient->GetPicture("branch-ob_t.xpm");
2476  spic = gClient->GetPicture("branch-ob_t.xpm");
2477  } else {
2478  if (branch->InheritsFrom("TBranchClones")) {
2479  pic = gClient->GetPicture("branch-cl_t.xpm");
2480  spic = gClient->GetPicture("branch-cl_t.xpm");
2481  } else {
2482  pic = gClient->GetPicture("branch_t.xpm");
2483  spic = gClient->GetPicture("branch_t.xpm");
2484  }
2485  }
2486  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2487  } else {
2488  if (branch->GetNleaves() > 1) {
2489  itemType = new ULong_t(kLTBranchType);
2490  pic = gClient->GetPicture("branch_t.xpm");
2491  spic = gClient->GetPicture("branch_t.xpm");
2492  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType,pic, spic);
2493  TObjArray *leaves = branch->GetListOfLeaves();
2494  TLeaf *leaf = 0;
2495  TString leafName;
2496  for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2497  leaf = (TLeaf *)leaves->At(lf);
2498  leafName = name;
2499  leafName.Append(".").Append(EmptyBrackets(leaf->GetName()));
2500  itemType = new ULong_t(kLTLeafType);
2501  pic = gClient->GetPicture("leaf_t.xpm");
2502  spic = gClient->GetPicture("leaf_t.xpm");
2503  fLt->AddItem(branchItem, leafName.Data(), itemType, pic, spic);
2504  }
2505  } else {
2506  itemType = new ULong_t(kLTLeafType);
2507  pic = gClient->GetPicture("leaf_t.xpm");
2508  spic = gClient->GetPicture("leaf_t.xpm");
2509  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2510  }
2511  }
2512  }
2513  }
2514  // list branch in list view if necessary
2515  if (listIt) {
2516  TGString *textEntry = 0;
2517  const TGPicture *pic, *spic;
2518  TTVLVEntry *entry;
2519  // make list view items in the right frame
2520  if (!fStopMapping) {
2521  fMappedBranch = branch;
2522  fMappedTree = 0;
2523  fStopMapping = kTRUE;
2524  }
2525  if ((branch->GetListOfBranches()->GetEntries()) ||
2526  (branch->GetNleaves())) {
2527  textEntry = new TGString(EmptyBrackets(name.Data()));
2528  if (branch->GetListOfBranches()->GetEntries()) {
2529  if (branch->InheritsFrom("TBranchObject")) {
2530  pic = gClient->GetPicture("branch-ob_t.xpm");
2531  spic = gClient->GetPicture("branch-ob_t.xpm");
2532  } else {
2533  if (branch->InheritsFrom("TBranchClones")) {
2534  pic = gClient->GetPicture("branch-cl_t.xpm");
2535  spic = gClient->GetPicture("branch-cl_t.xpm");
2536  } else {
2537  pic = gClient->GetPicture("branch_t.xpm");
2538  spic = gClient->GetPicture("branch_t.xpm");
2539  }
2540  }
2541  entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,0,kLVSmallIcons);
2542  entry->SetUserData(new UInt_t(kLTBranchType));
2543  entry->SetToolTipText("Branch with sub-branches. Can not be dragged");
2544  fLVContainer->AddThisItem(entry);
2545  entry->MapWindow();
2546  entry->SetAlias(textEntry->GetString());
2547  } else {
2548  if (branch->GetNleaves() > 1) {
2549  if (textEntry) delete textEntry;
2550  textEntry = new TGString(EmptyBrackets(name.Data()));
2551  pic = gClient->GetPicture("branch_t.xpm");
2552  spic = gClient->GetPicture("branch_t.xpm");
2553  entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,0,kLVSmallIcons);
2554  entry->SetUserData(new UInt_t(kLTBranchType));
2555  entry->SetToolTipText("Branch with more than one leaf. Can not be dragged");
2556  fLVContainer->AddThisItem(entry);
2557  entry->MapWindow();
2558  entry->SetAlias(textEntry->GetString());
2559 
2560  TObjArray *leaves = branch->GetListOfLeaves();
2561  TLeaf *leaf = 0;
2562  TString leafName;
2563  for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2564  leaf = (TLeaf *)leaves->At(lf);
2565  leafName = name;
2566  leafName.Append(".").Append(EmptyBrackets(leaf->GetName()));
2567  textEntry = new TGString(leafName.Data());
2568  pic = gClient->GetPicture("leaf_t.xpm");
2569  spic = gClient->GetPicture("leaf_t.xpm");
2570  entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,0,kLVSmallIcons);
2571  entry->SetUserData(new UInt_t(kLTDragType | kLTLeafType));
2572  entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2573  fLVContainer->AddThisItem(entry);
2574  entry->MapWindow();
2575  entry->SetAlias(textEntry->GetString());
2576  }
2577  } else {
2578  pic = (gClient->GetMimeTypeList())->GetIcon("TLeaf",kFALSE);
2579  if (!pic) pic = gClient->GetPicture("leaf_t.xpm");
2580  spic = gClient->GetMimeTypeList()->GetIcon("TLeaf",kTRUE);
2581  if (!spic) spic = gClient->GetPicture("leaf_t.xpm");
2582  entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,0,kLVSmallIcons);
2583  entry->SetUserData(new UInt_t(kLTDragType | kLTLeafType));
2584  entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2585  fLVContainer->AddThisItem(entry);
2586  entry->MapWindow();
2587  entry->SetAlias(textEntry->GetString());
2588  }
2589  }
2590  }
2591  }
2592 
2593  TObjArray *branches = branch->GetListOfBranches();
2594  TBranch *branchDaughter = 0;
2595 
2596  // loop all sub-branches
2597  for (ind=0; ind<branches->GetEntries(); ind++) {
2598  branchDaughter = (TBranch *)branches->UncheckedAt(ind);
2599  // map also all sub-branches
2600  MapBranch(branchDaughter, "", branchItem, listIt);
2601  }
2602 }
2603 
2604 ////////////////////////////////////////////////////////////////////////////////
2605 /// Create new expression
2606 
2608 {
2610  const TGPicture *pic = gClient->GetPicture("expression_t.xpm");
2611  const TGPicture *spic = gClient->GetPicture("expression_t.xpm");
2612 
2613  TTVLVEntry *entry = new TTVLVEntry(fLVContainer,pic,spic,
2614  new TGString(),0,kLVSmallIcons);
2616  fLVContainer->AddThisItem(entry);
2617  entry->MapWindow();
2618  entry->Empty();
2619  if (fMappedTree) MapTree(fTree);
2621  fListView->Layout();
2622  fNexpressions++;
2623 }
2624 
2625 ////////////////////////////////////////////////////////////////////////////////
2626 /// Find parent tree of a clicked item.
2627 
2629 {
2630  if (!item) return;
2631  ULong_t *itemType = (ULong_t *)item->GetUserData();
2632  if (!itemType) return;
2633  TGListTreeItem *parent = 0;
2634  Int_t index;
2635  if (!(*itemType & kLTTreeType)) {
2636  parent = item->GetParent();
2637  SetParentTree(parent);
2638  } else {
2639  index = (Int_t)(*itemType >> 8);
2640  SwitchTree(index);
2641  }
2642 }
2643 
2644 ////////////////////////////////////////////////////////////////////////////////
2645 /// Send a message on the status bar.
2646 
2647 void TTreeViewer::Message(const char* msg)
2648 {
2649  fStatusBar->SetText(msg);
2650 }
2651 
2652 ////////////////////////////////////////////////////////////////////////////////
2653 /// Put error/warning into TMsgBox and also forward to console.
2654 
2655 void TTreeViewer::DoError(int level, const char *location, const char *fmt, va_list va) const
2656 {
2657  TObject::DoError(level, location, fmt, va);
2658 
2659  // in case level will abort we will not come here...
2660 
2661  static const int buf_size = 2048;
2662  char buf[buf_size], *bp;
2663 
2664  int n = vsnprintf(buf, buf_size, fmt, va);
2665  // old vsnprintf's return -1 if string is truncated new ones return
2666  // total number of characters that would have been written
2667  if (n == -1 || n >= buf_size) {
2668  TObject::Warning("DoError", "Error message string truncated...");
2669  }
2670  if (level >= kSysError && level < kFatal)
2671  bp = Form("%s (%s)", buf, gSystem->GetError());
2672  else
2673  bp = buf;
2674 
2675  const char *title = "";
2676  if (level == kInfo)
2677  title = "Info";
2678  if (level == kWarning)
2679  title = "Warning";
2680  if (level == kError)
2681  title = "Error";
2682  if (level == kSysError)
2683  title = "System Error";
2684 
2685  new TGMsgBox(fClient->GetRoot(), this, title, bp, kMBIconExclamation);
2686 }
2687 
2688 ////////////////////////////////////////////////////////////////////////////////
2689 /// Print the number of selected entries on status-bar.
2690 
2692 {
2693  if (!fTree) return;
2694  char * msg = new char[100];
2695  snprintf(msg,100, "First entry : %lld Last entry : %lld",
2697  Message(msg);
2698  delete[] msg;
2699 }
2700 
2701 ////////////////////////////////////////////////////////////////////////////////
2702 /// Save current session as a C++ macro file.
2703 
2705 {
2706  if (!fTree) return;
2707  char quote = '"';
2708  std::ofstream out;
2709  Int_t lenfile = strlen(filename);
2710  char * fname;
2711  if (!lenfile) {
2712  fname = (char*)fSourceFile;
2713  lenfile = strlen(fname);
2714  } else {
2715  fname = (char*)filename;
2717  }
2718  // if filename is given, open this file, otherwise create a file
2719  // with a name : treeviewer.C
2720  if (lenfile) {
2721  out.open(fname, std::ios::out);
2722  } else {
2723  fname = new char[13];
2724  strlcpy(fname, "treeviewer.C",13);
2725  out.open(fname, std::ios::out);
2726  }
2727  if (!out.good ()) {
2728  printf("SaveSource cannot open file : %s\n", fname);
2729  fSourceFile = "treeviewer.C";
2730  if (!lenfile) delete [] fname;
2731  return;
2732  }
2733  // Write macro header and date/time stamp
2734  TDatime t;
2735  TString sname(fname);
2736  sname = sname.ReplaceAll(".C", "");
2737  out <<"void "<<sname.Data()<<"() {"<<std::endl;
2738  out <<"//=========Macro generated by ROOT version"<<gROOT->GetVersion()<<std::endl;
2739  out <<"//=========for tree "<<quote<<fTree->GetName()<<quote<<" ("<<t.AsString()<<")"<<std::endl;
2740  out <<"//===This macro can be opened from a TreeViewer session after loading"<<std::endl;
2741  out <<"//===the corresponding tree, or by running root with the macro name argument"<<std::endl<<std::endl;
2742  out <<" open_session();"<<std::endl;
2743  out <<"}"<<std::endl<<std::endl;
2744  out <<"open_session(void *p = 0) {"<<std::endl;
2745  out <<" gSystem->Load("<<quote<<"libTreeViewer"<<quote<<");"<<std::endl;
2746  out <<" TTreeViewer *treeview = (TTreeViewer *) p;"<<std::endl;
2747  out <<" if (!treeview) treeview = new TTreeViewer();"<<std::endl;
2748  out <<" TTree *tv_tree = (TTree*)gROOT->FindObject("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2749  out <<" TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("<<quote<<fFilename<<quote<<");"<<std::endl;
2750  out <<" if (!tv_tree) {"<<std::endl;
2751  out <<" if (!tv_file) tv_file = new TFile("<<quote<<fFilename<<quote<<");"<<std::endl;
2752  out <<" if (tv_file) tv_tree = (TTree*)tv_file->Get("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2753  out <<" if(!tv_tree) {"<<std::endl;
2754  out <<" printf(\"Tree %s not found\", fTree->GetName());"<<std::endl;
2755  out <<" return;"<<std::endl;
2756  out <<" }"<<std::endl;
2757  out <<" }"<<std::endl<<std::endl;
2758  out <<" treeview->SetTreeName("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2759  out <<" treeview->SetNexpressions("<<fNexpressions<<");"<<std::endl;
2760  // get expressions
2761  TTVLVEntry *item;
2762  out <<"// Set expressions on axis and cut"<<std::endl;
2763  out <<" TTVLVEntry *item;"<<std::endl;
2764  for (Int_t i=0; i<4; i++) {
2765  switch (i) {
2766  case 0:
2767  out <<"// X expression"<<std::endl;
2768  break;
2769  case 1:
2770  out <<"// Y expression"<<std::endl;
2771  break;
2772  case 2:
2773  out <<"// Z expression"<<std::endl;
2774  break;
2775  case 3:
2776  out <<"// Cut expression"<<std::endl;
2777  break;
2778  default:
2779  break;
2780  }
2781  item = ExpressionItem(i);
2782  out <<" item = treeview->ExpressionItem("<<i<<");"<<std::endl;
2783  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2784  <<", "<<quote<<item->GetAlias()<<quote<<");"<<std::endl;
2785  }
2786  out <<"// Scan list"<<std::endl;
2787  item = ExpressionItem(4);
2788  out <<" item = treeview->ExpressionItem(4);"<<std::endl;
2789  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2790  <<", "<<quote<<"Scan box"<<quote<<");"<<std::endl;
2791  out <<"// User defined expressions"<<std::endl;
2792  TString itemType;
2793  for (Int_t crt=5; crt<fNexpressions+5; crt++) {
2794  item = ExpressionItem(crt);
2795  if (item->IsCut())
2796  itemType = "kTRUE";
2797  else
2798  itemType = "kFALSE";
2799  out <<" item = treeview->ExpressionItem("<<crt<<");"<<std::endl;
2800  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2801  <<", "<<quote<<item->GetAlias()<<quote<<", "<<itemType.Data()<<");"<<std::endl;
2802  }
2803  fSession->SaveSource(out);
2804  out <<"}"<<std::endl;
2805  out.close();
2806  printf("C++ Macro file: %s has been generated\n", fname);
2807  if (!lenfile) delete [] fname;
2808 }
2809 
2810 ////////////////////////////////////////////////////////////////////////////////
2811 /// Makes current the tree at a given index in the list.
2812 
2814 {
2815  TTree *tree = (TTree *) fTreeList->At(index);
2816  if (!tree) {
2817  Warning("SwitchTree", "No tree found.");
2818  return kFALSE;
2819  }
2820  if ((tree == fTree) && (tree == fMappedTree)) return kFALSE; // nothing to switch
2821  std::string command;
2822  if (tree != fTree) {
2823  command = "tv__tree = (TTree *) tv__tree_list->At";
2824  command += Form("(%i)",index);
2825  ExecuteCommand(command.c_str());
2826  }
2827 
2828  fTree = tree;
2829  fSlider->SetRange(0,fTree->GetEntries()-1);
2831  command = "Current Tree : ";
2832  command += fTree->GetName();
2833  fLbl2->SetText(new TGString(command.c_str()));
2834  fTreeHdr->Layout();
2835  MapSubwindows();
2837  MapWindow();
2838  ///Resize(); //ia
2839  PrintEntries();
2840  return kTRUE;
2841 }
2842 
2843 ////////////////////////////////////////////////////////////////////////////////
2844 /// Set record name
2845 
2847 {
2848  fSession->SetRecordName(name);
2849 }
2850 
2851 ////////////////////////////////////////////////////////////////////////////////
2852 /// Set current record
2853 
2855 {
2856  fCombo->Select(entry);
2857 }
2858 
2859 ////////////////////////////////////////////////////////////////////////////////
2860 /// Set title of Histogram
2861 
2862 void TTreeViewer::SetHistogramTitle(const char *title)
2863 {
2864  if (!gPad) return;
2865  TH1 *hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
2866  if (hist) {
2867  hist->SetTitle(title);
2868  gPad->Update();
2869  }
2870 }
2871 
2872 ////////////////////////////////////////////////////////////////////////////////
2873 /// user defined command for current record
2874 
2875 void TTreeViewer::SetUserCode(const char *code, Bool_t autoexec)
2876 {
2877  TTVRecord *rec = fSession->GetCurrent();
2878  if (rec) rec->SetUserCode(code, autoexec);
2879 }
2880 
2881 ////////////////////////////////////////////////////////////////////////////////
2882 /// Updates combo box to current session entries.
2883 
2885 {
2886  TTVRecord *record;
2887  fCombo->RemoveEntries(0, 1000);
2888  for (Long64_t entry=0; entry<fSession->GetEntries(); entry++) {
2889  if ((record = fSession->GetRecord(entry)))
2890  fCombo->AddEntry(record->GetName(), entry);
2891  }
2892 }
2893 
2894 ////////////////////////////////////////////////////////////////////////////////
2895 /// Updates current record to new X, Y, Z items.
2896 
2898 {
2899  fSession->UpdateRecord(name);
2900 }
2901 
2902 ////////////////////////////////////////////////////////////////////////////////
2903 /// This slot is called when button REFR is clicked
2904 
2906 {
2907  fTree->Refresh();
2910  fSlider->SetRange(min,max);
2911  fSlider->SetPosition(min,max);
2912  ExecuteDraw();
2913 }
TGTextButton * fSPIDER
Definition: TTreeViewer.h:147
TTVRecord * First()
Definition: TTVSession.h:90
void InsertText(const char *text)
Insert text in text entry.
const char * Ey()
Return the expression on Y.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:37
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
const char * GetTrueName()
TGPictureButton * fBGPrevious
Definition: TTreeViewer.h:153
TGPictureButton * fSTOP
Definition: TTreeViewer.h:148
void Empty()
Clear all names and alias.
An array of TObjects.
Definition: TObjArray.h:39
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other commands generated.
void Empty()
Empty the content of the selected expression.
TTVSession * fSession
Definition: TTreeViewer.h:81
virtual const TGFrame * GetNextSelected(void **current)
Return the next selected item.
Definition: TGCanvas.cxx:678
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:404
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
void SetNexpressions(Int_t expr)
Change the number of expression widgets.
Int_t fNexpressions
Definition: TTreeViewer.h:103
const char * GetAlias()
virtual void * GetUserData() const =0
long long Long64_t
Definition: RtypesCore.h:69
TGCheckButton * fBarH
Definition: TTreeViewer.h:124
virtual void RemoveAll()
Remove all items from the container.
Definition: TGCanvas.cxx:638
const char * ScanList()
Return the cut entry.
TGPictureButton * fBGRecord
Definition: TTreeViewer.h:154
TTVRecord * Previous()
Definition: TTVSession.h:93
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
void Reset()
Reset the timer.
Definition: TTimer.cxx:155
virtual Int_t NumSelected() const
Definition: TGCanvas.h:116
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
void ExecuteDraw()
Called when the DRAW button is executed.
static const char * gOpt1D[12]
TGLayoutHints * fBarLayout
Definition: TTreeViewer.h:119
Collectable string class.
Definition: TObjString.h:32
float Float_t
Definition: RtypesCore.h:53
const TGPicture * fPicRefr
Definition: TTreeViewer.h:96
void SetRecordName(const char *name)
Set record name.
const char Option_t
Definition: RtypesCore.h:62
virtual Long64_t GetReadEntry() const
Definition: TTree.h:424
TTVLVEntry * EditedEntry()
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
void NewExpression()
Create new expression.
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
void PrintEntries()
Print the number of selected entries on status-bar.
REAL splitter
Definition: triangle.c:616
#define gDirectory
Definition: TDirectory.h:218
TGLabel * fLbl2
Definition: TTreeViewer.h:138
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
UInt_t GetWidth() const
Definition: TGFrame.h:287
void Draw3DCorner(Bool_t corner)
Definition: TGStatusBar.h:69
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1714
virtual void SetFrame(TGFrame *frame, Bool_t left)
Set frame to be resized.
Definition: TGSplitter.cxx:140
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
TGMenuBar * fMenuBar
Definition: TTreeViewer.h:108
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1101
void SetUserCode(const char *code, Bool_t autoexec=kTRUE)
user defined command for current record
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1835
void UpdateCombo()
Updates combo box to current session entries.
virtual void SetContainer(TGFrame *f)
Definition: TGCanvas.h:234
void SetListView(TGListView *lv)
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1797
static const char * filename()
const char * Ex()
Get the expression to be drawn on X axis.
#define gROOT
Definition: TROOT.h:340
void DoRefresh()
This slot is called when button REFR is clicked.
void ActivateButtons(Bool_t first, Bool_t previous, Bool_t next, Bool_t last)
Enable/disable session buttons.
void SetParentTree(TGListTreeItem *item)
Find parent tree of a clicked item.
TGHorizontalFrame * fBFrame
Definition: TTreeViewer.h:139
virtual void Associate(const TGWindow *w)
Definition: TGCanvas.h:101
TGLabel * fBarLbl2
Definition: TTreeViewer.h:122
Basic string class.
Definition: TString.h:137
#define gClient
Definition: TGClient.h:174
void SetTrueName(const char *name)
void SetTreeName(const char *treeName)
Allow geting the tree from the context menu.
TGPictureButton * fREFR
Definition: TTreeViewer.h:149
int Int_t
Definition: RtypesCore.h:41
ClassImp(TTreeViewer) TTreeViewer
TTreeViewer default constructor.
bool Bool_t
Definition: RtypesCore.h:59
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
const Bool_t kFALSE
Definition: Rtypes.h:92
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:987
TGHProgressBar * fProgressBar
Definition: TTreeViewer.h:141
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
#define gInterpreter
Definition: TInterpreter.h:502
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
const char * fFilename
Definition: TTreeViewer.h:82
void MapOptions(Long_t parm1)
Scan the selected options from option menu.
void SelectItem(const char *name)
Select an item.
virtual void SetRange(Float_t min, Float_t max)
TGCheckButton * fBarRec
Definition: TTreeViewer.h:126
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
Int_t MakeSelector(const char *selector=0)
Get use of TTree::MakeSelector() via the context menu.
const char * EmptyBrackets(const char *name)
Empty the bracket content of a string.
void EditExpression()
Start the expression editor.
R__EXTERN const char gTVHelpContext[]
Definition: HelpTextTV.h:27
void GrabPointer()
Just focus the cursor inside.
void Message(const char *msg)
Send a message on the status bar.
TGLabel * fBarLbl1
Definition: TTreeViewer.h:121
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:5653
TList * fTreeList
Definition: TTreeViewer.h:92
virtual void Layout()
Layout list view components (container and contents of container).
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:310
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1057
Int_t GetEntries()
Definition: TTVSession.h:87
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
TGLabel * fBLbl4
Definition: TTreeViewer.h:142
virtual void Refresh()
Refresh contents of this tree and its branches from the current status on disk.
Definition: TTree.cxx:7148
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1036
const TGPicture * fPicStop
Definition: TTreeViewer.h:95
void RemoveLastRecord()
Remove current record from list.
Definition: TTVSession.cxx:222
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
TContextMenu * fContextMenu
Definition: TTreeViewer.h:90
const char * ConvertAliases()
Convert all aliases into true names.
TTVRecord * Last()
Definition: TTVSession.h:91
TGPopupMenu * fFileMenu
Definition: TTreeViewer.h:109
TGItemContext * GetContext()
TGPopupMenu * fOptionsGen
Definition: TTreeViewer.h:113
EButtonIdentifiers
virtual TList * GetListOfFriends() const
Definition: TTree.h:407
const char * Data() const
Definition: TString.h:349
TGListTreeItem * GetParent() const
Definition: TGListTree.h:79
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
TGPictureButton * fBGNext
Definition: TTreeViewer.h:155
const char * fSourceFile
Definition: TTreeViewer.h:83
void SetCurrentRecord(Long64_t entry)
Set current record.
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
TGPopupMenu * fOptionsMenu
Definition: TTreeViewer.h:112
Sequenceable collection abstract base class.
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
virtual TObjArray * GetListOfBranches()
Definition: TTree.h:405
Bool_t SwitchTree(Int_t index)
Makes current the tree at a given index in the list.
void SaveSource(const char *filename="", Option_t *option="")
Save current session as a C++ macro file.
TStopwatch timer
Definition: pirndm.C:37
TGPopupMenu * fEditMenu
Definition: TTreeViewer.h:110
Double_t x[n]
Definition: legend1.C:17
const char * Cut()
Apply Cut.
TGListTree * fLt
Definition: TTreeViewer.h:160
TGComboBox * fCombo
Definition: TTreeViewer.h:151
Int_t Dimension()
Compute dimension of the histogram.
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:2334
void SetRecordName(const char *name)
Set record name.
Definition: TTVSession.cxx:209
const Int_t kSysError
Definition: TError.h:43
static const char * gMacroTypes[]
void SetUserCode(const char *code, Bool_t autoexec=kTRUE)
Definition: TTVSession.h:65
void ExecuteSpider()
Draw a spider plot for the selected entries.
static TGSelectBox * GetInstance()
Return the pointer to the instantiated singleton.
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
void DoError(int level, const char *location, const char *fmt, va_list va) const
Put error/warning into TMsgBox and also forward to console.
const char ** fFileTypes
Definition: TGFileDialog.h:65
TList * fWidgets
Definition: TTreeViewer.h:165
static const char * gOptgen[16]
Bool_t fCounting
Definition: TTreeViewer.h:100
const Int_t kFatal
Definition: TError.h:44
TTimer * fTimer
Definition: TTreeViewer.h:99
const char * GetText() const
Definition: TGTextEntry.h:140
virtual void AddThisItem(TTVLVEntry *item)
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:443
TGCompositeFrame(const TGCompositeFrame &)
TGToolBar * fToolBar
Definition: TTreeViewer.h:118
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1627
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:60
static const char * gOpt2D[14]
const Int_t kDoNotProcess
Definition: TBranch.h:52
TString & Append(const char *cs)
Definition: TString.h:492
std::vector< std::vector< double > > Data
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
const char * GetGrOpt()
Get graph option.
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:294
TObjArray * GetListOfBranches()
Definition: TBranch.h:177
void EmptyAll()
Clear all names and aliases for expression type items.
Bool_t HandleTimer(TTimer *timer)
This function is called by the fTimer object.
TString fLastOption
Definition: TTreeViewer.h:84
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text entry widget.
TGCompositeFrame * fListHdr
Definition: TTreeViewer.h:136
void SaveSource(std::ofstream &out)
Save the TTVSession in a C++ macro file.
Definition: TTVSession.cxx:253
Bool_t fVarDraw
Definition: TTreeViewer.h:88
TList * ExpressionList()
Get the list of expression items.
XFontStruct * id
Definition: TGX11.cxx:108
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
void RemoveNonStatic()
Remove all non-static items from the list view, except expressions.
TGTextEntry * fBarOption
Definition: TTreeViewer.h:128
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
const char * Ez()
Get the expression to be drawn on Z axis.
TGTextEntry * fBarCommand
Definition: TTreeViewer.h:127
R__EXTERN const char gTVHelpDrawing[]
Definition: HelpTextTV.h:28
TTVRecord * GetCurrent()
Definition: TTVSession.h:88
char * out
Definition: TBase64.cxx:29
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition: TGCanvas.cxx:657
static const char * gOpenTypes[]
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:8195
void SetTree(TTree *tree)
Assign the fTree member from existing tree, e.g.
A doubly linked list.
Definition: TList.h:47
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:4822
virtual TFile * GetFile() const
Definition: TDirectory.h:152
void SetLabel(const char *title)
Set label of selection box.
TH1 * GetHistogram()
Definition: TTree.h:398
TGListView * fListView
Definition: TTreeViewer.h:162
void SetFile()
Set file name containing the tree.
R__EXTERN const char gTVHelpStart[]
Definition: HelpTextTV.h:20
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:91
std::string trueName(const char *typeDefName)
TTVLVContainer * fLVContainer
Definition: TTreeViewer.h:163
TGTextButton * fReset
Definition: TTreeViewer.h:157
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
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:1135
void SetUserData(void *userData)
Definition: TGListView.h:118
TGHorizontalFrame * fHpb
Definition: TTreeViewer.h:140
virtual void SendCloseMessage()
Send close message to self.
Definition: TGFrame.cxx:1702
EMouseButton
Definition: GuiTypes.h:215
I/O classes for TreeViewer session handling.
Definition: TTVSession.h:30
const Int_t kInfo
Definition: TError.h:39
Class to manage histogram axis.
Definition: TAxis.h:36
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:387
Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0)
Get use of TTree::Process() via the context menu.
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:176
virtual EButtonState GetState() const
Definition: TGButton.h:116
Int_t GET_SUBMSG(Long_t val)
void SetScanFileName(const char *name="")
Set the name of the file where to redirect output.
TTVRecord * GetRecord(Int_t i)
Return record at index i.
Definition: TTVSession.cxx:186
TTVLVEntry * ExpressionItem(Int_t index)
Get the item from a specific position.
TDirectory * GetDirectory() const
Definition: TTree.h:381
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:389
This class represent entries that goes into the TreeViewer listview container.
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:227
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
ERootTreeViewerCommands
const TGPicture * fPicX
Definition: TTreeViewer.h:94
Cursor_t fDefaultCursor
Definition: TTreeViewer.h:97
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
void SetSession(TTVSession *session)
Set current session.
virtual const char * GetText() const =0
unsigned int UInt_t
Definition: RtypesCore.h:42
TGCanvas * fTreeView
Definition: TTreeViewer.h:159
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
The most important graphics class in the ROOT system.
Definition: TPad.h:46
TList * ExpressionList()
Return the list of user-defined expressions.
const char * Cut()
Return the cut entry.
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
Definition: TObject.cxx:879
char * Form(const char *fmt,...)
void ClearHighlighted()
Un highlight items.
Bool_t fStopMapping
Definition: TTreeViewer.h:101
virtual void TurnOff()
Remove timer from system timer list.
Definition: TTimer.cxx:227
void RemoveLastRecord()
Remove the current record.
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TGPictureButton * fBGLast
Definition: TTreeViewer.h:156
TAxis * GetYaxis()
Definition: TH1.h:320
const std::string sname
Definition: testIO.cxx:45
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:657
const Int_t kWarning
Definition: TError.h:40
TTree * fMappedTree
Definition: TTreeViewer.h:85
TTreeViewer(const char *treeName=0)
void SetHistogramTitle(const char *title)
Set title of Histogram.
Bool_t IsNull() const
Definition: TString.h:387
TGLayoutHints * fMenuBarHelpLayout
Definition: TTreeViewer.h:107
void ShowPosition(Bool_t set=kTRUE, Bool_t percent=kTRUE, const char *format="%.2f")
Show postion text, either in percent or formatted according format.
Long64_t entry
void SetToolTipText(const char *text, Long_t delayms=1000)
Set tool tip text associated with this item.
virtual ~TTreeViewer()
TTreeViewer destructor.
TString & String()
Definition: TObjString.h:52
Int_t fDimension
Definition: TTreeViewer.h:87
#define gVirtualX
Definition: TVirtualX.h:362
void RemoveItem()
Remove the selected item from the list.
void MapBranch(TBranch *branch, const char *prefix="", TGListTreeItem *parent=0, Bool_t listIt=kTRUE)
Map current branch and expand its content in the list view.
const TGPicture * fPicY
Definition: TTreeViewer.h:94
Cursor_t fWatchCursor
Definition: TTreeViewer.h:98
TTree * fTree
Definition: TTreeViewer.h:80
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2513
TGPictureButton * fBGFirst
Definition: TTreeViewer.h:152
Int_t GET_MSG(Long_t val)
R__EXTERN const char gTVHelpMacros[]
Definition: HelpTextTV.h:29
TGCheckButton * fBarScan
Definition: TTreeViewer.h:125
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:6706
TGLayoutHints * fMenuBarItemLayout
Definition: TTreeViewer.h:106
void SetAlias(const char *alias)
void SetViewer(TTreeViewer *viewer)
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:403
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
TGHorizontalFrame * fHf
Definition: TTreeViewer.h:131
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:309
virtual void CloseWindow()
Close the viewer.
TGTextEntry * fBarListOut
Definition: TTreeViewer.h:145
TGTextEntry * fBarHist
Definition: TTreeViewer.h:129
virtual const char * GetName() const
Returns name of object.
Definition: TTVSession.h:53
TGVerticalFrame * fV2
Definition: TTreeViewer.h:134
void UpdateRecord(const char *name="new name")
Updates current record to new X, Y, Z items.
const TGPicture * fPicDraw
Definition: TTreeViewer.h:95
virtual void SetCursorPosition(Int_t pos)
Set the cursor position to newPos.
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:108
R__EXTERN const char gTVHelpLayout[]
Definition: HelpTextTV.h:21
TGDoubleVSlider * fSlider
Definition: TTreeViewer.h:132
Describe directory structure in memory.
Definition: TDirectory.h:41
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:287
void SetPosition(Float_t pos)
Set progress position between [min,max].
void * GetUserData() const
Definition: TGListView.h:119
void SetSmallPic(const TGPicture *spic)
Set small picture.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
unsigned long ULong_t
Definition: RtypesCore.h:51
This class represent a specialized expression editor for TTVLVEntry 'true name' and 'alias' data memb...
char * fFilename
Definition: TGFileDialog.h:63
int nentries
Definition: THbookFile.cxx:89
Double_t y[n]
Definition: legend1.C:17
TGPopupMenu * fRunMenu
Definition: TTreeViewer.h:111
void AppendTree(TTree *tree)
Allow geting the tree from the context menu.
virtual void Draw(Option_t *options="")
Draw the spider.
Definition: TSpider.cxx:453
void BuildInterface()
Create all viewer widgets.
The TH1 histogram class.
Definition: TH1.h:80
virtual TTree * GetTree() const
Definition: TTree.h:432
void ExecuteCommand(const char *command, Bool_t fast=kFALSE)
Execute all user commands.
Int_t GetNleaves() const
Definition: TBranch.h:180
TObjArray * GetListOfLeaves()
Definition: TBranch.h:178
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:493
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
const char * En(Int_t n)
Get the n'th expression.
TGPopupMenu * fOptions2D
Definition: TTreeViewer.h:115
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
TGLabel * fLbl1
Definition: TTreeViewer.h:137
Bool_t fEnableCut
Definition: TTreeViewer.h:102
#define name(a, b)
Definition: linkTestLib0.cpp:5
void SetGrOpt(const char *option)
Set graph option.
TAxis * GetZaxis()
Definition: TH1.h:321
Mother of all ROOT objects.
Definition: TObject.h:58
void SetScanRedirect(Bool_t mode)
Set the state of Scan check button.
I/O classes for TreeViewer session handling.
Definition: TTVSession.h:71
void UpdateRecord(const char *name)
Updates current record according to new X, Y, Z settings.
Definition: TTVSession.cxx:270
char Char_t
Definition: RtypesCore.h:29
R__EXTERN const char gTVHelpAbout[]
Definition: HelpTextTV.h:19
virtual Int_t MakeSelector(const char *selector=0, Option_t *option="")
Generate skeleton selector class for this tree.
Definition: TTree.cxx:6161
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition: TGMenu.cxx:1772
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:254
virtual void SetHeight(UInt_t h)
Definition: TGFrame.h:310
Bool_t fScanMode
Definition: TTreeViewer.h:89
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Definition: TDirectory.cxx:433
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
TTVRecord * AddRecord(Bool_t fromFile=kFALSE)
Add a record.
Definition: TTVSession.cxx:159
TTVLVEntry * ExpressionItem(Int_t index)
Return the expression item at specific position.
virtual void MapWindow()
Definition: TGFrame.h:267
TGClient * fClient
Definition: TGObject.h:41
A TFriendElement TF describes a TTree object TF in a file.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
const char * Ey()
Get the expression to be drawn on Y axis.
void MapTree(TTree *tree, TGListTreeItem *parent=0, Bool_t listIt=kTRUE)
Map current tree and expand its content (including friends) in the lists.
const Int_t kError
Definition: TError.h:41
TGLabel * fBarLbl3
Definition: TTreeViewer.h:123
const char * Ez()
Return the expression on Z.
Spider class.
Definition: TSpider.h:52
virtual void SetPosition(Float_t min, Float_t max)
TGTextEntry * fBarListIn
Definition: TTreeViewer.h:144
TGLayoutHints * fMenuBarLayout
Definition: TTreeViewer.h:105
R__EXTERN const char gTVHelpUserCommands[]
Definition: HelpTextTV.h:26
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
#define gPad
Definition: TVirtualPad.h:288
virtual Float_t GetMinPosition() const
virtual void SetTimerInterval(Int_t msec=333)
Definition: TTree.h:548
TGPictureButton * fDRAW
Definition: TTreeViewer.h:146
Int_t fTreeIndex
Definition: TTreeViewer.h:93
virtual Long64_t GetEntries() const
Definition: TTree.h:382
A TTree object has a header with a name and a title.
Definition: TTree.h:94
TGVerticalFrame * fV1
Definition: TTreeViewer.h:133
const char * GetString() const
Definition: TGString.h:44
void EmptyAll()
Clear the content of all items in the list view.
TGSelectBox * fDialogBox
Definition: TTreeViewer.h:91
virtual Float_t GetMaxPosition() const
void Show(TTVRecord *rec)
Display record rec.
Definition: TTVSession.cxx:242
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:1149
const char * Ex()
Return the expression on X.
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
virtual void SetTitle(const char *title)
Change (i.e.
Definition: TH1.cxx:6268
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
R__EXTERN const char gTVHelpDraggingItems[]
Definition: HelpTextTV.h:23
R__EXTERN const char gTVHelpEditExpressions[]
Definition: HelpTextTV.h:24
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
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...
string message
Definition: ROOT.py:94
Bool_t IsCut()
const char * ScanList()
returns scanlist
TGCompositeFrame * fTreeHdr
Definition: TTreeViewer.h:135
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition: TTreePlayer.h:43
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
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...
A TTree is a list of TBranches.
Definition: TBranch.h:58
void HighlightItem(TGListTreeItem *item)
Highlight item.
void Clear(Option_t *option="")
Clears up the text entry.
TGPopupMenu * fHelpMenu
Definition: TTreeViewer.h:116
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:99
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Definition: TGComboBox.h:127
TObject * obj
Bool_t IsScanRedirected()
Return kTRUE if scan is redirected.
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:239
R__EXTERN const char gTVHelpSession[]
Definition: HelpTextTV.h:25
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
const TGPicture * fPicZ
Definition: TTreeViewer.h:94
TGStatusBar * fStatusBar
Definition: TTreeViewer.h:150
TTVRecord * Next()
Definition: TTVSession.h:92
const Int_t n
Definition: legend1.C:16
virtual void SetContainer(TGFrame *f)
Set list view container.
void SetFillType(EFillType type)
Set fill type.
TBranch * fMappedBranch
Definition: TTreeViewer.h:86
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition: TGMenu.cxx:415
TGPopupMenu * fOptions1D
Definition: TTreeViewer.h:114
TGLabel * fBLbl5
Definition: TTreeViewer.h:143
virtual const char * GetError()
Return system error string.
Definition: TSystem.cxx:254
void SetEntry(TTVLVEntry *entry)
Connect one entry.
TAxis * GetXaxis()
Definition: TH1.h:319
char * fIniDir
Definition: TGFileDialog.h:64
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39
virtual TObjArray * GetListOfLeaves()
Definition: TTree.h:406
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:229
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185
This class represent the list view container for the.
R__EXTERN const char gTVHelpOpenSave[]
Definition: HelpTextTV.h:22
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904