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 *GetTable(
Int_t at)
const {
return (HtmlObjTable *)fObjTables->
At(at); }
void Build();
TString Html()
const {
return fHtml; }
};
HtmlSummary *fgHtmlSummary = 0;
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;
}
void update_html_summary()
{
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());
}
}