1 #ifndef GUI_UTILS__SVG_HPP
2 #define GUI_UTILS__SVG_HPP
56 for (
unsigned i = 0;
i <
tag.m_Indent; ++
i) {
59 ostrm <<
'<' <<
tag.m_Tag <<
' ';
75 for (
unsigned i = 0;
i <
tag.m_Indent; ++
i) {
78 ostrm <<
"</" <<
tag.m_Tag <<
">\n";
99 ostrm << attr.
m_Name <<
"=\"" << std::fixed << std::setprecision(2) << attr.
m_Value << attr.
m_Units <<
"\" ";
117 object.Serialize(ostrm);
155 ostrm << Attribute<std::string>(
"id",
m_Id);
216 ostrm <<
StartTag(
"linearGradient", 2);
219 ostrm << Attribute<string>(
"gradientTransform",
"rotate(90)");
222 double step = 100.0 / double(
m_Colors.size() - 1);
231 ostrm <<
EndTag(
"linearGradient", 2);
254 ostrm <<
EndTag(
"clipPath", 2);
272 ostrm << Attribute<std::string>(
"fill",
m_RefId);
297 ostrm << m_Color << Attribute<double>(
"stroke-width",
m_Width);
300 static vector<std::string> linejoin_values = {
"miter",
"round",
"bevel" };
301 ostrm << Attribute<std::string>(
"stroke-linejoin", linejoin_values[
m_LineJoin]);
304 static vector<std::string> linecap_values = {
"butt",
"round",
"square" };
305 ostrm << Attribute<std::string>(
"stroke-linecap", linecap_values[
m_LineCap]);
323 for (
int j = 15; j >= 0; --j) {
358 ostrm << Attribute<std::string>(
"text-anchor",
"start");
361 ostrm << Attribute<std::string>(
"text-anchor",
"middle");
364 ostrm << Attribute<std::string>(
"text-anchor",
"end");
393 if (!clip_path_id.empty()) {
402 ostrm << Attribute<std::string>(
"clip-path",
m_ClipPathId);
464 ostrm << vertex.X() <<
"," << vertex.Y() <<
" ";
487 ostrm << vertex.X() <<
"," << vertex.Y() <<
" ";
509 ostrm <<
"transform=\"rotate(" << std::fixed << std::setprecision(2) << -
m_Angle <<
',' <<
m_Origin.
X() <<
',' <<
m_Origin.
Y() <<
")\" ";
531 inline int X()
const {
return m_X; };
532 inline int Y()
const {
return m_Y; };
605 <<
"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "
606 <<
"\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
620 ostr <<
StartTag(
"defs", 1) <<
">\n"
Attribute(std::string const &name, T const &value, std::string const &units="")
friend std::ostream & operator<<(std::ostream &ostrm, Attribute const &attr)
class CRgbaColor provides a simple abstraction for managing colors.
virtual void Serialize(std::ostream &ostrm) const
Circle(CVect2< float > const ¢er, double diameter, Fill const &fill, Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
virtual void Serialize(std::ostream &ostrm) const
ClipRect(std::string const &id, int x, int y, unsigned width, unsigned height)
virtual void Serialize(std::ostream &ostrm) const
Color(CRgbaColor const &color, std::string const &color_tag, std::string const &opacity_tag)
EndTag(std::string const &tag, unsigned indent=0)
friend std::ostream & operator<<(std::ostream &ostrm, EndTag const &tag)
Fill(std::string const &refid)
Fill(CRgbaColor const &color)
virtual void Serialize(std::ostream &ostrm) const
Font(CGlTextureFont const &font, int align=0)
Font(std::string const &family, unsigned size=12, int align=0)
virtual void Serialize(std::ostream &ostrm) const
virtual ~ISerializeable()=default
virtual void Serialize(std::ostream &ostrm) const =0
Image(std::string const &href, std::string const &id=std::string(), CVect2< float > const &origin={ 0.0, 0.0 }, unsigned width=32, unsigned height=32)
virtual void Serialize(std::ostream &ostrm) const
virtual void Serialize(std::ostream &ostrm) const
CVect2< float > m_EndPoint
CVect2< float > m_StartPoint
Line(CVect2< float > const &start_point, CVect2< float > const &end_point, Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
LinearGradient(std::string const &id, std::vector< CRgbaColor > const &colors, EType type=eVertical)
std::vector< CRgbaColor > const & m_Colors
virtual void Serialize(std::ostream &ostrm) const
Pattern(std::string const &id, Image const &image, unsigned width=32, unsigned height=32, std::string const &pattern_units=string("userSpaceOnUse"))
virtual void Serialize(std::ostream &ostrm) const
std::string m_PatternUnits
virtual void Serialize(std::ostream &ostrm) const
Polygon(vector< CVect2< float >> const &vertices, Fill const &fill=Fill(), Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
vector< CVect2< float > > m_Vertices
virtual void Serialize(std::ostream &ostrm) const
vector< CVect2< float > > m_Vertices
Polyline(vector< CVect2< float >> const &vertices, Fill const &fill=Fill(), Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
virtual void Serialize(std::ostream &ostrm) const
Primitive(Fill const &fill=Fill(), Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
ReferencePrimitive(std::string const &id)
virtual ~ReferencePrimitive()=default
virtual void Serialize(std::ostream &ostrm) const
std::stringstream m_Definitions
std::string m_Description
std::stringstream m_Primitives
SVG & operator<<(ReferencePrimitive const &primitive)
SVG(ViewBox viewbox, Style style=Style(), std::string const &description="")
void WriteToStream(std::ostream &ostr) const
SVG & operator<<(Primitive const &primitive)
virtual void Serialize(std::ostream &ostrm) const
SVG(ViewBox viewbox, SVG *parent)
StartTag(std::string const &tag, unsigned indent=0)
friend std::ostream & operator<<(std::ostream &ostrm, StartTag const &tag)
string x_ParseStipplePattern() const
Stroke(CRgbaColor const &color, double width=0.0, ELineJoinStyle line_join=eDefaultJoin, ELineCapStyle line_cap=eDefaultCap, unsigned pattern=0xffff, int factor=0)
virtual void Serialize(std::ostream &ostrm) const
ELineJoinStyle m_LineJoin
Style(std::string const &style_text="")
virtual void Serialize(std::ostream &ostrm) const
virtual void Serialize(std::ostream &ostrm) const
Text(CVect2< float > const &origin, std::string const &text, Font const &font, Fill const &fill=Fill(), std::string const &clip_path_id=std::string(), double angle=0.0)
virtual void Serialize(std::ostream &ostrm) const
ViewBox(int x=0, int y=0, unsigned width=100, unsigned height=100)
static const Colors colors
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
static const GLdouble origin[]
std::ostream & operator<<(std::ostream &ostrm, ISerializeable const &object)
std::string EmptyElementEnd()