Logo ROOT   6.18/05
Reference Guide
SplitGLView.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Helper classes for the alice_esd_split.C demo.
4///
5/// \macro_code
6///
7/// \author Bertrand Bellenot
8
9#include "TApplication.h"
10#include "TSystem.h"
11#include "TGFrame.h"
12#include "TGLayout.h"
13#include "TGSplitter.h"
14#include "TGLWidget.h"
15#include "TEvePad.h"
16#include "TGeoManager.h"
17#include "TString.h"
18#include "TGMenu.h"
19#include "TGStatusBar.h"
20#include "TGFileDialog.h"
21#include "TGMsgBox.h"
22#include "TGLPhysicalShape.h"
23#include "TGLLogicalShape.h"
24#include "HelpText.h"
25#include "TClass.h"
26#include "Riostream.h"
27#include "TEnv.h"
28#include "TGListTree.h"
29#include "TOrdCollection.h"
30#include "TArrayF.h"
31#include "TGHtml.h"
32#include "TPRegexp.h"
33
34#include "TEveManager.h"
35#include "TEveViewer.h"
36#include "TEveBrowser.h"
38#include "TEveProjectionAxes.h"
39#include "TEveScene.h"
40#include "TEveGeoNode.h"
41#include "TEveEventManager.h"
42#include "TEveTrack.h"
43#include "TEveSelection.h"
44
45#include "TRootEmbeddedCanvas.h"
46#include "TGSplitFrame.h"
47#include "TGLOverlayButton.h"
48#include "TGLEmbeddedViewer.h"
49#include "TGDockableFrame.h"
50#include "TGShapedFrame.h"
51#include "TGButton.h"
52#include "TGTab.h"
53#include "TEnv.h"
54
55#include "TCanvas.h"
56#include "TFormula.h"
57#include "TF1.h"
58#include "TH1F.h"
59
60#ifdef WIN32
61#include <TWin32SplashThread.h>
62#endif
63
64const char *filetypes[] = {
65 "ROOT files", "*.root",
66 "All files", "*",
67 0, 0
68};
69
70const char *rcfiletypes[] = {
71 "All files", "*",
72 0, 0
73};
74
75////////////////////////////////////////////////////////////////////////////////
76class TGShapedToolTip : public TGShapedFrame {
77
78private:
79 TGShapedToolTip(const TGShapedToolTip&); // Not implemented
80 TGShapedToolTip& operator=(const TGShapedToolTip&); // Not implemented
81
82protected:
83 Int_t fTextX, fTextY, fTextH;
84 TString fTextCol;
85
86 TRootEmbeddedCanvas *fEc; // embedded canvas for histogram
87 TH1 *fHist; // user histogram
88 TString fText; // info (as tool tip) text
89
90 virtual void DoRedraw() {}
91
92public:
93 TGShapedToolTip(const char *picname, Int_t cx=0, Int_t cy=0, Int_t cw=0,
94 Int_t ch=0, Int_t tx=0, Int_t ty=0, Int_t th=0,
95 const char *col="#ffffff");
96 virtual ~TGShapedToolTip();
97
98 virtual void CloseWindow();
99 void CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch);
100 void CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints);
101 TH1 *GetHisto() const { return fHist; }
102 const char *GetText() const { return fText.Data(); }
103 void Refresh();
104 void SetHisto(TH1 *hist);
105 void SetText(const char *text);
106 void SetTextColor(const char *col);
107 void SetTextAttributes(Int_t tx, Int_t ty, Int_t th, const char *col=0);
108 void Show(Int_t x, Int_t y, const char *text = 0, TH1 *hist = 0);
109
110 ClassDef(TGShapedToolTip, 0) // Shaped composite frame
111};
112
113////////////////////////////////////////////////////////////////////////////////
114class HtmlObjTable : public TObject {
115public: // make them public for shorter code
116
117 TString fName;
118 Int_t fNValues; // number of values
119 Int_t fNFields; // number of fields
120 TArrayF *fValues;
121 TString *fLabels;
122 Bool_t fExpand;
123
124 TString fHtml; // HTML output code
125
126 void Build();
127 void BuildTitle();
128 void BuildLabels();
129 void BuildTable();
130
131public:
132 HtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
133 virtual ~HtmlObjTable();
134
135 void SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
136 void SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
137 TString Html() const { return fHtml; }
138
139 ClassDef(HtmlObjTable, 0);
140};
141
142////////////////////////////////////////////////////////////////////////////////
143class HtmlSummary {
144public: // make them public for shorter code
145 Int_t fNTables;
146 TOrdCollection *fObjTables; // ->array of object tables
147 TString fHtml; // output HTML string
148 TString fTitle; // page title
149 TString fHeader; // HTML header
150 TString fFooter; // HTML footer
151
152 void MakeHeader();
153 void MakeFooter();
154
155public:
156 HtmlSummary(const char *title);
157 virtual ~HtmlSummary();
158
159 HtmlObjTable *AddTable(const char *name, Int_t nfields, Int_t nvals,
160 Bool_t exp=kTRUE, Option_t *opt="");
161 HtmlObjTable *GetTable(Int_t at) const { return (HtmlObjTable *)fObjTables->At(at); }
162 void Build();
163 void Clear(Option_t *option="");
164 void Reset(Option_t *option="");
165 TString Html() const { return fHtml; }
166
167 ClassDef(HtmlSummary, 0);
168};
169
170////////////////////////////////////////////////////////////////////////////////
171class SplitGLView : public TGMainFrame {
172
173public:
174 enum EMyCommands {
176 kHelpAbout, kGLPerspYOZ, kGLPerspXOZ, kGLPerspXOY, kGLXOY,
177 kGLXOZ, kGLZOY, kGLOrthoRotate, kGLOrthoDolly, kSceneUpdate,
178 kSceneUpdateAll, kSummaryUpdate
179 };
180
181private:
182 TEvePad *fPad; // pad used as geometry container
183 TGSplitFrame *fSplitFrame; // main (first) split frame
184 TGLEmbeddedViewer *fViewer0; // main GL viewer
185 TGLEmbeddedViewer *fViewer1; // first GL viewer
186 TGLEmbeddedViewer *fViewer2; // second GL viewer
187 TGLEmbeddedViewer *fActViewer; // actual (active) GL viewer
188 static HtmlSummary *fgHtmlSummary; // summary HTML table
189 static TGHtml *fgHtml;
190 TGMenuBar *fMenuBar; // main menu bar
191 TGPopupMenu *fMenuFile; // 'File' popup menu
192 TGPopupMenu *fMenuHelp; // 'Help' popup menu
193 TGPopupMenu *fMenuCamera; // 'Camera' popup menu
194 TGPopupMenu *fMenuScene; // 'Scene' popup menu
195 TGStatusBar *fStatusBar; // status bar
196 TGShapedToolTip *fShapedToolTip; // shaped tooltip
197 Bool_t fIsEmbedded;
198
199 TEveViewer *fViewer[3];
200 TEveProjectionManager *fRPhiMgr;
201 TEveProjectionManager *fRhoZMgr;
202
203public:
204 SplitGLView(const TGWindow *p=0, UInt_t w=800, UInt_t h=600, Bool_t embed=kFALSE);
205 virtual ~SplitGLView();
206
207 void ItemClicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
208 void HandleMenu(Int_t id);
209 void OnClicked(TObject *obj);
210 void OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy);
211 void OnMouseOver(TGLPhysicalShape *shape);
212 void OnViewerActivated();
213 void OpenFile(const char *fname);
214 void SwapToMainView(TGLViewerBase *viewer);
215 void ToggleOrthoRotate();
216 void ToggleOrthoDolly();
217 void UnDock(TGLViewerBase *viewer);
218 void LoadConfig(const char *fname);
219 void SaveConfig(const char *fname);
220 static void UpdateSummary();
221
222 TEveProjectionManager *GetRPhiMgr() const { return fRPhiMgr; }
223 TEveProjectionManager *GetRhoZMgr() const { return fRhoZMgr; }
224
225 ClassDef(SplitGLView, 0)
226};
227
228TEveProjectionManager *gRPhiMgr = 0;
229TEveProjectionManager *gRhoZMgr = 0;
230
231ClassImp(TGShapedToolTip)
232ClassImp(HtmlObjTable)
233ClassImp(HtmlSummary)
234ClassImp(SplitGLView)
235
236HtmlSummary *SplitGLView::fgHtmlSummary = 0;
237TGHtml *SplitGLView::fgHtml = 0;
238
239//______________________________________________________________________________
240TGShapedToolTip::TGShapedToolTip(const char *pname, Int_t cx, Int_t cy, Int_t cw,
241 Int_t ch, Int_t tx, Int_t ty, Int_t th,
242 const char *col) :
243 TGShapedFrame(pname, gClient->GetDefaultRoot(), 400, 300, kTempFrame |
244 kHorizontalFrame), fEc(0), fHist(0)
245{
246 // Shaped window constructor
247
248 fTextX = tx; fTextY = ty; fTextH = th;
249 if (col)
250 fTextCol = col;
251 else
252 fTextCol = "0x000000";
253
254 // create the embedded canvas
255 if ((cx > 0) && (cy > 0) && (cw > 0) && (ch > 0)) {
256 Int_t lhRight = fWidth-cx-cw;
257 Int_t lhBottom = fHeight-cy-ch;
258 fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
259 AddFrame(fEc, new TGLayoutHints(kLHintsTop | kLHintsLeft, cx,
260 lhRight, cy, lhBottom));
261 }
262 MapSubwindows();
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(0, "\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);
316 AddFrame(fEc, new TGLayoutHints(kLHintsTop | kLHintsLeft, cx,
317 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,
387 const char *col)
388{
389 // Set text attributes (position, size and color).
390
391 fTextX = tx; fTextY = ty; 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
533 fObjTables = new TOrdCollection();
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,
546 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; fObjTables = 0;
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(0), fShapedToolTip(0), fIsEmbedded(embed)
625{
626 // Main frame constructor.
627
628 TGSplitFrame *frm;
629 TEveScene *s = 0;
630 TGHorizontalFrame *hfrm;
631 TGDockableFrame *dfrm;
632 TGPictureButton *button;
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 |
668 kLHintsLeft, 0, 4, 0, 0));
669 fMenuBar->AddPopup("&Camera", fMenuCamera, new TGLayoutHints(kLHintsTop |
670 kLHintsLeft, 0, 4, 0, 0));
671 fMenuBar->AddPopup("&Scene", fMenuScene, new TGLayoutHints(kLHintsTop |
672 kLHintsLeft, 0, 4, 0, 0));
673 fMenuBar->AddPopup("&Help", fMenuHelp, new TGLayoutHints(kLHintsTop |
674 kLHintsRight));
675
676 AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
677
678 // connect menu signals to our menu handler slot
679 fMenuFile->Connect("Activated(Int_t)", "SplitGLView", this,
680 "HandleMenu(Int_t)");
681 fMenuCamera->Connect("Activated(Int_t)", "SplitGLView", this,
682 "HandleMenu(Int_t)");
683 fMenuScene->Connect("Activated(Int_t)", "SplitGLView", this,
684 "HandleMenu(Int_t)");
685 fMenuHelp->Connect("Activated(Int_t)", "SplitGLView", this,
686 "HandleMenu(Int_t)");
687
688 if (fIsEmbedded && gEve) {
689 // use status bar from the browser
690 fStatusBar = gEve->GetBrowser()->GetStatusBar();
691 }
692 else {
693 // create the status bar
694 Int_t parts[] = {45, 15, 10, 30};
695 fStatusBar = new TGStatusBar(this, 50, 10);
696 fStatusBar->SetParts(parts, 4);
697 AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
698 0, 0, 10, 0));
699 }
700
701 // create eve pad (our geometry container)
702 fPad = new TEvePad();
703 fPad->SetFillColor(kBlack);
704
705 // create the split frames
706 fSplitFrame = new TGSplitFrame(this, 800, 600);
707 AddFrame(fSplitFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
708 // split it once
709 fSplitFrame->HSplit(434);
710 // then split each part again (this will make four parts)
711 fSplitFrame->GetSecond()->VSplit(266);
712 fSplitFrame->GetSecond()->GetSecond()->VSplit(266);
713
714 TGLOverlayButton *but1, *but2, *but3, *but4, *but5, *but6;
715 // get top (main) split frame
716 frm = fSplitFrame->GetFirst();
717 frm->SetName("Main_View");
718
719 // create (embed) a GL viewer inside
720 fViewer0 = new TGLEmbeddedViewer(frm, fPad);
721 but1 = new TGLOverlayButton(fViewer0, "Swap", 10.0, -10.0, 55.0, 16.0);
722 but1->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
723 but2 = new TGLOverlayButton(fViewer0, "Undock", 70.0, -10.0, 55.0, 16.0);
724 but2->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
725 frm->AddFrame(fViewer0->GetFrame(), new TGLayoutHints(kLHintsExpandX |
727 // set the camera to perspective (XOZ) for this viewer
728 fViewer0->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
729 // connect signal we are interested to
730 fViewer0->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
731 "OnMouseOver(TGLPhysicalShape*)");
732 fViewer0->Connect("Activated()", "SplitGLView", this,
733 "OnViewerActivated()");
734 fViewer0->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
735 "SplitGLView", this,
736 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
737 fViewer0->Connect("Clicked(TObject*)", "SplitGLView", this,
738 "OnClicked(TObject*)");
739 fViewer[0] = new TEveViewer("SplitGLViewer[0]");
740 fViewer[0]->SetGLViewer(fViewer0, fViewer0->GetFrame());
741 fViewer[0]->IncDenyDestroy();
742 if (fIsEmbedded && gEve) {
743 fViewer[0]->AddScene(gEve->GetGlobalScene());
744 fViewer[0]->AddScene(gEve->GetEventScene());
745 gEve->GetViewers()->AddElement(fViewer[0]);
746 s = gEve->SpawnNewScene("Rho-Z Projection");
747 // projections
749 s->AddElement(fRhoZMgr);
750 gEve->AddToListTree(fRhoZMgr, kTRUE);
751 TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
752 s->AddElement(a);
753 }
754
755 // get bottom left split frame
756 frm = fSplitFrame->GetSecond()->GetFirst();
757 frm->SetName("Bottom_Left");
758
759 // create (embed) a GL viewer inside
760 fViewer1 = new TGLEmbeddedViewer(frm, fPad);
761 but3 = new TGLOverlayButton(fViewer1, "Swap", 10.0, -10.0, 55.0, 16.0);
762 but3->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
763 but4 = new TGLOverlayButton(fViewer1, "Undock", 70.0, -10.0, 55.0, 16.0);
764 but4->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
765 frm->AddFrame(fViewer1->GetFrame(), new TGLayoutHints(kLHintsExpandX |
767
768 // set the camera to orthographic (XOY) for this viewer
769 fViewer1->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
770 // connect signal we are interested to
771 fViewer1->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
772 "OnMouseOver(TGLPhysicalShape*)");
773 fViewer1->Connect("Activated()", "SplitGLView", this,
774 "OnViewerActivated()");
775 fViewer1->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
776 "SplitGLView", this,
777 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
778 fViewer1->Connect("Clicked(TObject*)", "SplitGLView", this,
779 "OnClicked(TObject*)");
780 fViewer[1] = new TEveViewer("SplitGLViewer[1]");
781 fViewer[1]->SetGLViewer(fViewer1, fViewer1->GetFrame());
782 fViewer[1]->IncDenyDestroy();
783 if (fIsEmbedded && gEve) {
784 fRhoZMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
785 fRhoZMgr->ImportElements((TEveElement *)gEve->GetEventScene());
786 fViewer[1]->AddScene(s);
787 gEve->GetViewers()->AddElement(fViewer[1]);
788 gRhoZMgr = fRhoZMgr;
789
790 s = gEve->SpawnNewScene("R-Phi Projection");
791 // projections
793 s->AddElement(fRPhiMgr);
794 gEve->AddToListTree(fRPhiMgr, kTRUE);
795 TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
796 s->AddElement(a);
797 }
798
799 // get bottom center split frame
800 frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
801 frm->SetName("Bottom_Center");
802
803 // create (embed) a GL viewer inside
804 fViewer2 = new TGLEmbeddedViewer(frm, fPad);
805 but5 = new TGLOverlayButton(fViewer2, "Swap", 10.0, -10.0, 55.0, 16.0);
806 but5->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
807 but6 = new TGLOverlayButton(fViewer2, "Undock", 70.0, -10.0, 55.0, 16.0);
808 but6->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
809 frm->AddFrame(fViewer2->GetFrame(), new TGLayoutHints(kLHintsExpandX |
811
812 // set the camera to orthographic (XOY) for this viewer
813 fViewer2->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
814 // connect signal we are interested to
815 fViewer2->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
816 "OnMouseOver(TGLPhysicalShape*)");
817 fViewer2->Connect("Activated()", "SplitGLView", this,
818 "OnViewerActivated()");
819 fViewer2->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
820 "SplitGLView", this,
821 "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
822 fViewer2->Connect("Clicked(TObject*)", "SplitGLView", this,
823 "OnClicked(TObject*)");
824 fViewer[2] = new TEveViewer("SplitGLViewer[2]");
825 fViewer[2]->SetGLViewer(fViewer2, fViewer2->GetFrame());
826 fViewer[2]->IncDenyDestroy();
827 if (fIsEmbedded && gEve) {
828 fRPhiMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
829 fRPhiMgr->ImportElements((TEveElement *)gEve->GetEventScene());
830 fViewer[2]->AddScene(s);
831 gEve->GetViewers()->AddElement(fViewer[2]);
832 gRPhiMgr = fRPhiMgr;
833 }
834
835 // get bottom right split frame
836 frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
837 frm->SetName("Bottom_Right");
838
839 dfrm = new TGDockableFrame(frm);
840 dfrm->SetFixedSize(kFALSE);
841 dfrm->EnableHide(kFALSE);
842 hfrm = new TGHorizontalFrame(dfrm);
843 button= new TGPictureButton(hfrm, gClient->GetPicture("swap.png"));
844 button->SetToolTipText("Swap to big view");
845 hfrm->AddFrame(button);
846 button->Connect("Clicked()","SplitGLView",this,"SwapToMainView(TGLViewerBase*=0)");
847 fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table");
848 fgHtml = new TGHtml(hfrm, 100, 100, -1);
852
853 if (fIsEmbedded && gEve) {
854 gEve->GetListTree()->Connect("Clicked(TGListTreeItem*, Int_t, Int_t, Int_t)",
855 "SplitGLView", this, "ItemClicked(TGListTreeItem*, Int_t, Int_t, Int_t)");
856 }
857
858 fShapedToolTip = new TGShapedToolTip("Default.png", 120, 22, 160, 110,
859 23, 115, 12, "#ffff80");
860 Resize(GetDefaultSize());
861 MapSubwindows();
862 MapWindow();
863 LoadConfig(".everc");
864}
865
866//______________________________________________________________________________
867SplitGLView::~SplitGLView()
868{
869 // Clean up main frame...
870 //Cleanup();
871
872 fMenuFile->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
873 fMenuCamera->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
874 fMenuScene->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
875 fMenuHelp->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
876 fViewer0->Disconnect("MouseOver(TGLPhysicalShape*)", this,
877 "OnMouseOver(TGLPhysicalShape*)");
878 fViewer0->Disconnect("Activated()", this, "OnViewerActivated()");
879 fViewer0->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
880 this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
881 fViewer1->Disconnect("MouseOver(TGLPhysicalShape*)", this,
882 "OnMouseOver(TGLPhysicalShape*)");
883 fViewer1->Disconnect("Activated()", this, "OnViewerActivated()");
884 fViewer1->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
885 this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
886 fViewer2->Disconnect("MouseOver(TGLPhysicalShape*)", this,
887 "OnMouseOver(TGLPhysicalShape*)");
888 fViewer2->Disconnect("Activated()", this, "OnViewerActivated()");
889 fViewer2->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
890 this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
891 if (!fIsEmbedded) {
892 delete fViewer[0];
893 delete fViewer[1];
894 delete fViewer[2];
895 }
896 delete fShapedToolTip;
897 delete fMenuFile;
898 delete fMenuScene;
899 delete fMenuCamera;
900 delete fMenuHelp;
901 if (!fIsEmbedded)
902 delete fMenuBar;
903 delete fViewer0;
904 delete fViewer1;
905 delete fViewer2;
906 delete fSplitFrame;
907 delete fPad;
908 if (!fIsEmbedded) {
909 delete fStatusBar;
911 }
912}
913
914//______________________________________________________________________________
915void SplitGLView::HandleMenu(Int_t id)
916{
917 // Handle menu items.
918
919 static TString rcdir(".");
920 static TString rcfile(".everc");
921
922 switch (id) {
923
924 case kFileOpen:
925 {
926 static TString dir(".");
927 TGFileInfo fi;
928 fi.fFileTypes = filetypes;
929 fi.fIniDir = StrDup(dir);
930 new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
931 if (fi.fFilename)
933 dir = fi.fIniDir;
934 }
935 break;
936
937 case kFileLoadConfig:
938 {
939 TGFileInfo fi;
940 fi.fFileTypes = rcfiletypes;
941 fi.fIniDir = StrDup(rcdir);
942 fi.fFilename = StrDup(rcfile);
943 new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
944 if (fi.fFilename) {
945 rcfile = fi.fFilename;
946 LoadConfig(fi.fFilename);
947 }
948 rcdir = fi.fIniDir;
949 }
950 break;
951
952 case kFileSaveConfig:
953 {
954 TGFileInfo fi;
955 fi.fFileTypes = rcfiletypes;
956 fi.fIniDir = StrDup(rcdir);
957 fi.fFilename = StrDup(rcfile);
958 new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
959 if (fi.fFilename) {
960 rcfile = fi.fFilename;
961 SaveConfig(fi.fFilename);
962 }
963 rcdir = fi.fIniDir;
964 }
965 break;
966
967 case kFileExit:
968 CloseWindow();
969 break;
970
971 case kGLPerspYOZ:
972 if (fActViewer)
973 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspYOZ);
974 break;
975 case kGLPerspXOZ:
976 if (fActViewer)
977 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
978 break;
979 case kGLPerspXOY:
980 if (fActViewer)
981 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
982 break;
983 case kGLXOY:
984 if (fActViewer)
985 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
986 break;
987 case kGLXOZ:
988 if (fActViewer)
989 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOZ);
990 break;
991 case kGLZOY:
992 if (fActViewer)
993 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
994 break;
995 case kGLOrthoRotate:
996 ToggleOrthoRotate();
997 break;
998 case kGLOrthoDolly:
999 ToggleOrthoDolly();
1000 break;
1001
1002 case kSceneUpdate:
1003 if (fActViewer)
1004 fActViewer->UpdateScene();
1005 UpdateSummary();
1006 break;
1007
1008 case kSceneUpdateAll:
1009 fViewer0->UpdateScene();
1010 fViewer1->UpdateScene();
1011 fViewer2->UpdateScene();
1012 UpdateSummary();
1013 break;
1014
1015 case kSummaryUpdate:
1016 UpdateSummary();
1017 break;
1018
1019 case kHelpAbout:
1020 {
1021#ifdef R__UNIX
1022 TString rootx = TROOT::GetBinDir() + "/root -a &";
1023 gSystem->Exec(rootx);
1024#else
1025#ifdef WIN32
1027#else
1028 char str[32];
1029 sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1030 hd = new TRootHelpDialog(this, str, 600, 400);
1031 hd->SetText(gHelpAbout);
1032 hd->Popup();
1033#endif
1034#endif
1035 }
1036 break;
1037
1038 default:
1039 break;
1040 }
1041}
1042
1043//______________________________________________________________________________
1044void SplitGLView::OnClicked(TObject *obj)
1045{
1046 // Handle click events in GL viewer
1047
1048 if (obj)
1049 fStatusBar->SetText(Form("User clicked on: \"%s\"", obj->GetName()), 1);
1050 else
1051 fStatusBar->SetText("", 1);
1052}
1053
1054//______________________________________________________________________________
1055void SplitGLView::OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy)
1056{
1057 // Slot used to handle "OnMouseIdle" signal coming from any GL viewer.
1058 // We receive a pointer on the physical shape in which the mouse cursor is
1059 // and the actual cursor position (x,y)
1060
1061 Window_t wtarget;
1062 Int_t x = 0, y = 0;
1063
1064 static TH1F *h1f = 0;
1065 TFormula *form1 = new TFormula("form1","abs(sin(x)/x)");
1066 TF1 *sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
1067 sqroot->SetParameters(10,4,1,20);
1068 if (h1f == 0)
1069 h1f = new TH1F("h1f","",50,0,10);
1070 h1f->Reset();
1071 h1f->SetFillColor(45);
1072 h1f->SetStats(0);
1073 h1f->FillRandom("sqroot",200);
1074
1075 if (fShapedToolTip) {
1076 fShapedToolTip->UnmapWindow();
1077 }
1078 if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal()) {
1079 // get the actual viewer who actually emitted the signal
1080 TGLEmbeddedViewer *actViewer = dynamic_cast<TGLEmbeddedViewer*>((TQObject*)gTQSender);
1081 // then translate coordinates from the root (screen) coordinates
1082 // to the actual frame (viewer) ones
1083 gVirtualX->TranslateCoordinates(actViewer->GetFrame()->GetId(),
1084 gClient->GetDefaultRoot()->GetId(), posx, posy, x, y,
1085 wtarget);
1086 // Then display our tooltip at this x,y location
1087 if (fShapedToolTip) {
1088 fShapedToolTip->Show(x+5, y+5, Form("%s\n \n%s",
1089 shape->GetLogical()->GetExternal()->IsA()->GetName(),
1090 shape->GetLogical()->GetExternal()->GetName()), h1f);
1091 }
1092 }
1093}
1094
1095//______________________________________________________________________________
1096void SplitGLView::OnMouseOver(TGLPhysicalShape *shape)
1097{
1098 // Slot used to handle "OnMouseOver" signal coming from any GL viewer.
1099 // We receive a pointer on the physical shape in which the mouse cursor is.
1100
1101 // display information on the physical shape in the status bar
1102 if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal())
1103 fStatusBar->SetText(Form("Mouse Over: \"%s\"",
1104 shape->GetLogical()->GetExternal()->GetName()), 0);
1105 else
1106 fStatusBar->SetText("", 0);
1107}
1108
1109//______________________________________________________________________________
1110void SplitGLView::OnViewerActivated()
1111{
1112 // Slot used to handle "Activated" signal coming from any GL viewer.
1113 // Used to know which GL viewer is active.
1114
1115 static Pixel_t green = 0;
1116 // set the actual GL viewer frame to default color
1117 if (fActViewer && fActViewer->GetFrame())
1118 fActViewer->GetFrame()->ChangeBackground(GetDefaultFrameBackground());
1119
1120 // change the actual GL viewer to the one who emitted the signal
1121 // fActViewer = (TGLEmbeddedViewer *)gTQSender;
1122 fActViewer = dynamic_cast<TGLEmbeddedViewer*>((TQObject*)gTQSender);
1123
1124 if (fActViewer == 0) {
1125 printf ("dyncast failed ...\n");
1126 return;
1127 }
1128
1129 // get the highlight color (only once)
1130 if (green == 0) {
1131 gClient->GetColorByName("green", green);
1132 }
1133 // set the new actual GL viewer frame to highlight color
1134 if (fActViewer->GetFrame())
1135 fActViewer->GetFrame()->ChangeBackground(green);
1136
1137 // update menu entries to match actual viewer's options
1138 if (fActViewer->GetOrthoXOYCamera()->GetDollyToZoom() &&
1139 fActViewer->GetOrthoXOZCamera()->GetDollyToZoom() &&
1140 fActViewer->GetOrthoZOYCamera()->GetDollyToZoom())
1141 fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1142 else
1143 fMenuCamera->CheckEntry(kGLOrthoDolly);
1144
1145 if (fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1146 fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1147 fActViewer->GetOrthoXOYCamera()->GetEnableRotate())
1148 fMenuCamera->CheckEntry(kGLOrthoRotate);
1149 else
1150 fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1151}
1152
1153//______________________________________________________________________________
1154void SplitGLView::OpenFile(const char *fname)
1155{
1156 // Open a Root file to display a geometry in the GL viewers.
1157
1158 TString filename = fname;
1159 // check if the file type is correct
1160 if (!filename.EndsWith(".root")) {
1161 new TGMsgBox(gClient->GetRoot(), this, "OpenFile",
1162 Form("The file \"%s\" is not a root file!", fname),
1164 return;
1165 }
1166 // check if the root file contains a geometry
1167 if (TGeoManager::Import(fname) == 0) {
1168 new TGMsgBox(gClient->GetRoot(), this, "OpenFile",
1169 Form("The file \"%s\" does't contain a geometry", fname),
1171 return;
1172 }
1174 // delete previous primitives (if any)
1175 fPad->GetListOfPrimitives()->Delete();
1176 // and add the geometry to eve pad (container)
1177 fPad->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume());
1178 // paint the geometry in each GL viewer
1179 fViewer0->PadPaint(fPad);
1180 fViewer1->PadPaint(fPad);
1181 fViewer2->PadPaint(fPad);
1182}
1183
1184//______________________________________________________________________________
1185void SplitGLView::ToggleOrthoRotate()
1186{
1187 // Toggle state of the 'Ortho allow rotate' menu entry.
1188
1189 if (fMenuCamera->IsEntryChecked(kGLOrthoRotate))
1190 fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1191 else
1192 fMenuCamera->CheckEntry(kGLOrthoRotate);
1193 Bool_t state = fMenuCamera->IsEntryChecked(kGLOrthoRotate);
1194 if (fActViewer) {
1195 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1196 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1197 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1198 }
1199}
1200
1201//______________________________________________________________________________
1202void SplitGLView::ToggleOrthoDolly()
1203{
1204 // Toggle state of the 'Ortho allow dolly' menu entry.
1205
1206 if (fMenuCamera->IsEntryChecked(kGLOrthoDolly))
1207 fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1208 else
1209 fMenuCamera->CheckEntry(kGLOrthoDolly);
1210 Bool_t state = ! fMenuCamera->IsEntryChecked(kGLOrthoDolly);
1211 if (fActViewer) {
1212 fActViewer->GetOrthoXOYCamera()->SetDollyToZoom(state);
1213 fActViewer->GetOrthoXOZCamera()->SetDollyToZoom(state);
1214 fActViewer->GetOrthoZOYCamera()->SetDollyToZoom(state);
1215 }
1216}
1217
1218//______________________________________________________________________________
1219void SplitGLView::ItemClicked(TGListTreeItem *item, Int_t, Int_t, Int_t)
1220{
1221 // Item has been clicked, based on mouse button do:
1222
1223 static const TEveException eh("SplitGLView::ItemClicked ");
1224 TEveElement* re = (TEveElement*)item->GetUserData();
1225 if(re == 0) return;
1226 TObject* obj = re->GetObject(eh);
1227 if (obj->InheritsFrom("TEveViewer")) {
1228 TGLViewer *v = ((TEveViewer *)obj)->GetGLViewer();
1229 //v->Activated();
1230 if (v->InheritsFrom("TGLEmbeddedViewer")) {
1232 gVirtualX->SetInputFocus(ev->GetGLWidget()->GetId());
1233 }
1234 }
1235}
1236
1237//______________________________________________________________________________
1238void SplitGLView::LoadConfig(const char *fname)
1239{
1240
1241 Int_t height, width;
1242 TEnv *env = new TEnv(fname);
1243
1244 Int_t mainheight = env->GetValue("MainView.Height", 434);
1245 Int_t blwidth = env->GetValue("Bottom.Left.Width", 266);
1246 Int_t bcwidth = env->GetValue("Bottom.Center.Width", 266);
1247 Int_t brwidth = env->GetValue("Bottom.Right.Width", 266);
1248 Int_t top_height = env->GetValue("Right.Tab.Height", 0);
1249 Int_t bottom_height = env->GetValue("Bottom.Tab.Height", 0);
1250
1251 if (fIsEmbedded && gEve) {
1252 Int_t sel = env->GetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1253 Int_t hi = env->GetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1254 gEve->GetBrowser()->EveMenu(9+sel);
1255 gEve->GetBrowser()->EveMenu(13+hi);
1256
1257 width = env->GetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1258 height = env->GetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1259 gEve->GetBrowser()->Resize(width, height);
1260 }
1261
1262 // top (main) split frame
1263 width = fSplitFrame->GetFirst()->GetWidth();
1264 fSplitFrame->GetFirst()->Resize(width, mainheight);
1265 // bottom left split frame
1266 height = fSplitFrame->GetSecond()->GetFirst()->GetHeight();
1267 fSplitFrame->GetSecond()->GetFirst()->Resize(blwidth, height);
1268 // bottom center split frame
1269 height = fSplitFrame->GetSecond()->GetSecond()->GetFirst()->GetHeight();
1270 fSplitFrame->GetSecond()->GetSecond()->GetFirst()->Resize(bcwidth, height);
1271 // bottom right split frame
1272 height = fSplitFrame->GetSecond()->GetSecond()->GetSecond()->GetHeight();
1273 fSplitFrame->GetSecond()->GetSecond()->GetSecond()->Resize(brwidth, height);
1274
1275 fSplitFrame->Layout();
1276
1277 if (fIsEmbedded && gEve) {
1278 width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetWidth();
1279 ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->Resize(width, bottom_height);
1280 width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetWidth();
1281 ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->Resize(width, top_height);
1282 }
1283}
1284
1285//______________________________________________________________________________
1286void SplitGLView::SaveConfig(const char *fname)
1287{
1288
1289 Int_t bottom_height = 0;
1290 Int_t top_height = 0;
1291 TGSplitFrame *frm;
1292 TEnv *env = new TEnv(fname);
1293
1294 if (fIsEmbedded && gEve) {
1295 env->SetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1296 env->SetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1297 }
1298 // get top (main) split frame
1299 frm = fSplitFrame->GetFirst();
1300 env->SetValue("MainView.Height", (Int_t)frm->GetHeight());
1301 // get bottom left split frame
1302 frm = fSplitFrame->GetSecond()->GetFirst();
1303 env->SetValue("Bottom.Left.Width", (Int_t)frm->GetWidth());
1304 // get bottom center split frame
1305 frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
1306 env->SetValue("Bottom.Center.Width", (Int_t)frm->GetWidth());
1307 // get bottom right split frame
1308 frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
1309 env->SetValue("Bottom.Right.Width", (Int_t)frm->GetWidth());
1310 if (fIsEmbedded && gEve) {
1311 top_height = (Int_t)((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetHeight();
1312 env->SetValue("Right.Tab.Height", top_height);
1313 bottom_height = (Int_t)((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetHeight();
1314 env->SetValue("Bottom.Tab.Height", bottom_height);
1315
1316 env->SetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1317 env->SetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1318 }
1319
1320 env->SaveLevel(kEnvLocal);
1321#ifdef R__WIN32
1322 if (!gSystem->AccessPathName(Form("%s.new", fname))) {
1323 gSystem->Exec(Form("del %s", fname));
1324 gSystem->Rename(Form("%s.new", fname), fname);
1325 }
1326#endif
1327}
1328
1329//______________________________________________________________________________
1330void SplitGLView::SwapToMainView(TGLViewerBase *viewer)
1331{
1332 // Swap frame embedded in a splitframe to the main view (slot method).
1333
1334 TGCompositeFrame *parent = 0;
1335 if (!fSplitFrame->GetFirst()->GetFrame())
1336 return;
1337 if (viewer == 0) {
1339 parent = (TGCompositeFrame *)src->GetParent();
1340 while (parent && !parent->InheritsFrom("TGSplitFrame")) {
1341 parent = (TGCompositeFrame *)parent->GetParent();
1342 }
1343 }
1344 else {
1345 TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1346 if (!src) return;
1348 but->ResetState();
1349 parent = (TGCompositeFrame *)src->GetParent();
1350 }
1351 if (parent && parent->InheritsFrom("TGSplitFrame"))
1352 ((TGSplitFrame *)parent)->SwitchToMain();
1353}
1354
1355//______________________________________________________________________________
1356void SplitGLView::UnDock(TGLViewerBase *viewer)
1357{
1358 // Undock frame embedded in a splitframe (slot method).
1359
1360 TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1361 if (!src) return;
1363 but->ResetState();
1364 TGCompositeFrame *parent = (TGCompositeFrame *)src->GetParent();
1365 if (parent && parent->InheritsFrom("TGSplitFrame"))
1366 ((TGSplitFrame *)parent)->ExtractFrame();
1367}
1368
1369//______________________________________________________________________________
1370void SplitGLView::UpdateSummary()
1371{
1372 // Update summary of current event.
1373
1376 Int_t k;
1377 TEveElement *el;
1378 HtmlObjTable *table;
1379 TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
1380 if (mgr) {
1381 fgHtmlSummary->Clear("D");
1382 for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) {
1383 el = ((TEveElement*)(*i));
1384 if (el->IsA() == TEvePointSet::Class()) {
1385 TEvePointSet *ps = (TEvePointSet *)el;
1386 TString ename = ps->GetElementName();
1387 TString etitle = ps->GetElementTitle();
1388 if (ename.First('\'') != kNPOS)
1389 ename.Remove(ename.First('\''));
1390 etitle.Remove(0, 2);
1391 Int_t nel = atoi(etitle.Data());
1392 table = fgHtmlSummary->AddTable(ename, 0, nel);
1393 }
1394 else if (el->IsA() == TEveTrackList::Class()) {
1396 TString ename = tracks->GetElementName();
1397 if (ename.First('\'') != kNPOS)
1398 ename.Remove(ename.First('\''));
1399 table = fgHtmlSummary->AddTable(ename.Data(), 5,
1400 tracks->NumChildren(), kTRUE, "first");
1401 table->SetLabel(0, "Momentum");
1402 table->SetLabel(1, "P_t");
1403 table->SetLabel(2, "Phi");
1404 table->SetLabel(3, "Theta");
1405 table->SetLabel(4, "Eta");
1406 k=0;
1407 for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) {
1408 Float_t p = ((TEveTrack*)(*j))->GetMomentum().Mag();
1409 table->SetValue(0, k, p);
1410 Float_t pt = ((TEveTrack*)(*j))->GetMomentum().Perp();
1411 table->SetValue(1, k, pt);
1412 Float_t phi = ((TEveTrack*)(*j))->GetMomentum().Phi();
1413 table->SetValue(2, k, phi);
1414 Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta();
1415 table->SetValue(3, k, theta);
1416 Float_t eta = ((TEveTrack*)(*j))->GetMomentum().Eta();
1417 table->SetValue(4, k, eta);
1418 ++k;
1419 }
1420 }
1421 }
1422 fgHtmlSummary->Build();
1423 fgHtml->Clear();
1424 fgHtml->ParseText((char*)fgHtmlSummary->Html().Data());
1425 fgHtml->Layout();
1426 }
1427}
1428
1429
1430#ifdef __CINT__
1431void SplitGLView()
1432{
1433 printf("This script is used via ACLiC by the macro \"alice_esd_split.C\"\n");
1434 printf("To see it in action, just run \".x alice_esd_split.C\"\n");
1435 return;
1436}
1437#endif
1438
1439
void Class()
Definition: Class.C:29
SVector< double, 2 > v
Definition: Dict.h:5
ULong_t Pixel_t
Definition: GuiTypes.h:39
Handle_t Window_t
Definition: GuiTypes.h:28
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:14
#define h(i)
Definition: RSha256.hxx:106
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
#define ClassImp(name)
Definition: Rtypes.h:365
@ kBlack
Definition: Rtypes.h:63
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kEnvLocal
Definition: TEnv.h:73
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
#define gClient
Definition: TGClient.h:166
@ kFDOpen
Definition: TGFileDialog.h:38
@ kFDSave
Definition: TGFileDialog.h:39
@ kTempFrame
Definition: TGFrame.h:71
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
@ kMBOk
Definition: TGMsgBox.h:44
@ kMBIconExclamation
Definition: TGMsgBox.h:35
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
float type_of_call hi(const int &, const int &)
double exp(double)
R__EXTERN void * gTQSender
Definition: TQObject.h:44
#define gROOT
Definition: TROOT.h:414
@ kHelpAbout
@ kFileOpen
@ kFileLoadConfig
@ kFileSaveConfig
char * Form(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
#define gVirtualX
Definition: TVirtualX.h:345
#define free
Definition: civetweb.c:1539
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Array of floats (32 bits per element).
Definition: TArrayF.h:27
void SetAt(Double_t v, Int_t i)
Definition: TArrayF.h:51
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Definition: TCanvas.cxx:712
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2286
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:693
The TEnv class reads config files, by default named .rootrc.
Definition: TEnv.h:125
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Definition: TEnv.cxx:736
virtual void SaveLevel(EEnvLevel level)
Write the resource file for a certain level.
Definition: TEnv.cxx:664
void EveMenu(Int_t id)
Handle events from Eve menu.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:34
List_i EndChildren()
Definition: TEveElement.h:165
List_i BeginChildren()
Definition: TEveElement.h:164
List_t::iterator List_i
Definition: TEveElement.h:70
virtual TObject * GetObject(const TEveException &eh) const
Get a TObject associated with this render-element.
Base class for event management and navigation.
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:103
TGListTree * GetListTree() const
Get default list-tree widget.
TEveViewerList * GetViewers() const
Definition: TEveManager.h:145
TEveSelection * GetSelection() const
Definition: TEveManager.h:129
TEveScene * GetGlobalScene() const
Definition: TEveManager.h:147
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=0)
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
TEveSelection * GetHighlight() const
Definition: TEveManager.h:130
TEveScene * GetEventScene() const
Definition: TEveManager.h:148
TEveEventManager * GetCurrentEvent() const
Definition: TEveManager.h:149
This was intended as a TPad wrapper to allow smart updates of groups of pads.
Definition: TEvePad.h:18
TEvePointSet is a render-element holding a collection of 3D points with optional per-point TRef and a...
Definition: TEvePointSet.h:36
Axes for non-linear projections.
Manager class for steering of projections and managing projected objects.
Eve representation of TGLScene.
Definition: TEveScene.h:27
Int_t GetPickToSelect() const
Definition: TEveSelection.h:64
A list of tracks supporting change of common attributes and selection based on track parameters.
Definition: TEveTrack.h:140
Visual representation of a track.
Definition: TEveTrack.h:33
virtual void AddElement(TEveElement *el)
Call base-class implementation.
Definition: TEveViewer.cxx:358
Eve representation of TGLViewer.
Definition: TEveViewer.h:31
1-Dim function class
Definition: TF1.h:211
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:638
The Formula class.
Definition: TFormula.h:84
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void AddFrame(TGFrame *f, TGLayoutHints *hints)
Add frame to dockable frame container. Frame and hints are NOT adopted.
void SetFixedSize(Bool_t fixed)
void EnableHide(Bool_t onoff)
Enable hiding.
char * fFilename
Definition: TGFileDialog.h:61
const char ** fFileTypes
Definition: TGFileDialog.h:63
char * fIniDir
Definition: TGFileDialog.h:62
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
UInt_t GetHeight() const
Definition: TGFrame.h:272
UInt_t GetWidth() const
Definition: TGFrame.h:271
Definition: TGHtml.h:872
Minimal GL-viewer that can be embedded in a standard ROOT frames.
TGCompositeFrame * GetFrame() const
TObject * GetExternal() const
GL-overlay button.
virtual void ResetState()
Concrete physical shape - a GL drawable.
const TGLLogicalShape * GetLogical() const
Base class for GL viewers.
Definition: TGLViewerBase.h:37
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:57
@ kCameraPerspXOY
Definition: TGLViewer.h:63
@ kCameraPerspXOZ
Definition: TGLViewer.h:63
@ kCameraPerspYOZ
Definition: TGLViewer.h:63
@ kCameraOrthoZOY
Definition: TGLViewer.h:64
@ kCameraOrthoXOY
Definition: TGLViewer.h:64
@ kCameraOrthoXOZ
Definition: TGLViewer.h:64
TGLWidget * GetGLWidget()
Definition: TGLViewer.h:225
virtual void * GetUserData() const =0
Handle_t GetId() const
Definition: TGObject.h:47
TGShapedFrame & operator=(const TGShapedFrame &)
TGSplitFrame * GetFirst() const
Definition: TGSplitFrame.h:105
TGSplitFrame * GetSecond() const
Definition: TGSplitFrame.h:107
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add a frame in the split frame using layout hints l.
virtual void SetName(const char *name)
Definition: TGWindow.h:125
const TGWindow * GetParent() const
Definition: TGWindow.h:85
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
void DefaultColors()
Set default volume colors according to A of material.
TGeoVolume * GetTopVolume() const
Definition: TGeoManager.h:531
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
virtual void Reset(Option_t *option="")
Reset.
Definition: TH1.cxx:9519
The TH1 histogram class.
Definition: TH1.h:56
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3428
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2664
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2981
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8404
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void DrawText(Int_t=0, Int_t=0, const char *="", Int_t=12, const char *=0, const char *="fixed", EText3DType=TImage::kPlain, const char *=0, Float_t=0)
Definition: TImage.h:200
virtual void PaintImage(Drawable_t, Int_t, Int_t, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0, Option_t *="")
Definition: TImage.h:243
virtual TObject * Clone(const char *) const
Make a clone of an object using the Streamer facility.
Definition: TImage.h:111
virtual void Clear(Option_t *option="")
Set name and title to empty strings ("").
Definition: TNamed.cxx:64
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
Ordered collection.
void Clear(Option_t *option="")
Remove all objects from the collection.
TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
void AddFirst(TObject *obj)
Insert object at beginning of collection.
void Delete(Option_t *option="")
Remove all objects from the collection AND delete all heap based objects.
virtual void SetBorderMode(Short_t bordermode)
Definition: TPad.h:318
virtual void Clear(Option_t *option="")
Clear all lines in this pavetext.
Definition: TPaveText.cxx:208
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2965
TGTab * GetTabBottom() const
Definition: TRootBrowser.h:142
TGStatusBar * GetStatusBar() const
Definition: TRootBrowser.h:139
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
TCanvas * GetCanvas() const
virtual void Add(TObject *obj)
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2177
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:499
const char * Data() const
Definition: TString.h:364
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:662
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:1286
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition: TSystem.cxx:1340
pt SetTextColor(4)
TPaveText * pt
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TH1 * GetHisto(TFile *inFile, const std::string name)
Definition: Helper.cxx:115
static constexpr double s
static constexpr double ps
TFile * OpenFile(const TString &fin)
Definition: tmvaglob.cxx:192
auto * a
Definition: textangle.C:12
void tracks()
Definition: tracks.C:47