Skip to content

Commit 1fb20ea

Browse files
rettinghausJojo-Schmitz
authored andcommitted
[MusicXML] invisible notations
Backport of musescore#27422
1 parent b6a87f5 commit 1fb20ea

File tree

5 files changed

+308
-71
lines changed

5 files changed

+308
-71
lines changed

importexport/musicxml/exportxml.cpp

+11-42
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ class ExportMusicXml {
397397
Fraction tick() const { return _tick; }
398398
void writeInstrumentChange(const InstrumentChange* instrChange);
399399
void writeInstrumentDetails(const Instrument* instrument, const bool concertPitch);
400-
static bool canWrite(const Element* e);
401400
};
402401

403402
//---------------------------------------------------------
@@ -768,7 +767,7 @@ void SlurHandler::doSlurs(const ChordRest* chordRest, Notations& notations, XmlW
768767
// search for slur(s) starting or stopping at this chord
769768
for (const auto& it : chordRest->score()->spanner()) {
770769
auto sp = it.second;
771-
if (sp->generated() || sp->type() != ElementType::SLUR || !ExportMusicXml::canWrite(sp))
770+
if (sp->generated() || sp->type() != ElementType::SLUR)
772771
continue;
773772
if (chordRest == sp->startElement() || chordRest == sp->endElement()) {
774773
const Slur* s = static_cast<const Slur*>(sp);
@@ -1035,7 +1034,7 @@ static void findTrills(const Measure* const measure, int strack, int etrack, Tri
10351034
for (auto it = measure->score()->spanner().lower_bound(stick.ticks()); it != measure->score()->spanner().upper_bound(etick.ticks()); ++it) {
10361035
Element* e = it->second;
10371036
//qDebug("1 trill %p type %d track %d tick %s", e, e->type(), e->track(), qPrintable(e->tick().print()));
1038-
if (e->isTrill() && ExportMusicXml::canWrite(e) && strack <= e->track() && e->track() < etrack
1037+
if (e->isTrill() && strack <= e->track() && e->track() < etrack
10391038
&& e->tick() >= measure->tick() && e->tick() < (measure->tick() + measure->ticks()))
10401039
{
10411040
//qDebug("2 trill %p", e);
@@ -2776,7 +2775,7 @@ void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& not
27762775
static void tremoloSingleStartStop(Chord* chord, Notations& notations, Ornaments& ornaments, XmlWriter& xml)
27772776
{
27782777
Tremolo* tr = chord->tremolo();
2779-
if (tr && ExportMusicXml::canWrite(tr)) {
2778+
if (tr) {
27802779
int count = 0;
27812780
TremoloType st = tr->tremoloType();
27822781
QString type;
@@ -2839,7 +2838,7 @@ static void tremoloSingleStartStop(Chord* chord, Notations& notations, Ornaments
28392838
static void fermatas(const QVector<Element*>& cra, XmlWriter& xml, Notations& notations)
28402839
{
28412840
for (const Element* e : cra) {
2842-
if (!e->isFermata() || !ExportMusicXml::canWrite(e))
2841+
if (!e->isFermata())
28432842
continue;
28442843
notations.tag(xml);
28452844
fermata(toFermata(e), xml);
@@ -3093,8 +3092,8 @@ static void writeChordLines(const Chord* const chord, XmlWriter& xml, Notations&
30933092
default:
30943093
qDebug("unknown ChordLine subtype %d", int(cl->chordLineType()));
30953094
}
3096-
subtype += color2xml(cl);
30973095
if (!subtype.isEmpty()) {
3096+
subtype += color2xml(cl);
30983097
notations.tag(xml);
30993098
articulations.tag(xml);
31003099
xml.tagE(subtype);
@@ -3109,7 +3108,7 @@ static void writeChordLines(const Chord* const chord, XmlWriter& xml, Notations&
31093108

31103109
static void writeBreathMark(const Breath* const breath, XmlWriter& xml, Notations& notations, Articulations& articulations)
31113110
{
3112-
if (breath && ExportMusicXml::canWrite(breath)) {
3111+
if (breath) {
31133112
QString tagName;
31143113
QString type;
31153114

@@ -3192,9 +3191,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
31923191
// first the attributes whose elements are children of <articulations>
31933192
Articulations articulations;
31943193
for (const Articulation* a : na) {
3195-
if (!ExportMusicXml::canWrite(a))
3196-
continue;
3197-
31983194
SymId sid = a->symId();
31993195
std::vector<QString> mxmlArtics = symIdToArtics(sid);
32003196

@@ -3229,8 +3225,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
32293225
// then the attributes whose elements are children of <ornaments>
32303226
Ornaments ornaments;
32313227
for (const Articulation* a : na) {
3232-
if (!ExportMusicXml::canWrite(a))
3233-
continue;
32343228
if (!a->isOrnament())
32353229
continue;
32363230

@@ -3257,9 +3251,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
32573251

32583252
// and finally the attributes whose elements are children of <technical>
32593253
for (const Articulation* a : na) {
3260-
if (!ExportMusicXml::canWrite(a))
3261-
continue;
3262-
32633254
SymId sid = a->symId();
32643255
QString placement;
32653256
QString direction;
@@ -3347,9 +3338,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
33473338

33483339
// check if all articulations were handled
33493340
for (const Articulation* a : na) {
3350-
if (!ExportMusicXml::canWrite(a))
3351-
continue;
3352-
33533341
SymId sid = a->symId();
33543342
if (symIdToArtics(sid).empty()
33553343
&& symIdToTechn(sid).isEmpty()
@@ -3389,9 +3377,6 @@ static Arpeggio* findArpeggio(Note* note)
33893377

33903378
static void arpeggiate(Arpeggio* arp, bool front, bool back, XmlWriter& xml, Notations& notations)
33913379
{
3392-
if (!ExportMusicXml::canWrite(arp))
3393-
return;
3394-
33953380
QString tagName;
33963381
switch (arp->arpeggioType()) {
33973382
case ArpeggioType::NORMAL:
@@ -3644,9 +3629,6 @@ static void writeNotehead(XmlWriter& xml, const Note* const note)
36443629
static void writeFingering(XmlWriter& xml, Notations& notations, Technical& technical, const Note* const note)
36453630
{
36463631
for (const Element* e : note->el()) {
3647-
if (!ExportMusicXml::canWrite(e))
3648-
continue;
3649-
36503632
if (e->type() == ElementType::FINGERING) {
36513633
const TextBase* f = toTextBase(e);
36523634
notations.tag(xml);
@@ -3999,17 +3981,17 @@ void ExportMusicXml::chord(Chord* chord, int staff, const std::vector<Lyrics*>*
39993981
Technical technical;
40003982

40013983
const Tie* tieBack = note->tieBack();
4002-
if (tieBack && ExportMusicXml::canWrite(tieBack)) {
3984+
if (tieBack) {
40033985
notations.tag(_xml);
40043986
_xml.tagE("tied type=\"stop\"");
40053987
}
40063988
const Tie* tieFor = note->tieFor();
4007-
if (tieFor && ExportMusicXml::canWrite(tieFor)) {
3989+
if (tieFor) {
40083990
notations.tag(_xml);
40093991
QString rest = slurTieLineStyle(tieFor);
40103992
_xml.tagE(QString("tied type=\"start\"%1").arg(rest));
40113993
}
4012-
if (hasLaissezVibrer(chord)/* && ExportMusicXml::canWrite(laissezVibrer)*/) {
3994+
if (hasLaissezVibrer(chord)) {
40133995
notations.tag(_xml);
40143996
_xml.tagE("tied type=\"let-ring\"");
40153997
}
@@ -4039,11 +4021,11 @@ void ExportMusicXml::chord(Chord* chord, int staff, const std::vector<Lyrics*>*
40394021
arpeggiate(arp, note == nl.front(), note == nl.back(), _xml, notations);
40404022
}
40414023
for (Spanner* spanner : note->spannerFor())
4042-
if (spanner->type() == ElementType::GLISSANDO && ExportMusicXml::canWrite(spanner)) {
4024+
if (spanner->type() == ElementType::GLISSANDO) {
40434025
gh.doGlissandoStart(static_cast<Glissando*>(spanner), notations, _xml);
40444026
}
40454027
for (Spanner* spanner : note->spannerBack())
4046-
if (spanner->type() == ElementType::GLISSANDO && ExportMusicXml::canWrite(spanner)) {
4028+
if (spanner->type() == ElementType::GLISSANDO) {
40474029
gh.doGlissandoStop(static_cast<Glissando*>(spanner), notations, _xml);
40484030
}
40494031
// write glissando (only for last note)
@@ -8207,17 +8189,4 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd
82078189
}
82088190
_xml.etag(); // harmony
82098191
}
8210-
//---------------------------------------------------------
8211-
// canWrite
8212-
//---------------------------------------------------------
8213-
8214-
/**
8215-
Whether a tag corresponding to the given element \p e
8216-
should be included to the exported MusicXML file.
8217-
*/
8218-
8219-
bool ExportMusicXml::canWrite(const Element* e)
8220-
{
8221-
return e->visible() || preferences.getBool(PREF_EXPORT_MUSICXML_EXPORTINVISIBLEELEMENTS);
8222-
}
82238192
}

0 commit comments

Comments
 (0)