Skip to content

Commit

Permalink
Merge pull request musescore#18510 from mike-spa/correctScalingErrors…
Browse files Browse the repository at this point in the history
…OfChordLines

Correct scaling errors of ChordLine objects
  • Loading branch information
RomanPudashkin authored Jul 11, 2023
2 parents a2537bc + d3be163 commit b82986e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/engraving/libmscore/chordline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,11 @@ std::vector<PointF> 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) {
Expand All @@ -217,7 +216,7 @@ std::vector<PointF> 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<PointF> grips(n);
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/rw/read400/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/rw/read410/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/engraving/rw/write/twrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit b82986e

Please sign in to comment.