[engraving] removed verticalClearance from Shape

This commit is contained in:
Igor Korsukov 2023-10-12 16:59:37 +03:00
parent b043502b6e
commit 9e5014caca
9 changed files with 46 additions and 48 deletions

View file

@ -115,30 +115,6 @@ const RectF& Shape::bbox() const
}
}
//-------------------------------------------------------------------
// minVerticalDistance
// a is located below this shape.
// Calculates the minimum distance between two shapes.
//-------------------------------------------------------------------
double Shape::minVerticalDistance(const Shape& a) const
{
return distances::minVerticalDistance(*this, a);
}
//-------------------------------------------------------------------
// verticalClearance
// a is located below this shape.
// Claculates the amount of clearance between the two shapes.
// If there is an overlap, returns a negative value corresponging
// to the amount of overlap.
//-------------------------------------------------------------------
double Shape::verticalClearance(const Shape& a) const
{
return distances::verticalClearance(*this, a);
}
//----------------------------------------------------------------
// clearsVertically()
// a is located below this shape

View file

@ -114,8 +114,6 @@ public:
Shape translated(const mu::PointF&) const;
const mu::RectF& bbox() const;
double minVerticalDistance(const Shape&) const;
double verticalClearance(const Shape&) const;
double topDistance(const mu::PointF&) const;
double bottomDistance(const mu::PointF&) const;
double left() const;

View file

@ -44,6 +44,7 @@
#include "tlayout.h"
#include "chordlayout.h"
#include "beamtremololayout.h"
#include "distances.h"
#include "log.h"
@ -893,7 +894,10 @@ void BeamLayout::verticalAdjustBeamedRests(Rest* rest, Beam* beam, LayoutContext
Shape restShape = rest->shape().translated(rest->pagePos() - rest->offset());
double restToBeamClearance = up ? beamShape.verticalClearance(restShape) : restShape.verticalClearance(beamShape);
double restToBeamClearance = up
? distances::verticalClearance(beamShape, restShape)
: distances::verticalClearance(restShape, beamShape);
if (restToBeamClearance > restToBeamPadding) {
return;
}

View file

@ -61,6 +61,7 @@
#include "slurtielayout.h"
#include "beamlayout.h"
#include "autoplace.h"
#include "distances.h"
using namespace mu::engraving;
using namespace mu::engraving::rendering::dev;
@ -1050,7 +1051,9 @@ void ChordLayout::layoutArticulations3(Chord* item, Slur* slur, LayoutContext& c
Shape sShape = ss->shape().translate(ss->pos());
if (aShape.intersects(sShape)) {
double d = ctx.conf().styleS(Sid::articulationMinDistance).val() * item->spatium();
d += slur->up() ? std::max(aShape.minVerticalDistance(sShape), 0.0) : std::max(sShape.minVerticalDistance(aShape), 0.0);
d += slur->up()
? std::max(distances::minVerticalDistance(aShape, sShape), 0.0)
: std::max(distances::minVerticalDistance(sShape, aShape), 0.0);
d *= slur->up() ? -1 : 1;
for (auto iter2 = iter; iter2 != item->articulations().end(); ++iter2) {
Articulation* aa = *iter2;
@ -3011,7 +3014,9 @@ void ChordLayout::resolveRestVSChord(std::vector<Rest*>& rests, std::vector<Chor
double clearance = 0.0;
Shape restShape = rest->shape().translated(rest->pos() - offset);
if (chord->segment() == rest->segment()) {
clearance = restAbove ? restShape.verticalClearance(chordShape) : chordShape.verticalClearance(restShape);
clearance = restAbove
? distances::verticalClearance(restShape, chordShape)
: distances::verticalClearance(chordShape, restShape);
} else {
Note* limitNote = restAbove ? chord->upNote() : chord->downNote();
Shape noteShape = limitNote->shape().translate(limitNote->pos());
@ -3095,9 +3100,9 @@ void ChordLayout::resolveRestVSRest(std::vector<Rest*>& rests, const Staff* staf
double clearance;
bool firstAbove = rest1->voice() < rest2->voice();
if (firstAbove) {
clearance = shape1.verticalClearance(shape2);
clearance = distances::verticalClearance(shape1, shape2);
} else {
clearance = shape2.verticalClearance(shape1);
clearance = distances::verticalClearance(shape2, shape1);
}
double margin = clearance - minRestToRestClearance;
int marginInSteps = floor(margin / lineDistance);

View file

@ -4134,8 +4134,8 @@ void TLayout::layoutOrnament(const Ornament* item, Ornament::LayoutData* ldata,
layoutAccidental(accidental, accLData, conf);
Shape accidentalShape = accidental->shape();
double minVertDist = above
? accidentalShape.minVerticalDistance(ldata->bbox())
: Shape(ldata->bbox()).minVerticalDistance(accidentalShape);
? distances::minVerticalDistance(accidentalShape, Shape(ldata->bbox()))
: distances::minVerticalDistance(Shape(ldata->bbox()), accidentalShape);
accLData->setPos(-0.5 * accLData->bbox().width(), above ? (-minVertDist - vertMargin) : (minVertDist + vertMargin));
}
@ -5798,8 +5798,9 @@ void TLayout::layoutTrillSegment(TrillSegment* item, LayoutContext& ctx)
double x = 0;
double y = 0;
x = 0.5 * (box.width() - a->width());
double minVertDist = accidentalGoesBelow ? Shape(box).minVerticalDistance(a->shape())
: a->shape().minVerticalDistance(Shape(box));
double minVertDist = accidentalGoesBelow
? distances::minVerticalDistance(Shape(box), a->shape())
: distances::minVerticalDistance(a->shape(), Shape(box));
y = accidentalGoesBelow ? minVertDist + vertMargin : -minVertDist - vertMargin;
a->setPos(x, y);
a->setParent(item);

View file

@ -89,6 +89,7 @@
#include "rendering/dev/tremololayout.h"
#include "rendering/dev/arpeggiolayout.h"
#include "rendering/dev/chordlayout.h"
#include "rendering/dev/distances.h"
#include "log.h"
@ -1300,8 +1301,8 @@ void SingleLayout::layout(Ornament* item, const Context& ctx)
layout(accidental, ctx);
Shape accidentalShape = accidental->shape();
double minVertDist = above
? accidentalShape.minVerticalDistance(item->ldata()->bbox())
: Shape(item->ldata()->bbox()).minVerticalDistance(accidentalShape);
? distances::minVerticalDistance(accidentalShape, item->ldata()->bbox())
: distances::minVerticalDistance(Shape(item->ldata()->bbox()), accidentalShape);
accidental->setPos(-0.5 * accidental->width(), above ? (-minVertDist - vertMargin) : (minVertDist + vertMargin));
}
return;
@ -1609,8 +1610,8 @@ void SingleLayout::layout(TrillSegment* item, const Context& ctx)
double y = 0;
x = 0.5 * (box.width() - a->width());
double minVertDist = accidentalGoesBelow
? Shape(box).minVerticalDistance(a->shape())
: a->shape().minVerticalDistance(Shape(box));
? distances::minVerticalDistance(Shape(box), a->shape())
: distances::minVerticalDistance(a->shape(), Shape(box));
y = accidentalGoesBelow ? minVertDist + vertMargin : -minVertDist - vertMargin;
a->setPos(x, y);
a->setParent(item);

View file

@ -44,11 +44,13 @@
#include "tlayout.h"
#include "chordlayout.h"
#include "../dev/beamtremololayout.h"
#include "../dev/distances.h"
#include "log.h"
using namespace mu::engraving;
using namespace mu::engraving::rendering::stable;
using namespace mu::engraving::rendering::dev;
void BeamLayout::layout(Beam* item, LayoutContext& ctx)
{
@ -882,7 +884,10 @@ void BeamLayout::verticalAdjustBeamedRests(Rest* rest, Beam* beam, LayoutContext
Shape restShape = rest->shape().translated(rest->pagePos() - rest->offset());
double restToBeamClearance = up ? beamShape.verticalClearance(restShape) : restShape.verticalClearance(beamShape);
double restToBeamClearance = up
? distances::verticalClearance(beamShape, restShape)
: distances::verticalClearance(restShape, beamShape);
if (restToBeamClearance > restToBeamPadding) {
return;
}

View file

@ -63,8 +63,11 @@
#include "beamlayout.h"
#include "autoplace.h"
#include "../dev/distances.h"
using namespace mu::engraving;
using namespace mu::engraving::rendering::stable;
using namespace mu::engraving::rendering::dev;
void ChordLayout::layout(Chord* item, LayoutContext& ctx)
{
@ -1092,7 +1095,9 @@ void ChordLayout::layoutArticulations3(Chord* item, Slur* slur, LayoutContext& c
Shape sShape = ss->shape().translate(ss->pos());
if (aShape.intersects(sShape)) {
double d = ctx.conf().styleS(Sid::articulationMinDistance).val() * item->spatium();
d += slur->up() ? std::max(aShape.minVerticalDistance(sShape), 0.0) : std::max(sShape.minVerticalDistance(aShape), 0.0);
d += slur->up()
? std::max(distances::minVerticalDistance(aShape, sShape), 0.0)
: std::max(distances::minVerticalDistance(sShape, aShape), 0.0);
d *= slur->up() ? -1 : 1;
for (auto iter2 = iter; iter2 != item->articulations().end(); ++iter2) {
Articulation* aa = *iter2;
@ -2999,7 +3004,9 @@ void ChordLayout::resolveRestVSChord(std::vector<Rest*>& rests, std::vector<Chor
double clearance = 0.0;
Shape restShape = rest->shape().translated(rest->pos() - offset);
if (chord->segment() == rest->segment()) {
clearance = restAbove ? restShape.verticalClearance(chordShape) : chordShape.verticalClearance(restShape);
clearance = restAbove
? distances::verticalClearance(restShape, chordShape)
: distances::verticalClearance(chordShape, restShape);
} else {
Note* limitNote = restAbove ? chord->upNote() : chord->downNote();
Shape noteShape = limitNote->shape().translate(limitNote->pos());
@ -3082,9 +3089,9 @@ void ChordLayout::resolveRestVSRest(std::vector<Rest*>& rests, const Staff* staf
double clearance;
bool firstAbove = rest1->voice() < rest2->voice();
if (firstAbove) {
clearance = shape1.verticalClearance(shape2);
clearance = distances::verticalClearance(shape1, shape2);
} else {
clearance = shape2.verticalClearance(shape1);
clearance = distances::verticalClearance(shape2, shape1);
}
double margin = clearance - minRestToRestClearance;
int marginInSteps = floor(margin / lineDistance);

View file

@ -3775,8 +3775,8 @@ void TLayout::layout(Ornament* item, LayoutContext& ctx)
layout(accidental, ctx);
Shape accidentalShape = accidental->shape();
double minVertDist = above
? accidentalShape.minVerticalDistance(ldata->bbox())
: Shape(ldata->bbox()).minVerticalDistance(accidentalShape);
? distances::minVerticalDistance(accidentalShape, ldata->bbox())
: distances::minVerticalDistance(Shape(ldata->bbox()), accidentalShape);
accidental->setPos(-0.5 * accidental->width(), above ? (-minVertDist - vertMargin) : (minVertDist + vertMargin));
}
}
@ -5311,8 +5311,9 @@ void TLayout::layout(TrillSegment* item, LayoutContext& ctx)
double x = 0;
double y = 0;
x = 0.5 * (box.width() - a->width());
double minVertDist = accidentalGoesBelow ? Shape(box).minVerticalDistance(a->shape())
: a->shape().minVerticalDistance(Shape(box));
double minVertDist = accidentalGoesBelow
? distances::minVerticalDistance(Shape(box), a->shape())
: distances::minVerticalDistance(a->shape(), Shape(box));
y = accidentalGoesBelow ? minVertDist + vertMargin : -minVertDist - vertMargin;
a->setPos(x, y);
a->setParent(item);