本文整理汇总了C++中Slur类的典型用法代码示例。如果您正苦于以下问题:C++ Slur类的具体用法?C++ Slur怎么用?C++ Slur使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Slur类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogMessage
bool Toolkit::Insert( std::string elementType, std::string startid, std::string endid )
{
LogMessage("Insert!");
if ( !m_doc.GetDrawingPage() ) return false;
Object *start = m_doc.GetDrawingPage()->FindChildByUuid(startid);
Object *end = m_doc.GetDrawingPage()->FindChildByUuid(endid);
// Check that start and end element exists
if ( !start || !end ) {
LogMessage("Elements start and end ids '%s' and '%s' could not be found", startid.c_str(), endid.c_str() );
return false;
}
// Check that it is a LayerElement
if ( !dynamic_cast<LayerElement*>(start) ) {
LogMessage("Element '%s' is not supported as start element", start->GetClassName().c_str() );
return false;
}
if ( !dynamic_cast<LayerElement*>(end) ) {
LogMessage("Element '%s' is not supported as end element", start->GetClassName().c_str() );
return false;
}
Measure *measure = dynamic_cast<Measure*>(start->GetFirstParent(&typeid(Measure)));
assert( measure );
if (elementType == "slur" ) {
Slur *slur = new Slur();
slur->SetStartid( startid );
slur->SetEndid( endid );
measure->AddMeasureElement(slur);
m_doc.PrepareDrawing();
return true;
}
return false;
}
示例2: QPointF
void SlurSegment::changeAnchor(MuseScoreView* viewer, int curGrip, ChordRest* cr)
{
Slur* sl = static_cast<Slur*>(slurTie());
if (curGrip == 0) {
((ChordRest*)sl->startElement())->removeSlurFor(sl);
sl->setStartElement(cr);
cr->addSlurFor(sl);
}
else {
((ChordRest*)sl->endElement())->removeSlurBack(sl);
sl->setEndElement(cr);
cr->addSlurBack(sl);
}
int segments = sl->spannerSegments().size();
ups[curGrip].off = QPointF();
sl->layout();
if (sl->spannerSegments().size() != segments) {
SlurSegment* newSegment = curGrip == 3 ? sl->backSegment() : sl->frontSegment();
score()->endCmd();
score()->startCmd();
viewer->startEdit(newSegment, curGrip);
score()->setLayoutAll(true);
}
}
示例3: edit
bool SlurSegment::edit(MuseScoreView* viewer, int curGrip, int key, Qt::KeyboardModifiers modifiers, const QString&)
{
Slur* sl = static_cast<Slur*>(slurTie());
if (key == Qt::Key_X) {
sl->setSlurDirection(sl->up() ? MScore::DOWN : MScore::UP);
sl->layout();
return true;
}
if (slurTie()->type() != SLUR)
return false;
if (!((modifiers & Qt::ShiftModifier)
&& ((subtype() == SEGMENT_SINGLE)
|| (subtype() == SEGMENT_BEGIN && curGrip == 0)
|| (subtype() == SEGMENT_END && curGrip == 3)
)))
return false;
ChordRest* cr = 0;
Element* e = curGrip == 0 ? sl->startElement() : sl->endElement();
Element* e1 = curGrip == 0 ? sl->endElement() : sl->startElement();
if (key == Qt::Key_Left)
cr = prevChordRest((ChordRest*)e);
else if (key == Qt::Key_Right)
cr = nextChordRest((ChordRest*)e);
if (cr == 0 || cr == (ChordRest*)e1)
return true;
changeAnchor(viewer, curGrip, cr);
return true;
}
示例4: spatium
void SlurSegment::editDrag(const EditData& ed)
{
qreal _spatium = spatium();
ups[ed.curGrip].off += (ed.delta / _spatium);
if (ed.curGrip == GRIP_START || ed.curGrip == GRIP_END) {
slurTie()->computeBezier(this);
//
// move anchor for slurs
//
Slur* slur = static_cast<Slur*>(slurTie());
Element* e = ed.view->elementNear(ed.pos);
if ((slur->type() == SLUR)
&& (
(ed.curGrip == GRIP_START && (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_BEGIN))
|| (ed.curGrip == GRIP_END && (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_END))
)
) {
if (e && e->type() == NOTE) {
Chord* chord = static_cast<Note*>(e)->chord();
if ((ed.curGrip == GRIP_END && chord != slur->endElement())
|| (ed.curGrip == GRIP_START && chord != slur->startElement())) {
changeAnchor(ed.view, ed.curGrip, chord);
QPointF p1 = ed.pos - ups[ed.curGrip].p - pagePos();
ups[ed.curGrip].off = p1 / _spatium;
return;
}
}
}
}
else if (ed.curGrip == GRIP_BEZIER1 || ed.curGrip == GRIP_BEZIER2)
slurTie()->computeBezier(this);
else if (ed.curGrip == GRIP_SHOULDER) {
ups[ed.curGrip].off = QPointF();
slurTie()->computeBezier(this, ed.delta);
}
else if (ed.curGrip == GRIP_DRAG) {
ups[GRIP_DRAG].off = QPointF();
setUserOff(userOff() + ed.delta);
}
}
示例5: foreach
foreach(Element* e, _gel) {
if (e->type() != SLUR)
continue;
Slur* s = (Slur*)e;
Element* n1 = s->startElement();
Element* n2 = s->endElement();
if (n1 == 0 || n2 == 0 || n1 == n2) {
printf("unconnected slur: removing\n");
if (n1) {
((ChordRest*)n1)->removeSlurFor(s);
((ChordRest*)n1)->removeSlurBack(s);
}
if (n1 == 0)
printf(" start at %d(%d) not found\n", s->tick(), s->track());
if (n2 == 0)
printf(" end at %d(%d) not found\n", s->tick2(), s->track2());
if ((n1 || n2) && (n1==n2))
printf(" start == end\n");
int idx = _gel.indexOf(s);
_gel.removeAt(idx);
}
}
示例6: Slur
Palette* MuseScore::newLinesPalette()
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Lines"));
sp->setMag(.8);
sp->setGrid(82, 35);
sp->setDrawGrid(true);
qreal w = gscore->spatium() * 8;
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, qApp->translate("lines", "Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setHairpinType(Hairpin::Type::CRESCENDO);
gabel0->setLen(w);
sp->append(gabel0, qApp->translate("lines", "Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setHairpinType(Hairpin::Type::DECRESCENDO);
gabel1->setLen(w);
sp->append(gabel1, QT_TRANSLATE_NOOP("Palette", "Diminuendo"));
Volta* volta = new Volta(gscore);
volta->setVoltaType(Volta::Type::CLOSED);
volta->setLen(w);
volta->setText("1.");
QList<int> il;
il.append(1);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Prima volta"));
volta = new Volta(gscore);
volta->setVoltaType(Volta::Type::CLOSED);
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta"));
volta = new Volta(gscore);
volta->setVoltaType(Volta::Type::CLOSED);
volta->setLen(w);
volta->setText("3.");
il.clear();
il.append(3);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Terza volta"));
volta = new Volta(gscore);
volta->setVoltaType(Volta::Type::OPEN);
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta 2"));
Ottava* ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_8VA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8va"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_8VB);
ottava->setLen(w);
ottava->setPlacement(Element::Placement::BELOW);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8vb"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_15MA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15ma"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_15MB);
ottava->setLen(w);
ottava->setPlacement(Element::Placement::BELOW);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15mb"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_22MA);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "22ma"));
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::Type::OTTAVA_22MB);
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "22mb"));
Pedal* pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginText("<sym>keyboardPedalPed</sym>");
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
pedal->setEndHook(true);
pedal = new Pedal(gscore);
//.........这里部分代码省略.........
示例7: setMscVersion
//.........这里部分代码省略.........
pf.copy(*pageFormat());
pf.read(e, this);
setPageFormat(pf);
}
else
e.skipCurrentElement();
}
else if (tag == "copyright" || tag == "rights") {
Text* text = new Text(this);
text->read(e);
text->layout();
setMetaTag("copyright", text->plainText());
delete text;
}
else if (tag == "movement-number")
setMetaTag("movementNumber", e.readElementText());
else if (tag == "movement-title")
setMetaTag("movementTitle", e.readElementText());
else if (tag == "work-number")
setMetaTag("workNumber", e.readElementText());
else if (tag == "work-title")
setMetaTag("workTitle", e.readElementText());
else if (tag == "source")
setMetaTag("source", e.readElementText());
else if (tag == "metaTag") {
QString name = e.attribute("name");
setMetaTag(name, e.readElementText());
}
else if (tag == "Part") {
Part* part = new Part(this);
part->read114(e);
_parts.push_back(part);
}
else if (tag == "Slur") {
Slur* slur = new Slur(this);
slur->read(e);
addSpanner(slur);
}
else if ((tag == "HairPin")
|| (tag == "Ottava")
|| (tag == "TextLine")
|| (tag == "Volta")
|| (tag == "Trill")
|| (tag == "Pedal")) {
Spanner* s = static_cast<Spanner*>(Element::name2Element(tag, this));
s->read(e);
if (s->track() == -1)
s->setTrack(e.track());
else
e.setTrack(s->track()); // update current track
if (s->tick() == -1)
s->setTick(e.tick());
else
e.initTick(s->tick()); // update current tick
if (s->track2() == -1)
s->setTrack2(s->track());
if (s->ticks() == 0) {
delete s;
qDebug("zero spanner %s ticks: %d", s->name(), s->ticks());
}
else {
addSpanner(s);
}
}
else if (tag == "Excerpt") {
if (MScore::noExcerpts)
示例8: Slur
Palette* MuseScore::newLinesPalette()
{
Palette* sp = new Palette;
sp->setName(qApp->translate("lines", "Lines"));
sp->setMag(.8);
sp->setGrid(82, 23);
sp->setDrawGrid(true);
qreal w = gscore->spatium() * 7;
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, qApp->translate("lines", "Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setSubtype(Hairpin::CRESCENDO);
gabel0->setLen(w);
sp->append(gabel0, qApp->translate("lines", "Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setSubtype(Hairpin::DECRESCENDO);
gabel1->setLen(w);
sp->append(gabel1, qApp->translate("lines", "Diminuendo"));
Volta* volta = new Volta(gscore);
volta->setSubtype(Volta::VOLTA_CLOSED);
volta->setLen(w);
volta->setText("1.");
QList<int> il;
il.append(1);
volta->setEndings(il);
sp->append(volta, qApp->translate("lines", "Prima volta"));
volta = new Volta(gscore);
volta->setSubtype(Volta::VOLTA_CLOSED);
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, qApp->translate("lines", "Seconda volta"));
volta = new Volta(gscore);
volta->setSubtype(Volta::VOLTA_CLOSED);
volta->setLen(w);
volta->setText("3.");
il.clear();
il.append(3);
volta->setEndings(il);
sp->append(volta, qApp->translate("lines", "Terza volta"));
volta = new Volta(gscore);
volta->setSubtype(Volta::VOLTA_OPEN);
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, qApp->translate("lines", "Seconda volta 2"));
Ottava* ottava = new Ottava(gscore);
ottava->setSubtype(Ottava::OTTAVA_8VA);
ottava->setLen(w);
sp->append(ottava, qApp->translate("lines", "8va"));
ottava = new Ottava(gscore);
ottava->setSubtype(Ottava::OTTAVA_15MA);
ottava->setLen(w);
sp->append(ottava, qApp->translate("lines", "15ma"));
ottava = new Ottava(gscore);
ottava->setSubtype(Ottava::OTTAVA_8VB);
ottava->setLen(w);
sp->append(ottava, qApp->translate("lines", "8vb"));
ottava = new Ottava(gscore);
ottava->setSubtype(Ottava::OTTAVA_15MB);
ottava->setLen(w);
sp->append(ottava, qApp->translate("lines", "15mb"));
Pedal* pedal = new Pedal(gscore);
pedal->setLen(w);
sp->append(pedal, qApp->translate("lines", "Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setEndHookType(HOOK_45);
sp->append(pedal, qApp->translate("lines", "Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginSymbol(noSym);
pedal->setBeginHook(true);
pedal->setBeginHookType(HOOK_45);
pedal->setEndHookType(HOOK_45);
sp->append(pedal, qApp->translate("lines", "Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginSymbol(noSym);
//.........这里部分代码省略.........
示例9: spatium
//.........这里部分代码省略.........
y = chordTopY - dy;
if (!headSide && type() == Element::Type::CHORD && chord->stem()) {
Stem* stem = chord->stem();
y = chordBotY + stem->stemLen();
if (chord->beam())
y -= score()->styleS(StyleIdx::beamWidth).val() * _spatium * .5;
x = stem->pos().x();
int line = lrint((y-0.5*_spatium) / _spatium);
if (line >= 0) // align between staff lines
y = line * _spatium - _spatium * .5;
else
y -= _spatium;
}
else {
if (line > 0)
y = ((line+1) & ~1) - 3;
else
y = line - 2;
y *= _spatium * .5;
}
}
dy += _spatium * .5;
a->setPos(x, y);
}
// reserve space for slur
bool botGap = false;
bool topGap = false;
#if 0 // TODO-S: optimize
for (Spanner* sp = _spannerFor; sp; sp = sp->next()) {
if (sp->type() != SLUR)
continue;
Slur* s = static_cast<Slur*>(sp);
if (s->up())
topGap = true;
else
botGap = true;
}
for (Spanner* sp = _spannerBack; sp; sp = sp->next()) {
if (sp->type() != SLUR)
continue;
Slur* s = static_cast<Slur*>(sp);
if (s->up())
topGap = true;
else
botGap = true;
}
#endif
if (botGap)
chordBotY += _spatium;
if (topGap)
chordTopY -= _spatium;
//
// pass 2
// place all articulations with anchor at chord/rest
//
n = _articulations.size();
for (int i = 0; i < n; ++i) {
Articulation* a = _articulations.at(i);
a->layout();
ArticulationAnchor aa = a->anchor();
if ((a->articulationType() == ArticulationType::Tenuto)
|| (a->articulationType() == ArticulationType::Staccato))
continue;
示例10: Palette
void MuseScore::lineMenu()
{
if (linePalette == 0) {
Palette* sp = new Palette();
sp->resize(400, 300);
linePalette = new PaletteScrollArea(sp);
linePalette->setRestrictHeight(false);
linePalette->setWindowTitle(tr("MuseScore: Lines"));
sp->setGrid(100, 30);
double l = gscore->spatium() * 8;
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, tr("Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setSubtype(0);
gabel0->setLen(l);
sp->append(gabel0, tr("Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setSubtype(1);
gabel1->setLen(l);
sp->append(gabel1, tr("Diminuendo"));
Volta* volta = new Volta(gscore);
volta->setLen(l);
volta->setText("1.");
QList<int> il;
il.clear();
il.append(1);
volta->setEndings(il);
volta->setSubtype(VOLTA_CLOSED);
sp->append(volta, tr("Prima volta"));
volta = new Volta(gscore);
volta->setLen(l);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
volta->setSubtype(VOLTA_CLOSED);
sp->append(volta, tr("Seconda volta"));
volta = new Volta(gscore);
volta->setLen(l);
volta->setText("3.");
il.clear();
il.append(3);
volta->setEndings(il);
volta->setSubtype(VOLTA_CLOSED);
sp->append(volta, tr("Terza volta"));
volta = new Volta(gscore);
volta->setLen(l);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
volta->setSubtype(VOLTA_OPEN);
sp->append(volta, tr("Seconda volta"));
//--------
Ottava* ottava = new Ottava(gscore);
ottava->setSubtype(0);
ottava->setLen(l);
sp->append(ottava, tr("8va"));
ottava = new Ottava(gscore);
ottava->setSubtype(1);
ottava->setLen(l);
sp->append(ottava, tr("15ma"));
ottava = new Ottava(gscore);
ottava->setSubtype(2);
ottava->setLen(l);
sp->append(ottava, tr("8vb"));
ottava = new Ottava(gscore);
ottava->setSubtype(3);
ottava->setLen(l);
sp->append(ottava, tr("15mb"));
//-------
Pedal* pedal = new Pedal(gscore);
pedal->setLen(l);
sp->append(pedal, tr("Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(l);
pedal->setEndHookType(HOOK_45);
sp->append(pedal, tr("Pedal"));
pedal = new Pedal(gscore);
pedal->setLen(l);
pedal->setBeginSymbol(-1);
//.........这里部分代码省略.........
示例11: populateIconPalette
//.........这里部分代码省略.........
sp = new Palette;
sp->setName(tr("Barlines"));
sp->setMag(0.8);
sp->setGrid(42, 38);
struct {
BarLineType type;
const char* name;
} t[] = {
{ NORMAL_BAR, QT_TR_NOOP("Normal") },
{ BROKEN_BAR, QT_TR_NOOP("Dashed") },
{ END_BAR, QT_TR_NOOP("End Bar") },
{ DOUBLE_BAR, QT_TR_NOOP("Double Bar") },
{ START_REPEAT, QT_TR_NOOP("Start Repeat") },
{ END_REPEAT, QT_TR_NOOP("End Repeat") },
{ END_START_REPEAT, QT_TR_NOOP("End-Start Repeat") },
};
for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) {
BarLine* b = new BarLine(gscore);
b->setSubtype(t[i].type);
sp->append(b, tr(t[i].name));
}
paletteBox->addPalette(sp);
//-----------------------------------
// Lines
//-----------------------------------
sp = new Palette;
sp->setName(tr("Lines"));
sp->setMag(.8);
sp->setGrid(82, 23);
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, tr("Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setSubtype(0);
sp->append(gabel0, tr("Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setSubtype(1);
sp->append(gabel1, tr("Diminuendo"));
Volta* volta = new Volta(gscore);
volta->setSubtype(VOLTA_CLOSED);
volta->setText("1.");
QList<int> il;
il.append(1);
volta->setEndings(il);
sp->append(volta, tr("Prima volta"));
volta = new Volta(gscore);
volta->setSubtype(VOLTA_CLOSED);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, tr("Seconda volta"));
volta = new Volta(gscore);
volta->setSubtype(VOLTA_CLOSED);
volta->setText("3.");
il.clear();
il.append(3);