Merge pull request #2717 from Rockettwo/gsoc_implode

Implode voices to voices
This commit is contained in:
Nicolas Froment 2016-09-29 10:34:30 +02:00 committed by GitHub
commit a5a97ff760
5 changed files with 2223 additions and 73 deletions

View file

@ -2855,88 +2855,115 @@ void Score::cmdImplode()
if (!selection().isRange())
return;
int dstStaff = selection().staffStart();
int endStaff = selection().staffEnd();
int dstStaff = selection().staffStart();
int endStaff = selection().staffEnd();
int dstTrack = dstStaff * VOICES;
int startTrack = dstStaff * VOICES;
int endTrack;
int trackInc;
// if single staff selected, combine voices
// otherwise combine staves
if (dstStaff == endStaff - 1) {
endTrack = startTrack + VOICES;
trackInc = 1;
}
else {
endTrack = endStaff * VOICES;
trackInc = VOICES;
}
int endTrack = endStaff * VOICES;
Segment* startSegment = selection().startSegment();
Segment* endSegment = selection().endSegment();
Measure* startMeasure = startSegment->measure();
Measure* endMeasure = endSegment ? endSegment->measure() : lastMeasure();
// loop through segments adding notes to chord on top staff
int dstTrack = dstStaff * VOICES;
for (Segment* s = startSegment; s && s != endSegment; s = s->next1()) {
if (s->segmentType() != Segment::Type::ChordRest)
continue;
Element* dst = s->element(dstTrack);
if (dst && dst->type() == Element::Type::CHORD) {
Chord* dstChord = toChord(dst);
// see if we are tying in to this chord
Chord* tied = 0;
foreach (Note* n, dstChord->notes()) {
if (n->tieBack()) {
tied = n->tieBack()->startNote()->chord();
break;
// if single staff selected, combine voices
// otherwise combine staves
if (dstStaff == endStaff - 1) {
// loop through segments adding notes to chord on top staff
for (Segment* s = startSegment; s && s != endSegment; s = s->next1()) {
if (!s->isChordRestType())
continue;
Element* dst = s->element(dstTrack);
if (dst && dst->isChord()) {
Chord* dstChord = toChord(dst);
// see if we are tying in to this chord
Chord* tied = 0;
for (Note* n : dstChord->notes()) {
if (n->tieBack()) {
tied = n->tieBack()->startNote()->chord();
break;
}
}
}
// loop through each subsequent staff (or track within staff)
// looking for notes to add
for (int srcTrack = startTrack + trackInc; srcTrack < endTrack; srcTrack += trackInc) {
Element* src = s->element(srcTrack);
if (src && src->type() == Element::Type::CHORD) {
Chord* srcChord = toChord(src);
// when combining voices, skip if not same duration
if ((trackInc == 1) && (srcChord->duration() != dstChord->duration()))
continue;
// add notes
foreach (Note* n, srcChord->notes()) {
NoteVal nv(n->pitch());
nv.tpc1 = n->tpc1();
// skip duplicates
if (dstChord->findNote(nv.pitch))
// loop through each subsequent staff (or track within staff)
// looking for notes to add
for (int srcTrack = startTrack + 1; srcTrack < endTrack; srcTrack++) {
Element* src = s->element(srcTrack);
if (src && src->isChord()) {
Chord* srcChord = toChord(src);
// when combining voices, skip if not same duration
if (srcChord->duration() != dstChord->duration())
continue;
Note* nn = addNote(dstChord, nv);
// add tie to this note if original chord was tied
if (tied) {
// find note to tie to
foreach (Note *tn, tied->notes()) {
if (nn->pitch() == tn->pitch() && nn->tpc() == tn->tpc() && !tn->tieFor()) {
// found note to tie
Tie* tie = new Tie(this);
tie->setStartNote(tn);
tie->setEndNote(nn);
tie->setTrack(tn->track());
undoAddElement(tie);
// add notes
for (Note* n : srcChord->notes()) {
NoteVal nv(n->pitch());
nv.tpc1 = n->tpc1();
// skip duplicates
if (dstChord->findNote(nv.pitch))
continue;
Note* nn = addNote(dstChord, nv);
// add tie to this note if original chord was tied
if (tied) {
// find note to tie to
for (Note *tn : tied->notes()) {
if (nn->pitch() == tn->pitch() && nn->tpc() == tn->tpc() && !tn->tieFor()) {
// found note to tie
Tie* tie = new Tie(this);
tie->setStartNote(tn);
tie->setEndNote(nn);
tie->setTrack(tn->track());
undoAddElement(tie);
}
}
}
}
}
// delete chordrest from source track if possible
if (src && src->voice())
undoRemoveElement(src);
}
}
else if (dst) {
// destination track has something, but it isn't a chord
// remove everything from other voices if in "voice mode"
for (int i = 1; i < VOICES; ++i) {
Element* e = s->element(dstTrack + i);
if (e)
undoRemoveElement(e);
}
// delete chordrest from source track if possible
if (src && src->voice())
undoRemoveElement(src);
}
}
else if (dst && trackInc == 1) {
// destination track has something, but it isn't a chord
// remove everything from other voices if in "voice mode"
for (int i = 1; i < VOICES; ++i) {
Element* e = s->element(dstTrack + i);
if (e)
undoRemoveElement(e);
}
else {
int tracks[VOICES];
for (int i = 0; i < VOICES; i++)
tracks[i] = -1;
int full = 0;
int lTick;
if (endSegment)
lTick = endSegment->tick();
else
lTick = lastMeasure()->endTick();
for (Segment* seg = startSegment; seg && seg->tick() < lTick; seg = seg->next1()) {
for (int i = startTrack; i < endTrack && full != VOICES; i++) {
bool t = true;
for (int j = 0; j < VOICES; j++) {
if (i == tracks[j]) {
t = false;
break;
}
}
if (!seg->measure()->hasVoice(i) || seg->measure()->isOnlyRests(i) || !t)
continue;
tracks[full] = i;
full++;
}
}
for (int i = dstTrack; i < dstTrack + VOICES; i++) {
int strack = tracks[i % VOICES];
if (strack != -1 && strack != i) {
undo( new CloneVoice(startSegment, lTick, startSegment, strack, i, i, false));
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,797 @@
<?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>4</lyricsMinBottomDistance>
<clefLeftMargin>0.64</clefLeftMargin>
<clefKeyRightMargin>1.75</clefKeyRightMargin>
<lastSystemFillLimit>0</lastSystemFillLimit>
<pedalY>0</pedalY>
<trillY>0</trillY>
<concertPitch>1</concertPitch>
<minMMRestWidth>0</minMMRestWidth>
<page-layout>
<page-height>1683.78</page-height>
<page-width>1190.55</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<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">implode1</metaTag>
<PageList>
<Page>
<System>
</System>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano</instrumentId>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
<midiPort>0</midiPort>
<midiChannel>1</midiChannel>
</Channel>
</Instrument>
</Part>
<Part>
<Staff id="2">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="-1" span="0"/>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<longName>Flute</longName>
<shortName>Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="73"/>
<midiPort>0</midiPort>
<midiChannel>0</midiChannel>
</Channel>
</Instrument>
</Part>
<Part>
<Staff id="3">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="-1" span="0"/>
</Staff>
<trackName>B♭ Trumpet</trackName>
<Instrument>
<longName>B♭ Trumpet</longName>
<shortName>B♭ Tpt.</shortName>
<trackName>B♭ Trumpet</trackName>
<minPitchP>52</minPitchP>
<maxPitchP>85</maxPitchP>
<minPitchA>52</minPitchA>
<maxPitchA>80</maxPitchA>
<transposeDiatonic>-1</transposeDiatonic>
<transposeChromatic>-2</transposeChromatic>
<instrumentId>brass.trumpet.bflat</instrumentId>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="56"/>
<midiPort>0</midiPort>
<midiChannel>2</midiChannel>
</Channel>
<Channel name="mute">
<program value="59"/>
<midiPort>0</midiPort>
<midiChannel>3</midiChannel>
</Channel>
</Instrument>
</Part>
<Part>
<Staff id="4">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<defaultClef>F</defaultClef>
<bracket type="-1" span="0"/>
</Staff>
<trackName>Tenor Trombone</trackName>
<Instrument>
<longName>Tenor Trombone</longName>
<shortName>T. Tbn.</shortName>
<trackName>Tenor Trombone</trackName>
<minPitchP>40</minPitchP>
<maxPitchP>74</maxPitchP>
<minPitchA>40</minPitchA>
<maxPitchA>70</maxPitchA>
<instrumentId>brass.trombone.tenor</instrumentId>
<clef>F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="57"/>
<midiPort>0</midiPort>
<midiChannel>4</midiChannel>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<Text>
<style>Title</style>
<text>implode1</text>
</Text>
</VBox>
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</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>
<Measure number="4">
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</Measure>
</Staff>
<Staff id="2">
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Chord>
<durationType>half</durationType>
<Articulation>
<subtype>fadeout</subtype>
</Articulation>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<HairPin id="2">
<subtype>0</subtype>
</HairPin>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>71</pitch>
<tpc>19</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>half</durationType>
<Note>
<pitch>69</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<endSpanner id="2"/>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
</Note>
</Chord>
</Measure>
<Measure number="3">
<Chord>
<durationType>half</durationType>
<Note>
<pitch>69</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Articulation>
<subtype>staccato</subtype>
</Articulation>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>eighth</durationType>
</Rest>
<Rest>
<durationType>quarter</durationType>
</Rest>
</Measure>
<Measure number="4">
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>74</pitch>
<tpc>16</tpc>
</Note>
</Chord>
</Measure>
</Staff>
<Staff id="3">
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Chord>
<durationType>quarter</durationType>
<Articulation>
<subtype>fadeout</subtype>
</Articulation>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
<tpc2>17</tpc2>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>77</pitch>
<tpc>13</tpc>
<tpc2>15</tpc2>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
<tpc2>20</tpc2>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>74</pitch>
<tpc>16</tpc>
<tpc2>18</tpc2>
</Note>
</Chord>
<move>0/1</move>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Articulation>
<subtype>fadeout</subtype>
<track>9</track>
</Articulation>
<Note>
<track>9</track>
<pitch>64</pitch>
<tpc>18</tpc>
<tpc2>20</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>69</pitch>
<tpc>17</tpc>
<tpc2>19</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>67</pitch>
<tpc>15</tpc>
<tpc2>17</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>64</pitch>
<tpc>18</tpc>
<tpc2>20</tpc2>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<dots>1</dots>
<durationType>quarter</durationType>
<Note>
<pitch>74</pitch>
<tpc>16</tpc>
<tpc2>18</tpc2>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
<tpc2>16</tpc2>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>71</pitch>
<tpc>19</tpc>
<tpc2>21</tpc2>
</Note>
</Chord>
<move>0/1</move>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>65</pitch>
<tpc>13</tpc>
<tpc2>15</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>60</pitch>
<tpc>14</tpc>
<tpc2>16</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>62</pitch>
<tpc>16</tpc>
<tpc2>18</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>quarter</durationType>
<Note>
<track>9</track>
<pitch>59</pitch>
<tpc>19</tpc>
<tpc2>21</tpc2>
</Note>
</Chord>
</Measure>
<Measure number="3">
<Chord>
<durationType>half</durationType>
<Note>
<pitch>69</pitch>
<tpc>17</tpc>
<tpc2>19</tpc2>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Articulation>
<subtype>staccato</subtype>
</Articulation>
<Note>
<pitch>69</pitch>
<tpc>17</tpc>
<tpc2>19</tpc2>
</Note>
</Chord>
<Rest>
<durationType>eighth</durationType>
</Rest>
<Rest>
<durationType>quarter</durationType>
</Rest>
<move>0/1</move>
<Chord>
<track>9</track>
<durationType>half</durationType>
<Note>
<track>9</track>
<pitch>60</pitch>
<tpc>14</tpc>
<tpc2>16</tpc2>
</Note>
</Chord>
<Chord>
<track>9</track>
<durationType>eighth</durationType>
<Articulation>
<subtype>staccato</subtype>
<track>9</track>
</Articulation>
<Note>
<track>9</track>
<pitch>65</pitch>
<tpc>13</tpc>
<tpc2>15</tpc2>
</Note>
</Chord>
<Rest>
<track>9</track>
<durationType>eighth</durationType>
</Rest>
<Rest>
<track>9</track>
<durationType>quarter</durationType>
</Rest>
</Measure>
<Measure number="4">
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>71</pitch>
<tpc>19</tpc>
<tpc2>21</tpc2>
</Note>
</Chord>
<move>0/1</move>
<Chord>
<track>9</track>
<durationType>whole</durationType>
<Note>
<track>9</track>
<pitch>64</pitch>
<tpc>18</tpc>
<tpc2>20</tpc2>
</Note>
</Chord>
</Measure>
</Staff>
<Staff id="4">
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Chord>
<durationType>half</durationType>
<Articulation>
<subtype>fadeout</subtype>
</Articulation>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Slur id="3">
<track>12</track>
</Slur>
<Beam id="1">
<l1>0</l1>
<l2>-1</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
<Beam>1</Beam>
<Slur type="start" id="3"/>
<Note>
<pitch>47</pitch>
<tpc>19</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Beam>1</Beam>
<Note>
<pitch>45</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Beam>1</Beam>
<Note>
<pitch>47</pitch>
<tpc>19</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Beam>1</Beam>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<move>0/1</move>
<Chord>
<track>13</track>
<durationType>quarter</durationType>
<Note>
<track>13</track>
<pitch>36</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>quarter</durationType>
<Slur type="stop" id="3"/>
<Note>
<pitch>50</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Beam id="2">
<l1>-5</l1>
<l2>-1</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
<Beam>2</Beam>
<Note>
<pitch>50</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Beam>2</Beam>
<Note>
<Tie id="4">
</Tie>
<pitch>41</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<endSpanner id="4"/>
<pitch>41</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Beam id="3">
<l1>-1</l1>
<l2>-5</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
<Beam>3</Beam>
<Note>
<pitch>43</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Beam>3</Beam>
<Note>
<Tie id="5">
</Tie>
<pitch>52</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</Measure>
<Measure number="3">
<Chord>
<durationType>half</durationType>
<Note>
<endSpanner id="5"/>
<pitch>52</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Articulation>
<subtype>staccato</subtype>
</Articulation>
<Note>
<pitch>50</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Rest>
<durationType>eighth</durationType>
</Rest>
<Rest>
<durationType>quarter</durationType>
</Rest>
</Measure>
<Measure number="4">
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -36,6 +36,9 @@ class TestImplodeExplode : public QObject, public MTest
void undoExplode();
void undoExplodeVoices();
void undoExplode1();
void undoImplode();
void undoImplodeVoice();
void implode1();
};
//---------------------------------------------------------
@ -80,7 +83,6 @@ void TestImplodeExplode::undoExplode()
delete score;
}
//---------------------------------------------------------
// undoExplodeVoices
//---------------------------------------------------------
@ -92,6 +94,19 @@ void TestImplodeExplode::undoExplodeVoices()
QString reference1(DIR + "undoExplode01-ref.mscx");
QString writeFile2("undoExplode02-test.mscx");
QString reference2(DIR + "undoExplode02-ref.mscx");
}
//---------------------------------------------------------
// undoImplode
//---------------------------------------------------------
void TestImplodeExplode::undoImplode()
{
QString readFile(DIR + "undoImplode.mscx");
QString writeFile1("undoImplode01-test.mscx");
QString reference1(DIR + "undoImplode01-ref.mscx");
QString writeFile2("undoImplode02-test.mscx");
QString reference2(DIR + "undoImplode02-ref.mscx");
MasterScore* score = readScore(readFile);
score->doLayout();
@ -103,7 +118,7 @@ void TestImplodeExplode::undoExplodeVoices()
// do
score->startCmd();
score->cmdExplode();
score->cmdImplode();
score->endCmd();
QVERIFY(saveCompareScore(score, writeFile1, reference1));
@ -125,7 +140,19 @@ void TestImplodeExplode::undoExplode1()
QString reference1(DIR + "explode1-ref.mscx");
QString writeFile2("explode1-test2.mscx");
QString reference2(DIR + "explode1-ref2.mscx");
}
//---------------------------------------------------------
// undoImplodeVoice
//---------------------------------------------------------
void TestImplodeExplode::undoImplodeVoice()
{
QString readFile(DIR + "undoImplodeVoice.mscx");
QString writeFile1("undoImplodeVoice01-test.mscx");
QString reference1(DIR + "undoImplodeVoice01-ref.mscx");
QString writeFile2("undoImplodeVoice02-test.mscx");
QString reference2(DIR + "undoImplodeVoice02-ref.mscx");
MasterScore* score = readScore(readFile);
score->doLayout();
@ -137,7 +164,7 @@ void TestImplodeExplode::undoExplode1()
// do
score->startCmd();
score->cmdExplode();
score->cmdImplode();
score->endCmd();
QVERIFY(saveCompareScore(score, writeFile1, reference1));
@ -148,6 +175,38 @@ void TestImplodeExplode::undoExplode1()
delete score;
}
//---------------------------------------------------------
// implode1
//---------------------------------------------------------
void TestImplodeExplode::implode1()
{
QString readFile(DIR + "implode1.mscx");
QString writeFile1("implode1-test1.mscx");
QString writeFile2("implode1-test2.mscx");
QString reference(DIR + "implode1-ref.mscx");
MasterScore* score = readScore(readFile);
score->doLayout();
// select all
score->startCmd();
score->cmdSelectAll();
score->endCmd();
// do
score->startCmd();
score->cmdImplode();
score->endCmd();
QVERIFY(saveCompareScore(score, writeFile1, reference));
// undo
score->undoStack()->undo();
QVERIFY(saveCompareScore(score, writeFile2, readFile));
delete score;
}
QTEST_MAIN(TestImplodeExplode)
#include "tst_implodeExplode.moc"

8
mtest/libmscore/implode_explode/undoImplode01-ref.mscx Normal file → Executable file
View file

@ -279,7 +279,8 @@
<Note>
<track>1</track>
<Accidental>
<subtype>accidentalSharp</subtype
<subtype>accidentalSharp</subtype>
<track>1</track>
</Accidental>
<pitch>70</pitch>
<tpc>24</tpc>
@ -333,7 +334,8 @@
<Note>
<track>2</track>
<Accidental>
<subtype>accidentalSharp</subtype
<subtype>accidentalSharp</subtype>
<track>2</track>
</Accidental>
<pitch>66</pitch>
<tpc>20</tpc>
@ -423,7 +425,7 @@
<Note>
<track>2</track>
<Accidental>
<subtype>flat</subtype>
<subtype>accidentalFlat</subtype>
<track>2</track>
</Accidental>
<pitch>68</pitch>