void Stem::updateGrips(int* grips, QRectF* grip) const { *grips = 1; grip[0].translate(pagePos() + line.p2()); }
void Tie::layout() { qreal _spatium = spatium(); // // show short bow // if (startNote() == 0 || endNote() == 0) { if (startNote() == 0) { qDebug("Tie::layout(): no start note"); return; } Chord* c1 = startNote()->chord(); if (_slurDirection == MScore::Direction::AUTO) { if (c1->measure()->mstaff(c1->staffIdx())->hasVoices) { // in polyphonic passage, ties go on the stem side _up = c1->up(); } else _up = !c1->up(); } else _up = _slurDirection == MScore::Direction::UP ? true : false; fixupSegments(1); SlurSegment* segment = segmentAt(0); segment->setSpannerSegmentType(SpannerSegmentType::SINGLE); segment->setSystem(startNote()->chord()->segment()->measure()->system()); SlurPos sPos; slurPos(&sPos); segment->layout(sPos.p1, sPos.p2); return; } calculateDirection(); qreal w = startNote()->headWidth(); qreal xo1 = w * 1.12; qreal h = w * 0.3; qreal yo = _up ? -h : h; QPointF off1(xo1, yo); QPointF off2(0.0, yo); #if 0 // yet(?) unused QPointF ppos(pagePos()); #endif // TODO: cleanup SlurPos sPos; slurPos(&sPos); // p1, p2, s1, s2 QList<System*>* systems = score()->systems(); setPos(0, 0); //--------------------------------------------------------- // count number of segments, if no change, all // user offsets (drags) are retained //--------------------------------------------------------- int sysIdx1 = systems->indexOf(sPos.system1); if (sysIdx1 == -1) { qDebug("system not found"); foreach(System* s, *systems) qDebug(" search %p in %p", sPos.system1, s); return; } int sysIdx2 = systems->indexOf(sPos.system2); if (sysIdx2 < 0) sysIdx2 = sysIdx1; unsigned nsegs = sysIdx2 - sysIdx1 + 1; fixupSegments(nsegs); int i = 0; for (uint ii = 0; ii < nsegs; ++ii) { System* system = (*systems)[sysIdx1++]; if (system->isVbox()) continue; SlurSegment* segment = segmentAt(i); segment->setSystem(system); // case 1: one segment if (sPos.system1 == sPos.system2) { segment->layout(sPos.p1, sPos.p2); segment->setSpannerSegmentType(SpannerSegmentType::SINGLE); } // case 2: start segment else if (i == 0) { qreal x = system->bbox().width(); segment->layout(sPos.p1, QPointF(x, sPos.p1.y())); segment->setSpannerSegmentType(SpannerSegmentType::BEGIN); } // case 4: end segment else { qreal x = firstNoteRestSegmentX(system) - 2 * _spatium; segment->layout(QPointF(x, sPos.p2.y()), sPos.p2); segment->setSpannerSegmentType(SpannerSegmentType::END); } ++i; } }
void Stem::updateGrips(Grip* defaultGrip, QVector<QRectF>& grip) const { *defaultGrip = Grip::START; grip[0].translate(pagePos() + line.p2()); }
bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) const { if ( itemElem.isNull() ) { return false; } QDomElement composerItemElem = doc.createElement( "ComposerItem" ); //frame if ( mFrame ) { composerItemElem.setAttribute( "frame", "true" ); } else { composerItemElem.setAttribute( "frame", "false" ); } //frame if ( mBackground ) { composerItemElem.setAttribute( "background", "true" ); } else { composerItemElem.setAttribute( "background", "false" ); } //scene rect QPointF pagepos = pagePos(); composerItemElem.setAttribute( "x", QString::number( pos().x() ) ); composerItemElem.setAttribute( "y", QString::number( pos().y() ) ); composerItemElem.setAttribute( "page", page() ); composerItemElem.setAttribute( "pagex", QString::number( pagepos.x() ) ); composerItemElem.setAttribute( "pagey", QString::number( pagepos.y() ) ); composerItemElem.setAttribute( "width", QString::number( rect().width() ) ); composerItemElem.setAttribute( "height", QString::number( rect().height() ) ); composerItemElem.setAttribute( "positionMode", QString::number(( int ) mLastUsedPositionMode ) ); composerItemElem.setAttribute( "zValue", QString::number( zValue() ) ); composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) ); composerItemElem.setAttribute( "frameJoinStyle", QgsSymbolLayerV2Utils::encodePenJoinStyle( mFrameJoinStyle ) ); composerItemElem.setAttribute( "itemRotation", QString::number( mItemRotation ) ); composerItemElem.setAttribute( "uuid", mUuid ); composerItemElem.setAttribute( "id", mId ); //position lock for mouse moves/resizes if ( mItemPositionLocked ) { composerItemElem.setAttribute( "positionLock", "true" ); } else { composerItemElem.setAttribute( "positionLock", "false" ); } composerItemElem.setAttribute( "lastValidViewScaleFactor", QString::number( mLastValidViewScaleFactor ) ); //frame color QDomElement frameColorElem = doc.createElement( "FrameColor" ); QColor frameColor = pen().color(); frameColorElem.setAttribute( "red", QString::number( frameColor.red() ) ); frameColorElem.setAttribute( "green", QString::number( frameColor.green() ) ); frameColorElem.setAttribute( "blue", QString::number( frameColor.blue() ) ); frameColorElem.setAttribute( "alpha", QString::number( frameColor.alpha() ) ); composerItemElem.appendChild( frameColorElem ); //background color QDomElement bgColorElem = doc.createElement( "BackgroundColor" ); QColor bgColor = brush().color(); bgColorElem.setAttribute( "red", QString::number( bgColor.red() ) ); bgColorElem.setAttribute( "green", QString::number( bgColor.green() ) ); bgColorElem.setAttribute( "blue", QString::number( bgColor.blue() ) ); bgColorElem.setAttribute( "alpha", QString::number( bgColor.alpha() ) ); composerItemElem.appendChild( bgColorElem ); //blend mode composerItemElem.setAttribute( "blendMode", QgsMapRenderer::getBlendModeEnum( mBlendMode ) ); //transparency composerItemElem.setAttribute( "transparency", QString::number( mTransparency ) ); itemElem.appendChild( composerItemElem ); return true; }
void BarLine::endEditDrag() { if (yoff1 == 0.0 && yoff2 == 0.0) // if no drag, do nothing return; qreal y1, y2; getY(&y1, &y2); qreal ay0 = pagePos().y(); qreal ay2 = ay0 + y2; // absolute (page-relative) bar line bottom coord int staffIdx1 = staffIdx(); int staffIdx2; System* syst; if (parent()->type() == Element::Type::SYSTEM) { syst = static_cast<System*>(parent()); } else { syst = static_cast<Segment*>(parent())->measure()->system(); } qreal systTopY = syst->pagePos().y(); // determine new span value int numOfStaves = syst->staves()->size(); if (staffIdx1 + 1 >= numOfStaves) // if initial staff is last staff, ending staff must be the same staffIdx2 = staffIdx1; else { // if there are other staves after it, look for staff nearest to bar line bottom coord qreal staff1TopY = syst->staff(staffIdx1)->y() + systTopY; for (staffIdx2 = staffIdx1 + 1; staffIdx2 < numOfStaves; ++staffIdx2) { // compute 1st staff height, absolute top Y of 2nd staff and height of blank between the staves Staff * staff1 = score()->staff(staffIdx2-1); qreal staff1Hght = (staff1->lines()-1) * staff1->lineDistance() * spatium(); qreal staff2TopY = systTopY + syst->staff(staffIdx2)->y(); qreal blnkBtwnStaff = staff2TopY - staff1TopY - staff1Hght; // if bar line bottom coord is above than mid-way of blank between staves... if (ay2 < (staff1TopY + staff1Hght + blnkBtwnStaff * .5)) break; // ...staff 1 is ending staff // if bar line is below, advance to next staff staff1TopY = staff2TopY; } staffIdx2 -= 1; } int newSpan = staffIdx2 - staffIdx1 + 1; // determine new spanFrom and spanTo values int newSpanFrom, newSpanTo; Staff * staff2 = score()->staff(staffIdx2); int Staff1lines = staff()->lines(); int Staff2lines = staff2->lines(); if (shiftDrag) { // if precision dragging newSpanFrom = _spanFrom; if(yoff1 != 0.0) { // round bar line top coord to nearest line of 1st staff (in half line dist units) newSpanFrom = ((int)floor(y1 / (staff()->lineDistance() * spatium()) + 0.5 )) * 2; // min = 1 line dist above 1st staff line | max = 1 line dist below last staff line if(newSpanFrom < MIN_BARLINE_SPAN_FROMTO) newSpanFrom = MIN_BARLINE_SPAN_FROMTO; if(newSpanFrom > Staff1lines*2) newSpanFrom = Staff1lines*2; } newSpanTo = _spanTo; if(yoff2 != 0.0) { // round bar line bottom coord to nearest line of 2nd staff (in half line dist units) qreal staff2TopY = systTopY + syst->staff(staffIdx2)->y(); newSpanTo = ((int)floor( (ay2 - staff2TopY) / (staff2->lineDistance() * spatium()) + 0.5 )) * 2; // min = 1 line dist above 1st staff line | max = 1 line dist below last staff line if(newSpanTo < MIN_BARLINE_SPAN_FROMTO) newSpanTo = MIN_BARLINE_SPAN_FROMTO; if(newSpanTo > Staff2lines*2) newSpanTo = Staff2lines*2; } // shiftDrag = false; // NO: a last call to this function is made when exiting editing: } // it would find shiftDrag = false and reset extrema to coarse resolution else { // if coarse dragging newSpanFrom = 0; newSpanTo = (Staff2lines - 1) * 2; } // if any value changed, update if(newSpan != _span || newSpanFrom != _spanFrom || newSpanTo != _spanTo) { _span = newSpan; _spanFrom = newSpanFrom; _spanTo = newSpanTo; } yoff1 = yoff2 = 0.0; }
void Bracket::updateGrips(int* grips, QRectF* grip) const { *grips = 1; grip[0].translate(QPointF(0.0, h2 * 2) + QPointF(0.0, yoff) + pagePos()); }
void Bracket::updateGrips(int* grips, int* defaultGrip, QRectF* grip) const { *grips = 1; *defaultGrip = 0; grip[0].translate(QPointF(0.0, h2 * 2) + pagePos()); }
void Stem::updateGrips(int* grips, QRectF* grip) const { *grips = 1; QPointF p(0.0, stemLen()); grip[0].translate(pagePos() + p); }
void Bracket::updateGrips(Grip* defaultGrip, QVector<QRectF>& grip) const { *defaultGrip = Grip::START; grip[0].translate(QPointF(0.0, h2 * 2) + pagePos()); }
bool QgsComposerItem::_writeXml( QDomElement &itemElem, QDomDocument &doc ) const { if ( itemElem.isNull() ) { return false; } QDomElement composerItemElem = doc.createElement( QStringLiteral( "ComposerItem" ) ); //frame if ( mFrame ) { composerItemElem.setAttribute( QStringLiteral( "frame" ), QStringLiteral( "true" ) ); } else { composerItemElem.setAttribute( QStringLiteral( "frame" ), QStringLiteral( "false" ) ); } //background if ( mBackground ) { composerItemElem.setAttribute( QStringLiteral( "background" ), QStringLiteral( "true" ) ); } else { composerItemElem.setAttribute( QStringLiteral( "background" ), QStringLiteral( "false" ) ); } //scene rect QPointF pagepos = pagePos(); composerItemElem.setAttribute( QStringLiteral( "x" ), QString::number( pos().x() ) ); composerItemElem.setAttribute( QStringLiteral( "y" ), QString::number( pos().y() ) ); composerItemElem.setAttribute( QStringLiteral( "page" ), page() ); composerItemElem.setAttribute( QStringLiteral( "pagex" ), QString::number( pagepos.x() ) ); composerItemElem.setAttribute( QStringLiteral( "pagey" ), QString::number( pagepos.y() ) ); composerItemElem.setAttribute( QStringLiteral( "width" ), QString::number( rect().width() ) ); composerItemElem.setAttribute( QStringLiteral( "height" ), QString::number( rect().height() ) ); composerItemElem.setAttribute( QStringLiteral( "positionMode" ), QString::number( static_cast< int >( mLastUsedPositionMode ) ) ); composerItemElem.setAttribute( QStringLiteral( "zValue" ), QString::number( zValue() ) ); composerItemElem.setAttribute( QStringLiteral( "outlineWidth" ), QString::number( mFrameWidth ) ); composerItemElem.setAttribute( QStringLiteral( "frameJoinStyle" ), QgsSymbolLayerUtils::encodePenJoinStyle( mFrameJoinStyle ) ); composerItemElem.setAttribute( QStringLiteral( "itemRotation" ), QString::number( mItemRotation ) ); composerItemElem.setAttribute( QStringLiteral( "uuid" ), mUuid ); composerItemElem.setAttribute( QStringLiteral( "id" ), mId ); composerItemElem.setAttribute( QStringLiteral( "visibility" ), isVisible() ); //position lock for mouse moves/resizes if ( mItemPositionLocked ) { composerItemElem.setAttribute( QStringLiteral( "positionLock" ), QStringLiteral( "true" ) ); } else { composerItemElem.setAttribute( QStringLiteral( "positionLock" ), QStringLiteral( "false" ) ); } composerItemElem.setAttribute( QStringLiteral( "lastValidViewScaleFactor" ), QString::number( mLastValidViewScaleFactor ) ); //frame color QDomElement frameColorElem = doc.createElement( QStringLiteral( "FrameColor" ) ); frameColorElem.setAttribute( QStringLiteral( "red" ), QString::number( mFrameColor.red() ) ); frameColorElem.setAttribute( QStringLiteral( "green" ), QString::number( mFrameColor.green() ) ); frameColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( mFrameColor.blue() ) ); frameColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( mFrameColor.alpha() ) ); composerItemElem.appendChild( frameColorElem ); //background color QDomElement bgColorElem = doc.createElement( QStringLiteral( "BackgroundColor" ) ); bgColorElem.setAttribute( QStringLiteral( "red" ), QString::number( mBackgroundColor.red() ) ); bgColorElem.setAttribute( QStringLiteral( "green" ), QString::number( mBackgroundColor.green() ) ); bgColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( mBackgroundColor.blue() ) ); bgColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( mBackgroundColor.alpha() ) ); composerItemElem.appendChild( bgColorElem ); //blend mode composerItemElem.setAttribute( QStringLiteral( "blendMode" ), QgsPainting::getBlendModeEnum( mBlendMode ) ); //opacity composerItemElem.setAttribute( QStringLiteral( "opacity" ), QString::number( mOpacity ) ); composerItemElem.setAttribute( QStringLiteral( "excludeFromExports" ), mExcludeFromExports ); QgsComposerObject::writeXml( composerItemElem, doc ); itemElem.appendChild( composerItemElem ); return true; }
QPointF Rest::stemPos() const { return pagePos(); }