本文整理汇总了C++中Articulation类的典型用法代码示例。如果您正苦于以下问题:C++ Articulation类的具体用法?C++ Articulation怎么用?C++ Articulation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Articulation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void ChordRest::add(Element* e)
{
e->setParent(this);
e->setTrack(track());
switch(e->type()) {
case Element::Type::ARTICULATION:
{
Articulation* a = static_cast<Articulation*>(e);
_articulations.push_back(a);
if (a->timeStretch() != 1.0)
score()->fixTicks(); // update tempo map
}
break;
case Element::Type::LYRICS:
{
Lyrics* l = static_cast<Lyrics*>(e);
int size = _lyricsList.size();
if (l->no() >= size) {
for (int i = size-1; i < l->no(); ++i)
_lyricsList.append(0);
}
_lyricsList[l->no()] = l;
}
break;
default:
qFatal("ChordRest::add: unknown element %s", e->name());
break;
}
}
示例2: segment
Element* BarLine::drop(const DropData& data)
{
Element* e = data.element;
int type = e->type();
if (type == BAR_LINE) {
BarLine* bl = static_cast<BarLine*>(e);
BarLineType st = bl->subtype();
if (st == subtype()) {
delete e;
return 0;
}
Measure* m = segment()->measure();
if (st == START_REPEAT) {
m = m->nextMeasure();
if (m == 0) {
delete e;
return 0;
}
}
m->drop(data);
}
else if (type == ARTICULATION) {
Articulation* atr = static_cast<Articulation*>(e);
atr->setParent(this);
atr->setTrack(track());
score()->select(atr, SELECT_SINGLE, 0);
score()->undoAddElement(atr);
}
return 0;
}
示例3: DurationElement
ChordRest::ChordRest(const ChordRest& cr, bool link)
: DurationElement(cr)
{
_durationType = cr._durationType;
_staffMove = cr._staffMove;
_beam = 0;
_tabDur = 0; // tab sur. symb. depends upon context: can't be
// simply copied from another CR
for (Articulation* a : cr._articulations) { // make deep copy
Articulation* na = new Articulation(*a);
if (link)
na->linkTo(a);
na->setParent(this);
na->setTrack(track());
_articulations.append(na);
}
_beamMode = cr._beamMode;
_up = cr._up;
_small = cr._small;
_crossMeasure = cr._crossMeasure;
_space = cr._space;
for (Lyrics* l : cr._lyricsList) { // make deep copy
if (l == 0)
continue;
Lyrics* nl = new Lyrics(*l);
if (link)
nl->linkTo(l);
nl->setParent(this);
nl->setTrack(track());
_lyricsList.append(nl);
}
}
示例4: Articulation
Palette* MuseScore::newArticulationsPalette()
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Articulations && Ornaments"));
sp->setGrid(42, 25);
sp->setDrawGrid(true);
for (int i = 0; i < int(ArticulationType::ARTICULATIONS); ++i) {
Articulation* s = new Articulation(gscore);
s->setArticulationType(ArticulationType(i));
sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeUserName())));
}
Bend* bend = new Bend(gscore);
bend->points().append(PitchValue(0, 0, false));
bend->points().append(PitchValue(15, 100, false));
bend->points().append(PitchValue(60, 100, false));
sp->append(bend, qApp->translate("articulation", "Bend"));
TremoloBar* tb = new TremoloBar(gscore);
tb->points().append(PitchValue(0, 0, false)); // "Dip"
tb->points().append(PitchValue(30, -100, false));
tb->points().append(PitchValue(60, 0, false));
sp->append(tb, qApp->translate("articulation", "Tremolo Bar"));
return sp;
}
示例5: getY
void BarLine::layout()
{
qreal y1, y2;
getY(&y1, &y2);
qreal _spatium = spatium();
qreal dw = layoutWidth(score(), barLineType(), magS());
QRectF r(0.0, y1, dw, y2-y1);
if (score()->styleB(ST_repeatBarTips)) {
qreal mags = magS();
int si = score()->symIdx();
switch (barLineType()) {
case START_REPEAT:
r |= symbols[si][brackettipsRightUp].bbox(mags).translated(0, y1);
r |= symbols[si][brackettipsRightDown].bbox(mags).translated(0, y2);
break;
case END_REPEAT:
r |= symbols[si][brackettipsLeftUp].bbox(mags).translated(0, y1);
r |= symbols[si][brackettipsLeftDown].bbox(mags).translated(0, y2);
break;
case END_START_REPEAT:
{
qreal lw = point(score()->styleS(ST_barWidth));
qreal lw2 = point(score()->styleS(ST_endBarWidth));
qreal d1 = point(score()->styleS(ST_endBarDistance));
const Sym& dotsym = symbols[score()->symIdx()][dotSym];
qreal dotw = dotsym.width(mags);
qreal x = dotw + 2 * d1 + lw + lw2 * .5; // thick bar
r |= symbols[si][brackettipsRightUp].bbox(mags).translated(x, y1);
r |= symbols[si][brackettipsRightDown].bbox(mags).translated(x, y2);
r |= symbols[si][brackettipsLeftUp].bbox(mags).translated(x, y1);
r |= symbols[si][brackettipsLeftDown].bbox(mags).translated(x, y2);
}
break;
default:
break;
}
}
foreach(Element* e, _el) {
e->layout();
if (e->type() == ARTICULATION) {
Articulation* a = static_cast<Articulation*>(e);
MScore::Direction dir = a->direction();
qreal distance = 0.5 * _spatium;
qreal x = width() * .5;
if (dir == MScore::DOWN) {
qreal botY = y2 + distance;
a->setPos(QPointF(x, botY));
}
else {
qreal topY = y1 - distance;
a->setPos(QPointF(x, topY));
}
}
}
示例6: staff
void BarLine::read(XmlReader& e)
{
// if bar line belongs to a staff, span values default to staff values
if (staff()) {
_span = staff()->barLineSpan();
_spanFrom = staff()->barLineFrom();
_spanTo = staff()->barLineTo();
}
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "subtype") {
bool ok;
const QString& val(e.readElementText());
int i = val.toInt(&ok);
if (!ok)
setBarLineType(val);
else {
BarLineType ct = NORMAL_BAR;
switch (i) {
default:
case 0: ct = NORMAL_BAR; break;
case 1: ct = DOUBLE_BAR; break;
case 2: ct = START_REPEAT; break;
case 3: ct = END_REPEAT; break;
case 4: ct = BROKEN_BAR; break;
case 5: ct = END_BAR; break;
case 6: ct = END_START_REPEAT; break;
case 7: ct = DOTTED_BAR; break;
}
setBarLineType(ct);
}
if (parent() && parent()->type() == SEGMENT) {
Measure* m = static_cast<Segment*>(parent())->measure();
if (barLineType() != m->endBarLineType())
_customSubtype = true;
}
}
else if (tag == "customSubtype")
_customSubtype = e.readInt();
else if (tag == "span") {
_span = e.readInt();
_spanFrom = e.intAttribute("from", _spanFrom);
_spanTo = e.intAttribute("to", _spanTo);
// WARNING: following statements assume staff and staff bar line spans are correctly set
if (staff() && (_span != staff()->barLineSpan()
|| _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo()))
_customSpan = true;
}
else if (tag == "Articulation") {
Articulation* a = new Articulation(score());
a->read(e);
add(a);
}
else if (!Element::readProperties(e))
e.unknown();
}
}
示例7: staff
void BarLine::read(const QDomElement& de)
{
// if bar line belongs to a staff, span values default to staff values
if(staff()) {
_span = staff()->barLineSpan();
_spanFrom = staff()->barLineFrom();
_spanTo = staff()->barLineTo();
}
for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
const QString& tag(e.tagName());
const QString& val(e.text());
if (tag == "subtype") {
bool ok;
int i = val.toInt(&ok);
if (!ok)
setSubtype(val);
else {
BarLineType ct = NORMAL_BAR;
switch (i) {
default:
case 0: ct = NORMAL_BAR; break;
case 1: ct = DOUBLE_BAR; break;
case 2: ct = START_REPEAT; break;
case 3: ct = END_REPEAT; break;
case 4: ct = BROKEN_BAR; break;
case 5: ct = END_BAR; break;
case 6: ct = END_START_REPEAT; break;
case 7: ct = DOTTED_BAR; break;
}
setSubtype(ct);
}
if(parent() && parent()->type() == SEGMENT) {
Measure* m = static_cast<Segment*>(parent())->measure();
if(subtype() != m->endBarLineType())
setCustomSubtype(true);
}
}
else if (tag == "customSubtype")
setCustomSubtype(val.toInt() != 0);
else if (tag == "span") {
_span = val.toInt();
_spanFrom = e.attribute("from", QString::number(_spanFrom)).toInt();
_spanTo = e.attribute("to", QString::number(_spanTo)).toInt();
// WARNING: following statements assume staff and staff bar line spans are correctly set
if(staff() && (_span != staff()->barLineSpan()
|| _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo()))
_customSpan = true;
}
else if (tag == "Articulation") {
Articulation* a = new Articulation(score());
a->read(e);
add(a);
}
else if (!Element::readProperties(e))
domError(e);
}
}
示例8: readScore
void TestNote::grace()
{
Score* score = readScore(DIR + "grace.mscx");
score->doLayout();
Chord* chord = score->firstMeasure()->findChord(0, 0);
Note* note = chord->upNote();
// create
score->setGraceNote(chord, note->pitch(), NoteType::APPOGGIATURA, MScore::division/2);
Chord* gc = chord->graceNotes().first();
Note* gn = gc->notes().first();
// Note* n = static_cast<Note*>(writeReadElement(gn));
// QCOMPARE(n->noteType(), NoteType::APPOGGIATURA);
// delete n;
// tie
score->startCmd();
score->select(gn);
score->cmdAddTie();
score->endCmd();
// n = static_cast<Note*>(writeReadElement(gn));
// QVERIFY(n->tieFor() != 0);
// delete n;
// tremolo
score->startCmd();
Tremolo* tr = new Tremolo(score);
tr->setTremoloType(TremoloType::R16);
tr->setParent(gc);
tr->setTrack(gc->track());
score->undoAddElement(tr);
score->endCmd();
// Chord* c = static_cast<Chord*>(writeReadElement(gc));
// QVERIFY(c->tremolo() != 0);
// delete c;
// articulation
score->startCmd();
Articulation* ar = new Articulation(score);
ar->setArticulationType(ArticulationType::Sforzatoaccent);
ar->setParent(gc);
ar->setTrack(gc->track());
score->undoAddElement(ar);
score->endCmd();
// c = static_cast<Chord*>(writeReadElement(gc));
// QVERIFY(c->articulations().size() == 1);
// delete c;
QVERIFY(saveCompareScore(score, "grace-test.mscx", DIR + "grace-ref.mscx"));
}
示例9: switch
Element* Rest::drop(const DropData& data)
{
Element* e = data.element;
switch (e->type()) {
case ElementType::ARTICULATION:
{
Articulation* a = static_cast<Articulation*>(e);
if (a->articulationType() != ArticulationType::Fermata
|| !score()->addArticulation(this, a)) {
delete e;
e = 0;
}
}
return e;
case ElementType::CHORD:
{
Chord* c = static_cast<Chord*>(e);
Note* n = c->upNote();
Direction dir = c->stemDirection();
// score()->select(0, SelectType::SINGLE, 0);
NoteVal nval;
nval.pitch = n->pitch();
nval.headGroup = n->headGroup();
Fraction d = score()->inputState().duration().fraction();
if (!d.isZero()) {
Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir);
if (seg) {
ChordRest* cr = static_cast<ChordRest*>(seg->element(track()));
if (cr)
score()->nextInputPos(cr, true);
}
}
delete e;
}
break;
case ElementType::REPEAT_MEASURE:
delete e;
if (durationType().type() == TDuration::DurationType::V_MEASURE) {
measure()->cmdInsertRepeatMeasure(staffIdx());
}
break;
default:
return ChordRest::drop(data);
}
return 0;
}
示例10: fixArticulations
static qreal fixArticulations(qreal yo, Chord* c, qreal _up)
{
//
// handle special case of tenuto and staccato;
//
QList<Articulation*>* al = c->getArticulations();
if (al->size() >= 2) {
Articulation* a = al->at(1);
if (a->subtype() == Articulation_Tenuto || a->subtype() == Articulation_Staccato)
return a->y() + (a->height() + c->score()->spatium() * .3) * _up;
}
else if (al->size() >= 1) {
Articulation* a = al->at(0);
if (a->subtype() == Articulation_Tenuto || a->subtype() == Articulation_Staccato)
return a->y() + (a->height() + c->score()->spatium() * .3) * _up;
}
return yo;
}
示例11: Palette
void MuseScore::noteAttributesMenu()
{
if (noteAttributesPalette == 0) {
Palette* sp = new Palette();
sp->resize(400, 300);
noteAttributesPalette = new PaletteScrollArea(sp);
noteAttributesPalette->setRestrictHeight(false);
noteAttributesPalette->setWindowTitle(tr("MuseScore: Articulations & Ornaments"));
unsigned nn = ARTICULATIONS;
sp->setGrid(42, 30);
for (unsigned i = 0; i < nn; ++i) {
Articulation* s = new Articulation(gscore);
s->setSubtype(ArticulationType(i));
sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeName())));
}
}
noteAttributesPalette->show();
noteAttributesPalette->raise();
}
示例12: setElement
void InspectorArticulation::setElement(Element* e)
{
Articulation* a = static_cast<Articulation*>(e);
qreal _spatium = e->score()->spatium();
ar.elementName->setText(e->name());
ar.x->blockSignals(true);
ar.y->blockSignals(true);
ar.direction->blockSignals(true);
ar.anchor->blockSignals(true);
ar.x->setValue(a->pos().x() / _spatium);
ar.y->setValue(a->pos().y() / _spatium);
ar.direction->setCurrentIndex(int(a->direction()));
ar.anchor->setCurrentIndex(int(a->anchor()));
ar.x->blockSignals(false);
ar.y->blockSignals(false);
ar.direction->blockSignals(false);
ar.anchor->blockSignals(false);
}
示例13: switch
Element* Rest::drop(const DropData& data)
{
Element* e = data.element;
switch (e->type()) {
case ARTICULATION:
{
Articulation* a = static_cast<Articulation*>(e);
if (a->articulationType() != Articulation_Fermata
|| !score()->addArticulation(this, a)) {
delete e;
e = 0;
}
}
return e;
case CHORD:
{
Chord* c = static_cast<Chord*>(e);
Note* n = c->upNote();
MScore::Direction dir = c->stemDirection();
// score()->select(0, SELECT_SINGLE, 0);
NoteVal nval;
nval.pitch = n->pitch();
nval.headGroup = n->headGroup();
Fraction d = score()->inputState().duration().fraction();
if (!d.isZero()) {
Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir);
if (seg) {
ChordRest* cr = static_cast<ChordRest*>(seg->element(track()));
if (cr)
score()->nextInputPos(cr, true);
}
}
delete e;
}
break;
default:
return ChordRest::drop(data);
}
return 0;
}
示例14: tag
void BarLine::read(const QDomElement& de)
{
for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
const QString& tag(e.tagName());
const QString& val(e.text());
if (tag == "subtype") {
bool ok;
int i = val.toInt(&ok);
if (!ok)
setSubtype(val);
else {
BarLineType ct = NORMAL_BAR;
switch (i) {
default:
case 0: ct = NORMAL_BAR; break;
case 1: ct = DOUBLE_BAR; break;
case 2: ct = START_REPEAT; break;
case 3: ct = END_REPEAT; break;
case 4: ct = BROKEN_BAR; break;
case 5: ct = END_BAR; break;
case 6: ct = END_START_REPEAT; break;
}
setSubtype(ct);
}
}
else if (tag == "span")
_span = val.toInt();
else if (tag == "Articulation") {
Articulation* a = new Articulation(score());
a->read(e);
add(a);
}
else if (!Element::readProperties(e))
domError(e);
}
}
示例15: Articulation
Palette* MuseScore::newArticulationsPalette(bool basic)
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Articulations && Ornaments"));
sp->setGrid(42, 25);
sp->setDrawGrid(true);
if (basic) {
static std::vector<ArticulationType> art {
ArticulationType::Fermata,
ArticulationType::Sforzatoaccent,
ArticulationType::Staccato,
ArticulationType::Tenuto,
ArticulationType::Portato,
ArticulationType::Marcato,
ArticulationType::Trill
};
for (auto i : art) {
Articulation* s = new Articulation(gscore);
s->setArticulationType(i);
sp->append(s, qApp->translate("articulation", s->subtypeUserName().toUtf8().constData()));
}
}
else {
for (int i = 0; i < int(ArticulationType::ARTICULATIONS); ++i) {
Articulation* s = new Articulation(gscore);
s->setArticulationType(ArticulationType(i));
sp->append(s, qApp->translate("articulation", s->subtypeUserName().toUtf8().constData()));
}
Bend* bend = new Bend(gscore);
bend->points().append(PitchValue(0, 0, false));
bend->points().append(PitchValue(15, 100, false));
bend->points().append(PitchValue(60, 100, false));
sp->append(bend, qApp->translate("articulation", "Bend"));
TremoloBar* tb = new TremoloBar(gscore);
tb->points().append(PitchValue(0, 0, false)); // "Dip"
tb->points().append(PitchValue(30, -100, false));
tb->points().append(PitchValue(60, 0, false));
sp->append(tb, qApp->translate("articulation", "Tremolo bar"));
}
return sp;
}