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