本文整理汇总了C++中StaffType类的典型用法代码示例。如果您正苦于以下问题:C++ StaffType类的具体用法?C++ StaffType怎么用?C++ StaffType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StaffType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spatium
void BarLine::drawDots(QPainter* painter, qreal x) const
{
qreal _spatium = spatium();
if (parent() == 0) { // for use in palette
drawSymbol(SymId::repeatDot, painter, QPointF(x, 2.0 * _spatium));
drawSymbol(SymId::repeatDot, painter, QPointF(x, 3.0 * _spatium));
}
else if (parent()->type() == Element::Type::SEGMENT) {
System* s = static_cast<Segment*>(parent())->measure()->system();
int staffIdx1 = staffIdx();
int staffIdx2 = staffIdx1 + _span - 1;
int sp = _span;
if (staffIdx2 >= score()->nstaves()) {
qDebug("BarLine: bad _span %d", _span);
staffIdx2 = score()->nstaves() - 1;
sp = staffIdx2 - staffIdx1 + 1;
}
qreal dy = s->staff(staffIdx1)->y();
for (int i = 0; i < sp; ++i) {
Staff* staff = score()->staff(staffIdx1 + i);
StaffType* st = staff->staffType();
qreal doty1 = (st->doty1() + .5) * _spatium;
qreal doty2 = (st->doty2() + .5) * _spatium;
qreal staffy = s->staff(staffIdx1 + i)->y() - dy;
drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty1));
drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty2));
}
}
}
示例2: layout
void Clef::layout()
{
// determine current number of lines and line distance
int lines = 5; // assume a resonable default
qreal lineDist = 1.0;
StaffType* staffType;
if (staff() && staff()->staffType()) {
staffType = staff()->staffType();
if (!staffType->genClef()) { // if no clef, set empty bbox and do nothing
setbbox(QRectF());
return;
}
// tablatures:
if (staffType->group() == TAB_STAFF) {
// if current clef type not compatible with tablature,
// set tab clef according to score style
if (clefTable[clefType()].staffGroup != TAB_STAFF)
setClefType( ClefType(score()->styleI(ST_tabClef)) );
}
// all staff types: init values from staff type
lines = staffType->lines();
lineDist = staffType->lineDistance().val();
}
// if nothing changed since last layout, do nothing
if (curClefType == clefType() && curLines == lines && curLineDist == lineDist)
return;
// if something has changed, cache new values and re-layout
curClefType = clefType();
curLines = lines;
curLineDist = lineDist;
layout1();
}
示例3: magS
void BarLine::drawDots(QPainter* painter, qreal x) const
{
const Sym& dotsym = symbols[score()->symIdx()][dotSym];
qreal mags = magS();
qreal _spatium = spatium();
if (parent() == 0) { // for use in palette
dotsym.draw(painter, mags, QPointF(x, 1.5 * _spatium));
dotsym.draw(painter, mags, QPointF(x, 2.5 * _spatium));
}
else if (parent()->type() == SEGMENT) {
System* s = static_cast<Segment*>(parent())->measure()->system();
int staffIdx1 = staffIdx();
int staffIdx2 = staffIdx1 + _span - 1;
int sp = _span;
if (staffIdx2 >= score()->nstaves()) {
qDebug("BarLine: bad _span %d", _span);
staffIdx2 = score()->nstaves() - 1;
sp = staffIdx2 - staffIdx1 + 1;
}
qreal dy = s->staff(staffIdx1)->y();
for (int i = 0; i < sp; ++i) {
Staff* staff = score()->staff(staffIdx1 + i);
StaffType* st = staff->staffType();
qreal doty1 = st->doty1() * _spatium;
qreal doty2 = st->doty2() * _spatium;
qreal staffy = s->staff(staffIdx1 + i)->y() - dy;
dotsym.draw(painter, mags, QPointF(x, staffy + doty1));
dotsym.draw(painter, mags, QPointF(x, staffy + doty2));
}
}
}
示例4: magS
void BarLine::drawDots(QPainter* painter, qreal x) const
{
const Sym& dotsym = symbols[score()->symIdx()][dotSym];
qreal mags = magS();
qreal _spatium = spatium();
if (parent() == 0) { // for use in palette
dotsym.draw(painter, mags, QPointF(x, 1.5 * _spatium));
dotsym.draw(painter, mags, QPointF(x, 2.5 * _spatium));
}
else {
System* s = measure()->system();
int _staffIdx = staffIdx();
qreal dy = s->staff(_staffIdx)->y();
for (int i = 0; i < _span; ++i) {
Staff* staff = score()->staff(_staffIdx + i);
StaffType* st = staff->staffType();
qreal doty1 = st->doty1() * _spatium;
qreal doty2 = st->doty2() * _spatium;
qreal staffy = s->staff(_staffIdx + i)->y() - dy;
dotsym.draw(painter, mags, QPointF(x, staffy + doty1));
dotsym.draw(painter, mags, QPointF(x, staffy + doty2));
}
}
}
示例5: apply
void EditStaff::apply()
{
Score* score = staff->score();
Part* part = staff->part();
int intervalIdx = iList->currentIndex();
bool upFlag = up->isChecked();
Interval interval = intervalList[intervalIdx];
interval.diatonic += octave->value() * 7;
interval.chromatic += octave->value() * 12;
if (!upFlag)
interval.flip();
instrument.setTranspose(interval);
instrument.setMinPitchA(_minPitchA);
instrument.setMaxPitchA(_maxPitchA);
instrument.setMinPitchP(_minPitchP);
instrument.setMaxPitchP(_maxPitchP);
instrument.setShortName(QTextDocumentFragment(shortName->document()));
instrument.setLongName(QTextDocumentFragment(longName->document()));
bool s = small->isChecked();
bool inv = invisible->isChecked();
qreal userDist = spinExtraDistance->value();
QColor col = color->color();
int staffIdx = staffType->itemData(staffType->currentIndex()).toInt();
StaffType* st = score->staffType(staffIdx);
// before changing instrument, check if notes need to be updated
// true if changing into or away from TAB or from one TAB type to another
StaffGroup ng = st->group(); // new staff group
StaffGroup og = staff->staffType()->group(); // old staff group
bool updateNeeded = (ng == TAB_STAFF_GROUP && og != TAB_STAFF_GROUP) ||
(ng != TAB_STAFF_GROUP && og == TAB_STAFF_GROUP) ||
(ng == TAB_STAFF_GROUP && og == TAB_STAFF_GROUP
&& instrument.stringData() != part->instr()->stringData());
if (!(instrument == *part->instr()) || part->partName() != partName->text()) {
score->undo(new ChangePart(part, instrument, partName->text()));
emit instrumentChanged();
}
if (s != staff->small() || inv != staff->invisible() || userDist != staff->userDist() || st != staff->staffType() || col != staff->color())
score->undo(new ChangeStaff(staff, s, inv, userDist * score->spatium(), col, st));
if (updateNeeded)
score->cmdUpdateNotes();
score->setLayoutAll(true);
score->update();
}
示例6: isSameStructure
bool StaffType::isSameStructure(const StaffType& st) const
{
if (st.group() != group() // common to all type groups
|| st._lines != _lines
|| st._stepOffset != _stepOffset
|| st._lineDistance != _lineDistance
|| st._genClef != _genClef
|| st._showBarlines != _showBarlines
|| st._slashStyle != _slashStyle
|| st._genTimesig != _genTimesig)
return false;
if (_group != StaffGroup::TAB) { // common to pitched and percussion
return st._genKeysig == _genKeysig
&& st._showLedgerLines == _showLedgerLines
;
}
else { // TAB-specific
return st._genDurations == _genDurations
&& st._linesThrough == _linesThrough
&& st._minimStyle == _minimStyle
&& st._onLines == _onLines
&& st._showRests == _showRests
&& st._stemsDown == _stemsDown
&& st._stemsThrough == _stemsThrough
&& st._upsideDown == _upsideDown
&& st._useNumbers == _useNumbers
;
}
}
示例7: saveCurrent
void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
{
if (n == 0)
return;
if (o)
saveCurrent(o);
// retrieve staff type corresponding to new current item in type list
int idx = n->data(Qt::UserRole).toInt();
StaffType* st = staffTypes[idx];
// switch to stack page and set props specific to each staff group
switch(st->group()) {
case STANDARD_STAFF_GROUP:
{
StaffTypePitched* ps = static_cast<StaffTypePitched*>(st);
stack->setCurrentIndex(0);
name->setText(st->name());
lines->setValue(st->lines());
lineDistance->setValue(st->lineDistance().val());
genClef->setChecked(st->genClef());
showBarlines->setChecked(st->showBarlines());
genTimesig->setChecked(st->genTimesig());
genKeysigPitched->setChecked(ps->genKeysig());
showLedgerLinesPitched->setChecked(ps->showLedgerLines());
stemlessPitched->setChecked(st->slashStyle());
}
break;
case TAB_STAFF_GROUP:
{
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
blockTabPreviewSignals(true);
setDlgFromTab(stt);
name->setText(stt->name()); // setDlgFromTab() does not copy the name and it shouldn't
stack->setCurrentIndex(1);
blockTabPreviewSignals(false);
}
break;
case PERCUSSION_STAFF_GROUP:
{
StaffTypePercussion* ps = static_cast<StaffTypePercussion*>(st);
blockPercPreviewSignals(true);
setDlgFromPerc(ps);
name->setText(ps->name()); // setDlgFromPerc() does not copy the name and it shouldn't
stack->setCurrentIndex(2);
blockPercPreviewSignals(false);
}
break;
}
}
示例8: switch
void PositionCursor::paint(QPainter* p)
{
if (!visible())
return;
QPointF points[3];
qreal h = _sv->score()->spatium() * 2;
qreal x = _rect.left();
qreal y = _rect.top();
switch(_type) {
case CursorType::LOOP_IN: // draw a right-pointing triangle
{
qreal tx = x - 1.0;
p->setPen(QPen(_color, 2.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p->drawLine(x, y, x, _rect.bottom());
points[0] = QPointF(tx, y);
points[1] = QPointF(tx, y + h);
points[2] = QPointF(tx + h, y + h * .5);
p->setBrush(_color);
p->drawConvexPolygon(points, 3);
}
break;
case CursorType::LOOP_OUT: // draw a left-pointing triangle
p->setPen(QPen(_color, 2.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p->drawLine(x, y, x, _rect.bottom());
points[0] = QPointF(x, y);
points[1] = QPointF(x, y + h);
points[2] = QPointF(x - h, y + h * .5);
p->setBrush(_color);
p->drawConvexPolygon(points, 3);
break;
default: // fill the rectangle and add TAB string marks, if required
p->fillRect(_rect, color());
if (_sv->score()->noteEntryMode()) {
int track = _sv->score()->inputTrack();
if (track >= 0) {
Staff* staff = _sv->score()->staff(track2staff(track));
StaffType* staffType = staff->staffType();
if (staffType && staffType->group() == StaffGroup::TAB)
staffType->drawInputStringMarks(p, _sv->score()->inputState().string(),
track2voice(track), _rect);
}
}
break;
}
}
示例9: createNewType
void EditStaffType::createNewType()
{
//
// initialize new StaffType with current selected one
//
int idx = staffTypeList->currentItem()->data(Qt::UserRole).toInt();
StaffType* ns = staffTypes[idx]->clone();
ns->setName(createUniqueStaffTypeName(ns->group()));
staffTypes.append(ns);
QListWidgetItem* item = new QListWidgetItem(ns->name());
item->setData(Qt::UserRole, staffTypes.size() - 1);
staffTypeList->addItem(item);
staffTypeList->setCurrentItem(item);
modified = true;
}
示例10: up
void Stem::layout()
{
qreal l = _len + _userLen;
qreal _up = up() ? -1.0 : 1.0;
l *= _up;
qreal y1 = 0.0; // vertical displacement to match note attach point
Staff* stf = staff();
if (chord()) {
int tick = chord()->tick();
StaffType* st = stf->staffType(tick);
if (st->isTabStaff() ) { // TAB staves
if (st->stemThrough()) {
// if stems through staves, gets Y pos. of stem-side note relative to chord other side
qreal lineDist = st->lineDistance().val() * spatium();
y1 = (chord()->downString() - chord()->upString()) * _up * lineDist;
// if fret marks above lines, raise stem beginning by 1/2 line distance
if (!st->onLines())
y1 -= lineDist * 0.5;
// shorten stem by 1/2 lineDist to clear the note and a little more to keep 'air' betwen stem and note
lineDist *= 0.7 * mag();
y1 += _up * lineDist;
}
// in other TAB types, no correction
}
else { // non-TAB
// move stem start to note attach point
Note* n = up() ? chord()->downNote() : chord()->upNote();
y1 += (up() ? n->stemUpSE().y() : n->stemDownNW().y());
rypos() = n->rypos();
}
}
qreal lw5 = _lineWidth * .5;
line.setLine(0.0, y1, 0.0, l);
// compute bounding rectangle
QRectF r(line.p1(), line.p2());
setbbox(r.normalized().adjusted(-lw5, -lw5, lw5, lw5));
adjustReadPos(); // does not work if stem is layouted twice
}
示例11: isEqual
bool StaffType::isEqual(const StaffType& st) const
{
return st.group() == group()
&& st._name == _name
&& st._stepOffset == _stepOffset
&& st._genClef == _genClef
&& st._showBarlines == _showBarlines
&& st._slashStyle == _slashStyle
&& st._genTimesig == _genTimesig
;
}
示例12: fillStaffTypeCombo
void EditStaff::fillStaffTypeCombo()
{
Score* score = staff->score();
int curIdx = 0;
int n = score->staffTypes().size();
// can this instrument accept tabs or drum set?
bool canUseTabs = instrument.stringData() && instrument.stringData()->strings() > 0;
bool canUsePerc = instrument.useDrumset();
staffType->clear();
for (int idx = 0; idx < n; ++idx) {
StaffType* st = score->staffType(idx);
if ( (canUseTabs && st->group() == TAB_STAFF_GROUP)
|| ( canUsePerc && st->group() == PERCUSSION_STAFF_GROUP)
|| (!canUsePerc && st->group() == STANDARD_STAFF_GROUP) ) {
staffType->addItem(st->name(), idx);
if (st == staff->staffType())
curIdx = staffType->count() - 1;
}
}
staffType->setCurrentIndex(curIdx);
}
示例13: updateStaffType
void EditStaff::updateStaffType()
{
StaffType* staffType = staff->staffType();
lines->setValue(staffType->lines());
lineDistance->setValue(staffType->lineDistance().val());
showClef->setChecked(staffType->genClef());
showTimesig->setChecked(staffType->genTimesig());
showBarlines->setChecked(staffType->showBarlines());
staffGroupName->setText(qApp->translate("Staff type group name", staffType->groupName()));
}
示例14: isSameStructure
bool StaffType::isSameStructure(const StaffType& st) const
{
return st.group() == group()
&& st._lines == _lines
&& st._stepOffset == _stepOffset
&& st._lineDistance == _lineDistance
&& st._genClef == _genClef
&& st._showBarlines == _showBarlines
&& st._slashStyle == _slashStyle
&& st._genTimesig == _genTimesig
;
}
示例15: createNewType
void EditStaffType::createNewType()
{
//
// initialize new StaffType with current selected one
//
int idx = staffTypeList->currentItem()->data(Qt::UserRole).toInt();
StaffType* ns = staffTypes[idx]->clone();
//
// create unique new name for StaffType
//
// count how many types there are already of the same group of the new type
for (int i = idx = 0; i < staffTypes.count(); i++)
if (staffTypes[i]->group() == ns->group())
idx++;
QString name;
switch (ns->group())
{
case STANDARD_STAFF_GROUP:
name = QString("Standard-%1 [*]").arg(idx);
break;
case PERCUSSION_STAFF_GROUP:
name = QString("Perc-%1 [*]").arg(idx);
break;
case TAB_STAFF_GROUP:
name = QString("Tab-%1 [*]").arg(idx);
break;
}
ns->setName(name);
staffTypes.append(ns);
QListWidgetItem* item = new QListWidgetItem(ns->name());
item->setData(Qt::UserRole, staffTypes.size() - 1);
staffTypeList->addItem(item);
staffTypeList->setCurrentItem(item);
modified = true;
}