37#ifndef Foam_SVGTools_H
38#define Foam_SVGTools_H
55 typedef std::pair<const char*, string>
entryType;
70 const std::initializer_list<entryType>& styles = {},
71 const std::initializer_list<entryType>& elems = {}
80 void addAttr(
const char* key,
const Type& value)
87 void addAttrStr(
const char* key,
const string& str)
96 for (
const auto&
e : ele.
elems_)
98 os <<
" " <<
e.first <<
"=" <<
e.second;
104 os <<
s.first <<
":" <<
s.second.c_str() <<
";";
131 const std::initializer_list<entryType>& styles = {},
132 const word anchor =
"middle",
133 const std::initializer_list<entryType>& elems = {}
136 element(
"text", styles, elems),
144 entryType(
"font-family",
"Arial, Helvetica, sans-serif")
177 const std::initializer_list<entryType>& styles = {},
178 const std::initializer_list<entryType>& elems = {}
209 header(
const label width,
const label height)
217 os <<
"<svg viewBox=\"0 0 " <<
h.width_ <<
' ' <<
h.height_ <<
"\""
218 <<
" xmlns=\"http://www.w3.org/2000/svg\""
219 <<
" xmlns:xlink=\"http://www.w3.org/1999/xlink\""
220 <<
" xmlns:bx=\"https://www.boxy-svg.com/bx\">";
227 const char*
end =
"</svg>";
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Foam::string str() const
Get the string. As Foam::string instead of std::string (may change in future).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Collection of tools to generate SVG strings.
std::pair< const char *, string > entryType
Ostream & operator<<(Ostream &os, const element &e)
dimensionedScalar y1(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void addAttrStr(const char *key, const string &str)
DynamicList< entryType > styles_
element(const word &key, const std::initializer_list< entryType > &styles={}, const std::initializer_list< entryType > &elems={})
void addAttr(const char *key, const Type &value)
DynamicList< entryType > elems_
friend Ostream & operator<<(Ostream &os, const element &ele)
friend Ostream & operator<<(Ostream &os, const line &l)
line(const label x1, const label y1, const label x2, const label y2, const std::initializer_list< entryType > &styles={}, const std::initializer_list< entryType > &elems={})
friend Ostream & operator<<(Ostream &os, const text &t)
text(const string text, const label left, const label top, const std::initializer_list< entryType > &styles={}, const word anchor="middle", const std::initializer_list< entryType > &elems={})