@@ -192,7 +192,7 @@ class Notations {
192
192
193
193
public:
194
194
Notations () { notationsPrinted = false ; }
195
- void tag (XmlWriter& xml);
195
+ void tag (XmlWriter& xml, const Element* e );
196
196
void etag (XmlWriter& xml);
197
197
};
198
198
@@ -525,11 +525,20 @@ static QString positioningAttributes(Element const* const el, bool isSpanStart =
525
525
// tag
526
526
// ---------------------------------------------------------
527
527
528
- void Notations::tag (XmlWriter& xml)
528
+ void Notations::tag (XmlWriter& xml, const Element* e )
529
529
{
530
- if (!notationsPrinted)
531
- xml.stag (" notations" );
530
+ // if (notationsPrinted && _prevElementVisible != e->visible())
531
+ // etag(xml);
532
+
533
+ if (!notationsPrinted) {
534
+ if (e->visible ())
535
+ xml.stag (" notations" );
536
+ else
537
+ xml.stag (" notations print-object=\" no\" " );
538
+ }
539
+
532
540
notationsPrinted = true ;
541
+ // _prevElementVisible = e->visible();
533
542
}
534
543
535
544
// ---------------------------------------------------------
@@ -784,7 +793,7 @@ void SlurHandler::doSlurs(const ChordRest* chordRest, Notations& notations, XmlW
784
793
// search for slur(s) starting or stopping at this chord
785
794
for (const auto & it : chordRest->score ()->spanner ()) {
786
795
auto sp = it.second ;
787
- if (sp->generated () || sp->type () != ElementType::SLUR || ! ExportMusicXml::canWrite (sp) )
796
+ if (sp->generated () || sp->type () != ElementType::SLUR)
788
797
continue ;
789
798
if (chordRest == sp->startElement () || chordRest == sp->endElement ()) {
790
799
const Slur* s = static_cast <const Slur*>(sp);
@@ -824,7 +833,7 @@ void SlurHandler::doSlurStart(const Slur* s, Notations& notations, XmlWriter& xm
824
833
// remove from list and print start
825
834
slur[i] = 0 ;
826
835
started[i] = false ;
827
- notations.tag (xml);
836
+ notations.tag (xml, s );
828
837
tagName += QString (" number=\" %1\" " ).arg (i + 1 );
829
838
xml.tagE (tagName);
830
839
}
@@ -834,7 +843,7 @@ void SlurHandler::doSlurStart(const Slur* s, Notations& notations, XmlWriter& xm
834
843
if (i >= 0 ) {
835
844
slur[i] = s;
836
845
started[i] = true ;
837
- notations.tag (xml);
846
+ notations.tag (xml, s );
838
847
tagName += QString (" number=\" %1\" " ).arg (i + 1 );
839
848
xml.tagE (tagName);
840
849
}
@@ -863,7 +872,7 @@ void SlurHandler::doSlurStop(const Slur* s, Notations& notations, XmlWriter& xml
863
872
if (i >= 0 ) {
864
873
slur[i] = s;
865
874
started[i] = false ;
866
- notations.tag (xml);
875
+ notations.tag (xml, s );
867
876
QString tagName = QString (" slur type=\" stop\" number=\" %1\" " ).arg (i + 1 );
868
877
tagName += positioningAttributes (s, false );
869
878
xml.tagE (tagName);
@@ -875,7 +884,7 @@ void SlurHandler::doSlurStop(const Slur* s, Notations& notations, XmlWriter& xml
875
884
// found (already started), stop it and remove from list
876
885
slur[i] = 0 ;
877
886
started[i] = false ;
878
- notations.tag (xml);
887
+ notations.tag (xml, s );
879
888
QString tagName = QString (" slur type=\" stop\" number=\" %1\" " ).arg (i + 1 );
880
889
tagName += positioningAttributes (s, false );
881
890
xml.tagE (tagName);
@@ -922,7 +931,7 @@ static void glissando(const Glissando* gli, int number, bool start, Notations& n
922
931
tagName += color2xml (gli);
923
932
tagName += positioningAttributes (gli, start);
924
933
}
925
- notations.tag (xml);
934
+ notations.tag (xml, gli );
926
935
if (start && gli->showText () && !gli->text ().isEmpty ())
927
936
xml.tag (tagName, gli->text ());
928
937
else
@@ -1051,7 +1060,7 @@ static void findTrills(const Measure* const measure, int strack, int etrack, Tri
1051
1060
for (auto it = measure->score ()->spanner ().lower_bound (stick.ticks ()); it != measure->score ()->spanner ().upper_bound (etick.ticks ()); ++it) {
1052
1061
Element* e = it->second ;
1053
1062
// qDebug("1 trill %p type %d track %d tick %s", e, e->type(), e->track(), qPrintable(e->tick().print()));
1054
- if (e->isTrill () && ExportMusicXml::canWrite (e) && strack <= e->track () && e->track () < etrack
1063
+ if (e->isTrill () && strack <= e->track () && e->track () < etrack
1055
1064
&& e->tick () >= measure->tick () && e->tick () < (measure->tick () + measure->ticks ()))
1056
1065
{
1057
1066
// qDebug("2 trill %p", e);
@@ -2550,7 +2559,7 @@ static void tupletActualAndNormal(const Tuplet* const t, XmlWriter& xml)
2550
2559
2551
2560
static void tupletStart (const Tuplet* const t, const int number, const bool needActualAndNormal, Notations& notations, XmlWriter& xml)
2552
2561
{
2553
- notations.tag (xml);
2562
+ notations.tag (xml, t );
2554
2563
QString tupletTag = " tuplet type=\" start\" " ;
2555
2564
if (!isSimpleTuplet (t))
2556
2565
tupletTag += QString (" number=\" %1\" " ).arg (number);
@@ -2581,7 +2590,7 @@ static void tupletStart(const Tuplet* const t, const int number, const bool need
2581
2590
2582
2591
static void tupletStop (const Tuplet* const t, const int number, Notations& notations, XmlWriter& xml)
2583
2592
{
2584
- notations.tag (xml);
2593
+ notations.tag (xml, t );
2585
2594
QString tupletTag = " tuplet type=\" stop\" " ;
2586
2595
if (!isSimpleTuplet (t))
2587
2596
tupletTag += QString (" number=\" %1\" " ).arg (number);
@@ -2695,7 +2704,7 @@ static void writeDisplayName(XmlWriter& xml, const QString& partName)
2695
2704
2696
2705
static void wavyLineStart (const Trill* tr, const int number, Notations& notations, Ornaments& ornaments, XmlWriter& xml)
2697
2706
{
2698
- notations.tag (xml);
2707
+ notations.tag (xml, tr );
2699
2708
ornaments.tag (xml);
2700
2709
switch (tr->trillType ()) {
2701
2710
case Trill::Type::TRILL_LINE:
@@ -2725,7 +2734,7 @@ static void wavyLineStart(const Trill* tr, const int number, Notations& notation
2725
2734
2726
2735
static void wavyLineStop (const Trill* tr, const int number, Notations& notations, Ornaments& ornaments, XmlWriter& xml)
2727
2736
{
2728
- notations.tag (xml);
2737
+ notations.tag (xml, tr );
2729
2738
ornaments.tag (xml);
2730
2739
QString trillXml = QString (" wavy-line type=\" stop\" number=\" %1\" " ).arg (number + 1 );
2731
2740
trillXml += positioningAttributes (tr, false );
@@ -2798,7 +2807,7 @@ void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& not
2798
2807
static void tremoloSingleStartStop (Chord* chord, Notations& notations, Ornaments& ornaments, XmlWriter& xml)
2799
2808
{
2800
2809
Tremolo* tr = chord->tremolo ();
2801
- if (tr && ExportMusicXml::canWrite (tr) ) {
2810
+ if (tr) {
2802
2811
int count = 0 ;
2803
2812
TremoloType st = tr->tremoloType ();
2804
2813
QString type;
@@ -2843,7 +2852,7 @@ static void tremoloSingleStartStop(Chord* chord, Notations& notations, Ornaments
2843
2852
2844
2853
2845
2854
if (!type.isEmpty () && ((count > 0 && type != " unmeasured" ) || (count == 0 && type == " unmeasured" ))) {
2846
- notations.tag (xml);
2855
+ notations.tag (xml, tr );
2847
2856
ornaments.tag (xml);
2848
2857
QString tagName = " tremolo" ;
2849
2858
tagName += QString (" type=\" %1\" " ).arg (type);
@@ -2861,9 +2870,9 @@ static void tremoloSingleStartStop(Chord* chord, Notations& notations, Ornaments
2861
2870
static void fermatas (const QVector<Element*>& cra, XmlWriter& xml, Notations& notations)
2862
2871
{
2863
2872
for (const Element* e : cra) {
2864
- if (!e->isFermata () || ! ExportMusicXml::canWrite (e) )
2873
+ if (!e->isFermata ())
2865
2874
continue ;
2866
- notations.tag (xml);
2875
+ notations.tag (xml, e );
2867
2876
fermata (toFermata (e), xml);
2868
2877
}
2869
2878
}
@@ -3115,9 +3124,9 @@ static void writeChordLines(const Chord* const chord, XmlWriter& xml, Notations&
3115
3124
default :
3116
3125
qDebug (" unknown ChordLine subtype %d" , int (cl->chordLineType ()));
3117
3126
}
3118
- subtype += color2xml (cl);
3119
3127
if (!subtype.isEmpty ()) {
3120
- notations.tag (xml);
3128
+ subtype += color2xml (cl);
3129
+ notations.tag (xml, cl);
3121
3130
articulations.tag (xml);
3122
3131
xml.tagE (subtype);
3123
3132
}
@@ -3131,11 +3140,11 @@ static void writeChordLines(const Chord* const chord, XmlWriter& xml, Notations&
3131
3140
3132
3141
static void writeBreathMark (const Breath* const breath, XmlWriter& xml, Notations& notations, Articulations& articulations)
3133
3142
{
3134
- if (breath && ExportMusicXml::canWrite (breath) ) {
3143
+ if (breath) {
3135
3144
QString tagName;
3136
3145
QString type;
3137
3146
3138
- notations.tag (xml);
3147
+ notations.tag (xml, breath );
3139
3148
articulations.tag (xml);
3140
3149
if (breath->isCaesura ()) {
3141
3150
tagName = " caesura" ;
@@ -3214,9 +3223,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3214
3223
// first the attributes whose elements are children of <articulations>
3215
3224
Articulations articulations;
3216
3225
for (const Articulation* a : na) {
3217
- if (!ExportMusicXml::canWrite (a))
3218
- continue ;
3219
-
3220
3226
SymId sid = a->symId ();
3221
3227
std::vector<QString> mxmlArtics = symIdToArtics (sid);
3222
3228
@@ -3237,7 +3243,7 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3237
3243
mxmlArtic += color2xml (a);
3238
3244
mxmlArtic += positioningAttributes (a);
3239
3245
3240
- notations.tag (_xml);
3246
+ notations.tag (_xml, a );
3241
3247
articulations.tag (_xml);
3242
3248
_xml.tagE (mxmlArtic);
3243
3249
}
@@ -3251,8 +3257,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3251
3257
// then the attributes whose elements are children of <ornaments>
3252
3258
Ornaments ornaments;
3253
3259
for (const Articulation* a : na) {
3254
- if (!ExportMusicXml::canWrite (a))
3255
- continue ;
3256
3260
if (!a->isOrnament ())
3257
3261
continue ;
3258
3262
@@ -3266,7 +3270,7 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3266
3270
mxmlOrnam += QString (" placement=\" %1\" " ).arg (placement);
3267
3271
mxmlOrnam += color2xml (a);
3268
3272
3269
- notations.tag (_xml);
3273
+ notations.tag (_xml, a );
3270
3274
ornaments.tag (_xml);
3271
3275
_xml.tagE (mxmlOrnam);
3272
3276
// accidental-mark is missing
@@ -3279,9 +3283,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3279
3283
3280
3284
// and finally the attributes whose elements are children of <technical>
3281
3285
for (const Articulation* a : na) {
3282
- if (!ExportMusicXml::canWrite (a))
3283
- continue ;
3284
-
3285
3286
SymId sid = a->symId ();
3286
3287
QString placement;
3287
3288
QString direction;
@@ -3303,7 +3304,7 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3303
3304
3304
3305
QString mxmlTechn = symIdToTechn (sid);
3305
3306
if (!mxmlTechn.isEmpty ()) {
3306
- notations.tag (_xml);
3307
+ notations.tag (_xml, a );
3307
3308
technical.tag (_xml);
3308
3309
mxmlTechn += color2xml (a);
3309
3310
mxmlTechn += positioningAttributes (a);
@@ -3369,9 +3370,6 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
3369
3370
3370
3371
// check if all articulations were handled
3371
3372
for (const Articulation* a : na) {
3372
- if (!ExportMusicXml::canWrite (a))
3373
- continue ;
3374
-
3375
3373
SymId sid = a->symId ();
3376
3374
if (symIdToArtics (sid).empty ()
3377
3375
&& symIdToTechn (sid).isEmpty ()
@@ -3411,32 +3409,29 @@ static Arpeggio* findArpeggio(Note* note)
3411
3409
3412
3410
static void arpeggiate (Arpeggio* arp, bool front, bool back, XmlWriter& xml, Notations& notations)
3413
3411
{
3414
- if (!ExportMusicXml::canWrite (arp))
3415
- return ;
3416
-
3417
3412
QString tagName;
3418
3413
switch (arp->arpeggioType ()) {
3419
3414
case ArpeggioType::NORMAL:
3420
- notations.tag (xml);
3415
+ notations.tag (xml, arp );
3421
3416
tagName = " arpeggiate" ;
3422
3417
break ;
3423
3418
case ArpeggioType::UP: // fall through
3424
3419
case ArpeggioType::UP_STRAIGHT: // not supported by MusicXML, export as normal arpeggio
3425
- notations.tag (xml);
3420
+ notations.tag (xml, arp );
3426
3421
tagName = " arpeggiate direction=\" up\" " ;
3427
3422
break ;
3428
3423
case ArpeggioType::DOWN: // fall through
3429
3424
case ArpeggioType::DOWN_STRAIGHT: // not supported by MusicXML, export as normal arpeggio
3430
- notations.tag (xml);
3425
+ notations.tag (xml, arp );
3431
3426
tagName = " arpeggiate direction=\" down\" " ;
3432
3427
break ;
3433
3428
case ArpeggioType::BRACKET:
3434
3429
if (front) {
3435
- notations.tag (xml);
3430
+ notations.tag (xml, arp );
3436
3431
tagName = " non-arpeggiate type=\" bottom\" " ;
3437
3432
}
3438
3433
if (back) {
3439
- notations.tag (xml);
3434
+ notations.tag (xml, arp );
3440
3435
tagName = " non-arpeggiate type=\" top\" " ;
3441
3436
}
3442
3437
break ;
@@ -3666,12 +3661,9 @@ static void writeNotehead(XmlWriter& xml, const Note* const note)
3666
3661
static void writeFingering (XmlWriter& xml, Notations& notations, Technical& technical, const Note* const note)
3667
3662
{
3668
3663
for (const Element* e : note->el ()) {
3669
- if (!ExportMusicXml::canWrite (e))
3670
- continue ;
3671
-
3672
3664
if (e->type () == ElementType::FINGERING) {
3673
3665
const TextBase* f = toTextBase (e);
3674
- notations.tag (xml);
3666
+ notations.tag (xml, e );
3675
3667
technical.tag (xml);
3676
3668
QString t = MScoreTextToMXML::toPlainText (f->xmlText ());
3677
3669
QString attr;
@@ -4021,18 +4013,18 @@ void ExportMusicXml::chord(Chord* chord, int staff, const std::vector<Lyrics*>*
4021
4013
Technical technical;
4022
4014
4023
4015
const Tie* tieBack = note->tieBack ();
4024
- if (tieBack && ExportMusicXml::canWrite (tieBack) ) {
4025
- notations.tag (_xml);
4016
+ if (tieBack) {
4017
+ notations.tag (_xml, tieBack );
4026
4018
_xml.tagE (" tied type=\" stop\" " );
4027
4019
}
4028
4020
const Tie* tieFor = note->tieFor ();
4029
- if (tieFor && ExportMusicXml::canWrite (tieFor) ) {
4030
- notations.tag (_xml);
4021
+ if (tieFor) {
4022
+ notations.tag (_xml, tieFor );
4031
4023
QString rest = slurTieLineStyle (tieFor);
4032
4024
_xml.tagE (QString (" tied type=\" start\" %1" ).arg (rest));
4033
4025
}
4034
- if (hasLaissezVibrer (chord)/* && ExportMusicXml::canWrite(laissezVibrer) */ ) {
4035
- notations.tag (_xml);
4026
+ if (hasLaissezVibrer (chord)) {
4027
+ notations.tag (_xml, tieFor );
4036
4028
_xml.tagE (" tied type=\" let-ring\" " );
4037
4029
}
4038
4030
@@ -4050,7 +4042,7 @@ void ExportMusicXml::chord(Chord* chord, int staff, const std::vector<Lyrics*>*
4050
4042
// write tablature string / fret
4051
4043
if (chord->staff () && chord->staff ()->isTabStaff (Fraction (0 ,1 )))
4052
4044
if (note->fret () >= 0 && note->string () >= 0 ) {
4053
- notations.tag (_xml);
4045
+ notations.tag (_xml, note );
4054
4046
technical.tag (_xml);
4055
4047
_xml.tag (" string" , note->string () + 1 );
4056
4048
_xml.tag (" fret" , note->fret ());
@@ -4061,11 +4053,11 @@ void ExportMusicXml::chord(Chord* chord, int staff, const std::vector<Lyrics*>*
4061
4053
arpeggiate (arp, note == nl.front (), note == nl.back (), _xml, notations);
4062
4054
}
4063
4055
for (Spanner* spanner : note->spannerFor ())
4064
- if (spanner->type () == ElementType::GLISSANDO && ExportMusicXml::canWrite (spanner) ) {
4056
+ if (spanner->type () == ElementType::GLISSANDO) {
4065
4057
gh.doGlissandoStart (static_cast <Glissando*>(spanner), notations, _xml);
4066
4058
}
4067
4059
for (Spanner* spanner : note->spannerBack ())
4068
- if (spanner->type () == ElementType::GLISSANDO && ExportMusicXml::canWrite (spanner) ) {
4060
+ if (spanner->type () == ElementType::GLISSANDO) {
4069
4061
gh.doGlissandoStop (static_cast <Glissando*>(spanner), notations, _xml);
4070
4062
}
4071
4063
// write glissando (only for last note)
@@ -5813,6 +5805,9 @@ static void measureStyle(XmlWriter& xml, Attributes& attr, const Measure* const
5813
5805
5814
5806
static bool commonAnnotations (ExportMusicXml* exp, const Element* e, int sstaff)
5815
5807
{
5808
+ if (!exp ->canWrite (e))
5809
+ return false ;
5810
+
5816
5811
bool instrChangeHandled = false ;
5817
5812
5818
5813
// note: the instrument change details are handled in ExportMusicXml::writeMeasureTracks,
@@ -7595,7 +7590,7 @@ void ExportMusicXml::writeMeasure(const Measure* const m,
7595
7590
writeInstrumentDetails (part->instrument (), _score->styleB (Sid::concertPitch));
7596
7591
}
7597
7592
else {
7598
- for (size_t staffIdx : _hiddenStaves) {
7593
+ for (int & staffIdx : _hiddenStaves) {
7599
7594
_attr.doAttr (_xml, true );
7600
7595
QString attributes;
7601
7596
if (staves > 1 )
0 commit comments