From 198caa700b65c8c12b942f923e48fc3e2fc09cfc Mon Sep 17 00:00:00 2001 From: James Grogan Date: Sun, 26 Feb 2023 18:23:21 +0000 Subject: [PATCH] Fix linux build. --- apps/notes_tk/canvas/CanvasDrawingArea.cpp | 2 +- apps/notes_tk/image_editor/ImageViewWidget.cpp | 2 +- apps/notes_tk/mesh_viewer/MeshViewerView.cpp | 2 +- plugins/circuits/src/visuals/WireNode.cpp | 8 ++++---- src/base/geometry/Transform.cpp | 9 +++++++++ src/base/geometry/Transform.h | 2 ++ src/base/geometry/points/Point.cpp | 5 ++--- src/base/geometry/points/Point.h | 2 +- src/publishing/plotting/EquationNode.cpp | 10 +++++----- src/rendering/mesh/AbstractMesh.cpp | 2 +- .../visual_elements/basic_shapes/LineNode.cpp | 2 +- src/rendering/visual_elements/svg/SvgNode.cpp | 2 +- src/rendering/visual_elements/svg/SvgShapeElement.cpp | 2 +- src/ui/ui_controls/Button.cpp | 4 ++-- src/ui/ui_elements/widgets/Widget.cpp | 2 +- test/publishing/TestSvgConverter.cpp | 2 +- 16 files changed, 34 insertions(+), 24 deletions(-) diff --git a/apps/notes_tk/canvas/CanvasDrawingArea.cpp b/apps/notes_tk/canvas/CanvasDrawingArea.cpp index a9bbc4a..90b7992 100644 --- a/apps/notes_tk/canvas/CanvasDrawingArea.cpp +++ b/apps/notes_tk/canvas/CanvasDrawingArea.cpp @@ -15,7 +15,7 @@ void CanvasDrawingArea::addShapeAt(unsigned x, unsigned y) { if (mActiveDrawingCommand == CanvasDrawCommand::CIRCLE) { - auto circle = std::make_unique(Transform(DiscretePoint(x, y)), 5); + auto circle = std::make_unique(Transform(Point2(x, y)), 5); circle->setFillColor(Color(255, 0, 0)); circle->setName("CanvasDrawingArea_CircleNode"); diff --git a/apps/notes_tk/image_editor/ImageViewWidget.cpp b/apps/notes_tk/image_editor/ImageViewWidget.cpp index 9f47275..4afc019 100644 --- a/apps/notes_tk/image_editor/ImageViewWidget.cpp +++ b/apps/notes_tk/image_editor/ImageViewWidget.cpp @@ -25,7 +25,7 @@ void ImageViewWidget::doPaint(const PaintEvent* event) if (!mGridNode) { - mGridNode = std::make_unique(Transform(mLocation)); + mGridNode = std::make_unique(Transform(Point3(mLocation))); mGridNode->setName(mName + "_GridNode"); mGridNode->setNumX(mNumX); mGridNode->setNumY(mNumY); diff --git a/apps/notes_tk/mesh_viewer/MeshViewerView.cpp b/apps/notes_tk/mesh_viewer/MeshViewerView.cpp index bcf6d0a..e5644a9 100644 --- a/apps/notes_tk/mesh_viewer/MeshViewerView.cpp +++ b/apps/notes_tk/mesh_viewer/MeshViewerView.cpp @@ -34,7 +34,7 @@ void MeshViewerView::doPaint(const PaintEvent* event) if (!mMeshNode) { - mMeshNode = std::make_unique(Transform(mLocation)); + mMeshNode = std::make_unique(Transform(Point3(mLocation))); mMeshNode->setName(mName + "_MeshNode"); mMeshNode->setWidth(mSize.mWidth); diff --git a/plugins/circuits/src/visuals/WireNode.cpp b/plugins/circuits/src/visuals/WireNode.cpp index 12d9ed2..8509f58 100644 --- a/plugins/circuits/src/visuals/WireNode.cpp +++ b/plugins/circuits/src/visuals/WireNode.cpp @@ -3,15 +3,15 @@ #include "LineNode.h" WireNode::WireNode(const Transform& transform) - : AbstractVisualNode(transform) + : AbstractVisualNode(transform) { } void WireNode::setContent(Wire* wire) { - mContent = wire; - mContentDirty = true; + mContent = wire; + mContentDirty = true; } void WireNode::setInputLocation(const Point2& point) @@ -66,4 +66,4 @@ void WireNode::createOrUpdateGeometry(SceneInfo*) addChild(mLine.get()); } -} \ No newline at end of file +} diff --git a/src/base/geometry/Transform.cpp b/src/base/geometry/Transform.cpp index 60090bd..eca7ce6 100644 --- a/src/base/geometry/Transform.cpp +++ b/src/base/geometry/Transform.cpp @@ -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) { mLocation.moveBy(transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ()); diff --git a/src/base/geometry/Transform.h b/src/base/geometry/Transform.h index bebbe06..19d4ec8 100644 --- a/src/base/geometry/Transform.h +++ b/src/base/geometry/Transform.h @@ -37,6 +37,8 @@ class Transform public: 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); const Point3& getLocation() const; diff --git a/src/base/geometry/points/Point.cpp b/src/base/geometry/points/Point.cpp index a1e6484..d436168 100644 --- a/src/base/geometry/points/Point.cpp +++ b/src/base/geometry/points/Point.cpp @@ -7,10 +7,9 @@ #include template -Point::Point(const Point<2>& p) - : Point(p.getX(), p.getY()) +Point Point::from(const Point<2>& p) { - + return Point(p.getX(), p.getY()); } template diff --git a/src/base/geometry/points/Point.h b/src/base/geometry/points/Point.h index 689f799..d2e2451 100644 --- a/src/base/geometry/points/Point.h +++ b/src/base/geometry/points/Point.h @@ -15,7 +15,7 @@ public: Point(const Vector& v); - Point(const Point<2>& p); + static Point from(const Point<2>& p); Point(const Point& p) = default; diff --git a/src/publishing/plotting/EquationNode.cpp b/src/publishing/plotting/EquationNode.cpp index 7bfaa47..c16a443 100644 --- a/src/publishing/plotting/EquationNode.cpp +++ b/src/publishing/plotting/EquationNode.cpp @@ -56,7 +56,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression } MLOG_INFO("Processing leaf expr with content: " << content << " and size " << content.size()); - auto node = std::make_unique(content, Transform(mTextCursor)); + auto node = std::make_unique(content, Transform(Point<3>::from(mTextCursor))); node->setFont(mDefaultFont); addChild(node.get()); @@ -75,7 +75,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression mTextCursor.moveBy(x_cache - mTextCursor.getX(), 16.0); std::vector end_loc{ { 25.0, 0.0 } }; - auto dividing_line = std::make_unique(Transform(mTextCursor), end_loc); + auto dividing_line = std::make_unique(Transform(Point<3>::from(mTextCursor)), end_loc); addChild(dividing_line.get()); 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_node = std::make_unique(left_content, Transform(mTextCursor)); + auto left_node = std::make_unique(left_content, Transform(Point<3>::from(mTextCursor))); left_node->setFont(mDefaultFont); addChild(left_node.get()); @@ -103,7 +103,7 @@ void EquationNode::addExpression(SceneInfo* sceneInfo, const LatexMathExpression auto right_content = expression->getRightSymbol().mUnicode; - auto right_node = std::make_unique(right_content, Transform(mTextCursor)); + auto right_node = std::make_unique(right_content, Transform(Point<3>::from(mTextCursor))); right_node->setFont(mDefaultFont); addChild(right_node.get()); @@ -120,4 +120,4 @@ void EquationNode::createOrUpdateGeometry(SceneInfo* sceneInfo) mText.clear(); addExpression(sceneInfo, mContent); -} \ No newline at end of file +} diff --git a/src/rendering/mesh/AbstractMesh.cpp b/src/rendering/mesh/AbstractMesh.cpp index e522427..cb71ef5 100644 --- a/src/rendering/mesh/AbstractMesh.cpp +++ b/src/rendering/mesh/AbstractMesh.cpp @@ -48,7 +48,7 @@ std::vector AbstractMesh::getVectorAttribute(const std::string& tag) con 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) { diff --git a/src/rendering/visual_elements/basic_shapes/LineNode.cpp b/src/rendering/visual_elements/basic_shapes/LineNode.cpp index d50fce6..4b65a03 100644 --- a/src/rendering/visual_elements/basic_shapes/LineNode.cpp +++ b/src/rendering/visual_elements/basic_shapes/LineNode.cpp @@ -35,7 +35,7 @@ void LineNode::createOrUpdateGeometry(SceneInfo*) if (!mEndNode) { auto end_loc = mPoints[mPoints.size() - 1]; - mEndNode = std::make_unique(Transform(end_loc)); + mEndNode = std::make_unique(Transform(Point<3>::from(end_loc))); addChild(mEndNode.get()); } mEndNode->setStyle(mEndEndStyle); diff --git a/src/rendering/visual_elements/svg/SvgNode.cpp b/src/rendering/visual_elements/svg/SvgNode.cpp index 0085f4e..c624389 100644 --- a/src/rendering/visual_elements/svg/SvgNode.cpp +++ b/src/rendering/visual_elements/svg/SvgNode.cpp @@ -130,7 +130,7 @@ void SvgNode::onCircle(XmlElement* element, std::unique_ptr& node) minor_radius *= transform.getScale().mY; } - auto circle_node = std::make_unique(Transform(loc), radius); + auto circle_node = std::make_unique(Transform(Point<3>::from(loc)), radius); circle_node->setMinorRadius(minor_radius); node = std::move(circle_node); } diff --git a/src/rendering/visual_elements/svg/SvgShapeElement.cpp b/src/rendering/visual_elements/svg/SvgShapeElement.cpp index 0068a03..3344292 100644 --- a/src/rendering/visual_elements/svg/SvgShapeElement.cpp +++ b/src/rendering/visual_elements/svg/SvgShapeElement.cpp @@ -47,7 +47,7 @@ Transform SvgShapeElement::getTransform() const if (in_translate) { const auto loc = parsePoint(working_string, 0.0); - transform.setLocation(loc); + transform.setLocation(Point<3>::from(loc)); in_translate = false; } else if (in_scale) diff --git a/src/ui/ui_controls/Button.cpp b/src/ui/ui_controls/Button.cpp index 8986134..b3ca74e 100644 --- a/src/ui/ui_controls/Button.cpp +++ b/src/ui/ui_controls/Button.cpp @@ -205,7 +205,7 @@ void Button::doPaint(const PaintEvent* event) { if (mTransformDirty) { - mRootNode->setTransform(Transform(mLocation)); + mRootNode->setTransform(Transform(Point3(mLocation))); mTransformDirty = false; } @@ -255,7 +255,7 @@ void Button::updateIcon(const PaintEvent* event) { if (!mIconNode && mIcon != Resource::Icon::Svg::NONE) { - mIconNode = std::make_unique(Transform(Point(15.0, 8.0), 0.5, 0.5)); + mIconNode = std::make_unique(Transform(Point3(15.0, 8.0), 0.5, 0.5)); mIconNode->setName(mName + "_IconNode"); mIconNode->setSvgContent(MediaResourceManager::getSvgIconNode(mIcon)); mRootNode->addChild(mIconNode.get()); diff --git a/src/ui/ui_elements/widgets/Widget.cpp b/src/ui/ui_elements/widgets/Widget.cpp index 50eab76..5b21426 100644 --- a/src/ui/ui_elements/widgets/Widget.cpp +++ b/src/ui/ui_elements/widgets/Widget.cpp @@ -335,7 +335,7 @@ void Widget::createOrUpdateGeometry() void Widget::updateTransform() { - mRootNode->setTransform({ mLocation }); + mRootNode->setTransform(Point3{ mLocation }); } void Widget::updateMaterial(const PaintEvent* event) diff --git a/test/publishing/TestSvgConverter.cpp b/test/publishing/TestSvgConverter.cpp index 866a34e..5114b13 100644 --- a/test/publishing/TestSvgConverter.cpp +++ b/test/publishing/TestSvgConverter.cpp @@ -16,7 +16,7 @@ TEST_CASE(TestSvgConverter, "[publishing]") Scene scene; //scene.setShowMeshOutline(true); - CircleNode circle({40, 40}, 20); + CircleNode circle(Point2{40, 40}, 20); circle.setFillColor({255, 0, 0}); scene.addNode(&circle);