64 const char *filetypes[] = {
65 "ROOT files",
"*.root",
70 const char *rcfiletypes[] = {
76 class TGShapedToolTip :
public TGShapedFrame {
79 TGShapedToolTip(
const TGShapedToolTip&);
80 TGShapedToolTip& operator=(
const TGShapedToolTip&);
83 Int_t fTextX, fTextY, fTextH;
86 TRootEmbeddedCanvas *fEc;
90 virtual void DoRedraw() {}
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();
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(); }
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);
110 ClassDef(TGShapedToolTip, 0)
114 class HtmlObjTable :
public TObject {
132 HtmlObjTable(
const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
133 virtual ~HtmlObjTable();
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; }
139 ClassDef(HtmlObjTable, 0);
146 TOrdCollection *fObjTables;
156 HtmlSummary(
const char *title);
157 virtual ~HtmlSummary();
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); }
163 void Clear(Option_t *option=
"");
164 void Reset(Option_t *option=
"");
165 TString Html()
const {
return fHtml; }
167 ClassDef(HtmlSummary, 0);
171 class SplitGLView :
public TGMainFrame {
175 kFileOpen, kFileExit, kFileLoadConfig, kFileSaveConfig,
176 kHelpAbout, kGLPerspYOZ, kGLPerspXOZ, kGLPerspXOY, kGLXOY,
177 kGLXOZ, kGLZOY, kGLOrthoRotate, kGLOrthoDolly, kSceneUpdate,
178 kSceneUpdateAll, kSummaryUpdate
183 TGSplitFrame *fSplitFrame;
184 TGLEmbeddedViewer *fViewer0;
185 TGLEmbeddedViewer *fViewer1;
186 TGLEmbeddedViewer *fViewer2;
187 TGLEmbeddedViewer *fActViewer;
188 static HtmlSummary *fgHtmlSummary;
189 static TGHtml *fgHtml;
191 TGPopupMenu *fMenuFile;
192 TGPopupMenu *fMenuHelp;
193 TGPopupMenu *fMenuCamera;
194 TGPopupMenu *fMenuScene;
195 TGStatusBar *fStatusBar;
196 TGShapedToolTip *fShapedToolTip;
199 TEveViewer *fViewer[3];
200 TEveProjectionManager *fRPhiMgr;
201 TEveProjectionManager *fRhoZMgr;
204 SplitGLView(
const TGWindow *p=0, UInt_t w=800, UInt_t h=600, Bool_t embed=kFALSE);
205 virtual ~SplitGLView();
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();
222 TEveProjectionManager *GetRPhiMgr()
const {
return fRPhiMgr; }
223 TEveProjectionManager *GetRhoZMgr()
const {
return fRhoZMgr; }
225 ClassDef(SplitGLView, 0)
228 TEveProjectionManager *gRPhiMgr = 0;
229 TEveProjectionManager *gRhoZMgr = 0;
231 ClassImp(TGShapedToolTip)
232 ClassImp(HtmlObjTable)
233 ClassImp(HtmlSummary)
234 ClassImp(SplitGLView)
236 HtmlSummary *SplitGLView::fgHtmlSummary = 0;
237 TGHtml *SplitGLView::fgHtml = 0;
240 TGShapedToolTip::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,
243 TGShapedFrame(pname, gClient->GetDefaultRoot(), 400, 300, kTempFrame |
244 kHorizontalFrame), fEc(0), fHist(0)
248 fTextX = tx; fTextY = ty; fTextH = th;
252 fTextCol =
"0x000000";
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));
264 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
268 TGShapedToolTip::~TGShapedToolTip()
279 void TGShapedToolTip::CloseWindow()
287 void TGShapedToolTip::Refresh()
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"))) {
300 img->DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
302 img->PaintImage(fId, 0, 0, 0, 0, 0, 0,
"opaque");
309 void TGShapedToolTip::CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch)
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));
320 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
327 void TGShapedToolTip::CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints)
331 fEc =
new TRootEmbeddedCanvas(
"ec",
this, cw, ch, 0);
332 AddFrame(fEc, hints);
335 Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
342 void TGShapedToolTip::SetHisto(TH1 *hist)
350 fEc->GetCanvas()->Clear();
352 fHist = (TH1 *)hist->Clone();
354 fEc->GetCanvas()->SetBorderMode(0);
355 fEc->GetCanvas()->SetFillColor(10);
356 fEc->GetCanvas()->cd();
358 fEc->GetCanvas()->Update();
364 void TGShapedToolTip::SetText(
const char *text)
376 void TGShapedToolTip::SetTextColor(
const char *col)
386 void TGShapedToolTip::SetTextAttributes(Int_t tx, Int_t ty, Int_t th,
391 fTextX = tx; fTextY = ty; fTextH = th;
399 void TGShapedToolTip::Show(Int_t x, Int_t y,
const char *text, TH1 *hist)
413 fEc->GetCanvas()->SetBorderMode(0);
414 fEc->GetCanvas()->SetFillColor(10);
415 fEc->GetCanvas()->cd();
417 fEc->GetCanvas()->Update();
423 HtmlObjTable::HtmlObjTable(
const char *name, Int_t nfields, Int_t nvals, Bool_t exp) :
424 fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
428 fValues =
new TArrayF[fNFields];
429 for (
int i=0;i<fNFields;i++)
430 fValues[i].Set(nvals);
431 fLabels =
new TString[fNFields];
435 HtmlObjTable::~HtmlObjTable()
444 void HtmlObjTable::Build()
448 fHtml =
"<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
451 if (fExpand && (fNFields > 0) && (fNValues > 0)) {
460 void HtmlObjTable::BuildTitle()
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>";
470 fHtml +=
"</i></b></font></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>";
477 fHtml +=
"</td></tr>";
481 void HtmlObjTable::BuildLabels()
486 fHtml +=
"<tr bgcolor=c0c0ff>";
487 fHtml +=
"<th> </th>";
488 for (i=0;i<fNFields;i++) {
497 void HtmlObjTable::BuildTable()
501 for (
int i = 0; i < fNValues; i++) {
503 fHtml +=
"<tr bgcolor=e0e0ff>";
505 fHtml +=
"<tr bgcolor=ffffff>";
507 TString name = fName;
508 name.ReplaceAll(
" ",
"_");
510 fHtml +=
"<td bgcolor=d0d0ff align=\"center\">";
511 fHtml +=
"<input type=\"checkbox\" name=\"";
513 fHtml += Form(
"[%d]\">",i);
516 for (
int j = 0; j < fNFields; j++) {
517 fHtml +=
"<td width=";
518 fHtml += Form(
"%d%%", 100/fNFields);
519 fHtml +=
" align=\"center\"";
521 fHtml += Form(
"%1.4f", fValues[j][i]);
529 HtmlSummary::HtmlSummary(
const char *title) : fNTables(0), fTitle(title)
533 fObjTables =
new TOrdCollection();
537 HtmlSummary::~HtmlSummary()
545 HtmlObjTable *HtmlSummary::AddTable(
const char *name, Int_t nfields, Int_t nvals,
546 Bool_t exp, Option_t *option)
550 TString opt = option;
552 HtmlObjTable *table =
new HtmlObjTable(name, nfields, nvals, exp);
554 if (opt.Contains(
"first"))
555 fObjTables->AddFirst(table);
557 fObjTables->Add(table);
562 void HtmlSummary::Clear(Option_t *option)
566 if (option && option[0] ==
'D')
567 fObjTables->Delete(option);
569 fObjTables->Clear(option);
574 void HtmlSummary::Reset(Option_t *)
578 delete fObjTables; fObjTables = 0;
583 void HtmlSummary::Build()
588 for (
int i=0;i<fNTables;i++) {
589 GetTable(i)->Build();
590 fHtml += GetTable(i)->Html();
596 void HtmlSummary::MakeHeader()
600 fHeader =
"<html><head><title>";
602 fHeader +=
"</title></head><body>";
603 fHeader +=
"<center><h2><font color=#2222ee><i>";
605 fHeader +=
"</i></font></h2></center>";
610 void HtmlSummary::MakeFooter()
614 fFooter =
"<br><p><br><center><strong><font size=2 color=#2222ee>";
615 fFooter +=
"Example of using Html widget to display tabular data";
617 fFooter +=
"(c) 2007-2010 Bertrand Bellenot";
618 fFooter +=
"</font></strong></center></body></html>";
623 SplitGLView::SplitGLView(
const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
624 TGMainFrame(p, w, h), fActViewer(0), fShapedToolTip(0), fIsEmbedded(embed)
630 TGHorizontalFrame *hfrm;
631 TGDockableFrame *dfrm;
632 TGPictureButton *button;
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);
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);
657 fMenuScene =
new TGPopupMenu(gClient->GetRoot());
658 fMenuScene->AddEntry(
"&Update Current", kSceneUpdate);
659 fMenuScene->AddEntry(
"Update &All", kSceneUpdateAll);
662 fMenuHelp =
new TGPopupMenu(gClient->GetRoot());
663 fMenuHelp->AddEntry(
"&About", kHelpAbout);
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 |
676 AddFrame(fMenuBar,
new TGLayoutHints(kLHintsTop | kLHintsExpandX));
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)");
688 if (fIsEmbedded && gEve) {
690 fStatusBar = gEve->GetBrowser()->GetStatusBar();
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,
702 fPad =
new TEvePad();
703 fPad->SetFillColor(kBlack);
706 fSplitFrame =
new TGSplitFrame(
this, 800, 600);
707 AddFrame(fSplitFrame,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
709 fSplitFrame->HSplit(434);
711 fSplitFrame->GetSecond()->VSplit(266);
712 fSplitFrame->GetSecond()->GetSecond()->VSplit(266);
714 TGLOverlayButton *but1, *but2, *but3, *but4, *but5, *but6;
716 frm = fSplitFrame->GetFirst();
717 frm->SetName(
"Main_View");
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 |
728 fViewer0->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
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)",
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");
748 fRhoZMgr =
new TEveProjectionManager(TEveProjection::kPT_RhoZ);
749 s->AddElement(fRhoZMgr);
750 gEve->AddToListTree(fRhoZMgr, kTRUE);
751 TEveProjectionAxes* a =
new TEveProjectionAxes(fRhoZMgr);
756 frm = fSplitFrame->GetSecond()->GetFirst();
757 frm->SetName(
"Bottom_Left");
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 |
769 fViewer1->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
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)",
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]);
790 s = gEve->SpawnNewScene(
"R-Phi Projection");
792 fRPhiMgr =
new TEveProjectionManager(TEveProjection::kPT_RPhi);
793 s->AddElement(fRPhiMgr);
794 gEve->AddToListTree(fRPhiMgr, kTRUE);
795 TEveProjectionAxes* a =
new TEveProjectionAxes(fRPhiMgr);
800 frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
801 frm->SetName(
"Bottom_Center");
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 |
813 fViewer2->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
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)",
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]);
836 frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
837 frm->SetName(
"Bottom_Right");
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);
849 hfrm->AddFrame(fgHtml,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
850 dfrm->AddFrame(hfrm,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
851 frm->AddFrame(dfrm,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
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)");
858 fShapedToolTip =
new TGShapedToolTip(
"Default.png", 120, 22, 160, 110,
859 23, 115, 12,
"#ffff80");
860 Resize(GetDefaultSize());
863 LoadConfig(
".everc");
867 SplitGLView::~SplitGLView()
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)");
896 delete fShapedToolTip;
910 gApplication->Terminate(0);
915 void SplitGLView::HandleMenu(Int_t
id)
919 static TString rcdir(
".");
920 static TString rcfile(
".everc");
926 static TString dir(
".");
928 fi.fFileTypes = filetypes;
929 fi.fIniDir = StrDup(dir);
930 new TGFileDialog(gClient->GetRoot(),
this, kFDOpen, &fi);
932 OpenFile(fi.fFilename);
937 case kFileLoadConfig:
940 fi.fFileTypes = rcfiletypes;
941 fi.fIniDir = StrDup(rcdir);
942 fi.fFilename = StrDup(rcfile);
943 new TGFileDialog(gClient->GetRoot(),
this, kFDOpen, &fi);
945 rcfile = fi.fFilename;
946 LoadConfig(fi.fFilename);
952 case kFileSaveConfig:
955 fi.fFileTypes = rcfiletypes;
956 fi.fIniDir = StrDup(rcdir);
957 fi.fFilename = StrDup(rcfile);
958 new TGFileDialog(gClient->GetRoot(),
this, kFDSave, &fi);
960 rcfile = fi.fFilename;
961 SaveConfig(fi.fFilename);
973 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspYOZ);
977 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
981 fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
985 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
989 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOZ);
993 fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
1004 fActViewer->UpdateScene();
1008 case kSceneUpdateAll:
1009 fViewer0->UpdateScene();
1010 fViewer1->UpdateScene();
1011 fViewer2->UpdateScene();
1015 case kSummaryUpdate:
1022 TString rootx = TROOT::GetBinDir() +
"/root -a &";
1023 gSystem->Exec(rootx);
1026 new TWin32SplashThread(kTRUE);
1029 sprintf(str,
"About ROOT %s...", gROOT->GetVersion());
1030 hd =
new TRootHelpDialog(
this, str, 600, 400);
1031 hd->SetText(gHelpAbout);
1044 void SplitGLView::OnClicked(TObject *obj)
1049 fStatusBar->SetText(Form(
"User clicked on: \"%s\"", obj->GetName()), 1);
1051 fStatusBar->SetText(
"", 1);
1055 void SplitGLView::OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy)
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);
1069 h1f =
new TH1F(
"h1f",
"",50,0,10);
1071 h1f->SetFillColor(45);
1073 h1f->FillRandom(
"sqroot",200);
1075 if (fShapedToolTip) {
1076 fShapedToolTip->UnmapWindow();
1078 if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal()) {
1080 TGLEmbeddedViewer *actViewer =
dynamic_cast<TGLEmbeddedViewer*
>((TQObject*)gTQSender);
1083 gVirtualX->TranslateCoordinates(actViewer->GetFrame()->GetId(),
1084 gClient->GetDefaultRoot()->GetId(), posx, posy, x, y,
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);
1096 void SplitGLView::OnMouseOver(TGLPhysicalShape *shape)
1102 if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal())
1103 fStatusBar->SetText(Form(
"Mouse Over: \"%s\"",
1104 shape->GetLogical()->GetExternal()->GetName()), 0);
1106 fStatusBar->SetText(
"", 0);
1110 void SplitGLView::OnViewerActivated()
1115 static Pixel_t green = 0;
1117 if (fActViewer && fActViewer->GetFrame())
1118 fActViewer->GetFrame()->ChangeBackground(GetDefaultFrameBackground());
1122 fActViewer =
dynamic_cast<TGLEmbeddedViewer*
>((TQObject*)gTQSender);
1124 if (fActViewer == 0) {
1125 printf (
"dyncast failed ...\n");
1131 gClient->GetColorByName(
"green", green);
1134 if (fActViewer->GetFrame())
1135 fActViewer->GetFrame()->ChangeBackground(green);
1138 if (fActViewer->GetOrthoXOYCamera()->GetDollyToZoom() &&
1139 fActViewer->GetOrthoXOZCamera()->GetDollyToZoom() &&
1140 fActViewer->GetOrthoZOYCamera()->GetDollyToZoom())
1141 fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1143 fMenuCamera->CheckEntry(kGLOrthoDolly);
1145 if (fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1146 fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
1147 fActViewer->GetOrthoXOYCamera()->GetEnableRotate())
1148 fMenuCamera->CheckEntry(kGLOrthoRotate);
1150 fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1154 void SplitGLView::OpenFile(
const char *fname)
1158 TString filename = fname;
1160 if (!filename.EndsWith(
".root")) {
1161 new TGMsgBox(gClient->GetRoot(),
this,
"OpenFile",
1162 Form(
"The file \"%s\" is not a root file!", fname),
1163 kMBIconExclamation, kMBOk);
1167 if (TGeoManager::Import(fname) == 0) {
1168 new TGMsgBox(gClient->GetRoot(),
this,
"OpenFile",
1169 Form(
"The file \"%s\" does't contain a geometry", fname),
1170 kMBIconExclamation, kMBOk);
1173 gGeoManager->DefaultColors();
1175 fPad->GetListOfPrimitives()->Delete();
1177 fPad->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume());
1179 fViewer0->PadPaint(fPad);
1180 fViewer1->PadPaint(fPad);
1181 fViewer2->PadPaint(fPad);
1185 void SplitGLView::ToggleOrthoRotate()
1189 if (fMenuCamera->IsEntryChecked(kGLOrthoRotate))
1190 fMenuCamera->UnCheckEntry(kGLOrthoRotate);
1192 fMenuCamera->CheckEntry(kGLOrthoRotate);
1193 Bool_t state = fMenuCamera->IsEntryChecked(kGLOrthoRotate);
1195 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1196 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1197 fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
1202 void SplitGLView::ToggleOrthoDolly()
1206 if (fMenuCamera->IsEntryChecked(kGLOrthoDolly))
1207 fMenuCamera->UnCheckEntry(kGLOrthoDolly);
1209 fMenuCamera->CheckEntry(kGLOrthoDolly);
1210 Bool_t state = ! fMenuCamera->IsEntryChecked(kGLOrthoDolly);
1212 fActViewer->GetOrthoXOYCamera()->SetDollyToZoom(state);
1213 fActViewer->GetOrthoXOZCamera()->SetDollyToZoom(state);
1214 fActViewer->GetOrthoZOYCamera()->SetDollyToZoom(state);
1219 void SplitGLView::ItemClicked(TGListTreeItem *item, Int_t, Int_t, Int_t)
1223 static const TEveException eh(
"SplitGLView::ItemClicked ");
1224 TEveElement* re = (TEveElement*)item->GetUserData();
1226 TObject* obj = re->GetObject(eh);
1227 if (obj->InheritsFrom(
"TEveViewer")) {
1228 TGLViewer *v = ((TEveViewer *)obj)->GetGLViewer();
1230 if (v->InheritsFrom(
"TGLEmbeddedViewer")) {
1231 TGLEmbeddedViewer *ev = (TGLEmbeddedViewer *)v;
1232 gVirtualX->SetInputFocus(ev->GetGLWidget()->GetId());
1238 void SplitGLView::LoadConfig(
const char *fname)
1241 Int_t height, width;
1242 TEnv *env =
new TEnv(fname);
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);
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);
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);
1263 width = fSplitFrame->GetFirst()->GetWidth();
1264 fSplitFrame->GetFirst()->Resize(width, mainheight);
1266 height = fSplitFrame->GetSecond()->GetFirst()->GetHeight();
1267 fSplitFrame->GetSecond()->GetFirst()->Resize(blwidth, height);
1269 height = fSplitFrame->GetSecond()->GetSecond()->GetFirst()->GetHeight();
1270 fSplitFrame->GetSecond()->GetSecond()->GetFirst()->Resize(bcwidth, height);
1272 height = fSplitFrame->GetSecond()->GetSecond()->GetSecond()->GetHeight();
1273 fSplitFrame->GetSecond()->GetSecond()->GetSecond()->Resize(brwidth, height);
1275 fSplitFrame->Layout();
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);
1286 void SplitGLView::SaveConfig(
const char *fname)
1289 Int_t bottom_height = 0;
1290 Int_t top_height = 0;
1292 TEnv *env =
new TEnv(fname);
1294 if (fIsEmbedded && gEve) {
1295 env->SetValue(
"Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
1296 env->SetValue(
"Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
1299 frm = fSplitFrame->GetFirst();
1300 env->SetValue(
"MainView.Height", (Int_t)frm->GetHeight());
1302 frm = fSplitFrame->GetSecond()->GetFirst();
1303 env->SetValue(
"Bottom.Left.Width", (Int_t)frm->GetWidth());
1305 frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
1306 env->SetValue(
"Bottom.Center.Width", (Int_t)frm->GetWidth());
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);
1316 env->SetValue(
"Eve.Selection", gEve->GetSelection()->GetPickToSelect());
1317 env->SetValue(
"Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
1320 env->SaveLevel(kEnvLocal);
1322 if (!gSystem->AccessPathName(Form(
"%s.new", fname))) {
1323 gSystem->Exec(Form(
"del %s", fname));
1324 gSystem->Rename(Form(
"%s.new", fname), fname);
1330 void SplitGLView::SwapToMainView(TGLViewerBase *viewer)
1334 TGCompositeFrame *parent = 0;
1335 if (!fSplitFrame->GetFirst()->GetFrame())
1338 TGPictureButton *src = (TGPictureButton*)gTQSender;
1339 parent = (TGCompositeFrame *)src->GetParent();
1340 while (parent && !parent->InheritsFrom(
"TGSplitFrame")) {
1341 parent = (TGCompositeFrame *)parent->GetParent();
1345 TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1347 TGLOverlayButton *but = (TGLOverlayButton *)((TQObject *)gTQSender);
1349 parent = (TGCompositeFrame *)src->GetParent();
1351 if (parent && parent->InheritsFrom(
"TGSplitFrame"))
1352 ((TGSplitFrame *)parent)->SwitchToMain();
1356 void SplitGLView::UnDock(TGLViewerBase *viewer)
1360 TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
1362 TGLOverlayButton *but = (TGLOverlayButton *)((TQObject *)gTQSender);
1364 TGCompositeFrame *parent = (TGCompositeFrame *)src->GetParent();
1365 if (parent && parent->InheritsFrom(
"TGSplitFrame"))
1366 ((TGSplitFrame *)parent)->ExtractFrame();
1370 void SplitGLView::UpdateSummary()
1374 TEveElement::List_i i;
1375 TEveElement::List_i j;
1378 HtmlObjTable *table;
1379 TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
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);
1394 else if (el->IsA() == TEveTrackList::Class()) {
1395 TEveTrackList *tracks = (TEveTrackList *)el;
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");
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);
1422 fgHtmlSummary->Build();
1424 fgHtml->ParseText((
char*)fgHtmlSummary->Html().Data());
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");