本文整理汇总了C++中BarLine类的典型用法代码示例。如果您正苦于以下问题:C++ BarLine类的具体用法?C++ BarLine怎么用?C++ BarLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BarLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readScore
void TestBarline::barline02()
{
char msg[256];
Score* score = readScore(DIR + "barline02.mscx");
QVERIFY(score);
Measure* msr = score->firstMeasure()->nextMeasure();
TimeSig* ts = new TimeSig(score);
ts->setSig(Fraction(3, 4), TimeSigType::NORMAL);
score->cmdAddTimeSig(msr, 0, ts, false);
score->doLayout();
msr = score->firstMeasure();
int msrNo = 1;
while ((msr = msr->nextMeasure())) {
++msrNo;
Segment* seg = msr->findSegment(SegmentType::EndBarLine, msr->tick()+msr->ticks());
sprintf(msg, "No SegEndBarLine in measure %d.", msrNo);
QVERIFY2(seg != nullptr, msg);
BarLine* bar = static_cast<BarLine*>(seg->element(0));
sprintf(msg, "No barline in measure %d.", msrNo);
QVERIFY2(bar != nullptr, msg);
// bar line should be generated if NORMAL, except the END one at the end
sprintf(msg, "Barline in measure %d changed into 'non-generated'.", msrNo);
// ws: end barline is also generated
// bool test = (bar->barLineType() == BarLineType::NORMAL) ? bar->generated() : !bar->generated();
bool test = bar->generated();
QVERIFY2(test, msg);
}
// QVERIFY(saveCompareScore(score, "barline02.mscx", DIR + "barline02-ref.mscx"));
delete score;
}
示例2: QT_TR_NOOP
Palette* MuseScore::newBarLinePalette()
{
Palette* sp = new Palette;
sp->setName(qApp->translate("barlines", "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, qApp->translate("barlines", t[i].name));
}
return sp;
}
示例3: Palette
void MuseScore::barMenu()
{
if (barPalette == 0) {
Palette* sp = new Palette();
sp->resize(300, 200);
barPalette = new PaletteScrollArea(sp, 0);
barPalette->setRestrictHeight(false);
barPalette->setWindowTitle(tr("MuseScore: Barlines"));
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->setHeight(4 * gscore->spatium());
b->setSubtype(t[i].type);
sp->append(b, tr(t[i].name));
}
}
barPalette->show();
barPalette->raise();
}
示例4: toBarLine
void InspectorBarLine::setElement()
{
InspectorElementBase::setElement();
BarLine* bl = toBarLine(inspector->element());
// enable / disable individual type combo items according to score and selected bar line status
bool bMultiStaff = bl->score()->nstaves() > 1;
BarLineType blt = bl->barLineType();
bool isRepeat = blt & (BarLineType::START_REPEAT | BarLineType::END_REPEAT | BarLineType::END_START_REPEAT);
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(b.type->model());
int i = 0;
for (auto& k : BarLine::barLineTable) {
QStandardItem* item = model->item(i);
// if combo item is repeat type, should be disabled for multi-staff scores
if (k.type & (BarLineType::START_REPEAT | BarLineType::END_REPEAT | BarLineType::END_START_REPEAT)) {
// disable / enable
item->setFlags(bMultiStaff ?
item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
}
// if combo item is NOT repeat type, should be disabled if selected bar line is a repeat
else {
item->setFlags(isRepeat ?
item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
}
++i;
}
#if 0
blockSpanDataSignals(true);
manageSpanData();
blockSpanDataSignals(false);
#endif
}
示例5: readScore
void TestBarline::barline04()
{
Score* score = readScore(DIR + "barline04.mscx");
QVERIFY(score);
score->doLayout();
// 'go' to 5th measure
Measure* msr = score->firstMeasure();
for (int i=0; i < 4; i++)
msr = msr->nextMeasure();
// check span data of measure-initial start-repeat bar line
Segment* seg = msr->findSegment(SegmentType::StartRepeatBarLine, msr->tick());
QVERIFY2(seg != nullptr, "No SegStartRepeatBarLine segment in measure 5.");
BarLine* bar = static_cast<BarLine*>(seg->element(0));
QVERIFY2(bar != nullptr, "No start-repeat bar line in measure 5.");
score->undoChangeSingleBarLineSpan(bar, 2, 2, 6);
score->doLayout();
QVERIFY2(bar->span() == 2 && bar->spanFrom() == 2 && bar->spanTo() == 6,
"Wrong span data in start-repeat bar line of measure 5.");
// check start-repeat bar ine in second staff is gone
QVERIFY2(seg->element(1) == nullptr, "Extra start-repeat bar line in 2nd staff of measure 5.");
// QVERIFY(saveCompareScore(score, "barline04.mscx", DIR + "barline04-ref.mscx"));
delete score;
}
示例6: drop
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;
}
示例7: dropNormalBarline
void dropNormalBarline(Element* e)
{
EditData dropData(0);
BarLine* barLine = new BarLine(e->score());
barLine->setBarLineType(BarLineType::NORMAL);
dropData.dropElement = barLine;
e->score()->startCmd();
e->drop(dropData);
e->score()->endCmd();
}
示例8: toBarLine
void InspectorBarLine::presetDefaultClicked()
{
Score* score = inspector->element()->score();
score->startCmd();
BarLine* bl;
for (Element* e : *inspector->el()) {
if (e->isBarLine()) {
bl = toBarLine(e);
bl->undoResetProperty(Pid::BARLINE_SPAN);
bl->undoResetProperty(Pid::BARLINE_SPAN_FROM);
bl->undoResetProperty(Pid::BARLINE_SPAN_TO);
}
}
score->endCmd();
}
示例9: QT_TR_NOOP
Palette* MuseScore::newBarLinePalette()
{
Palette* sp = new Palette;
sp->setName(qApp->translate("barlines", "Barlines"));
sp->setMag(0.8);
sp->setGrid(42, 38);
// bar line styles
struct {
BarLineType type;
const char* name;
} t[] = {
{ NORMAL_BAR, QT_TR_NOOP("Normal") },
{ BROKEN_BAR, QT_TR_NOOP("Dashed") },
{ DOTTED_BAR, QT_TR_NOOP("Dotted") },
{ 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, qApp->translate("barlines", t[i].name));
}
// bar line spans
struct {
int from, to;
const char* name;
} span[] = {
{ -1, 1, QT_TR_NOOP("Tick 1") },
{ -2, 2, QT_TR_NOOP("Tick 2") },
{ 2, 6, QT_TR_NOOP("Short 1") },
{ 1, 7, QT_TR_NOOP("Short 2") },
};
for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
BarLine* b = new BarLine(gscore);
b->setSubtype(NORMAL_BAR);
b->setSpanFrom(span[i].from);
b->setSpanTo(span[i].to);
sp->append(b, qApp->translate("barlines", span[i].name));
}
return sp;
}
示例10: QT_TRANSLATE_NOOP
Palette* MuseScore::newBarLinePalette()
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Barlines"));
sp->setMag(0.8);
sp->setGrid(42, 38);
// bar line styles
struct {
BarLineType type;
const char* name;
} t[] = {
{ BarLineType::NORMAL, QT_TRANSLATE_NOOP("Palette", "Normal") },
{ BarLineType::BROKEN, QT_TRANSLATE_NOOP("Palette", "Dashed") },
{ BarLineType::DOTTED, QT_TRANSLATE_NOOP("Palette", "Dotted") },
{ BarLineType::END, QT_TRANSLATE_NOOP("Palette", "End Bar") },
{ BarLineType::DOUBLE, QT_TRANSLATE_NOOP("Palette", "Double Bar") },
{ BarLineType::START_REPEAT, QT_TRANSLATE_NOOP("Palette", "Start Repeat") },
{ BarLineType::END_REPEAT, QT_TRANSLATE_NOOP("Palette", "End Repeat") },
{ BarLineType::END_START_REPEAT, QT_TRANSLATE_NOOP("Palette", "End-Start Repeat") },
};
for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) {
BarLine* b = new BarLine(gscore);
b->setBarLineType(t[i].type);
sp->append(b, t[i].name);
}
// bar line spans
struct {
int from, to;
const char* name;
} span[] = {
{ -1, 1, QT_TRANSLATE_NOOP("Palette", "Tick 1") },
{ -2, 2, QT_TRANSLATE_NOOP("Palette", "Tick 2") },
{ 2, 6, QT_TRANSLATE_NOOP("Palette", "Short 1") },
{ 1, 7, QT_TRANSLATE_NOOP("Palette", "Short 2") },
};
for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
BarLine* b = new BarLine(gscore);
b->setBarLineType(BarLineType::NORMAL);
b->setSpanFrom(span[i].from);
b->setSpanTo(span[i].to);
sp->append(b, span[i].name);
}
return sp;
}
示例11: return
bool BarLine::acceptDrop(const DropData& data) const
{
Element::Type type = data.element->type();
if (type == Element::Type::BAR_LINE) {
if (parent() && parent()->type() == Element::Type::SEGMENT)
return true;
if (parent() && parent()->type() == Element::Type::SYSTEM) {
BarLine* b = static_cast<BarLine*>(data.element);
return (b->barLineType() == BarLineType::BROKEN || b->barLineType() == BarLineType::DOTTED
|| b->barLineType() == BarLineType::NORMAL || b->barLineType() == BarLineType::DOUBLE
|| b->spanFrom() != 0 || b->spanTo() != DEFAULT_BARLINE_TO);
}
}
else {
return (type == Element::Type::ARTICULATION
&& parent()
&& parent()->type() == Element::Type::SEGMENT
&& static_cast<Segment*>(parent())->segmentType() == Segment::Type::EndBarLine);
}
return false;
}
示例12: return
bool BarLine::acceptDrop(MuseScoreView*, const QPointF&, Element* e) const
{
int type = e->type();
if (type == BAR_LINE) {
if (parent() && parent()->type() == SEGMENT)
return true;
if (parent() && parent()->type() == SYSTEM) {
BarLine* b = static_cast<BarLine*>(e);
return (b->barLineType() == BROKEN_BAR || b->barLineType() == DOTTED_BAR
|| b->barLineType() == NORMAL_BAR || b->barLineType() == DOUBLE_BAR
|| b->spanFrom() != 0 || b->spanTo() != DEFAULT_BARLINE_TO);
}
}
else {
return (type == ARTICULATION
&& parent()
&& parent()->type() == SEGMENT
&& static_cast<Segment*>(parent())->segmentType() == Segment::SegEndBarLine);
}
return false;
}
示例13: BarLine
Palette* MuseScore::newBarLinePalette(bool basic)
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Barlines"));
sp->setMag(0.8);
sp->setGrid(42, 38);
// bar line styles
for (unsigned i = 0; i < BarLine::barLineTableSize(); ++i) {
BarLine* b = new BarLine(gscore);
BarLineTableItem bti = BarLine::barLineTableItem(i);
b->setBarLineType(bti.type);
sp->append(b, qApp->translate("Palette", bti.name));
}
if (!basic) {
// bar line spans
struct {
int from, to;
const char* name;
} span[] = {
{ BARLINE_SPAN_TICK1_FROM, BARLINE_SPAN_TICK1_TO, QT_TRANSLATE_NOOP("Palette", "Tick 1 span") },
{ BARLINE_SPAN_TICK2_FROM, BARLINE_SPAN_TICK2_TO, QT_TRANSLATE_NOOP("Palette", "Tick 2 span") },
{ BARLINE_SPAN_SHORT1_FROM,BARLINE_SPAN_SHORT1_TO,QT_TRANSLATE_NOOP("Palette", "Short 1 span") },
{ BARLINE_SPAN_SHORT2_FROM,BARLINE_SPAN_SHORT2_TO,QT_TRANSLATE_NOOP("Palette", "Short 2 span") },
};
for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
BarLine* b = new BarLine(gscore);
b->setBarLineType(BarLineType::NORMAL);
b->setSpanFrom(span[i].from);
b->setSpanTo(span[i].to);
sp->append(b, qApp->translate("Palette", span[i].name));
}
}
return sp;
}
示例14: staffnum
//.........这里部分代码省略.........
char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]);
int octave = loc_clef.get_octave(eventit->pitch_num[0]);
rest->addAttribute("ploc", std::string(&pitch_name,1));
rest->addAttribute("oloc", std::to_string(octave));
}
break;
}
}
break;
// non-standard mensuration signs
case code_t::mensuration:
{
Mensur* mensuration_sign = new Mensur;
foster->addChild(mensuration_sign);
if (eventit->code == "MO" || eventit->code == "MC" || eventit->code == "MO." || eventit->code == "MC.")
{
char the_sign = eventit->code[1];
mensuration_sign->addAttribute("sign", std::string(&the_sign,1));
if (eventit->code.size()==3 && eventit->code[2]=='.') {
mensuration_sign->addAttribute("dot", "true");
}
//also able to set attribute 'orient' to reversed for reversed signs; and slash attribute for cut signs
}
if (eventit->code == ".D." || eventit->code == ".Q." || eventit->code == ".SI." || eventit->code == ".P." || eventit->code == ".N." || eventit->code == ".O." || eventit->code == ".I.") //also .SG.?
{
//these are wholly new to the MEI schema; the whole dot-letter-dot sign is encoded
mensuration_sign->addAttribute("sign", eventit->code);
}
break;
}
case code_t::barline:
{
BarLine* barline = new BarLine;
foster->addChild(barline);
if (eventit->code == "QBAR") {
barline->addAttribute("rend", "quarter"); //non-standard data type for rend.
}
if (eventit->code == "HBAR") {
barline->addAttribute("rend", "half");
}
if (eventit->code == "WBAR") {
barline->addAttribute("rend", "single");
}
if (eventit->code == "DBAR") {
barline->addAttribute("rend", "dbl");
}
//modern bar editorial - ignore?
if (eventit->code == "MBAR") {
barline->addAttribute("barplace", "takt");
barline->addAttribute("taktplace", std::string(9,1));
}
//also able to see rend attribute
break;
}
case code_t::clef:
{
//NB. old clefchange element superceded; clefGrp used for simultaneous clefs
示例15: score
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->barLineType();
// if no change in subtype or no change in span, do nothing
if (st == barLineType() && bl->spanFrom() == 0 && bl->spanTo() == DEFAULT_BARLINE_TO) {
delete e;
return 0;
}
// system left-side bar line
if (parent()->type() == SYSTEM) {
BarLine* b = static_cast<System*>(parent())->barLine();
score()->undoChangeProperty(b, P_SUBTYPE, int(bl->barLineType()));
delete e;
return 0;
}
// check if the new property can apply to this single bar line
bool oldRepeat = (barLineType() == START_REPEAT || barLineType() == END_REPEAT
|| barLineType() == END_START_REPEAT);
bool newRepeat = (bl->barLineType() == START_REPEAT || bl->barLineType() == END_REPEAT
|| bl->barLineType() == END_START_REPEAT);
// if repeats are not involved or drop refers to span rather than subtype =>
// single bar line drop
if( (!oldRepeat && !newRepeat) || (bl->spanFrom() != 0 || bl->spanTo() != DEFAULT_BARLINE_TO) ) {
// if drop refers to span, update this bar line span
if(bl->spanFrom() != 0 || bl->spanTo() != DEFAULT_BARLINE_TO) {
// if dropped spanFrom or spanTo are below the middle of standard staff (5 lines)
// adjust to the number of syaff lines
int bottomSpan = (staff()->lines()-1) * 2;
int spanFrom = bl->spanFrom() > 4 ? bottomSpan - (8 - bl->spanFrom()) : bl->spanFrom();
int spanTo = bl->spanTo() > 4 ? bottomSpan - (8 - bl->spanTo()) : bl->spanTo();
score()->undoChangeSingleBarLineSpan(this, 1, spanFrom, spanTo);
}
// if drop refer to subtype, update this bar line subtype
else {
score()->undoChangeProperty(this, P_SUBTYPE, int(bl->barLineType()));
// setCustomSubtype(true);
}
delete e;
return 0;
}
// drop applies to all bar lines of the measure
Measure* m = static_cast<Segment*>(parent())->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()->undoAddElement(atr);
return atr;
}
return 0;
}