Improve node to svg conversion.

This commit is contained in:
jmsgrogan 2023-01-12 17:45:06 +00:00
parent 64f0b3e77a
commit 26ecae46b3
22 changed files with 403 additions and 126 deletions

View file

@ -8,19 +8,19 @@ SvgCircle::SvgCircle()
}
void SvgCircle::setLocation(const DiscretePoint& loc)
void SvgCircle::setLocation(const Point& loc)
{
auto cx = std::make_unique<XmlAttribute>("cx");
auto cy = std::make_unique<XmlAttribute>("cy");
cx->setValue(std::to_string(loc.GetX()));
cy->setValue(std::to_string(loc.GetY()));
cx->setValue(std::to_string(loc.getX()));
cy->setValue(std::to_string(loc.getY()));
addAttribute(std::move(cx));
addAttribute(std::move(cy));
}
void SvgCircle::setRadius(unsigned rad)
void SvgCircle::setRadius(double rad)
{
auto r = std::make_unique<XmlAttribute>("r");
r->setValue(std::to_string(rad));
@ -33,19 +33,19 @@ SvgRectangle::SvgRectangle()
}
void SvgRectangle::setLocation(const DiscretePoint& loc)
void SvgRectangle::setLocation(const Point& loc)
{
auto x = std::make_unique<XmlAttribute>("x");
auto y = std::make_unique<XmlAttribute>("y");
x->setValue(std::to_string(loc.GetX()));
y->setValue(std::to_string(loc.GetY()));
x->setValue(std::to_string(loc.getX()));
y->setValue(std::to_string(loc.getY()));
addAttribute(std::move(x));
addAttribute(std::move(y));
}
void SvgRectangle::setWidth(unsigned w)
void SvgRectangle::setWidth(double w)
{
auto width = std::make_unique<XmlAttribute>("width");
@ -54,7 +54,7 @@ void SvgRectangle::setWidth(unsigned w)
addAttribute(std::move(width));
}
void SvgRectangle::setHeight(unsigned h)
void SvgRectangle::setHeight(double h)
{
auto height = std::make_unique<XmlAttribute>("height");
@ -70,14 +70,14 @@ SvgPolygon::SvgPolygon()
}
void SvgPolygon::setPoints(const std::vector<DiscretePoint>& locs)
void SvgPolygon::setPoints(const std::vector<Point>& locs)
{
auto points = std::make_unique<XmlAttribute>("points");
std::stringstream sstr;
for (const auto& loc : locs)
{
sstr << loc.GetX() << "," << loc.GetY() << " ";
sstr << loc.getX() << "," << loc.getY() << " ";
}
points->setValue(sstr.str());
addAttribute(std::move(points));
@ -91,14 +91,14 @@ SvgPolyline::SvgPolyline()
addAttribute(std::move(fill));
}
void SvgPolyline::setPoints(const std::vector<DiscretePoint>& locs)
void SvgPolyline::setPoints(const std::vector<Point>& locs)
{
auto points = std::make_unique<XmlAttribute>("points");
std::stringstream sstr;
for (const auto& loc : locs)
{
sstr << loc.GetX() << "," << loc.GetY() << " ";
sstr << loc.getX() << "," << loc.getY() << " ";
}
points->setValue(sstr.str());
addAttribute(std::move(points));