TreeSVG-example.cpp

A node for TreeXML

/*
Copyright 2001 - 2017 Markus Peura, Finnish Meteorological Institute (First.Last@fmi.fi)
This file is part of Rack for C++.
Rack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
Rack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.
You should have received a copy of the GNU General Public License
along with Rack. If not, see <http://www.gnu.org/licenses/>.
*/
/*
REQUIRE: drain/{Caster,Castable,Log,FlexibleVariable,RegExp,Reference,Sprinter,String,TextStyle,Type,TypeUtils,Variable,VariableBase}.cpp
REQUIRE: drain/util/{FileInfo,TreeXML}.cpp
REQUIRE: drain/image/TreeSVG.cpp
g ++ -I. drain/examples/TreeSVG-example.cpp drain/util/{Log,Caster,Castable,JSONwriter,RegExp,String,TreeXML,Type}.cpp drain/image/TreeSVG.cpp -o TreeSVG-example
*/
#include <iostream>
#include "drain/Type.h"
#include "drain/util/TreeXML.h"
#include "drain/image/TreeSVG.h"
using namespace std;
using namespace drain;
using namespace drain::image;
template <class T>
class Parameter {
public:
inline
inline
Parameter<T> & setUnit(const std::string & s){
unit = s;
return *this;
};
/* Consider:
virtual
const std::string & getName() const = 0;
virtual
const std::string & getDescription() const = 0;
*/
inline
const std::string & getUnit(){
return unit;
};
protected:
std::string unit;
};
/*
void fct(drain::image::NodeSVG & node, const std::initializer_list<Variable::init_pair_t > &l){
drain::FlexVariableMap m;
drain::SmartMapTools::setValues(m, l);
std::cout << m << '\n';
node.set(l);
}
*/
//
int main(int argc, char **argv){
std::cout << drain::TypeName<NodeSVG>::str() << '/' << drain::TypeName<NodeSVG>::str() << " demo \n";
/*
if (argc==1){
cerr << "Usage: " << argv[0] << " <keychars> <sample-string> <key>=<value> <key2>=<value2> ..." << endl;
cerr << "Example: " << argv[0] << " '[a-zA-Z0-9]+' 'Hello, ${e} and ${pi}! My name is ${x}.' e=world x=test" << endl;
return 1;
}
*/
/*
*
TreeSVG svg0;
Periaatteessa näin. Jos noden voi
svg0 = {
{"width", 100},
{"heigh", 100},
};
cout << svg0;
*/
TreeSVG svg(NodeSVG::SVG);
// svg(NodeSVG::SVG)->set("width", 100);//
svg->set("height", 200);
/*
= {
{"width", 100},
{"height", 200}
};
*/
//svg->set("width", 100);
//svg->set("height", 200);
svg.data = {
{"height", 222},
{"width","111"},
{"MAMBO", false}
};
// svg = {{"height", 333}, {"width", "444"}, {"BIMBO", true}}; (under construction... template problems)
svg["first"](NodeSVG::GROUP)->set("name", "mainGroup");
svg["first"]->setStyle("fill", "red 2px");
svg["first"]->setStyle("scale", 0.5);
svg["first"]->setStyle("opacity", 0.33);
//svg["first"]["r"]
svg["first"]["r"](NodeSVG::RECT) = "Dependent ctext.";
svg["first"]["r"]->set("width", 10);
svg["first"]["r"]->set("height", 20);
svg["first"]["t"](NodeSVG::TEXT) = "Explanation... free ctext.";
//svg["first"]["t"]->set("style", "fill:lightgreen");
//svg["first"]["t"]->ctext = "Explanation";
svg["first"]["t"]->set("x ", 15);
svg["first"]["t"]->set("y", 25);
svg["first"]["t"]->set("depth", 30); // FLEXIBLE
// cout << "Starter" << std::endl;
TreeSVG::path_t p("koe/mika/sika");
svg(p);
svg("toka/poka/joka");
cout << svg;
/*
TreeSVG svg2;
svg->set("test", "test1");
svg2 = svg;
cout << "Copy" << std::endl;
cout << svg2;
svg2->set("test", "test2");
cout << svg;
//svg.d
*/
return 0;
}
Definition: TreeSVG-example.cpp:46
static bool dump(const TR &tree, std::ostream &ostr=std::cout, bool(*callBack)(const typename TR::node_data_t &, std::ostream &)=TreeUtils::dataDumper, const std::string &indent="")
Render a tree using character graphics.
Definition: TreeUtils.h:192
Namespace for images and image processing tools.
Definition: AccumulationArray.cpp:45
Definition: DataSelector.cpp:1277
Definition: Type.h:542