41#include "drain/util/EnumFlags.h"
42#include "drain/util/FileInfo.h"
43#include "drain/util/Frame.h"
44#include "drain/util/SelectorXML.h"
45#include "drain/util/TreeXML.h"
54typedef drain::UnorderedMultiTree<NodeSVG,false, NodeXML<>::path_t> TreeSVG;
58 typedef float coord_t;
61 UNDEFINED=XML::UNDEFINED,
66 STYLE_SELECT=XML::STYLE_SELECT,
68 CIRCLE, DESC, GROUP, LINE, IMAGE, METADATA, POLYGON, RECT, TEXT, TITLE, TSPAN };
82DRAIN_ENUM_OSTREAM(image::svg::tag_t)
116 return (*
this == 0.0);
120 void toStream(std::ostream & ostr)
const override {
130std::ostream & operator<<(std::ostream & ostr,
Transform<N> & tr){
145 return (
rotate.empty() && scale.empty() && translate.empty() && matrix.empty()) ;
149 void setTranslate(
const svg::coord_t & x,
const svg::coord_t & y){
155 void setTranslateX(
const svg::coord_t & x){
162 void setTranslateY(
const svg::coord_t & y){
186 void toStream(std::ostream & ostr)
const;
217 NodeSVG(svg::tag_t t = svg::UNDEFINED);
230 svg::tag_t::METADATA,
270 void setAttribute(
const std::string & key,
const std::string &value)
override;
274 void setAttribute(
const std::string & key,
const char *value)
override;
292 template <
typename T>
301 template <
typename T>
312 template <
typename T>
315 box.setLocation(x, y);
318 template <
typename T>
321 box.width = frame.width;
322 box.height = frame.height;
329 template <
typename T>
340 template <
typename T>
347 svg::coord_t getWidth(){
355 template <
typename T>
358 link(
"data-margin", box.width);
376 template <
typename T>
379 if (typeIs(svg::TEXT)){
380 link(
"data-height", box.height);
386 svg::coord_t getHeight(){
391 void setFontSize(svg::coord_t size, svg::coord_t elemHeight = 0.0);
413 void handleType(
const svg::tag_t & t)
override final;
416 void updateAlign()
override;
440std::ostream & operator<<(std::ostream &ostr,
const image::NodeSVG & node){
441 return node.nodeToStream(ostr);
449std::ostream & operator<<(std::ostream &ostr,
const drain::image::TreeSVG & tree){
464const NodeXML<image::svg::tag_t>::xml_default_elem_map_t NodeXML<image::svg::tag_t>::xml_default_elems;
481image::TreeSVG & image::TreeSVG::operator=(
const std::string & arg){
489image::TreeSVG & image::TreeSVG::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
497image::TreeSVG & image::TreeSVG::operator=(
const T & arg){
509image::TreeSVG & image::TreeSVG::operator()(
const image::svg::tag_t & type){
516image::TreeSVG & image::TreeSVG::operator[](
const image::svg::tag_t & type);
520const image::TreeSVG & image::TreeSVG::operator[](
const image::svg::tag_t & type)
const ;
525image::TreeSVG & image::TreeSVG::addChild(
const image::TreeSVG::key_t & key){
532bool image::TreeSVG::hasChild(
const image::svg::tag_t & type)
const;
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
Something that has width and height.
Definition Frame.h:53
static std::ostream & docToStream(std::ostream &ostr, const V &tree)
Definition TreeXML.h:733
ref_t & link(const std::string &key, F &x)
Associates a map entry with a variable.
Definition ReferenceMap.h:84
Currently used only as CSS element selector.
Definition SelectorXML.h:50
virtual void toStreamFormatted(std::ostream &ostr, char separator=',') const
Definition TupleBase.h:331
Tuple of N elements of type T.
Definition UniTuple.h:65
static TX & xmlAssignString(TX &tree, const std::string &s)
When assigning a string, create new element unless the element itself is of type CTEXT.
Definition XML.h:618
static TX & xmlSetType(TX &tree, const typename TX::node_data_t::xml_tag_t &type)
Definition XML.h:679
static T & xmlAddChild(T &tree, const std::string &key)
Definition XML.h:692
static X & xmlAssignNode(X &dst, const X &src)
Assign another tree structure to another.
Definition XML.h:554
static TX & xmlAssign(TX &dst, const TX &src)
Assign another tree structure to another.
Definition XML.h:513
virtual void handleType(const svg::tag_t &t) override final
Definition TreeSVG.cpp:190
void setBoundingBox(const drain::Box< T > &b)
Set position (x,y), width and height of an object.
Definition TreeSVG.h:294
void setLocation(const T &x, const T &y)
Definition TreeSVG.h:314
virtual void setAttribute(const std::string &key, const std::string &value) override
Set attribute value, handling units in string arguments, like in "50%" or "640px".
Definition TreeSVG.cpp:288
const BBoxSVG & getBoundingBox() const
Get position (x,y), width and height of an object.
Definition TreeSVG.h:280
NodeSVG & operator=(const NodeSVG &node)
Copy data from a node. (Does not copy subtree.)
Definition TreeSVG.h:246
static std::string xlink
In opening SVG tag, referred to by attribute "xmlns:xlink".
Definition TreeSVG.h:206
void setMargin(T w)
Set margin of a TEXT element (non-standard).
Definition TreeSVG.h:357
void setWidth(T w)
Definition TreeSVG.h:342
NodeSVG & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition TreeSVG.h:253
virtual void specificAttributesToStream(std::ostream &ostr) const override
Write transform, in addition to XML::ClassList.
Definition TreeSVG.cpp:358
svg::coord_t getMargin()
Get margin of a TEXT element (non-standard).
Definition TreeSVG.h:367
void setFontSize(svg::coord_t size, svg::coord_t elemHeight=0.0)
Sets font size and also text elem "height".
Definition TreeSVG.cpp:297
void setHeight(T h)
Definition TreeSVG.h:378
virtual bool isSingular() const override final
If true, render always as single elem (without child elems)
Definition TreeSVG.h:239
void setLocation(const drain::Point2D< T > &point)
Set position (x,y) of an object.
Definition TreeSVG.h:303
BBoxSVG & getBoundingBox()
Get position (x,y), width and height of an object.
Definition TreeSVG.h:287
void setFrame(const T &w, const T &h)
Definition TreeSVG.h:331
static std::string svg
In opening SVG tag, referred to by attributes "xmlns" and "xmlns:svg".
Definition TreeSVG.h:210
Definition DataSelector.cpp:1277
DRAIN_TYPENAME(void)
Add a specialization for each type of those you want to support.
Something that has coordinates (x,y) and dimensions (width, height).
Definition Frame.h:160
Wrapper for unique (static) dictionary of enum values.
Definition EnumFlags.h:66
Adapter designed for NodeSVG.
Definition AlignSVG.h:787