Logo ROOT   6.07/09
Reference Guide
TTreeViewer.cxx
Go to the documentation of this file.
1 // @(#)root/treeviewer:$Id: c8e226dde2f9b6f39946bfe90cabcb778d63dc4f $
2 //Author : Andrei Gheata 16/08/00
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TTreeViewer
13 A graphic user interface designed to handle ROOT trees and to take advantage of
14 TTree class features.
15 
16 It uses ROOT native GUI widgets adapted for 'drag and drop' functionality.
17 in the same session.
18 
19 ### The following capabilities are making the viewer a helpful tool for analysis:
20 
21  - several trees may be opened in the same session;
22  - branches and leaves can be easily browsed or scanned;
23  - fast drawing of branch expressions by double-clicking;
24  - new variables/selections easy to compose with the built-in editor;
25  - histograms can be composed by dragging leaves or user-defined expressions
26  to X, Y and Z axis items;
27  - the tree entries to be processed can be selected with a double slider;
28  - selections can be defined and activated by dragging them to the 'Cut' item;
29  - all expressions can be aliased and aliases can be used in composing others;
30  - input/output event lists easy to handle;
31  - menu with histogram drawing options;
32  - user commands may be executed within the viewer and the current command
33  can be echoed;
34  - current 'Draw' event loop is reflected by a progress bar and may be
35  interrupted by the user;
36  - all widgets have self-explaining tool tips and/or context menus;
37  - expressions/leaves can be dragged to a 'scan box' and scanned by
38  double-clicking this item. The result can be redirected to an ASCII file;
39 
40 ### The layout has the following items:
41 
42  - a menu bar with entries : File, Edit, Run, Options and Help;
43  - a toolbar in the upper part where you can issue user commands, change
44  the drawing option and the histogram name, three check buttons Hist, Rec
45  and Scan.HIST toggles histogram drawing mode, REC enables recording of the
46  last command issued and SCAN enables redirecting of TTree::Scan command in
47  an ASCII file (see -Scanning expressions-);
48  - a button bar in the lower part with : buttons DRAW/STOP that issue histogram
49  drawing and stop the current command respectively, two text widgets where
50  input and output event lists can be specified, a message box and a RESET
51  button on the right that clear edited expression content (see Editing...)
52  - a tree-type list on the main left panel where you can select among trees or
53  branches. The tree/branch will be detailed in the right panel.
54  Mapped trees are provided with context menus, activated by right-clicking;
55  - a view-type list on the right panel. The first column contain X, Y and
56  Z expression items, an optional cut and ten optional editable expressions.
57  Expressions and leaf-type items can be dragged or deleted. A right click on
58  the list-box or item activates context menus.
59 
60 ### Opening a new tree and saving a session :
61 
62  To open a new tree in the viewer use <File/Open tree file> menu
63 The content of the file (keys) will be listed. Use <SetTreeName> function
64 from the context menu of the right panel, entering a tree name among those
65 listed.
66 
67  To save the current session, use <File/Save> menu or the <SaveSource>
68 function from the context menu of the right panel (to specify the name of the
69 file - name.C)
70 
71  To open a previously saved session for the tree MyTree, first open MyTree
72 in the browser, then use <File/Open session> menu.
73 
74 ### Dragging items:
75 
76 Items that can be dragged from the list in the right : expressions and
77 leaves. Dragging an item and dropping to another will copy the content of first
78 to the last (leaf->expression, expression->expression). Items far to the right
79 side of the list can be easily dragged to the left (where expressions are
80 placed) by dragging them to the left at least 10 pixels.
81 
82 ### Editing expressions:
83 
84  Any editable expression from the right panel has two components : a
85 true name (that will be used when TTree::Draw() commands are issued) and an
86 alias. The visible name is the alias. Aliases of user defined expressions have
87 a leading ~ and may be used in new expressions. Expressions containing boolean
88 operators have a specific icon and may be dragged to the active cut (scissors
89 item) position.
90 
91  The expression editor can be activated by double-clicking empty expression,
92 using <EditExpression> from the selected expression context menu or using
93 <Edit/Expression> menu.
94 
95  The editor will pop-up in the left part, but it can be moved.
96 The editor usage is the following :
97 
98  - you can write C expressions made of leaf names by hand or you can insert
99  any item from the right panel by clicking on it (recommandable);
100  - you can click on other expressions/leaves to paste them in the editor;
101  - you should write the item alias by hand since it not only make the
102  expression meaningful, but it also highly improve the layout for big
103  expressions
104  - you may redefine an old alias - the other expressions depending on it will
105  be modified accordingly. An alias must not be the leading string of other
106  aliases. When Draw commands are issued, the name of the corresponding
107  histogram axes will become the aliases of the expressions.
108 
109 User commands can be issued directly from the textbox labeled "Command"
110 from the upper-left toolbar by typing and pressing Enter at the end.
111 
112  Another way is from the right panel context menu : ExecuteCommand.
113 All commands can be interrupted at any time by pressing the STOP button
114 from the bottom-left
115 You can toggle recording of the current command in the history file by
116 checking the Rec button from the top-right
117 
118 ### Context menus
119 
120  You can activate context menus by right-clicking on items or inside the
121 right panel.
122 
123 Context menus for mapped items from the left tree-type list :
124  The items from the left that are provided with context menus are tree and
125 branch items. You can directly activate the *MENU* marked methods of TTree
126 from this menu.
127 
128 Context menu for the right panel:
129 
130  A general context menu is activated if the user right-clicks the right panel.
131 
132  Commands are :
133  - EmptyAll : clears the content of all expressions;
134  - ExecuteCommand : execute a ROOT command;
135  - MakeSelector : equivalent of TTree::MakeSelector();
136  - NewExpression : add an expression item in the right panel;
137  - Process : equivalent of TTree::Process();
138  - SaveSource : save the current session as a C++ macro;
139  - SetScanFileName : define a name for the file where TTree::Scan command
140  is redirected when the <Scan> button is checked;
141  - SetTreeName : open a new tree with this name in the viewer;
142 
143  A specific context menu is activated if expressions/leaves are right-clicked.
144 
145  Commands are :
146  - Draw : draw a histogram for this item;
147  - EditExpression : pops-up the expression editor;
148  - Empty : empty the name and alias of this item;
149  - RemoveItem : removes clicked item from the list;
150  - Scan : scan this expression;
151  - SetExpression : edit name and alias for this item by hand;
152 
153 Starting the viewer
154 
155  1. From the TBrowser: Select a tree in the TBrowser, then call the
156  StartViewer() method from its context menu (right-click on the tree).
157  2. From the command line: Start a ROOT session in the directory where you have
158  your tree. You will need first to load the library for TTreeViewer and
159  optionally other libraries for user defined classes (you can do this later in
160  the session) :
161 ~~~ {.cpp}
162  root [0] gSystem->Load(\"TTreeViewer\");
163 ~~~
164 Supposing you have the tree MyTree in the file MyFile, you can do :
165 ~~~ {.cpp}
166  root [1] TFile file("Myfile");
167  root [2] new TTreeViewer("Mytree");
168 ~~~
169 or :
170 ~~~ {.cpp}
171  root [2] TTreeViewer *tv = new TTreeViewer();
172  root [3] tv->SetTreeName("Mytree");
173 ~~~
174 \image html ttree_treeview.png
175 */
176 
177 #include "RConfigure.h"
178 
179 #include "Riostream.h"
180 #include "TTreeViewer.h"
181 #include "HelpText.h"
182 #include "HelpTextTV.h"
183 #include "TTVLVContainer.h"
184 #include "TTVSession.h"
185 
186 #include "TROOT.h"
187 #include "TError.h"
188 #include "TGMsgBox.h"
189 #include "TTreePlayer.h"
190 #include "TContextMenu.h"
191 #include "TInterpreter.h"
192 #include "TLeaf.h"
193 #include "TRootHelpDialog.h"
194 #include "TSystem.h"
195 #include "TApplication.h"
196 #include "TVirtualX.h"
197 #include "TGClient.h"
198 #include "TKey.h"
199 #include "TFile.h"
200 #include "TGMenu.h"
201 #include "TGFrame.h"
202 #include "TCanvas.h"
203 #include "TH1.h"
204 #include "TTree.h"
205 #include "TFriendElement.h"
206 #include "TObjArray.h"
207 #include "TObjString.h"
208 #include "TGButton.h"
209 #include "TGButtonGroup.h"
210 #include "TGTextEntry.h"
211 #include "TGComboBox.h"
212 #include "TGLabel.h"
213 #include "TGListView.h"
214 #include "TGListTree.h"
215 #include "TGMimeTypes.h"
216 #include "TGSplitter.h"
217 #include "TGDoubleSlider.h"
218 #include "TGToolBar.h"
219 #include "TGStatusBar.h"
220 #include "Getline.h"
221 #include "TTimer.h"
222 #include "TG3DLine.h"
223 #include "TGFileDialog.h"
224 #include "TGProgressBar.h"
225 #include "TClonesArray.h"
226 #include "TSpider.h"
227 
228 #ifdef WIN32
229 #include "TWin32SplashThread.h"
230 #endif
231 
232 // drawing options
233 static const char* gOptgen[16] =
234 {
235  "","AXIS","HIST","SAME","CYL","POL","SPH","PSR","LEGO","LEGO1","LEGO2",
236  "SURF","SURF1","SURF2","SURF3","SURF4"
237 };
238 static const char* gOpt1D[12] =
239 {
240  "","AH","B","C","E","E1","E2","E3","E4","L","P","*H"
241 };
242 static const char* gOpt2D[14] =
243 {
244  "","ARR","BOX","COL","COL2","CONT","CONT0","CONT1","CONT2","CONT3",
245  "FB","BB","SCAT","PROF"
246 };
247 
248 static const char* gOpenTypes[] = {"Root files", "*.root",
249  0, 0 };
250 
251 static const char* gMacroTypes[] = {"C++ macros", "*.C",
252  0, 0 };
253 
254 // Menu command id's
264 
269 
272 
277 
278  kHelpAbout = 100,
290 
295 };
296 
297 // button Id's
309 };
310 
312 
313 ////////////////////////////////////////////////////////////////////////////////
314 /// TTreeViewer default constructor
315 
316 TTreeViewer::TTreeViewer(const char* treeName) :
317  TGMainFrame(0,10,10,kVerticalFrame),
318  fDimension(0), fVarDraw(0), fScanMode(0),
319  fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
320  fCounting(0), fStopMapping(0), fEnableCut(0),fNexpressions(0)
321 {
322  fTree = 0;
323  if (!gClient) return;
324  char command[128];
325  snprintf(command,128, "TTreeViewer *gTV = (TTreeViewer*)0x%lx", (ULong_t)this);
326  gROOT->ProcessLine(command);
327  gROOT->ProcessLine("TTree *tv__tree = 0;");
328  fTreeList = new TList;
329  gROOT->ProcessLine("TList *tv__tree_list = new TList;");
330  fFilename = "";
331  gROOT->ProcessLine("TFile *tv__tree_file = 0;");
332  gInterpreter->SaveContext();
333  BuildInterface();
334  SetTreeName(treeName);
335 }
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 
340  TGMainFrame(0, 10, 10, kVerticalFrame),
341  fDimension(0), fVarDraw(0), fScanMode(0),
342  fTreeIndex(0), fDefaultCursor(0), fWatchCursor(0),
343  fCounting(0), fStopMapping(0), fEnableCut(0),fNexpressions(0)
344 
345 {
346  // TTreeViewer constructor with a pointer to a Tree
347 
348  fTree = 0;
349  char command[128];
350  snprintf(command,128, "TTreeViewer *gTV = (TTreeViewer*)0x%lx", (ULong_t)this);
351  gROOT->ProcessLine(command);
352  if (!tree) return;
353  gROOT->ProcessLine("TTree *tv__tree = 0;");
354  fTreeList = new TList;
355  gROOT->ProcessLine("TList *tv__tree_list = new TList;");
356  fFilename = "";
357  gROOT->ProcessLine("TFile *tv__tree_file = 0;");
358  gInterpreter->SaveContext();
359  BuildInterface();
360  TDirectory *dirsav = gDirectory;
361  TDirectory *cdir = tree->GetDirectory();
362  if (cdir) cdir->cd();
363 
364  SetTree((TTree *)tree);
365  // If the tree is a chain, the tree directory will be changed by SwitchTree
366  // (called by SetTreeName)
367  cdir = tree->GetDirectory();
368  if (cdir) {
369  if (cdir->GetFile()) fFilename = cdir->GetFile()->GetName();
370  }
371  if (dirsav) dirsav->cd();
372 }
373 ////////////////////////////////////////////////////////////////////////////////
374 /// Allow geting the tree from the context menu.
375 
377 {
378  if (!tree) return;
379  TTree *ftree;
380  if (fTreeList) {
381  if (fTreeList->FindObject(tree)) {
382  printf("Tree found\n");
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  // gopt = "hist";
1494  // fLastOption = "hist";
1495  //}
1496  if (dimension == 3 && strlen(gopt)) {
1497  std::cout << "Graphics option " << gopt << " not valid for 3D histograms" << std::endl;
1498  gopt = "";
1499  fLastOption = "";
1500  }
1501  command = TString::Format("tv__tree->Draw(\"%s\",\"%s\",\"%s\", %lld, %lld);",
1502  varexp.Data(), cut, gopt, nentries, firstentry);
1503  if (fCounting) return;
1504  fCounting = kTRUE;
1505  fTree->SetTimerInterval(200);
1506  fTimer->TurnOn();
1507  ExecuteCommand(command.Data());
1509  fTimer->TurnOff();
1510  fTree->SetTimerInterval(0);
1511  fCounting = kFALSE;
1514  TH1 *hist = fTree->GetHistogram();
1515  if (hist) {
1516  // put expressions aliases on axes
1517  Int_t current = 0;
1518  for (i=0; i<3; i++) {
1519  if (alias[i].Length()) {
1520  if (i != current) {
1521  alias[current] = alias[i];
1522  alias[i] = "";
1523  }
1524  current++;
1525  }
1526  }
1527  //hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
1528  TAxis *axis[3];
1529  axis[0] = hist->GetXaxis();
1530  axis[1] = hist->GetYaxis();
1531  axis[2] = hist->GetZaxis();
1532  for (Int_t ind=0; ind<3; ind++) axis[ind]->SetTitle(alias[ind].Data());
1533  }
1534  if (gPad) gPad->Update();
1535 }
1536 
1537 ////////////////////////////////////////////////////////////////////////////////
1538 /// Draw a spider plot for the selected entries.
1539 
1541 {
1542  TString varexp;
1543  Int_t dimension = 0;
1544  TString alias[3];
1545  TTVLVEntry *item;
1546  Bool_t previousexp = kFALSE;
1547  // fill in expressions
1548  if (Ez() && strlen(Ez())) {
1549  previousexp = kTRUE;
1550  dimension++;
1551  varexp = Ez();
1552  item = ExpressionItem(2);
1553  alias[2] = item->GetAlias();
1554  if (alias[2].BeginsWith("~")) alias[2].Remove(0, 1);
1555  }
1556  if ((Ez() && strlen(Ez())) && ((Ex() && strlen(Ex())) || (Ey() && strlen(Ey())))) varexp += ":";
1557  if (Ey() && strlen(Ey())) {
1558  previousexp = kTRUE;
1559  dimension++;
1560  varexp += Ey();
1561  item = ExpressionItem(1);
1562  alias[1] = item->GetAlias();
1563  if (alias[1].BeginsWith("~")) alias[1].Remove(0, 1);
1564  }
1565  if (Ey() && strlen(Ey()) && Ex() && strlen(Ex())) varexp += ":";
1566  if (Ex() && strlen(Ex())) {
1567  previousexp = kTRUE;
1568  dimension++;
1569  varexp += Ex();
1570  item = ExpressionItem(0);
1571  alias[0] = item->GetAlias();
1572  if (alias[0].BeginsWith("~")) alias[0].Remove(0, 1);
1573  }
1574  for(Int_t i=0;i<10;++i){
1575  if(En(i+5) && strlen(En(i+5))){
1576  ++dimension;
1577  if(previousexp){
1578  varexp += ":";
1579  varexp += En(i+5);
1580  } else varexp = En(i+5);
1581  previousexp = kTRUE;
1582  }
1583  }
1584  if (dimension<3) {
1585  Warning("ExecuteSpider", "Need at least 3 variables");
1586  return;
1587  }
1588  // find ListIn
1589  fTree->SetEventList(0);
1590  TEventList *elist = 0;
1591  if (strlen(fBarListIn->GetText())) {
1592  elist = (TEventList *) gROOT->FindObject(fBarListIn->GetText());
1593  if (elist) fTree->SetEventList(elist);
1594  }
1595  // find ListOut
1596  if (strlen(fBarListOut->GetText())) varexp = TString::Format(">>%s", fBarListOut->GetText());
1597  // find canvas/pad where to draw
1598  TPad *pad = (TPad*)gROOT->GetSelectedPad();
1599  if (pad) pad->cd();
1600  // find graphics option
1601  const char* gopt = fBarOption->GetText();
1602  // just in case a previous interrupt was posted
1603  gROOT->SetInterrupt(kFALSE);
1604  // check if cut is enabled
1605  const char *cut = "";
1606  if (fEnableCut) cut = Cut();
1607 
1608  // get entries to be processed
1610  fSlider->GetMinPosition() + 1);
1611  Long64_t firstentry =(Long64_t) fSlider->GetMinPosition();
1612 
1613  // create the spider plot
1614 
1615  TSpider* spider = new TSpider(fTree,varexp.Data(),cut,Form("%s spider average",gopt),nentries,firstentry);
1616  spider->Draw();
1617 
1618  if (gPad) gPad->Update();
1619 }
1620 
1621 ////////////////////////////////////////////////////////////////////////////////
1622 /// Get the expression to be drawn on X axis.
1623 
1624 const char* TTreeViewer::Ex()
1625 {
1626  return fLVContainer->Ex();
1627 }
1628 
1629 ////////////////////////////////////////////////////////////////////////////////
1630 /// Get the expression to be drawn on Y axis.
1631 
1632 const char* TTreeViewer::Ey()
1633 {
1634  return fLVContainer->Ey();
1635 }
1636 
1637 ////////////////////////////////////////////////////////////////////////////////
1638 /// Get the expression to be drawn on Z axis.
1639 
1640 const char* TTreeViewer::Ez()
1641 {
1642  return fLVContainer->Ez();
1643 }
1644 
1645 ////////////////////////////////////////////////////////////////////////////////
1646 /// Get the n'th expression
1647 
1649 {
1651  if(e) return e->ConvertAliases();
1652  return "";
1653 }
1654 
1655 ////////////////////////////////////////////////////////////////////////////////
1656 /// Start the expression editor.
1657 
1659 {
1660  void *p = 0;
1661  // get the selected item
1662  TTVLVEntry *item = 0;
1663  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == 0) {
1664  Warning("EditExpression", "No item selected.");
1665  return;
1666  }
1667  // check if it is an expression
1668  ULong_t *itemType = (ULong_t *) item->GetUserData();
1669  if (!(*itemType & kLTExpressionType)) {
1670  Warning("EditExpression", "Not expression type.");
1671  return;
1672  }
1673  // check if the editor is already active
1675  if (!fDialogBox) {
1676  fDialogBox = new TGSelectBox(fClient->GetRoot(), this, fV1->GetWidth() - 10);
1677  }
1678  // copy current item data into editor boxes
1679  fDialogBox->SetEntry(item);
1680  fDialogBox->SetWindowName("Expression editor");
1681  // check if you are editing the cut expression
1682  if (*itemType & kLTCutType || item->IsCut()) {
1683  fDialogBox->SetLabel("Selection");
1684  } else {
1685  fDialogBox->SetLabel("Expression");
1686  }
1687 }
1688 
1689 ////////////////////////////////////////////////////////////////////////////////
1690 /// Get use of TTree::MakeSelector() via the context menu.
1691 
1692 Int_t TTreeViewer::MakeSelector(const char* selector)
1693 {
1694  if (!fTree) return 0;
1695  return fTree->MakeSelector(selector);
1696 }
1697 
1698 ////////////////////////////////////////////////////////////////////////////////
1699 /// Get use of TTree::Process() via the context menu.
1700 
1701 Long64_t TTreeViewer::Process(const char* filename, Option_t *option, Long64_t nentries, Long64_t firstentry)
1702 {
1703  if (!fTree) return 0;
1704  return fTree->Process(filename, option, nentries, firstentry);
1705 }
1706 
1707 ////////////////////////////////////////////////////////////////////////////////
1708 /// Get graph option
1709 
1711 {
1712  return fBarOption->GetText();
1713 }
1714 
1715 ////////////////////////////////////////////////////////////////////////////////
1716 /// Set graph option
1717 
1718 void TTreeViewer::SetGrOpt(const char *option)
1719 {
1720  fBarOption->SetText(option);
1721 }
1722 
1723 ////////////////////////////////////////////////////////////////////////////////
1724 /// Return kTRUE if scan is redirected
1725 
1727 {
1728  return (fBarScan->GetState()==kButtonDown);
1729 }
1730 
1731 ////////////////////////////////////////////////////////////////////////////////
1732 /// Remove the selected item from the list.
1733 
1735 {
1736  void *p = 0;
1737  TTVLVEntry *item = 0;
1738  // get the selected item
1739  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) == 0) {
1740  Warning("RemoveItem", "No item selected.");
1741  return;
1742  }
1743  // check if it is removable
1744  ULong_t *itemType = (ULong_t *) item->GetUserData();
1745  if (!(*itemType & kLTDragType)) {
1746  Warning("RemoveItem", "Not removable type.");
1747  return;
1748  }
1749  fLVContainer->RemoveItem(item);
1750  fListView->Layout();
1751 }
1752 
1753 ////////////////////////////////////////////////////////////////////////////////
1754 /// Remove the current record.
1755 
1757 {
1759 }
1760 
1761 ////////////////////////////////////////////////////////////////////////////////
1762 /// This function is called by the fTimer object.
1763 
1765 {
1766  if (fCounting) {
1768  Float_t last = fSlider->GetMaxPosition();
1769  Float_t current = (Float_t)fTree->GetReadEntry();
1770  Float_t percent = (current-first+1)/(last-first+1);
1771  fProgressBar->SetPosition(100.*percent);
1773  }
1774  timer->Reset();
1775  return kFALSE;
1776 }
1777 
1778 ////////////////////////////////////////////////////////////////////////////////
1779 /// Handle menu and other commands generated.
1780 
1782 {
1783  TRootHelpDialog *hd;
1784  TTVRecord *record;
1785 
1786  switch (GET_MSG(msg)) {
1787  case kC_VSLIDER :
1788  // handle slider messages
1789  PrintEntries();
1790  break;
1791  case kC_TEXTENTRY:
1792  switch (GET_SUBMSG(msg)) {
1793  // handle enter posted by the Command text entry
1794  case kTE_ENTER:
1795  if ((ERootTreeViewerCommands)parm1 == kBarCommand) {
1797  fBarCommand->Clear();
1798  }
1799  if ((ERootTreeViewerCommands)parm1 == kBarOption) {
1800  fVarDraw = kFALSE;
1802  ExecuteDraw();
1804  }
1805  break;
1806  default:
1807  break;
1808  }
1809  break;
1810  case kC_LISTTREE:
1811  switch (GET_SUBMSG(msg)) {
1812  // handle mouse messages in the list-tree (left panel)
1813  case kCT_ITEMCLICK :
1814  // tell coverity that parm1 is a Long_t, and not an enum (even
1815  // if we compare it with an enum value) and the meaning of
1816  // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
1817  // coverity[mixed_enums]
1818  if (((EMouseButton)parm1==kButton1) ||
1819  ((EMouseButton)parm1==kButton3)) {
1820  TGListTreeItem *ltItem = 0;
1821  // get item that sent this
1822  if ((ltItem = fLt->GetSelected()) != 0) {
1823  // get item type
1824  ULong_t *itemType = (ULong_t *)ltItem->GetUserData();
1825  if (!itemType)
1826  break;
1827  if (*itemType & kLTTreeType) {
1828  // already mapped tree item clicked
1829  Int_t index = (Int_t)(*itemType >> 8);
1830  SwitchTree(index);
1831  if (fTree != fMappedTree) {
1832  // switch also the global "tree" variable
1834  // map it on the right panel
1835  MapTree(fTree);
1836  fListView->Layout();
1837  }
1838  // activate context menu for this tree
1839  if (parm1 == kButton3) {
1840  Int_t x = (Int_t)(parm2 &0xffff);
1841  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1842  fContextMenu->Popup(x, y, fTree);
1843  }
1844  }
1845 
1846  if (*itemType & kLTBranchType) {
1847  // branch item clicked
1848  SetParentTree(ltItem);
1849  if (!fTree) break; // really needed ?
1850  TBranch *branch = fTree->GetBranch(ltItem->GetText());
1851  if (!branch) break;
1852  // check if it is mapped on the right panel
1853  if (branch != fMappedBranch) {
1855  MapBranch(branch);
1856  fStopMapping = kFALSE;
1857  fListView->Layout();
1858  }
1859  // activate context menu for this branch (no *MENU* methods ):)
1860  if (parm1 == kButton3) {
1861  Int_t x = (Int_t)(parm2 &0xffff);
1862  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
1863  fContextMenu->Popup(x, y, branch);
1864  }
1865  }
1866 
1867  if (*itemType & kLTLeafType) {
1868  // leaf item clicked
1869  SetParentTree(ltItem);
1870  if (!fTree) break;
1871  // find parent branch
1872  TBranch *branch = fTree->GetBranch(ltItem->GetParent()->GetText());
1873  if (!branch) {
1874  if (fTree != fMappedTree) {
1876  MapTree(fTree);
1877  fListView->Layout();
1878  }
1879  } else {
1880  // check if it is already mapped
1881  if (branch!=fMappedBranch) {
1883  MapBranch(branch);
1884  fStopMapping = kFALSE;
1885  fListView->Layout();
1886  }
1887  }
1888  // select corresponding leaf on the right panel
1889  fLVContainer->SelectItem(ltItem->GetText());
1890  if (parm1 == kButton3) {
1891  // activate context menu for this leaf
1893  }
1894  }
1895  }
1896  }
1897  break;
1898  case kCT_ITEMDBLCLICK :
1900  if (parm1 == kButton1) {
1901  // execute double-click action for corresponding item in the right panel
1903  }
1904  break;
1905  default:
1906  break;
1907  }
1908  break;
1909  case kC_COMMAND:
1910  switch (GET_SUBMSG(msg)) {
1911  case kCM_COMBOBOX:
1912  if ((record = fSession->GetRecord((Int_t)parm2)))
1913  fSession->Show(record);
1914  break;
1915  case kCM_BUTTON:
1916  switch (parm1) {
1917  // handle button messages
1918  case kRESET:
1919  EmptyAll();
1920  break;
1921  case kDRAW:
1922  fVarDraw = kFALSE;
1923  ExecuteDraw();
1924  break;
1925  case kSTOP:
1926  if (fCounting)
1927  gROOT->SetInterrupt(kTRUE);
1928  break;
1929  case kCLOSE:
1930  SendCloseMessage();
1931  break;
1932  case kBGFirst:
1933  if ((record = fSession->First()))
1934  fSession->Show(record);
1935  break;
1936  case kBGPrevious:
1937  if ((record = fSession->Previous()))
1938  fSession->Show(record);
1939  break;
1940  case kBGRecord:
1941  fSession->AddRecord();
1942  break;
1943  case kBGNext:
1944  if ((record = fSession->Next()))
1945  fSession->Show(record);
1946  break;
1947  case kBGLast:
1948  if ((record = fSession->Last()))
1949  fSession->Show(record);
1950  break;
1951  default:
1952  break;
1953  }
1954  break;
1955  case kCM_MENU:
1956  // handle menu messages
1957  // check if sent by Options menu
1958  if ((parm1>=kOptionsReset) && (parm1<kHelpAbout)) {
1959  Dimension();
1960  if ((fDimension==0) && (parm1>=kOptions1D)) {
1961  Warning("ProcessMessage", "Edit expressions first.");
1962  break;
1963  }
1964  if ((fDimension==1) && (parm1>=kOptions2D)) {
1965  Warning("ProcessMessage", "You have only one expression active.");
1966  break;
1967  }
1968  if ((fDimension==2) && (parm1>=kOptions1D) &&(parm1<kOptions2D)) {
1969  Warning("ProcessMessage", "1D drawing options not apply to 2D histograms.");
1970  break;
1971  }
1972  // make composed option
1973  MapOptions(parm1);
1974  break;
1975  }
1976  switch (parm1) {
1977  case kFileCanvas:
1978  gROOT->MakeDefCanvas();
1979  break;
1980  case kFileBrowse:
1981  if (1) {
1982  static TString dir(".");
1983  TGFileInfo info;
1984  info.fFileTypes = gOpenTypes;
1985  info.fIniDir = StrDup(dir);
1986  new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
1987  if (!info.fFilename) return kTRUE;
1988  dir = info.fIniDir;
1989  TString command = TString::Format("tv__tree_file = new TFile(\"%s\");",
1990  gSystem->UnixPathName(info.fFilename));
1991  ExecuteCommand(command.Data());
1992  ExecuteCommand("tv__tree_file->ls();");
1993  std::cout << "Use SetTreeName() from context menu and supply a tree name" << std::endl;
1994  std::cout << "The context menu is activated by right-clicking the panel from right" << std::endl;
1995  }
1996  break;
1997  case kFileLoadLibrary:
1998  fBarCommand->SetText("gSystem->Load(\"\");");
1999  if (1) {
2000  Event_t event;
2001  event.fType = kButtonPress;
2002  event.fCode = kButton1;
2003  event.fX = event.fY = 1;
2004  fBarCommand->HandleButton(&event);
2005  }
2007  break;
2008  case kFileOpenSession:
2009  if (1) {
2010  static TString dir(".");
2011  TGFileInfo info;
2012  info.fFileTypes = gMacroTypes;
2013  info.fIniDir = StrDup(dir);
2014  new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &info);
2015  if (!info.fFilename) return kTRUE;
2016  dir = info.fIniDir;
2017  gInterpreter->Reset();
2018  if (!gInterpreter->IsLoaded(info.fFilename)) gInterpreter->LoadMacro(info.fFilename);
2019  char command[1024];
2020  command[0] = 0;
2021  snprintf(command,1024,"open_session((void*)0x%lx);", (Long_t)this);
2022  ExecuteCommand(command);
2023  }
2024  break;
2025  case kFileSaveMacro:
2026  fContextMenu->Action(this,(TMethod*)IsA()->GetListOfMethods()->FindObject("SaveSource"));
2027  break;
2028  case kFilePrint:
2029  break;
2030  case kFileClose:
2031  SendCloseMessage();
2032  break;
2033  case kFileQuit:
2034  gApplication->Terminate(0);
2035  break;
2036  case kEditExpression:
2037  EditExpression();
2038  break;
2039  case kEditCut:
2040  EditExpression();
2041  break;
2042  case kEditMacro:
2043  break;
2044  case kEditEvent:
2045  break;
2046  case kRunMacro:
2047  break;
2048  case kHelpAbout:
2049  {
2050 #ifdef R__UNIX
2051  TString rootx;
2052 # ifdef ROOTBINDIR
2053  rootx = ROOTBINDIR;
2054 # else
2055  rootx = gSystem->Getenv("ROOTSYS");
2056  if (!rootx.IsNull()) rootx += "/bin";
2057 # endif
2058  rootx += "/root -a &";
2059  gSystem->Exec(rootx);
2060 #else
2061 #ifdef WIN32
2063 #else
2064  char str[32];
2065  snprintf(str,32, "About ROOT %s...", gROOT->GetVersion());
2066  hd = new TRootHelpDialog(this, str, 600, 400);
2067  hd->SetText(gHelpAbout);
2068  hd->Popup();
2069 #endif
2070 #endif
2071  }
2072  break;
2073  case kHelpAboutTV:
2074  hd = new TRootHelpDialog(this, "About TreeViewer...", 600, 400);
2075  hd->SetText(gTVHelpAbout);
2076  hd->Resize(hd->GetDefaultSize());
2077  hd->Popup();
2078  break;
2079  case kHelpStart:
2080  hd = new TRootHelpDialog(this, "Quick start...", 600, 400);
2081  hd->SetText(gTVHelpStart);
2082  hd->Popup();
2083  break;
2084  case kHelpLayout:
2085  hd = new TRootHelpDialog(this, "Layout...", 600, 400);
2086  hd->SetText(gTVHelpLayout);
2087  hd->Popup();
2088  break;
2089  case kHelpOpenSave:
2090  hd = new TRootHelpDialog(this, "Open/Save...", 600, 400);
2091  hd->SetText(gTVHelpOpenSave);
2092  hd->Popup();
2093  break;
2094  case kHelpDragging:
2095  hd = new TRootHelpDialog(this, "Dragging items...", 600, 400);
2097  hd->Popup();
2098  break;
2099  case kHelpEditing:
2100  hd = new TRootHelpDialog(this, "Editing expressions...", 600, 400);
2102  hd->Popup();
2103  break;
2104  case kHelpSession:
2105  hd = new TRootHelpDialog(this, "Session...", 600, 400);
2106  hd->SetText(gTVHelpSession);
2107  hd->Popup();
2108  break;
2109  case kHelpCommands:
2110  hd = new TRootHelpDialog(this, "Executing user commands...", 600, 400);
2112  hd->Popup();
2113  break;
2114  case kHelpContext:
2115  hd = new TRootHelpDialog(this, "Context menus...", 600, 400);
2116  hd->SetText(gTVHelpContext);
2117  hd->Popup();
2118  break;
2119  case kHelpDrawing:
2120  hd = new TRootHelpDialog(this, "Drawing histograms...", 600, 400);
2121  hd->SetText(gTVHelpDrawing);
2122  hd->Popup();
2123  break;
2124  case kHelpMacros:
2125  hd = new TRootHelpDialog(this, "Using macros...", 600, 400);
2126  hd->SetText(gTVHelpMacros);
2127  hd->Popup();
2128  break;
2129  default:
2130  break;
2131  }
2132  break;
2133  default:
2134  break;
2135  }
2136  break;
2137  case kC_CONTAINER:
2138  switch (GET_SUBMSG(msg)) {
2139  // handle messages sent from the listview (right panel)
2140  case kCT_SELCHANGED:
2141  break;
2142  case kCT_ITEMCLICK:
2143  // handle mouse messages
2144  switch (parm1) {
2145  case kButton1:
2146  if (fLVContainer->NumSelected()) {
2147  // get item that sent this
2148  void *p = 0;
2149  TTVLVEntry *item;
2150  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != 0) {
2151  const char* vname = item->GetTrueName();
2152  TString trueName(vname);
2153  if (trueName.Contains("[]")) {
2154  TIter next(fTree->GetListOfLeaves());
2155  TLeaf *leaf;
2156  while((leaf=(TLeaf*)next())) {
2157  if (!strcmp(vname, EmptyBrackets(leaf->GetName())))
2158  vname = leaf->GetName();
2159  }
2160  }
2161  char* msg2 = new char[2000];
2162  // get item type
2163  ULong_t *itemType = (ULong_t *) item->GetUserData();
2164  if (*itemType & kLTTreeType) {
2165  // X, Y or Z clicked
2166  char symbol = (char)((*itemType) >> 8);
2167  snprintf(msg2,2000, "%c expression : %s", symbol, vname);
2168  } else {
2169  if (*itemType & kLTCutType) {
2170  // scissors clicked
2171  snprintf(msg2,2000, "Cut : %s", vname);
2172  } else {
2173  if (*itemType & kLTPackType) {
2174  snprintf(msg2,2000, "Box : %s", vname);
2175  } else {
2176  if (*itemType & kLTExpressionType) {
2177  // expression clicked
2178  snprintf(msg2,2000, "Expression : %s", vname);
2179  } else {
2180  if (*itemType & kLTBranchType) {
2181  snprintf(msg2,2000, "Branch : %s", vname);
2182  } else {
2183  snprintf(msg2,2000, "Leaf : %s", vname);
2184  }
2185  }
2186  }
2187  }
2188  }
2189  // write who is responsable for this
2190  TString message = msg2;
2191  message = message(0,150);
2192  Message(msg2);
2193  delete[] msg2;
2194  // check if this should be pasted into the expression editor
2195  if ((*itemType & kLTBranchType) || (*itemType & kLTCutType)) break;
2197  if (!fDialogBox || !vname[0]) break;
2198  if (item == fDialogBox->EditedEntry()) break;
2199  // paste it
2200 // char first = (char) vname[0];
2201  TString insert(item->GetAlias());
2202 // if (first != '(') insert += "(";
2203 // insert += item->GetAlias();
2204 // if (first != '(') insert += ")";
2205 
2207  fDialogBox->InsertText(insert.Data());
2208  // put the cursor at the right position
2209  }
2210  }
2211  break;
2212  case kButton2:
2213  break;
2214  case kButton3:
2215  // activate general context menu
2216  if (fLVContainer->NumSelected()) {
2217  void *p = 0;
2218  Int_t x = (Int_t)(parm2 &0xffff);
2219  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2220  TTVLVEntry *item = 0;
2221  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != 0) {
2222  fContextMenu->Popup(x, y, item->GetContext());
2223  }
2224  } else { // empty click
2225  Int_t x = (Int_t)(parm2 &0xffff);
2226  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2227  fContextMenu->Popup(x, y, this);
2228  }
2229  break;
2230  default:
2231  break;
2232  }
2233  break;
2234  case kCT_ITEMDBLCLICK:
2235  switch (parm1) {
2236  case kButton1:
2237  if (fLVContainer->NumSelected()) {
2238  // get item that sent this
2239  void *p = 0;
2240  TTVLVEntry *item;
2241  if ((item = (TTVLVEntry *) fLVContainer->GetNextSelected(&p)) != 0) {
2242  // get item type
2243  ULong_t *itemType = (ULong_t *) item->GetUserData();
2244  if (!(*itemType & kLTCutType) && !(*itemType & kLTBranchType)
2245  && !(*itemType & kLTPackType)) {
2246  if (strlen(item->GetTrueName())) {
2247  fVarDraw = kTRUE;
2248  // draw on double-click
2249  ExecuteDraw();
2250  break;
2251  } else {
2252  // open expression in editor
2253  EditExpression();
2254  }
2255  }
2256  if (*itemType & kLTCutType) {
2258  if (fEnableCut) {
2259  item->SetSmallPic(gClient->GetPicture("cut_t.xpm"));
2260  } else {
2261  item->SetSmallPic(gClient->GetPicture("cut-disable_t.xpm"));
2262  }
2263  }
2264  if (*itemType & kLTPackType) {
2265  fScanMode = kTRUE;
2266  ExecuteDraw();
2267  }
2268  }
2269  }
2270  break;
2271  case kButton2:
2272  break;
2273  case kButton3:
2274  break;
2275  default:
2276  break;
2277  }
2278  break;
2279  case 4:
2280 // std::cout << "Dragging Item" << std::endl;
2281  default:
2282  break;
2283  }
2284  break;
2285  default:
2286  break;
2287  }
2288  return kTRUE;
2289 }
2290 
2291 ////////////////////////////////////////////////////////////////////////////////
2292 /// Close the viewer.
2293 
2295 {
2296  DeleteWindow();
2297 }
2298 
2299 ////////////////////////////////////////////////////////////////////////////////
2300 /// Execute all user commands.
2301 
2302 void TTreeViewer::ExecuteCommand(const char* command, Bool_t fast)
2303 {
2304  // Execute the command, write it to history file and echo it to output
2305  if (fBarRec->GetState() == kButtonDown) {
2306  // show the command on the command line
2307  //printf("%s\n", command);
2308  char comm[2000];
2309  comm[0] = 0;
2310  if (strlen(command) > 1999) {
2311  Warning("ExecuteCommand", "Command too long: aborting.");
2312  return;
2313  }
2314  snprintf(comm,2000, "%s", command);
2315  // print the command to history file
2316  Gl_histadd(comm);
2317  }
2318  // execute it
2319  if (fast) {
2320  gROOT->ProcessLineFast(command);
2321  } else {
2322  gROOT->ProcessLine(command);
2323  }
2324  // make sure that 'draw on double-click' flag is reset
2325  fVarDraw = kFALSE;
2326 }
2327 
2328 ////////////////////////////////////////////////////////////////////////////////
2329 /// Scan the selected options from option menu.
2330 
2332 {
2333  Int_t ind;
2334  if (parm1 == kOptionsReset) {
2335  for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++)
2336  fOptionsGen->UnCheckEntry(ind);
2337  for (ind=kOptions1D; ind<kOptions1D+12; ind++)
2338  fOptions1D->UnCheckEntry(ind);
2339  for (ind=kOptions2D; ind<kOptions2D+14; ind++)
2340  fOptions2D->UnCheckEntry(ind);
2341  }
2342  if ((parm1 < kOptions1D) && (parm1 != kOptionsReset)) {
2343  if (fOptionsGen->IsEntryChecked((Int_t)parm1)) {
2344  fOptionsGen->UnCheckEntry((Int_t)parm1);
2345  } else {
2346  fOptionsGen->CheckEntry((Int_t)parm1);
2348  }
2350  // uncheck all in this menu
2351  for (ind=kOptionsGeneral+1; ind<kOptionsGeneral+16; ind++) {
2352  fOptionsGen->UnCheckEntry(ind);
2353  }
2354  }
2355  }
2356 
2357  if ((parm1 < kOptions2D) && (parm1 >= kOptions1D)) {
2358  if (fOptions1D->IsEntryChecked((Int_t)parm1)) {
2359  fOptions1D->UnCheckEntry((Int_t)parm1);
2360  } else {
2361  fOptions1D->CheckEntry((Int_t)parm1);
2363  }
2365  // uncheck all in this menu
2366  for (ind=kOptions1D+1; ind<kOptions1D+12; ind++) {
2367  fOptions1D->UnCheckEntry(ind);
2368  }
2369  }
2370  }
2371 
2372  if (parm1 >= kOptions2D) {
2373  if (fOptions2D->IsEntryChecked((Int_t)parm1)) {
2374  fOptions2D->UnCheckEntry((Int_t)parm1);
2375  } else {
2376  fOptions2D->CheckEntry((Int_t)parm1);
2378  }
2380  // uncheck all in this menu
2381  for (ind=kOptions2D+1; ind<kOptions2D+14; ind++) {
2382  fOptions2D->UnCheckEntry(ind);
2383  }
2384  }
2385  }
2386  // concatenate options
2387  fBarOption->SetText("");
2388  for (ind=kOptionsGeneral; ind<kOptionsGeneral+16; ind++) {
2389  if (fOptionsGen->IsEntryChecked(ind))
2390  fBarOption->AppendText(gOptgen[ind-kOptionsGeneral]);
2391  }
2392  if (Dimension() == 1) {
2393  for (ind=kOptions1D; ind<kOptions1D+12; ind++) {
2394  if (fOptions1D->IsEntryChecked(ind))
2395  fBarOption->AppendText(gOpt1D[ind-kOptions1D]);
2396  }
2397  }
2398  if (Dimension() == 2) {
2399  for (ind=kOptions2D; ind<kOptions2D+14; ind++) {
2400  if (fOptions2D->IsEntryChecked(ind))
2401  fBarOption->AppendText(gOpt2D[ind-kOptions2D]);
2402  }
2403  }
2404 }
2405 
2406 ////////////////////////////////////////////////////////////////////////////////
2407 /// Map current tree and expand its content (including friends) in the lists.
2408 
2410 {
2411  if (!tree) return;
2412  TObjArray *branches = tree->GetListOfBranches();
2413  if (!branches) return; // A Chain with no underlying trees.
2414  TBranch *branch;
2415  // loop on branches
2416  Int_t id;
2417  for (id=0; id<branches->GetEntries(); id++) {
2418  branch = (TBranch *)branches->At(id);
2419  if (branch->TestBit(kDoNotProcess)) continue;
2420  TString name = branch->GetName();
2421  if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2422  // now map sub-branches
2423  MapBranch(branch, "", parent, listIt);
2424  fStopMapping = kFALSE;
2425  }
2426  //Map branches of friend Trees (if any)
2427  //Look at tree->GetTree() to insure we see both the friendss of a chain
2428  //and the friends of the chain members
2429  TIter nextf( tree->GetTree()->GetListOfFriends() );
2430  TFriendElement *fr;
2431  while ((fr = (TFriendElement*)nextf())) {
2432  TTree * t = fr->GetTree();
2433  branches = t->GetListOfBranches();
2434  for (id=0; id<branches->GetEntries(); id++) {
2435  branch = (TBranch *)branches->At(id);
2436  if (branch->TestBit(kDoNotProcess)) continue;
2437  TString name = branch->GetName();
2438  if (name.Contains("fBits") || name.Contains("fUniqueID")) continue;
2439  // now map sub-branches
2440  MapBranch(branch, fr->GetName(), parent, listIt);
2441  fStopMapping = kFALSE;
2442  }
2443  }
2444 
2445  // tell who was last mapped
2446  if (listIt) {
2447  fMappedTree = tree;
2448  fMappedBranch = 0;
2449  }
2450 }
2451 
2452 ////////////////////////////////////////////////////////////////////////////////
2453 /// Map current branch and expand its content in the list view.
2454 
2455 void TTreeViewer::MapBranch(TBranch *branch, const char *prefix, TGListTreeItem *parent, Bool_t listIt)
2456 {
2457  if (!branch) return;
2458  TString name;
2459  if (prefix && strlen(prefix) >0) name = Form("%s.%s",prefix,branch->GetName());
2460  else name = branch->GetName();
2461  Int_t ind;
2462  TGListTreeItem *branchItem = 0;
2463  ULong_t *itemType;
2464  // map this branch
2465  if (name.Contains("fBits") || name.Contains("fUniqueID")) return;
2466  if (parent) {
2467  // make list tree items for each branch according to the type
2468  const TGPicture *pic, *spic;
2469  if ((branch->GetListOfBranches()->GetEntries()) ||
2470  (branch->GetNleaves())) {
2471  if (branch->GetListOfBranches()->GetEntries()) {
2472  itemType = new ULong_t(kLTBranchType);
2473  if (branch->InheritsFrom("TBranchObject")) {
2474  pic = gClient->GetPicture("branch-ob_t.xpm");
2475  spic = gClient->GetPicture("branch-ob_t.xpm");
2476  } else {
2477  if (branch->InheritsFrom("TBranchClones")) {
2478  pic = gClient->GetPicture("branch-cl_t.xpm");
2479  spic = gClient->GetPicture("branch-cl_t.xpm");
2480  } else {
2481  pic = gClient->GetPicture("branch_t.xpm");
2482  spic = gClient->GetPicture("branch_t.xpm");
2483  }
2484  }
2485  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2486  } else {
2487  if (branch->GetNleaves() > 1) {
2488  itemType = new ULong_t(kLTBranchType);
2489  pic = gClient->GetPicture("branch_t.xpm");
2490  spic = gClient->GetPicture("branch_t.xpm");
2491  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType,pic, spic);
2492  TObjArray *leaves = branch->GetListOfLeaves();
2493  TLeaf *leaf = 0;
2494  TString leafName;
2495  for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2496  leaf = (TLeaf *)leaves->At(lf);
2497  leafName = name;
2498  leafName.Append(".").Append(EmptyBrackets(leaf->GetName()));
2499  itemType = new ULong_t(kLTLeafType);
2500  pic = gClient->GetPicture("leaf_t.xpm");
2501  spic = gClient->GetPicture("leaf_t.xpm");
2502  fLt->AddItem(branchItem, leafName.Data(), itemType, pic, spic);
2503  }
2504  } else {
2505  itemType = new ULong_t(kLTLeafType);
2506  pic = gClient->GetPicture("leaf_t.xpm");
2507  spic = gClient->GetPicture("leaf_t.xpm");
2508  branchItem = fLt->AddItem(parent, EmptyBrackets(name), itemType, pic, spic);
2509  }
2510  }
2511  }
2512  }
2513  // list branch in list view if necessary
2514  if (listIt) {
2515  TGString *textEntry = 0;
2516  const TGPicture *pic, *spic;
2517  TTVLVEntry *entry;
2518  // make list view items in the right frame
2519  if (!fStopMapping) {
2520  fMappedBranch = branch;
2521  fMappedTree = 0;
2522  fStopMapping = kTRUE;
2523  }
2524  if ((branch->GetListOfBranches()->GetEntries()) ||
2525  (branch->GetNleaves())) {
2526  textEntry = new TGString(EmptyBrackets(name.Data()));
2527  if (branch->GetListOfBranches()->GetEntries()) {
2528  if (branch->InheritsFrom("TBranchObject")) {
2529  pic = gClient->GetPicture("branch-ob_t.xpm");
2530  spic = gClient->GetPicture("branch-ob_t.xpm");
2531  } else {
2532  if (branch->InheritsFrom("TBranchClones")) {
2533  pic = gClient->GetPicture("branch-cl_t.xpm");
2534  spic = gClient->GetPicture("branch-cl_t.xpm");
2535  } else {
2536  pic = gClient->GetPicture("branch_t.xpm");
2537  spic = gClient->GetPicture("branch_t.xpm");
2538  }
2539  }
2540  entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,0,kLVSmallIcons);
2541  entry->SetUserData(new UInt_t(kLTBranchType));
2542  entry->SetToolTipText("Branch with sub-branches. Can not be dragged");
2543  fLVContainer->AddThisItem(entry);
2544  entry->MapWindow();
2545  entry->SetAlias(textEntry->GetString());
2546  } else {
2547  if (branch->GetNleaves() > 1) {
2548  if (textEntry) delete textEntry;
2549  textEntry = new TGString(EmptyBrackets(name.Data()));
2550  pic = gClient->GetPicture("branch_t.xpm");
2551  spic = gClient->GetPicture("branch_t.xpm");
2552  entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,0,kLVSmallIcons);
2553  entry->SetUserData(new UInt_t(kLTBranchType));
2554  entry->SetToolTipText("Branch with more than one leaf. Can not be dragged");
2555  fLVContainer->AddThisItem(entry);
2556  entry->MapWindow();
2557  entry->SetAlias(textEntry->GetString());
2558 
2559  TObjArray *leaves = branch->GetListOfLeaves();
2560  TLeaf *leaf = 0;
2561  TString leafName;
2562  for (Int_t lf=0; lf<leaves->GetEntries(); lf++) {
2563  leaf = (TLeaf *)leaves->At(lf);
2564  leafName = name;
2565  leafName.Append(".").Append(EmptyBrackets(leaf->GetName()));
2566  textEntry = new TGString(leafName.Data());
2567  pic = gClient->GetPicture("leaf_t.xpm");
2568  spic = gClient->GetPicture("leaf_t.xpm");
2569  entry = new TTVLVEntry(fLVContainer, pic, spic, textEntry,0,kLVSmallIcons);
2570  entry->SetUserData(new UInt_t(kLTDragType | kLTLeafType));
2571  entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2572  fLVContainer->AddThisItem(entry);
2573  entry->MapWindow();
2574  entry->SetAlias(textEntry->GetString());
2575  }
2576  } else {
2577  pic = (gClient->GetMimeTypeList())->GetIcon("TLeaf",kFALSE);
2578  if (!pic) pic = gClient->GetPicture("leaf_t.xpm");
2579  spic = gClient->GetMimeTypeList()->GetIcon("TLeaf",kTRUE);
2580  if (!spic) spic = gClient->GetPicture("leaf_t.xpm");
2581  entry = new TTVLVEntry(fLVContainer,pic,spic,textEntry,0,kLVSmallIcons);
2582  entry->SetUserData(new UInt_t(kLTDragType | kLTLeafType));
2583  entry->SetToolTipText("Double-click to draw. Drag to X, Y, Z or scan box.");
2584  fLVContainer->AddThisItem(entry);
2585  entry->MapWindow();
2586  entry->SetAlias(textEntry->GetString());
2587  }
2588  }
2589  }
2590  }
2591 
2592  TObjArray *branches = branch->GetListOfBranches();
2593  TBranch *branchDaughter = 0;
2594 
2595  // loop all sub-branches
2596  for (ind=0; ind<branches->GetEntries(); ind++) {
2597  branchDaughter = (TBranch *)branches->UncheckedAt(ind);
2598  // map also all sub-branches
2599  MapBranch(branchDaughter, "", branchItem, listIt);
2600  }
2601 }
2602 
2603 ////////////////////////////////////////////////////////////////////////////////
2604 /// Create new expression
2605 
2607 {
2609  const TGPicture *pic = gClient->GetPicture("expression_t.xpm");
2610  const TGPicture *spic = gClient->GetPicture("expression_t.xpm");
2611 
2612  TTVLVEntry *entry = new TTVLVEntry(fLVContainer,pic,spic,
2613  new TGString(),0,kLVSmallIcons);
2615  fLVContainer->AddThisItem(entry);
2616  entry->MapWindow();
2617  entry->Empty();
2618  if (fMappedTree) MapTree(fTree);
2620  fListView->Layout();
2621  fNexpressions++;
2622 }
2623 
2624 ////////////////////////////////////////////////////////////////////////////////
2625 /// Find parent tree of a clicked item.
2626 
2628 {
2629  if (!item) return;
2630  ULong_t *itemType = (ULong_t *)item->GetUserData();
2631  if (!itemType) return;
2632  TGListTreeItem *parent = 0;
2633  Int_t index;
2634  if (!(*itemType & kLTTreeType)) {
2635  parent = item->GetParent();
2636  SetParentTree(parent);
2637  } else {
2638  index = (Int_t)(*itemType >> 8);
2639  SwitchTree(index);
2640  }
2641 }
2642 
2643 ////////////////////////////////////////////////////////////////////////////////
2644 /// Send a message on the status bar.
2645 
2646 void TTreeViewer::Message(const char* msg)
2647 {
2648  fStatusBar->SetText(msg);
2649 }
2650 
2651 ////////////////////////////////////////////////////////////////////////////////
2652 /// Put error/warning into TMsgBox and also forward to console.
2653 
2654 void TTreeViewer::DoError(int level, const char *location, const char *fmt, va_list va) const
2655 {
2656  TObject::DoError(level, location, fmt, va);
2657 
2658  // in case level will abort we will not come here...
2659 
2660  static const int buf_size = 2048;
2661  char buf[buf_size], *bp;
2662 
2663  int n = vsnprintf(buf, buf_size, fmt, va);
2664  // old vsnprintf's return -1 if string is truncated new ones return
2665  // total number of characters that would have been written
2666  if (n == -1 || n >= buf_size) {
2667  TObject::Warning("DoError", "Error message string truncated...");
2668  }
2669  if (level >= kSysError && level < kFatal)
2670  bp = Form("%s (%s)", buf, gSystem->GetError());
2671  else
2672  bp = buf;
2673 
2674  const char *title = "";
2675  if (level == kInfo)
2676  title = "Info";
2677  if (level == kWarning)
2678  title = "Warning";
2679  if (level == kError)
2680  title = "Error";
2681  if (level == kSysError)
2682  title = "System Error";
2683 
2684  new TGMsgBox(fClient->GetRoot(), this, title, bp, kMBIconExclamation);
2685 }
2686 
2687 ////////////////////////////////////////////////////////////////////////////////
2688 /// Print the number of selected entries on status-bar.
2689 
2691 {
2692  if (!fTree) return;
2693  char * msg = new char[100];
2694  snprintf(msg,100, "First entry : %lld Last entry : %lld",
2696  Message(msg);
2697  delete[] msg;
2698 }
2699 
2700 ////////////////////////////////////////////////////////////////////////////////
2701 /// Save current session as a C++ macro file.
2702 
2703 void TTreeViewer::SaveSource(const char* filename, Option_t *)
2704 {
2705  if (!fTree) return;
2706  char quote = '"';
2707  std::ofstream out;
2708  Int_t lenfile = strlen(filename);
2709  char * fname;
2710  if (!lenfile) {
2711  fname = (char*)fSourceFile;
2712  lenfile = strlen(fname);
2713  } else {
2714  fname = (char*)filename;
2715  fSourceFile = filename;
2716  }
2717  // if filename is given, open this file, otherwise create a file
2718  // with a name : treeviewer.C
2719  if (lenfile) {
2720  out.open(fname, std::ios::out);
2721  } else {
2722  fname = new char[13];
2723  strlcpy(fname, "treeviewer.C",13);
2724  out.open(fname, std::ios::out);
2725  }
2726  if (!out.good ()) {
2727  printf("SaveSource cannot open file : %s\n", fname);
2728  fSourceFile = "treeviewer.C";
2729  if (!lenfile) delete [] fname;
2730  return;
2731  }
2732  // Write macro header and date/time stamp
2733  TDatime t;
2734  TString sname(fname);
2735  sname = sname.ReplaceAll(".C", "");
2736  out <<"void open_session(void *p = 0);"<<std::endl<<std::endl;
2737  out <<"void "<<sname.Data()<<"() {"<<std::endl;
2738  out <<"//=========Macro generated by ROOT version"<<gROOT->GetVersion()<<std::endl;
2739  out <<"//=========for tree "<<quote<<fTree->GetName()<<quote<<" ("<<t.AsString()<<")"<<std::endl;
2740  out <<"//===This macro can be opened from a TreeViewer session after loading"<<std::endl;
2741  out <<"//===the corresponding tree, or by running root with the macro name argument"<<std::endl<<std::endl;
2742  out <<" open_session();"<<std::endl;
2743  out <<"}"<<std::endl<<std::endl;
2744  out <<"void open_session(void *p = 0) {"<<std::endl;
2745  out <<" gSystem->Load("<<quote<<"libTreeViewer"<<quote<<");"<<std::endl;
2746  out <<" TTreeViewer *treeview = (TTreeViewer *) p;"<<std::endl;
2747  out <<" if (!treeview) treeview = new TTreeViewer();"<<std::endl;
2748  out <<" TTree *tv_tree = (TTree*)gROOT->FindObject("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2749  out <<" TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("<<quote<<fFilename<<quote<<");"<<std::endl;
2750  out <<" if (!tv_tree) {"<<std::endl;
2751  out <<" if (!tv_file) tv_file = new TFile("<<quote<<fFilename<<quote<<");"<<std::endl;
2752  out <<" if (tv_file) tv_tree = (TTree*)tv_file->Get("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2753  out <<" if(!tv_tree) {"<<std::endl;
2754  out <<" printf(\"Tree %s not found\", "<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2755  out <<" return;"<<std::endl;
2756  out <<" }"<<std::endl;
2757  out <<" }"<<std::endl<<std::endl;
2758  out <<" treeview->SetTreeName("<<quote<<fTree->GetName()<<quote<<");"<<std::endl;
2759  out <<" treeview->SetNexpressions("<<fNexpressions<<");"<<std::endl;
2760  // get expressions
2761  TTVLVEntry *item;
2762  out <<"// Set expressions on axis and cut"<<std::endl;
2763  out <<" TTVLVEntry *item;"<<std::endl;
2764  for (Int_t i=0; i<4; i++) {
2765  switch (i) {
2766  case 0:
2767  out <<"// X expression"<<std::endl;
2768  break;
2769  case 1:
2770  out <<"// Y expression"<<std::endl;
2771  break;
2772  case 2:
2773  out <<"// Z expression"<<std::endl;
2774  break;
2775  case 3:
2776  out <<"// Cut expression"<<std::endl;
2777  break;
2778  default:
2779  break;
2780  }
2781  item = ExpressionItem(i);
2782  out <<" item = treeview->ExpressionItem("<<i<<");"<<std::endl;
2783  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2784  <<", "<<quote<<item->GetAlias()<<quote<<");"<<std::endl;
2785  }
2786  out <<"// Scan list"<<std::endl;
2787  item = ExpressionItem(4);
2788  out <<" item = treeview->ExpressionItem(4);"<<std::endl;
2789  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2790  <<", "<<quote<<"Scan box"<<quote<<");"<<std::endl;
2791  out <<"// User defined expressions"<<std::endl;
2792  TString itemType;
2793  for (Int_t crt=5; crt<fNexpressions+5; crt++) {
2794  item = ExpressionItem(crt);
2795  if (item->IsCut())
2796  itemType = "kTRUE";
2797  else
2798  itemType = "kFALSE";
2799  out <<" item = treeview->ExpressionItem("<<crt<<");"<<std::endl;
2800  out <<" item->SetExpression("<<quote<<item->GetTrueName()<<quote
2801  <<", "<<quote<<item->GetAlias()<<quote<<", "<<itemType.Data()<<");"<<std::endl;
2802  }
2803  fSession->SaveSource(out);
2804  out <<"}"<<std::endl;
2805  out.close();
2806  printf("C++ Macro file: %s has been generated\n", fname);
2807  if (!lenfile) delete [] fname;
2808 }
2809 
2810 ////////////////////////////////////////////////////////////////////////////////
2811 /// Makes current the tree at a given index in the list.
2812 
2814 {
2815  TTree *tree = (TTree *) fTreeList->At(index);
2816  if (!tree) {
2817  Warning("SwitchTree", "No tree found.");
2818  return kFALSE;
2819  }
2820  if ((tree == fTree) && (tree == fMappedTree)) return kFALSE; // nothing to switch
2821  std::string command;
2822  if (tree != fTree) {
2823  command = "tv__tree = (TTree *) tv__tree_list->At";
2824  command += Form("(%i)",index);
2825  ExecuteCommand(command.c_str());
2826  }
2827 
2828  fTree = tree;
2829  fSlider->SetRange(0,fTree->GetEntries()-1);
2830  fSlider->SetPosition(0,fTree->GetEntries()-1);
2831  command = "Current Tree : ";
2832  command += fTree->GetName();
2833  fLbl2->SetText(new TGString(command.c_str()));
2834  fTreeHdr->Layout();
2835  MapSubwindows();
2837  MapWindow();
2838  ///Resize(); //ia
2839  PrintEntries();
2840  return kTRUE;
2841 }
2842 
2843 ////////////////////////////////////////////////////////////////////////////////
2844 /// Set record name
2845 
2847 {
2848  fSession->SetRecordName(name);
2849 }
2850 
2851 ////////////////////////////////////////////////////////////////////////////////
2852 /// Set current record
2853 
2855 {
2856  fCombo->Select(entry);
2857 }
2858 
2859 ////////////////////////////////////////////////////////////////////////////////
2860 /// Set title of Histogram
2861 
2862 void TTreeViewer::SetHistogramTitle(const char *title)
2863 {
2864  if (!gPad) return;
2865  TH1 *hist = (TH1*)gPad->GetListOfPrimitives()->FindObject(fBarHist->GetText());
2866  if (hist) {
2867  hist->SetTitle(title);
2868  gPad->Update();
2869  }
2870 }
2871 
2872 ////////////////////////////////////////////////////////////////////////////////
2873 /// user defined command for current record
2874 
2875 void TTreeViewer::SetUserCode(const char *code, Bool_t autoexec)
2876 {
2877  TTVRecord *rec = fSession->GetCurrent();
2878  if (rec) rec->SetUserCode(code, autoexec);
2879 }
2880 
2881 ////////////////////////////////////////////////////////////////////////////////
2882 /// Updates combo box to current session entries.
2883 
2885 {
2886  TTVRecord *record;
2887  fCombo->RemoveEntries(0, 1000);
2888  for (Long64_t entry=0; entry<fSession->GetEntries(); entry++) {
2889  if ((record = fSession->GetRecord(entry)))
2890  fCombo->AddEntry(record->GetName(), entry);
2891  }
2892 }
2893 
2894 ////////////////////////////////////////////////////////////////////////////////
2895 /// Updates current record to new X, Y, Z items.
2896 
2898 {
2899  fSession->UpdateRecord(name);
2900 }
2901 
2902 ////////////////////////////////////////////////////////////////////////////////
2903 /// This slot is called when button REFR is clicked
2904 
2906 {
2907  fTree->Refresh();
2908  Float_t min = fSlider->GetMinPosition();
2909  Float_t max = (Float_t)fTree->GetEntries()-1;
2910  fSlider->SetRange(min,max);
2911  fSlider->SetPosition(min,max);
2912  ExecuteDraw();
2913 }
TGTextButton * fSPIDER
Definition: TTreeViewer.h:147
TTVRecord * First()
Definition: TTVSession.h:90
void InsertText(const char *text)
Insert text in text entry.
const char * Ey()
Return the expression on Y.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:37
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
const char * GetTrueName()
TGPictureButton * fBGPrevious
Definition: TTreeViewer.h:153
TGPictureButton * fSTOP
Definition: TTreeViewer.h:148
void Empty()
Clear all names and alias.
An array of TObjects.
Definition: TObjArray.h:39
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other commands generated.
void Empty()
Empty the content of the selected expression.
TTVSession * fSession
Definition: TTreeViewer.h:81
virtual const TGFrame * GetNextSelected(void **current)
Return the next selected item.
Definition: TGCanvas.cxx:678
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:405
void SetNexpressions(Int_t expr)
Change the number of expression widgets.
Int_t fNexpressions
Definition: TTreeViewer.h:103
const char * GetAlias()
long long Long64_t
Definition: RtypesCore.h:69
TGCheckButton * fBarH
Definition: TTreeViewer.h:124
virtual void RemoveAll()
Remove all items from the container.
Definition: TGCanvas.cxx:638
const char * ScanList()
Return the cut entry.
TGPictureButton * fBGRecord
Definition: TTreeViewer.h:154
TTVRecord * Previous()
Definition: TTVSession.h:93
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
void Reset()
Reset the timer.
Definition: TTimer.cxx:157
virtual Int_t NumSelected() const
Definition: TGCanvas.h:116
void ExecuteDraw()
Called when the DRAW button is executed.
static const char * gOpt1D[12]
TGLayoutHints * fBarLayout
Definition: TTreeViewer.h:119
Collectable string class.
Definition: TObjString.h:32
float Float_t
Definition: RtypesCore.h:53
const TGPicture * fPicRefr
Definition: TTreeViewer.h:96
void SetRecordName(const char *name)
Set record name.
const char Option_t
Definition: RtypesCore.h:62
virtual Long64_t GetReadEntry() const
Definition: TTree.h:435
TTVLVEntry * EditedEntry()
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
void NewExpression()
Create new expression.
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
void PrintEntries()
Print the number of selected entries on status-bar.
REAL splitter
Definition: triangle.c:616
TGLabel * fLbl2
Definition: TTreeViewer.h:138
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
UInt_t GetWidth() const
Definition: TGFrame.h:287
void Draw3DCorner(Bool_t corner)
Definition: TGStatusBar.h:69
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1714
virtual void SetFrame(TGFrame *frame, Bool_t left)
Set frame to be resized.
Definition: TGSplitter.cxx:140
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
TGMenuBar * fMenuBar
Definition: TTreeViewer.h:108
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1102
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
const char * Ex()
Get the expression to be drawn on X axis.
#define gROOT
Definition: TROOT.h:364
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)
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu entry.
Definition: TGMenu.cxx:987
TGHProgressBar * fProgressBar
Definition: TTreeViewer.h:141
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
#define gInterpreter
Definition: TInterpreter.h:515
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
const char * fFilename
Definition: TTreeViewer.h:82
void MapOptions(Long_t parm1)
Scan the selected options from option menu.
void SelectItem(const char *name)
Select an item.
virtual void SetRange(Float_t min, Float_t max)
TGCheckButton * fBarRec
Definition: TTreeViewer.h:126
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
Int_t MakeSelector(const char *selector=0)
Get use of TTree::MakeSelector() via the context menu.
const char * EmptyBrackets(const char *name)
Empty the bracket content of a string.
void EditExpression()
Start the expression editor.
R__EXTERN const char gTVHelpContext[]
Definition: HelpTextTV.h:27
void GrabPointer()
Just focus the cursor inside.
void Message(const char *msg)
Send a message on the status bar.
TGLabel * fBarLbl1
Definition: TTreeViewer.h:121
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:5816
TList * fTreeList
Definition: TTreeViewer.h:92
virtual void Layout()
Layout list view components (container and contents of container).
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:311
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1057
Int_t GetEntries()
Definition: TTVSession.h:87
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
TGLabel * fBLbl4
Definition: TTreeViewer.h:142
virtual void Refresh()
Refresh contents of this tree and its branches from the current status on disk.
Definition: TTree.cxx:7338
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1037
const TGPicture * fPicStop
Definition: TTreeViewer.h:95
void RemoveLastRecord()
Remove current record from list.
Definition: TTVSession.cxx:222
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
TContextMenu * fContextMenu
Definition: TTreeViewer.h:90
const char * ConvertAliases()
Convert all aliases into true names.
TTVRecord * Last()
Definition: TTVSession.h:91
TGPopupMenu * fFileMenu
Definition: TTreeViewer.h:109
TGItemContext * GetContext()
TGPopupMenu * fOptionsGen
Definition: TTreeViewer.h:113
EButtonIdentifiers
virtual TList * GetListOfFriends() const
Definition: TTree.h:418
const char * Data() const
Definition: TString.h:349
TGListTreeItem * GetParent() const
Definition: TGListTree.h:79
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
TGPictureButton * fBGNext
Definition: TTreeViewer.h:155
const char * fSourceFile
Definition: TTreeViewer.h:83
void SetCurrentRecord(Long64_t entry)
Set current record.
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
virtual void Action(TObject *object, TMethod *method)
Action to be performed when this menu item is selected.
TGPopupMenu * fOptionsMenu
Definition: TTreeViewer.h:112
Sequenceable collection abstract base class.
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:526
virtual TObjArray * GetListOfBranches()
Definition: TTree.h:416
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:2335
void SetRecordName(const char *name)
Set record name.
Definition: TTVSession.cxx:209
const Int_t kSysError
Definition: TError.h:43
static const char * gMacroTypes[]
void SetUserCode(const char *code, Bool_t autoexec=kTRUE)
Definition: TTVSession.h:65
void ExecuteSpider()
Draw a spider plot for the selected entries.
static TGSelectBox * GetInstance()
Return the pointer to the instantiated singleton.
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
void DoError(int level, const char *location, const char *fmt, va_list va) const
Put error/warning into TMsgBox and also forward to console.
const char ** fFileTypes
Definition: TGFileDialog.h:65
TList * fWidgets
Definition: TTreeViewer.h:165
static const char * gOptgen[16]
Bool_t fCounting
Definition: TTreeViewer.h:100
const Int_t kFatal
Definition: TError.h:44
TTimer * fTimer
Definition: TTreeViewer.h:99
const char * GetText() const
Definition: TGTextEntry.h:140
virtual void AddThisItem(TTVLVEntry *item)
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:443
TGCompositeFrame(const TGCompositeFrame &)
TGToolBar * fToolBar
Definition: TTreeViewer.h:118
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1627
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:60
static const char * gOpt2D[14]
const Int_t kDoNotProcess
Definition: TBranch.h:52
TString & Append(const char *cs)
Definition: TString.h:492
std::vector< std::vector< double > > Data
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
const char * GetGrOpt()
Get graph option.
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:294
TObjArray * GetListOfBranches()
Definition: TBranch.h:178
void EmptyAll()
Clear all names and aliases for expression type items.
Bool_t HandleTimer(TTimer *timer)
This function is called by the fTimer object.
TString fLastOption
Definition: TTreeViewer.h:84
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text entry widget.
TGCompositeFrame * fListHdr
Definition: TTreeViewer.h:136
void SaveSource(std::ofstream &out)
Save the TTVSession in a C++ macro file.
Definition: TTVSession.cxx:253
Bool_t fVarDraw
Definition: TTreeViewer.h:88
TList * ExpressionList()
Get the list of expression items.
XFontStruct * id
Definition: TGX11.cxx:108
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
void RemoveNonStatic()
Remove all non-static items from the list view, except expressions.
TGTextEntry * fBarOption
Definition: TTreeViewer.h:128
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
const char * Ez()
Get the expression to be drawn on Z axis.
TGTextEntry * fBarCommand
Definition: TTreeViewer.h:127
R__EXTERN const char gTVHelpDrawing[]
Definition: HelpTextTV.h:28
TTVRecord * GetCurrent()
Definition: TTVSession.h:88
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition: TGCanvas.cxx:657
static const char * gOpenTypes[]
virtual void SetEventList(TEventList *list)
This function transfroms the given TEventList into a TEntryList The new TEntryList is owned by the TT...
Definition: TTree.cxx:8385
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:4868
virtual TFile * GetFile() const
Definition: TDirectory.h:155
void SetLabel(const char *title)
Set label of selection box.
TH1 * GetHistogram()
Definition: TTree.h:408
TGListView * fListView
Definition: TTreeViewer.h:162
void SetFile()
Set file name containing the tree.
R__EXTERN const char gTVHelpStart[]
Definition: HelpTextTV.h:20
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:91
std::string trueName(const char *typeDefName)
TTVLVContainer * fLVContainer
Definition: TTreeViewer.h:163
TGTextButton * fReset
Definition: TTreeViewer.h:157
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:1137
void SetUserData(void *userData)
Definition: TGListView.h:118
TGHorizontalFrame * fHpb
Definition: TTreeViewer.h:140
virtual void SendCloseMessage()
Send close message to self.
Definition: TGFrame.cxx:1702
EMouseButton
Definition: GuiTypes.h:215
I/O classes for TreeViewer session handling.
Definition: TTVSession.h:30
const Int_t kInfo
Definition: TError.h:39
Class to manage histogram axis.
Definition: TAxis.h:36
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2853
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:387
Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0)
Get use of TTree::Process() via the context menu.
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:176
virtual EButtonState GetState() const
Definition: TGButton.h:116
Int_t GET_SUBMSG(Long_t val)
void SetScanFileName(const char *name="")
Set the name of the file where to redirect <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.
TDirectory * GetDirectory() const
Definition: TTree.h:391
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:389
This class represent entries that goes into the TreeViewer listview container.
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:227
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
ERootTreeViewerCommands
const TGPicture * fPicX
Definition: TTreeViewer.h:94
Cursor_t fDefaultCursor
Definition: TTreeViewer.h:97
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
void SetSession(TTVSession *session)
Set current session.
unsigned int UInt_t
Definition: RtypesCore.h:42
TGCanvas * fTreeView
Definition: TTreeViewer.h:159
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
The most important graphics class in the ROOT system.
Definition: TPad.h:37
TList * ExpressionList()
Return the list of user-defined expressions.
const char * Cut()
Return the cut entry.
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
Definition: TObject.cxx:886
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:229
void RemoveLastRecord()
Remove the current record.
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TGPictureButton * fBGLast
Definition: TTreeViewer.h:156
TAxis * GetYaxis()
Definition: TH1.h:325
const std::string sname
Definition: testIO.cxx:45
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:658
const Int_t kWarning
Definition: TError.h:40
TTree * fMappedTree
Definition: TTreeViewer.h:85
TTreeViewer(const char *treeName=0)
TTreeViewer default constructor.
void SetHistogramTitle(const char *title)
Set title of Histogram.
Bool_t IsNull() const
Definition: TString.h:387
TGLayoutHints * fMenuBarHelpLayout
Definition: TTreeViewer.h:107
void ShowPosition(Bool_t set=kTRUE, Bool_t percent=kTRUE, const char *format="%.2f")
Show postion text, either in percent or formatted according format.
virtual void * GetUserData() const =0
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:2514
TGPictureButton * fBGFirst
Definition: TTreeViewer.h:152
Int_t GET_MSG(Long_t val)
R__EXTERN const char gTVHelpMacros[]
Definition: HelpTextTV.h:29
TGCheckButton * fBarScan
Definition: TTreeViewer.h:125
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Process this tree executing the TSelector code in the specified filename.
Definition: TTree.cxx:6881
TGLayoutHints * fMenuBarItemLayout
Definition: TTreeViewer.h:106
virtual const char * GetText() const =0
void SetAlias(const char *alias)
void SetViewer(TTreeViewer *viewer)
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:403
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
TGHorizontalFrame * fHf
Definition: TTreeViewer.h:131
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:309
virtual void CloseWindow()
Close the viewer.
TGTextEntry * fBarListOut
Definition: TTreeViewer.h:145
TGTextEntry * fBarHist
Definition: TTreeViewer.h:129
virtual const char * GetName() const
Returns name of object.
Definition: TTVSession.h:53
UInt_t GetListOfMethods(TList &methods, TDirectory *dir=0)
Definition: tmvaglob.cxx:581
#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:44
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:287
void SetPosition(Float_t pos)
Set progress position between [min,max].
void * GetUserData() const
Definition: TGListView.h:119
void SetSmallPic(const TGPicture *spic)
Set small picture.
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.
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
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
virtual TTree * GetTree() const
Definition: TTree.h:443
void ExecuteCommand(const char *command, Bool_t fast=kFALSE)
Execute all user commands.
Int_t GetNleaves() const
Definition: TBranch.h:181
TObjArray * GetListOfLeaves()
Definition: TBranch.h:179
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:494
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
TGLabel * fLbl1
Definition: TTreeViewer.h:137
Bool_t fEnableCut
Definition: TTreeViewer.h:102
void SetGrOpt(const char *option)
Set graph option.
TAxis * GetZaxis()
Definition: TH1.h:326
Mother of all ROOT objects.
Definition: TObject.h:44
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:6324
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition: TGMenu.cxx:1772
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:254
virtual void SetHeight(UInt_t h)
Definition: TGFrame.h:310
Bool_t fScanMode
Definition: TTreeViewer.h:89
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Definition: TDirectory.cxx:435
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
Definition: file.py:1
TTVRecord * AddRecord(Bool_t fromFile=kFALSE)
Add a record.
Definition: TTVSession.cxx:159
TTVLVEntry * ExpressionItem(Int_t index)
Return the expression item at specific position.
virtual void MapWindow()
Definition: TGFrame.h:267
TGClient * fClient
Definition: TGObject.h:41
A TFriendElement TF describes a TTree object TF in a file.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
const char * Ey()
Get the expression to be drawn on Y axis.
void MapTree(TTree *tree, TGListTreeItem *parent=0, Bool_t listIt=kTRUE)
Map current tree and expand its content (including friends) in the lists.
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:40
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
#define snprintf
Definition: civetweb.c:822
R__EXTERN const char gTVHelpUserCommands[]
Definition: HelpTextTV.h:26
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
#define gPad
Definition: TVirtualPad.h:289
virtual Float_t GetMinPosition() const
Definition: tree.py:1
virtual void SetTimerInterval(Int_t msec=333)
Definition: TTree.h:560
TGPictureButton * fDRAW
Definition: TTreeViewer.h:146
Int_t fTreeIndex
Definition: TTreeViewer.h:93
virtual Long64_t GetEntries() const
Definition: TTree.h:392
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TGVerticalFrame * fV1
Definition: TTreeViewer.h:133
const char * GetString() const
Definition: TGString.h:44
void EmptyAll()
Clear the content of all items in the list view.
TGSelectBox * fDialogBox
Definition: TTreeViewer.h:91
virtual Float_t GetMaxPosition() const
#define gDirectory
Definition: TDirectory.h:221
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:5984
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
R__EXTERN const char gTVHelpDraggingItems[]
Definition: HelpTextTV.h:23
Definition: first.py:1
R__EXTERN const char gTVHelpEditExpressions[]
Definition: HelpTextTV.h:24
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
Bool_t IsCut()
const char * ScanList()
returns scanlist
TGCompositeFrame * fTreeHdr
Definition: TTreeViewer.h:135
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition: TTreePlayer.h:43
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
virtual void AppendText(const char *text)
Appends text to the end of text entry, clears the selection and moves the cursor to the end of the li...
A TTree is a list of TBranches.
Definition: TBranch.h:58
void HighlightItem(TGListTreeItem *item)
Highlight item.
void Clear(Option_t *option="")
Clears up the text entry.
TGPopupMenu * fHelpMenu
Definition: TTreeViewer.h:116
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:101
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 TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:380
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:241
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:255
char name[80]
Definition: TGX11.cxx:109
void SetEntry(TTVLVEntry *entry)
Connect one entry.
TAxis * GetXaxis()
Definition: TH1.h:324
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:417
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:229
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185
This class represent the list view container for the.
R__EXTERN const char gTVHelpOpenSave[]
Definition: HelpTextTV.h:22
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:911