本文整理汇总了C++中Chord::arpeggio方法的典型用法代码示例。如果您正苦于以下问题:C++ Chord::arpeggio方法的具体用法?C++ Chord::arpeggio怎么用?C++ Chord::arpeggio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chord
的用法示例。
在下文中一共展示了Chord::arpeggio方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void Glissando::layout()
{
Chord* chord = static_cast<Chord*>(parent());
if (chord == 0)
return;
Note* anchor2 = chord->upNote();
Segment* s = chord->segment();
s = s->prev1();
while (s) {
if ((s->segmentType() & (Segment::SegChordRest)) && s->element(track()))
break;
s = s->prev1();
}
if (s == 0) {
qDebug("no segment for first note of glissando found\n");
return;
}
ChordRest* cr = static_cast<ChordRest*>(s->element(track()));
if (cr == 0 || cr->type() != CHORD) {
qDebug("no first note for glissando found, track %d", track());
return;
}
qreal _spatium = spatium();
Note* anchor1 = static_cast<Chord*>(cr)->upNote();
setPos(0.0, 0.0);
adjustReadPos();
QPointF cp1 = anchor1->pagePos();
QPointF cp2 = anchor2->pagePos();
// line starting point
int dots = static_cast<Chord*>(cr)->dots();
LedgerLine * ledLin = static_cast<Chord*>(cr)->ledgerLines();
// if dots, from right of last dot (assume a standard dot with of 1/4 sp)
// if no dots, from right of ledger line, if any; from right of note head, if no ledger line
qreal x1 = (dots ? anchor1->dot(dots-1)->pos().x() + anchor1->dot(dots-1)->width()
: (ledLin ? ledLin->pos().x() + ledLin->width() : anchor1->headWidth()) )
- (cp2.x() - cp1.x()); // make relative to end note
qreal y1 = anchor1->pos().y();
// line end point: left of note head
qreal x2 = anchor2->pos().x();
qreal y2 = anchor2->pos().y();
// angle glissando between notes with the same pitch letter
if (anchor1->line() == anchor2->line()) {
int upDown = anchor2->pitch() - anchor1->pitch();
if (upDown != 0)
upDown /= abs(upDown);
y1 += _spatium * 0.25 * upDown;
y2 -= _spatium * 0.25 * upDown;
}
// on TAB's, adjust lower end point from string line height to base of note height (= ca. half line spacing)
if (chord->staff()->isTabStaff()) {
qreal yOff = chord->staff()->lineDistance() * 0.3 * _spatium;
if (anchor1->pitch() > anchor2->pitch()) { // descending glissando:
y2 += yOff;
y1 -= yOff;
} // move ending point to base of note
else { // ascending glissando:
y1 += yOff; // move starting point to base of note
y2 -= yOff;
}
}
// shorten line to avoid end note ledger line
ledLin=anchor2->chord()->ledgerLines();
if (ledLin)
x2 = ledLin->pos().x();
// shorten line so it doesn't go through end note accidental or arpeggio
if (Accidental* a = anchor2->accidental()) {
x2 = a->pos().x() + a->userOff().x();
}
if (Arpeggio* a = chord->arpeggio()) {
x2 = a->pos().x() + a->userOff().x();
}
QLineF fullLine(x1, y1, x2, y2);
// shorten line on each side by offsets
qreal xo = _spatium * .5;
qreal yo = xo; // spatium() * .5;
QPointF p1 = fullLine.pointAt(xo / fullLine.length());
QPointF p2 = fullLine.pointAt(1 - (yo / fullLine.length()));
line = QLineF(p1, p2);
qreal lw = _spatium * .15 * .5;
QRectF r = QRectF(line.p1(), line.p2()).normalized();
setbbox(r.adjusted(-lw, -lw, lw, lw));
}
示例2: layout
//.........这里部分代码省略.........
ChordRest* cr = static_cast<ChordRest*>(s1->element(track()));
if (cr == 0 || cr->type() != Element::Type::CHORD) {
qDebug("no first note for glissando found, track %d", track());
return;
}
qreal _spatium = spatium();
Note* anchor1 = static_cast<Chord*>(cr)->upNote();
setPos(0.0, 0.0);
adjustReadPos();
// since line will be drawn relative to end note,
// calculate offsets for start note coordinates relative to end note
qreal x1off = 0.0;
qreal y1off = 0.0;
QPointF cp1 = anchor1->pagePos();
QPointF cp2 = anchor2->pagePos();
// layout of glissandi happens before we have staff positions within the system
// so these "page" positions are not accurate across different staves
// cheap partial fix for cross-staff glissandi: adjust vertical position according to difference in staffMove
int moveDiff = anchor2->chord()->staffMove() - anchor1->chord()->staffMove();
if (moveDiff)
y1off = moveDiff * 4.0 * _spatium;
// now calculate offsets
if (s1->system() == s2->system()) {
// normal case - start and end note in same system
x1off = cp2.x() - cp1.x();
if (!moveDiff)
y1off = cp2.y() - cp1.y();
}
else {
// cheap partial fix for cross system glissandi: just draw a short line into end note
// TODO: draw line coming out of start note on previous system
x1off = 4.0 * _spatium;
if (!moveDiff)
y1off = anchor2->pos().y() - anchor1->pos().y();
}
// line starting point
int dots = static_cast<Chord*>(cr)->dots();
LedgerLine * ledLin = static_cast<Chord*>(cr)->ledgerLines();
// if dots, from right of last dot (assume a standard dot with of 1/4 sp)
// if no dots, from right of ledger line, if any; from right of note head, if no ledger line
qreal x1 = (dots && anchor1->dot(dots-1) ? anchor1->dot(dots-1)->pos().x() + anchor1->dot(dots-1)->width()
: (ledLin ? ledLin->pos().x() + ledLin->width() : anchor1->headWidth()) )
- x1off; // make relative to end note
qreal y1 = anchor2->y() - y1off;
// line end point: left of note head
qreal x2 = anchor2->pos().x();
qreal y2 = anchor2->pos().y();
// angle glissando between notes with the same pitch letter
if (anchor1->line() == anchor2->line()) {
int upDown = anchor2->pitch() - anchor1->pitch();
if (upDown != 0)
upDown /= abs(upDown);
y1 += _spatium * 0.25 * upDown;
y2 -= _spatium * 0.25 * upDown;
}
// on TAB's, adjust lower end point from string line height to base of note height (= ca. half line spacing)
if (chord->staff()->isTabStaff()) {
qreal yOff = chord->staff()->lineDistance() * 0.3 * _spatium;
if (anchor1->pitch() > anchor2->pitch()) { // descending glissando:
y2 += yOff;
y1 -= yOff;
} // move ending point to base of note
else { // ascending glissando:
y1 += yOff; // move starting point to base of note
y2 -= yOff;
}
}
// shorten line to avoid end note ledger line
ledLin = anchor2->chord()->ledgerLines();
if (ledLin)
x2 = ledLin->pos().x();
// shorten line so it doesn't go through end note accidental or arpeggio
if (Accidental* a = anchor2->accidental()) {
x2 = a->pos().x() + a->userOff().x();
}
if (Arpeggio* a = chord->arpeggio()) {
x2 = a->pos().x() + a->userOff().x();
}
QLineF fullLine(x1, y1, x2, y2);
// shorten line on each side by offsets
qreal xo = _spatium * .5;
qreal yo = xo; // spatium() * .5;
QPointF p1 = fullLine.pointAt(xo / fullLine.length());
QPointF p2 = fullLine.pointAt(1 - (yo / fullLine.length()));
line = QLineF(p1, p2);
qreal lw = _spatium * .15 * .5;
QRectF r = QRectF(line.p1(), line.p2()).normalized();
setbbox(r.adjusted(-lw, -lw, lw, lw));
}