|
|
@ -1,7 +1,27 @@ |
|
|
|
#include "svg.h" |
|
|
|
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
|
|
|
|
SvgGraph::~SvgGraph() { |
|
|
|
for (auto *object : objects) { |
|
|
|
delete object; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void SvgGraph::insert(SvgObject *obj) { |
|
|
|
objects.emplace_back(obj); |
|
|
|
} |
|
|
|
|
|
|
|
std::string SvgLine::dump() const { |
|
|
|
/// basic attributes of svg-line
|
|
|
|
|
|
|
|
return "<line />"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string SvgRect::dump() const { |
|
|
|
/// basic attribute of svg-rect
|
|
|
|
/// basic attributes of svg-rect
|
|
|
|
std::string xml = "<rect "; |
|
|
|
xml += "x=\"" + std::to_string(left) + "\" "; |
|
|
|
xml += "y=\"" + std::to_string(top) + "\" "; |
|
|
@ -27,44 +47,12 @@ std::string SvgRect::dump() const { |
|
|
|
return xml + "style=\"" + style + "\" />"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SvgGraph::~SvgGraph() { |
|
|
|
for (auto &object : objects) { |
|
|
|
delete object; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//void SvgGraph::insert(SvgObject *obj) {
|
|
|
|
// objects.emplace_back(obj);
|
|
|
|
//}
|
|
|
|
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
std::string SvgGraph::dump() const { |
|
|
|
|
|
|
|
for (auto o : objects) { |
|
|
|
std::cout << o->dump() << std::endl; |
|
|
|
std::string xml = R"(<svg xmlns="http://www.w3.org/2000/svg" version="1.1")";
|
|
|
|
xml += " width=\"" + std::to_string(width) + "\""; |
|
|
|
xml += " height=\"" + std::to_string(height) + "\">\n"; |
|
|
|
for (const auto *object : objects) { |
|
|
|
xml += " " + object->dump() + "\n"; |
|
|
|
} |
|
|
|
|
|
|
|
return "svg result"; |
|
|
|
} |
|
|
|
|
|
|
|
void SvgGraph::insert(const SvgRect &rect) { |
|
|
|
//void SvgGraph::insert(SvgRect rect) {
|
|
|
|
|
|
|
|
auto s = new SvgRect(rect); |
|
|
|
objects.emplace_back(s); |
|
|
|
} |
|
|
|
|
|
|
|
void SvgGraph::insert(const SvgLine &line) { |
|
|
|
|
|
|
|
auto l = new SvgLine(line); |
|
|
|
objects.emplace_back(l); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::string SvgLine::dump() const { |
|
|
|
|
|
|
|
return "<line />"; |
|
|
|
|
|
|
|
return xml + "</svg>\n"; |
|
|
|
} |
|
|
|