本文整理汇总了C++中MasterScore::excerpts方法的典型用法代码示例。如果您正苦于以下问题:C++ MasterScore::excerpts方法的具体用法?C++ MasterScore::excerpts怎么用?C++ MasterScore::excerpts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MasterScore
的用法示例。
在下文中一共展示了MasterScore::excerpts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ex
void TestLinks::test5LinkedParts_94911()
{
MCursor c;
c.setTimeSig(Fraction(4,4));
c.createScore("test");
c.addPart("electric-guitar");
c.move(0, 0); // move to track 0 tick 0
c.addKeySig(Key(1));
c.addTimeSig(Fraction(4,4));
c.addChord(60, TDuration(TDuration::DurationType::V_WHOLE));
MasterScore* score = c.score();
score->addText("title", "Title");
score->doLayout();
// delete chord
Measure* m = score->firstMeasure();
Segment* s = m->first(Segment::Type::ChordRest);
Element* e = s->element(0);
QVERIFY(e->type() == ElementType::CHORD);
score->select(e);
score->cmdDeleteSelection();
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links() == nullptr);
// create parts//
score->startCmd();
QList<Part*> parts;
parts.append(score->parts().at(0));
Score* nscore = new Score(score);
Excerpt ex(score);
ex.setPartScore(nscore);
ex.setTitle("Guitar");
ex.setParts(parts);
Excerpt::createExcerpt(&ex);
QVERIFY(nscore);
score->undo(new AddExcerpt(&ex));
score->endCmd();
// we should have now 1 staff and 2 linked rests
QVERIFY(score->staves().size() == 1);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 2);
// add a linked staff
score->startCmd();
Staff* oStaff = score->staff(0);
Staff* staff = new Staff(score);
staff->setPart(oStaff->part());
score->undoInsertStaff(staff, 1);
Excerpt::cloneStaff(oStaff, staff);
score->endCmd();
// we should have now 2 staves and 3 linked rests
QCOMPARE(score->staves().size(), 2);
QCOMPARE(nscore->staves().size(), 1);
QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
e = s->element(4);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
QVERIFY(score->excerpts().size() == 1);
// undo
score->undoStack()->undo();
// we should have now 1 staves and 2 linked rests
QVERIFY(score->staves().size() == 1);
QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 2);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 2);
QVERIFY(score->excerpts().size() == 1);
// redo
score->undoStack()->redo();
// we should have now 2 staves and 3 linked rests
QVERIFY(score->staves().size() == 2);
QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3);
e = s->element(0);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
e = s->element(4);
QVERIFY(e->type() == ElementType::REST);
QVERIFY(e->links()->size() == 3);
QVERIFY(score->excerpts().size() == 1);
}
示例2: editInstrList
//.........这里部分代码省略.........
int n = s->nstaves();
int curSpan = 0;
for (int j = 0; j < n; ++j) {
Staff* staff = s->staff(j);
int span = staff->barLineSpan();
int setSpan = -1;
// determine if we need to update barline span
if (curSpan == 0) {
// no current span; this staff must start a new one
if (span == 0) {
// no span; this staff must have been within a span
// update it to a span of 1
setSpan = j;
}
else if (span > (n - j)) {
// span too big; staves must have been removed
// reduce span to last staff
setSpan = n - j;
}
else if (span > 1 && staff->barLineTo() > 0) {
// TODO: check if span is still valid
// (true if the last staff is the same as it was before this edit)
// the code here fixes https://musescore.org/en/node/41786
// but by forcing an update,
// we lose custom modifications to staff barLineTo
// at least this happens only for span > 1, and not for Mensurstrich (barLineTo<=0)
setSpan = span; // force update to pick up new barLineTo value
}
else {
// this staff starts a span
curSpan = span;
}
}
else if (span && staff->barLineTo() > 0) {
// within a current span; staff must have span of 0
// except for Mensurstrich (barLineTo<=0)
// for consistency with Barline::endEdit,
// don't special case 1-line staves
//TODO s->undoChangeBarLineSpan(staff, 0, 0, (staff->lines() - 1) * 2);
}
// update barline span if necessary
if (setSpan > 0) {
// this staff starts a span
curSpan = setSpan;
// calculate spanFrom and spanTo values
// int spanFrom = staff->lines() == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : 0;
// int linesTo = masterScore->staff(i + setSpan - 1)->lines();
// int spanTo = linesTo == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (linesTo - 1) * 2;
//TODO s->undoChangeBarLineSpan(staff, setSpan, spanFrom, spanTo);
}
// count off one from barline span
--curSpan;
// update brackets
for (BracketItem* bi : staff->brackets()) {
if ((bi->bracketSpan() > (n - j)))
bi->undoChangeProperty(Pid::BRACKET_SPAN, n - j);
}
}
}
//
// there should be at least one measure
//
if (masterScore->measures()->size() == 0)
masterScore->insertMeasure(ElementType::MEASURE, 0, false);
const QList<Excerpt*> excerpts(masterScore->excerpts()); // excerpts list may change in the loop below
for (Excerpt* excerpt : excerpts) {
QList<Staff*> sl = excerpt->partScore()->staves();
QMultiMap<int, int> tr = excerpt->tracks();
if (sl.size() == 0)
masterScore->undo(new RemoveExcerpt(excerpt));
else {
for (Staff* s : sl) {
const LinkedElements* sll = s->links();
for (auto le : *sll) {
Staff* ss = toStaff(le);
if (ss->primaryStaff()) {
for (int j = s->idx() * VOICES; j < (s->idx() + 1) * VOICES; j++) {
int strack = tr.key(j, -1);
if (strack != -1 && ((strack & ~3) == ss->idx()))
break;
else if (strack != -1)
tr.insert(ss->idx() + strack % VOICES, tr.value(strack, -1));
}
}
}
}
}
}
masterScore->setLayoutAll();
masterScore->endCmd();
masterScore->rebuildAndUpdateExpressive(MuseScore::synthesizer("Fluid"));
seq->initInstruments();
}