Cleaning for mesh addition.
This commit is contained in:
parent
8e0ce22b57
commit
402f381d10
67 changed files with 655 additions and 456 deletions
36
src/visual_elements/AbstractVisualNode.h
Normal file
36
src/visual_elements/AbstractVisualNode.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractMesh.h"
|
||||
#include "Image.h"
|
||||
#include "DiscretePoint.h"
|
||||
#include <memory>
|
||||
|
||||
class AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
AbstractVisualNode(const DiscretePoint& location)
|
||||
: mLocation(location)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AbstractMesh* getMesh() const
|
||||
{
|
||||
return mMesh.get();
|
||||
}
|
||||
|
||||
Image<unsigned char>* getImage() const
|
||||
{
|
||||
return mImage.get();
|
||||
}
|
||||
|
||||
const DiscretePoint& getLocation() const
|
||||
{
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
private:
|
||||
DiscretePoint mLocation;
|
||||
std::unique_ptr<AbstractMesh> mMesh;
|
||||
std::unique_ptr<Image<unsigned char> > mImage;
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
list(APPEND visual_elements_LIB_INCLUDES
|
||||
GeometryElement.cpp
|
||||
RectangleElement.cpp
|
||||
TextElement.cpp
|
||||
GeometryNode.cpp
|
||||
RectangleNode.cpp
|
||||
TextNode.cpp
|
||||
VisualLayer.cpp
|
||||
)
|
||||
|
||||
|
@ -12,7 +12,7 @@ target_include_directories(visual_elements PUBLIC
|
|||
"${PROJECT_SOURCE_DIR}/src/geometry/"
|
||||
)
|
||||
|
||||
target_link_libraries(visual_elements PUBLIC core geometry)
|
||||
target_link_libraries(visual_elements PUBLIC core geometry mesh image)
|
||||
|
||||
set_property(TARGET visual_elements PROPERTY FOLDER src)
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
#include "GeometryElement.h"
|
||||
|
||||
GeometryElement::GeometryElement()
|
||||
: mFillColor(Color::Create(255, 255, 255)),
|
||||
mStrokeColor(Color::Create(0, 0, 0)),
|
||||
mStrokeThickness(1),
|
||||
mType(Type::Path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Color* GeometryElement::GetFillColor() const
|
||||
{
|
||||
return mFillColor.get();
|
||||
}
|
||||
Color* GeometryElement::GetStrokeColor() const
|
||||
{
|
||||
return mStrokeColor.get();
|
||||
}
|
||||
|
||||
unsigned GeometryElement::GetStrokeThickness() const
|
||||
{
|
||||
return mStrokeThickness;
|
||||
}
|
||||
|
||||
void GeometryElement::SetFillColor(ColorUPtr color)
|
||||
{
|
||||
mFillColor = std::move(color);
|
||||
}
|
||||
|
||||
void GeometryElement::SetStrokeColor(ColorUPtr color)
|
||||
{
|
||||
mStrokeColor = std::move(color);
|
||||
}
|
||||
|
||||
void GeometryElement::SetStrokeThickness(unsigned thickness)
|
||||
{
|
||||
mStrokeThickness = thickness;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
class GeometryElement
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Path,
|
||||
Rectangle,
|
||||
Circle,
|
||||
Arc
|
||||
};
|
||||
|
||||
private:
|
||||
ColorUPtr mFillColor;
|
||||
ColorUPtr mStrokeColor;
|
||||
unsigned mStrokeThickness;
|
||||
Type mType;
|
||||
|
||||
public:
|
||||
|
||||
GeometryElement();
|
||||
virtual ~GeometryElement() = default;
|
||||
|
||||
Color* GetFillColor() const;
|
||||
Color* GetStrokeColor() const;
|
||||
unsigned GetStrokeThickness() const;
|
||||
virtual Type GetType() = 0;
|
||||
|
||||
void SetFillColor(ColorUPtr color);
|
||||
void SetStrokeColor(ColorUPtr color);
|
||||
void SetStrokeThickness(unsigned thickness);
|
||||
};
|
||||
|
||||
using GeometryElementUPtr = std::unique_ptr<GeometryElement>;
|
41
src/visual_elements/GeometryNode.cpp
Normal file
41
src/visual_elements/GeometryNode.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "GeometryNode.h"
|
||||
|
||||
GeometryNode::GeometryNode(const DiscretePoint& location)
|
||||
: AbstractVisualNode(location),
|
||||
mFillColor(Color(255, 255, 255)),
|
||||
mStrokeColor(Color(0, 0, 0)),
|
||||
mStrokeThickness(1),
|
||||
mType(Type::Path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Color& GeometryNode::getFillColor() const
|
||||
{
|
||||
return mFillColor;
|
||||
}
|
||||
|
||||
const Color& GeometryNode::getStrokeColor() const
|
||||
{
|
||||
return mStrokeColor;
|
||||
}
|
||||
|
||||
unsigned GeometryNode::getStrokeThickness() const
|
||||
{
|
||||
return mStrokeThickness;
|
||||
}
|
||||
|
||||
void GeometryNode::setFillColor(const Color& color)
|
||||
{
|
||||
mFillColor = color;
|
||||
}
|
||||
|
||||
void GeometryNode::setStrokeColor(const Color& color)
|
||||
{
|
||||
mStrokeColor = std::move(color);
|
||||
}
|
||||
|
||||
void GeometryNode::setStrokeThickness(unsigned thickness)
|
||||
{
|
||||
mStrokeThickness = thickness;
|
||||
}
|
36
src/visual_elements/GeometryNode.h
Normal file
36
src/visual_elements/GeometryNode.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractVisualNode.h"
|
||||
#include "Color.h"
|
||||
|
||||
class GeometryNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Path,
|
||||
Rectangle,
|
||||
Circle,
|
||||
Arc
|
||||
};
|
||||
|
||||
public:
|
||||
GeometryNode(const DiscretePoint& location);
|
||||
virtual ~GeometryNode() = default;
|
||||
|
||||
const Color& getFillColor() const;
|
||||
const Color& getStrokeColor() const;
|
||||
unsigned getStrokeThickness() const;
|
||||
virtual Type getType() = 0;
|
||||
|
||||
void setFillColor(const Color& color);
|
||||
void setStrokeColor(const Color& color);
|
||||
void setStrokeThickness(unsigned thickness);
|
||||
private:
|
||||
Color mFillColor;
|
||||
Color mStrokeColor;
|
||||
unsigned mStrokeThickness{0};
|
||||
Type mType;
|
||||
};
|
||||
|
||||
using GeometryNodePtr = std::unique_ptr<GeometryNode>;
|
|
@ -1,36 +0,0 @@
|
|||
#include "RectangleElement.h"
|
||||
|
||||
RectangleElement::RectangleElement(const DiscretePoint& loc,
|
||||
unsigned width, unsigned height)
|
||||
: mLocation(loc),
|
||||
mWidth(width),
|
||||
mHeight(height)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<RectangleElement> RectangleElement::Create(const DiscretePoint& loc,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
return std::make_unique<RectangleElement>(loc, width, height);
|
||||
}
|
||||
|
||||
GeometryElement::Type RectangleElement::GetType()
|
||||
{
|
||||
return GeometryElement::Type::Rectangle;
|
||||
}
|
||||
|
||||
DiscretePoint RectangleElement::GetLocation() const
|
||||
{
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
unsigned RectangleElement::GetWidth() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
unsigned RectangleElement::GetHeight() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "GeometryElement.h"
|
||||
#include "DiscretePoint.h"
|
||||
|
||||
class RectangleElement : public GeometryElement
|
||||
{
|
||||
DiscretePoint mLocation;
|
||||
unsigned mWidth;
|
||||
unsigned mHeight;
|
||||
|
||||
public:
|
||||
|
||||
RectangleElement(const DiscretePoint& loc, unsigned width, unsigned height);
|
||||
static std::unique_ptr<RectangleElement> Create(const DiscretePoint& loc,
|
||||
unsigned width, unsigned height);
|
||||
GeometryElement::Type GetType() override;
|
||||
|
||||
DiscretePoint GetLocation() const;
|
||||
unsigned GetWidth() const;
|
||||
unsigned GetHeight() const;
|
||||
};
|
||||
|
||||
using RectangleElementUPtr = std::unique_ptr<RectangleElement>;
|
||||
|
||||
|
29
src/visual_elements/RectangleNode.cpp
Normal file
29
src/visual_elements/RectangleNode.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "RectangleNode.h"
|
||||
|
||||
RectangleNode::RectangleNode(const DiscretePoint& loc, unsigned width, unsigned height)
|
||||
: GeometryNode(loc),
|
||||
mWidth(width),
|
||||
mHeight(height)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<RectangleNode> RectangleNode::Create(const DiscretePoint& loc, unsigned width, unsigned height)
|
||||
{
|
||||
return std::make_unique<RectangleNode>(loc, width, height);
|
||||
}
|
||||
|
||||
GeometryNode::Type RectangleNode::getType()
|
||||
{
|
||||
return GeometryNode::Type::Rectangle;
|
||||
}
|
||||
|
||||
unsigned RectangleNode::getWidth() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
unsigned RectangleNode::getHeight() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
25
src/visual_elements/RectangleNode.h
Normal file
25
src/visual_elements/RectangleNode.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "GeometryNode.h"
|
||||
#include "DiscretePoint.h"
|
||||
|
||||
class RectangleNode : public GeometryNode
|
||||
{
|
||||
public:
|
||||
RectangleNode(const DiscretePoint& loc, unsigned width, unsigned height);
|
||||
static std::unique_ptr<RectangleNode> Create(const DiscretePoint& loc, unsigned width, unsigned height);
|
||||
GeometryNode::Type getType() override;
|
||||
|
||||
unsigned getWidth() const;
|
||||
unsigned getHeight() const;
|
||||
|
||||
private:
|
||||
unsigned mWidth{1};
|
||||
unsigned mHeight{1};
|
||||
};
|
||||
|
||||
using RectangleNodePtr = std::unique_ptr<RectangleNode>;
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
#include "TextElement.h"
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
TextElement::TextElement(const std::string& content, const DiscretePoint& loc)
|
||||
: mContent(content),
|
||||
mLocation(loc),
|
||||
mFontLabel("fixed"),
|
||||
mFillColor(Color::Create(255, 255, 255)),
|
||||
mStrokeColor(Color::Create(0, 0, 0))
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Fixed_(typeface)#:~:text=misc%2Dfixed%20is%20a%20collection,to%20a%20single%20font%20family.
|
||||
}
|
||||
|
||||
TextElement::~TextElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<TextElement> TextElement::Create(const std::string& content, const DiscretePoint& loc)
|
||||
{
|
||||
return std::make_unique<TextElement>(content, loc);
|
||||
}
|
||||
|
||||
Color* TextElement::GetFillColor() const
|
||||
{
|
||||
return mFillColor.get();
|
||||
}
|
||||
Color* TextElement::GetStrokeColor() const
|
||||
{
|
||||
return mStrokeColor.get();
|
||||
}
|
||||
|
||||
DiscretePoint TextElement::GetLocation() const
|
||||
{
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
std::string TextElement::GetFontLabel() const
|
||||
{
|
||||
return mFontLabel;
|
||||
}
|
||||
|
||||
std::string TextElement::GetContent() const
|
||||
{
|
||||
return mContent;
|
||||
}
|
||||
|
||||
void TextElement::SetContent(const std::string& content)
|
||||
{
|
||||
mContent = content;
|
||||
}
|
||||
|
||||
void TextElement::SetFillColor(ColorUPtr color)
|
||||
{
|
||||
mFillColor = std::move(color);
|
||||
}
|
||||
|
||||
void TextElement::SetStrokeColor(ColorUPtr color)
|
||||
{
|
||||
mStrokeColor = std::move(color);
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "DiscretePoint.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class Color;
|
||||
|
||||
class TextElement
|
||||
{
|
||||
std::string mContent;
|
||||
DiscretePoint mLocation;
|
||||
std::string mFontLabel;
|
||||
std::unique_ptr<Color> mFillColor;
|
||||
std::unique_ptr<Color> mStrokeColor;
|
||||
|
||||
public:
|
||||
|
||||
TextElement(const std::string& content, const DiscretePoint& loc);
|
||||
|
||||
~TextElement();
|
||||
|
||||
static std::unique_ptr<TextElement> Create(const std::string& content, const DiscretePoint& loc);
|
||||
|
||||
Color* GetFillColor() const;
|
||||
Color* GetStrokeColor() const;
|
||||
|
||||
DiscretePoint GetLocation() const;
|
||||
std::string GetContent() const;
|
||||
std::string GetFontLabel() const;
|
||||
void SetContent(const std::string& content);
|
||||
void SetFillColor(std::unique_ptr<Color> color);
|
||||
void SetStrokeColor(std::unique_ptr<Color> color);
|
||||
};
|
||||
|
||||
using TextElementUPtr = std::unique_ptr<TextElement>;
|
57
src/visual_elements/TextNode.cpp
Normal file
57
src/visual_elements/TextNode.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "TextNode.h"
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
TextNode::TextNode(const std::string& content, const DiscretePoint& loc)
|
||||
: AbstractVisualNode(loc),
|
||||
mContent(content),
|
||||
mFontLabel("fixed"),
|
||||
mFillColor(Color(255, 255, 255)),
|
||||
mStrokeColor(Color(0, 0, 0))
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Fixed_(typeface)#:~:text=misc%2Dfixed%20is%20a%20collection,to%20a%20single%20font%20family.
|
||||
}
|
||||
|
||||
TextNode::~TextNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<TextNode> TextNode::Create(const std::string& content, const DiscretePoint& loc)
|
||||
{
|
||||
return std::make_unique<TextNode>(content, loc);
|
||||
}
|
||||
|
||||
const Color& TextNode::getFillColor() const
|
||||
{
|
||||
return mFillColor;
|
||||
}
|
||||
const Color& TextNode::getStrokeColor() const
|
||||
{
|
||||
return mStrokeColor;
|
||||
}
|
||||
|
||||
std::string TextNode::getFontLabel() const
|
||||
{
|
||||
return mFontLabel;
|
||||
}
|
||||
|
||||
std::string TextNode::getContent() const
|
||||
{
|
||||
return mContent;
|
||||
}
|
||||
|
||||
void TextNode::setContent(const std::string& content)
|
||||
{
|
||||
mContent = content;
|
||||
}
|
||||
|
||||
void TextNode::setFillColor(const Color& color)
|
||||
{
|
||||
mFillColor = color;
|
||||
}
|
||||
|
||||
void TextNode::setStrokeColor(const Color& color)
|
||||
{
|
||||
mStrokeColor = color;
|
||||
}
|
38
src/visual_elements/TextNode.h
Normal file
38
src/visual_elements/TextNode.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "DiscretePoint.h"
|
||||
|
||||
#include "AbstractVisualNode.h"
|
||||
#include "Color.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class Color;
|
||||
|
||||
class TextNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
TextNode(const std::string& content, const DiscretePoint& loc);
|
||||
|
||||
~TextNode();
|
||||
|
||||
static std::unique_ptr<TextNode> Create(const std::string& content, const DiscretePoint& loc);
|
||||
|
||||
const Color& getFillColor() const;
|
||||
const Color& getStrokeColor() const;
|
||||
|
||||
std::string getContent() const;
|
||||
std::string getFontLabel() const;
|
||||
void setContent(const std::string& content);
|
||||
void setFillColor(const Color& color);
|
||||
void setStrokeColor(const Color& color);
|
||||
|
||||
private:
|
||||
std::string mContent;
|
||||
std::string mFontLabel;
|
||||
Color mFillColor;
|
||||
Color mStrokeColor;
|
||||
};
|
||||
|
||||
using TextNodetr = std::unique_ptr<TextNode>;
|
|
@ -1,7 +1,7 @@
|
|||
#include "VisualLayer.h"
|
||||
|
||||
#include "GeometryElement.h"
|
||||
#include "TextElement.h"
|
||||
#include "GeometryNode.h"
|
||||
#include "TextNode.h"
|
||||
|
||||
VisualLayer::VisualLayer()
|
||||
: mShape(),
|
||||
|
@ -15,32 +15,32 @@ std::unique_ptr<VisualLayer> VisualLayer::Create()
|
|||
return std::make_unique<VisualLayer>();
|
||||
}
|
||||
|
||||
bool VisualLayer::HasShape() const
|
||||
bool VisualLayer::hasShape() const
|
||||
{
|
||||
return bool(mShape);
|
||||
}
|
||||
|
||||
bool VisualLayer::HasText() const
|
||||
bool VisualLayer::hasText() const
|
||||
{
|
||||
return bool(mText);
|
||||
}
|
||||
|
||||
GeometryElement* VisualLayer::GetShape() const
|
||||
GeometryNode* VisualLayer::getShape() const
|
||||
{
|
||||
return mShape.get();
|
||||
}
|
||||
|
||||
TextElement* VisualLayer::GetText() const
|
||||
TextNode* VisualLayer::getText() const
|
||||
{
|
||||
return mText.get();
|
||||
}
|
||||
|
||||
void VisualLayer::SetShape(GeometryElementUPtr shape)
|
||||
void VisualLayer::setShape(GeometryNodePtr shape)
|
||||
{
|
||||
mShape = std::move(shape);
|
||||
}
|
||||
|
||||
void VisualLayer::SetText(TextElementUPtr text)
|
||||
void VisualLayer::setText(std::unique_ptr<TextNode> text)
|
||||
{
|
||||
mText = std::move(text);
|
||||
}
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
class GeometryElement;
|
||||
class TextElement;
|
||||
class GeometryNode;
|
||||
class TextNode;
|
||||
|
||||
class VisualLayer
|
||||
{
|
||||
std::unique_ptr<GeometryElement> mShape;
|
||||
std::unique_ptr<TextElement> mText;
|
||||
|
||||
public:
|
||||
|
||||
VisualLayer();
|
||||
|
||||
static std::unique_ptr<VisualLayer> Create();
|
||||
|
||||
GeometryElement* GetShape() const;
|
||||
TextElement* GetText() const;
|
||||
bool HasShape() const;
|
||||
bool HasText() const;
|
||||
void SetShape(std::unique_ptr<GeometryElement> shape);
|
||||
void SetText(std::unique_ptr<TextElement> text);
|
||||
GeometryNode* getShape() const;
|
||||
TextNode* getText() const;
|
||||
bool hasShape() const;
|
||||
bool hasText() const;
|
||||
void setShape(std::unique_ptr<GeometryNode> shape);
|
||||
void setText(std::unique_ptr<TextNode> text);
|
||||
|
||||
private:
|
||||
std::unique_ptr<GeometryNode> mShape;
|
||||
std::unique_ptr<TextNode> mText;
|
||||
};
|
||||
using VisualLayerUPtr = std::unique_ptr<VisualLayer>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue