38 #ifndef DRAIN_TREE_SVG
39 #define DRAIN_TREE_SVG
41 #include "drain/util/EnumFlags.h"
42 #include "drain/util/FileInfo.h"
43 #include "drain/util/Frame.h"
44 #include "drain/util/TreeXML.h"
53 typedef drain::UnorderedMultiTree<NodeSVG,false, NodeXML<>::path_t> TreeSVG;
57 typedef float coord_t;
60 UNDEFINED=XML::UNDEFINED,
65 STYLE_SELECT=XML::STYLE_SELECT,
67 CIRCLE, DESC, GROUP, LINE, IMAGE, METADATA, POLYGON, RECT, TEXT, TITLE, TSPAN };
81 DRAIN_ENUM_OSTREAM(image::svg::tag_t)
115 return (*
this == 0.0);
119 void toStream(std::ostream & ostr)
const {
129 std::ostream & operator<<(std::ostream & ostr,
Transform<N> & tr){
144 return (
rotate.empty() && scale.empty() && translate.empty() && matrix.empty()) ;
148 void setTranslate(
const svg::coord_t & x,
const svg::coord_t & y){
154 void setTranslateX(
const svg::coord_t & x){
161 void setTranslateY(
const svg::coord_t & y){
185 void toStream(std::ostream & ostr)
const;
216 NodeSVG(svg::tag_t t = svg::UNDEFINED);
229 svg::tag_t::METADATA,
269 void setAttribute(
const std::string & key,
const std::string &value)
override;
273 void setAttribute(
const std::string & key,
const char *value)
override;
291 template <
typename T>
300 template <
typename T>
311 template <
typename T>
314 box.setLocation(x, y);
317 template <
typename T>
320 box.width = frame.width;
321 box.height = frame.height;
328 template <
typename T>
339 template <
typename T>
346 svg::coord_t getWidth(){
354 template <
typename T>
357 link(
"data-margin", box.width);
375 template <
typename T>
378 if (typeIs(svg::TEXT)){
379 link(
"data-height", box.height);
385 svg::coord_t getHeight(){
390 void setFontSize(svg::coord_t size, svg::coord_t elemHeight = 0.0);
412 void handleType(
const svg::tag_t & t)
override final;
415 void updateAlign()
override;
439 std::ostream & operator<<(std::ostream &ostr,
const image::NodeSVG & node){
440 return node.nodeToStream(ostr);
448 std::ostream & operator<<(std::ostream &ostr,
const drain::image::TreeSVG & tree){
458 DRAIN_TYPENAME(image::NodeSVG);
459 DRAIN_TYPENAME(image::svg::tag_t);
463 const NodeXML<image::svg::tag_t>::xml_default_elem_map_t NodeXML<image::svg::tag_t>::xml_default_elems;
483 image::TreeSVG & image::TreeSVG::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
491 image::TreeSVG & image::TreeSVG::operator=(
const T & arg){
503 image::TreeSVG & image::TreeSVG::operator()(
const image::svg::tag_t & type){
509 image::TreeSVG & image::TreeSVG::addChild(
const image::TreeSVG::key_t & key){
539 bool image::TreeSVG::hasChild(
const image::svg::tag_t & type)
const;
544 image::TreeSVG & image::TreeSVG::operator[](
const image::svg::tag_t & type);
548 const image::TreeSVG & image::TreeSVG::operator[](
const image::svg::tag_t & type)
const ;
Two-way mapping between strings and objects of template class T.
Definition: Dictionary.h:63
Definition: FileInfo.h:48
Something that has width and height.
Definition: Frame.h:53
Definition: TreeXML.h:341
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
Definition: TreeXML.h:777
virtual std::ostream & toStream(std::ostream &ostr, char separator=',') const
Definition: TupleBase.h:331
Tuple of N elements of type T.
Definition: UniTuple.h:65
static X & xmlAssignNode(X &dst, const X &src)
Assign another tree structure to another.
Definition: XML.h:497
static TX & xmlSetType(TX &tree, const typename TX::node_data_t::xml_tag_t &type)
Definition: XML.h:559
static T & xmlAddChild(T &tree, const std::string &key)
Definition: XML.h:573
static TX & xmlAssign(TX &dst, const TX &src)
Assign another tree structure to another.
Definition: XML.h:458
Definition: TreeSVG.h:200
virtual void handleType(const svg::tag_t &t) override final
Definition: TreeSVG.cpp:206
void setBoundingBox(const drain::Box< T > &b)
Set position (x,y), width and height of an object.
Definition: TreeSVG.h:293
BBoxSVG & getBoundingBox()
Get position (x,y), width and height of an object.
Definition: TreeSVG.h:286
void setLocation(const T &x, const T &y)
Definition: TreeSVG.h:313
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:303
static std::string xlink
In opening SVG tag, referred to by attribute "xmlns:xlink".
Definition: TreeSVG.h:205
NodeSVG(svg::tag_t t=svg::UNDEFINED)
Default constructor. Create a node of given type.
Definition: TreeSVG.cpp:181
void setMargin(T w)
Set margin of a TEXT element (non-standard).
Definition: TreeSVG.h:356
void setWidth(T w)
Definition: TreeSVG.h:341
NodeSVG & operator=(const NodeSVG &node)
Copy data from a node. (Does not copy subtree.)
Definition: TreeSVG.h:238
virtual void specificAttributesToStream(std::ostream &ostr) const override
Write transform, in addition to XML::ClassList.
Definition: TreeSVG.cpp:373
const BBoxSVG & getBoundingBox() const
Get position (x,y), width and height of an object.
Definition: TreeSVG.h:279
svg::coord_t getMargin()
Get margin of a TEXT element (non-standard).
Definition: TreeSVG.h:366
void setFontSize(svg::coord_t size, svg::coord_t elemHeight=0.0)
Sets font size and also text elem "height".
Definition: TreeSVG.cpp:312
void setHeight(T h)
Definition: TreeSVG.h:377
NodeSVG & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition: TreeSVG.h:252
void setLocation(const drain::Point2D< T > &point)
Set position (x,y) of an object.
Definition: TreeSVG.h:302
void setFrame(const T &w, const T &h)
Definition: TreeSVG.h:330
static std::string svg
In opening SVG tag, referred to by attributes "xmlns" and "xmlns:svg".
Definition: TreeSVG.h:209
Definition: DataSelector.cpp:1277
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