Skip to content

Commit 1ceb6a0

Browse files
committed
Introduce new accidental placement algorithm and options
1 parent 4852ed8 commit 1ceb6a0

39 files changed

+1992
-226
lines changed

src/engraving/dom/accidental.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ double Accidental::subtype2centOffset(AccidentalType st)
306306
return ACC_LIST[int(st)].centOffset;
307307
}
308308

309+
int Accidental::line() const
310+
{
311+
return note()->line();
312+
}
313+
309314
//---------------------------------------------------------
310315
// name2subtype
311316
//---------------------------------------------------------
@@ -437,6 +442,7 @@ PropertyValue Accidental::getProperty(Pid propertyId) const
437442
case Pid::SMALL: return m_isSmall;
438443
case Pid::ACCIDENTAL_BRACKET: return int(bracket());
439444
case Pid::ACCIDENTAL_ROLE: return role();
445+
case Pid::ACCIDENTAL_STACKING_ORDER_OFFSET: return stackingOrderOffset();
440446
default:
441447
return EngravingItem::getProperty(propertyId);
442448
}
@@ -453,6 +459,7 @@ PropertyValue Accidental::propertyDefault(Pid propertyId) const
453459
case Pid::SMALL: return false;
454460
case Pid::ACCIDENTAL_BRACKET: return int(AccidentalBracket::NONE);
455461
case Pid::ACCIDENTAL_ROLE: return AccidentalRole::AUTO;
462+
case Pid::ACCIDENTAL_STACKING_ORDER_OFFSET: return 0;
456463
default:
457464
return EngravingItem::propertyDefault(propertyId);
458465
}
@@ -477,6 +484,9 @@ bool Accidental::setProperty(Pid propertyId, const PropertyValue& v)
477484
case Pid::ACCIDENTAL_ROLE:
478485
m_role = v.value<AccidentalRole>();
479486
break;
487+
case Pid::ACCIDENTAL_STACKING_ORDER_OFFSET:
488+
setStackingOrderOffset(v.toInt());
489+
break;
480490
default:
481491
return EngravingItem::setProperty(propertyId, v);
482492
}

src/engraving/dom/accidental.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class Accidental final : public EngravingItem
6161
OBJECT_ALLOCATOR(engraving, Accidental)
6262
DECLARE_CLASSOF(ElementType::ACCIDENTAL)
6363

64+
M_PROPERTY2(int, stackingOrderOffset, setStackingOrderOffset, 0)
65+
6466
public:
6567

6668
Accidental* clone() const override { return new Accidental(*this); }
@@ -109,6 +111,10 @@ class Accidental final : public EngravingItem
109111
static bool isMicrotonal(AccidentalType t) { return t > AccidentalType::FLAT3; }
110112
static double subtype2centOffset(AccidentalType);
111113

114+
int stackingOrder() const { return ldata()->stackingNumber + _stackingOrderOffset; }
115+
116+
int line() const;
117+
112118
String accessibleInfo() const override;
113119

114120
void computeMag();
@@ -124,6 +130,12 @@ class Accidental final : public EngravingItem
124130

125131
std::vector<Sym> syms;
126132

133+
ld_field<int> stackingNumber = { "[Accidental] stackingNumber", 0 };
134+
ld_field<int> verticalSubgroup = { "[Accidental] verticalSubgroup", 0 };
135+
ld_field<int> column = { "[Accidental] column", 0 };
136+
ld_field<std::vector<Accidental*> > octaves = { "[Accidental] octaves", std::vector<Accidental*> {} };
137+
ld_field<std::vector<Accidental*> > seconds = { "[Accidental] seconds", std::vector<Accidental*> {} };
138+
127139
bool isValid() const override { return EngravingItem::LayoutData::isValid() && !syms.empty(); }
128140
};
129141
DECLARE_LAYOUTDATA_METHODS(Accidental)

src/engraving/dom/property.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static constexpr PropertyMetaData propertyList[] = {
151151
{ Pid::TEMPO_FOLLOW_TEXT, true, "followText", P_TYPE::BOOL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "following text") },
152152
{ Pid::ACCIDENTAL_BRACKET, false, "bracket", P_TYPE::INT, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "bracket") },
153153
{ Pid::ACCIDENTAL_TYPE, true, "subtype", P_TYPE::INT, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "type") },
154+
{ Pid::ACCIDENTAL_STACKING_ORDER_OFFSET, true, "stackingOrderOffset", P_TYPE::INT, PropertyGroup::NONE, DUMMY_QT_TR_NOOP("propertyName", "stacking order offset") },
154155
{ Pid::NUMERATOR_STRING, false, "textN", P_TYPE::STRING, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "numerator string") },
155156
{ Pid::DENOMINATOR_STRING, false, "textD", P_TYPE::STRING, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "denominator string") },
156157
{ Pid::FBPREFIX, false, "prefix", P_TYPE::INT, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "prefix") },

src/engraving/dom/property.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ enum class Pid {
160160
TEMPO_FOLLOW_TEXT,
161161
ACCIDENTAL_BRACKET,
162162
ACCIDENTAL_TYPE,
163+
ACCIDENTAL_STACKING_ORDER_OFFSET,
163164
NUMERATOR_STRING,
164165
DENOMINATOR_STRING,
165166
FBPREFIX, // used for FiguredBassItem

src/engraving/infrastructure/shape.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,19 @@ bool Shape::contains(const PointF& p) const
494494
// intersects
495495
//---------------------------------------------------------
496496

497-
bool Shape::intersects(const RectF& rr) const
497+
bool Shape::intersects(const RectF& rr, double horClearance, double vertClearance) const
498498
{
499-
for (const RectF& r : m_elements) {
500-
if (r.intersects(rr)) {
501-
return true;
499+
if (RealIsNull(horClearance) && RealIsNull(vertClearance)) {
500+
for (const RectF& r : m_elements) {
501+
if (r.intersects(rr)) {
502+
return true;
503+
}
504+
}
505+
} else {
506+
for (const RectF& r : m_elements) {
507+
if (r.intersects(rr.adjusted(-horClearance, -vertClearance, horClearance, vertClearance))) {
508+
return true;
509+
}
502510
}
503511
}
504512
return false;
@@ -508,10 +516,10 @@ bool Shape::intersects(const RectF& rr) const
508516
// intersects
509517
//---------------------------------------------------------
510518

511-
bool Shape::intersects(const Shape& other) const
519+
bool Shape::intersects(const Shape& other, double horClearance, double vertClearance) const
512520
{
513521
for (const RectF& r : other.m_elements) {
514-
if (intersects(r)) {
522+
if (intersects(r, horClearance, vertClearance)) {
515523
return true;
516524
}
517525
}

src/engraving/infrastructure/shape.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ class Shape
158158
double leftMostEdgeAtHeight(double yAbove, double yBelow) const;
159159

160160
bool contains(const PointF&) const;
161-
bool intersects(const RectF& rr) const;
162-
bool intersects(const Shape&) const;
161+
bool intersects(const RectF& rr, double horClearance = 0.0, double vertClearance = 0.0) const;
162+
bool intersects(const Shape& other, double horClearance = 0.0, double vertClearance = 0.0) const;
163163
bool clearsVertically(const Shape& a) const;
164164

165165
void paint(muse::draw::Painter& painter) const;

0 commit comments

Comments
 (0)