41#include <drain/Enum.h>
42#include <drain/image/AlignAnchorSVG.h>
43#include "drain/util/FileInfo.h"
44#include "drain/util/Frame.h"
45#include "drain/util/SelectorXML.h"
46#include "drain/util/TreeXML.h"
47#include "drain/util/UtilsXML.h"
50#include "TransformSVG.h"
87 ALL = ON|(PNG|SVG|TXT),
94 int radialBezierResolution;
103 std::string DEBUG_ALIGN;
109DRAIN_ENUM_DICT(image::FileSVG::IncludePolicy);
110DRAIN_ENUM_DICT(image::FileSVG::PathPolicy);
115DRAIN_ENUM_OSTREAM(image::FileSVG::IncludePolicy)
116DRAIN_ENUM_OSTREAM(image::FileSVG::PathPolicy)
122typedef DRAIN_XML_TREE(
NodeSVG) TreeSVG;
138 typedef svg::tag_t tag_t;
150 NodeSVG(svg::tag_t t = svg::UNDEFINED);
159 bool isAbstract()
const {
161 svg::tag_t::UNDEFINED,
164 svg::tag_t::CLIP_PATH,
167 svg::tag_t::METADATA,
222 void setAttribute(const std::string & key, const char *value) override;
240 template <
typename T>
251 return box.getFrame();
257 return box.getFrame();
262 return box.getLocation();
267 return box.getLocation();
270 template <
typename T>
273 setViewBox(bb.x, bb.y, bb.width, bb.height);
276 template <
typename T>
278 void setViewBox(T & x, T & y, T & width, T & height){
283 template <
typename T>
294 template <
typename T>
297 box.setLocation(x, y);
300 template <
typename T>
303 box.width = frame.width;
304 box.height = frame.height;
311 template <
typename T>
322 template <
typename T>
329 svg::coord_t getWidth()
const {
337 template <
typename T>
342 setUserAttribute(
"margin", w);
353 return getUserAttribute(
"margin");
361 template <
typename T>
365 getMap()[
"data-height"].link(box.height);
371 svg::coord_t getHeight()
const {
376 void setFontSize(svg::coord_t size, svg::coord_t elemHeight = 0.0);
396 void handleType() override final;
400 void updateAlign() override;
406 void setAlignClass(
AlignClass cls) override final {
432 std::stringstream sstr;
433 sstr <<
"<" << node.
getTag();
434 if (::atoi(node.
getId().c_str())==0){
435 sstr <<
" id=" << node.
getId();
437 if (node.getName().isValid()){
438 sstr <<
" name=" << node.getName();
440 if (!node.getClasses().empty()){
441 sstr <<
" class=[" << node.getClasses() <<
']';
447 const std::string & str()
const {
485std::ostream &
operator<<(std::ostream &ostr,
const drain::image::TreeSVG & tree){
486 return drain::image::NodeSVG::docToStream(ostr, tree);
493DRAIN_TYPENAME(image::NodeSVG);
494DRAIN_TYPENAME(image::svg::tag_t);
513image::TreeSVG & image::TreeSVG::operator=(
const std::string & arg){
521image::TreeSVG & image::TreeSVG::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
528image::TreeSVG & image::TreeSVG::operator=(
const T & arg){
544DRAIN_XML_EASY_TYPE(image::TreeSVG)
546DRAIN_GETKEY_ENUM(image::TreeSVG, image::svg::tag_t)
552const image::TreeSVG::key_t & image::TreeSVG::getKey(
const ClassXML & cls){
555 return (
const std::string &)cls;
563 return (
const std::string &)sel;
568DRAIN_XML_DEFAULT_ELEMS(image::TreeSVG);
574DRAIN_XML_DEFAULT_INIT(image::TreeSVG)
578void image::TreeSVG::swapData(image::NodeSVG & node);
589image::TreeSVG & image::TreeSVG::addChild(
const image::svg::tag_t & type);
Something that has width and height.
Definition Frame.h:53
virtual std::ostream & nodeToStream(std::ostream &ostr, tag_display_mode mode=EMPTY_TAG) const override
Dumps info. Future option: outputs leading and ending tag.
Definition TreeXML.h:412
virtual const std::string & getTag() const override
Default implementation of tag name retrieval based on drain::Enum<t>.
Definition TreeXML.h:140
Definition SelectorXML.h:75
Definition StringBuilder.h:58
static T & assign(T &dst, const T &src)
Assign another tree structure to another.
Definition UtilsXML.h:108
static TX & assignString(TX &tree, const std::string &s)
When assigning a string, create new element unless the element itself is of type CTEXT.
Definition UtilsXML.h:183
bool typeIs(const T2 &arg, const T3... args) const
Return true, if type is any of the arguments.
Definition XML.h:230
bool typeIsSet() const
Return true, if type is any of the arguments.
Definition XML.h:220
const std::string & getId() const
Returns ID of this element. Hopefully a unique ID...
Definition XML.h:286
void setType(const T &t)
Definition XML.h:200
static N & xmlAssignNode(N &dst, const N &src)
Assign tree node (data) to another.
Definition XML.h:887
DOC: Add class description.
Definition TreeSVG.h:64
DOC: Add class description.
Definition TreeSVG.h:426
void setBoundingBox(const drain::Box< T > &b)
Set position (x,y), width and height of an object.
Definition TreeSVG.h:242
void setLocation(const T &x, const T &y)
Definition TreeSVG.h:296
const BBoxSVG & getBoundingBox() const
Set attribute value, handling units in string arguments, like in "50%" or "640px".
Definition TreeSVG.h:228
NodeSVG & operator=(const NodeSVG &node)
Copy data from a node. (Does not copy subtree.)
Definition TreeSVG.h:183
static std::string xlink
In opening SVG tag, referred to by attribute "xmlns:xlink".
Definition TreeSVG.h:142
void setMargin(T w)
Set margin of a TEXT element (non-standard).
Definition TreeSVG.h:339
svg::coord_t getMargin() const
Get margin of a TEXT element (non-standard).
Definition TreeSVG.h:350
void setWidth(T w)
Definition TreeSVG.h:324
NodeSVG & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition TreeSVG.h:195
virtual void specificAttributesToStream(std::ostream &ostr) const override
Write transform, in addition to XML::ClassList.
Definition TreeSVG.cpp:315
Frame2D< svg::coord_t > & getGeometry()
Get location (x,y) and geometry (width,height) of an object.
Definition TreeSVG.h:256
void swapDataSVG(NodeSVG &node)
Swaps XML properties and also alignment, anchors etc.
Definition TreeSVG.cpp:250
void setFontSize(svg::coord_t size, svg::coord_t elemHeight=0.0)
Sets font size and also text elem "height".
Definition TreeSVG.cpp:217
const Frame2D< svg::coord_t > & getGeometry() const
Get location (x,y) and geometry (width,height) of an object.
Definition TreeSVG.h:250
void setHeight(T h)
Definition TreeSVG.h:363
virtual bool isSingular() const override final
If true, render always as single elem (without child elems)
Definition TreeSVG.h:176
void setLocation(const drain::Point2D< T > &point)
Set position (x,y) of an object.
Definition TreeSVG.h:285
BBoxSVG & getBoundingBox()
Get location (x,y) and geometry (width,height) of an object.
Definition TreeSVG.h:235
static std::string svg_decl
In opening SVG tag, referred to by attributes "xmlns" and "xmlns:svg".
Definition TreeSVG.h:146
void setGeometry(const T &w, const T &h)
Definition TreeSVG.h:313
std::ostream & operator<<(std::ostream &ostr, const PlainData< DT > &d)
Definition Data.h:631
Something that has coordinates (x,y) and dimensions (width, height).
Definition Frame.h:225
Adapter designed for NodeSVG.
Definition AlignAnchorSVG.h:159
User-friendly programming interface for alignment considering two elements.
Definition AlignSVG.h:59
AlignClass
Moved from Layput.
Definition AlignSVG.h:117