Logo ROOT   6.07/09
Reference Guide
SplitGLView.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Helper classes for the alice_esd_split.C demo.
4 ///
5 /// \macro_code
6 ///
7 /// \author Bertrand Bellenot
8 
9 #include "TApplication.h"
10 #include "TSystem.h"
11 #include "TGFrame.h"
12 #include "TGLayout.h"
13 #include "TGSplitter.h"
14 #include "TGLWidget.h"
15 #include "TEvePad.h"
16 #include "TGeoManager.h"
17 #include "TString.h"
18 #include "TGMenu.h"
19 #include "TGStatusBar.h"
20 #include "TGFileDialog.h"
21 #include "TGMsgBox.h"
22 #include "TGLPhysicalShape.h"
23 #include "TGLLogicalShape.h"
24 #include "HelpText.h"
25 #include "TClass.h"
26 #include "Riostream.h"
27 #include "TEnv.h"
28 #include "TGListTree.h"
29 #include "TOrdCollection.h"
30 #include "TArrayF.h"
31 #include "TGHtml.h"
32 #include "TPRegexp.h"
33 
34 #include "TEveManager.h"
35 #include "TEveViewer.h"
36 #include "TEveBrowser.h"
37 #include "TEveProjectionManager.h"
38 #include "TEveProjectionAxes.h"
39 #include "TEveScene.h"
40 #include "TEveGeoNode.h"
41 #include "TEveEventManager.h"
42 #include "TEveTrack.h"
43 #include "TEveSelection.h"
44 
45 #include "TRootEmbeddedCanvas.h"
46 #include "TGSplitFrame.h"
47 #include "TGLOverlayButton.h"
48 #include "TGLEmbeddedViewer.h"
49 #include "TGDockableFrame.h"
50 #include "TGShapedFrame.h"
51 #include "TGButton.h"
52 #include "TGTab.h"
53 #include "TEnv.h"
54 
55 #include "TCanvas.h"
56 #include "TFormula.h"
57 #include "TF1.h"
58 #include "TH1F.h"
59 
60 #ifdef WIN32
61 #include <TWin32SplashThread.h>
62 #endif
63 
64 const char *filetypes[] = {
65  "ROOT files", "*.root",
66  "All files", "*",
67  0, 0
68 };
69 
70 const char *rcfiletypes[] = {
71  "All files", "*",
72  0, 0
73 };
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 class TGShapedToolTip : public TGShapedFrame {
77 
78 private:
79  TGShapedToolTip(const TGShapedToolTip&); // Not implemented
80  TGShapedToolTip& operator=(const TGShapedToolTip&); // Not implemented
81 
82 protected:
83  Int_t fTextX, fTextY, fTextH;
84  TString fTextCol;
85 
86  TRootEmbeddedCanvas *fEc; // embedded canvas for histogram
87  TH1 *fHist; // user histogram
88  TString fText; // info (as tool tip) text
89 
90  virtual void DoRedraw() {}
91 
92 public:
93  TGShapedToolTip(const char *picname, Int_t cx=0, Int_t cy=0, Int_t cw=0,
94  Int_t ch=0, Int_t tx=0, Int_t ty=0, Int_t th=0,
95  const char *col="#ffffff");
96  virtual ~TGShapedToolTip();
97 
98  virtual void CloseWindow();
99  void CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch);
100  void CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints);
101  TH1 *GetHisto() const { return fHist; }
102  const char *GetText() const { return fText.Data(); }
103  void Refresh();
104  void SetHisto(TH1 *hist);
105  void SetText(const char *text);
106  void SetTextColor(const char *col);
107  void SetTextAttributes(Int_t tx, Int_t ty, Int_t th, const char *col=0);
108  void Show(Int_t x, Int_t y, const char *text = 0, TH1 *hist = 0);
109 
110  ClassDef(TGShapedToolTip, 0) // Shaped composite frame
111 };
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 class HtmlObjTable : public TObject {
115 public: // make them public for shorter code
116 
117  TString fName;
118  Int_t fNValues; // number of values
119  Int_t fNFields; // number of fields
120  TArrayF *fValues;
121  TString *fLabels;
122  Bool_t fExpand;
123 
124  TString fHtml; // HTML output code
125 
126  void Build();
127  void BuildTitle();
128  void BuildLabels();
129  void BuildTable();
130 
131 public:
132  HtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
133  virtual ~HtmlObjTable();
134 
135  void SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
136  void SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
137  TString Html() const { return fHtml; }
138 
139  ClassDef(HtmlObjTable, 0);
140 };
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 class HtmlSummary {
144 public: // make them public for shorter code
145  Int_t fNTables;
146  TOrdCollection *fObjTables; // ->array of object tables
147  TString fHtml; // output HTML string
148  TString fTitle; // page title
149  TString fHeader; // HTML header
150  TString fFooter; // HTML footer
151 
152  void MakeHeader();
153  void MakeFooter();
154 
155 public:
156  HtmlSummary(const char *title);
157  virtual ~HtmlSummary();
158 
159  HtmlObjTable *AddTable(const char *name, Int_t nfields, Int_t nvals,
160  Bool_t exp=kTRUE, Option_t *opt="");
161  HtmlObjTable *GetTable(Int_t at) const { return (HtmlObjTable *)fObjTables->At(at); }
162  void Build();
163  void Clear(Option_t *option="");
164  void Reset(Option_t *option="");
165  TString Html() const { return fHtml; }
166 
167  ClassDef(HtmlSummary, 0);
168 };
169 
170 ////////////////////////////////////////////////////////////////////////////////
171 class SplitGLView : public TGMainFrame {
172 
173 public:
174  enum EMyCommands {
176  kHelpAbout, kGLPerspYOZ, kGLPerspXOZ, kGLPerspXOY, kGLXOY,
177  kGLXOZ, kGLZOY, kGLOrthoRotate, kGLOrthoDolly, kSceneUpdate,
178  kSceneUpdateAll, kSummaryUpdate
179  };
180 
181 private:
182  TEvePad *fPad; // pad used as geometry container
183  TGSplitFrame *fSplitFrame; // main (first) split frame
184  TGLEmbeddedViewer *fViewer0; // main GL viewer
185  TGLEmbeddedViewer *fViewer1; // first GL viewer
186  TGLEmbeddedViewer *fViewer2; // second GL viewer
187  TGLEmbeddedViewer *fActViewer; // actual (active) GL viewer
188  static HtmlSummary *fgHtmlSummary; // summary HTML table
189  static TGHtml *fgHtml;
190  TGMenuBar *fMenuBar; // main menu bar
191  TGPopupMenu *fMenuFile; // 'File' popup menu
192  TGPopupMenu *fMenuHelp; // 'Help' popup menu
193  TGPopupMenu *fMenuCamera; // 'Camera' popup menu
194  TGPopupMenu *fMenuScene; // 'Scene' popup menu
195  TGStatusBar *fStatusBar; // status bar
196  TGShapedToolTip *fShapedToolTip; // shaped tooltip
197  Bool_t fIsEmbedded;
198 
199  TEveViewer *fViewer[3];
200  TEveProjectionManager *fRPhiMgr;
201  TEveProjectionManager *fRhoZMgr;
202 
203 public:
204  SplitGLView(const TGWindow *p=0, UInt_t w=800, UInt_t h=600, Bool_t embed=kFALSE);
205  virtual ~SplitGLView();
206 
207  void ItemClicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
208  void HandleMenu(Int_t id);
209  void OnClicked(TObject *obj);
210  void OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy);
211  void OnMouseOver(TGLPhysicalShape *shape);
212  void OnViewerActivated();
213  void OpenFile(const char *fname);
214  void SwapToMainView(TGLViewerBase *viewer);
215  void ToggleOrthoRotate();
216  void ToggleOrthoDolly();
217  void UnDock(TGLViewerBase *viewer);
218  void LoadConfig(const char *fname);
219  void SaveConfig(const char *fname);
220  static void UpdateSummary();
221 
222  TEveProjectionManager *GetRPhiMgr() const { return fRPhiMgr; }
223  TEveProjectionManager *GetRhoZMgr() const { return fRhoZMgr; }
224 
225  ClassDef(SplitGLView, 0)
226 };
227 
228 TEveProjectionManager *gRPhiMgr = 0;
229 TEveProjectionManager *gRhoZMgr = 0;
230 
231 ClassImp(TGShapedToolTip)
232 ClassImp(HtmlObjTable)
233 ClassImp(HtmlSummary)
234 ClassImp(SplitGLView)
235 
236 HtmlSummary *SplitGLView::fgHtmlSummary = 0;
237 TGHtml *SplitGLView::fgHtml = 0;
238 
239 //______________________________________________________________________________
240 TGShapedToolTip::TGShapedToolTip(const char *pname, Int_t cx, Int_t cy, Int_t cw,
241  Int_t ch, Int_t tx, Int_t ty, Int_t th,
242  const char *col) :
243  TGShapedFrame(pname, gClient->GetDefaultRoot(), 400, 300, kTempFrame |
244  kHorizontalFrame), fEc(0), fHist(0)
245 {
246  // Shaped window constructor
247 
248  fTextX = tx; fTextY = ty; fTextH = th;
249  if (col)
250  fTextCol = col;
251  else
252  fTextCol = "0x000000";
253 
254  // create the embedded canvas
255  if ((cx > 0) && (cy > 0) && (cw > 0) && (ch > 0)) {
256  Int_t lhRight = fWidth-cx-cw;
257  Int_t lhBottom = fHeight-cy-ch;
258  fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
259  AddFrame(fEc, new TGLayoutHints(kLHintsTop | kLHintsLeft, cx,
260  lhRight, cy, lhBottom));
261  }
262  MapSubwindows();
263  Resize();
264  Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
265 }
266 
267 //______________________________________________________________________________
268 TGShapedToolTip::~TGShapedToolTip()
269 {
270  // Destructor.
271 
272  if (fHist)
273  delete fHist;
274  if (fEc)
275  delete fEc;
276 }
277 
278 //______________________________________________________________________________
279 void TGShapedToolTip::CloseWindow()
280 {
281  // Close shaped window.
282 
283  DeleteWindow();
284 }
285 
286 //______________________________________________________________________________
287 void TGShapedToolTip::Refresh()
288 {
289  // Redraw the window with current attributes.
290 
291  const char *str = fText.Data();
292  char *string = strdup(str);
293  Int_t nlines = 0, size = fTextH;
294  TString fp = gEnv->GetValue("Root.TTFontPath", "");
295  TString ar = fp + "/arial.ttf";
296  char *s = strtok((char *)string, "\n");
297  TImage *img = (TImage*)fImage->Clone("img");
298  img->DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
299  while ((s = strtok(0, "\n"))) {
300  nlines++;
301  img->DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
302  }
303  img->PaintImage(fId, 0, 0, 0, 0, 0, 0, "opaque");
304  free(string);
305  delete img;
306  gVirtualX->Update();
307 }
308 
309 //______________________________________________________________________________
310 void TGShapedToolTip::CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch)
311 {
312 
313  // create the embedded canvas
314  Int_t lhRight = fWidth-cx-cw;
315  Int_t lhBottom = fHeight-cy-ch;
316  fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
317  AddFrame(fEc, new TGLayoutHints(kLHintsTop | kLHintsLeft, cx,
318  lhRight, cy, lhBottom));
319  MapSubwindows();
320  Resize();
321  Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
322  if (IsMapped()) {
323  Refresh();
324  }
325 }
326 
327 //______________________________________________________________________________
328 void TGShapedToolTip::CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints)
329 {
330  // Create the embedded canvas.
331 
332  fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
333  AddFrame(fEc, hints);
334  MapSubwindows();
335  Resize();
336  Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
337  if (IsMapped()) {
338  Refresh();
339  }
340 }
341 
342 //______________________________________________________________________________
343 void TGShapedToolTip::SetHisto(TH1 *hist)
344 {
345  // Set which histogram has to be displayed in the embedded canvas.
346 
347  if (hist) {
348  if (fHist) {
349  delete fHist;
350  if (fEc)
351  fEc->GetCanvas()->Clear();
352  }
353  fHist = (TH1 *)hist->Clone();
354  if (fEc) {
355  fEc->GetCanvas()->SetBorderMode(0);
356  fEc->GetCanvas()->SetFillColor(10);
357  fEc->GetCanvas()->cd();
358  fHist->Draw();
359  fEc->GetCanvas()->Update();
360  }
361  }
362 }
363 
364 //______________________________________________________________________________
365 void TGShapedToolTip::SetText(const char *text)
366 {
367  // Set which text has to be displayed.
368 
369  if (text) {
370  fText = text;
371  }
372  if (IsMapped())
373  Refresh();
374 }
375 
376 //______________________________________________________________________________
377 void TGShapedToolTip::SetTextColor(const char *col)
378 {
379  // Set text color.
380 
381  fTextCol = col;
382  if (IsMapped())
383  Refresh();
384 }
385 
386 //______________________________________________________________________________
387 void TGShapedToolTip::SetTextAttributes(Int_t tx, Int_t ty, Int_t th,
388  const char *col)
389 {
390  // Set text attributes (position, size and color).
391 
392  fTextX = tx; fTextY = ty; fTextH = th;
393  if (col)
394  fTextCol = col;
395  if (IsMapped())
396  Refresh();
397 }
398 
399 //______________________________________________________________________________
400 void TGShapedToolTip::Show(Int_t x, Int_t y, const char *text, TH1 *hist)
401 {
402  // Show (popup) the shaped window at location x,y and possibly
403  // set the text and histogram to be displayed.
404 
405  Move(x, y);
406  MapWindow();
407 
408  if (text)
409  SetText(text);
410  if (hist)
411  SetHisto(hist);
412  // end of demo code -------------------------------------------
413  if (fHist) {
414  fEc->GetCanvas()->SetBorderMode(0);
415  fEc->GetCanvas()->SetFillColor(10);
416  fEc->GetCanvas()->cd();
417  fHist->Draw();
418  fEc->GetCanvas()->Update();
419  }
420  Refresh();
421 }
422 
423 //______________________________________________________________________________
424 HtmlObjTable::HtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) :
425  fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
426 {
427  // Constructor.
428 
429  fValues = new TArrayF[fNFields];
430  for (int i=0;i<fNFields;i++)
431  fValues[i].Set(nvals);
432  fLabels = new TString[fNFields];
433 }
434 
435 //______________________________________________________________________________
436 HtmlObjTable::~HtmlObjTable()
437 {
438  // Destructor.
439 
440  delete [] fValues;
441  delete [] fLabels;
442 }
443 
444 //______________________________________________________________________________
445 void HtmlObjTable::Build()
446 {
447  // Build HTML code.
448 
449  fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
450 
451  BuildTitle();
452  if (fExpand && (fNFields > 0) && (fNValues > 0)) {
453  BuildLabels();
454  BuildTable();
455  }
456 
457  fHtml += "</table>";
458 }
459 
460 //______________________________________________________________________________
461 void HtmlObjTable::BuildTitle()
462 {
463  // Build table title.
464 
465  fHtml += "<tr><td colspan=";
466  fHtml += Form("%d>", fNFields+1);
467  fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
468  fHtml += "<tr><td align=left>";
469  fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
470  fHtml += fName;
471  fHtml += "</i></b></font></td>";
472  fHtml += "<td>";
473  fHtml += "<td align=right> ";
474  fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
475  fHtml += Form("Size = %d", fNValues);
476  fHtml += "</i></b></font></td></tr>";
477  fHtml += "</table>";
478  fHtml += "</td></tr>";
479 }
480 
481 //______________________________________________________________________________
482 void HtmlObjTable::BuildLabels()
483 {
484  // Build table labels.
485 
486  Int_t i;
487  fHtml += "<tr bgcolor=c0c0ff>";
488  fHtml += "<th> </th>"; // for the check boxes
489  for (i=0;i<fNFields;i++) {
490  fHtml += "<th> ";
491  fHtml += fLabels[i];
492  fHtml += " </th>"; // for the check boxes
493  }
494  fHtml += "</tr>";
495 }
496 
497 //______________________________________________________________________________
498 void HtmlObjTable::BuildTable()
499 {
500  // Build part of table with values.
501 
502  for (int i = 0; i < fNValues; i++) {
503  if (i%2)
504  fHtml += "<tr bgcolor=e0e0ff>";
505  else
506  fHtml += "<tr bgcolor=ffffff>";
507 
508  TString name = fName;
509  name.ReplaceAll(" ", "_");
510  // checkboxes
511  fHtml += "<td bgcolor=d0d0ff align=\"center\">";
512  fHtml += "<input type=\"checkbox\" name=\"";
513  fHtml += name;
514  fHtml += Form("[%d]\">",i);
515  fHtml += "</td>";
516 
517  for (int j = 0; j < fNFields; j++) {
518  fHtml += "<td width=";
519  fHtml += Form("%d%%", 100/fNFields);
520  fHtml += " align=\"center\"";
521  fHtml += ">";
522  fHtml += Form("%1.4f", fValues[j][i]);
523  fHtml += "</td>";
524  }
525  fHtml += "</tr> ";
526  }
527 }
528 
529 //______________________________________________________________________________
530 HtmlSummary::HtmlSummary(const char *title) : fNTables(0), fTitle(title)
531 {
532  // Constructor.
533 
534  fObjTables = new TOrdCollection();
535 }
536 
537 //______________________________________________________________________________
538 HtmlSummary::~HtmlSummary()
539 {
540  // Destructor.
541 
542  Reset();
543 }
544 
545 //______________________________________________________________________________
546 HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
547  Bool_t exp, Option_t *option)
548 {
549  // Add a new table in our list of tables.
550 
551  TString opt = option;
552  opt.ToLower();
553  HtmlObjTable *table = new HtmlObjTable(name, nfields, nvals, exp);
554  fNTables++;
555  if (opt.Contains("first"))
556  fObjTables->AddFirst(table);
557  else
558  fObjTables->Add(table);
559  return table;
560 }
561 
562 //______________________________________________________________________________
563 void HtmlSummary::Clear(Option_t *option)
564 {
565  // Clear the table list.
566 
567  if (option && option[0] == 'D')
568  fObjTables->Delete(option);
569  else
570  fObjTables->Clear(option);
571  fNTables = 0;
572 }
573 
574 //______________________________________________________________________________
576 {
577  // Reset (delete) the table list;
578 
579  delete fObjTables; fObjTables = 0;
580  fNTables = 0;
581 }
582 
583 //______________________________________________________________________________
584 void HtmlSummary::Build()
585 {
586  // Build the summary.
587 
588  MakeHeader();
589  for (int i=0;i<fNTables;i++) {
590  GetTable(i)->Build();
591  fHtml += GetTable(i)->Html();
592  }
593  MakeFooter();
594 }
595 
596 //______________________________________________________________________________
597 void HtmlSummary::MakeHeader()
598 {
599  // Make HTML header.
600 
601  fHeader = "<html><head><title>";
602  fHeader += fTitle;
603  fHeader += "</title></head><body>";
604  fHeader += "<center><h2><font color=#2222ee><i>";
605  fHeader += fTitle;
606  fHeader += "</i></font></h2></center>";
607  fHtml = fHeader;
608 }
609 
610 //______________________________________________________________________________
611 void HtmlSummary::MakeFooter()
612 {
613  // Make HTML footer.
614 
615  fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
616  fFooter += "Example of using Html widget to display tabular data";
617  fFooter += "<br>";
618  fFooter += "(c) 2007-2010 Bertrand Bellenot";
619  fFooter += "</font></strong></center></body></html>";
620  fHtml += fFooter;
621 }
622 
623 //______________________________________________________________________________
624 SplitGLView::SplitGLView(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
625  TGMainFrame(p, w, h), fActViewer(0), fShapedToolTip(0), fIsEmbedded(embed)
626 {
627  // Main frame constructor.
628 
629  TGSplitFrame *frm;
630  TEveScene *s = 0;
631  TGHorizontalFrame *hfrm;
632  TGDockableFrame *dfrm;
633  TGPictureButton *button;
634 
635  // create the "file" popup menu
636  fMenuFile = new TGPopupMenu(gClient->GetRoot());
637  fMenuFile->AddEntry("&Open...", kFileOpen);
638  fMenuFile->AddSeparator();
639  fMenuFile->AddEntry( "&Update Summary", kSummaryUpdate);
640  fMenuFile->AddSeparator();
641  fMenuFile->AddEntry("&Load Config...", kFileLoadConfig);
642  fMenuFile->AddEntry("&Save Config...", kFileSaveConfig);
643  fMenuFile->AddSeparator();
644  fMenuFile->AddEntry("E&xit", kFileExit);
645 
646  // create the "camera" popup menu
647  fMenuCamera = new TGPopupMenu(gClient->GetRoot());
648  fMenuCamera->AddEntry("Perspective (Floor XOZ)", kGLPerspXOZ);
649  fMenuCamera->AddEntry("Perspective (Floor YOZ)", kGLPerspYOZ);
650  fMenuCamera->AddEntry("Perspective (Floor XOY)", kGLPerspXOY);
651  fMenuCamera->AddEntry("Orthographic (XOY)", kGLXOY);
652  fMenuCamera->AddEntry("Orthographic (XOZ)", kGLXOZ);
653  fMenuCamera->AddEntry("Orthographic (ZOY)", kGLZOY);
654  fMenuCamera->AddSeparator();
655  fMenuCamera->AddEntry("Ortho allow rotate", kGLOrthoRotate);
656  fMenuCamera->AddEntry("Ortho allow dolly", kGLOrthoDolly);
657 
658  fMenuScene = new TGPopupMenu(gClient->GetRoot());
659  fMenuScene->AddEntry("&Update Current", kSceneUpdate);
660  fMenuScene->AddEntry("Update &All", kSceneUpdateAll);
661 
662  // create the "help" popup menu
663  fMenuHelp = new TGPopupMenu(gClient->GetRoot());
664  fMenuHelp->AddEntry("&About", kHelpAbout);
665 
666  // create the main menu bar
667  fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
668  fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop |
669  kLHintsLeft, 0, 4, 0, 0));
670  fMenuBar->AddPopup("&Camera", fMenuCamera, new TGLayoutHints(kLHintsTop |
671  kLHintsLeft, 0, 4, 0, 0));
672  fMenuBar->AddPopup("&Scene", fMenuScene, new TGLayoutHints(kLHintsTop |
673  kLHintsLeft, 0, 4, 0, 0));
674  fMenuBar->AddPopup("&Help", fMenuHelp, new TGLayoutHints(kLHintsTop |
675  kLHintsRight));
676 
677  AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
678 
679  // connect menu signals to our menu handler slot
680  fMenuFile->Connect("Activated(Int_t)", "SplitGLView", this,
681  "HandleMenu(Int_t)");
682  fMenuCamera->Connect("Activated(Int_t)", "SplitGLView", this,
683  "HandleMenu(Int_t)");
684  fMenuScene->Connect("Activated(Int_t)", "SplitGLView", this,
685  "HandleMenu(Int_t)");
686  fMenuHelp->Connect("Activated(Int_t)", "SplitGLView", this,
687  "HandleMenu(Int_t)");
688 
689  if (fIsEmbedded && gEve) {
690  // use status bar from the browser
691  fStatusBar = gEve->GetBrowser()->GetStatusBar();
692  }
693  else {
694  // create the status bar
695  Int_t parts[] = {45, 15, 10, 30};
696  fStatusBar = new TGStatusBar(this, 50, 10);
697  fStatusBar->SetParts(parts, 4);
698  AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
699  0, 0, 10, 0));
700  }
701 
702  // create eve pad (our geometry container)
703  fPad = new TEvePad();
704  fPad->SetFillColor(kBlack);
705 
706  // create the split frames
707  fSplitFrame = new TGSplitFrame(this, 800, 600);
708  AddFrame(fSplitFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
709  // split it once
710  fSplitFrame->HSplit(434);
711  // then split each part again (this will make four parts)
712  fSplitFrame->GetSecond()->VSplit(266);
713  fSplitFrame->GetSecond()->GetSecond()->VSplit(266);
714 
715  TGLOverlayButton *but1, *but2, *but3, *but4, *but5, *but6;
716  // get top (main) split frame
717  frm = fSplitFrame->GetFirst();
718  frm->SetName("Main_View");
719 
720  // create (embed) a GL viewer inside
721  fViewer0 = new TGLEmbeddedViewer(frm, fPad);
722  but1 = new TGLOverlayButton(fViewer0, "Swap", 10.0, -10.0, 55.0, 16.0);
723  but1->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
724  but2 = new TGLOverlayButton(fViewer0, "Undock", 70.0, -10.0, 55.0, 16.0);
725  but2->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
726  frm->AddFrame(fViewer0->GetFrame(), new TGLayoutHints(kLHintsExpandX |
727  kLHintsExpandY));
728  // set the camera to perspective (XOZ) for this viewer
729  fViewer0->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
730  // connect signal we are interested to
731  fViewer0->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
732  "OnMouseOver(TGLPhysicalShape*)");
733  fViewer0->Connect("Activated()", "SplitGLView", this,
734  "OnViewerActivated()");
735  fViewer0->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
736  "SplitGLView", this,
737  "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
738  fViewer0->Connect("Clicked(TObject*)", "SplitGLView", this,
739  "OnClicked(TObject*)");
740  fViewer[0] = new TEveViewer("SplitGLViewer[0]");
741  fViewer[0]->SetGLViewer(fViewer0, fViewer0->GetFrame());
742  fViewer[0]->IncDenyDestroy();
743  if (fIsEmbedded && gEve) {
744  fViewer[0]->AddScene(gEve->GetGlobalScene());
745  fViewer[0]->AddScene(gEve->GetEventScene());
746  gEve->GetViewers()->AddElement(fViewer[0]);
747  s = gEve->SpawnNewScene("Rho-Z Projection");
748  // projections
750  s->AddElement(fRhoZMgr);
751  gEve->AddToListTree(fRhoZMgr, kTRUE);
752  TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
753  s->AddElement(a);
754  }
755 
756  // get bottom left split frame
757  frm = fSplitFrame->GetSecond()->GetFirst();
758  frm->SetName("Bottom_Left");
759 
760  // create (embed) a GL viewer inside
761  fViewer1 = new TGLEmbeddedViewer(frm, fPad);
762  but3 = new TGLOverlayButton(fViewer1, "Swap", 10.0, -10.0, 55.0, 16.0);
763  but3->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
764  but4 = new TGLOverlayButton(fViewer1, "Undock", 70.0, -10.0, 55.0, 16.0);
765  but4->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
766  frm->AddFrame(fViewer1->GetFrame(), new TGLayoutHints(kLHintsExpandX |
767  kLHintsExpandY));
768 
769  // set the camera to orthographic (XOY) for this viewer
770  fViewer1->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
771  // connect signal we are interested to
772  fViewer1->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
773  "OnMouseOver(TGLPhysicalShape*)");
774  fViewer1->Connect("Activated()", "SplitGLView", this,
775  "OnViewerActivated()");
776  fViewer1->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
777  "SplitGLView", this,
778  "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
779  fViewer1->Connect("Clicked(TObject*)", "SplitGLView", this,
780  "OnClicked(TObject*)");
781  fViewer[1] = new TEveViewer("SplitGLViewer[1]");
782  fViewer[1]->SetGLViewer(fViewer1, fViewer1->GetFrame());
783  fViewer[1]->IncDenyDestroy();
784  if (fIsEmbedded && gEve) {
785  fRhoZMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
786  fRhoZMgr->ImportElements((TEveElement *)gEve->GetEventScene());
787  fViewer[1]->AddScene(s);
788  gEve->GetViewers()->AddElement(fViewer[1]);
789  gRhoZMgr = fRhoZMgr;
790 
791  s = gEve->SpawnNewScene("R-Phi Projection");
792  // projections
794  s->AddElement(fRPhiMgr);
795  gEve->AddToListTree(fRPhiMgr, kTRUE);
796  TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
797  s->AddElement(a);
798  }
799 
800  // get bottom center split frame
801  frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
802  frm->SetName("Bottom_Center");
803 
804  // create (embed) a GL viewer inside
805  fViewer2 = new TGLEmbeddedViewer(frm, fPad);
806  but5 = new TGLOverlayButton(fViewer2, "Swap", 10.0, -10.0, 55.0, 16.0);
807  but5->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
808  but6 = new TGLOverlayButton(fViewer2, "Undock", 70.0, -10.0, 55.0, 16.0);
809  but6->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
810  frm->AddFrame(fViewer2->GetFrame(), new TGLayoutHints(kLHintsExpandX |
811  kLHintsExpandY));
812 
813  // set the camera to orthographic (XOY) for this viewer
814  fViewer2->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
815  // connect signal we are interested to
816  fViewer2->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
817  "OnMouseOver(TGLPhysicalShape*)");
818  fViewer2->Connect("Activated()", "SplitGLView", this,
819  "OnViewerActivated()");
820  fViewer2->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
821  "SplitGLView", this,
822  "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
823  fViewer2->Connect("Clicked(TObject*)", "SplitGLView", this,
824  "OnClicked(TObject*)");
825  fViewer[2] = new TEveViewer("SplitGLViewer[2]");
826  fViewer[2]->SetGLViewer(fViewer2, fViewer2->GetFrame());
827  fViewer[2]->IncDenyDestroy();
828  if (fIsEmbedded && gEve) {
829  fRPhiMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
830  fRPhiMgr->ImportElements((TEveElement *)gEve->GetEventScene());
831  fViewer[2]->AddScene(s);
832  gEve->GetViewers()->AddElement(fViewer[2]);
833  gRPhiMgr = fRPhiMgr;
834  }
835 
836  // get bottom right split frame
837  frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
838  frm->SetName("Bottom_Right");
839 
840  dfrm = new TGDockableFrame(frm);
841  dfrm->SetFixedSize(kFALSE);
842  dfrm->EnableHide(kFALSE);
843  hfrm = new TGHorizontalFrame(dfrm);
844  button= new TGPictureButton(hfrm, gClient->GetPicture("swap.png"));
845  button->SetToolTipText("Swap to big view");
846  hfrm->AddFrame(button);
847  button->Connect("Clicked()","SplitGLView",this,"SwapToMainView(TGLViewerBase*=0)");
848  fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table");
849  fgHtml = new TGHtml(hfrm, 100, 100, -1);
850  hfrm->AddFrame(fgHtml, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
853 
854  if (fIsEmbedded && gEve) {
855  gEve->GetListTree()->Connect("Clicked(TGListTreeItem*, Int_t, Int_t, Int_t)",
856  "SplitGLView", this, "ItemClicked(TGListTreeItem*, Int_t, Int_t, Int_t)");
857  }
858 
859  fShapedToolTip = new TGShapedToolTip("Default.png", 120, 22, 160, 110,
860  23, 115, 12, "#ffff80");
861  Resize(GetDefaultSize());
862  MapSubwindows();
863  MapWindow();
864  LoadConfig(".everc");
865 }
866 
867 //______________________________________________________________________________
868 SplitGLView::~SplitGLView()
869 {
870  // Clean up main frame...
871  //Cleanup();
872 
873  fMenuFile->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
874  fMenuCamera->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
875  fMenuScene->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
876  fMenuHelp->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
877  fViewer0->Disconnect("MouseOver(TGLPhysicalShape*)", this,
878  "OnMouseOver(TGLPhysicalShape*)");
879  fViewer0->Disconnect("Activated()", this, "OnViewerActivated()");
880  fViewer0->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
881  this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
882  fViewer1->Disconnect("MouseOver(TGLPhysicalShape*)", this,
883  "OnMouseOver(TGLPhysicalShape*)");
884  fViewer1->Disconnect("Activated()", this, "OnViewerActivated()");
885  fViewer1->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
886  this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
887  fViewer2->Disconnect("MouseOver(TGLPhysicalShape*)", this,
888  "OnMouseOver(TGLPhysicalShape*)");
889  fViewer2->Disconnect("Activated()", this, "OnViewerActivated()");
890  fViewer2->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
891  this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
892  if (!fIsEmbedded) {
893  delete fViewer[0];
894  delete fViewer[1];
895  delete fViewer[2];
896  }
897  delete fShapedToolTip;
898  delete fMenuFile;
899  delete fMenuScene;
900  delete fMenuCamera;
901  delete fMenuHelp;
902  if (!fIsEmbedded)
903  delete fMenuBar;
904  delete fViewer0;
905  delete fViewer1;
906  delete fViewer2;
907  delete fSplitFrame;
908  delete fPad;
909  if (!fIsEmbedded) {
910  delete fStatusBar;
912  }
913 }
914 
915 //______________________________________________________________________________
916 void SplitGLView::HandleMenu(Int_t id)
917 {
918  // Handle menu items.
919 
920  static TString rcdir(".");
921  static TString rcfile(".everc");
922 
923  switch (id) {
924 
925  case kFileOpen:
926  {
927  static TString dir(".");
928  TGFileInfo fi;
929  fi.fFileTypes = filetypes;
930  fi.fIniDir = StrDup(dir);
931  new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
932  if (fi.fFilename)
933  OpenFile(fi.fFilename);
934  dir = fi.fIniDir;
935  }
936  break;
937 
938  case kFileLoadConfig:
939  {
940  TGFileInfo fi;
941  fi.fFileTypes = rcfiletypes;
942  fi.fIniDir = StrDup(rcdir);
943  fi.fFilename = StrDup(rcfile);
944  new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
945  if (fi.fFilename) {
946  rcfile = fi.fFilename;
947  LoadConfig(fi.fFilename);
948  }
949  rcdir = fi.fIniDir;
950  }
951  break;
952 
953  case kFileSaveConfig:
954  {
955  TGFileInfo fi;
956  fi.fFileTypes = rcfiletypes;
957  fi.fIniDir = StrDup(rcdir);
958  fi.fFilename = StrDup(rcfile);
959  new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
960  if (fi.fFilename) {
961  rcfile = fi.fFilename;
962  SaveConfig(fi.fFilename);
963  }
964  rcdir = fi.fIniDir;
965  }
966  break;
967 
968  case kFileExit:
969  CloseWindow();
970  break;
971 
972  case kGLPerspYOZ:
973  if (fActViewer)
974  fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspYOZ);
975  break;
976  case kGLPerspXOZ:
977  if (fActViewer)
978  fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
979  break;
980  case kGLPerspXOY:
981  if (fActViewer)
982  fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
983  break;
984  case kGLXOY:
985  if (fActViewer)
986  fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
987  break;
988  case kGLXOZ:
989  if (fActViewer)
990  fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOZ);
991  break;
992  case kGLZOY:
993  if (fActViewer)
994  fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
995  break;
996  case kGLOrthoRotate:
997  ToggleOrthoRotate();
998  break;
999  case kGLOrthoDolly:
1000  ToggleOrthoDolly();
1001  break;
1002 
1003  case kSceneUpdate:
1004  if (fActViewer)
1005  fActViewer->UpdateScene();
1006  UpdateSummary();
1007  break;
1008 
1009  case kSceneUpdateAll:
1010  fViewer0->UpdateScene();
1011  fViewer1->UpdateScene();
1012  fViewer2->UpdateScene();
1013  UpdateSummary();
1014  break;
1015 
1016  case kSummaryUpdate:
1017  UpdateSummary();
1018  break;
1019 
1020  case kHelpAbout:
1021  {
1022 #ifdef R__UNIX
1023  TString rootx;
1024 # ifdef ROOTBINDIR
1025  rootx = ROOTBINDIR;
1026 # else
1027  rootx = gSystem->Getenv("ROOTSYS");
1028  if (!rootx.IsNull()) rootx += "/bin";
1029 # endif
1030  rootx += "/root -a &";
1031  gSystem->Exec(rootx);
1032 #else
1033 #ifdef WIN32
1035 #else
1036  char str[32];
1037  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1038  hd = new TRootHelpDialog(this, str, 600, 400);
1039  hd->SetText(gHelpAbout);
1040  hd->Popup();
1041 #endif
1042 #endif
1043  }
1044  break;
1045 
1046  default:
1047  break;
1048  }
1049 }
1050 
1051 //______________________________________________________________________________
1052 void SplitGLView::OnClicked(TObject *obj)
1053 {
1054  // Handle click events in GL viewer
1055 
1056  if (obj)
1057  fStatusBar->SetText(Form("User clicked on: \"%s\"", obj->GetName()), 1);
1058  else
1059  fStatusBar->SetText("", 1);
1060 }
1061 
1062 //______________________________________________________________________________
1063 void SplitGLView::OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy)
1064 {
1065  // Slot used to handle "OnMouseIdle" signal coming from any GL viewer.
1066  // We receive a pointer on the physical shape in which the mouse cursor is
1067  // and the actual cursor position (x,y)
1068 
1069  Window_t wtarget;
1070  Int_t x = 0, y = 0;
1071 
1072  static TH1F *h1f = 0;
1073  TFormula *form1 = new TFormula("form1","abs(sin(x)/x)");
1074  form1->Update(); // silent warning about unused variable...
1075  TF1 *sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
1076  sqroot->SetParameters(10,4,1,20);
1077  if (h1f == 0)
1078  h1f = new TH1F("h1f","",50,0,10);
1079  h1f->Reset();
1080  h1f->SetFillColor(45);
1081  h1f->SetStats(0);
1082  h1f->FillRandom("sqroot",200);
1083 
1084  if (fShapedToolTip) {
1085  fShapedToolTip->UnmapWindow();
1086  }
1087  if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal()) {
1088  // get the actual viewer who actually emitted the signal
1089  TGLEmbeddedViewer *actViewer = dynamic_cast<TGLEmbeddedViewer*>((TQObject*)gTQSender);
1090  // then translate coordinates from the root (screen) coordinates
1091  // to the actual frame (viewer) ones
1092  gVirtualX->TranslateCoordinates(actViewer->GetFrame()->GetId(),
1093  gClient->GetDefaultRoot()->GetId(), posx, posy, x, y,
1094  wtarget);
1095  // Then display our tooltip at this x,y location
1096  if (fShapedToolTip) {
1097  fShapedToolTip->Show(x+5, y+5, Form("%s\n \n%s",
1098  shape->GetLogical()->GetExternal()->IsA()->GetName(),
1099  shape->GetLogical()->GetExternal()->GetName()), h1f);
1100  }
1101  }
1102 }
1103 
1104 //______________________________________________________________________________
1105 void SplitGLView::OnMouseOver(TGLPhysicalShape *shape)
1106 {
1107  // Slot used to handle "OnMouseOver" signal coming from any GL viewer.
1108  // We receive a pointer on the physical shape in which the mouse cursor is.
1109 
1110  // display information on the physical shape in the status bar
1111  if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal())
1112  fStatusBar->SetText(Form("Mouse Over: \"%s\"",
1113  shape->GetLogical()->GetExternal()->GetName()), 0);
1114  else
1115  fStatusBar->SetText("", 0);
1116 }
1117 
1118 //______________________________________________________________________________
1119 void SplitGLView::OnViewerActivated()
1120 {
1121  // Slot used to handle "Activated" signal coming from any GL viewer.
1122  // Used to know which GL viewer is active.
1123 
1124  static Pixel_t green = 0;
1125  // set the actual GL viewer frame to default color
1126  if (fActViewer && fActViewer->GetFrame())
1127  fActViewer->GetFrame()->ChangeBackground(GetDefaultFrameBackground());
1128 
1129  // change the actual GL viewer to the one who emitted the signal
1130  // fActViewer = (TGLEmbeddedViewer *)gTQSender;
1131  fActViewer = dynamic_cast<TGLEmbeddedViewer*>((TQObject*)gTQSender);
1132 
1133  if (fActViewer == 0) {
1134  printf ("dyncast failed ...\n");
1135  return;
1136  }
1137 
1138  // get the highlight color (only once)
1139  if (green == 0) {
1140  gClient->GetColorByName("green", green);
1141  }
1142  // set the new actual GL viewer frame to highlight color
1143  if (fActViewer->GetFrame())
1144  fActViewer->GetFrame()->ChangeBackground(green);
1145 
1146  // update menu entries to match actual viewer's options
1147  if (fActViewer->GetOrthoXOYCamera()->GetDollyToZoom() &&
1148  fActViewer->GetOrthoXOZCamera()->GetDollyToZoom() &&
1149  fActViewer->GetOrthoZOYCamera()->GetDollyToZoom())
1150  fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1151  else
1152  fMenuCamera->CheckEntry(kGLOrthoDolly);
1153 
1154  if (fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1155  fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1156  fActViewer->GetOrthoXOYCamera()->GetEnableRotate())
1157  fMenuCamera->CheckEntry(kGLOrthoRotate);
1158  else
1159  fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1160 }
1161 
1162 //______________________________________________________________________________
1163 void SplitGLView::OpenFile(const char *fname)
1164 {
1165  // Open a Root file to display a geometry in the GL viewers.
1166 
1167  TString filename = fname;
1168  // check if the file type is correct
1169  if (!filename.EndsWith(".root")) {
1170  new TGMsgBox(gClient->GetRoot(), this, "OpenFile",
1171  Form("The file \"%s\" is not a root file!", fname),
1173  return;
1174  }
1175  // check if the root file contains a geometry
1176  if (TGeoManager::Import(fname) == 0) {
1177  new TGMsgBox(gClient->GetRoot(), this, "OpenFile",
1178  Form("The file \"%s\" does't contain a geometry", fname),
1180  return;
1181  }
1183  // delete previous primitives (if any)
1184  fPad->GetListOfPrimitives()->Delete();
1185  // and add the geometry to eve pad (container)
1186  fPad->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume());
1187  // paint the geometry in each GL viewer
1188  fViewer0->PadPaint(fPad);
1189  fViewer1->PadPaint(fPad);
1190  fViewer2->PadPaint(fPad);
1191 }
1192 
1193 //______________________________________________________________________________
1194 void SplitGLView::ToggleOrthoRotate()
1195 {
1196  // Toggle state of the 'Ortho allow rotate' menu entry.
1197 
1198  if (fMenuCamera->IsEntryChecked(kGLOrthoRotate))
1199  fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1200  else
1201  fMenuCamera->CheckEntry(kGLOrthoRotate);
1202  Bool_t state = fMenuCamera->IsEntryChecked(kGLOrthoRotate);
1203  if (fActViewer) {
1204  fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1205  fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1206  fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1207  }
1208 }
1209 
1210 //______________________________________________________________________________
1211 void SplitGLView::ToggleOrthoDolly()
1212 {
1213  // Toggle state of the 'Ortho allow dolly' menu entry.
1214 
1215  if (fMenuCamera->IsEntryChecked(kGLOrthoDolly))
1216  fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1217  else
1218  fMenuCamera->CheckEntry(kGLOrthoDolly);
1219  Bool_t state = ! fMenuCamera->IsEntryChecked(kGLOrthoDolly);
1220  if (fActViewer) {
1221  fActViewer->GetOrthoXOYCamera()->SetDollyToZoom(state);
1222  fActViewer->GetOrthoXOZCamera()->SetDollyToZoom(state);
1223  fActViewer->GetOrthoZOYCamera()->SetDollyToZoom(state);
1224  }
1225 }
1226 
1227 //______________________________________________________________________________
1228 void SplitGLView::ItemClicked(TGListTreeItem *item, Int_t, Int_t, Int_t)
1229 {
1230  // Item has been clicked, based on mouse button do:
1231 
1232  static const TEveException eh("SplitGLView::ItemClicked ");
1233  TEveElement* re = (TEveElement*)item->GetUserData();
1234  if(re == 0) return;
1235  TObject* obj = re->GetObject(eh);
1236  if (obj->InheritsFrom("TEveViewer")) {
1237  TGLViewer *v = ((TEveViewer *)obj)->GetGLViewer();
1238  //v->Activated();
1239  if (v->InheritsFrom("TGLEmbeddedViewer")) {
1241  gVirtualX->SetInputFocus(ev->GetGLWidget()->GetId());
1242  }
1243  }
1244 }
1245 
1246 //______________________________________________________________________________
1247 void SplitGLView::LoadConfig(const char *fname)
1248 {
1249 
1250  Int_t height, width;
1251  TEnv *env = new TEnv(fname);
1252 
1253  Int_t mainheight = env->GetValue("MainView.Height", 434);
1254  Int_t blwidth = env->GetValue("Bottom.Left.Width", 266);
1255  Int_t bcwidth = env->GetValue("Bottom.Center.Width", 266);
1256  Int_t brwidth = env->GetValue("Bottom.Right.Width", 266);
1257  Int_t top_height = env->GetValue("Right.Tab.Height", 0);
1258  Int_t bottom_height = env->GetValue("Bottom.Tab.Height", 0);
1259 
1260  if (fIsEmbedded && gEve) {
1261  Int_t sel = env->GetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1262  Int_t hi = env->GetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1263  gEve->GetBrowser()->EveMenu(9+sel);
1264  gEve->GetBrowser()->EveMenu(13+hi);
1265 
1266  width = env->GetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1267  height = env->GetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1268  gEve->GetBrowser()->Resize(width, height);
1269  }
1270 
1271  // top (main) split frame
1272  width = fSplitFrame->GetFirst()->GetWidth();
1273  fSplitFrame->GetFirst()->Resize(width, mainheight);
1274  // bottom left split frame
1275  height = fSplitFrame->GetSecond()->GetFirst()->GetHeight();
1276  fSplitFrame->GetSecond()->GetFirst()->Resize(blwidth, height);
1277  // bottom center split frame
1278  height = fSplitFrame->GetSecond()->GetSecond()->GetFirst()->GetHeight();
1279  fSplitFrame->GetSecond()->GetSecond()->GetFirst()->Resize(bcwidth, height);
1280  // bottom right split frame
1281  height = fSplitFrame->GetSecond()->GetSecond()->GetSecond()->GetHeight();
1282  fSplitFrame->GetSecond()->GetSecond()->GetSecond()->Resize(brwidth, height);
1283 
1284  fSplitFrame->Layout();
1285 
1286  if (fIsEmbedded && gEve) {
1287  width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetWidth();
1288  ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->Resize(width, bottom_height);
1289  width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetWidth();
1290  ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->Resize(width, top_height);
1291  }
1292 }
1293 
1294 //______________________________________________________________________________
1295 void SplitGLView::SaveConfig(const char *fname)
1296 {
1297 
1298  Int_t bottom_height = 0;
1299  Int_t top_height = 0;
1300  TGSplitFrame *frm;
1301  TEnv *env = new TEnv(fname);
1302 
1303  if (fIsEmbedded && gEve) {
1304  env->SetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1305  env->SetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1306  }
1307  // get top (main) split frame
1308  frm = fSplitFrame->GetFirst();
1309  env->SetValue("MainView.Height", (Int_t)frm->GetHeight());
1310  // get bottom left split frame
1311  frm = fSplitFrame->GetSecond()->GetFirst();
1312  env->SetValue("Bottom.Left.Width", (Int_t)frm->GetWidth());
1313  // get bottom center split frame
1314  frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
1315  env->SetValue("Bottom.Center.Width", (Int_t)frm->GetWidth());
1316  // get bottom right split frame
1317  frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
1318  env->SetValue("Bottom.Right.Width", (Int_t)frm->GetWidth());
1319  if (fIsEmbedded && gEve) {
1320  top_height = (Int_t)((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetHeight();
1321  env->SetValue("Right.Tab.Height", top_height);
1322  bottom_height = (Int_t)((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetHeight();
1323  env->SetValue("Bottom.Tab.Height", bottom_height);
1324 
1325  env->SetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1326  env->SetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1327  }
1328 
1329  env->SaveLevel(kEnvLocal);
1330 #ifdef R__WIN32
1331  if (!gSystem->AccessPathName(Form("%s.new", fname))) {
1332  gSystem->Exec(Form("del %s", fname));
1333  gSystem->Rename(Form("%s.new", fname), fname);
1334  }
1335 #endif
1336 }
1337 
1338 //______________________________________________________________________________
1339 void SplitGLView::SwapToMainView(TGLViewerBase *viewer)
1340 {
1341  // Swap frame embedded in a splitframe to the main view (slot method).
1342 
1343  TGCompositeFrame *parent = 0;
1344  if (!fSplitFrame->GetFirst()->GetFrame())
1345  return;
1346  if (viewer == 0) {
1348  parent = (TGCompositeFrame *)src->GetParent();
1349  while (parent && !parent->InheritsFrom("TGSplitFrame")) {
1350  parent = (TGCompositeFrame *)parent->GetParent();
1351  }
1352  }
1353  else {
1354  TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1355  if (!src) return;
1357  but->ResetState();
1358  parent = (TGCompositeFrame *)src->GetParent();
1359  }
1360  if (parent && parent->InheritsFrom("TGSplitFrame"))
1361  ((TGSplitFrame *)parent)->SwitchToMain();
1362 }
1363 
1364 //______________________________________________________________________________
1365 void SplitGLView::UnDock(TGLViewerBase *viewer)
1366 {
1367  // Undock frame embedded in a splitframe (slot method).
1368 
1369  TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1370  if (!src) return;
1372  but->ResetState();
1373  TGCompositeFrame *parent = (TGCompositeFrame *)src->GetParent();
1374  if (parent && parent->InheritsFrom("TGSplitFrame"))
1375  ((TGSplitFrame *)parent)->ExtractFrame();
1376 }
1377 
1378 //______________________________________________________________________________
1379 void SplitGLView::UpdateSummary()
1380 {
1381  // Update summary of current event.
1382 
1385  Int_t k;
1386  TEveElement *el;
1387  HtmlObjTable *table;
1388  TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
1389  if (mgr) {
1390  fgHtmlSummary->Clear("D");
1391  for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) {
1392  el = ((TEveElement*)(*i));
1393  if (el->IsA() == TEvePointSet::Class()) {
1394  TEvePointSet *ps = (TEvePointSet *)el;
1395  TString ename = ps->GetElementName();
1396  TString etitle = ps->GetElementTitle();
1397  if (ename.First('\'') != kNPOS)
1398  ename.Remove(ename.First('\''));
1399  etitle.Remove(0, 2);
1400  Int_t nel = atoi(etitle.Data());
1401  table = fgHtmlSummary->AddTable(ename, 0, nel);
1402  }
1403  else if (el->IsA() == TEveTrackList::Class()) {
1404  TEveTrackList *tracks = (TEveTrackList *)el;
1405  TString ename = tracks->GetElementName();
1406  if (ename.First('\'') != kNPOS)
1407  ename.Remove(ename.First('\''));
1408  table = fgHtmlSummary->AddTable(ename.Data(), 5,
1409  tracks->NumChildren(), kTRUE, "first");
1410  table->SetLabel(0, "Momentum");
1411  table->SetLabel(1, "P_t");
1412  table->SetLabel(2, "Phi");
1413  table->SetLabel(3, "Theta");
1414  table->SetLabel(4, "Eta");
1415  k=0;
1416  for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) {
1417  Float_t p = ((TEveTrack*)(*j))->GetMomentum().Mag();
1418  table->SetValue(0, k, p);
1419  Float_t pt = ((TEveTrack*)(*j))->GetMomentum().Perp();
1420  table->SetValue(1, k, pt);
1421  Float_t phi = ((TEveTrack*)(*j))->GetMomentum().Phi();
1422  table->SetValue(2, k, phi);
1423  Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta();
1424  table->SetValue(3, k, theta);
1425  Float_t eta = ((TEveTrack*)(*j))->GetMomentum().Eta();
1426  table->SetValue(4, k, eta);
1427  ++k;
1428  }
1429  }
1430  }
1431  fgHtmlSummary->Build();
1432  fgHtml->Clear();
1433  fgHtml->ParseText((char*)fgHtmlSummary->Html().Data());
1434  fgHtml->Layout();
1435  }
1436 }
1437 
1438 
1439 #ifdef __CINT__
1440 void SplitGLView()
1441 {
1442  printf("This script is used via ACLiC by the macro \"alice_esd_split.C\"\n");
1443  printf("To see it in action, just run \".x alice_esd_split.C\"\n");
1444  return;
1445 }
1446 #endif
1447 
1448 
TEveViewerList * GetViewers() const
Definition: TEveManager.h:145
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1265
virtual void Add(TObject *obj)
TGShapedFrame & operator=(const TGShapedFrame &)
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
List_i EndChildren()
Definition: TEveElement.h:165
virtual void AddFrame(TGFrame *f, TGLayoutHints *hints)
Add frame to dockable frame container. Frame and hints are NOT adopted.
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:439
Base class for event management and navigation.
void Delete(Option_t *option="")
Remove all objects from the collection AND delete all heap based objects.
TObject * GetExternal() const
Eve representation of TGLScene.
Definition: TEveScene.h:26
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
const TGWindow * GetParent() const
Definition: TGWindow.h:87
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
virtual const char * GetElementName() const
Virtual function for retrieving name of the element.
Definition: TEveElement.h:481
R__EXTERN void * gTQSender
Definition: TQObject.h:49
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
TH1 * GetHisto(TFile *inFile, const std::string name)
Definition: Helper.cxx:119
TFile * OpenFile(const TString &fin)
Definition: tmvaglob.cxx:192
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:302
Definition: Rtypes.h:60
TH1 * h
Definition: legend2.C:5
UInt_t GetWidth() const
Definition: TGFrame.h:287
pt SetTextColor(4)
List_t::iterator List_i
Definition: TEveElement.h:70
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
void SetFixedSize(Bool_t fixed)
TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
#define gROOT
Definition: TROOT.h:364
The TEnv class reads config files, by default named .rootrc.
Definition: TEnv.h:128
Basic string class.
Definition: TString.h:137
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
#define gClient
Definition: TGClient.h:174
TGStatusBar * GetStatusBar() const
Definition: TRootBrowser.h:143
Array of floats (32 bits per element).
Definition: TArrayF.h:29
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1089
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
TGSplitFrame * GetSecond() const
Definition: TGSplitFrame.h:111
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
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:255
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=0)
An abstract interface to image processing library.
Definition: TImage.h:37
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
TGCompositeFrame * GetFrame() const
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
Axes for non-linear projections.
UInt_t GetHeight() const
Definition: TGFrame.h:288
const char * Class
Definition: TXMLSetup.cxx:64
TGSplitFrame * GetFirst() const
Definition: TGSplitFrame.h:109
TEveSelection * GetSelection() const
Definition: TEveManager.h:129
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
TEveEventManager * GetCurrentEvent() const
Definition: TEveManager.h:149
virtual void Reset(Option_t *option="")
Reset.
Definition: TH1.cxx:9164
Definition: TGHtml.h:876
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2546
Minimal GL-viewer that can be embedded in a standard ROOT frames.
Base class for GL viewers.
Definition: TGLViewerBase.h:36
Concrete physical shape - a GL drawable.
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Definition: TEnv.cxx:751
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition: TSystem.cxx:1319
const char * Data() const
Definition: TString.h:349
virtual void Clear(Option_t *option="")
Set name and title to empty strings ("").
Definition: TNamed.cxx:55
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
TEveScene * GetGlobalScene() const
Definition: TEveManager.h:147
const char ** fFileTypes
Definition: TGFileDialog.h:65
const TGLLogicalShape * GetLogical() const
virtual void ResetState()
A list of tracks supporting change of common attributes and selection based on track parameters...
Definition: TEveTrack.h:137
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1627
virtual void SetName(const char *name)
Definition: TGWindow.h:127
virtual void Clear(Option_t *option="")
Clear all lines in this pavetext.
Definition: TPaveText.cxx:186
TGeoVolume * GetTopVolume() const
Definition: TGeoManager.h:497
Int_t GetPickToSelect() const
Definition: TEveSelection.h:64
Manager class for steering of projections and managing projected objects.
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
virtual void PaintImage(Drawable_t, Int_t, Int_t, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0, Option_t *="")
Definition: TImage.h:251
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3295
TPaveText * pt
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2221
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
SVector< double, 2 > v
Definition: Dict.h:5
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:42
virtual TObject * Clone(const char *) const
Make a clone of an object using the Streamer facility.
Definition: TImage.h:119
GL-overlay button.
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
void DefaultColors()
Set default volume colors according to A of material.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:496
The F O R M U L A class.
Definition: TFormula.h:89
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
TEvePointSet is a render-element holding a collection of 3D points with optional per-point TRef and a...
Definition: TEvePointSet.h:31
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:658
void AddFirst(TObject *obj)
Insert object at beginning of collection.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
Definition: TEnv.h:77
virtual void AddElement(TEveElement *el)
Add el to the list of children.
Bool_t IsNull() const
Definition: TString.h:387
void Reset(Detail::TBranchProxy *x)
Visual representation of a track.
Definition: TEveTrack.h:32
virtual void * GetUserData() const =0
virtual const char * GetElementTitle() const
Virtual function for retrieving title of the render-element.
Definition: TEvePointSet.h:67
#define gVirtualX
Definition: TVirtualX.h:362
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2514
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
virtual void DrawText(Int_t=0, Int_t=0, const char *="", Int_t=12, const char *=0, const char *="fixed", EText3DType=TImage::kPlain, const char *=0, Float_t=0)
Definition: TImage.h:208
#define ClassImp(name)
Definition: Rtypes.h:279
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:554
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:416
TText * text
void EveMenu(Int_t id)
Handle events from Eve menu.
TGListTree * GetListTree() const
Get default list-tree widget.
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
#define free
Definition: civetweb.c:821
TEveScene * GetEventScene() const
Definition: TEveManager.h:148
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
char * fFilename
Definition: TGFileDialog.h:63
Double_t y[n]
Definition: legend1.C:17
The TH1 histogram class.
Definition: TH1.h:80
virtual TObject * GetObject(const TEveException &eh) const
Get a TObject associated with this render-element.
void SetAt(Double_t v, Int_t i)
Definition: TArrayF.h:53
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void SaveLevel(EEnvLevel level)
Write the resource file for a certain level.
Definition: TEnv.cxx:669
Mother of all ROOT objects.
Definition: TObject.h:44
This was intended as a TPad wrapper to allow smart updates of groups of pads.
Definition: TEvePad.h:17
Handle_t Window_t
Definition: GuiTypes.h:30
const Ssiz_t kNPOS
Definition: Rtypes.h:115
virtual void DoRedraw()
Redraw the frame.
Definition: TGShapedFrame.h:40
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
1-Dim function class
Definition: TF1.h:149
void Clear(Option_t *option="")
Remove all objects from the collection.
List_i BeginChildren()
Definition: TEveElement.h:164
virtual void AddElement(TEveElement *el)
Call base-class implementation.
Definition: TEveViewer.cxx:358
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
Int_t NumChildren() const
Definition: TEveElement.h:168
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
float type_of_call hi(const int &, const int &)
double exp(double)
const Bool_t kTRUE
Definition: Rtypes.h:91
Ordered collection.
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
Handle_t GetId() const
Definition: TGObject.h:52
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8058
TGTab * GetTabBottom() const
Definition: TRootBrowser.h:146
char name[80]
Definition: TGX11.cxx:109
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:467
Eve representation of TGLViewer.
Definition: TEveViewer.h:30
char * fIniDir
Definition: TGFileDialog.h:64
Definition: TGMsgBox.h:52
TEveSelection * GetHighlight() const
Definition: TEveManager.h:130
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add a frame in the split frame using layout hints l.
void EnableHide(Bool_t onoff)
Enable hiding.
TGLWidget * GetGLWidget()
Definition: TGLViewer.h:223
virtual const char * GetElementName() const
Virtual function for retrieving name of the element.
Definition: TEvePointSet.h:66