本文整理汇总了C++中SysStaff::setbbox方法的典型用法代码示例。如果您正苦于以下问题:C++ SysStaff::setbbox方法的具体用法?C++ SysStaff::setbbox怎么用?C++ SysStaff::setbbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SysStaff
的用法示例。
在下文中一共展示了SysStaff::setbbox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layoutSystem
//.........这里部分代码省略.........
b = new Bracket(score());
b->setGenerated(true);
b->setTrack(track);
b->setLevel(i);
}
add(b);
b->setFirstStaff(firstStaff);
b->setLastStaff(lastStaff);
b->setBracketType(s->bracket(i));
b->setSpan(s->bracketSpan(i));
bracketWidth[i] = qMax(bracketWidth[i], b->width());
}
}
if (!s->show())
continue;
for (InstrumentName* t : _staves[staffIdx]->instrumentNames) {
t->layout();
qreal w = t->width() + point(instrumentNameOffset);
if (w > xoff2)
xoff2 = w;
}
}
for (Bracket* b : bl)
delete b;
//---------------------------------------------------
// layout SysStaff and StaffLines
//---------------------------------------------------
_leftMargin = xoff2;
qreal bd = score()->styleP(StyleIdx::bracketDistance);
if ( _brackets.size() > 0) {
for (int i = 0; i < bracketLevels; ++i)
_leftMargin += bracketWidth[i] + bd;
}
int nVisible = 0;
for (int staffIdx = 0; staffIdx < nstaves; ++staffIdx) {
SysStaff* s = _staves[staffIdx];
Staff* staff = score()->staff(staffIdx);
if (!staff->show() || !s->show()) {
s->setbbox(QRectF());
continue;
}
++nVisible;
qreal staffMag = staff->mag();
qreal h;
if (staff->lines() == 1)
h = 2;
else
h = (staff->lines()-1) * staff->lineDistance();
h = h * staffMag * spatium();
s->bbox().setRect(_leftMargin + xo1, 0.0, 0.0, h);
}
//---------------------------------------------------
// layout brackets
//---------------------------------------------------
for (Bracket* b : _brackets) {
qreal xo = -xo1;
for (const Bracket* b2 : _brackets) {
if (b->level() > b2->level() &&
((b->firstStaff() >= b2->firstStaff() && b->firstStaff() <= b2->lastStaff()) ||
(b->lastStaff() >= b2->firstStaff() && b->lastStaff() <= b2->lastStaff())))
xo += b2->width() + bd;
}
b->rxpos() = _leftMargin - xo - b->width();
}
//---------------------------------------------------
// layout instrument names x position
//---------------------------------------------------
int idx = 0;
for (const Part* p : score()->parts()) {
SysStaff* s = staff(idx);
if (s->show() && p->show()) {
for (InstrumentName* t : s->instrumentNames) {
switch (t->textStyle().align() & AlignmentFlags::HMASK) {
case int(AlignmentFlags::LEFT):
t->rxpos() = 0;
break;
case int(AlignmentFlags::HCENTER):
t->rxpos() = (xoff2 - point(instrumentNameOffset) + xo1) * .5;
break;
case int(AlignmentFlags::RIGHT):
default:
t->rxpos() = xoff2 - point(instrumentNameOffset) + xo1;
break;
}
t->rxpos() += t->textStyle().offset(t->spatium()).x();
}
}
idx += p->nstaves();
}
}
示例2: if
void System::layout2()
{
VBox* b = vbox();
if (b) {
b->layout();
setbbox(b->bbox());
return;
}
setPos(0.0, 0.0);
QList<std::pair<int,SysStaff*>> visibleStaves;
int firstStaffIdx = -1;
int lastStaffIdx = 0;
int firstStaffInitialIdx = -1;
int lastStaffInitialIdx = 0;
Measure* fm = firstMeasure();
for (int i = 0; i < _staves.size(); ++i) {
Staff* s = score()->staff(i);
SysStaff* ss = _staves[i];
if (s->show() && ss->show()) {
visibleStaves.append(std::pair<int,SysStaff*>(i, ss));
if (firstStaffIdx == -1)
firstStaffIdx = i;
if (i > lastStaffIdx)
lastStaffIdx = i;
if (fm && fm->visible(i)) {
if (firstStaffInitialIdx == -1)
firstStaffInitialIdx = i;
lastStaffInitialIdx = i;
}
}
else {
ss->setbbox(QRectF()); // already done in layout() ?
}
}
if (firstStaffIdx == -1)
firstStaffIdx = 0;
if (firstStaffInitialIdx == -1)
firstStaffInitialIdx = 0;
qreal _spatium = spatium();
qreal y = 0.0;
qreal minVerticalDistance = score()->styleP(StyleIdx::minVerticalDistance);
qreal staffDistance = score()->styleP(StyleIdx::staffDistance);
qreal akkoladeDistance = score()->styleP(StyleIdx::akkoladeDistance);
if (visibleStaves.empty()) {
qDebug("====no visible staves, staves %d, score staves %d", _staves.size(), score()->nstaves());
}
for (auto i = visibleStaves.begin();; ++i) {
SysStaff* ss = i->second;
int si1 = i->first;
Staff* staff = score()->staff(si1);
auto ni = i + 1;
qreal h = staff->height();
if (ni == visibleStaves.end()) {
ss->setYOff(staff->lines() == 1 ? _spatium * staff->mag() : 0.0);
ss->bbox().setRect(_leftMargin, y, width() - _leftMargin, h);
break;
}
int si2 = ni->first;
qreal dist = h;
switch (staff->innerBracket()) {
case BracketType::BRACE:
dist += akkoladeDistance;
break;
case BracketType::NORMAL:
case BracketType::SQUARE:
case BracketType::LINE:
case BracketType::NO_BRACKET:
dist += staffDistance;
break;
}
dist += score()->staff(si2)->userDist();
for (MeasureBase* mb : ml) {
if (!mb->isMeasure())
continue;
Measure* m = toMeasure(mb);
Shape& s1 = m->staffShape(si1);
Shape& s2 = m->staffShape(si2);
qreal d = s1.minVerticalDistance(s2) + minVerticalDistance;
dist = qMax(dist, d);
Spacer* sp = m->mstaff(si1)->_vspacerDown;
if (sp) {
if (sp->spacerType() == SpacerType::FIXED) {
dist = staff->height() + sp->gap();
break;
}
else
dist = qMax(dist, staff->height() + sp->gap());
}
//.........这里部分代码省略.........
示例3: if
void System::layout2()
{
if (isVbox()) // ignore vbox
return;
int nstaves = _staves.size();
qreal _spatium = spatium();
qreal y = 0.0;
int lastStaffIdx = 0; // last visible staff
int firstStaffIdx = -1;
qreal lastStaffDistanceDown = 0.0;
for (int staffIdx = 0; staffIdx < nstaves; ++staffIdx) {
Staff* staff = score()->staff(staffIdx);
StyleIdx downDistance;
qreal userDist = 0.0;
if ((staffIdx + 1) == nstaves) {
//
// last staff in system
//
MeasureBase* mb = ml.last();
bool nextMeasureIsVBOX = false;
if (mb->next()) {
Element::Type type = mb->next()->type();
if (type == Element::Type::VBOX || type == Element::Type::TBOX || type == Element::Type::FBOX)
nextMeasureIsVBOX = true;
}
downDistance = nextMeasureIsVBOX ? StyleIdx::systemFrameDistance : StyleIdx::minSystemDistance;
}
else if (staff->rstaff() < (staff->part()->staves()->size()-1)) {
//
// staff is not last staff in a part
//
downDistance = StyleIdx::akkoladeDistance;
userDist = score()->staff(staffIdx + 1)->userDist();
}
else {
downDistance = StyleIdx::staffDistance;
userDist = score()->staff(staffIdx + 1)->userDist();
}
SysStaff* s = _staves[staffIdx];
qreal distDown = score()->styleS(downDistance).val() * _spatium + userDist;
qreal nominalDistDown = distDown;
qreal distUp = 0.0;
int n = ml.size();
for (int i = 0; i < n; ++i) {
MeasureBase* m = ml.at(i);
distDown = qMax(distDown, m->distanceDown(staffIdx));
distUp = qMax(distUp, m->distanceUp(staffIdx));
}
s->setDistanceDown(distDown);
s->setDistanceUp(distUp);
if (!staff->show() || !s->show()) {
s->setbbox(QRectF()); // already done in layout() ?
continue;
}
qreal sHeight = staff->height();
qreal dup = staffIdx == 0 ? 0.0 : s->distanceUp();
if (staff->lines() == 1)
dup -= _spatium * staff->mag();
s->bbox().setRect(_leftMargin, y + dup, width() - _leftMargin, sHeight);
y += dup + sHeight + s->distanceDown();
lastStaffIdx = staffIdx;
lastStaffDistanceDown = distDown - nominalDistDown;
if (firstStaffIdx == -1)
firstStaffIdx = staffIdx;
}
if (firstStaffIdx == -1)
firstStaffIdx = 0;
qreal systemHeight = staff(lastStaffIdx)->bbox().bottom();
if (lastStaffIdx < nstaves - 1)
systemHeight += lastStaffDistanceDown;
setHeight(systemHeight);
int n = ml.size();
for (int i = 0; i < n; ++i) {
MeasureBase* m = ml.at(i);
if (m->type() == Element::Type::MEASURE) {
// note that the factor 2 * _spatium must be corrected for when exporting
// system distance in MusicXML (issue #24733)
m->bbox().setRect(0.0, -_spatium, m->width(), systemHeight + 2 * _spatium);
}
else if (m->type() == Element::Type::HBOX) {
m->bbox().setRect(0.0, 0.0, m->width(), systemHeight);
static_cast<HBox*>(m)->layout2();
}
}
if (_barLine) {
_barLine->setTrack(firstStaffIdx * VOICES);
_barLine->setSpan(lastStaffIdx - firstStaffIdx + 1);
if (score()->staff(0)->lines() == 1)
_barLine->setSpanFrom(BARLINE_SPAN_1LINESTAFF_FROM);
int spanTo = (score()->staff(lastStaffIdx)->lines() == 1) ?
BARLINE_SPAN_1LINESTAFF_TO :
(score()->staff(lastStaffIdx)->lines()-1)*2;
//.........这里部分代码省略.........