From d3be163b8e21fed64d9f8490d008eda41392ffce Mon Sep 17 00:00:00 2001 From: Michele Spagnolo Date: Tue, 11 Jul 2023 10:00:09 +0200 Subject: [PATCH] Correct scaling errors of chordlines --- src/engraving/libmscore/chordline.cpp | 5 ++--- src/engraving/rw/read400/tread.cpp | 3 +++ src/engraving/rw/read410/tread.cpp | 3 +++ src/engraving/rw/write/twrite.cpp | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/engraving/libmscore/chordline.cpp b/src/engraving/libmscore/chordline.cpp index 18ac28813d94c..e1324a78cb74e 100644 --- a/src/engraving/libmscore/chordline.cpp +++ b/src/engraving/libmscore/chordline.cpp @@ -198,12 +198,11 @@ std::vector ChordLine::gripsPositions(const EditData&) const return {}; } - double sp = spatium(); auto n = m_path.elementCount(); PointF cp(pagePos()); if (m_straight) { // limit the number of grips to one - double offset = 0.5 * sp; + double offset = 0.5; PointF p; if (m_chordLineType == ChordLineType::FALL) { @@ -217,7 +216,7 @@ std::vector ChordLine::gripsPositions(const EditData&) const } // translate on the length and height - stops the grips from going past boundaries of slide - p += (cp + PointF(m_path.elementAt(1).x * sp, m_path.elementAt(1).y * sp)); + p += (cp + PointF(m_path.elementAt(1).x, m_path.elementAt(1).y)); return { p }; } else { std::vector grips(n); diff --git a/src/engraving/rw/read400/tread.cpp b/src/engraving/rw/read400/tread.cpp index a27c25e6a90c6..34b7a485847c6 100644 --- a/src/engraving/rw/read400/tread.cpp +++ b/src/engraving/rw/read400/tread.cpp @@ -2541,6 +2541,9 @@ void TRead::read(ChordLine* l, XmlReader& e, ReadContext& ctx) int type = e.intAttribute("type"); double x = e.doubleAttribute("x"); double y = e.doubleAttribute("y"); + double spatium = ctx.spatium(); + x *= spatium; + y *= spatium; switch (PainterPath::ElementType(type)) { case PainterPath::ElementType::MoveToElement: path.moveTo(x, y); diff --git a/src/engraving/rw/read410/tread.cpp b/src/engraving/rw/read410/tread.cpp index 6a8ebb1ed7b26..c5c6b9a676bfc 100644 --- a/src/engraving/rw/read410/tread.cpp +++ b/src/engraving/rw/read410/tread.cpp @@ -2530,6 +2530,9 @@ void TRead::read(ChordLine* l, XmlReader& e, ReadContext& ctx) int type = e.intAttribute("type"); double x = e.doubleAttribute("x"); double y = e.doubleAttribute("y"); + double spatium = ctx.spatium(); + x *= spatium; + y *= spatium; switch (PainterPath::ElementType(type)) { case PainterPath::ElementType::MoveToElement: path.moveTo(x, y); diff --git a/src/engraving/rw/write/twrite.cpp b/src/engraving/rw/write/twrite.cpp index 86e3e6b0a017a..1899c52c5ce4f 100644 --- a/src/engraving/rw/write/twrite.cpp +++ b/src/engraving/rw/write/twrite.cpp @@ -857,7 +857,10 @@ void TWrite::write(const ChordLine* item, XmlWriter& xml, WriteContext& ctx) xml.startElement("Path"); for (size_t i = 0; i < n; ++i) { const PainterPath::Element& e = path.elementAt(i); - xml.tag("Element", { { "type", int(e.type) }, { "x", e.x }, { "y", e.y } }); + double spatium = item->spatium(); + double x = e.x / spatium; + double y = e.y / spatium; + xml.tag("Element", { { "type", int(e.type) }, { "x", x }, { "y", y } }); } xml.endElement(); }