Start cleaning icon.
This commit is contained in:
parent
97afa782a0
commit
3915a40c96
10 changed files with 172 additions and 33 deletions
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
void setName(const std::string& name);
|
||||
|
||||
void setLocation(const Point& loc);
|
||||
virtual void setLocation(const Point& loc);
|
||||
|
||||
virtual void update(SceneInfo* sceneInfo);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
PathNode::PathNode(const Point& loc, const std::string& psPath)
|
||||
: GeometryNode(loc),
|
||||
mPathString(psPath)
|
||||
mPathString(psPath)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "SvgShapeElements.h"
|
||||
|
||||
SvgNode::SvgNode(const Point& location)
|
||||
: AbstractVisualNode(location)
|
||||
: MaterialNode(location)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,25 @@ void SvgNode::setContent(std::unique_ptr<SvgDocument> doc)
|
|||
mContentDirty = true;
|
||||
|
||||
mChildren.clear();
|
||||
mManagedChildren.clear();
|
||||
mGeometryNodes.clear();
|
||||
}
|
||||
|
||||
void SvgNode::setWidth(unsigned width)
|
||||
{
|
||||
if (mWidth != width)
|
||||
{
|
||||
mWidth = width;
|
||||
mTransformIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SvgNode::setHeight(unsigned height)
|
||||
{
|
||||
if (mHeight != height)
|
||||
{
|
||||
mHeight = height;
|
||||
mTransformIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SvgNode::updateTransform()
|
||||
|
@ -37,25 +55,23 @@ void SvgNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
|||
|
||||
for (const auto& svg_element : mContent->getRoot()->getChildren())
|
||||
{
|
||||
std::unique_ptr<AbstractVisualNode> node;
|
||||
std::unique_ptr<GeometryNode> geom_node;
|
||||
|
||||
if (svg_element->getTagName() == "circle")
|
||||
{
|
||||
onCircle(svg_element.get(), node);
|
||||
onCircle(svg_element.get(), geom_node);
|
||||
}
|
||||
else if (svg_element->getTagName() == "path")
|
||||
{
|
||||
onPath(svg_element.get(), node);
|
||||
onPath(svg_element.get(), geom_node);
|
||||
}
|
||||
|
||||
if (!node)
|
||||
AbstractVisualNode* raw_node{ nullptr };
|
||||
if (geom_node)
|
||||
{
|
||||
continue;
|
||||
raw_node = geom_node.get();
|
||||
mGeometryNodes.push_back(std::move(geom_node));
|
||||
}
|
||||
|
||||
auto raw_node = node.get();
|
||||
mManagedChildren.push_back(std::move(node));
|
||||
|
||||
addChild(raw_node);
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +89,43 @@ void SvgNode::update(SceneInfo* sceneInfo)
|
|||
updateTransform();
|
||||
mTransformIsDirty = false;
|
||||
}
|
||||
|
||||
if (mMaterialIsDirty)
|
||||
{
|
||||
if (mHasFillColor)
|
||||
{
|
||||
for (const auto& geom_node : mGeometryNodes)
|
||||
{
|
||||
geom_node->setFillColor(mFillColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& geom_node : mGeometryNodes)
|
||||
{
|
||||
geom_node->setHasFillColor(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mHasStrokeColor)
|
||||
{
|
||||
for (const auto& geom_node : mGeometryNodes)
|
||||
{
|
||||
geom_node->setStrokeColor(mStrokeColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& geom_node : mGeometryNodes)
|
||||
{
|
||||
geom_node->setHasStrokeColor(false);
|
||||
}
|
||||
}
|
||||
mMaterialIsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SvgNode::onCircle(XmlElement* element, std::unique_ptr<AbstractVisualNode>& node)
|
||||
void SvgNode::onCircle(XmlElement* element, std::unique_ptr<GeometryNode>& node)
|
||||
{
|
||||
auto svg_circle = dynamic_cast<SvgCircle*>(element);
|
||||
auto loc = svg_circle->getLocation();
|
||||
|
@ -100,7 +150,7 @@ void SvgNode::onCircle(XmlElement* element, std::unique_ptr<AbstractVisualNode>&
|
|||
node = std::move(circle_node);
|
||||
}
|
||||
|
||||
void SvgNode::onPath(XmlElement* element, std::unique_ptr<AbstractVisualNode>& node)
|
||||
void SvgNode::onPath(XmlElement* element, std::unique_ptr<GeometryNode>& node)
|
||||
{
|
||||
auto svg_path = dynamic_cast<SvgPath*>(element);
|
||||
|
||||
|
|
|
@ -1,28 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractVisualNode.h"
|
||||
#include "MaterialNode.h"
|
||||
#include "GeometryNode.h"
|
||||
#include "SvgDocument.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class SvgNode : public AbstractVisualNode
|
||||
class SvgNode : public MaterialNode
|
||||
{
|
||||
public:
|
||||
SvgNode(const Point& location);
|
||||
|
||||
void setContent(std::unique_ptr<SvgDocument> doc);
|
||||
|
||||
void setWidth(unsigned width);
|
||||
void setHeight(unsigned height);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
void updateTransform();
|
||||
|
||||
void onCircle(XmlElement* element, std::unique_ptr<AbstractVisualNode>& node);
|
||||
void onPath(XmlElement* element, std::unique_ptr<AbstractVisualNode>& node);
|
||||
void onCircle(XmlElement* element, std::unique_ptr<GeometryNode>& node);
|
||||
void onPath(XmlElement* element, std::unique_ptr<GeometryNode>& node);
|
||||
|
||||
unsigned mWidth{ 0 };
|
||||
unsigned mHeight{ 0 };
|
||||
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::vector<std::unique_ptr<AbstractVisualNode> > mManagedChildren;
|
||||
std::vector<std::unique_ptr<GeometryNode> > mGeometryNodes;
|
||||
std::unique_ptr<SvgDocument> mContent;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue