ROOT  6.06/08
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");
383  TIter next(fTreeList);
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");
512  TIter next(fTreeList);
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 = TROOT::GetBinDir() + "/root -a &";
2053  gSystem->Exec(rootx);
2054 #else
2055 #ifdef WIN32
2057 #else
2058  char str[32];
2059  snprintf(str,32, "About ROOT %s...", gROOT->GetVersion());
2060  hd = new TRootHelpDialog(this, str, 600, 400);
2061  hd->SetText(gHelpAbout);
2062  hd->Popup();
2063 #endif
2064 #endif
2065  }
2066  break;
2067  case kHelpAboutTV:
2068  hd = new TRootHelpDialog(this, "About TreeViewer...", 600, 400);
2069  hd->SetText(gTVHelpAbout);
2070  hd->Resize(hd->GetDefaultSize());
2071  hd->Popup();
2072  break;
2073  case kHelpStart:
2074  hd = new TRootHelpDialog(this, "Quick start...", 600, 400);
2075  hd->SetText(gTVHelpStart);
2076  hd->Popup();
2077  break;
2078  case kHelpLayout:
2079  hd = new TRootHelpDialog(this, "Layout...", 600, 400);
2080  hd->SetText(gTVHelpLayout);
2081  hd->Popup();
2082  break;
2083  case kHelpOpenSave:
2084  hd = new TRootHelpDialog(this, "Open/Save...", 600, 400);
2085  hd->SetText(gTVHelpOpenSave);
2086  hd->Popup();
2087  break;
2088  case kHelpDragging:
2089  hd = new TRootHelpDialog(this, "Dragging items...", 600, 400);
2091  hd->Popup();
2092  break;
2093  case kHelpEditing:
2094  hd = new TRootHelpDialog(this, "Editing expressions...", 600, 400);
2096  hd->Popup();
2097  break;
2098  case kHelpSession:
2099  hd = new TRootHelpDialog(this, "Session...", 600, 400);
2100  hd->SetText(gTVHelpSession);
2101  hd->Popup();
2102  break;
2103  case kHelpCommands:
2104  hd = new TRootHelpDialog(this, "Executing user commands...", 600, 400);
2106  hd->Popup();
2107  break;
2108  case kHelpContext:
2109  hd = new TRootHelpDialog(this, "Context menus...", 600, 400);
2110  hd->SetText(gTVHelpContext);
2111  hd->Popup();
2112  break;
2113  case kHelpDrawing:
2114  hd = new TRootHelpDialog(this, "Drawing histograms...", 600, 400);
2115  hd->SetText(gTVHelpDrawing);
2116  hd->Popup();
2117  break;
2118  case kHelpMacros:
2119  hd = new TRootHelpDialog(this, "Using macros...", 600, 400);
2120  hd->SetText(gTVHelpMacros);
2121  hd->Popup();
2122  break;
2123  default:
2124  break;
2125  }
2126  break;
2127  default:
2128  break;
2129  }
2130  break;
2131  case kC_CONTAINER:
2132  switch (GET_SUBMSG(msg)) {
2133  // handle messages sent from the listview (right panel)
2134  case kCT_SELCHANGED:
2135  break;
2136  case kCT_ITEMCLICK:
2137  // handle mouse messages
2138  switch (parm1) {
2139  case kButton1:
2140  if (fLVContainer->NumSelected()) {
2141  // get item that sent this
2142  void *p = 0;
2143  TTVLVEntry *item;
2144  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != 0) {
2145  const char* vname = item->GetTrueName();
2146  TString trueName(vname);
2147  if (trueName.Contains("[]")) {
2148  TIter next(fTree->GetListOfLeaves());
2149  TLeaf *leaf;
2150  while((leaf=(TLeaf*)next())) {
2151  if (!strcmp(vname, EmptyBrackets(leaf->GetName())))
2152  vname = leaf->GetName();
2153  }
2154  }
2155  char* msg2 = new char[2000];
2156  // get item type
2157  ULong_t *itemType = (ULong_t *) item->GetUserData();
2158  if (*itemType & kLTTreeType) {
2159  // X, Y or Z clicked
2160  char symbol = (char)((*itemType) >> 8);
2161  snprintf(msg2,2000, "%c expression : %s", symbol, vname);
2162  } else {
2163  if (*itemType & kLTCutType) {
2164  // scissors clicked
2165  snprintf(msg2,2000, "Cut : %s", vname);
2166  } else {
2167  if (*itemType & kLTPackType) {
2168  snprintf(msg2,2000, "Box : %s", vname);
2169  } else {
2170  if (*itemType & kLTExpressionType) {
2171  // expression clicked
2172  snprintf(msg2,2000, "Expression : %s", vname);
2173  } else {
2174  if (*itemType & kLTBranchType) {
2175  snprintf(msg2,2000, "Branch : %s", vname);
2176  } else {
2177  snprintf(msg2,2000, "Leaf : %s", vname);
2178  }
2179  }
2180  }
2181  }
2182  }
2183  // write who is responsable for this
2184  TString message = msg2;
2185  message = message(0,150);
2186  Message(msg2);
2187  delete[] msg2;
2188  // check if this should be pasted into the expression editor
2189  if ((*itemType & kLTBranchType) || (*itemType & kLTCutType)) break;
2191  if (!fDialogBox || !vname[0]) break;
2192  if (item == fDialogBox->EditedEntry()) break;
2193  // paste it
2194 // char first = (char) vname[0];
2195  TString insert(item->GetAlias());
2196 // if (first != '(') insert += "(";
2197 // insert += item->GetAlias();
2198 // if (first != '(') insert += ")";
2199 
2201  fDialogBox->InsertText(insert.Data());
2202  // put the cursor at the right position
2203  }
2204  }
2205  break;
2206  case kButton2:
2207  break;
2208  case kButton3:
2209  // activate general context menu
2210  if (fLVContainer->NumSelected()) {
2211  void *p = 0;
2212  Int_t x = (Int_t)(parm2 &0xffff);
2213  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2214  TTVLVEntry *item = 0;
2215  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != 0) {
2216  fContextMenu->Popup(x, y, item->GetContext());
2217  }
2218  } else { // empty click
2219  Int_t x = (Int_t)(parm2 &0xffff);
2220  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2221  fContextMenu->Popup(x, y, this);
2222  }
2223  break;
2224  default:
2225  break;
2226  }
2227  break;
2228  case kCT_ITEMDBLCLICK:
2229  switch (parm1) {
2230  case kButton1:
2231  if (fLVContainer->NumSelected()) {
2232  // get item that sent this
2233  void *p = 0;
2234  TTVLVEntry *item;
2235  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != 0) {
2236  // get item type
2237  ULong_t *itemType = (ULong_t *) item->GetUserData();
2238  if (!(*itemType & kLTCutType) && !(*itemType & kLTBranchType)
2239  && !(*itemType & kLTPackType)) {
2240  if (strlen(item->GetTrueName())) {
2241  fVarDraw = kTRUE;
2242  // draw on double-click
2243  ExecuteDraw();
2244  break;
2245  } else {
2246  // open expression in editor
2247  EditExpression();
2248  }
2249  }
2250  if (*itemType & kLTCutType) {
2252  if (fEnableCut) {
2253  item->SetSmallPic(gClient->GetPicture("cut_t.xpm"));
2254  } else {
2255  item->SetSmallPic(gClient->GetPicture("cut-disable_t.xpm"));
2256  }
2257  }
2258  if (*itemType & kLTPackType) {
2259  fScanMode = kTRUE;
2260  ExecuteDraw();
2261  }
2262  }
2263  }
2264  break;
2265  case kButton2:
2266  break;
2267  case kButton3:
2268  break;
2269  default:
2270  break;
2271  }
2272  break;
2273  case 4:
2274 // std::cout << "Dragging Item" << std::endl;
2275  default:
2276  break;
2277  }
2278  break;
2279  default:
2280  break;
2281  }
2282  return kTRUE;
2283 }
2284 
2285 ////////////////////////////////////////////////////////////////////////////////
2286 /// Close the viewer.
2287 
2289 {
2290  DeleteWindow();
2291 }
2292 
2293 ////////////////////////////////////////////////////////////////////////////////
2294 /// Execute all user commands.
2295 
2296 void TTreeViewer::ExecuteCommand(const char* command, Bool_t fast)
2297 {
2298  // Execute the command, write it to history file and echo it to output
2299  if (fBarRec->GetState() == kButtonDown) {
2300  // show the command on the command line
2301  //printf("%s\n", command);
2302  char comm[2000];
2303  comm[0] = 0;
2304  if (strlen(command) > 1999) {
2305  Warning("ExecuteCommand", "Command too long: aborting.");
2306  return;
2307  }
2308  snprintf(comm,2000, "%s", command);
2309  // print the command to history file
2310  Gl_histadd(comm);
2311  }
2312  // execute it
2313  if (fast) {
2314  gROOT->ProcessLineFast(command);
2315  } else {
2316  gROOT->ProcessLine(command);
2317  }
2318  // make sure that 'draw on double-click' flag is reset
2319  fVarDraw = kFALSE;
2320 }
2321 
2322 ////////////////////////////////////////////////////////////////////////////////
2323 /// Scan the selected options from option menu.
2324 
2326 {
2327  Int_t ind;
2328  if (parm1 == kOptionsReset) {
2329  for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++)
2330  fOptionsGen->UnCheckEntry(ind);
2331  for (ind=kOptions1D; ind<kOptions1D+12; ind++)
2332  fOptions1D->UnCheckEntry(ind);
2333  for (ind=kOptions2D; ind<kOptions2D+14; ind++)
2334  fOptions2D->UnCheckEntry(ind);
2335  }
2336  if ((parm1 < kOptions1D) && (parm1 != kOptionsReset)) {
2337  if (fOptionsGen->IsEntryChecked((Int_t)parm1)) {
2338  fOptionsGen->UnCheckEntry((Int_t)parm1);
2339  } else {
2340  fOptionsGen->CheckEntry((Int_t)parm1);
2342  }
2344  // uncheck all in this menu
2345  for (ind=kOptionsGeneral+1; ind<kOptionsGeneral+16; ind++) {
2346  fOptionsGen->UnCheckEntry(ind);
2347  }
2348  }
2349  }
2350 
2351  if ((parm1 < kOptions2D) && (parm1 >= kOptions1D)) {
2352  if (fOptions1D->IsEntryChecked((Int_t)parm1)) {
2353  fOptions1D->UnCheckEntry((Int_t)parm1);
2354  } else {
2355  fOptions1D->CheckEntry((Int_t)parm1);
2357  }
2359  // uncheck all in this menu
2360  for (ind=kOptions1D+1; ind<kOptions1D+12; ind++) {
2361  fOptions1D->UnCheckEntry(ind);
2362  }
2363  }
2364  }
2365 
2366  if (parm1 >= kOptions2D) {
2367  if (fOptions2D->IsEntryChecked((Int_t)parm1)) {
2368  fOptions2D->UnCheckEntry((Int_t)parm1);
2369  } else {
2370  fOptions2D->CheckEntry((Int_t)parm1);
2372  }
2374  // uncheck all in this menu
2375  for (ind=kOptions2D+1; ind<kOptions2D+14; ind++) {
2376  fOptions2D->UnCheckEntry(ind);
2377  }
2378  }
2379  }
2380  // concatenate options
2381  fBarOption->SetText("");
2382  for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++) {
2383  if (fOptionsGen->IsEntryChecked(ind))
2384  fBarOption->AppendText(gOptgen[ind-kOptionsGeneral]);
2385  }
2386  if (Dimension() == 1) {
2387  for (ind=kOptions1D; ind<kOptions1D+12; ind++) {
2388  if (fOptions1D->IsEntryChecked(ind))
2389  fBarOption->AppendText(gOpt1D[ind-kOptions1D]);
2390  }
2391  }
2392  if (Dimension() == 2) {
2393  for (ind=kOptions2D; ind<kOptions2D+14; ind++) {
2394  if (fOptions2D->IsEntryChecked(ind))
2395  fBarOption->AppendText(gOpt2D[ind-kOptions2D]);
2396  }
2397  }
2398 }
2399 
2400 ////////////////////////////////////////////////////////////////////////////////
2401 /// Map current tree and expand its content (including friends) in the lists.
2402 
2403 void TTreeViewer::MapTree(TTree *tree, TGListTreeItem *parent, Bool_t listIt)
2404 {
2405  if (!tree) return;
2406  TObjArray *branches = tree->GetListOfBranches();
2407  if (!branches) return; // A Chain with no underlying trees.
2408  TBranch *branch;
2409  // loop on branches
2410  Int_t id;
2411  for (id=0; id<branches->GetEntries(); id++) {
2412  branch = (TBranch *)branches->At(id);
2413  if (branch->TestBit(kDoNotProcess)) continue;
2414  TString name = branch->GetName();
2415  if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2416  // now map sub-branches
2417  MapBranch(branch, "", parent, listIt);
2418  fStopMapping = kFALSE;
2419  }
2420  //Map branches of friend Trees (if any)
2421  //Look at tree->GetTree() to insure we see both the friendss of a chain
2422  //and the friends of the chain members
2423  TIter nextf( tree->GetTree()->GetListOfFriends() );
2424  TFriendElement *fr;
2425  while ((fr = (TFriendElement*)nextf())) {
2426  TTree * t = fr->GetTree();
2427  branches = t->GetListOfBranches();
2428  for (id=0; id<branches->GetEntries(); id++) {
2429  branch = (TBranch *)branches->At(id);
2430  if (branch->TestBit(kDoNotProcess)) continue;
2431  TString name = branch->GetName();
2432  if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2433  // now map sub-branches
2434  MapBranch(branch, fr->GetName(), parent, listIt);
2435  fStopMapping = kFALSE;
2436  }
2437  }
2438 
2439  // tell who was last mapped
2440  if (listIt) {
2441  fMappedTree = tree;
2442  fMappedBranch = 0;
2443  }
2444 }
2445 
2446 ////////////////////////////////////////////////////////////////////////////////
2447 /// Map current branch and expand its content in the list view.
2448 
2449 void TTreeViewer::MapBranch(TBranch *branch, const char *prefix, TGListTreeItem *parent, Bool_t listIt)
2450 {
2451  if (!branch) return;
2452  TString name;
2453  if (prefix && strlen(prefix) >0) name = Form("%s.%s",prefix,branch->GetName());
2454  else name = branch->GetName();
2455  Int_t ind;
2456  TGListTreeItem *branchItem = 0;
2457  ULong_t *itemType;
2458  // map this branch
2459  if (name.Contains("fBits") || name.Contains("fUniqueID")) return;
2460  if (parent) {
2461  // make list tree items for each branch according to the type
2462  const TGPicture *pic, *spic;
2463  if ((branch->GetListOfBranches()->GetEntries()) ||
2464  (branch->GetNleaves())) {
2465  if (branch->GetListOfBranches()->GetEntries()) {
2466  itemType = new ULong_t(kLTBranchType);
2467  if (branch->InheritsFrom("TBranchObject")) {
2468  pic = gClient->GetPicture("branch-ob_t.xpm");
2469  spic = gClient->GetPicture("branch-ob_t.xpm");
2470  } else {
2471  if (branch->InheritsFrom("TBranchClones")) {
2472  pic = gClient->GetPicture("branch-cl_t.xpm");
2473  spic = gClient->GetPicture("branch-cl_t.xpm");
2474  } else {
2475  pic = gClient->GetPicture("branch_t.xpm");
2476  spic = gClient->GetPicture("branch_t.xpm");
2477  }
2478  }
2479  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2480  } else {
2481  if (branch->GetNleaves() > 1) {
2482  itemType = new ULong_t(kLTBranchType);
2483  pic = gClient->GetPicture("branch_t.xpm");
2484  spic = gClient->GetPicture("branch_t.xpm");
2485  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType,pic, spic);
2486  TObjArray *leaves = branch->GetListOfLeaves();
2487  TLeaf *leaf = 0;
2488  TString leafName;
2489  for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2490  leaf = (TLeaf *)leaves->At(lf);
2491  leafName = name;
2492  leafName.Append(".").Append(EmptyBrackets(leaf->GetName()));
2493  itemType = new ULong_t(kLTLeafType);
2494  pic = gClient->GetPicture("leaf_t.xpm");
2495  spic = gClient->GetPicture("leaf_t.xpm");
2496  fLt->AddItem(branchItem, leafName.Data(), itemType, pic, spic);
2497  }
2498  } else {
2499  itemType = new ULong_t(kLTLeafType);
2500  pic = gClient->GetPicture("leaf_t.xpm");
2501  spic = gClient->GetPicture("leaf_t.xpm");
2502  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2503  }
2504  }
2505  }
2506  }
2507  // list branch in list view if necessary
2508  if (listIt) {
2509  TGString *textEntry = 0;
2510  const TGPicture *pic, *spic;
2511  TTVLVEntry *entry;
2512  // make list view items in the right frame
2513  if (!fStopMapping) {
2514  fMappedBranch = branch;
2515  fMappedTree = 0;
2516  fStopMapping = kTRUE;
2517  }
2518  if ((branch->GetListOfBranches()->GetEntries()) ||
2519  (branch->GetNleaves())) {
2520  textEntry = new TGString(EmptyBrackets(name.Data()));
2521  if (branch->GetListOfBranches()->GetEntries()) {
2522  if (branch->InheritsFrom("TBranchObject")) {
2523  pic = gClient->GetPicture("branch-ob_t.xpm");
2524  spic = gClient->GetPicture("branch-ob_t.xpm");
2525  } else {
2526  if (branch->InheritsFrom("TBranchClones")) {
2527  pic = gClient->GetPicture("branch-cl_t.xpm");
2528  spic = gClient->GetPicture("branch-cl_t.xpm");
2529  } else {
2530  pic = gClient->GetPicture("branch_t.xpm");
2531  spic = gClient->GetPicture("branch_t.xpm");
2532  }
2533  }
2534  entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,0,kLVSmallIcons);
2535  entry->SetUserData(new UInt_t(kLTBranchType));
2536  entry->SetToolTipText("Branch with sub-branches. Can not be dragged");
2537  fLVContainer->AddThisItem(entry);
2538  entry->MapWindow();
2539  entry->SetAlias(textEntry->GetString());
2540  } else {
2541  if (branch->GetNleaves() > 1) {
2542  if (textEntry) delete textEntry;
2543  textEntry = new TGString(EmptyBrackets(name.Data()));
2544  pic = gClient->GetPicture("branch_t.xpm");
2545  spic = gClient->GetPicture("branch_t.xpm");
2546  entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,0,kLVSmallIcons);
2547  entry->SetUserData(new UInt_t(kLTBranchType));
2548  entry->SetToolTipText("Branch with more than one leaf. Can not be dragged");
2549  fLVContainer->AddThisItem(entry);
2550  entry->MapWindow();
2551  entry->SetAlias(textEntry->GetString());
2552 
2553  TObjArray *leaves = branch->GetListOfLeaves();
2554  TLeaf *leaf = 0;
2555  TString leafName;
2556  for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2557  leaf = (TLeaf *)leaves->At(lf);
2558  leafName = name;
2559  leafName.Append(".").Append(EmptyBrackets(leaf->GetName()));
2560  textEntry = new TGString(leafName.Data());
2561  pic = gClient->GetPicture("leaf_t.xpm");
2562  spic = gClient->GetPicture("leaf_t.xpm");
2563  entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,0,kLVSmallIcons);
2564  entry->SetUserData(new UInt_t(kLTDragType | kLTLeafType));
2565  entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2566  fLVContainer->AddThisItem(entry);
2567  entry->MapWindow();
2568  entry->SetAlias(textEntry->GetString());
2569  }
2570  } else {
2571  pic = (gClient->GetMimeTypeList())->GetIcon("TLeaf",kFALSE);
2572  if (!pic) pic = gClient->GetPicture("leaf_t.xpm");
2573  spic = gClient->GetMimeTypeList()->GetIcon("TLeaf",kTRUE);
2574  if (!spic) spic = gClient->GetPicture("leaf_t.xpm");
2575  entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,0,kLVSmallIcons);
2576  entry->SetUserData(new UInt_t(kLTDragType | kLTLeafType));
2577  entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2578  fLVContainer->AddThisItem(entry);
2579  entry->MapWindow();
2580  entry->SetAlias(textEntry->GetString());
2581  }
2582  }
2583  }
2584  }
2585 
2586  TObjArray *branches = branch->GetListOfBranches();
2587  TBranch *branchDaughter = 0;
2588 
2589  // loop all sub-branches
2590  for (ind=0; ind<branches->GetEntries(); ind++) {
2591  branchDaughter = (TBranch *)branches->UncheckedAt(ind);
2592  // map also all sub-branches
2593  MapBranch(branchDaughter, "", branchItem, listIt);
2594  }
2595 }
2596 
2597 ////////////////////////////////////////////////////////////////////////////////
2598 /// Create new expression
2599 
2601 {
2603  const TGPicture *pic = gClient->GetPicture("expression_t.xpm");
2604  const TGPicture *spic = gClient->GetPicture("expression_t.xpm");
2605 
2606  TTVLVEntry *entry = new TTVLVEntry(fLVContainer,pic,spic,
2607  new TGString(),0,kLVSmallIcons);
2609  fLVContainer->AddThisItem(entry);
2610  entry->MapWindow();
2611  entry->Empty();
2612  if (fMappedTree) MapTree(fTree);
2614  fListView->Layout();
2615  fNexpressions++;
2616 }
2617 
2618 ////////////////////////////////////////////////////////////////////////////////
2619 /// Find parent tree of a clicked item.
2620 
2622 {
2623  if (!item) return;
2624  ULong_t *itemType = (ULong_t *)item->GetUserData();
2625  if (!itemType) return;
2626  TGListTreeItem *parent = 0;
2627  Int_t index;
2628  if (!(*itemType & kLTTreeType)) {
2629  parent = item->GetParent();
2630  SetParentTree(parent);
2631  } else {
2632  index = (Int_t)(*itemType >> 8);
2633  SwitchTree(index);
2634  }
2635 }
2636 
2637 ////////////////////////////////////////////////////////////////////////////////
2638 /// Send a message on the status bar.
2639 
2640 void TTreeViewer::Message(const char* msg)
2641 {
2642  fStatusBar->SetText(msg);
2643 }
2644 
2645 ////////////////////////////////////////////////////////////////////////////////
2646 /// Put error/warning into TMsgBox and also forward to console.
2647 
2648 void TTreeViewer::DoError(int level, const char *location, const char *fmt, va_list va) const
2649 {
2650  TObject::DoError(level, location, fmt, va);
2651 
2652  // in case level will abort we will not come here...
2653 
2654  static const int buf_size = 2048;
2655  char buf[buf_size], *bp;
2656 
2657  int n = vsnprintf(buf, buf_size, fmt, va);
2658  // old vsnprintf's return -1 if string is truncated new ones return
2659  // total number of characters that would have been written
2660  if (n == -1 || n >= buf_size) {
2661  TObject::Warning("DoError", "Error message string truncated...");
2662  }
2663  if (level >= kSysError && level < kFatal)
2664  bp = Form("%s (%s)", buf, gSystem->GetError());
2665  else
2666  bp = buf;
2667 
2668  const char *title = "";
2669  if (level == kInfo)
2670  title = "Info";
2671  if (level == kWarning)
2672  title = "Warning";
2673  if (level == kError)
2674  title = "Error";
2675  if (level == kSysError)
2676  title = "System Error";
2677 
2678  new TGMsgBox(fClient->GetRoot(), this, title, bp, kMBIconExclamation);
2679 }
2680 
2681 ////////////////////////////////////////////////////////////////////////////////
2682 /// Print the number of selected entries on status-bar.
2683 
2685 {
2686  if (!fTree) return;
2687  char * msg = new char[100];
2688  snprintf(msg,100, "First entry : %lld Last entry : %lld",
2690  Message(msg);
2691  delete[] msg;
2692 }
2693 
2694 ////////////////////////////////////////////////////////////////////////////////
2695 /// Save current session as a C++ macro file.
2696 
2698 {
2699  if (!fTree) return;
2700  char quote = '"';
2701  std::ofstream out;
2702  Int_t lenfile = strlen(filename);
2703  char * fname;
2704  if (!lenfile) {
2705  fname = (char*)fSourceFile;
2706  lenfile = strlen(fname);
2707  } else {
2708  fname = (char*)filename;
2710  }
2711  // if filename is given, open this file, otherwise create a file
2712  // with a name : treeviewer.C
2713  if (lenfile) {
2714  out.open(fname, std::ios::out);
2715  } else {
2716  fname = new char[13];
2717  strlcpy(fname, "treeviewer.C",13);
2718  out.open(fname, std::ios::out);
2719  }
2720  if (!out.good ()) {
2721  printf("SaveSource cannot open file : %s\n", fname);
2722  fSourceFile = "treeviewer.C";
2723  if (!lenfile) delete [] fname;
2724  return;
2725  }
2726  // Write macro header and date/time stamp
2727  TDatime t;
2728  TString sname(fname);
2729  sname = sname.ReplaceAll(".C", "");
2730  out <<"void "<<sname.Data()<<"() {"<<std::endl;
2731  out <<"//=========Macro generated by ROOT version"<<gROOT->GetVersion()<<std::endl;
2732  out <<"//=========for tree "<<quote<<fTree->GetName()<<quote<<" ("<<t.AsString()<<")"<<std::endl;
2733  out <<"//===This macro can be opened from a TreeViewer session after loading"<<std::endl;
2734  out <<"//===the corresponding tree, or by running root with the macro name argument"<<std::endl<<std::endl;
2735  out <<" open_session();"<<std::endl;
2736  out <<"}"<<std::endl<<std::endl;
2737  out <<"open_session(void *p = 0) {"<<std::endl;
2738  out <<" gSystem->Load("<<quote<<"libTreeViewer"<<quote<<");"<<std::endl;
2739  out <<" TTreeViewer *treeview = (TTreeViewer *) p;"<<std::endl;
2740  out <<" if (!treeview) treeview = new TTreeViewer();"<<std::endl;
2741  out <<" TTree *tv_tree = (TTree*)gROOT->FindObject("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2742  out <<" TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("<<quote<<fFilename<<quote<<");"<<std::endl;
2743  out <<" if (!tv_tree) {"<<std::endl;
2744  out <<" if (!tv_file) tv_file = new TFile("<<quote<<fFilename<<quote<<");"<<std::endl;
2745  out <<" if (tv_file) tv_tree = (TTree*)tv_file->Get("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2746  out <<" if(!tv_tree) {"<<std::endl;
2747  out <<" printf(\"Tree %s not found\", fTree->GetName());"<<std::endl;
2748  out <<" return;"<<std::endl;
2749  out <<" }"<<std::endl;
2750  out <<" }"<<std::endl<<std::endl;
2751  out <<" treeview->SetTreeName("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2752  out <<" treeview->SetNexpressions("<<fNexpressions<<");"<<std::endl;
2753  // get expressions
2754  TTVLVEntry *item;
2755  out <<"// Set expressions on axis and cut"<<std::endl;
2756  out <<" TTVLVEntry *item;"<<std::endl;
2757  for (Int_t i=0; i<4; i++) {
2758  switch (i) {
2759  case 0:
2760  out <<"// X expression"<<std::endl;
2761  break;
2762  case 1:
2763  out <<"// Y expression"<<std::endl;
2764  break;
2765  case 2:
2766  out <<"// Z expression"<<std::endl;
2767  break;
2768  case 3:
2769  out <<"// Cut expression"<<std::endl;
2770  break;
2771  default:
2772  break;
2773  }
2774  item = ExpressionItem(i);
2775  out <<" item = treeview->ExpressionItem("<<i<<");"<<std::endl;
2776  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2777  <<", "<<quote<<item->GetAlias()<<quote<<");"<<std::endl;
2778  }
2779  out <<"// Scan list"<<std::endl;
2780  item = ExpressionItem(4);
2781  out <<" item = treeview->ExpressionItem(4);"<<std::endl;
2782  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2783  <<", "<<quote<<"Scan box"<<quote<<");"<<std::endl;
2784  out <<"// User defined expressions"<<std::endl;
2785  TString itemType;
2786  for (Int_t crt=5; crt<fNexpressions+5; crt++) {
2787  item = ExpressionItem(crt);
2788  if (item->IsCut())
2789  itemType = "kTRUE";
2790  else
2791  itemType = "kFALSE";
2792  out <<" item = treeview->ExpressionItem("<<crt<<");"<<std::endl;
2793  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2794  <<", "<<quote<<item->GetAlias()<<quote<<", "<<itemType.Data()<<");"<<std::endl;
2795  }
2796  fSession->SaveSource(out);
2797  out <<"}"<<std::endl;
2798  out.close();
2799  printf("C++ Macro file: %s has been generated\n", fname);
2800  if (!lenfile) delete [] fname;
2801 }
2802 
2803 ////////////////////////////////////////////////////////////////////////////////
2804 /// Makes current the tree at a given index in the list.
2805 
2807 {
2808  TTree *tree = (TTree *) fTreeList->At(index);
2809  if (!tree) {
2810  Warning("SwitchTree", "No tree found.");
2811  return kFALSE;
2812  }
2813  if ((tree == fTree) && (tree == fMappedTree)) return kFALSE; // nothing to switch
2814  std::string command;
2815  if (tree != fTree) {
2816  command = "tv__tree = (TTree *) tv__tree_list->At";
2817  command += Form("(%i)",index);
2818  ExecuteCommand(command.c_str());
2819  }
2820 
2821  fTree = tree;
2822  fSlider->SetRange(0,fTree->GetEntries()-1);
2823  fSlider->SetPosition(0,fTree->GetEntries()-1);
2824  command = "Current Tree : ";
2825  command += fTree->GetName();
2826  fLbl2->SetText(new TGString(command.c_str()));
2827  fTreeHdr->Layout();
2828  MapSubwindows();
2830  MapWindow();
2831  ///Resize(); //ia
2832  PrintEntries();
2833  return kTRUE;
2834 }
2835 
2836 ////////////////////////////////////////////////////////////////////////////////
2837 /// Set record name
2838 
2840 {
2841  fSession->SetRecordName(name);
2842 }
2843 
2844 ////////////////////////////////////////////////////////////////////////////////
2845 /// Set current record
2846 
2848 {
2849  fCombo->Select(entry);
2850 }
2851 
2852 ////////////////////////////////////////////////////////////////////////////////
2853 /// Set title of Histogram
2854 
2855 void TTreeViewer::SetHistogramTitle(const char *title)
2856 {
2857  if (!gPad) return;
2858  TH1 *hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
2859  if (hist) {
2860  hist->SetTitle(title);
2861  gPad->Update();
2862  }
2863 }
2864 
2865 ////////////////////////////////////////////////////////////////////////////////
2866 /// user defined command for current record
2867 
2868 void TTreeViewer::SetUserCode(const char *code, Bool_t autoexec)
2869 {
2870  TTVRecord *rec = fSession->GetCurrent();
2871  if (rec) rec->SetUserCode(code, autoexec);
2872 }
2873 
2874 ////////////////////////////////////////////////////////////////////////////////
2875 /// Updates combo box to current session entries.
2876 
2878 {
2879  TTVRecord *record;
2880  fCombo->RemoveEntries(0, 1000);
2881  for (Long64_t entry=0; entry<fSession->GetEntries(); entry++) {
2882  if ((record = fSession->GetRecord(entry)))
2883  fCombo->AddEntry(record->GetName(), entry);
2884  }
2885 }
2886 
2887 ////////////////////////////////////////////////////////////////////////////////
2888 /// Updates current record to new X, Y, Z items.
2889 
2891 {
2892  fSession->UpdateRecord(name);
2893 }
2894 
2895 ////////////////////////////////////////////////////////////////////////////////
2896 /// This slot is called when button REFR is clicked
2897 
2899 {
2900  fTree->Refresh();
2903  fSlider->SetRange(min,max);
2904  fSlider->SetPosition(min,max);
2905  ExecuteDraw();
2906 }
TGTextButton * fSPIDER
Definition: TTreeViewer.h:147
TTVRecord * First()
Definition: TTVSession.h:90
void InsertText(const char *text)
Insert text in text entry.
virtual Float_t GetMinPosition() const
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
Definition: TObject.cxx:879
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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.
virtual Int_t NumSelected() const
Definition: TGCanvas.h:116
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
virtual Float_t GetMaxPosition() const
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
void Reset()
Reset the timer.
Definition: TTimer.cxx:155
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
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.
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
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
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
#define gDirectory
Definition: TDirectory.h:218
TGLabel * fLbl2
Definition: TTreeViewer.h:138
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
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
virtual TList * GetListOfFriends() const
Definition: TTree.h:407
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:352
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
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
bool Bool_t
Definition: RtypesCore.h:59
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:389
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
#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
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
Int_t MakeSelector(const char *selector=0)
Get use of TTree::MakeSelector() via the context menu.
UInt_t GetWidth() const
Definition: TGFrame.h:287
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 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
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:403
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
TGLabel * fBLbl4
Definition: TTreeViewer.h:142
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
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
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
const char ** fFileTypes
Definition: TGFileDialog.h:65
virtual Long64_t GetReadEntry() const
Definition: TTree.h:424
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
virtual void AddThisItem(TTVLVEntry *item)
virtual const char * GetName() const
Returns name of object.
Definition: TTVSession.h:53
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
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 EButtonState GetState() const
Definition: TGButton.h:116
message
Definition: ROOT.py:94
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
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:229
R__EXTERN const char gTVHelpDrawing[]
Definition: HelpTextTV.h:28
TTVRecord * GetCurrent()
Definition: TTVSession.h:88
virtual TFile * GetFile() const
Definition: TDirectory.h:152
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition: TGCanvas.cxx:657
static const char * gOpenTypes[]
virtual TTree * GetTree() const
Definition: TTree.h:432
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
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
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
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:387
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:2884
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
void * GetUserData() const
Definition: TGListView.h:119
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
Int_t GET_SUBMSG(Long_t val)
void SetScanFileName(const char *name="")
Set the name of the file where to redirect <Scan> 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.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
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.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
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
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.
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
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
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
TTreeViewer(const char *treeName=0)
TTreeViewer default constructor.
void SetHistogramTitle(const char *title)
Set title of Histogram.
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.
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)
const char * GetString() const
Definition: TGString.h:44
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)
const char * GetText() const
Definition: TGTextEntry.h:140
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:254
TGHorizontalFrame * fHf
Definition: TTreeViewer.h:131
TGListTreeItem * GetParent() const
Definition: TGListTree.h:79
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
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:91
#define ClassImp(name)
Definition: Rtypes.h:279
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
TDirectory * GetDirectory() const
Definition: TTree.h:381
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 SetSmallPic(const TGPicture *spic)
Set small picture.
unsigned long ULong_t
Definition: RtypesCore.h:51
This class represent a specialized expression editor for TTVLVEntry &#39;true name&#39; and &#39;alias&#39; 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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
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
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:99
void ExecuteCommand(const char *command, Bool_t fast=kFALSE)
Execute all user commands.
TObjArray * GetListOfLeaves()
Definition: TBranch.h:178
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&#39;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
virtual Long64_t GetEntries() const
Definition: TTree.h:382
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 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.
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
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:493
#define gPad
Definition: TVirtualPad.h:288
virtual void SetTimerInterval(Int_t msec=333)
Definition: TTree.h:548
TGPictureButton * fDRAW
Definition: TTreeViewer.h:146
Int_t fTreeIndex
Definition: TTreeViewer.h:93
A TTree object has a header with a name and a title.
Definition: TTree.h:94
TGVerticalFrame * fV1
Definition: TTreeViewer.h:133
void EmptyAll()
Clear the content of all items in the list view.
TGSelectBox * fDialogBox
Definition: TTreeViewer.h:91
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2538
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:6274
void DoError(int level, const char *location, const char *fmt, va_list va) const
Put error/warning into TMsgBox and also forward to console.
R__EXTERN const char gTVHelpDraggingItems[]
Definition: HelpTextTV.h:23
R__EXTERN const char gTVHelpEditExpressions[]
Definition: HelpTextTV.h:24
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
Bool_t 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
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
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
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.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904
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
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
Int_t GetNleaves() const
Definition: TBranch.h:180
const char * Data() const
Definition: TString.h:349