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