Skip to content

Commit

Permalink
fix spanner handling when creating linked stave
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 24, 2014
1 parent 26bb716 commit cfac2f9
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions libmscore/excerpt.cpp
Expand Up @@ -202,6 +202,52 @@ Score* createExcerpt(const QList<Part*>& parts)
return score;
}

//---------------------------------------------------------
// cloneSpanner
//---------------------------------------------------------

static void cloneSpanner(Spanner* s, Score* score, int dstTrack, int dstTrack2)
{
Spanner* ns = static_cast<Spanner*>(s->linkedClone());
ns->setScore(score);
ns->setParent(0);
ns->setTrack(dstTrack);
ns->setTrack2(dstTrack2);
if (ns->type() == Element::Type::SLUR) {
//
// set start/end element for slur
//
ChordRest* cr1 = s->startCR();
ChordRest* cr2 = s->endCR();

ns->setStartElement(0);
ns->setEndElement(0);
for (Element* e : *cr1->links()) {
ChordRest* cr = static_cast<ChordRest*>(e);
if (cr == cr1)
continue;
if ((cr->score() == score) && (cr->tick() == ns->tick()) && cr->track() == dstTrack) {
ns->setStartElement(cr);
break;
}
}
for (Element* e : *cr2->links()) {
ChordRest* cr = static_cast<ChordRest*>(e);
if (cr == cr2)
continue;
if ((cr->score() == score) && (cr->tick() == ns->tick2()) && cr->track() == dstTrack2) {
ns->setEndElement(cr);
break;
}
}
if (!ns->startElement())
qDebug("clone Slur: no start element");
if (!ns->endElement())
qDebug("clone Slur: no end element");
}
score->addSpanner(ns);
}

//---------------------------------------------------------
// cloneStaves
//---------------------------------------------------------
Expand Down Expand Up @@ -435,44 +481,8 @@ void cloneStaves(Score* oscore, Score* score, const QList<int>& map)
}
if (dstTrack == -1)
continue;
Spanner* ns = static_cast<Spanner*>(s->linkedClone());
ns->setScore(score);
ns->setParent(0);
ns->setTrack(dstTrack);
ns->setTrack2(dstTrack2);
if (ns->type() == Element::Type::SLUR) {
//
// set start/end element for slur
//
ChordRest* cr1 = s->startCR();
ChordRest* cr2 = s->endCR();

ns->setStartElement(0);
ns->setEndElement(0);
for (Element* e : *cr1->links()) {
ChordRest* cr = static_cast<ChordRest*>(e);
if (cr == cr1)
continue;
if ((cr->score() == score) && (cr->tick() == ns->tick())) {
ns->setStartElement(cr);
break;
}
}
for (Element* e : *cr2->links()) {
ChordRest* cr = static_cast<ChordRest*>(e);
if (cr == cr2)
continue;
if ((cr->score() == score) && (cr->tick() == ns->tick2())) {
ns->setEndElement(cr);
break;
}
}
if (!ns->startElement())
qDebug("clone Slur: no start element");
if (!ns->endElement())
qDebug("clone Slur: no end element");
}
score->addSpanner(ns);

cloneSpanner(s, score, dstTrack, dstTrack2);
}
}

Expand Down Expand Up @@ -604,12 +614,7 @@ void cloneStaff(Staff* srcStaff, Staff* dstStaff)
}
if (dstTrack == -1)
continue;
Spanner* ns = static_cast<Spanner*>(s->linkedClone());
ns->setScore(score);
ns->setParent(0);
ns->setTrack(dstTrack);
ns->setTrack2(dstTrack2);
score->addSpanner(ns);
cloneSpanner(s, score, dstTrack, dstTrack2);
}
}

Expand Down Expand Up @@ -739,12 +744,7 @@ void cloneStaff2(Staff* srcStaff, Staff* dstStaff, int stick, int etick)
}
if (dstTrack == -1)
continue;
Spanner* ns = static_cast<Spanner*>(s->linkedClone());
ns->setScore(score);
ns->setParent(0);
ns->setTrack(dstTrack);
ns->setTrack2(dstTrack2);
score->addSpanner(ns);
cloneSpanner(s, score, dstTrack, dstTrack2);
}
}

Expand Down

0 comments on commit cfac2f9

Please sign in to comment.