7 #include "PlusConfigure.h" 9 #include "vtkObjectFactory.h" 10 #include "vtksys/SystemTools.hxx" 12 #include "vtkVariant.h" 38 this->Superclass::PrintSelf(os, indent);
44 LOG_TRACE(
"vtkPlusHTMLGenerator::AddHorizontalLine");
45 this->
HtmlBody <<
"<hr />" << std::endl;
51 LOG_TRACE(
"vtkPlusHTMLGenerator::AddImage");
52 if (imageSource == NULL)
54 LOG_ERROR(
"Unable to add imageSource to HTML document - imageSource is NULL!");
60 LOG_ERROR(
"Unable to add alterantive text to HTML document - alt is NULL!");
64 if (widthPx == 0 && heightPx == 0)
66 this->
HtmlBody <<
"<img src='" << imageSource <<
"' alt='" << alt <<
"' />" << std::endl;
70 this->
HtmlBody <<
"<img src='" << imageSource <<
"' alt='" << alt <<
"' width='" << widthPx <<
"' height='" << heightPx <<
"' />" << std::endl;
77 LOG_TRACE(
"vtkPlusHTMLGenerator::AddParagraph");
78 if (paragraph == NULL)
80 LOG_ERROR(
"Unable to add paragraph to HTML document - paragraph is NULL!");
84 this->
HtmlBody <<
"<p>" << paragraph <<
"</p>" << std::endl;
90 LOG_TRACE(
"vtkPlusHTMLGenerator::AddLink");
93 LOG_ERROR(
"Unable to add link to HTML document - linkText is NULL!");
99 LOG_ERROR(
"Unable to add link to HTML document - url is NULL!");
103 this->
HtmlBody <<
"<a href='" << url <<
"'>" << linkText <<
"</a>" << std::endl;
109 LOG_TRACE(
"vtkPlusHTMLGenerator::AddText");
112 LOG_ERROR(
"Unable to add text to HTML document - input text is NULL!");
116 std::string openTag, closeTag;
127 openTag =
"<h1 style='" + std::string(style) +
"'>";
141 openTag =
"<h2 style='" + std::string(style) +
"'>";
155 openTag =
"<h3 style='" + std::string(style) +
"'>";
170 openTag =
"<h4 style='" + std::string(style) +
"'>";
185 openTag =
"<h5 style='" + std::string(style) +
"'>";
200 openTag =
"<h6 style='" + std::string(style) +
"'>";
208 this->
HtmlBody << openTag <<
text << closeTag << std::endl;
214 LOG_TRACE(
"vtkPlusHTMLGenerator::AddTable");
215 if (inputTable == NULL)
217 LOG_ERROR(
"Unable to add table to HTML document - table is NULL");
221 std::ostringstream openTag;
222 openTag <<
"<table border='" << borderPx <<
"'>";
223 std::string closeTag =
"</table>";
225 std::ostringstream table;
229 for (
int c = 0; c < inputTable->GetNumberOfColumns(); ++c)
231 table <<
"<th>" << inputTable->GetColumnName(c) <<
"</th>";
235 for (
int r = 0; r < inputTable->GetNumberOfRows(); ++r)
238 for (
int c = 0; c < inputTable->GetNumberOfColumns(); ++c)
240 table <<
"<td>" << inputTable->GetValue(r, c).ToString() <<
"</td>";
245 this->
HtmlBody << openTag.str() << table.str() << closeTag << std::endl;
251 LOG_TRACE(
"vtkPlusHTMLGenerator::GetHtmlBody");
258 LOG_TRACE(
"vtkPlusHTMLGenerator::GetHtmlPage");
259 std::ostringstream page;
260 page <<
"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" << std::endl;
261 page <<
"<html>" << std::endl;
262 page <<
"<head>" << std::endl;
263 page <<
"<title>" << this->
GetTitle() <<
"</title>" << std::endl;
264 page <<
"</head>" << std::endl;
265 page <<
"<body>" << std::endl;
267 page <<
"</body>" << std::endl;
277 LOG_TRACE(
"vtkPlusHTMLGenerator::SaveHtmlPage");
278 std::ofstream htmlpage;
279 htmlpage.open(fileName, ios::out);
287 std::string fullPath;
294 LOG_INFO(
"Write HTML report to " << fullPath);
302 std::string fullPath;
309 AddImage(fullPath.c_str(), description, widthPx, heightPx);
virtual ~vtkPlusHTMLGenerator()
virtual char * GetOutputDirectory()
virtual void AddText(const char *text, HEADINGS h, const char *style=NULL)
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual void SaveHtmlPage(const char *fileName)
virtual void AddImage(const char *imageSource, const char *alt, const int widthPx=0, const int heightPx=0)
static vtkPlusConfig * GetInstance()
virtual void AddLink(const char *linkText, const char *url)
PhidgetLCD_Font int int const char * text
virtual void SetTitle(const char *)
virtual void SetBaseFilename(const char *)
virtual std::string SaveHtmlPageAutoFilename()
virtual void AddHorizontalLine()
std::ostringstream HtmlBody
virtual void AddParagraph(const char *paragraph)
virtual void AddTable(vtkTable *table, int borderPx)
virtual std::string GetHtmlBody()
virtual std::string AddImageAutoFilename(const char *filenamePostfix, const char *description, const int widthPx=0, const int heightPx=0)
virtual char * GetBaseFilename()
virtual char * GetTitle()
class for generating basic html tags
vtkStandardNewMacro(vtkPlusHTMLGenerator)
virtual void SetOutputDirectory(const char *)
virtual std::string GetHtmlPage()