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