本文整理汇总了C++中Sheet::bar方法的典型用法代码示例。如果您正苦于以下问题:C++ Sheet::bar方法的具体用法?C++ Sheet::bar怎么用?C++ Sheet::bar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sheet
的用法示例。
在下文中一共展示了Sheet::bar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderKeyboardPreview
void NoteEntryAction::renderKeyboardPreview(QPainter& painter, const MusicCursor& cursor)
{
Staff* staff = cursor.staff();
Part* part = staff->part();
Sheet* sheet = part->sheet();
Bar* bar = sheet->bar(cursor.bar());
QPointF p = bar->position() + QPointF(0, staff->top());
Voice* voice = cursor.staff()->part()->voice(cursor.voice());
VoiceBar* vb = voice->bar(bar);
if (cursor.element() >= vb->elementCount()) {
// cursor is past last element in bar, position of cursor is
// halfway between last element and end of bar
if (vb->elementCount() == 0) {
// unless entire voicebar is still empty
p.rx() += 15.0;
} else {
VoiceElement* ve = vb->element(vb->elementCount()-1);
p.rx() += (ve->x() + bar->size()) / 2;
}
} else {
// cursor is on an element, get the position of that element
p.rx() += vb->element(cursor.element())->x();
}
p.ry() += (cursor.staff()->lineCount() - 1)* cursor.staff()->lineSpacing();
p.ry() -= cursor.staff()->lineSpacing() * cursor.line() / 2;
m_tool->shape()->renderer()->renderNote(painter, m_duration < QuarterNote ? QuarterNote : m_duration, p, 0, Qt::magenta);
}
示例2: mousePress
void AbstractNoteMusicAction::mousePress(Staff* staff, int barIdx, const QPointF& pos)
{
Part* part = staff->part();
Sheet* sheet = part->sheet();
Bar* bar = sheet->bar(barIdx);
Clef* clef = staff->lastClefChange(barIdx, 0);
// loop over all noteheads
qreal closestDist = 1e9;
Note* closestNote = 0;
Chord* chord = 0;
// outer loop, loop over all voices
for (int v = 0; v < part->voiceCount(); v++) {
Voice* voice = part->voice(v);
VoiceBar* vb = voice->bar(bar);
// next loop over all chords
for (int e = 0; e < vb->elementCount(); e++) {
Chord* c = dynamic_cast<Chord*>(vb->element(e));
if (!c) continue;
qreal centerX = c->x() + (c->width() / 2);
// check if it is a rest
if (c->noteCount() == 0) {
qreal centerY = c->y() + (c->height() / 2);
qreal dist = sqrt(sqr(centerX - pos.x()) + sqr(centerY - pos.y()));
if (dist < closestDist) {
closestDist = dist;
closestNote = NULL;
chord = c;
}
}
// lastly loop over all noteheads
for (int n = 0; n < c->noteCount(); n++) {
Note* note = c->note(n);
if (note->staff() != staff) continue;
int line = clef->pitchToLine(note->pitch());
qreal centerY = line * staff->lineSpacing() / 2;
qreal dist = sqrt(sqr(centerX - pos.x()) + sqr(centerY - pos.y()));
if (dist < closestDist) {
closestDist = dist;
closestNote = note;
chord = c;
}
}
}
}
StaffElement* se = 0;
for (int e = 0; e < bar->staffElementCount(staff); e++) {
StaffElement* elem = bar->staffElement(staff, e);
qreal centerX = elem->x() + (elem->width() / 2);
qreal centerY = elem->y() + (elem->height() / 2);
qreal dist = sqrt(sqr(centerX - pos.x()) + sqr(centerY - pos.y()));
if (dist < closestDist) {
se = elem;
closestDist = dist;
}
}
if (se) {
mousePress(se, closestDist, pos);
} else {
mousePress(chord, closestNote, closestDist, pos);
}
}