Skip to content

Commit

Permalink
Merge pull request #2879 from lasconic/slurshape
Browse files Browse the repository at this point in the history
Slur shape for anticolision
  • Loading branch information
wschweer committed Nov 7, 2016
2 parents a4b5f1b + dd5fb88 commit 461d30b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,21 @@ void Slur::computeBezier(SlurSegment* ss, QPointF p6o)
if (ss->system() && ss->track() >= 0)
staffOffset = QPointF(0.0, -ss->system()->staff(ss->staffIdx())->y());

QPainterPath p;
p.moveTo(QPointF());
p.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
ss->_shape.clear();
QPointF start;
start = t.map(start);
int nbShapes = 10;
for (int i = 1; i <= nbShapes; i++) {
QPointF point = t.map(p.pointAtPercent(i/float(nbShapes)));
QRectF re(start, point);
re.translate(staffOffset);
ss->_shape.add(re);
start = point;
}

ss->path.translate(staffOffset);
ss->shapePath.translate(staffOffset);
}
Expand Down
2 changes: 2 additions & 0 deletions libmscore/slur.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SlurSegment : public SpannerSegment {

QPainterPath path;
QPainterPath shapePath;
Shape _shape;
QPointF autoAdjustOffset;

void computeBezier();
Expand Down Expand Up @@ -116,6 +117,7 @@ class SlurSegment : public SpannerSegment {
void setSlurOffset(Grip i, const QPointF& val) { _ups[int(i)].off = val; }
const struct UP& ups(Grip i) const { return _ups[int(i)]; }
struct UP& ups(Grip i) { return _ups[int(i)]; }
virtual Shape shape() const override { return _shape; }

friend class Tie;
friend class Slur;
Expand Down

0 comments on commit 461d30b

Please sign in to comment.