本文整理汇总了C++中MeasureBase::type方法的典型用法代码示例。如果您正苦于以下问题:C++ MeasureBase::type方法的具体用法?C++ MeasureBase::type怎么用?C++ MeasureBase::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeasureBase
的用法示例。
在下文中一共展示了MeasureBase::type方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addText
static void addText(Score* score, int subtype, const QString& s)
{
MeasureBase* measure = score->first();
if (measure == 0 || measure->type() != VBOX) {
score->insertMeasure(VBOX, measure);
measure = score->first();
}
Text* text = new Text(score);
switch(subtype) {
case TEXT_TITLE:
text->setTextStyleType(TEXT_STYLE_TITLE);
break;
case TEXT_SUBTITLE:
text->setTextStyleType(TEXT_STYLE_SUBTITLE);
break;
case TEXT_COMPOSER:
text->setTextStyleType(TEXT_STYLE_COMPOSER);
break;
case TEXT_POET:
text->setTextStyleType(TEXT_STYLE_POET);
break;
}
text->setParent(measure);
text->setText(s);
score->undoAddElement(text);
}
示例2: nextMeasure
ChordRest* Score::nextMeasure(ChordRest* element, bool selectBehavior)
{
if (!element)
return 0;
MeasureBase* mb = element->measure()->next();
while (mb && ((mb->type() != Element::MEASURE) || (mb->type() == Element::MEASURE && static_cast<Measure*>(mb)->multiMeasure() < 0)))
mb = mb->next();
Measure* measure = static_cast<Measure*>(mb);
int endTick = element->measure()->last()->nextChordRest(element->track(), true)->tick();
bool last = false;
if (selection().state() == SEL_RANGE) {
if (element->tick() != endTick && selection().tickEnd() <= endTick) {
measure = element->measure();
last = true;
}
else if (element->tick() == endTick && selection().isEndActive())
last = true;
}
else if (element->tick() != endTick && selectBehavior) {
measure = element->measure();
last = true;
}
if (!measure) {
measure = element->measure();
last = true;
}
int staff = element->staffIdx();
Segment* startSeg = last ? measure->last() : measure->first();
for (Segment* seg = startSeg; seg; seg = last ? seg->prev() : seg->next()) {
int etrack = (staff+1) * VOICES;
for (int track = staff * VOICES; track < etrack; ++track) {
Element* pel = seg->element(track);
if (pel && pel->isChordRest())
return static_cast<ChordRest*>(pel);
}
}
return 0;
}
示例3: prev
Segment* Segment::prev1() const
{
if (prev())
return prev();
MeasureBase* m = measure();
for (;;) {
m = m->prev();
if (m == 0)
return 0;
if (m->type() == MEASURE)
return static_cast<Measure*>(m)->last();
}
}
示例4: next
Segment* Segment::next1() const
{
if (next())
return next();
MeasureBase* m = measure();
for (;;) {
m = m->next();
if (m == 0)
return 0;
if (m->type() == MEASURE)
return static_cast<Measure*>(m)->first();
}
}
示例5: addTitleToScore
void addTitleToScore(Score *score, const QString &string, int textCounter)
{
Text* text = new Text(score);
if (textCounter == 1)
text->setSubStyle(SubStyle::TITLE);
else if (textCounter == 2)
text->setSubStyle(SubStyle::COMPOSER);
text->setPlainText(string.right(string.size() - TEXT_PREFIX.size()));
MeasureBase* measure = score->first();
if (measure->type() != Element::Type::VBOX) {
measure = new VBox(score);
measure->setTick(0);
measure->setNext(score->first());
score->measures()->add(measure);
}
measure->add(text);
}
示例6: addTitle
void addTitle(Score *score, const QString &string, int *textCounter)
{
if (string.left(TEXT_PREFIX.size()) == QString::fromStdString(TEXT_PREFIX)) {
++*textCounter;
Text* text = new Text(score);
if (*textCounter == 1)
text->setTextStyleType(TextStyleType::TITLE);
else if (*textCounter == 2)
text->setTextStyleType(TextStyleType::COMPOSER);
text->setText(string.right(string.size() - TEXT_PREFIX.size()));
MeasureBase* measure = score->first();
if (measure->type() != Element::Type::VBOX) {
measure = new VBox(score);
measure->setTick(0);
measure->setNext(score->first());
score->measures()->add(measure);
}
measure->add(text);
}
}
示例7: setStaves
void Part::setStaves(int n)
{
int ns = _staves.size();
if (n < ns) {
printf("Part::setStaves(): remove staves not implemented!\n");
return;
}
int staffIdx = _score->staffIdx(this) + ns;
for (int i = ns; i < n; ++i) {
Staff* staff = new Staff(_score, this, i);
_staves.push_back(staff);
_score->staves().insert(staffIdx, staff);
for (MeasureBase* mb = _score->first(); mb; mb = mb->next()) {
if (mb->type() != MEASURE)
continue;
Measure* m = static_cast<Measure*>(mb);
m->insertStaff(staff, staffIdx);
}
++staffIdx;
}
}
示例8: if
//.........这里部分代码省略.........
}
}
// create missing KeySig
KeyList* km = s->keyList();
for (auto i = km->begin(); i != km->end(); ++i) {
int tick = i->first;
if (tick < 0) {
qDebug("read114: Key tick %d", tick);
continue;
}
if (tick == 0 && i->second.key() == Key::C)
continue;
Measure* m = tick2measure(tick);
if (!m) //empty score
break;
Segment* seg = m->getSegment(Segment::Type::KeySig, tick);
if (seg->element(track))
static_cast<KeySig*>(seg->element(track))->setGenerated(false);
else {
KeySigEvent ke = i->second;
KeySig* ks = new KeySig(this);
ks->setKeySigEvent(ke);
ks->setParent(seg);
ks->setTrack(track);
ks->setGenerated(false);
seg->add(ks);
}
}
}
for (std::pair<int,Spanner*> p : spanner()) {
Spanner* s = p.second;
if (s->type() != Element::Type::SLUR) {
if (s->type() == Element::Type::VOLTA) {
Volta* volta = static_cast<Volta*>(s);
volta->setAnchor(Spanner::Anchor::MEASURE);
}
}
if (s->type() == Element::Type::OTTAVA
|| s->type() == Element::Type::PEDAL
|| s->type() == Element::Type::TRILL
|| s->type() == Element::Type::TEXTLINE) {
qreal yo = 0;
if (s->type() == Element::Type::OTTAVA) {
// fix ottava position
yo = styleS(StyleIdx::ottavaY).val() * spatium();
if (s->placement() == Element::Placement::BELOW)
yo = -yo + s->staff()->height();
}
else if (s->type() == Element::Type::PEDAL) {
yo = styleS(StyleIdx::pedalY).val() * spatium();
}
else if (s->type() == Element::Type::TRILL) {
yo = styleS(StyleIdx::trillY).val() * spatium();
}
else if (s->type() == Element::Type::TEXTLINE) {
yo = -5.0 * spatium();
}
if (!s->spannerSegments().isEmpty()) {
for (SpannerSegment* seg : s->spannerSegments()) {
if (!seg->userOff().isNull())
seg->setUserYoffset(seg->userOff().y() - yo);
}
}
示例9: if
void System::layout2()
{
if (isVbox()) // ignore vbox
return;
int nstaves = _staves.size();
qreal _spatium = spatium();
qreal y = 0.0;
int lastStaffIdx = 0; // last visible staff
int firstStaffIdx = -1;
qreal lastStaffDistanceDown = 0.0;
for (int staffIdx = 0; staffIdx < nstaves; ++staffIdx) {
Staff* staff = score()->staff(staffIdx);
StyleIdx downDistance;
qreal userDist = 0.0;
if ((staffIdx + 1) == nstaves) {
//
// last staff in system
//
MeasureBase* mb = ml.last();
bool nextMeasureIsVBOX = false;
if (mb->next()) {
Element::Type type = mb->next()->type();
if (type == Element::Type::VBOX || type == Element::Type::TBOX || type == Element::Type::FBOX)
nextMeasureIsVBOX = true;
}
downDistance = nextMeasureIsVBOX ? StyleIdx::systemFrameDistance : StyleIdx::minSystemDistance;
}
else if (staff->rstaff() < (staff->part()->staves()->size()-1)) {
//
// staff is not last staff in a part
//
downDistance = StyleIdx::akkoladeDistance;
userDist = score()->staff(staffIdx + 1)->userDist();
}
else {
downDistance = StyleIdx::staffDistance;
userDist = score()->staff(staffIdx + 1)->userDist();
}
SysStaff* s = _staves[staffIdx];
qreal distDown = score()->styleS(downDistance).val() * _spatium + userDist;
qreal nominalDistDown = distDown;
qreal distUp = 0.0;
int n = ml.size();
for (int i = 0; i < n; ++i) {
MeasureBase* m = ml.at(i);
distDown = qMax(distDown, m->distanceDown(staffIdx));
distUp = qMax(distUp, m->distanceUp(staffIdx));
}
s->setDistanceDown(distDown);
s->setDistanceUp(distUp);
if (!staff->show() || !s->show()) {
s->setbbox(QRectF()); // already done in layout() ?
continue;
}
qreal sHeight = staff->height();
qreal dup = staffIdx == 0 ? 0.0 : s->distanceUp();
if (staff->lines() == 1)
dup -= _spatium * staff->mag();
s->bbox().setRect(_leftMargin, y + dup, width() - _leftMargin, sHeight);
y += dup + sHeight + s->distanceDown();
lastStaffIdx = staffIdx;
lastStaffDistanceDown = distDown - nominalDistDown;
if (firstStaffIdx == -1)
firstStaffIdx = staffIdx;
}
if (firstStaffIdx == -1)
firstStaffIdx = 0;
qreal systemHeight = staff(lastStaffIdx)->bbox().bottom();
if (lastStaffIdx < nstaves - 1)
systemHeight += lastStaffDistanceDown;
setHeight(systemHeight);
int n = ml.size();
for (int i = 0; i < n; ++i) {
MeasureBase* m = ml.at(i);
if (m->type() == Element::Type::MEASURE) {
// note that the factor 2 * _spatium must be corrected for when exporting
// system distance in MusicXML (issue #24733)
m->bbox().setRect(0.0, -_spatium, m->width(), systemHeight + 2 * _spatium);
}
else if (m->type() == Element::Type::HBOX) {
m->bbox().setRect(0.0, 0.0, m->width(), systemHeight);
static_cast<HBox*>(m)->layout2();
}
}
if (_barLine) {
_barLine->setTrack(firstStaffIdx * VOICES);
_barLine->setSpan(lastStaffIdx - firstStaffIdx + 1);
if (score()->staff(0)->lines() == 1)
_barLine->setSpanFrom(BARLINE_SPAN_1LINESTAFF_FROM);
int spanTo = (score()->staff(lastStaffIdx)->lines() == 1) ?
BARLINE_SPAN_1LINESTAFF_TO :
(score()->staff(lastStaffIdx)->lines()-1)*2;
//.........这里部分代码省略.........
示例10: processMeta
void MTrack::processMeta(int tick, const MidiEvent& mm)
{
if (!staff) {
qDebug("processMeta: no staff");
return;
}
const uchar* data = (uchar*)mm.edata();
int staffIdx = staff->idx();
Score* cs = staff->score();
switch (mm.metaType()) {
case META_TEXT:
case META_LYRIC: {
QString s((char*)data);
cs->addLyrics(tick, staffIdx, s);
}
break;
case META_TRACK_NAME:
name = (const char*)data;
break;
case META_TEMPO:
{
unsigned tempo = data[2] + (data[1] << 8) + (data[0] <<16);
double t = 1000000.0 / double(tempo);
cs->setTempo(tick, t);
// TODO: create TempoText
}
break;
case META_KEY_SIGNATURE:
{
int key = ((const char*)data)[0];
if (key < -7 || key > 7) {
qDebug("ImportMidi: illegal key %d", key);
break;
}
KeySigEvent ks;
ks.setAccidentalType(key);
(*staff->keymap())[tick] = ks;
hasKey = true;
}
break;
case META_COMPOSER: // mscore extension
case META_POET:
case META_TRANSLATOR:
case META_SUBTITLE:
case META_TITLE:
{
Text* text = new Text(cs);
switch(mm.metaType()) {
case META_COMPOSER:
text->setTextStyleType(TEXT_STYLE_COMPOSER);
break;
case META_TRANSLATOR:
text->setTextStyleType(TEXT_STYLE_TRANSLATOR);
break;
case META_POET:
text->setTextStyleType(TEXT_STYLE_POET);
break;
case META_SUBTITLE:
text->setTextStyleType(TEXT_STYLE_SUBTITLE);
break;
case META_TITLE:
text->setTextStyleType(TEXT_STYLE_TITLE);
break;
}
text->setText((const char*)(mm.edata()));
MeasureBase* measure = cs->first();
if (measure->type() != Element::VBOX) {
measure = new VBox(cs);
measure->setTick(0);
measure->setNext(cs->first());
cs->add(measure);
}
measure->add(text);
}
break;
case META_COPYRIGHT:
cs->setMetaTag("Copyright", QString((const char*)(mm.edata())));
break;
case META_TIME_SIGNATURE:
qDebug("midi: meta timesig: %d, division %d", tick, MScore::division);
cs->sigmap()->add(tick, Fraction(data[0], 1 << data[1]));
break;
default:
if (MScore::debugMode)
qDebug("unknown meta type 0x%02x", mm.metaType());
break;
}
}