Skip to content

Commit

Permalink
fix import regressions; remove debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jun 25, 2013
1 parent 7c1f1c0 commit f227ab7
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 145 deletions.
2 changes: 1 addition & 1 deletion libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ bool ChordRest::readProperties(XmlReader& e)
slur->setAnchor(Spanner::ANCHOR_SEGMENT);
}
else if (atype == "stop") {
slur->setTickLen(e.tick() - slur->tick());
slur->setTick2(e.tick());
slur->setEndElement(this);
Chord* start = static_cast<Chord*>(slur->startElement());
if (start)
Expand Down
8 changes: 4 additions & 4 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void Score::cmdAddSpanner(Spanner* spanner, const QPointF& pos)
delete spanner;
return;
}
spanner->setTickLen(ns->tick() - spanner->tick());
spanner->setTick2(ns->tick());
}
else { // ANCHOR_MEASURE
Measure* m = static_cast<Measure*>(mb);
Expand All @@ -252,7 +252,7 @@ void Score::cmdAddSpanner(Spanner* spanner, const QPointF& pos)
if (pos.x() >= (b.x() + b.width() * .5))
m = m->nextMeasure();
spanner->setTick(m->tick());
spanner->setTickLen(m->ticks());
spanner->setTick2(m->endTick());
}

undoAddElement(spanner);
Expand Down Expand Up @@ -280,7 +280,7 @@ void Score::cmdAddSpanner(Spanner* spanner, const QPointF& pos)
s = s->next1(Segment::SegChordRest);
}
if (s)
spanner->setTickLen(s->tick() - spanner->tick());
spanner->setTick2(s->tick());
Fraction d(1,32);
Fraction e = l / d;
int n = e.numerator() / e.denominator();
Expand Down Expand Up @@ -437,7 +437,7 @@ printf("add pitch %d add %d repitch %d\n", pitch, addFlag, _is.repitchMode());
_is.slur->setTick(stick);
}
else
_is.slur->setTickLen(e->tick() - _is.slur->tick());
_is.slur->setTick2(e->tick());
}
else
qDebug("addPitch: cannot find slur note");
Expand Down
2 changes: 1 addition & 1 deletion libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ void Score::cmdAddHairpin(bool decrescendo)
pin->setHairpinType(decrescendo ? Hairpin::DECRESCENDO : Hairpin::CRESCENDO);
pin->setTrack(cr1->track());
pin->setTick(cr1->segment()->tick());
pin->setTickLen(cr2->segment()->tick() - pin->tick());
pin->setTick2(cr2->segment()->tick());
pin->setParent(cr1->segment());
undoAddElement(pin);
if (!noteEntryMode())
Expand Down
16 changes: 5 additions & 11 deletions libmscore/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ bool LineSegment::edit(MuseScoreView* sv, int curGrip, int key, Qt::KeyboardModi
if (key == Qt::Key_Left)
ls = l->takeLastSegment();
}
l->setTickLen(m2->tick() - l->tick());
l->setTick2(m2->tick());
}
}
l->layout();
Expand Down Expand Up @@ -655,16 +655,10 @@ bool SLine::readProperties(XmlReader& e)
{
const QStringRef& tag(e.name());

if (tag == "tick2") {
int tick2 = e.readInt();
setTickLen(tick() == -1 ? tick2 : tick2 - tick());
}
else if (tag == "tick") {
int tick1 = e.readInt();
if (tickLen() != -1)
setTickLen(tickLen() - tick1);
setTick(tick1);
}
if (tag == "tick2") // obsolete
setTick2(e.readInt());
else if (tag == "tick") // obsolete
setTick(e.readInt());
else if (tag == "Segment") {
LineSegment* ls = createLineSegment();
ls->read(e);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ void Measure::read(XmlReader& e, int staffIdx)
int id = e.attribute("id").toInt();
Spanner* spanner = score()->findSpanner(id);
if (spanner) {
spanner->setTickLen(e.tick() - spanner->tick());
spanner->setTick2(e.tick());
if (spanner->type() == OTTAVA) {
Ottava* o = static_cast<Ottava*>(spanner);
int shift = o->pitchShift();
Expand Down
2 changes: 1 addition & 1 deletion libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static const PropertyData propertyList[] = {
{ P_TIMESIG_GLOBAL, false, 0, T_FRACTION },

{ P_SPANNER_TICK, true, "tick", T_INT },
{ P_SPANNER_TICKLEN, true, "tickLen", T_INT },
{ P_SPANNER_TICK2, true, "tick2", T_INT },
{ P_USER_OFF2, false, "userOff2", T_POINT },

{ P_END, false, "", T_INT }
Expand Down
2 changes: 1 addition & 1 deletion libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ enum P_ID {
P_TIMESIG_GLOBAL,

P_SPANNER_TICK,
P_SPANNER_TICKLEN,
P_SPANNER_TICK2,
P_USER_OFF2,

P_END
Expand Down
75 changes: 9 additions & 66 deletions libmscore/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ Score::FileError Score::read114(XmlReader& e)
}
qDeleteAll(e.clefListList());

#if 0 // TODO-S
foreach(Spanner* s, e.spanner()) {
for (std::pair<int,Spanner*> p : spanner()) {
Spanner* s = p.second;
if (s->type() == Element::OTTAVA
|| (s->type() == Element::TEXTLINE)
|| (s->type() == Element::VOLTA)
Expand All @@ -529,71 +529,10 @@ Score::FileError Score::read114(XmlReader& e)
tl->setEndSymbol(resolveSymCompatibility(tl->endSymbol(), mscoreVersion()));
}

if (s->type() == Element::SLUR) {
Slur* slur = static_cast<Slur*>(s);

if (!slur->startElement() || !slur->endElement()) {
qDebug("incomplete Slur");
if (slur->startElement()) {
qDebug(" front %d", static_cast<ChordRest*>(slur->startElement())->tick());
static_cast<ChordRest*>(slur->startElement())->removeSlurFor(slur);
}
if (slur->endElement()) {
qDebug(" back %d", static_cast<ChordRest*>(slur->endElement())->tick());
static_cast<ChordRest*>(slur->endElement())->removeSlurBack(slur);
}
}
else {
ChordRest* cr1 = (ChordRest*)(slur->startElement());
ChordRest* cr2 = (ChordRest*)(slur->endElement());
if (cr1->tick() > cr2->tick()) {
qDebug("Slur invalid start-end tick %d-%d", cr1->tick(), cr2->tick());
slur->setStartElement(cr2);
slur->setEndElement(cr1);
}
int n1 = 0;
int n2 = 0;
for (Spanner* s = cr1->spannerFor(); s; s = s->next()) {
if (s == slur)
++n1;
}
for (Spanner* s = cr2->spannerBack(); s; s = s->next()) {
if (s == slur)
++n2;
}
if (n1 != 1 || n2 != 1) {
qDebug("Slur references bad: %d %d", n1, n2);
}
}
}
else {
Segment* s1 = tick2segment(s->__tick1());
Segment* s2 = tick2segment(s->__tick2());
if (s1 == 0 || s2 == 0) {
qDebug("cannot place %s at tick %d - %d",
s->name(), s->__tick1(), s->__tick2());
continue;
}
if (s->type() != Element::SLUR) {
if (s->type() == Element::VOLTA) {
Volta* volta = static_cast<Volta*>(s);
volta->setAnchor(Spanner::ANCHOR_MEASURE);
volta->setStartMeasure(s1->measure());
Measure* m2 = s2->measure();
if (s2->tick() == m2->tick())
m2 = m2->prevMeasure();
volta->setEndMeasure(m2);
s1->measure()->add(s);
int n = volta->spannerSegments().size();
if (n) {
// volta->setYoff(-styleS(ST_voltaHook).val());
// LineSegment* ls = volta->segmentAt(0);
// ls->setReadPos(QPointF());
}
}
else {
s->setStartElement(s1);
s->setEndElement(s2);
s1->add(s);
}
}

Expand All @@ -608,7 +547,7 @@ Score::FileError Score::read114(XmlReader& e)
}
}
}
#endif

connectTies();

//
Expand Down Expand Up @@ -684,7 +623,11 @@ Score::FileError Score::read114(XmlReader& e)
_showOmr = false;

// create excerpts
foreach(Excerpt* excerpt, _excerpts) {
foreach (Excerpt* excerpt, _excerpts) {
if (excerpt->parts().isEmpty()) { // ignore empty parts
_excerpts.removeOne(excerpt);
continue;
}
Score* nscore = Ms::createExcerpt(excerpt->parts());
if (nscore) {
nscore->setParentScore(this);
Expand Down
12 changes: 5 additions & 7 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,7 @@ printf(" %p score %p change spanner %d+%d\n", s, s->score(), s->tick(), s->tic
// +----spanner--------+
// +---add---
//
undoChangeProperty(s, P_SPANNER_TICKLEN, s->tickLen() + len);
undoChangeProperty(s, P_SPANNER_TICK2, s->tick2() + len);
}
else if (tick < s->tick()) {
//
Expand Down Expand Up @@ -3455,9 +3455,9 @@ printf(" %p score %p change spanner %d+%d\n", s, s->score(), s->tick(), s->tic
// +----spanner--------+
// +---remove---+
//
int l = s->tickLen() + len;
if (l > 0)
undoChangeProperty(s, P_SPANNER_TICKLEN, l);
int t2 = s->tick2() + len;
if (t2 > s->tick())
undoChangeProperty(s, P_SPANNER_TICK2, t2);
}
else if (s->tick() >= tick && s->tick2() < tick2) {
//
Expand All @@ -3478,10 +3478,8 @@ printf(" %p score %p change spanner %d+%d\n", s, s->score(), s->tick(), s->tic
int len = s->tickLen() - d2;
if (len == 0)
undoRemoveElement(s);
else {
else
undoChangeProperty(s, P_SPANNER_TICK, s->tick() - d1);
undoChangeProperty(s, P_SPANNER_TICKLEN, s->tickLen() - d2);
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions libmscore/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ Segment::Segment(Measure* m)
Segment::Segment(Measure* m, SegmentType st, int t)
: Element(m->score())
{
if (st == SegBreath)
abort();
setParent(m);
setSegmentType(st);
setTick(t);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Segment : public Element {
static const char* subTypeName(SegmentType);
static SegmentType segmentType(ElementType type);
SegmentType segmentType() const { return _segmentType; }
void setSegmentType(SegmentType t) { if (t == SegBreath) abort(); _segmentType = t; }
void setSegmentType(SegmentType t) { _segmentType = t; }

void removeGeneratedElements();
bool isEmpty() const { return empty; }
Expand Down
Loading

0 comments on commit f227ab7

Please sign in to comment.