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