Move xml and svg to lower levels.
This commit is contained in:
parent
942cc2539c
commit
7cab70f839
32 changed files with 35 additions and 33 deletions
|
@ -15,7 +15,6 @@ list(APPEND publishing_HEADERS
|
|||
latex/LatexDocument.h
|
||||
latex/LatexMathExpression.h
|
||||
latex/LatexSymbols.h
|
||||
svg/SvgNode.h
|
||||
svg/SvgPainter.h
|
||||
DocumentConverter.h
|
||||
)
|
||||
|
@ -38,7 +37,6 @@ list(APPEND publishing_LIB_INCLUDES
|
|||
plotting/PlotNode.cpp
|
||||
plotting/EquationNode.cpp
|
||||
DocumentConverter.cpp
|
||||
svg/SvgNode.cpp
|
||||
svg/SvgPainter.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#include "SvgNode.h"
|
||||
|
||||
#include "CircleNode.h"
|
||||
|
||||
#include "SvgShapeElements.h"
|
||||
|
||||
SvgNode::SvgNode(const Point& location)
|
||||
: AbstractVisualNode(location)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SvgNode::setContent(std::unique_ptr<SvgDocument> doc)
|
||||
{
|
||||
mContent = std::move(doc);
|
||||
mContentDirty = true;
|
||||
|
||||
mChildren.clear();
|
||||
mManagedChildren.clear();
|
||||
}
|
||||
|
||||
void SvgNode::updateTransform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SvgNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (!mContent->getRoot())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto viewbox = mContent->getViewBox();
|
||||
|
||||
for (const auto& svg_element : mContent->getRoot()->getChildren())
|
||||
{
|
||||
std::unique_ptr<AbstractVisualNode> node;
|
||||
|
||||
if (svg_element->getTagName() == "circle")
|
||||
{
|
||||
auto svg_circle = dynamic_cast<SvgCircle*>(svg_element.get());
|
||||
auto loc = svg_circle->getLocation();
|
||||
auto radius = svg_circle->getRadius();
|
||||
auto minor_radius = radius;
|
||||
|
||||
if (svg_circle->getType() == SvgCircle::Type::ELLIPSE)
|
||||
{
|
||||
minor_radius = svg_circle->getMinorRadius();
|
||||
}
|
||||
|
||||
if (svg_element->hasAttribute("transform"))
|
||||
{
|
||||
const auto transform = svg_circle->getTransform();
|
||||
loc.move(transform.getLocation().getX(), transform.getLocation().getY());
|
||||
radius *= transform.getScaleX();
|
||||
minor_radius *= transform.getScaleY();
|
||||
}
|
||||
auto circle_node = std::make_unique<CircleNode>(loc, radius);
|
||||
circle_node->setMinorRadius(minor_radius);
|
||||
node = std::move(circle_node);
|
||||
}
|
||||
|
||||
if (!node)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto raw_node = node.get();
|
||||
mManagedChildren.push_back(std::move(node));
|
||||
|
||||
addChild(raw_node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SvgNode::update(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (mContent && mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
|
||||
if (mTransformIsDirty)
|
||||
{
|
||||
updateTransform();
|
||||
mTransformIsDirty = false;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractVisualNode.h"
|
||||
#include "SvgDocument.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class SvgNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
SvgNode(const Point& location);
|
||||
|
||||
void setContent(std::unique_ptr<SvgDocument> doc);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
void updateTransform();
|
||||
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::vector<std::unique_ptr<AbstractVisualNode> > mManagedChildren;
|
||||
std::unique_ptr<SvgDocument> mContent;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue