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
236
237 HtmlSummary *SplitGLView::fgHtmlSummary = nullptr;
238TGHtml *SplitGLView::fgHtml = nullptr;
239
240//______________________________________________________________________________
241TGShapedToolTip::TGShapedToolTip(const char *pname, Int_t cx, Int_t cy, Int_t cw, Int_t ch, Int_t tx, Int_t ty,
242 Int_t th, const char *col)
243 : TGShapedFrame(pname, gClient->GetDefaultRoot(), 400, 300, kTempFrame | kHorizontalFrame),
244 fEc(nullptr),
245 fHist(nullptr)
246{
247 // Shaped window constructor
248
249 fTextX = tx;
250 fTextY = ty;
251 fTextH = th;
252 if (col)
253 fTextCol = col;
254 else
255 fTextCol = "0x000000";
256
257 // create the embedded canvas
258 if ((cx > 0) && (cy > 0) && (cw > 0) && (ch > 0)) {
259 Int_t lhRight = fWidth - cx - cw;
260 Int_t lhBottom = fHeight - cy - ch;
261 fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
263 }
265 Resize();
266 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
267}
268
269//______________________________________________________________________________
270TGShapedToolTip::~TGShapedToolTip()
271{
272 // Destructor.
273
274 if (fHist)
275 delete fHist;
276 if (fEc)
277 delete fEc;
278}
279
280//______________________________________________________________________________
281void TGShapedToolTip::CloseWindow()
282{
283 // Close shaped window.
284
285 DeleteWindow();
286}
287
288//______________________________________________________________________________
289void TGShapedToolTip::Refresh()
290{
291 // Redraw the window with current attributes.
292
293 const char *str = fText.Data();
294 char *string = strdup(str);
295 Int_t nlines = 0, size = fTextH;
296 TString ar = "arial.ttf";
297 char *s = strtok((char *)string, "\n");
298 TImage *img = (TImage *)fImage->Clone("img");
299 img->DrawText(fTextX, fTextY + (nlines * size), s, size, fTextCol, ar);
300 while ((s = strtok(nullptr, "\n"))) {
301 nlines++;
302 img->DrawText(fTextX, fTextY + (nlines * size), s, size, fTextCol, ar);
303 }
304 img->PaintImage(fId, 0, 0, 0, 0, 0, 0, "opaque");
305 free(string);
306 delete img;
307 gVirtualX->Update();
308}
309
310//______________________________________________________________________________
311void TGShapedToolTip::CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch)
312{
313
314 // create the embedded canvas
315 Int_t lhRight = fWidth - cx - cw;
316 Int_t lhBottom = fHeight - cy - ch;
317 fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
320 Resize();
321 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
322 if (IsMapped()) {
323 Refresh();
324 }
325}
326
327//______________________________________________________________________________
328void TGShapedToolTip::CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints)
329{
330 // Create the embedded canvas.
331
332 fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
333 AddFrame(fEc, hints);
335 Resize();
336 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
337 if (IsMapped()) {
338 Refresh();
339 }
340}
341
342//______________________________________________________________________________
343void TGShapedToolTip::SetHisto(TH1 *hist)
344{
345 // Set which histogram has to be displayed in the embedded canvas.
346
347 if (hist) {
348 if (fHist) {
349 delete fHist;
350 if (fEc)
351 fEc->GetCanvas()->Clear();
352 }
353 fHist = (TH1 *)hist->Clone();
354 if (fEc) {
355 fEc->GetCanvas()->SetBorderMode(0);
356 fEc->GetCanvas()->SetFillColor(10);
357 fEc->GetCanvas()->cd();
358 fHist->Draw();
359 fEc->GetCanvas()->Update();
360 }
361 }
362}
363
364//______________________________________________________________________________
365void TGShapedToolTip::SetText(const char *text)
366{
367 // Set which text has to be displayed.
368
369 if (text) {
370 fText = text;
371 }
372 if (IsMapped())
373 Refresh();
374}
375
376//______________________________________________________________________________
377void TGShapedToolTip::SetTextColor(const char *col)
378{
379 // Set text color.
380
381 fTextCol = col;
382 if (IsMapped())
383 Refresh();
384}
385
386//______________________________________________________________________________
387void TGShapedToolTip::SetTextAttributes(Int_t tx, Int_t ty, Int_t th, const char *col)
388{
389 // Set text attributes (position, size and color).
390
391 fTextX = tx;
392 fTextY = ty;
393 fTextH = th;
394 if (col)
395 fTextCol = col;
396 if (IsMapped())
397 Refresh();
398}
399
400//______________________________________________________________________________
401void TGShapedToolTip::Show(Int_t x, Int_t y, const char *text, TH1 *hist)
402{
403 // Show (popup) the shaped window at location x,y and possibly
404 // set the text and histogram to be displayed.
405
406 Move(x, y);
407 MapWindow();
408
409 if (text)
410 SetText(text);
411 if (hist)
412 SetHisto(hist);
413 // end of demo code -------------------------------------------
414 if (fHist) {
415 fEc->GetCanvas()->SetBorderMode(0);
416 fEc->GetCanvas()->SetFillColor(10);
417 fEc->GetCanvas()->cd();
418 fHist->Draw();
419 fEc->GetCanvas()->Update();
420 }
421 Refresh();
422}
423
424//______________________________________________________________________________
425HtmlObjTable::HtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp)
426 : fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
427{
428 // Constructor.
429
430 fValues = new TArrayF[fNFields];
431 for (int i = 0; i < fNFields; i++)
432 fValues[i].Set(nvals);
433 fLabels = new TString[fNFields];
434}
435
436//______________________________________________________________________________
437HtmlObjTable::~HtmlObjTable()
438{
439 // Destructor.
440
441 delete[] fValues;
442 delete[] fLabels;
443}
444
445//______________________________________________________________________________
446void HtmlObjTable::Build()
447{
448 // Build HTML code.
449
450 fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
451
452 BuildTitle();
453 if (fExpand && (fNFields > 0) && (fNValues > 0)) {
454 BuildLabels();
455 BuildTable();
456 }
457
458 fHtml += "</table>";
459}
460
461//______________________________________________________________________________
462void HtmlObjTable::BuildTitle()
463{
464 // Build table title.
465
466 fHtml += "<tr><td colspan=";
467 fHtml += Form("%d>", fNFields + 1);
468 fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
469 fHtml += "<tr><td align=left>";
470 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
471 fHtml += fName;
472 fHtml += "</i></b></font></td>";
473 fHtml += "<td>";
474 fHtml += "<td align=right> ";
475 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
476 fHtml += Form("Size = %d", fNValues);
477 fHtml += "</i></b></font></td></tr>";
478 fHtml += "</table>";
479 fHtml += "</td></tr>";
480}
481
482//______________________________________________________________________________
483void HtmlObjTable::BuildLabels()
484{
485 // Build table labels.
486
487 Int_t i;
488 fHtml += "<tr bgcolor=c0c0ff>";
489 fHtml += "<th> </th>"; // for the check boxes
490 for (i = 0; i < fNFields; i++) {
491 fHtml += "<th> ";
492 fHtml += fLabels[i];
493 fHtml += " </th>"; // for the check boxes
494 }
495 fHtml += "</tr>";
496}
497
498//______________________________________________________________________________
499void HtmlObjTable::BuildTable()
500{
501 // Build part of table with values.
502
503 for (int i = 0; i < fNValues; i++) {
504 if (i % 2)
505 fHtml += "<tr bgcolor=e0e0ff>";
506 else
507 fHtml += "<tr bgcolor=ffffff>";
508
509 TString name = fName;
510 name.ReplaceAll(" ", "_");
511 // checkboxes
512 fHtml += "<td bgcolor=d0d0ff align=\"center\">";
513 fHtml += "<input type=\"checkbox\" name=\"";
514 fHtml += name;
515 fHtml += Form("[%d]\">", i);
516 fHtml += "</td>";
517
518 for (int j = 0; j < fNFields; j++) {
519 fHtml += "<td width=";
520 fHtml += Form("%d%%", 100 / fNFields);
521 fHtml += " align=\"center\"";
522 fHtml += ">";
523 fHtml += Form("%1.4f", fValues[j][i]);
524 fHtml += "</td>";
525 }
526 fHtml += "</tr> ";
527 }
528}
529
530//______________________________________________________________________________
531HtmlSummary::HtmlSummary(const char *title) : fNTables(0), fTitle(title)
532{
533 // Constructor.
534
536}
537
538//______________________________________________________________________________
539HtmlSummary::~HtmlSummary()
540{
541 // Destructor.
542
543 Reset();
544}
545
546//______________________________________________________________________________
547HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp, Option_t *option)
548{
549 // Add a new table in our list of tables.
550
551 TString opt = option;
552 opt.ToLower();
553 HtmlObjTable *table = new HtmlObjTable(name, nfields, nvals, exp);
554 fNTables++;
555 if (opt.Contains("first"))
556 fObjTables->AddFirst(table);
557 else
558 fObjTables->Add(table);
559 return table;
560}
561
562//______________________________________________________________________________
563void HtmlSummary::Clear(Option_t *option)
564{
565 // Clear the table list.
566
567 if (option && option[0] == 'D')
568 fObjTables->Delete(option);
569 else
570 fObjTables->Clear(option);
571 fNTables = 0;
572}
573
574//______________________________________________________________________________
575void HtmlSummary::Reset(Option_t *)
576{
577 // Reset (delete) the table list;
578
579 delete fObjTables;
580 fObjTables = nullptr;
581 fNTables = 0;
582}
583
584//______________________________________________________________________________
585void HtmlSummary::Build()
586{
587 // Build the summary.
588
589 MakeHeader();
590 for (int i = 0; i < fNTables; i++) {
591 GetTable(i)->Build();
592 fHtml += GetTable(i)->Html();
593 }
594 MakeFooter();
595}
596
597//______________________________________________________________________________
598void HtmlSummary::MakeHeader()
599{
600 // Make HTML header.
601
602 fHeader = "<html><head><title>";
603 fHeader += fTitle;
604 fHeader += "</title></head><body>";
605 fHeader += "<center><h2><font color=#2222ee><i>";
606 fHeader += fTitle;
607 fHeader += "</i></font></h2></center>";
608 fHtml = fHeader;
609}
610
611//______________________________________________________________________________
612void HtmlSummary::MakeFooter()
613{
614 // Make HTML footer.
615
616 fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
617 fFooter += "Example of using Html widget to display tabular data";
618 fFooter += "<br>";
619 fFooter += "(c) 2007-2010 Bertrand Bellenot";
620 fFooter += "</font></strong></center></body></html>";
621 fHtml += fFooter;
622}
623
624//______________________________________________________________________________
625SplitGLView::SplitGLView(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed)
626 : TGMainFrame(p, w, h), fActViewer(nullptr), fShapedToolTip(nullptr), fIsEmbedded(embed)
627{
628 // Main frame constructor.
629
631 TEveScene *s = nullptr;
635
636 // create the "file" popup menu
637 fMenuFile = new TGPopupMenu(gClient->GetRoot());
638 fMenuFile->AddEntry("&Open...", kFileOpen);
639 fMenuFile->AddSeparator();
640 fMenuFile->AddEntry("&Update Summary", kSummaryUpdate);
641 fMenuFile->AddSeparator();
642 fMenuFile->AddEntry("&Load Config...", kFileLoadConfig);
643 fMenuFile->AddEntry("&Save Config...", kFileSaveConfig);
644 fMenuFile->AddSeparator();
645 fMenuFile->AddEntry("E&xit", kFileExit);
646
647 // create the "camera" popup menu
648 fMenuCamera = new TGPopupMenu(gClient->GetRoot());
649 fMenuCamera->AddEntry("Perspective (Floor XOZ)", kGLPerspXOZ);
650 fMenuCamera->AddEntry("Perspective (Floor YOZ)", kGLPerspYOZ);
651 fMenuCamera->AddEntry("Perspective (Floor XOY)", kGLPerspXOY);
652 fMenuCamera->AddEntry("Orthographic (XOY)", kGLXOY);
653 fMenuCamera->AddEntry("Orthographic (XOZ)", kGLXOZ);
654 fMenuCamera->AddEntry("Orthographic (ZOY)", kGLZOY);
655 fMenuCamera->AddSeparator();
656 fMenuCamera->AddEntry("Ortho allow rotate", kGLOrthoRotate);
657 fMenuCamera->AddEntry("Ortho allow dolly", kGLOrthoDolly);
658
659 fMenuScene = new TGPopupMenu(gClient->GetRoot());
660 fMenuScene->AddEntry("&Update Current", kSceneUpdate);
661 fMenuScene->AddEntry("Update &All", kSceneUpdateAll);
662
663 // create the "help" popup menu
664 fMenuHelp = new TGPopupMenu(gClient->GetRoot());
665 fMenuHelp->AddEntry("&About", kHelpAbout);
666
667 // create the main menu bar
668 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
669 fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
670 fMenuBar->AddPopup("&Camera", fMenuCamera, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
671 fMenuBar->AddPopup("&Scene", fMenuScene, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
672 fMenuBar->AddPopup("&Help", fMenuHelp, new TGLayoutHints(kLHintsTop | kLHintsRight));
673
674 AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
675
676 // connect menu signals to our menu handler slot
677 fMenuFile->Connect("Activated(Int_t)", "SplitGLView", this, "HandleMenu(Int_t)");
678 fMenuCamera->Connect("Activated(Int_t)", "SplitGLView", this, "HandleMenu(Int_t)");
679 fMenuScene->Connect("Activated(Int_t)", "SplitGLView", this, "HandleMenu(Int_t)");
680 fMenuHelp->Connect("Activated(Int_t)", "SplitGLView", this, "HandleMenu(Int_t)");
681
682 if (fIsEmbedded && gEve) {
683 // use status bar from the browser
684 fStatusBar = gEve->GetBrowser()->GetStatusBar();
685 } else {
686 // create the status bar
687 Int_t parts[] = {45, 15, 10, 30};
688 fStatusBar = new TGStatusBar(this, 50, 10);
689 fStatusBar->SetParts(parts, 4);
690 AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 10, 0));
691 }
692
693 // create eve pad (our geometry container)
694 fPad = new TEvePad();
695 fPad->SetFillColor(kBlack);
696
697 // create the split frames
698 fSplitFrame = new TGSplitFrame(this, 800, 600);
700 // split it once
701 fSplitFrame->HSplit(434);
702 // then split each part again (this will make four parts)
703 fSplitFrame->GetSecond()->VSplit(266);
704 fSplitFrame->GetSecond()->GetSecond()->VSplit(266);
705
707 // get top (main) split frame
708 frm = fSplitFrame->GetFirst();
709 frm->SetName("Main_View");
710
711 // create (embed) a GL viewer inside
712 fViewer0 = new TGLEmbeddedViewer(frm, fPad);
713 but1 = new TGLOverlayButton(fViewer0, "Swap", 10.0, -10.0, 55.0, 16.0);
714 but1->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
715 but2 = new TGLOverlayButton(fViewer0, "Undock", 70.0, -10.0, 55.0, 16.0);
716 but2->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
717 frm->AddFrame(fViewer0->GetFrame(), new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
718 // set the camera to perspective (XOZ) for this viewer
719 fViewer0->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
720 // connect signal we are interested to
721 fViewer0->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this, "OnMouseOver(TGLPhysicalShape*)");
722 fViewer0->Connect("Activated()", "SplitGLView", this, "OnViewerActivated()");
723 fViewer0->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", "SplitGLView", this,
724 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
725 fViewer0->Connect("Clicked(TObject*)", "SplitGLView", this, "OnClicked(TObject*)");
726 fViewer[0] = new TEveViewer("SplitGLViewer[0]");
727 fViewer[0]->SetGLViewer(fViewer0, fViewer0->GetFrame());
728 fViewer[0]->IncDenyDestroy();
729 if (fIsEmbedded && gEve) {
730 fViewer[0]->AddScene(gEve->GetGlobalScene());
731 fViewer[0]->AddScene(gEve->GetEventScene());
732 gEve->GetViewers()->AddElement(fViewer[0]);
733 s = gEve->SpawnNewScene("Rho-Z Projection");
734 // projections
739 s->AddElement(a);
740 }
741
742 // get bottom left split frame
743 frm = fSplitFrame->GetSecond()->GetFirst();
744 frm->SetName("Bottom_Left");
745
746 // create (embed) a GL viewer inside
747 fViewer1 = new TGLEmbeddedViewer(frm, fPad);
748 but3 = new TGLOverlayButton(fViewer1, "Swap", 10.0, -10.0, 55.0, 16.0);
749 but3->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
750 but4 = new TGLOverlayButton(fViewer1, "Undock", 70.0, -10.0, 55.0, 16.0);
751 but4->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
752 frm->AddFrame(fViewer1->GetFrame(), new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
753
754 // set the camera to orthographic (XOY) for this viewer
755 fViewer1->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
756 // connect signal we are interested to
757 fViewer1->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this, "OnMouseOver(TGLPhysicalShape*)");
758 fViewer1->Connect("Activated()", "SplitGLView", this, "OnViewerActivated()");
759 fViewer1->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", "SplitGLView", this,
760 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
761 fViewer1->Connect("Clicked(TObject*)", "SplitGLView", this, "OnClicked(TObject*)");
762 fViewer[1] = new TEveViewer("SplitGLViewer[1]");
763 fViewer[1]->SetGLViewer(fViewer1, fViewer1->GetFrame());
764 fViewer[1]->IncDenyDestroy();
765 if (fIsEmbedded && gEve) {
766 fRhoZMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
767 fRhoZMgr->ImportElements((TEveElement *)gEve->GetEventScene());
768 fViewer[1]->AddScene(s);
769 gEve->GetViewers()->AddElement(fViewer[1]);
771
772 s = gEve->SpawnNewScene("R-Phi Projection");
773 // projections
778 s->AddElement(a);
779 }
780
781 // get bottom center split frame
782 frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
783 frm->SetName("Bottom_Center");
784
785 // create (embed) a GL viewer inside
786 fViewer2 = new TGLEmbeddedViewer(frm, fPad);
787 but5 = new TGLOverlayButton(fViewer2, "Swap", 10.0, -10.0, 55.0, 16.0);
788 but5->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
789 but6 = new TGLOverlayButton(fViewer2, "Undock", 70.0, -10.0, 55.0, 16.0);
790 but6->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
791 frm->AddFrame(fViewer2->GetFrame(), new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
792
793 // set the camera to orthographic (XOY) for this viewer
794 fViewer2->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
795 // connect signal we are interested to
796 fViewer2->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this, "OnMouseOver(TGLPhysicalShape*)");
797 fViewer2->Connect("Activated()", "SplitGLView", this, "OnViewerActivated()");
798 fViewer2->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", "SplitGLView", this,
799 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
800 fViewer2->Connect("Clicked(TObject*)", "SplitGLView", this, "OnClicked(TObject*)");
801 fViewer[2] = new TEveViewer("SplitGLViewer[2]");
802 fViewer[2]->SetGLViewer(fViewer2, fViewer2->GetFrame());
803 fViewer[2]->IncDenyDestroy();
804 if (fIsEmbedded && gEve) {
805 fRPhiMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
806 fRPhiMgr->ImportElements((TEveElement *)gEve->GetEventScene());
807 fViewer[2]->AddScene(s);
808 gEve->GetViewers()->AddElement(fViewer[2]);
810 }
811
812 // get bottom right split frame
813 frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
814 frm->SetName("Bottom_Right");
815
816 dfrm = new TGDockableFrame(frm);
817 dfrm->SetFixedSize(kFALSE);
818 dfrm->EnableHide(kFALSE);
820 button = new TGPictureButton(hfrm, gClient->GetPicture("swap.png"));
821 button->SetToolTipText("Swap to big view");
822 hfrm->AddFrame(button);
823 button->Connect("Clicked()", "SplitGLView", this, "SwapToMainView(TGLViewerBase*=0)");
824 fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table");
825 fgHtml = new TGHtml(hfrm, 100, 100, -1);
829
830 if (fIsEmbedded && gEve) {
831 gEve->GetListTree()->Connect("Clicked(TGListTreeItem*, Int_t, Int_t, Int_t)", "SplitGLView", this,
832 "ItemClicked(TGListTreeItem*, Int_t, Int_t, Int_t)");
833 }
834
835 fShapedToolTip = new TGShapedToolTip("Default.png", 120, 22, 160, 110, 23, 115, 12, "#ffff80");
836 Resize(GetDefaultSize());
838 MapWindow();
839 LoadConfig(".everc");
840}
841
842//______________________________________________________________________________
843SplitGLView::~SplitGLView()
844{
845 // Clean up main frame...
846 // Cleanup();
847
848 fMenuFile->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
849 fMenuCamera->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
850 fMenuScene->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
851 fMenuHelp->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
852 fViewer0->Disconnect("MouseOver(TGLPhysicalShape*)", this, "OnMouseOver(TGLPhysicalShape*)");
853 fViewer0->Disconnect("Activated()", this, "OnViewerActivated()");
854 fViewer0->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", this,
855 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
856 fViewer1->Disconnect("MouseOver(TGLPhysicalShape*)", this, "OnMouseOver(TGLPhysicalShape*)");
857 fViewer1->Disconnect("Activated()", this, "OnViewerActivated()");
858 fViewer1->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", this,
859 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
860 fViewer2->Disconnect("MouseOver(TGLPhysicalShape*)", this, "OnMouseOver(TGLPhysicalShape*)");
861 fViewer2->Disconnect("Activated()", this, "OnViewerActivated()");
862 fViewer2->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", this,
863 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
864 if (!fIsEmbedded) {
865 delete fViewer[0];
866 delete fViewer[1];
867 delete fViewer[2];
868 }
869 delete fShapedToolTip;
870 delete fMenuFile;
871 delete fMenuScene;
872 delete fMenuCamera;
873 delete fMenuHelp;
874 if (!fIsEmbedded)
875 delete fMenuBar;
876 delete fViewer0;
877 delete fViewer1;
878 delete fViewer2;
879 delete fSplitFrame;
880 delete fPad;
881 if (!fIsEmbedded) {
882 delete fStatusBar;
884 }
885}
886
887//______________________________________________________________________________
888void SplitGLView::HandleMenu(Int_t id)
889{
890 // Handle menu items.
891
892 static TString rcdir(".");
893 static TString rcfile(".everc");
894
895 switch (id) {
896
897 case kFileOpen: {
898 static TString dir(".");
900 fi.fFileTypes = filetypes;
901 fi.SetIniDir(dir);
902 new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
903 if (fi.fFilename)
904 OpenFile(fi.fFilename);
905 dir = fi.fIniDir;
906 } break;
907
908 case kFileLoadConfig: {
910 fi.fFileTypes = rcfiletypes;
911 fi.SetIniDir(rcdir);
912 fi.SetFilename(rcfile);
913 new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
914 if (fi.fFilename) {
915 rcfile = fi.fFilename;
916 LoadConfig(fi.fFilename);
917 }
918 rcdir = fi.fIniDir;
919 } break;
920
921 case kFileSaveConfig: {
923 fi.fFileTypes = rcfiletypes;
924 fi.SetIniDir(rcdir);
925 fi.SetFilename(rcfile);
926 new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
927 if (fi.fFilename) {
928 rcfile = fi.fFilename;
929 SaveConfig(fi.fFilename);
930 }
931 rcdir = fi.fIniDir;
932 } break;
933
934 case kFileExit: CloseWindow(); break;
935
936 case kGLPerspYOZ:
937 if (fActViewer)
938 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspYOZ);
939 break;
940 case kGLPerspXOZ:
941 if (fActViewer)
942 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
943 break;
944 case kGLPerspXOY:
945 if (fActViewer)
946 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
947 break;
948 case kGLXOY:
949 if (fActViewer)
950 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
951 break;
952 case kGLXOZ:
953 if (fActViewer)
954 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOZ);
955 break;
956 case kGLZOY:
957 if (fActViewer)
958 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
959 break;
960 case kGLOrthoRotate: ToggleOrthoRotate(); break;
961 case kGLOrthoDolly: ToggleOrthoDolly(); break;
962
963 case kSceneUpdate:
964 if (fActViewer)
965 fActViewer->UpdateScene();
967 break;
968
969 case kSceneUpdateAll:
970 fViewer0->UpdateScene();
971 fViewer1->UpdateScene();
972 fViewer2->UpdateScene();
974 break;
975
976 case kSummaryUpdate: UpdateSummary(); break;
977
978 case kHelpAbout: {
979#ifdef R__UNIX
980 TString rootx = TROOT::GetBinDir() + "/root -a &";
982#else
983#ifdef WIN32
985#else
986 char str[32];
987 sprintf(str, "About ROOT %s...", gROOT->GetVersion());
988 hd = new TRootHelpDialog(this, str, 600, 400);
989 hd->SetText(gHelpAbout);
990 hd->Popup();
991#endif
992#endif
993 } break;
994
995 default: break;
996 }
997}
998
999//______________________________________________________________________________
1000void SplitGLView::OnClicked(TObject *obj)
1001{
1002 // Handle click events in GL viewer
1003
1004 if (obj)
1005 fStatusBar->SetText(Form("User clicked on: \"%s\"", obj->GetName()), 1);
1006 else
1007 fStatusBar->SetText("", 1);
1008}
1009
1010//______________________________________________________________________________
1011void SplitGLView::OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy)
1012{
1013 // Slot used to handle "OnMouseIdle" signal coming from any GL viewer.
1014 // We receive a pointer on the physical shape in which the mouse cursor is
1015 // and the actual cursor position (x,y)
1016
1018 Int_t x = 0, y = 0;
1019
1020 static TH1F *h1f = nullptr;
1021 TFormula *form1 = new TFormula("form1", "abs(sin(x)/x)");
1022 TF1 *sqroot = new TF1("sqroot", "x*gaus(0) + [3]*form1", 0, 10);
1023 sqroot->SetParameters(10, 4, 1, 20);
1024 if (h1f == nullptr)
1025 h1f = new TH1F("h1f", "", 50, 0, 10);
1026 h1f->Reset();
1027 h1f->SetFillColor(45);
1028 h1f->SetStats(false);
1029 h1f->FillRandom("sqroot", 200);
1030
1031 if (fShapedToolTip) {
1032 fShapedToolTip->UnmapWindow();
1033 }
1034 if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal()) {
1035 // get the actual viewer who actually emitted the signal
1037 // then translate coordinates from the root (screen) coordinates
1038 // to the actual frame (viewer) ones
1039 gVirtualX->TranslateCoordinates(actViewer->GetFrame()->GetId(), gClient->GetDefaultRoot()->GetId(), posx, posy, x,
1040 y, wtarget);
1041 // Then display our tooltip at this x,y location
1042 if (fShapedToolTip) {
1043 fShapedToolTip->Show(x + 5, y + 5,
1044 Form("%s\n \n%s", shape->GetLogical()->GetExternal()->IsA()->GetName(),
1045 shape->GetLogical()->GetExternal()->GetName()),
1046 h1f);
1047 }
1048 }
1049}
1050
1051//______________________________________________________________________________
1052void SplitGLView::OnMouseOver(TGLPhysicalShape *shape)
1053{
1054 // Slot used to handle "OnMouseOver" signal coming from any GL viewer.
1055 // We receive a pointer on the physical shape in which the mouse cursor is.
1056
1057 // display information on the physical shape in the status bar
1058 if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal())
1059 fStatusBar->SetText(Form("Mouse Over: \"%s\"", shape->GetLogical()->GetExternal()->GetName()), 0);
1060 else
1061 fStatusBar->SetText("", 0);
1062}
1063
1064//______________________________________________________________________________
1065void SplitGLView::OnViewerActivated()
1066{
1067 // Slot used to handle "Activated" signal coming from any GL viewer.
1068 // Used to know which GL viewer is active.
1069
1070 static Pixel_t green = 0;
1071 // set the actual GL viewer frame to default color
1072 if (fActViewer && fActViewer->GetFrame())
1073 fActViewer->GetFrame()->ChangeBackground(GetDefaultFrameBackground());
1074
1075 // change the actual GL viewer to the one who emitted the signal
1076 // fActViewer = (TGLEmbeddedViewer *)gTQSender;
1077 fActViewer = dynamic_cast<TGLEmbeddedViewer *>((TQObject *)gTQSender);
1078
1079 if (fActViewer == nullptr) {
1080 printf("dyncast failed ...\n");
1081 return;
1082 }
1083
1084 // get the highlight color (only once)
1085 if (green == 0) {
1086 gClient->GetColorByName("green", green);
1087 }
1088 // set the new actual GL viewer frame to highlight color
1089 if (fActViewer->GetFrame())
1090 fActViewer->GetFrame()->ChangeBackground(green);
1091
1092 // update menu entries to match actual viewer's options
1093 if (fActViewer->GetOrthoXOYCamera()->GetDollyToZoom() && fActViewer->GetOrthoXOZCamera()->GetDollyToZoom() &&
1094 fActViewer->GetOrthoZOYCamera()->GetDollyToZoom())
1095 fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1096 else
1097 fMenuCamera->CheckEntry(kGLOrthoDolly);
1098
1099 if (fActViewer->GetOrthoXOYCamera()->GetEnableRotate() && fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1100 fActViewer->GetOrthoXOYCamera()->GetEnableRotate())
1101 fMenuCamera->CheckEntry(kGLOrthoRotate);
1102 else
1103 fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1104}
1105
1106//______________________________________________________________________________
1107void SplitGLView::OpenFile(const char *fname)
1108{
1109 // Open a Root file to display a geometry in the GL viewers.
1110
1112 // check if the file type is correct
1113 if (!filename.EndsWith(".root")) {
1114 new TGMsgBox(gClient->GetRoot(), this, "OpenFile", Form("The file \"%s\" is not a root file!", fname),
1116 return;
1117 }
1118 // check if the root file contains a geometry
1119 if (TGeoManager::Import(fname) == nullptr) {
1120 new TGMsgBox(gClient->GetRoot(), this, "OpenFile", Form("The file \"%s\" does't contain a geometry", fname),
1122 return;
1123 }
1125 // delete previous primitives (if any)
1126 fPad->GetListOfPrimitives()->Delete();
1127 // and add the geometry to eve pad (container)
1128 fPad->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume());
1129 // paint the geometry in each GL viewer
1130 fViewer0->PadPaint(fPad);
1131 fViewer1->PadPaint(fPad);
1132 fViewer2->PadPaint(fPad);
1133}
1134
1135//______________________________________________________________________________
1136void SplitGLView::ToggleOrthoRotate()
1137{
1138 // Toggle state of the 'Ortho allow rotate' menu entry.
1139
1140 if (fMenuCamera->IsEntryChecked(kGLOrthoRotate))
1141 fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1142 else
1143 fMenuCamera->CheckEntry(kGLOrthoRotate);
1144 Bool_t state = fMenuCamera->IsEntryChecked(kGLOrthoRotate);
1145 if (fActViewer) {
1146 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1147 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1148 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1149 }
1150}
1151
1152//______________________________________________________________________________
1153void SplitGLView::ToggleOrthoDolly()
1154{
1155 // Toggle state of the 'Ortho allow dolly' menu entry.
1156
1157 if (fMenuCamera->IsEntryChecked(kGLOrthoDolly))
1158 fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1159 else
1160 fMenuCamera->CheckEntry(kGLOrthoDolly);
1161 Bool_t state = !fMenuCamera->IsEntryChecked(kGLOrthoDolly);
1162 if (fActViewer) {
1163 fActViewer->GetOrthoXOYCamera()->SetDollyToZoom(state);
1164 fActViewer->GetOrthoXOZCamera()->SetDollyToZoom(state);
1165 fActViewer->GetOrthoZOYCamera()->SetDollyToZoom(state);
1166 }
1167}
1168
1169//______________________________________________________________________________
1170void SplitGLView::ItemClicked(TGListTreeItem *item, Int_t, Int_t, Int_t)
1171{
1172 // Item has been clicked, based on mouse button do:
1173
1174 static const TEveException eh("SplitGLView::ItemClicked ");
1175 TEveElement *re = (TEveElement *)item->GetUserData();
1176 if (re == nullptr)
1177 return;
1178 TObject *obj = re->GetObject(eh);
1179 if (obj->InheritsFrom("TEveViewer")) {
1180 TGLViewer *v = ((TEveViewer *)obj)->GetGLViewer();
1181 // v->Activated();
1182 if (v->InheritsFrom("TGLEmbeddedViewer")) {
1184 gVirtualX->SetInputFocus(ev->GetGLWidget()->GetId());
1185 }
1186 }
1187}
1188
1189//______________________________________________________________________________
1190void SplitGLView::LoadConfig(const char *fname)
1191{
1192
1194 TEnv *env = new TEnv(fname);
1195
1196 Int_t mainheight = env->GetValue("MainView.Height", 434);
1197 Int_t blwidth = env->GetValue("Bottom.Left.Width", 266);
1198 Int_t bcwidth = env->GetValue("Bottom.Center.Width", 266);
1199 Int_t brwidth = env->GetValue("Bottom.Right.Width", 266);
1200 Int_t top_height = env->GetValue("Right.Tab.Height", 0);
1201 Int_t bottom_height = env->GetValue("Bottom.Tab.Height", 0);
1202
1203 if (fIsEmbedded && gEve) {
1204 Int_t sel = env->GetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1205 Int_t hi = env->GetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1206 gEve->GetBrowser()->EveMenu(9 + sel);
1207 gEve->GetBrowser()->EveMenu(13 + hi);
1208
1209 width = env->GetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1210 height = env->GetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1212 }
1213
1214 // top (main) split frame
1215 width = fSplitFrame->GetFirst()->GetWidth();
1216 fSplitFrame->GetFirst()->Resize(width, mainheight);
1217 // bottom left split frame
1218 height = fSplitFrame->GetSecond()->GetFirst()->GetHeight();
1219 fSplitFrame->GetSecond()->GetFirst()->Resize(blwidth, height);
1220 // bottom center split frame
1221 height = fSplitFrame->GetSecond()->GetSecond()->GetFirst()->GetHeight();
1222 fSplitFrame->GetSecond()->GetSecond()->GetFirst()->Resize(bcwidth, height);
1223 // bottom right split frame
1224 height = fSplitFrame->GetSecond()->GetSecond()->GetSecond()->GetHeight();
1225 fSplitFrame->GetSecond()->GetSecond()->GetSecond()->Resize(brwidth, height);
1226
1227 fSplitFrame->Layout();
1228
1229 if (fIsEmbedded && gEve) {
1230 width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetWidth();
1232 width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetWidth();
1234 }
1235}
1236
1237//______________________________________________________________________________
1238void SplitGLView::SaveConfig(const char *fname)
1239{
1240
1241 Int_t bottom_height = 0;
1242 Int_t top_height = 0;
1244 TEnv *env = new TEnv(fname);
1245
1246 if (fIsEmbedded && gEve) {
1247 env->SetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1248 env->SetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1249 }
1250 // get top (main) split frame
1251 frm = fSplitFrame->GetFirst();
1252 env->SetValue("MainView.Height", (Int_t)frm->GetHeight());
1253 // get bottom left split frame
1254 frm = fSplitFrame->GetSecond()->GetFirst();
1255 env->SetValue("Bottom.Left.Width", (Int_t)frm->GetWidth());
1256 // get bottom center split frame
1257 frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
1258 env->SetValue("Bottom.Center.Width", (Int_t)frm->GetWidth());
1259 // get bottom right split frame
1260 frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
1261 env->SetValue("Bottom.Right.Width", (Int_t)frm->GetWidth());
1262 if (fIsEmbedded && gEve) {
1264 env->SetValue("Right.Tab.Height", top_height);
1266 env->SetValue("Bottom.Tab.Height", bottom_height);
1267
1268 env->SetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1269 env->SetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1270 }
1271
1272 env->SaveLevel(kEnvLocal);
1273#ifdef R__WIN32
1274 if (!gSystem->AccessPathName(Form("%s.new", fname))) {
1275 gSystem->Exec(Form("del %s", fname));
1276 gSystem->Rename(Form("%s.new", fname), fname);
1277 }
1278#endif
1279}
1280
1281//______________________________________________________________________________
1282void SplitGLView::SwapToMainView(TGLViewerBase *viewer)
1283{
1284 // Swap frame embedded in a splitframe to the main view (slot method).
1285
1286 TGCompositeFrame *parent = nullptr;
1287 if (!fSplitFrame->GetFirst()->GetFrame())
1288 return;
1289 if (viewer == nullptr) {
1291 parent = (TGCompositeFrame *)src->GetParent();
1292 while (parent && !parent->InheritsFrom("TGSplitFrame")) {
1293 parent = (TGCompositeFrame *)parent->GetParent();
1294 }
1295 } else {
1296 TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1297 if (!src)
1298 return;
1300 but->ResetState();
1301 parent = (TGCompositeFrame *)src->GetParent();
1302 }
1303 if (parent && parent->InheritsFrom("TGSplitFrame"))
1304 ((TGSplitFrame *)parent)->SwitchToMain();
1305}
1306
1307//______________________________________________________________________________
1308void SplitGLView::UnDock(TGLViewerBase *viewer)
1309{
1310 // Undock frame embedded in a splitframe (slot method).
1311
1312 TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1313 if (!src)
1314 return;
1316 but->ResetState();
1317 TGCompositeFrame *parent = (TGCompositeFrame *)src->GetParent();
1318 if (parent && parent->InheritsFrom("TGSplitFrame"))
1319 ((TGSplitFrame *)parent)->ExtractFrame();
1320}
1321
1322//______________________________________________________________________________
1323void SplitGLView::UpdateSummary()
1324{
1325 // Update summary of current event.
1326
1329 Int_t k;
1330 TEveElement *el;
1331 HtmlObjTable *table;
1332 TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : nullptr;
1333 if (mgr) {
1334 fgHtmlSummary->Clear("D");
1335 for (i = mgr->BeginChildren(); i != mgr->EndChildren(); ++i) {
1336 el = ((TEveElement *)(*i));
1337 if (el->IsA() == TEvePointSet::Class()) {
1338 TEvePointSet *ps = (TEvePointSet *)el;
1341 if (ename.First('\'') != kNPOS)
1342 ename.Remove(ename.First('\''));
1343 etitle.Remove(0, 2);
1344 Int_t nel = atoi(etitle.Data());
1345 table = fgHtmlSummary->AddTable(ename, 0, nel);
1346 } else if (el->IsA() == TEveTrackList::Class()) {
1348 TString ename = tracks->GetElementName();
1349 if (ename.First('\'') != kNPOS)
1350 ename.Remove(ename.First('\''));
1351 table = fgHtmlSummary->AddTable(ename.Data(), 5, tracks->NumChildren(), kTRUE, "first");
1352 table->SetLabel(0, "Momentum");
1353 table->SetLabel(1, "P_t");
1354 table->SetLabel(2, "Phi");
1355 table->SetLabel(3, "Theta");
1356 table->SetLabel(4, "Eta");
1357 k = 0;
1358 for (j = tracks->BeginChildren(); j != tracks->EndChildren(); ++j) {
1359 Float_t p = ((TEveTrack *)(*j))->GetMomentum().Mag();
1360 table->SetValue(0, k, p);
1361 Float_t pt = ((TEveTrack *)(*j))->GetMomentum().Perp();
1362 table->SetValue(1, k, pt);
1363 Float_t phi = ((TEveTrack *)(*j))->GetMomentum().Phi();
1364 table->SetValue(2, k, phi);
1365 Float_t theta = ((TEveTrack *)(*j))->GetMomentum().Theta();
1366 table->SetValue(3, k, theta);
1367 Float_t eta = ((TEveTrack *)(*j))->GetMomentum().Eta();
1368 table->SetValue(4, k, eta);
1369 ++k;
1370 }
1371 }
1372 }
1373 fgHtmlSummary->Build();
1374 fgHtml->Clear();
1375 fgHtml->ParseText((char *)fgHtmlSummary->Html().Data());
1376 fgHtml->Layout();
1377 }
1378}
1379
1380#ifdef __CINT__
1381void SplitGLView()
1382{
1383 printf("This script is used via ACLiC by the macro \"alice_esd_split.C\"\n");
1384 printf("To see it in action, just run \".x alice_esd_split.C\"\n");
1385 return;
1386}
1387#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
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:342
#define ClassImp(name)
Definition Rtypes.h:382
@ kBlack
Definition Rtypes.h:65
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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
#define hi
R__EXTERN void * gTQSender
Definition TQObject.h:46
Binding & operator=(OUT(*fun)(void))
#define gROOT
Definition TROOT.h:406
@ kHelpAbout
@ kFileOpen
@ kFileLoadConfig
@ kFileSaveConfig
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
#define gVirtualX
Definition TVirtualX.h:337
#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) override
Definition TArrayF.h:51
The TEnv class reads config files, by default named .rootrc.
Definition TEnv.h:124
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=nullptr)
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: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:233
The Formula class.
Definition TFormula.h:89
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
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:605
UInt_t GetHeight() const
Definition TGFrame.h:225
UInt_t GetWidth() const
Definition TGFrame.h:224
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
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
virtual void * GetUserData() const =0
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
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:645
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
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:456
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:542
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:869
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:2993
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:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
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:1296
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition TSystem.cxx:1350
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