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()
{
Reset();
}
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");
if (el->IsA() == TEvePointSet::Class()) {
table = fgHtmlSummary->AddTable(ename, 0, nel);
}
else if (el->IsA() == TEveTrackList::Class()) {
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;
for (j=
tracks->BeginChildren(); j!=
tracks->EndChildren(); ++j) {
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());
}
}
#define ClassDef(name, id)
R__EXTERN TEveManager * gEve
char * Form(const char *fmt,...)
Array of floats (32 bits per element).
void SetAt(Double_t v, Int_t i)
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Base class for event management and navigation.
TEveEventManager * GetCurrentEvent() const
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.
A list of tracks supporting change of common attributes and selection based on track parameters.
Visual representation of a track.
virtual void Clear(Option_t *="")
Erase all HTML from this widget and clear the screen.
int ParseText(char *text, const char *index=0)
Appends (or insert at the specified position) the given HTML text to the end of any HTML text that ma...
virtual void Layout()
layout view
Mother of all ROOT objects.
void Clear(Option_t *option="")
Remove all objects from the collection.
TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
void AddFirst(TObject *obj)
Insert object at beginning of collection.
void Delete(Option_t *option="")
Remove all objects from the collection AND delete all heap based objects.
virtual void Add(TObject *obj)
void ToLower()
Change string to lower-case.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Remove(Ssiz_t pos)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const