Add path rendering and svg line output.
This commit is contained in:
parent
73051a5f27
commit
6274c41a80
15 changed files with 281 additions and 79 deletions
|
@ -15,6 +15,8 @@
|
|||
#include "Circle.h"
|
||||
#include "Rectangle.h"
|
||||
#include "Path.h"
|
||||
#include "Line.h"
|
||||
#include "LineSegment.h"
|
||||
|
||||
#include "SvgShapeElements.h"
|
||||
#include "SvgTextElement.h"
|
||||
|
@ -139,6 +141,14 @@ void SvgPainter::paintPrimitive(SvgDocument* document, SceneModel* model) const
|
|||
{
|
||||
paintPath(document, model);
|
||||
}
|
||||
else if (model->getGeometry()->getType() == AbstractGeometricItem::Type::LINE)
|
||||
{
|
||||
paintLine(document, model);
|
||||
}
|
||||
else if (model->getGeometry()->getType() == AbstractGeometricItem::Type::LINE_SEGMENT)
|
||||
{
|
||||
paintLineSegment(document, model);
|
||||
}
|
||||
}
|
||||
|
||||
void SvgPainter::paintRect(SvgDocument* document, SceneModel* model) const
|
||||
|
@ -173,6 +183,25 @@ void SvgPainter::paintCircle(SvgDocument* document, SceneModel* model) const
|
|||
document->getRoot()->addChild(std::move(circle));
|
||||
}
|
||||
|
||||
void SvgPainter::paintLine(SvgDocument* document, SceneModel* model) const
|
||||
{
|
||||
auto model_line = dynamic_cast<Line*>(model->getGeometry());
|
||||
auto svg_line = std::make_unique<SvgPolyline>();
|
||||
svg_line->setPoints(model_line->getFirstPoint(), model_line->getPoints().getPoints());
|
||||
|
||||
setStyle(model, svg_line.get());
|
||||
document->getRoot()->addChild(std::move(svg_line));
|
||||
}
|
||||
|
||||
void SvgPainter::paintLineSegment(SvgDocument* document, SceneModel* model) const
|
||||
{
|
||||
auto model_line = dynamic_cast<LineSegment*>(model->getGeometry());
|
||||
auto svg_line = std::make_unique<SvgLine>(model_line->getFirstPoint(), model_line->getEndPoint());
|
||||
|
||||
setStyle(model, svg_line.get());
|
||||
document->getRoot()->addChild(std::move(svg_line));
|
||||
}
|
||||
|
||||
void SvgPainter::paintPath(SvgDocument* document, SceneModel* model) const
|
||||
{
|
||||
auto model_path = dynamic_cast<GeometryPath*>(model->getGeometry());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue