本文整理汇总了C++中setbbox函数的典型用法代码示例。如果您正苦于以下问题:C++ setbbox函数的具体用法?C++ setbbox怎么用?C++ setbbox使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setbbox函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: up
void Stem::layout()
{
qreal l = _len + _userLen;
qreal _up = up() ? -1.0 : 1.0;
l *= _up;
qreal y1 = 0.0; // vertical displacement to match note attach point
Staff* stf = staff();
if (chord()) {
int tick = chord()->tick();
StaffType* st = stf->staffType(tick);
if (st->isTabStaff() ) { // TAB staves
if (st->stemThrough()) {
// if stems through staves, gets Y pos. of stem-side note relative to chord other side
qreal lineDist = st->lineDistance().val() * spatium();
y1 = (chord()->downString() - chord()->upString()) * _up * lineDist;
// if fret marks above lines, raise stem beginning by 1/2 line distance
if (!st->onLines())
y1 -= lineDist * 0.5;
// shorten stem by 1/2 lineDist to clear the note and a little more to keep 'air' betwen stem and note
lineDist *= 0.7 * mag();
y1 += _up * lineDist;
}
// in other TAB types, no correction
}
else { // non-TAB
// move stem start to note attach point
Note* n = up() ? chord()->downNote() : chord()->upNote();
y1 += (up() ? n->stemUpSE().y() : n->stemDownNW().y());
rypos() = n->rypos();
}
}
qreal lw5 = _lineWidth * .5;
line.setLine(0.0, y1, 0.0, l);
// compute bounding rectangle
QRectF r(line.p1(), line.p2());
setbbox(r.normalized().adjusted(-lw5, -lw5, lw5, lw5));
adjustReadPos(); // does not work if stem is layouted twice
}
示例2: setPos
void Image::layout()
{
setPos(0.0, 0.0);
if (imageType == ImageType::SVG && !svgDoc) {
if (_storeItem)
svgDoc = new QSvgRenderer(_storeItem->buffer());
}
else if (imageType == ImageType::RASTER && !rasterDoc) {
if (_storeItem) {
rasterDoc = new QImage;
rasterDoc->loadFromData(_storeItem->buffer());
if (!rasterDoc->isNull())
_dirty = true;
}
}
if (_size.isNull())
_size = pixel2size(imageSize());
// if autoscale && inside a box, scale to box relevant size
if (autoScale() && parent() && ((parent()->isHBox() || parent()->isVBox()))) {
if (_lockAspectRatio) {
qreal f = _sizeIsSpatium ? spatium() : DPMM;
QSizeF size(imageSize());
qreal ratio = size.width() / size.height();
qreal w = parent()->width();
qreal h = parent()->height();
if ((w / h) < ratio) {
_size.setWidth(w / f);
_size.setHeight((w / ratio) / f);
}
else {
_size.setHeight(h / f);
_size.setWidth(h * ratio / f);
}
}
else
_size = pixel2size(parent()->bbox().size());
}
// in any case, adjust position relative to parent
setbbox(QRectF(QPointF(), size2pixel(_size)));
}
示例3: pos2
void TrillSegment::symbolLine(SymId start, SymId fill, SymId end)
{
qreal x1 = 0;
qreal x2 = pos2().x();
qreal w = x2 - x1;
qreal mag = magS();
ScoreFont* f = score()->scoreFont();
_symbols.clear();
_symbols.push_back(start);
qreal w1 = f->advance(start, mag);
qreal w2 = f->advance(fill, mag);
qreal w3 = f->advance(end, mag);
int n = lrint((w - w1 - w3) / w2);
for (int i = 0; i < n; ++i)
_symbols.push_back(fill);
_symbols.push_back(end);
QRectF r(f->bbox(_symbols, mag));
setbbox(r);
}
示例4: b1
void TrillSegment::layout()
{
QRectF b1(symBbox(SymId::ornamentTrill));
QRectF rr(b1.translated(-b1.x(), 0.0));
rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height());
setbbox(rr);
if (parent())
rypos() += score()->styleS(ST_trillY).val() * spatium();
if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) {
Accidental* a = trill()->accidental();
if (a) {
a->layout();
a->setMag(a->mag() * .6);
qreal _spatium = spatium();
a->setPos(_spatium*1.3, -2.2*_spatium);
a->adjustReadPos();
}
}
adjustReadPos();
}
示例5: pos2
void TrillSegment::symbolLine(SymId start, SymId fill, SymId end)
{
qreal x1 = 0;
qreal x2 = pos2().x();
qreal w = x2 - x1;
qreal mag = magS();
ScoreFont* f = score()->scoreFont();
_symbols.clear();
_symbols.append(f->toString(start));
_symbols.append(f->toString(end));
qreal w1 = f->bbox(start, mag).width();
qreal w2 = f->width(fill, mag);
qreal w3 = f->width(end, mag);
int n = lrint((w - w1 - w3) / w2);
for (int i = 0; i < n; ++i)
_symbols.insert(1, f->toString(fill));
QRectF r(f->bbox(_symbols, mag));
setbbox(r);
}
示例6: spatium
void Spacer::layout0()
{
qreal _spatium = spatium();
path = QPainterPath();
qreal w = _spatium;
qreal b = w * .5;
qreal h = _gap;
switch (spacerType()) {
case SpacerType::DOWN:
path.lineTo(w, 0.0);
path.moveTo(b, 0.0);
path.lineTo(b, h);
path.lineTo(0.0, h-b);
path.moveTo(b, h);
path.lineTo(w, h-b);
break;
case SpacerType::UP:
path.moveTo(b, 0.0);
path.lineTo(0.0, b);
path.moveTo(b, 0.0);
path.lineTo(w, b);
path.moveTo(b, 0.0);
path.lineTo(b, h);
path.moveTo(0.0, h);
path.lineTo(w, h);
break;
case SpacerType::FIXED:
path.lineTo(w, 0.0);
path.moveTo(b, 0.0);
path.lineTo(b, h);
path.moveTo(0.0, h);
path.lineTo(w, h);
break;
}
qreal lw = _spatium * 0.4;
QRectF bb(0, 0, w, h);
bb.adjust(-lw, -lw, lw, lw);
setbbox(bb);
}
示例7: setbbox
void Symbol::layout()
{
// foreach(Element* e, leafs()) done in BSymbol::layout() ?
// e->layout();
setbbox(_scoreFont ? _scoreFont->bbox(_sym, magS()) : symBbox(_sym));
QPointF o(offset());
qreal w = width();
QPointF p;
if (align() & Align::BOTTOM)
p.setY(- height());
else if (align() & Align::VCENTER)
p.setY((- height()) * .5);
else if (align() & Align::BASELINE)
p.setY(-baseLine());
if (align() & Align::RIGHT)
p.setX(-w);
else if (align() & Align::HCENTER)
p.setX(-(w * .5));
setPos(p);
BSymbol::layout();
}
示例8: staff
void Stem::layout()
{
qreal l = _len + _userLen;
if (up())
l = -l;
Staff* st = staff();
qreal lw5 = point(score()->styleS(ST_stemWidth)) * .5;
QPointF p1(0.0, 0.0);
QPointF p2(0.0, l);
if (st) {
// if TAB, use simplified positioning
if (st->isTabStaff()) {
p1.rx() = -lw5;
p2.rx() = -lw5;
}
// for any other staff type, use standard positioning
else if (chord()) {
// adjust P1 for note head
Chord* c = chord();
if (c->up()) {
Note* n = c->downNote();
p1 = symbols[score()->symIdx()][n->noteHead()].attach(n->magS());
p1.rx() = -lw5;
p2.rx() = -lw5;
}
else {
Note* n = c->upNote();
p1 = -symbols[score()->symIdx()][n->noteHead()].attach(n->magS());
p1.rx() = lw5;
p2.rx() = lw5;
}
}
}
line.setP1(p1);
line.setP2(p2);
// compute bounding rectangle
QRectF r(line.p1(), line.p2());
setbbox(r.normalized().adjusted(-lw5, -lw5, lw5, lw5));
}
示例9: up
void Stem::layout()
{
qreal l = _len + _userLen;
qreal _up = up() ? -1.0 : 1.0;
l *= _up;
qreal y1 = 0.0; // vertical displacement to match note attach point
Staff* st = staff();
if (chord() && st ) {
if (st->isTabStaff() ) { // TAB staves
if ( ((StaffTypeTablature*)st->staffType())->stemThrough()) {
// if stems through staves, gets Y pos. of stem-side note relative to chord other side
qreal lineDist = st->lineDistance() * spatium();
y1 = (chord()->downString() - chord()->upString() ) * _up * lineDist;
// if fret marks above lines, raise stem beginning by 1/2 line distance
if ( !((StaffTypeTablature*)st->staffType())->onLines() )
y1 -= lineDist * 0.5;
// shorten stem by 1/2 lineDist to clear the note and a little more to keep 'air' betwen stem and note
lineDist *= 0.7 * mag();
y1 += _up * lineDist;
}
// in other TAB types, no correction
}
else { // non-TAB
// move stem start to note attach point
Note* n = up() ? chord()->downNote() : chord()->upNote();
const Sym& sym = symbols[score()->symIdx()][n->noteHead()];
if (n->mirror())
_up *= -1;
y1 -= sym.attach(n->magS()).y() * _up;
}
}
line.setLine(0.0, y1, 0.0, l);
// compute bounding rectangle
QRectF r(line.p1(), line.p2());
qreal lw5 = lineWidth() * .5;
setbbox(r.normalized().adjusted(-lw5, -lw5, lw5, lw5));
}
示例10: spatium
void RepeatMeasure::layout()
{
qreal sp = spatium();
qreal y = sp;
qreal w = sp * 2.0;
qreal h = sp * 2.0;
qreal lw = sp * .30; // line width
qreal r = sp * .15; // dot radius
path = QPainterPath();
path.moveTo(w - lw, y);
path.lineTo(w, y);
path.lineTo(lw, h+y);
path.lineTo(0.0, h+y);
path.closeSubpath();
path.addEllipse(QRectF(w * .25 - r, y+h * .25 - r, r * 2.0, r * 2.0 ));
path.addEllipse(QRectF(w * .75 - r, y+h * .75 - r, r * 2.0, r * 2.0 ));
setbbox(path.boundingRect());
}
示例11: up
void Stem::layout()
{
qreal l = _len + _userLen;
qreal _up = up() ? -1.0 : 1.0;
l *= _up;
qreal y1 = 0.0;
Staff* st = staff();
if (chord() && st && !st->isTabStaff()) {
Note* n = up() ? chord()->downNote() : chord()->upNote();
const Sym& sym = symbols[score()->symIdx()][n->noteHead()];
if (n->mirror())
_up *= -1;
y1 -= sym.attach(n->magS()).y() * _up;
}
line.setLine(0.0, y1, 0.0, l);
// compute bounding rectangle
QRectF r(line.p1(), line.p2());
qreal lw5 = lineWidth() * .5;
setbbox(r.normalized().adjusted(-lw5, -lw5, lw5, lw5));
}
示例12: frontSegment
void SLine::layout()
{
if (parent() == 0) {
//
// when used in a palette, SLine has no parent and
// tick and tick2 has no meaning so no layout is
// possible and needed
//
if (!spannerSegments().isEmpty()) {
LineSegment* s = frontSegment();
s->layout();
setbbox(s->bbox());
}
return;
}
if (startElement() == 0 || endElement() == 0) {
qDebug("SLine::layout() failed: %s %s\n", parent()->name(), name());
qDebug(" start %p end %p\n", startElement(), endElement());
return;
}
System* s1;
System* s2;
QPointF p1 = linePos(GRIP_LINE_START, &s1);
QPointF p2 = linePos(GRIP_LINE_END, &s2);
QList<System*>* systems = score()->systems();
int sysIdx1 = systems->indexOf(s1);
int sysIdx2 = systems->indexOf(s2);
int segmentsNeeded = 0;
for (int i = sysIdx1; i < sysIdx2+1; ++i) {
if (systems->at(i)->isVbox())
continue;
++segmentsNeeded;
}
int segCount = spannerSegments().size();
if (segmentsNeeded != segCount) {
if (segmentsNeeded > segCount) {
int n = segmentsNeeded - segCount;
for (int i = 0; i < n; ++i) {
LineSegment* ls = createLineSegment();
add(ls);
// set user offset to previous segment's offset
if (segCount > 0)
ls->setUserOff(QPointF(0, segmentAt(segCount+i-1)->userOff().y()));
}
}
else {
int n = segCount - segmentsNeeded;
qDebug("SLine: segments %d needed %d, remove %d\n", segCount, segmentsNeeded, n);
for (int i = 0; i < n; ++i) {
if (spannerSegments().isEmpty()) {
qDebug("SLine::layout(): no segment %d, %d expected\n", i, n);
break;
}
else {
// LineSegment* seg = takeLastSegment();
// TODO delete seg;
}
}
}
}
int segIdx = 0;
int si = staffIdx();
for (int i = sysIdx1; i <= sysIdx2; ++i) {
System* system = systems->at(i);
if (system->isVbox())
continue;
LineSegment* seg = segmentAt(segIdx++);
seg->setSystem(system);
Measure* m = system->firstMeasure();
qreal x1 = m->first(SegChordRest)->pos().x() + m->pos().x();
qreal x2 = system->bbox().right();
qreal y = system->staff(si)->y();
if (sysIdx1 == sysIdx2) {
// single segment
seg->setSubtype(SEGMENT_SINGLE);
seg->setPos(p1);
seg->setPos2(QPointF(p2.x() - p1.x(), 0.0));
}
else if (i == sysIdx1) {
// start segment
seg->setSubtype(SEGMENT_BEGIN);
seg->setPos(p1);
seg->setPos2(QPointF(x2 - p1.x(), 0.0));
}
else if (i > 0 && i != sysIdx2) {
// middle segment
seg->setSubtype(SEGMENT_MIDDLE);
seg->setPos(QPointF(x1, y));
seg->setPos2(QPointF(x2 - x1, 0.0));
}
else if (i == sysIdx2) {
// end segment
seg->setSubtype(SEGMENT_END);
seg->setPos(QPointF(x1, y));
//.........这里部分代码省略.........
示例13: parent
void Fingering::layout()
{
if (parent()) {
Fraction tick = parent()->tick();
const Staff* st = staff();
if (st && st->isTabStaff(tick) && !st->staffType(tick)->showTabFingering()) {
setbbox(QRectF());
return;
}
}
TextBase::layout();
rypos() = 0.0; // handle placement below
if (autoplace() && note()) {
Note* n = note();
Chord* chord = n->chord();
bool voices = chord->measure()->hasVoices(chord->staffIdx());
bool tight = voices && chord->notes().size() == 1 && !chord->beam() && tid() != Tid::STRING_NUMBER;
qreal headWidth = n->bboxRightPos();
// update offset after drag
qreal rebase = 0.0;
if (offsetChanged() != OffsetChange::NONE)
rebase = rebaseOffset();
// temporarily exclude self from chord shape
setAutoplace(false);
if (layoutType() == ElementType::CHORD) {
Stem* stem = chord->stem();
Segment* s = chord->segment();
Measure* m = s->measure();
qreal sp = spatium();
qreal md = minDistance().val() * sp;
SysStaff* ss = m->system()->staff(chord->vStaffIdx());
Staff* vStaff = chord->staff(); // TODO: use current height at tick
if (n->mirror())
rxpos() -= n->ipos().x();
rxpos() += headWidth * .5;
if (placeAbove()) {
if (tight) {
if (chord->stem())
rxpos() -= 0.8 * sp;
rypos() -= 1.5 * sp;
}
else {
QRectF r = bbox().translated(m->pos() + s->pos() + chord->pos() + n->pos() + pos());
SkylineLine sk(false);
sk.add(r.x(), r.bottom(), r.width());
qreal d = sk.minDistance(ss->skyline().north());
qreal yd = 0.0;
if (d > 0.0 && isStyled(Pid::MIN_DISTANCE))
yd -= d + height() * .25;
// force extra space above staff & chord (but not other fingerings)
qreal top;
if (chord->up() && chord->beam() && stem) {
top = stem->y() + stem->bbox().top();
}
else {
Note* un = chord->upNote();
top = qMin(0.0, un->y() + un->bbox().top());
}
top -= md;
qreal diff = (bbox().bottom() + ipos().y() + yd + n->y()) - top;
if (diff > 0.0)
yd -= diff;
if (offsetChanged() != OffsetChange::NONE) {
// user moved element within the skyline
// we may need to adjust minDistance, yd, and/or offset
bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
rebaseMinDistance(md, yd, sp, rebase, inStaff);
}
rypos() += yd;
}
}
else {
if (tight) {
if (chord->stem())
rxpos() += 0.8 * sp;
rypos() += 1.5 * sp;
}
else {
QRectF r = bbox().translated(m->pos() + s->pos() + chord->pos() + n->pos() + pos());
SkylineLine sk(true);
sk.add(r.x(), r.top(), r.width());
qreal d = ss->skyline().south().minDistance(sk);
qreal yd = 0.0;
if (d > 0.0 && isStyled(Pid::MIN_DISTANCE))
yd += d + height() * .25;
// force extra space below staff & chord (but not other fingerings)
qreal bottom;
if (!chord->up() && chord->beam() && stem) {
bottom = stem->y() + stem->bbox().bottom();
}
else {
Note* dn = chord->downNote();
bottom = qMax(vStaff->height(), dn->y() + dn->bbox().bottom());
//.........这里部分代码省略.........
示例14: QLineF
void Glissando::setSize(const QSizeF& s)
{
line = QLineF(0.0, s.height(), s.width(), 0.0);
setbbox(QRectF(QPointF(), s));
}
示例15: vbox
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());
}
//.........这里部分代码省略.........