Simple drawing example.
This commit is contained in:
parent
d7fe11913f
commit
f0091f9e04
27 changed files with 450 additions and 68 deletions
83
src/visual_elements/basic_shapes/CircleNode.cpp
Normal file
83
src/visual_elements/basic_shapes/CircleNode.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "CircleNode.h"
|
||||
|
||||
#include "FontsManager.h"
|
||||
#include "SceneModel.h"
|
||||
#include "AbstractMesh.h"
|
||||
#include "MeshPrimitives.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
CircleNode::CircleNode(const DiscretePoint& location, unsigned radius)
|
||||
: GeometryNode(location),
|
||||
mRadius(radius)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CircleNode::Type CircleNode::getType()
|
||||
{
|
||||
return Type::Circle;
|
||||
}
|
||||
|
||||
unsigned CircleNode::getRadius() const
|
||||
{
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
SceneItem* CircleNode::getSceneItem(std::size_t idx) const
|
||||
{
|
||||
if (idx == 0)
|
||||
{
|
||||
return mBackgroundItem.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned CircleNode::getNumSceneItems() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CircleNode::setRadius(unsigned radius)
|
||||
{
|
||||
if (mRadius != radius)
|
||||
{
|
||||
mRadius = radius;
|
||||
mTransformIsDirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CircleNode::update(FontsManager* fontsManager)
|
||||
{
|
||||
if (!mBackgroundItem || mGeometryIsDirty)
|
||||
{
|
||||
auto mesh = MeshPrimitives::buildCircleAsTriMesh();
|
||||
|
||||
if (!mBackgroundItem)
|
||||
{
|
||||
mBackgroundItem = std::make_unique<SceneModel>(std::move(mesh));
|
||||
mBackgroundItem->setName(mName + "_Model");
|
||||
}
|
||||
else
|
||||
{
|
||||
mBackgroundItem->updateMesh(std::move(mesh));
|
||||
}
|
||||
mGeometryIsDirty = false;
|
||||
}
|
||||
|
||||
if (mTransformIsDirty)
|
||||
{
|
||||
mBackgroundItem->updateTransform({mLocation, static_cast<double>(2*mRadius), static_cast<double>(2*mRadius)});
|
||||
mTransformIsDirty = false;
|
||||
}
|
||||
|
||||
if (mMaterialIsDirty)
|
||||
{
|
||||
mBackgroundItem->updateUniformColor(mFillColor);
|
||||
mMaterialIsDirty = false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue