Add path rendering.
This commit is contained in:
parent
f2ab532005
commit
97afa782a0
39 changed files with 1148 additions and 131 deletions
59
src/rendering/visual_elements/nodes/PathNode.cpp
Normal file
59
src/rendering/visual_elements/nodes/PathNode.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "PathNode.h"
|
||||
|
||||
#include "Path.h"
|
||||
#include "SceneInfo.h"
|
||||
|
||||
PathNode::PathNode(const Point& loc, const std::string& psPath)
|
||||
: GeometryNode(loc),
|
||||
mPathString(psPath)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<PathNode> PathNode::Create(const Point& loc, const std::string& psPath)
|
||||
{
|
||||
return std::make_unique<PathNode>(loc, psPath);
|
||||
}
|
||||
|
||||
GeometryNode::Type PathNode::getType()
|
||||
{
|
||||
return GeometryNode::Type::Path;
|
||||
}
|
||||
|
||||
const std::string& PathNode::getPathString() const
|
||||
{
|
||||
return mPathString;
|
||||
}
|
||||
|
||||
void PathNode::setPathString(const std::string& psPath)
|
||||
{
|
||||
mPathString = psPath;
|
||||
}
|
||||
|
||||
void PathNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (!mBackgroundItem)
|
||||
{
|
||||
if (sceneInfo->mSupportsGeometryPrimitives)
|
||||
{
|
||||
auto path = std::make_unique<GeometryPath>();
|
||||
path->buildFromPostscript(mPathString);
|
||||
mBackgroundItem = std::make_unique<SceneModel>(std::move(path));
|
||||
mBackgroundItem->setName(mName + "_Model");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sceneInfo->mSupportsGeometryPrimitives)
|
||||
{
|
||||
auto path = std::make_unique<GeometryPath>();
|
||||
path->buildFromPostscript(mPathString);
|
||||
mBackgroundItem->updateGeometry(std::move(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PathNode::updateTransform()
|
||||
{
|
||||
mBackgroundItem->updateTransform({ mLocation });
|
||||
}
|
24
src/rendering/visual_elements/nodes/PathNode.h
Normal file
24
src/rendering/visual_elements/nodes/PathNode.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include "GeometryNode.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PathNode : public GeometryNode
|
||||
{
|
||||
public:
|
||||
PathNode(const Point& loc, const std::string& psPath);
|
||||
static std::unique_ptr<PathNode> Create(const Point& loc, const std::string& psPath);
|
||||
|
||||
GeometryNode::Type getType() override;
|
||||
|
||||
const std::string& getPathString() const;
|
||||
|
||||
void setPathString(const std::string& psPath);
|
||||
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo) override;
|
||||
void updateTransform() override;
|
||||
|
||||
std::string mPathString;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue