fix ottava position for staff > 0; fix ottava import from 1.2

This commit is contained in:
ws 2013-08-26 14:33:05 +02:00
parent ec77df240c
commit 136190a49c
5 changed files with 43 additions and 9 deletions

View file

@ -506,6 +506,8 @@ QPointF Element::pagePos() const
system = static_cast<Segment*>(parent())->measure()->system();
else if (parent()->type() == MEASURE) // used in measure number
system = static_cast<Measure*>(parent())->system();
else if (parent()->type() == SYSTEM)
system = static_cast<System*>(parent());
else
abort();
if (system) {
@ -538,6 +540,8 @@ QPointF Element::canvasPos() const
system = static_cast<Segment*>(parent())->measure()->system();
else if (parent()->type() == MEASURE) // used in measure number
system = static_cast<Measure*>(parent())->system();
else if (parent()->type() == SYSTEM)
system = static_cast<System*>(parent());
else
abort();
if (system) {

View file

@ -139,6 +139,7 @@ QPointF LineSegment::getGrip(int grip) const
return p;
}
#if 0
//---------------------------------------------------------
// pagePos
// return position in canvas coordinates
@ -151,6 +152,7 @@ QPointF LineSegment::pagePos() const
pt += parent()->pos();
return pt;
}
#endif
//---------------------------------------------------------
// gripAnchor
@ -537,6 +539,7 @@ QPointF SLine::linePos(int grip, System** sys)
qFatal("Sline::linePos(): anchor not implemented\n");
break;
}
printf("staff %d\n", staffIdx());
qreal y = (*sys)->staves()->isEmpty() ? 0.0 : (*sys)->staff(staffIdx())->y();
return QPointF(x, y);
}
@ -610,7 +613,6 @@ void SLine::layout()
}
int segIdx = 0;
int si = staffIdx();
for (int i = sysIdx1; i <= sysIdx2; ++i) {
System* system = systems->at(i);
if (system->isVbox())
@ -623,7 +625,6 @@ void SLine::layout()
Segment* mseg = m->first(Segment::SegChordRest);
qreal x1 = (mseg ? mseg->pos().x() : 0) + m->pos().x();
qreal x2 = system->bbox().right();
qreal y = system->staff(si)->y();
if (sysIdx1 == sysIdx2) {
// single segment
@ -643,7 +644,7 @@ void SLine::layout()
else if (i > 0 && i != sysIdx2) {
// middle segment
seg->setSpannerSegmentType(SEGMENT_MIDDLE);
seg->setPos(QPointF(x1, y));
seg->setPos(QPointF(x1, p1.y()));
seg->setPos2(QPointF(x2 - x1, 0.0));
}
else if (i == sysIdx2) {
@ -652,7 +653,7 @@ void SLine::layout()
if (anchor() == ANCHOR_SEGMENT)
len = qMax(3 * spatium(), len);
seg->setSpannerSegmentType(SEGMENT_END);
seg->setPos(QPointF(x1, y));
seg->setPos(QPointF(x1, p1.y()));
seg->setPos2(QPointF(len, 0.0)); // p2 is relative to p1
}
seg->layout();
@ -672,8 +673,8 @@ void SLine::writeProperties(Xml& xml) const
if (propertyStyle(P_LINE_WIDTH) != PropertyStyle::STYLED)
xml.tag("lineWidth", lineWidth().val());
if (propertyStyle(P_LINE_STYLE) == PropertyStyle::UNSTYLED || (lineStyle() != Qt::SolidLine))
if (propertyStyle(P_LINE_STYLE) != PropertyStyle::STYLED)
xml.tag("lineStyle", int(lineStyle()));
if (propertyStyle(P_LINE_STYLE) != PropertyStyle::STYLED)
xml.tag("lineStyle", int(lineStyle()));
if (propertyStyle(P_LINE_COLOR) == PropertyStyle::UNSTYLED || (lineColor() != MScore::defaultColor))
xml.tag("lineColor", lineColor());

View file

@ -67,7 +67,7 @@ class LineSegment : public SpannerSegment {
virtual void draw(QPainter*) const = 0;
SLine* line() const { return (SLine*)spanner(); }
virtual void spatiumChanged(qreal, qreal);
virtual QPointF pagePos() const;
// virtual QPointF pagePos() const;
friend class SLine;
virtual void read(XmlReader&);

View file

@ -39,7 +39,7 @@ class OttavaSegment : public TextLineSegment {
protected:
public:
OttavaSegment(Score* s) : TextLineSegment(s) {}
OttavaSegment(Score* s) : TextLineSegment(s) { setFlag(ELEMENT_ON_STAFF, true); }
virtual ElementType type() const override { return OTTAVA_SEGMENT; }
virtual OttavaSegment* clone() const override { return new OttavaSegment(*this); }
Ottava* ottava() const { return (Ottava*)spanner(); }

View file

@ -384,8 +384,9 @@ Score::FileError Score::read114(XmlReader& e)
qDebug("invalid spanner %s tick2: %d\n",
s->name(), s->tick2());
}
else
else {
addSpanner(s);
}
}
else if (tag == "Excerpt") {
Excerpt* ex = new Excerpt(this);
@ -470,6 +471,30 @@ Score::FileError Score::read114(XmlReader& e)
for (std::pair<int,Spanner*> p : spanner()) {
Spanner* s = p.second;
if (s->anchor() == Spanner::ANCHOR_SEGMENT) {
Segment* segment = tick2segment(s->tick2(), true, Segment::SegChordRest);
if (segment) {
segment = segment->prev1(Segment::SegChordRest);
if (segment)
s->setTick2(segment->tick());
else
qDebug("1:no segment for tick %d", s->tick2());
}
else {
Measure* m = lastMeasure();
segment = m->last();
if (!segment)
qDebug("2:no segment for tick %d", s->tick2());
else {
if (segment->segmentType() != Segment::SegChordRest)
segment = segment->prev1(Segment::SegChordRest);
if (segment)
s->setTick2(segment->tick());
else
qDebug("3:no segment for tick %d", s->tick2());
}
}
}
if (s->type() == Element::OTTAVA
|| (s->type() == Element::TEXTLINE)
|| (s->type() == Element::VOLTA)
@ -494,8 +519,12 @@ Score::FileError Score::read114(XmlReader& e)
int n = ottava->spannerSegments().size();
for (int i = 0; i < n; ++i) {
LineSegment* seg = ottava->segmentAt(i);
seg->setUserOff(QPointF());
seg->setUserOff2(QPointF());
#if 0
if (!seg->userOff().isNull())
seg->setUserYoffset(seg->userOff().y() - styleP(ST_ottavaY));
#endif
}
ottava->staff()->updateOttava(ottava);
}