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