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,
248 setType(node.getType());
275 void setAttribute(
const std::string & key,
const std::string &value)
override;
279 void setAttribute(
const std::string & key,
const char *value)
override;
297 template <
typename T>
306 template <
typename T>
317 template <
typename T>
320 box.setLocation(x, y);
323 template <
typename T>
326 box.width = frame.width;
327 box.height = frame.height;
334 template <
typename T>
345 template <
typename T>
352 svg::coord_t getWidth(){
360 template <
typename T>
363 link(
"data-margin", box.width);
381 template <
typename T>
384 if (typeIs(svg::TEXT)){
385 link(
"data-height", box.height);
391 svg::coord_t getHeight(){
396 void setFontSize(svg::coord_t size, svg::coord_t elemHeight = 0.0);
414 void handleType() override final;
418 void updateAlign() override;
443std::ostream & operator<<(std::ostream &ostr, const image::
NodeSVG & node){
444 return node.nodeToStream(ostr);
470 Elem(
image::NodeSVG & node) : x(node[
"x"]), y(node[
"y"]), width(node[
"width"]), height(node[
"height"]){
471 node.setType(image::svg::tag_t::RECT);
489 node.setType(image::svg::tag_t::CIRCLE);
512std::ostream & operator<<(std::ostream &ostr,
const drain::image::TreeSVG & tree){
522DRAIN_TYPENAME(image::NodeSVG);
523DRAIN_TYPENAME(image::svg::tag_t);
527const NodeXML<image::svg::tag_t>::xml_default_elem_map_t NodeXML<image::svg::tag_t>::xml_default_elems;
544image::TreeSVG & image::TreeSVG::operator=(
const std::string & arg){
545 XML::xmlAssignString(*
this, arg);
552image::TreeSVG & image::TreeSVG::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
554 return XML::xmlAssign(*
this, l);
560image::TreeSVG & image::TreeSVG::operator=(
const T & arg){
561 return XML::xmlAssign(*
this, arg);
579image::TreeSVG & image::TreeSVG::operator()(
const image::svg::tag_t & type);
590image::TreeSVG & image::TreeSVG::operator[](
const image::svg::tag_t & type);
595const image::TreeSVG & image::TreeSVG::operator[](
const image::svg::tag_t & type)
const ;
600image::TreeSVG & image::TreeSVG::addChild(
const image::TreeSVG::key_t & key){
601 return XML::xmlAddChild(*
this, key);
607bool 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
friend class Elem
Provides access to ReferenceMap2 of XML elements, to link FlexibleVariables.
Definition TreeXML.h:106
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
VariableT is a final class applied through typedefs Variable, Reference and FlexibleVariable.
Definition VariableT.h:87
bool typeIsSet() const
Return true, if type is any of the arguments.
Definition XML.h:144
static N & xmlAssignNode(N &dst, const N &src)
Assign tree node (data) to another.
Definition XML.h:654
void setBoundingBox(const drain::Box< T > &b)
Set position (x,y), width and height of an object.
Definition TreeSVG.h:299
void setLocation(const T &x, const T &y)
Definition TreeSVG.h:319
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:240
const BBoxSVG & getBoundingBox() const
Get position (x,y), width and height of an object.
Definition TreeSVG.h:285
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:362
void setWidth(T w)
Definition TreeSVG.h:347
NodeSVG & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition TreeSVG.h:258
virtual void specificAttributesToStream(std::ostream &ostr) const override
Write transform, in addition to XML::ClassList.
Definition TreeSVG.cpp:310
svg::coord_t getMargin()
Get margin of a TEXT element (non-standard).
Definition TreeSVG.h:372
void setFontSize(svg::coord_t size, svg::coord_t elemHeight=0.0)
Sets font size and also text elem "height".
Definition TreeSVG.cpp:249
void setHeight(T h)
Definition TreeSVG.h:383
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:308
BBoxSVG & getBoundingBox()
Get position (x,y), width and height of an object.
Definition TreeSVG.h:292
void setFrame(const T &w, const T &h)
Definition TreeSVG.h:336
static std::string svg
In opening SVG tag, referred to by attributes "xmlns" and "xmlns:svg".
Definition TreeSVG.h:210
Definition DataSelector.cpp:1277
Something that has coordinates (x,y) and dimensions (width, height).
Definition Frame.h:160
A container for a static dictionary of enumeration values.
Definition EnumFlags.h:69
Adapter designed for NodeSVG.
Definition AlignSVG.h:730