Skip to content

Commit

Permalink
Fix #275259: add ability to read pedal from old score
Browse files Browse the repository at this point in the history
1) add pedal to unit tests

2) add textline to unit tests

3) add ottava to unit tests
  • Loading branch information
handrok committed Aug 20, 2018
1 parent c27d0e6 commit d04f0e3
Show file tree
Hide file tree
Showing 9 changed files with 1,092 additions and 7 deletions.
14 changes: 8 additions & 6 deletions libmscore/pedal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,14 @@ QPointF Pedal::linePos(Grip grip, System** sys) const
System* s = nullptr;
if (grip == Grip::START) {
ChordRest* c = toChordRest(startElement());
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
if (c->type() == ElementType::REST && c->durationType() == TDuration::DurationType::V_MEASURE)
x -= c->x();
if (beginHookType() == HookType::HOOK_45)
x += nhw * .5;
if (c) {
s = c->segment()->system();
x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
if (c->type() == ElementType::REST && c->durationType() == TDuration::DurationType::V_MEASURE)
x -= c->x();
if (beginHookType() == HookType::HOOK_45)
x += nhw * .5;
}
}
else {
Element* e = endElement();
Expand Down
36 changes: 35 additions & 1 deletion libmscore/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "textframe.h"
#include "jump.h"
#include "textline.h"
#include "pedal.h"

namespace Ms {

Expand Down Expand Up @@ -1305,6 +1306,37 @@ static void readTextLine114(XmlReader& e, TextLine* textLine)
e.unknown();
}
}

//---------------------------------------------------------
// readPedal114
//---------------------------------------------------------

static void readPedal114(XmlReader& e, Pedal* pedal)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "beginSymbol"
|| tag == "beginSymbolOffset"
|| tag == "endSymbol"
|| tag == "endSymbolOffset"
|| tag == "subtype"
)
e.skipCurrentElement();
else if (tag == "endHookHeight" || tag == "hookHeight") { // hookHeight is obsolete
pedal->setEndHookHeight(Spatium(e.readDouble()));
}
else if (tag == "lineWidth") {
pedal->setLineWidth(qreal(e.readDouble()));
}
else if (tag == "lineStyle") {
pedal->setLineStyle(Qt::PenStyle(e.readInt()));
}
else if (!readTextLineProperties114(e, pedal))
e.unknown();
}
pedal->setBeginText("<sym>keyboardPedalPed</sym>");
}

//---------------------------------------------------------
// readHarmony114
//---------------------------------------------------------
Expand Down Expand Up @@ -2881,6 +2913,8 @@ Score::FileError MasterScore::read114(XmlReader& e)
readOttava114(e, toOttava(s));
else if (tag == "TextLine")
readTextLine114(e, toTextLine(s));
else if (tag == "Pedal")
readPedal114(e, toPedal(s));
else
s->read(e);
if (s->track() == -1)
Expand All @@ -2894,8 +2928,8 @@ Score::FileError MasterScore::read114(XmlReader& e)
if (s->track2() == -1)
s->setTrack2(s->track());
if (s->ticks() == 0) {
delete s;
qDebug("zero spanner %s ticks: %d", s->name(), s->ticks());
delete s;
}
else {
addSpanner(s);
Expand Down
169 changes: 169 additions & 0 deletions mtest/libmscore/compat114/ottava-ref.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<lyricsMinBottomDistance>6</lyricsMinBottomDistance>
<minMeasureWidth>4</minMeasureWidth>
<endBarDistance>0.3</endBarDistance>
<bracketWidth>0.35</bracketWidth>
<bracketDistance>0.25</bracketDistance>
<clefLeftMargin>0.5</clefLeftMargin>
<clefKeyRightMargin>1.75</clefKeyRightMargin>
<clefBarlineDistance>0.18</clefBarlineDistance>
<minNoteDistance>0.4</minNoteDistance>
<barNoteDistance>1.2</barNoteDistance>
<measureSpacing>1.14</measureSpacing>
<ledgerLineWidth>0.12</ledgerLineWidth>
<beamWidth>0.48</beamWidth>
<beamMinLen>1.25</beamMinLen>
<propertyDistanceStem>0.5</propertyDistanceStem>
<chordStyle>custom</chordStyle>
<chordsXmlFile>1</chordsXmlFile>
<chordDescriptionFile>stdchords.xml</chordDescriptionFile>
<hideInstrumentNameIfOneInstrument>0</hideInstrumentNameIfOneInstrument>
<voltaY>0</voltaY>
<keySigNaturals>1</keySigNaturals>
<tupletOufOfStaff>0</tupletOufOfStaff>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
</StaffType>
<bracket type="1" span="2" col="0"/>
<barLineSpan>2</barLineSpan>
</Staff>
<Staff id="2">
<StaffType group="pitched">
</StaffType>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<longName><font face="Times New Roman"/>Piano</longName>
<shortName><font face="Times New Roman"/>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Ottava id="2">
<subtype>8va</subtype>
<beginText>&lt;font size=&quot;12&quot;/&gt;&lt;font face=&quot;Times New Roman&quot;/&gt;&lt;i&gt;8va&lt;/i&gt;</beginText>
<continueText>&lt;font size=&quot;12&quot;/&gt;&lt;font face=&quot;Times New Roman&quot;/&gt;&lt;i&gt;(8va)&lt;/i&gt;</continueText>
<endHookHeight>1.5</endHookHeight>
<lineWidth>0.15</lineWidth>
<lineStyle>1</lineStyle>
</Ottava>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Rest>
<durationType>quarter</durationType>
</Rest>
<Rest>
<durationType>half</durationType>
</Rest>
</Measure>
<Measure number="2">
<endSpanner id="2"/>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</Measure>
<Measure number="3">
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
</Staff>
<Staff id="2">
<Measure number="1">
<Clef>
<concertClefType>F</concertClefType>
<transposingClefType>F</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</Measure>
<Measure number="2">
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</Measure>
<Measure number="3">
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</Measure>
</Staff>
</Score>
</museScore>
Loading

0 comments on commit d04f0e3

Please sign in to comment.