Start cleaning geometry module.

This commit is contained in:
jmsgrogan 2023-01-13 11:47:48 +00:00
parent 26ecae46b3
commit cd688f608f
52 changed files with 493 additions and 277 deletions

View file

@ -2,8 +2,9 @@
#include <sstream>
SvgCircle::SvgCircle()
: SvgShapeElement("circle")
SvgCircle::SvgCircle(Type type)
: SvgShapeElement(type == Type::REGULAR ? "circle" : "ellipse"),
mType(type)
{
}
@ -22,7 +23,23 @@ void SvgCircle::setLocation(const Point& loc)
void SvgCircle::setRadius(double rad)
{
auto r = std::make_unique<XmlAttribute>("r");
if (mType == Type::REGULAR)
{
auto r = std::make_unique<XmlAttribute>("r");
r->setValue(std::to_string(rad));
addAttribute(std::move(r));
}
else
{
auto r = std::make_unique<XmlAttribute>("rx");
r->setValue(std::to_string(rad));
addAttribute(std::move(r));
}
}
void SvgCircle::setMinorRadius(double rad)
{
auto r = std::make_unique<XmlAttribute>("ry");
r->setValue(std::to_string(rad));
addAttribute(std::move(r));
}

View file

@ -8,11 +8,21 @@
class SvgCircle : public SvgShapeElement
{
public:
SvgCircle();
enum class Type
{
REGULAR,
ELLIPSE
};
SvgCircle(Type type = Type::REGULAR);
void setLocation(const Point& loc);
void setRadius(double rad);
void setMinorRadius(double rad);
private:
Type mType{ Type::REGULAR };
};
class SvgRectangle : public SvgShapeElement