#include "TFormula.h"
#ifdef WIN32
#endif
const char *filetypes[] = {
"ROOT files", "*.root",
"All files", "*",
0, 0
};
const char *rcfiletypes[] = {
"All files", "*",
0, 0
};
private:
TGShapedToolTip(const TGShapedToolTip&);
TGShapedToolTip&
operator=(
const TGShapedToolTip&);
protected:
Int_t fTextX, fTextY, fTextH;
public:
const char *col="#ffffff");
virtual ~TGShapedToolTip();
virtual void CloseWindow();
const char *GetText()
const {
return fText.
Data(); }
void Refresh();
void SetHisto(
TH1 *hist);
void SetText(const char *text);
void Show(
Int_t x,
Int_t y,
const char *text = 0,
TH1 *hist = 0);
};
class HtmlObjTable :
public TObject {
public:
void Build();
void BuildTitle();
void BuildLabels();
void BuildTable();
public:
virtual ~HtmlObjTable();
void SetLabel(
Int_t col,
const char *label) { fLabels[col] = label; }
TString Html()
const {
return fHtml; }
};
class HtmlSummary {
public:
void MakeHeader();
void MakeFooter();
public:
HtmlSummary(const char *title);
virtual ~HtmlSummary();
HtmlObjTable *AddTable(
const char *name,
Int_t nfields,
Int_t nvals,
HtmlObjTable *GetTable(
Int_t at)
const {
return (HtmlObjTable *)fObjTables->
At(at); }
void Build();
TString Html()
const {
return fHtml; }
};
public:
enum EMyCommands {
kHelpAbout, kGLPerspYOZ, kGLPerspXOZ, kGLPerspXOY, kGLXOY,
kGLXOZ, kGLZOY, kGLOrthoRotate, kGLOrthoDolly, kSceneUpdate,
kSceneUpdateAll, kSummaryUpdate
};
private:
static HtmlSummary *fgHtmlSummary;
TGShapedToolTip *fShapedToolTip;
public:
virtual ~SplitGLView();
void HandleMenu(
Int_t id);
void OnViewerActivated();
void ToggleOrthoRotate();
void ToggleOrthoDolly();
void LoadConfig(const char *fname);
void SaveConfig(const char *fname);
static void UpdateSummary();
};
HtmlSummary *SplitGLView::fgHtmlSummary = 0;
TGHtml *SplitGLView::fgHtml = 0;
TGShapedToolTip::TGShapedToolTip(
const char *pname,
Int_t cx,
Int_t cy,
Int_t cw,
const char *col) :
{
fTextX = tx; fTextY = ty; fTextH = th;
if (col)
fTextCol = col;
else
fTextCol = "0x000000";
if ((cx > 0) && (cy > 0) && (cw > 0) && (ch > 0)) {
Int_t lhRight = fWidth-cx-cw;
Int_t lhBottom = fHeight-cy-ch;
lhRight, cy, lhBottom));
}
MapSubwindows();
Resize();
Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
}
TGShapedToolTip::~TGShapedToolTip()
{
if (fHist)
delete fHist;
if (fEc)
delete fEc;
}
void TGShapedToolTip::CloseWindow()
{
DeleteWindow();
}
void TGShapedToolTip::Refresh()
{
const char *str = fText.
Data();
char *string = strdup(str);
Int_t nlines = 0, size = fTextH;
char *s = strtok((char *)string, "\n");
img->
DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
while ((s = strtok(0, "\n"))) {
nlines++;
img->
DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
}
delete img;
}
{
Int_t lhRight = fWidth-cx-cw;
Int_t lhBottom = fHeight-cy-ch;
lhRight, cy, lhBottom));
MapSubwindows();
Resize();
Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
if (IsMapped()) {
Refresh();
}
}
{
AddFrame(fEc, hints);
MapSubwindows();
Resize();
Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
if (IsMapped()) {
Refresh();
}
}
void TGShapedToolTip::SetHisto(
TH1 *hist)
{
if (hist) {
if (fHist) {
delete fHist;
if (fEc)
}
if (fEc) {
}
}
}
void TGShapedToolTip::SetText(const char *text)
{
if (text) {
}
if (IsMapped())
Refresh();
}
{
fTextCol = col;
if (IsMapped())
Refresh();
}
const char *col)
{
fTextX = tx; fTextY = ty; fTextH = th;
if (col)
fTextCol = col;
if (IsMapped())
Refresh();
}
void TGShapedToolTip::Show(
Int_t x,
Int_t y,
const char *text,
TH1 *hist)
{
Move(x, y);
MapWindow();
if (text)
SetText(text);
if (hist)
SetHisto(hist);
if (fHist) {
}
Refresh();
}
HtmlObjTable::HtmlObjTable(
const char *name,
Int_t nfields,
Int_t nvals,
Bool_t exp) :
fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
{
for (int i=0;i<fNFields;i++)
fValues[i].Set(nvals);
}
HtmlObjTable::~HtmlObjTable()
{
delete [] fValues;
delete [] fLabels;
}
void HtmlObjTable::Build()
{
fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
BuildTitle();
if (fExpand && (fNFields > 0) && (fNValues > 0)) {
BuildLabels();
BuildTable();
}
fHtml += "</table>";
}
void HtmlObjTable::BuildTitle()
{
fHtml += "<tr><td colspan=";
fHtml +=
Form(
"%d>", fNFields+1);
fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
fHtml += "<tr><td align=left>";
fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
fHtml += fName;
fHtml += "</i></b></font></td>";
fHtml += "<td>";
fHtml += "<td align=right> ";
fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
fHtml +=
Form(
"Size = %d", fNValues);
fHtml += "</i></b></font></td></tr>";
fHtml += "</table>";
fHtml += "</td></tr>";
}
void HtmlObjTable::BuildLabels()
{
fHtml += "<tr bgcolor=c0c0ff>";
fHtml += "<th> </th>";
for (i=0;i<fNFields;i++) {
fHtml += "<th> ";
fHtml += fLabels[i];
fHtml += " </th>";
}
fHtml += "</tr>";
}
void HtmlObjTable::BuildTable()
{
for (int i = 0; i < fNValues; i++) {
if (i%2)
fHtml += "<tr bgcolor=e0e0ff>";
else
fHtml += "<tr bgcolor=ffffff>";
fHtml += "<td bgcolor=d0d0ff align=\"center\">";
fHtml += "<input type=\"checkbox\" name=\"";
fHtml +=
Form(
"[%d]\">",i);
fHtml += "</td>";
for (int j = 0; j < fNFields; j++) {
fHtml += "<td width=";
fHtml +=
Form(
"%d%%", 100/fNFields);
fHtml += " align=\"center\"";
fHtml += ">";
fHtml +=
Form(
"%1.4f", fValues[j][i]);
fHtml += "</td>";
}
fHtml += "</tr> ";
}
}
HtmlSummary::HtmlSummary(const char *title) : fNTables(0), fTitle(title)
{
}
HtmlSummary::~HtmlSummary()
{
}
HtmlObjTable *HtmlSummary::AddTable(
const char *name,
Int_t nfields,
Int_t nvals,
{
HtmlObjTable *table = new HtmlObjTable(name, nfields, nvals, exp);
fNTables++;
else
return table;
}
void HtmlSummary::Clear(
Option_t *option)
{
if (option && option[0] == 'D')
else
fObjTables->
Clear(option);
fNTables = 0;
}
{
delete fObjTables; fObjTables = 0;
fNTables = 0;
}
void HtmlSummary::Build()
{
MakeHeader();
for (int i=0;i<fNTables;i++) {
GetTable(i)->Build();
fHtml += GetTable(i)->Html();
}
MakeFooter();
}
void HtmlSummary::MakeHeader()
{
fHeader = "<html><head><title>";
fHeader += fTitle;
fHeader += "</title></head><body>";
fHeader += "<center><h2><font color=#2222ee><i>";
fHeader += fTitle;
fHeader += "</i></font></h2></center>";
fHtml = fHeader;
}
void HtmlSummary::MakeFooter()
{
fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
fFooter += "Example of using Html widget to display tabular data";
fFooter += "<br>";
fFooter += "(c) 2007-2010 Bertrand Bellenot";
fFooter += "</font></strong></center></body></html>";
fHtml += fFooter;
}
TGMainFrame(p, w, h), fActViewer(0), fShapedToolTip(0), fIsEmbedded(embed)
{
fMenuFile->AddSeparator();
fMenuFile->AddEntry( "&Update Summary", kSummaryUpdate);
fMenuFile->AddSeparator();
fMenuFile->AddSeparator();
fMenuFile->AddEntry("E&xit", kFileExit);
fMenuCamera->
AddEntry(
"Perspective (Floor XOZ)", kGLPerspXOZ);
fMenuCamera->AddEntry("Perspective (Floor YOZ)", kGLPerspYOZ);
fMenuCamera->AddEntry("Perspective (Floor XOY)", kGLPerspXOY);
fMenuCamera->AddEntry("Orthographic (XOY)", kGLXOY);
fMenuCamera->AddEntry("Orthographic (XOZ)", kGLXOZ);
fMenuCamera->AddEntry("Orthographic (ZOY)", kGLZOY);
fMenuCamera->AddSeparator();
fMenuCamera->AddEntry("Ortho allow rotate", kGLOrthoRotate);
fMenuCamera->AddEntry("Ortho allow dolly", kGLOrthoDolly);
fMenuScene->
AddEntry(
"&Update Current", kSceneUpdate);
fMenuScene->AddEntry("Update &All", kSceneUpdateAll);
fMenuFile->Connect("Activated(Int_t)", "SplitGLView", this,
"HandleMenu(Int_t)");
fMenuCamera->Connect("Activated(Int_t)", "SplitGLView", this,
"HandleMenu(Int_t)");
fMenuScene->Connect("Activated(Int_t)", "SplitGLView", this,
"HandleMenu(Int_t)");
fMenuHelp->Connect("Activated(Int_t)", "SplitGLView", this,
"HandleMenu(Int_t)");
if (fIsEmbedded &&
gEve) {
}
else {
Int_t parts[] = {45, 15, 10, 30};
fStatusBar->SetParts(parts, 4);
0, 0, 10, 0));
}
fSplitFrame->HSplit(434);
fSplitFrame->GetSecond()->VSplit(266);
fSplitFrame->GetSecond()->GetSecond()->VSplit(266);
but1->
Connect(
"Clicked(TGLViewerBase*)",
"SplitGLView",
this,
"SwapToMainView(TGLViewerBase*)");
but2->
Connect(
"Clicked(TGLViewerBase*)",
"SplitGLView",
this,
"UnDock(TGLViewerBase*)");
fViewer0->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
"OnMouseOver(TGLPhysicalShape*)");
fViewer0->Connect("Activated()", "SplitGLView", this,
"OnViewerActivated()");
fViewer0->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
"SplitGLView", this,
"OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
fViewer0->Connect("Clicked(TObject*)", "SplitGLView", this,
"OnClicked(TObject*)");
fViewer[0]->SetGLViewer(fViewer0, fViewer0->GetFrame());
fViewer[0]->IncDenyDestroy();
if (fIsEmbedded &&
gEve) {
}
but3->
Connect(
"Clicked(TGLViewerBase*)",
"SplitGLView",
this,
"SwapToMainView(TGLViewerBase*)");
but4->
Connect(
"Clicked(TGLViewerBase*)",
"SplitGLView",
this,
"UnDock(TGLViewerBase*)");
fViewer1->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
"OnMouseOver(TGLPhysicalShape*)");
fViewer1->Connect("Activated()", "SplitGLView", this,
"OnViewerActivated()");
fViewer1->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
"SplitGLView", this,
"OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
fViewer1->Connect("Clicked(TObject*)", "SplitGLView", this,
"OnClicked(TObject*)");
fViewer[1]->SetGLViewer(fViewer1, fViewer1->GetFrame());
fViewer[1]->IncDenyDestroy();
if (fIsEmbedded &&
gEve) {
fViewer[1]->AddScene(s);
gRhoZMgr = fRhoZMgr;
}
but5->
Connect(
"Clicked(TGLViewerBase*)",
"SplitGLView",
this,
"SwapToMainView(TGLViewerBase*)");
but6->
Connect(
"Clicked(TGLViewerBase*)",
"SplitGLView",
this,
"UnDock(TGLViewerBase*)");
fViewer2->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this,
"OnMouseOver(TGLPhysicalShape*)");
fViewer2->Connect("Activated()", "SplitGLView", this,
"OnViewerActivated()");
fViewer2->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
"SplitGLView", this,
"OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
fViewer2->Connect("Clicked(TObject*)", "SplitGLView", this,
"OnClicked(TObject*)");
fViewer[2]->SetGLViewer(fViewer2, fViewer2->GetFrame());
fViewer[2]->IncDenyDestroy();
if (fIsEmbedded &&
gEve) {
fViewer[2]->AddScene(s);
gRPhiMgr = fRPhiMgr;
}
button->
Connect(
"Clicked()",
"SplitGLView",
this,
"SwapToMainView(TGLViewerBase*=0)");
fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table");
fgHtml =
new TGHtml(hfrm, 100, 100, -1);
if (fIsEmbedded &&
gEve) {
"SplitGLView", this, "ItemClicked(TGListTreeItem*, Int_t, Int_t, Int_t)");
}
fShapedToolTip = new TGShapedToolTip("Default.png", 120, 22, 160, 110,
23, 115, 12, "#ffff80");
Resize(GetDefaultSize());
MapSubwindows();
MapWindow();
LoadConfig(".everc");
}
SplitGLView::~SplitGLView()
{
fMenuFile->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
fMenuCamera->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
fMenuScene->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
fMenuHelp->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
fViewer0->Disconnect("MouseOver(TGLPhysicalShape*)", this,
"OnMouseOver(TGLPhysicalShape*)");
fViewer0->Disconnect("Activated()", this, "OnViewerActivated()");
fViewer0->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
fViewer1->Disconnect("MouseOver(TGLPhysicalShape*)", this,
"OnMouseOver(TGLPhysicalShape*)");
fViewer1->Disconnect("Activated()", this, "OnViewerActivated()");
fViewer1->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
fViewer2->Disconnect("MouseOver(TGLPhysicalShape*)", this,
"OnMouseOver(TGLPhysicalShape*)");
fViewer2->Disconnect("Activated()", this, "OnViewerActivated()");
fViewer2->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)",
this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
if (!fIsEmbedded) {
delete fViewer[0];
delete fViewer[1];
delete fViewer[2];
}
delete fShapedToolTip;
delete fMenuFile;
delete fMenuScene;
delete fMenuCamera;
delete fMenuHelp;
if (!fIsEmbedded)
delete fMenuBar;
delete fViewer0;
delete fViewer1;
delete fViewer2;
delete fSplitFrame;
delete fPad;
if (!fIsEmbedded) {
delete fStatusBar;
}
}
void SplitGLView::HandleMenu(
Int_t id)
{
switch (id) {
{
}
break;
{
}
}
break;
{
}
}
break;
case kFileExit:
CloseWindow();
break;
case kGLPerspYOZ:
if (fActViewer)
break;
case kGLPerspXOZ:
if (fActViewer)
break;
case kGLPerspXOY:
if (fActViewer)
break;
case kGLXOY:
if (fActViewer)
break;
case kGLXOZ:
if (fActViewer)
break;
case kGLZOY:
if (fActViewer)
break;
case kGLOrthoRotate:
ToggleOrthoRotate();
break;
case kGLOrthoDolly:
ToggleOrthoDolly();
break;
case kSceneUpdate:
if (fActViewer)
fActViewer->UpdateScene();
UpdateSummary();
break;
case kSceneUpdateAll:
fViewer0->UpdateScene();
fViewer1->UpdateScene();
fViewer2->UpdateScene();
UpdateSummary();
break;
case kSummaryUpdate:
UpdateSummary();
break;
{
#ifdef R__UNIX
# ifdef ROOTBINDIR
rootx = ROOTBINDIR;
# else
if (!rootx.
IsNull()) rootx +=
"/bin";
# endif
rootx += "/root -a &";
#else
#ifdef WIN32
#else
char str[32];
sprintf(str,
"About ROOT %s...",
gROOT->GetVersion());
hd->Popup();
#endif
#endif
}
break;
default:
break;
}
}
void SplitGLView::OnClicked(
TObject *obj)
{
if (obj)
fStatusBar->SetText(
Form(
"User clicked on: \"%s\"", obj->
GetName()), 1);
else
fStatusBar->SetText("", 1);
}
{
form1->Update();
TF1 *sqroot =
new TF1(
"sqroot",
"x*gaus(0) + [3]*form1",0,10);
if (h1f == 0)
h1f =
new TH1F(
"h1f",
"",50,0,10);
if (fShapedToolTip) {
fShapedToolTip->UnmapWindow();
}
gClient->GetDefaultRoot()->GetId(), posx, posy,
x,
y,
wtarget);
if (fShapedToolTip) {
fShapedToolTip->Show(x+5, y+5,
Form(
"%s\n \n%s",
}
}
}
{
fStatusBar->SetText(
Form(
"Mouse Over: \"%s\"",
else
fStatusBar->SetText("", 0);
}
void SplitGLView::OnViewerActivated()
{
if (fActViewer && fActViewer->GetFrame())
fActViewer->GetFrame()->ChangeBackground(GetDefaultFrameBackground());
if (fActViewer == 0) {
printf ("dyncast failed ...\n");
return;
}
if (green == 0) {
gClient->GetColorByName(
"green", green);
}
if (fActViewer->GetFrame())
fActViewer->GetFrame()->ChangeBackground(green);
if (fActViewer->GetOrthoXOYCamera()->GetDollyToZoom() &&
fActViewer->GetOrthoXOZCamera()->GetDollyToZoom() &&
fActViewer->GetOrthoZOYCamera()->GetDollyToZoom())
fMenuCamera->UnCheckEntry(kGLOrthoDolly);
else
fMenuCamera->CheckEntry(kGLOrthoDolly);
if (fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
fActViewer->GetOrthoXOYCamera()->GetEnableRotate())
fMenuCamera->CheckEntry(kGLOrthoRotate);
else
fMenuCamera->UnCheckEntry(kGLOrthoRotate);
}
{
Form(
"The file \"%s\" is not a root file!", fname),
return;
}
Form(
"The file \"%s\" does't contain a geometry", fname),
return;
}
fPad->GetListOfPrimitives()->Delete();
fViewer0->PadPaint(fPad);
fViewer1->PadPaint(fPad);
fViewer2->PadPaint(fPad);
}
void SplitGLView::ToggleOrthoRotate()
{
if (fMenuCamera->IsEntryChecked(kGLOrthoRotate))
fMenuCamera->UnCheckEntry(kGLOrthoRotate);
else
fMenuCamera->CheckEntry(kGLOrthoRotate);
Bool_t state = fMenuCamera->IsEntryChecked(kGLOrthoRotate);
if (fActViewer) {
fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
}
}
void SplitGLView::ToggleOrthoDolly()
{
if (fMenuCamera->IsEntryChecked(kGLOrthoDolly))
fMenuCamera->UnCheckEntry(kGLOrthoDolly);
else
fMenuCamera->CheckEntry(kGLOrthoDolly);
Bool_t state = ! fMenuCamera->IsEntryChecked(kGLOrthoDolly);
if (fActViewer) {
fActViewer->GetOrthoXOYCamera()->SetDollyToZoom(state);
fActViewer->GetOrthoXOZCamera()->SetDollyToZoom(state);
fActViewer->GetOrthoZOYCamera()->SetDollyToZoom(state);
}
}
{
if(re == 0) return;
}
}
}
void SplitGLView::LoadConfig(const char *fname)
{
if (fIsEmbedded &&
gEve) {
}
width = fSplitFrame->GetFirst()->GetWidth();
fSplitFrame->GetFirst()->Resize(width, mainheight);
height = fSplitFrame->GetSecond()->GetFirst()->GetHeight();
fSplitFrame->GetSecond()->GetFirst()->Resize(blwidth, height);
height = fSplitFrame->GetSecond()->GetSecond()->GetFirst()->GetHeight();
fSplitFrame->GetSecond()->GetSecond()->GetFirst()->Resize(bcwidth, height);
height = fSplitFrame->GetSecond()->GetSecond()->GetSecond()->GetHeight();
fSplitFrame->GetSecond()->GetSecond()->GetSecond()->Resize(brwidth, height);
fSplitFrame->Layout();
if (fIsEmbedded &&
gEve) {
}
}
void SplitGLView::SaveConfig(const char *fname)
{
if (fIsEmbedded &&
gEve) {
}
if (fIsEmbedded &&
gEve) {
env->
SetValue(
"Right.Tab.Height", top_height);
env->
SetValue(
"Bottom.Tab.Height", bottom_height);
}
#ifdef R__WIN32
}
#endif
}
{
if (!fSplitFrame->GetFirst()->GetFrame())
return;
if (viewer == 0) {
}
}
else {
if (!src) return;
}
}
{
if (!src) return;
}
void SplitGLView::UpdateSummary()
{
HtmlObjTable *table;
if (mgr) {
fgHtmlSummary->Clear("D");
table = fgHtmlSummary->AddTable(ename, 0, nel);
}
table = fgHtmlSummary->AddTable(ename.
Data(), 5,
table->SetLabel(0, "Momentum");
table->SetLabel(1, "P_t");
table->SetLabel(2, "Phi");
table->SetLabel(3, "Theta");
table->SetLabel(4, "Eta");
k=0;
table->SetValue(0, k, p);
table->SetValue(1, k, pt);
table->SetValue(2, k, phi);
table->SetValue(3, k, theta);
table->SetValue(4, k, eta);
++k;
}
}
}
fgHtmlSummary->Build();
fgHtml->
ParseText((
char*)fgHtmlSummary->Html().Data());
}
}
#ifdef __CINT__
void SplitGLView()
{
printf("This script is used via ACLiC by the macro \"alice_esd_split.C\"\n");
printf("To see it in action, just run \".x alice_esd_split.C\"\n");
return;
}
#endif