From 5b1dc0b16472da16ad38fb20537a57ce411caddf Mon Sep 17 00:00:00 2001 From: rettinghaus Date: Tue, 18 Feb 2025 18:53:57 +0100 Subject: [PATCH] write bezier points --- .../musicxml/export/exportmusicxml.cpp | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp b/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp index 406036abe863b..d6ea6d413ee41 100644 --- a/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp +++ b/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp @@ -799,6 +799,30 @@ static String slurTieLineStyle(const SlurTie* s) return rest; } +static String slurBezier(const Slur* s, const bool start) +{ + if (!ExportMusicXml::configuration()->exportLayout()) { + return String(); + } + + String rest; + const int spatium = s->spatium(); + if (start) { + const SlurSegment* front = s->frontSegment(); + const PointF start = front->ups(Grip::START).pos(); + const PointF bezier = front->ups(Grip::BEZIER1).pos(); + rest += String(u" bezier-x=\"%1\"").arg(10 * (bezier.x() - start.x()) / spatium); + rest += String(u" bezier-y=\"%1\"").arg(-10 * bezier.y() / spatium); + } else { + const SlurSegment* back = s->backSegment(); + const PointF end = back->ups(Grip::END).pos(); + const PointF bezier = back->ups(Grip::BEZIER2).pos(); + rest += String(u" bezier-x=\"%1\"").arg(10 * (bezier.x() - end.x()) / spatium); + rest += String(u" bezier-y=\"%1\"").arg(-10 * bezier.y() / spatium); + } + return rest; +} + //--------------------------------------------------------- // findSlur -- get index of slur in slur table // return -1 if not found @@ -919,7 +943,7 @@ void SlurHandler::doSlurStart(const Slur* s, Notations& notations, XmlWriter& xm String tagName = u"slur"; tagName += u" type=\"start\""; tagName += slurTieLineStyle(s); - tagName += ExportMusicXml::positioningAttributes(s, true); + tagName += slurBezier(s, true); if (i >= 0) { // remove from list and print start @@ -965,7 +989,7 @@ void SlurHandler::doSlurStop(const Slur* s, Notations& notations, XmlWriter& xml m_started[i] = false; notations.tag(xml, s); String tagName = String(u"slur type=\"stop\" number=\"%1\"").arg(i + 1); - tagName += ExportMusicXml::positioningAttributes(s, false); + tagName += slurBezier(s, false); xml.tagRaw(tagName); } else { LOGD("no free slur slot"); @@ -976,7 +1000,7 @@ void SlurHandler::doSlurStop(const Slur* s, Notations& notations, XmlWriter& xml m_started[i] = false; notations.tag(xml, s); String tagName = String(u"slur type=\"stop\" number=\"%1\"").arg(i + 1); - tagName += ExportMusicXml::positioningAttributes(s, false); + tagName += slurBezier(s, false); xml.tagRaw(tagName); } }