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