MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
CAD4FE_HtmlText.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// CAD4FE_HtmlText.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:56 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 #include "gestionversion.h"
23 
24 #include "CAD4FE_Common_platform.h"
25 
26 #include <stdlib.h>
27 #include <sstream>
28 #include <fstream>
29 #include <map>
30 #include <vector>
31 #include <set>
32 
33 #include <unistd.h>
34 
35 
36 
37 
38 #include "CAD4FE_HtmlText.h"
39 
40 
41 using namespace CAD4FE;
42 
43 HtmlText_Table::HtmlText_Table (std::vector <std::string> & __head)
44 {
45  _head = __head;
46 }
47 
48 HtmlText_Table::HtmlText_Table (std::vector <std::string> & __head, std::vector < std::vector <std::string> > & __rows)
49 {
50  _head = __head;
51  _rows = __rows;
52 }
53 
54 void HtmlText_Table::AddRow (std::vector <std::string> & __row)
55 {
56  _rows.push_back(__row);
57 }
58 
60 {
61  std::ostringstream out;
62  out << "<table border=\"2\" cellpadding=5 frame=\"vhsides\" rules=\"cols\">\n";
63  out << "<tr>";
64  for (unsigned i=0; i<_head.size(); i++)
65  out << "<th>" << _head[i] << "</th>";
66  out << "</tr>\n";
67  for (unsigned j=0; j<_rows.size(); j++)
68  {
69  std::vector <std::string> & row = _rows[j];
70  out << "<tr>";
71  for (unsigned i=0; i<row.size(); i++)
72  out << "<td>" << row[i] << "</td>";
73  out << "</tr>\n";
74  }
75  out << "</table>\n";
76  return out.str();
77 }
78 
80 {
81 }
82 
83 void HtmlText_Page::Add(std::string __html)
84 {
85  _html += __html;
86 }
87 
88 void HtmlText_Page::operator << (const std::ostringstream & __os)
89 {
90  _html += __os.str();
91 }
92 
94 {
95 }
96 
98 {
99  return _html;
100 }
101 
102 
103 void HtmlText_Page::Show(std::string __filename)
104 {
105  WriteFile(__filename);
106 
107  char htmlViewer[] = "firefox";
108  execl(htmlViewer, __filename.c_str());
109 
110 
111 }
112 
113 void HtmlText_Page::WriteFile(std::string __filename)
114 {
115  std::ofstream file;
116  file.open(__filename.c_str());
117  file << _html;
118  file.close();
119 }
120 
121 
123 {
124  _html.clear();
125 }
126 
CAD4FE_Common_platform.h
gestionversion.h
CAD4FE::HtmlText_Page::WriteFile
void WriteFile(std::string __filename)
Definition: CAD4FE_HtmlText.cpp:113
CAD4FE::HtmlText_Table::HtmlText_Table
HtmlText_Table(std::vector< std::string > &__head)
Definition: CAD4FE_HtmlText.cpp:43
CAD4FE::HtmlText_Table::GetHtml
virtual std::string GetHtml()
Definition: CAD4FE_HtmlText.cpp:59
CAD4FE::HtmlText_Table::_rows
std::vector< std::vector< std::string > > _rows
Definition: CAD4FE_HtmlText.h:48
CAD4FE::HtmlText_Page::operator<<
void operator<<(const std::ostringstream &__os)
Definition: CAD4FE_HtmlText.cpp:88
CAD4FE::HtmlText_Page::_html
std::string _html
Definition: CAD4FE_HtmlText.h:62
CAD4FE::HtmlText_Page::Clear
void Clear()
Definition: CAD4FE_HtmlText.cpp:122
CAD4FE::HtmlText_Page::Close
void Close()
Definition: CAD4FE_HtmlText.cpp:93
CAD4FE::HtmlText_Page::Show
void Show(std::string __filename)
Definition: CAD4FE_HtmlText.cpp:103
CAD4FE::HtmlText_Table::_head
std::vector< std::string > _head
Definition: CAD4FE_HtmlText.h:47
CAD4FE
Definition: CAD4FE_ClosestPoint_Segment_MG_ARETE.h:34
CAD4FE::HtmlText_Page::GetHtml
virtual std::string GetHtml()
Definition: CAD4FE_HtmlText.cpp:97
CAD4FE::HtmlText_Page::HtmlText_Page
HtmlText_Page()
Definition: CAD4FE_HtmlText.cpp:79
CAD4FE_HtmlText.h
CAD4FE::HtmlText_Page::Add
void Add(std::string __string)
Definition: CAD4FE_HtmlText.cpp:83
CAD4FE::HtmlText_Table::AddRow
void AddRow(std::vector< std::string > &__row)
Definition: CAD4FE_HtmlText.cpp:54