Fix linux build.

This commit is contained in:
James Grogan 2023-02-26 18:23:21 +00:00
parent c5363327e8
commit 198caa700b
16 changed files with 34 additions and 24 deletions

View file

@ -15,7 +15,7 @@ void CanvasDrawingArea::addShapeAt(unsigned x, unsigned y)
{ {
if (mActiveDrawingCommand == CanvasDrawCommand::CIRCLE) if (mActiveDrawingCommand == CanvasDrawCommand::CIRCLE)
{ {
auto circle = std::make_unique<CircleNode>(Transform(DiscretePoint(x, y)), 5); auto circle = std::make_unique<CircleNode>(Transform(Point2(x, y)), 5);
circle->setFillColor(Color(255, 0, 0)); circle->setFillColor(Color(255, 0, 0));
circle->setName("CanvasDrawingArea_CircleNode"); circle->setName("CanvasDrawingArea_CircleNode");

View file

@ -25,7 +25,7 @@ void ImageViewWidget::doPaint(const PaintEvent* event)
if (!mGridNode) if (!mGridNode)
{ {
mGridNode = std::make_unique<GridNode>(Transform(mLocation)); mGridNode = std::make_unique<GridNode>(Transform(Point3(mLocation)));
mGridNode->setName(mName + "_GridNode"); mGridNode->setName(mName + "_GridNode");
mGridNode->setNumX(mNumX); mGridNode->setNumX(mNumX);
mGridNode->setNumY(mNumY); mGridNode->setNumY(mNumY);

View file

@ -34,7 +34,7 @@ void MeshViewerView::doPaint(const PaintEvent* event)
if (!mMeshNode) if (!mMeshNode)
{ {
mMeshNode = std::make_unique<MeshNode>(Transform(mLocation)); mMeshNode = std::make_unique<MeshNode>(Transform(Point3(mLocation)));
mMeshNode->setName(mName + "_MeshNode"); mMeshNode->setName(mName + "_MeshNode");
mMeshNode->setWidth(mSize.mWidth); mMeshNode->setWidth(mSize.mWidth);

View file

@ -27,6 +27,15 @@ Transform::Transform(const Point3& location, const Scale& scale, const Rotation&
} }
Transform::Transform(const Point2& location, const Scale& scale, const Rotation& rotation)
: mLocation(Point<3>::from(location)),
mScale(scale),
mRotation(rotation),
mMatrix()
{
}
void Transform::applyPre(const Transform& transform) void Transform::applyPre(const Transform& transform)
{ {
mLocation.moveBy(transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ()); mLocation.moveBy(transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ());

View file

@ -37,6 +37,8 @@ class Transform
public: public:
Transform(const Point3& location = {}, const Scale& scale = {}, const Rotation& rotation = {}); Transform(const Point3& location = {}, const Scale& scale = {}, const Rotation& rotation = {});
Transform(const Point2& location, const Scale& scale = {}, const Rotation& rotation = {});
void applyPre(const Transform& transform); void applyPre(const Transform& transform);
const Point3& getLocation() const; const Point3& getLocation() const;

View file

@ -7,10 +7,9 @@
#include <numeric> #include <numeric>
template<std::size_t DIM> template<std::size_t DIM>
Point<DIM>::Point(const Point<2>& p) Point<DIM> Point<DIM>::from(const Point<2>& p)
: Point(p.getX(), p.getY())
{ {
return Point<DIM>(p.getX(), p.getY());
} }
template<std::size_t DIM> template<std::size_t DIM>

View file

@ -15,7 +15,7 @@ public:
Point(const Vector<double, DIM>& v); Point(const Vector<double, DIM>& v);
Point(const Point<2>& p); static Point<DIM> from(const Point<2>& p);
Point(const Point<DIM>& p) = default; Point(const Point<DIM>& p) = default;

View file

@ -56,7 +56,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression
} }
MLOG_INFO("Processing leaf expr with content: " << content << " and size " << content.size()); MLOG_INFO("Processing leaf expr with content: " << content << " and size " << content.size());
auto node = std::make_unique<TextNode>(content, Transform(mTextCursor)); auto node = std::make_unique<TextNode>(content, Transform(Point<3>::from(mTextCursor)));
node->setFont(mDefaultFont); node->setFont(mDefaultFont);
addChild(node.get()); addChild(node.get());
@ -75,7 +75,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression
mTextCursor.moveBy(x_cache - mTextCursor.getX(), 16.0); mTextCursor.moveBy(x_cache - mTextCursor.getX(), 16.0);
std::vector<Point2> end_loc{ { 25.0, 0.0 } }; std::vector<Point2> end_loc{ { 25.0, 0.0 } };
auto dividing_line = std::make_unique<LineNode>(Transform(mTextCursor), end_loc); auto dividing_line = std::make_unique<LineNode>(Transform(Point<3>::from(mTextCursor)), end_loc);
addChild(dividing_line.get()); addChild(dividing_line.get());
mLines.push_back(std::move(dividing_line)); mLines.push_back(std::move(dividing_line));
@ -92,7 +92,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression
{ {
auto left_content = expression->getLeftSymbol().mUnicode; auto left_content = expression->getLeftSymbol().mUnicode;
auto left_node = std::make_unique<TextNode>(left_content, Transform(mTextCursor)); auto left_node = std::make_unique<TextNode>(left_content, Transform(Point<3>::from(mTextCursor)));
left_node->setFont(mDefaultFont); left_node->setFont(mDefaultFont);
addChild(left_node.get()); addChild(left_node.get());
@ -103,7 +103,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression
auto right_content = expression->getRightSymbol().mUnicode; auto right_content = expression->getRightSymbol().mUnicode;
auto right_node = std::make_unique<TextNode>(right_content, Transform(mTextCursor)); auto right_node = std::make_unique<TextNode>(right_content, Transform(Point<3>::from(mTextCursor)));
right_node->setFont(mDefaultFont); right_node->setFont(mDefaultFont);
addChild(right_node.get()); addChild(right_node.get());

View file

@ -48,7 +48,7 @@ std::vector<double> AbstractMesh::getVectorAttribute(const std::string& tag) con
void AbstractMesh::scale(double scaleX, double scaleY) void AbstractMesh::scale(double scaleX, double scaleY)
{ {
Transform transform({ 0.0, 0.0 }, scaleX, scaleY); Transform transform(Point3{ 0.0, 0.0, 0.0 }, scaleX, scaleY);
for (auto& node : mNodes) for (auto& node : mNodes)
{ {

View file

@ -35,7 +35,7 @@ void LineNode::createOrUpdateGeometry(SceneInfo*)
if (!mEndNode) if (!mEndNode)
{ {
auto end_loc = mPoints[mPoints.size() - 1]; auto end_loc = mPoints[mPoints.size() - 1];
mEndNode = std::make_unique<LineEndNode>(Transform(end_loc)); mEndNode = std::make_unique<LineEndNode>(Transform(Point<3>::from(end_loc)));
addChild(mEndNode.get()); addChild(mEndNode.get());
} }
mEndNode->setStyle(mEndEndStyle); mEndNode->setStyle(mEndEndStyle);

View file

@ -130,7 +130,7 @@ void SvgNode::onCircle(XmlElement* element, std::unique_ptr<GeometryNode>& node)
minor_radius *= transform.getScale().mY; minor_radius *= transform.getScale().mY;
} }
auto circle_node = std::make_unique<CircleNode>(Transform(loc), radius); auto circle_node = std::make_unique<CircleNode>(Transform(Point<3>::from(loc)), radius);
circle_node->setMinorRadius(minor_radius); circle_node->setMinorRadius(minor_radius);
node = std::move(circle_node); node = std::move(circle_node);
} }

View file

@ -47,7 +47,7 @@ Transform SvgShapeElement::getTransform() const
if (in_translate) if (in_translate)
{ {
const auto loc = parsePoint(working_string, 0.0); const auto loc = parsePoint(working_string, 0.0);
transform.setLocation(loc); transform.setLocation(Point<3>::from(loc));
in_translate = false; in_translate = false;
} }
else if (in_scale) else if (in_scale)

View file

@ -205,7 +205,7 @@ void Button::doPaint(const PaintEvent* event)
{ {
if (mTransformDirty) if (mTransformDirty)
{ {
mRootNode->setTransform(Transform(mLocation)); mRootNode->setTransform(Transform(Point3(mLocation)));
mTransformDirty = false; mTransformDirty = false;
} }
@ -255,7 +255,7 @@ void Button::updateIcon(const PaintEvent* event)
{ {
if (!mIconNode && mIcon != Resource::Icon::Svg::NONE) if (!mIconNode && mIcon != Resource::Icon::Svg::NONE)
{ {
mIconNode = std::make_unique<IconNode>(Transform(Point(15.0, 8.0), 0.5, 0.5)); mIconNode = std::make_unique<IconNode>(Transform(Point3(15.0, 8.0), 0.5, 0.5));
mIconNode->setName(mName + "_IconNode"); mIconNode->setName(mName + "_IconNode");
mIconNode->setSvgContent(MediaResourceManager::getSvgIconNode(mIcon)); mIconNode->setSvgContent(MediaResourceManager::getSvgIconNode(mIcon));
mRootNode->addChild(mIconNode.get()); mRootNode->addChild(mIconNode.get());

View file

@ -335,7 +335,7 @@ void Widget::createOrUpdateGeometry()
void Widget::updateTransform() void Widget::updateTransform()
{ {
mRootNode->setTransform({ mLocation }); mRootNode->setTransform(Point3{ mLocation });
} }
void Widget::updateMaterial(const PaintEvent* event) void Widget::updateMaterial(const PaintEvent* event)

View file

@ -16,7 +16,7 @@ TEST_CASE(TestSvgConverter, "[publishing]")
Scene scene; Scene scene;
//scene.setShowMeshOutline(true); //scene.setShowMeshOutline(true);
CircleNode circle({40, 40}, 20); CircleNode circle(Point2{40, 40}, 20);
circle.setFillColor({255, 0, 0}); circle.setFillColor({255, 0, 0});
scene.addNode(&circle); scene.addNode(&circle);