NCBI C++ ToolKit
svg.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_UTILS__SVG_HPP
2 #define GUI_UTILS__SVG_HPP
3 
4 /* $Id: svg.hpp 45024 2020-05-09 02:03:16Z evgeniev $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Vladislav Evgeniev
30  *
31  * File Description:
32  * SVG serialization
33  */
34 
35 #include <ostream>
36 #include <vector>
37 #include <string>
38 #include <sstream>
39 
40 #include <corelib/ncbistd.hpp>
41 #include <gui/utils/vect2.hpp>
42 #include <gui/utils/rgba_color.hpp>
44 
46 
47 BEGIN_SCOPE(svg)
48 
49 class StartTag
50 {
51 public:
52  StartTag(std::string const& tag, unsigned indent = 0) : m_Tag(tag), m_Indent(indent) {}
53 
54  friend std::ostream& operator<<(std::ostream& ostrm, StartTag const& tag)
55  {
56  for (unsigned i = 0; i < tag.m_Indent; ++i) {
57  ostrm << "\t";
58  }
59  ostrm << '<' << tag.m_Tag << ' ';
60  return ostrm;
61  }
62 
63 private:
65  unsigned m_Indent;
66 };
67 
68 class EndTag
69 {
70 public:
71  EndTag(std::string const& tag, unsigned indent = 0) : m_Tag(tag), m_Indent(indent) {}
72 
73  friend std::ostream& operator<<(std::ostream& ostrm, EndTag const& tag)
74  {
75  for (unsigned i = 0; i < tag.m_Indent; ++i) {
76  ostrm << "\t";
77  }
78  ostrm << "</" << tag.m_Tag << ">\n";
79  return ostrm;
80  }
81 
82 private:
84  unsigned m_Indent;
85 };
86 
88 {
89  return "/>\n";
90 }
91 
92 template <typename T>
93 class Attribute
94 {
95 public:
96  Attribute(std::string const& name, T const& value, std::string const& units = "") : m_Name(name), m_Value(value), m_Units(units) {}
97  friend std::ostream& operator<<(std::ostream& ostrm, Attribute const& attr)
98  {
99  ostrm << attr.m_Name << "=\"" << std::fixed << std::setprecision(2) << attr.m_Value << attr.m_Units << "\" ";
100  return ostrm;
101  }
102 private:
106 };
107 
109 {
110 public:
111  virtual ~ISerializeable() = default;
112  virtual void Serialize(std::ostream& ostrm) const = 0;
113 };
114 
115 inline std::ostream& operator<<(std::ostream& ostrm, ISerializeable const& object)
116 {
117  object.Serialize(ostrm);
118  return ostrm;
119 }
120 
121 class Color : public ISerializeable
122 {
123 public:
124  Color() = default;
125  Color(CRgbaColor const& color, std::string const& color_tag, std::string const& opacity_tag) :
126  m_Color(color.ToHtmlString()), m_Opacity(color.GetAlpha()), m_ColorTag(color_tag), m_OpacityTag(opacity_tag) {}
127  bool IsEmpty() const
128  {
129  return m_Color.empty();
130  }
131  virtual void Serialize(std::ostream& ostrm) const
132  {
133  if (m_Color.empty())
134  return;
135  ostrm << Attribute<std::string>(m_ColorTag, m_Color);
136  if (1.0 == m_Opacity)
137  return;
138  ostrm << Attribute<float>(m_OpacityTag, m_Opacity);
139  }
140 private:
142  float m_Opacity;
145 };
146 
148 {
149 public:
150  ReferencePrimitive(std::string const& id) : m_Id(id) {}
151  virtual ~ReferencePrimitive() = default;
152  virtual void Serialize(std::ostream& ostrm) const
153  {
154  if (!m_Id.empty())
155  ostrm << Attribute<std::string>("id", m_Id);
156  }
157 private:
159 };
160 
161 class Image : public ReferencePrimitive
162 {
163 public:
164  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) :
165  ReferencePrimitive(id), m_Origin(origin), m_Href(href), m_Width(width), m_Height(height) {}
166  virtual void Serialize(std::ostream& ostrm) const
167  {
168  ostrm << StartTag("image", 3)
169  << Attribute<float>("x", m_Origin.X())
170  << Attribute<float>("y", m_Origin.Y())
171  << Attribute<unsigned>("width", m_Width)
172  << Attribute<unsigned>("height", m_Height)
173  << Attribute<std::string>("href", m_Href);
175  ostrm << EmptyElementEnd();
176  }
177 private:
180  unsigned m_Width;
181  unsigned m_Height;
182 };
183 
185 {
186 public:
187  Pattern(std::string const& id, Image const& image, unsigned width = 32, unsigned height = 32, std::string const& pattern_units = string("userSpaceOnUse")) :
188  ReferencePrimitive(id), m_Image(image), m_PatternUnits(pattern_units), m_Width(width), m_Height(height) {}
189 
190  virtual void Serialize(std::ostream& ostrm) const
191  {
192  ostrm << StartTag("pattern", 2)
193  << Attribute<std::string>("patternUnits", m_PatternUnits)
194  << Attribute<unsigned>("width", m_Width)
195  << Attribute<unsigned>("height", m_Height);
197  ostrm << ">\n" << m_Image << EndTag("pattern", 2);
198 
199  }
200 private:
203  unsigned m_Width;
204  unsigned m_Height;
205 };
206 
208 {
209 public:
211  LinearGradient(std::string const& id, std::vector<CRgbaColor> const& colors, EType type = eVertical) :
213 
214  virtual void Serialize(std::ostream& ostrm) const
215  {
216  ostrm << StartTag("linearGradient", 2);
218  if (eVertical == m_Type) {
219  ostrm << Attribute<string>("gradientTransform", "rotate(90)");
220  }
221  ostrm << ">\n";
222  double step = 100.0 / double(m_Colors.size() - 1);
223  double offset = 0.0;
224  for (auto const& color : m_Colors) {
225  ostrm << StartTag("stop", 3)
226  << Attribute<int>("offset", int(offset), "%")
227  << Color(color, "stop-color", "stop-opacity")
228  << EmptyElementEnd();
229  offset += step;
230  }
231  ostrm << EndTag("linearGradient", 2);
232  }
233 private:
234  std::vector<CRgbaColor> const& m_Colors;
236 };
237 
239 {
240 public:
241  ClipRect(std::string const& id, int x, int y, unsigned width, unsigned height) :
242  ReferencePrimitive(id), m_X(x), m_Y(y), m_Width(width), m_Height(height) {}
243  virtual void Serialize(std::ostream& ostrm) const
244  {
245  ostrm << StartTag("clipPath", 2);
247  ostrm << ">\n";
248  ostrm << StartTag("rect", 3)
249  << Attribute<int>("x", int(m_X))
250  << Attribute<int>("y", int(m_Y))
251  << Attribute<unsigned>("width", int(m_Width))
252  << Attribute<unsigned>("height", int(m_Height))
253  << EmptyElementEnd();
254  ostrm << EndTag("clipPath", 2);
255  }
256 private:
257  int m_X;
258  int m_Y;
259  unsigned m_Width;
260  unsigned m_Height;
261 };
262 
263 class Fill : public ISerializeable
264 {
265 public:
266  Fill() = default;
267  Fill(CRgbaColor const& color) : m_Color(color, "fill", "fill-opacity") { }
268  Fill(std::string const& refid) : m_RefId("url('#" + refid + "')") { }
269  virtual void Serialize(std::ostream& ostrm) const
270  {
271  if (!m_RefId.empty()) {
272  ostrm << Attribute<std::string>("fill", m_RefId);
273  }
274  else {
275  ostrm << m_Color;
276  }
277  }
278 private:
281 };
282 
283 class Stroke : public ISerializeable
284 {
285 public:
288 public:
289  Stroke() = default;
290  Stroke(CRgbaColor const& color, double width = 0.0, ELineJoinStyle line_join = eDefaultJoin, ELineCapStyle line_cap = eDefaultCap, unsigned pattern = 0xffff, int factor = 0)
291  : m_Color(color, "stroke", "stroke-opacity"), m_Width(width), m_LineJoin(line_join), m_LineCap(line_cap), m_Pattern(pattern), m_Factor(factor) { }
292  virtual void Serialize(std::ostream& ostrm) const
293  {
294  if (m_Color.IsEmpty())
295  return;
296  if (m_Width > 0.0) {
297  ostrm << m_Color << Attribute<double>("stroke-width", m_Width);
298  }
299  if ((eDefaultJoin != m_LineJoin) && (eMiteredJoin != m_LineJoin)) {
300  static vector<std::string> linejoin_values = { "miter", "round", "bevel" };
301  ostrm << Attribute<std::string>("stroke-linejoin", linejoin_values[m_LineJoin]);
302  }
303  if ((eDefaultCap != m_LineCap) && (eButtCap != m_LineCap)) {
304  static vector<std::string> linecap_values = { "butt", "round", "square" };
305  ostrm << Attribute<std::string>("stroke-linecap", linecap_values[m_LineCap]);
306  }
307  if (0xffff != m_Pattern) {
308  ostrm << Attribute<std::string>("stroke-dasharray", x_ParseStipplePattern());
309  }
310  }
311 private:
312  string x_ParseStipplePattern() const
313  {
314  int on = 0;
315  int off = 0;
316  stringstream result;
317  auto OutputPattern = [&result, this](int &count) {
318  if (count == 0)
319  return;
320  result << NStr::NumericToString(m_Factor * count) << ' ';
321  count = 0;
322  };
323  for (int j = 15; j >= 0; --j) {
324  if (m_Pattern & (1 << j)) {
325  OutputPattern(off);
326  ++on;
327  }
328  else {
329  OutputPattern(on);
330  ++off;
331  }
332  }
333  OutputPattern(on);
334  OutputPattern(off);
335 
336  return result.str();
337  }
338 private:
340  double m_Width = 1.0;
343  unsigned m_Pattern = 0xffff;
344  int m_Factor = 0;
345 };
346 
347 class Font : public ISerializeable
348 {
349 public:
350  Font(CGlTextureFont const& font, int align = 0) : m_Family(CGlTextureFont::FaceToString(font.GetFontFace())), m_Size(font.GetFontSize()), m_Align(align) {}
351  Font(std::string const &family, unsigned size = 12, int align = 0) : m_Family(family), m_Size(size), m_Align(align) { }
352  virtual void Serialize(std::ostream& ostrm) const
353  {
354  ostrm << Attribute<std::string>("font-family", m_Family) << Attribute<unsigned>("font-size", m_Size);
355  if (m_Align) {
358  ostrm << Attribute<std::string>("text-anchor", "start");
359  break;
361  ostrm << Attribute<std::string>("text-anchor", "middle");
362  break;
364  ostrm << Attribute<std::string>("text-anchor", "end");
365  break;
366  }
367 
368  /*switch (m_Align & CGlTextureFont::eAlign_VertMask) {
369  case CGlTextureFont::eAlign_Top:
370  ostrm << Attribute<unsigned>("dy", m_Size);
371  break;
372  case CGlTextureFont::eAlign_VCenter:
373  ostrm << Attribute<double>("dy", m_Size / 2.0);
374  break;
375  case CGlTextureFont::eAlign_Bottom:
376  ostrm << Attribute<unsigned>("dy", 0);
377  break;
378  }*/
379  }
380  }
381 private:
383  unsigned m_Size;
384  int m_Align;
385 };
386 
387 class Primitive : public ISerializeable
388 {
389 public:
390  Primitive(Fill const &fill = Fill(), Stroke const &stroke = Stroke(), std::string const &clip_path_id = std::string())
391  : m_Fill(fill), m_Stroke(stroke)
392  {
393  if (!clip_path_id.empty()) {
394  m_ClipPathId = "url('#" + clip_path_id + "')";
395  }
396  }
397  virtual void Serialize(std::ostream& ostrm) const
398  {
399  if (m_ClipPathId.empty())
400  return;
401 
402  ostrm << Attribute<std::string>("clip-path", m_ClipPathId);
403  }
404 protected:
408 };
409 
410 class Circle : public Primitive
411 {
412 public:
413  Circle(CVect2<float> const& center, double diameter, Fill const & fill, Stroke const & stroke = Stroke(), std::string const &clip_path_id = std::string())
414  : Primitive(fill, stroke, clip_path_id), m_Center(center), m_Radius(diameter * 0.5) { }
415  virtual void Serialize(std::ostream& ostrm) const
416  {
417  ostrm << StartTag("circle", 2)
418  << Attribute<float>("cx", m_Center.X())
419  << Attribute<float>("cy", m_Center.Y())
420  << Attribute<double>("r", m_Radius)
421  << m_Fill
422  << m_Stroke;
423  Primitive::Serialize(ostrm);
424  ostrm << EmptyElementEnd();
425  }
426 private:
428  double m_Radius;
429 };
430 
431 class Line : public Primitive
432 {
433 public:
434  Line(CVect2<float> const& start_point, CVect2<float> const& end_point, Stroke const & stroke = Stroke(), std::string const &clip_path_id = std::string())
435  : Primitive(Fill(), stroke, clip_path_id), m_StartPoint(start_point), m_EndPoint(end_point) { }
436  virtual void Serialize(std::ostream& ostrm) const
437  {
438  ostrm << StartTag("line", 2)
439  << Attribute<float>("x1", m_StartPoint.X())
440  << Attribute<float>("y1", m_StartPoint.Y())
441  << Attribute<float>("x2", m_EndPoint.X())
442  << Attribute<float>("y2", m_EndPoint.Y())
443  << m_Stroke;
444  Primitive::Serialize(ostrm);
445  ostrm << EmptyElementEnd();
446  }
447 private:
450 };
451 
452 class Polyline : public Primitive
453 {
454 public:
455  Polyline(vector<CVect2<float>> const& vertices, Fill const& fill = Fill(), Stroke const& stroke = Stroke(), std::string const &clip_path_id = std::string())
456  : Primitive(fill, stroke, clip_path_id), m_Vertices(vertices) { }
457  virtual void Serialize(std::ostream& ostrm) const
458  {
459  ostrm << StartTag("polyline", 2)
460  << m_Fill
461  << m_Stroke
462  << "points=\"";
463  for (const auto& vertex : m_Vertices) {
464  ostrm << vertex.X() << "," << vertex.Y() << " ";
465  }
466  ostrm << "\" ";
467  Primitive::Serialize(ostrm);
468  ostrm << EmptyElementEnd();
469  }
470 private:
471  vector<CVect2<float>> m_Vertices;
472 };
473 
474 class Polygon : public Primitive
475 {
476 public:
477  Polygon(vector<CVect2<float>> const& vertices, Fill const& fill = Fill(), Stroke const& stroke = Stroke(), std::string const &clip_path_id = std::string())
478  : Primitive(fill, stroke, clip_path_id), m_Vertices(vertices) { }
479  virtual void Serialize(std::ostream& ostrm) const
480  {
481  ostrm << StartTag("polygon", 2)
482  << m_Fill
483  << m_Stroke
484  << Attribute<string>("shape-rendering", "crispEdges")
485  << "points=\"";
486  for (const auto& vertex : m_Vertices) {
487  ostrm << vertex.X() << "," << vertex.Y() << " ";
488  }
489  ostrm << "\" ";
490  Primitive::Serialize(ostrm);
491  ostrm << EmptyElementEnd();
492  }
493 private:
494  vector<CVect2<float>> m_Vertices;
495 };
496 
497 class Text : public Primitive
498 {
499 public:
500  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)
501  : Primitive(fill, Stroke(), clip_path_id), m_Origin(origin), m_Text(text), m_Angle(angle), m_Font(font) { }
502  virtual void Serialize(std::ostream& ostrm) const
503  {
504  ostrm << StartTag("text", 2)
505  << Attribute<float>("x", m_Origin.X())
506  << Attribute<float>("y", m_Origin.Y())
507  << m_Font;
508  if (m_Angle) {
509  ostrm << "transform=\"rotate(" << std::fixed << std::setprecision(2) << -m_Angle << ',' << m_Origin.X() << ',' << m_Origin.Y() << ")\" ";
510  }
511  ostrm << m_Fill
512  << m_Stroke;
513  Primitive::Serialize(ostrm);
514  ostrm << ">" << m_Text << EndTag("text");
515  }
516 private:
519  double m_Angle;
521 };
522 
523 class ViewBox : public ISerializeable
524 {
525 public:
526  ViewBox(int x = 0, int y = 0, unsigned width = 100, unsigned height = 100) : m_X(x), m_Y(y), m_Width(width), m_Height(height) {}
527  virtual void Serialize(std::ostream& ostrm) const
528  {
529  ostrm << "viewBox=\"" << m_X << ' ' << m_Y << ' ' << m_Width << ' ' << m_Height << "\" ";
530  }
531  inline int X() const { return m_X; };
532  inline int Y() const { return m_Y; };
533  inline unsigned Width() const { return m_Width; };
534  inline unsigned Height() const { return m_Height; };
535 private:
536  int m_X;
537  int m_Y;
538  unsigned m_Width;
539  unsigned m_Height;
540 };
541 
542 class Style : public ISerializeable
543 {
544 public:
545  Style(std::string const& style_text = "") : m_Text(style_text) {}
546  virtual void Serialize(std::ostream& ostrm) const
547  {
548  if (m_Text.empty()) {
549  return;
550  }
551  ostrm << StartTag("style", 1)
552  << Attribute<std::string>("type", "text/css")
553  << ">"
554  << m_Text
555  << EndTag("style", 1);
556  }
557 private:
559 };
560 
561 class SVG : public Primitive
562 {
563 public:
564  SVG(ViewBox viewbox, SVG *parent) : m_ViewBox(viewbox), m_Parent(parent) {}
565  SVG(ViewBox viewbox, Style style = Style(), std::string const& description = "") : m_ViewBox(viewbox), m_Style(style), m_Description(description) {}
566 
567  SVG& operator<<(ReferencePrimitive const& primitive)
568  {
569  if (nullptr != m_Parent) {
570  m_Parent->operator<<(primitive);
571  return *this;
572  }
573 
574  m_Definitions << primitive;
575  m_Definitions.flush();
576  return *this;
577  }
578 
579  SVG& operator<<(Primitive const& primitive)
580  {
581  m_Primitives << primitive;
582  m_Primitives.flush();
583  return *this;
584  }
585 
586  virtual void Serialize(std::ostream& ostrm) const
587  {
588  ostrm << StartTag("svg", 1)
589  << Attribute<int>("x", m_ViewBox.X())
590  << Attribute<int>("y", m_ViewBox.Y())
591  << Attribute<unsigned>("width", m_ViewBox.Width(), "px")
592  << Attribute<unsigned>("height", m_ViewBox.Height(), "px")
593  << Attribute<std::string>("preserveAspectRatio", "xMinYMin slice")
594  << ViewBox(0, 0, m_ViewBox.Width(), m_ViewBox.Height())
595  << ">\n"
596  << m_Primitives.str()
597  << EndTag("svg", 1);
598  }
599 
600  void WriteToStream(std::ostream& ostr) const
601  {
602  ostr << "<?xml "
603  << Attribute<std::string>("version", "1.0")
604  << Attribute<std::string>("standalone", "no")
605  << "?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "
606  << "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
607  << StartTag("svg")
608  << Attribute<unsigned>("width", m_ViewBox.Width(), "px")
609  << Attribute<unsigned>("height", m_ViewBox.Height(), "px")
610  << Attribute<std::string>("xmlns", "http://www.w3.org/2000/svg")
611  << Attribute<std::string>("version", "1.1")
612  << m_ViewBox
613  << ">\n"
614  << m_Style;
615  if (!m_Description.empty()) {
616  ostr << StartTag("desc", 1) << '>'
617  << m_Description
618  << EndTag("desc");
619  }
620  ostr << StartTag("defs", 1) << ">\n"
621  << m_Definitions.str()
622  << EndTag("defs", 1)
623  << StartTag("g", 1) << ">\n"
624  << m_Primitives.str()
625  << EndTag("g", 1)
626  << EndTag("svg");
627  }
628 private:
629  std::stringstream m_Definitions;
630  std::stringstream m_Primitives;
634  SVG *m_Parent = nullptr;
635 };
636 
637 END_SCOPE(svg)
638 
640 
641 #endif // GUI_UTILS__SVG_HPP
Attribute(std::string const &name, T const &value, std::string const &units="")
Definition: svg.hpp:96
friend std::ostream & operator<<(std::ostream &ostrm, Attribute const &attr)
Definition: svg.hpp:97
std::string m_Name
Definition: svg.hpp:103
T m_Value
Definition: svg.hpp:104
std::string m_Units
Definition: svg.hpp:105
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
Definition: svg.hpp:411
CVect2< float > m_Center
Definition: svg.hpp:427
double m_Radius
Definition: svg.hpp:428
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:415
Circle(CVect2< float > const &center, double diameter, Fill const &fill, Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
Definition: svg.hpp:413
unsigned m_Width
Definition: svg.hpp:259
int m_Y
Definition: svg.hpp:258
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:243
int m_X
Definition: svg.hpp:257
ClipRect(std::string const &id, int x, int y, unsigned width, unsigned height)
Definition: svg.hpp:241
unsigned m_Height
Definition: svg.hpp:260
Definition: svg.hpp:122
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:131
float m_Opacity
Definition: svg.hpp:142
std::string m_OpacityTag
Definition: svg.hpp:144
bool IsEmpty() const
Definition: svg.hpp:127
std::string m_ColorTag
Definition: svg.hpp:143
Color()=default
Color(CRgbaColor const &color, std::string const &color_tag, std::string const &opacity_tag)
Definition: svg.hpp:125
std::string m_Color
Definition: svg.hpp:141
Definition: svg.hpp:69
std::string m_Tag
Definition: svg.hpp:83
EndTag(std::string const &tag, unsigned indent=0)
Definition: svg.hpp:71
unsigned m_Indent
Definition: svg.hpp:84
friend std::ostream & operator<<(std::ostream &ostrm, EndTag const &tag)
Definition: svg.hpp:73
Definition: svg.hpp:264
Fill(std::string const &refid)
Definition: svg.hpp:268
Color m_Color
Definition: svg.hpp:280
Fill()=default
Fill(CRgbaColor const &color)
Definition: svg.hpp:267
std::string m_RefId
Definition: svg.hpp:279
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:269
Definition: svg.hpp:348
int m_Align
Definition: svg.hpp:384
Font(CGlTextureFont const &font, int align=0)
Definition: svg.hpp:350
std::string m_Family
Definition: svg.hpp:382
Font(std::string const &family, unsigned size=12, int align=0)
Definition: svg.hpp:351
unsigned m_Size
Definition: svg.hpp:383
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:352
virtual ~ISerializeable()=default
virtual void Serialize(std::ostream &ostrm) const =0
Definition: svg.hpp:162
unsigned m_Width
Definition: svg.hpp:180
CVect2< float > m_Origin
Definition: svg.hpp:178
std::string m_Href
Definition: svg.hpp:179
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)
Definition: svg.hpp:164
unsigned m_Height
Definition: svg.hpp:181
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:166
Definition: svg.hpp:432
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:436
CVect2< float > m_EndPoint
Definition: svg.hpp:449
CVect2< float > m_StartPoint
Definition: svg.hpp:448
Line(CVect2< float > const &start_point, CVect2< float > const &end_point, Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
Definition: svg.hpp:434
LinearGradient(std::string const &id, std::vector< CRgbaColor > const &colors, EType type=eVertical)
Definition: svg.hpp:211
std::vector< CRgbaColor > const & m_Colors
Definition: svg.hpp:234
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:214
EType m_Type
Definition: svg.hpp:235
Definition: svg.hpp:185
unsigned m_Height
Definition: svg.hpp:204
Image m_Image
Definition: svg.hpp:201
unsigned m_Width
Definition: svg.hpp:203
Pattern(std::string const &id, Image const &image, unsigned width=32, unsigned height=32, std::string const &pattern_units=string("userSpaceOnUse"))
Definition: svg.hpp:187
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:190
std::string m_PatternUnits
Definition: svg.hpp:202
Definition: svg.hpp:475
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:479
Polygon(vector< CVect2< float >> const &vertices, Fill const &fill=Fill(), Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
Definition: svg.hpp:477
vector< CVect2< float > > m_Vertices
Definition: svg.hpp:494
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:457
vector< CVect2< float > > m_Vertices
Definition: svg.hpp:471
Polyline(vector< CVect2< float >> const &vertices, Fill const &fill=Fill(), Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
Definition: svg.hpp:455
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:397
Primitive(Fill const &fill=Fill(), Stroke const &stroke=Stroke(), std::string const &clip_path_id=std::string())
Definition: svg.hpp:390
std::string m_ClipPathId
Definition: svg.hpp:407
Stroke m_Stroke
Definition: svg.hpp:406
Fill m_Fill
Definition: svg.hpp:405
ReferencePrimitive(std::string const &id)
Definition: svg.hpp:150
virtual ~ReferencePrimitive()=default
std::string m_Id
Definition: svg.hpp:158
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:152
Definition: svg.hpp:562
std::stringstream m_Definitions
Definition: svg.hpp:629
std::string m_Description
Definition: svg.hpp:633
std::stringstream m_Primitives
Definition: svg.hpp:630
SVG & operator<<(ReferencePrimitive const &primitive)
Definition: svg.hpp:567
SVG(ViewBox viewbox, Style style=Style(), std::string const &description="")
Definition: svg.hpp:565
ViewBox m_ViewBox
Definition: svg.hpp:631
void WriteToStream(std::ostream &ostr) const
Definition: svg.hpp:600
SVG & operator<<(Primitive const &primitive)
Definition: svg.hpp:579
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:586
SVG(ViewBox viewbox, SVG *parent)
Definition: svg.hpp:564
Style m_Style
Definition: svg.hpp:632
SVG * m_Parent
Definition: svg.hpp:634
Definition: svg.hpp:50
std::string m_Tag
Definition: svg.hpp:64
StartTag(std::string const &tag, unsigned indent=0)
Definition: svg.hpp:52
friend std::ostream & operator<<(std::ostream &ostrm, StartTag const &tag)
Definition: svg.hpp:54
unsigned m_Indent
Definition: svg.hpp:65
Definition: svg.hpp:284
string x_ParseStipplePattern() const
Definition: svg.hpp:312
ELineCapStyle m_LineCap
Definition: svg.hpp:342
int m_Factor
Definition: svg.hpp:344
Color m_Color
Definition: svg.hpp:339
ELineJoinStyle
Definition: svg.hpp:286
@ eMiteredJoin
Definition: svg.hpp:286
@ eBeveledJoin
Definition: svg.hpp:286
@ eDefaultJoin
Definition: svg.hpp:286
@ eRoundedJoin
Definition: svg.hpp:286
Stroke(CRgbaColor const &color, double width=0.0, ELineJoinStyle line_join=eDefaultJoin, ELineCapStyle line_cap=eDefaultCap, unsigned pattern=0xffff, int factor=0)
Definition: svg.hpp:290
double m_Width
Definition: svg.hpp:340
Stroke()=default
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:292
ELineJoinStyle m_LineJoin
Definition: svg.hpp:341
unsigned m_Pattern
Definition: svg.hpp:343
ELineCapStyle
Definition: svg.hpp:287
@ eDefaultCap
Definition: svg.hpp:287
@ eRoundCap
Definition: svg.hpp:287
@ eSquareCap
Definition: svg.hpp:287
@ eButtCap
Definition: svg.hpp:287
Definition: svg.hpp:543
Style(std::string const &style_text="")
Definition: svg.hpp:545
std::string m_Text
Definition: svg.hpp:558
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:546
Definition: svg.hpp:498
double m_Angle
Definition: svg.hpp:519
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:502
Font m_Font
Definition: svg.hpp:520
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)
Definition: svg.hpp:500
std::string m_Text
Definition: svg.hpp:518
CVect2< float > m_Origin
Definition: svg.hpp:517
Definition: svg.hpp:524
unsigned m_Width
Definition: svg.hpp:538
int m_X
Definition: svg.hpp:534
int X() const
Definition: svg.hpp:531
unsigned m_Height
Definition: svg.hpp:539
virtual void Serialize(std::ostream &ostrm) const
Definition: svg.hpp:527
int Y() const
Definition: svg.hpp:532
ViewBox(int x=0, int y=0, unsigned width=100, unsigned height=100)
Definition: svg.hpp:526
int m_Y
Definition: svg.hpp:537
unsigned Width() const
Definition: svg.hpp:533
unsigned Height() const
Definition: svg.hpp:534
static const Colors colors
Definition: cn3d_colors.cpp:50
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define T(s)
Definition: common.h:230
int offset
Definition: replacements.h:160
string
Definition: cgiapp.hpp:687
T & X()
Definition: vect2.hpp:107
T & Y()
Definition: vect2.hpp:109
@ eAlign_Right
Definition: glfont.hpp:104
@ eAlign_Left
Definition: glfont.hpp:102
@ eAlign_HorizMask
Definition: glfont.hpp:101
@ eAlign_HCenter
Definition: glfont.hpp:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
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.
Definition: ncbistr.hpp:673
n background color
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const char * tag
static const GLdouble origin[]
string indent(" ")
Definition: type.c:6
std::ostream & operator<<(std::ostream &ostrm, ISerializeable const &object)
Definition: svg.hpp:115
std::string EmptyElementEnd()
Definition: svg.hpp:87
else result
Definition: token2.c:20
Modified on Wed Apr 17 13:10:16 2024 by modify_doxy.py rev. 669887