void Ambitus::draw(QPainter* p) const { qreal _spatium = spatium(); qreal lw = lineWidth().val() * _spatium; p->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); drawSymbol(noteHead(), p, _topPos); drawSymbol(noteHead(), p, _bottomPos); if (_hasLine) p->drawLine(_line); // draw ledger lines (if not in a palette) if (segment() && track() > -1) { int tick = segment()->tick(); Staff* stf = score()->staff(staffIdx()); qreal lineDist = stf->lineDistance(tick); int numOfLines = stf->lines(tick); qreal step = lineDist * _spatium; qreal stepTolerance = step * 0.1; qreal ledgerOffset = score()->styleS(Sid::ledgerLineLength).val() * 0.5 * _spatium; p->setPen(QPen(curColor(), score()->styleS(Sid::ledgerLineWidth).val() * _spatium, Qt::SolidLine, Qt::RoundCap) ); if (_topPos.y()-stepTolerance <= -step) { qreal xMin = _topPos.x() - ledgerOffset; qreal xMax = _topPos.x() + headWidth() + ledgerOffset; for (qreal y = -step; y >= _topPos.y()-stepTolerance; y -= step) p->drawLine(QPointF(xMin, y), QPointF(xMax, y)); } if (_bottomPos.y()+stepTolerance >= numOfLines * step) { qreal xMin = _bottomPos.x() - ledgerOffset; qreal xMax = _bottomPos.x() + headWidth() + ledgerOffset; for (qreal y = numOfLines*step; y <= _bottomPos.y()+stepTolerance; y += step) p->drawLine(QPointF(xMin, y), QPointF(xMax, y)); } } }
void Drumset::save(Xml& xml) { for (int i = 0; i < 128; ++i) { if (!isValid(i)) continue; xml.stag(QString("Drum pitch=\"%1\"").arg(i)); xml.tag("head", int(noteHead(i))); xml.tag("line", line(i)); xml.tag("voice", voice(i)); xml.tag("name", name(i)); xml.tag("stem", int(stemDirection(i))); if (shortcut(i)) { switch (shortcut(i)) { case 'C': case 'D': case 'E': case 'F': case 'G': case 'A': case 'B': { char a[2]; a[0] = shortcut(i); a[1] = 0; xml.tag("shortcut", a); } break; default: qDebug("illegal drum shortcut"); break; } } xml.etag(); } }
qreal Ambitus::headWidth() const { // int head = noteHead(); // qreal val = symbols[score()->symIdx()][head].width(magS()); // return val; return symWidth(noteHead()); }