[engraving] changed implementation Beam shape
This commit is contained in:
parent
aa2dcb7b70
commit
8b11d82d32
|
@ -844,17 +844,6 @@ void BarLine::endEditDrag(EditData& ed)
|
|||
bed->yoff2 = 0.0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// shape
|
||||
//---------------------------------------------------------
|
||||
|
||||
Shape BarLine::doCreateShape() const
|
||||
{
|
||||
Shape shape;
|
||||
shape.add(ldata()->bbox(), this);
|
||||
return shape;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// scanElements
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -108,7 +108,6 @@ public:
|
|||
bool edit(EditData& ed) override;
|
||||
void editDrag(EditData&) override;
|
||||
void endEditDrag(EditData&) override;
|
||||
Shape doCreateShape() const override;
|
||||
|
||||
const ElementList* el() const { return &m_el; }
|
||||
|
||||
|
|
|
@ -848,11 +848,8 @@ bool Beam::hasAllRests()
|
|||
|
||||
Shape Beam::doCreateShape() const
|
||||
{
|
||||
Shape shape;
|
||||
for (BeamSegment* beamSegment : m_beamSegments) {
|
||||
shape.add(beamSegment->shape());
|
||||
}
|
||||
return shape;
|
||||
UNREACHABLE;
|
||||
return Shape();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
|
|
@ -536,13 +536,25 @@ public:
|
|||
return m_shape.value(mode).bbox();
|
||||
}
|
||||
|
||||
// Shape shape() const
|
||||
// {
|
||||
// Shape old = m_item->_internal_shape();
|
||||
// const Shape& sh = m_shape.value(LD_ACCESS::CHECK);
|
||||
// DO_ASSERT(old.equal(sh));
|
||||
// return old;
|
||||
// }
|
||||
bool isSetShape() const { return m_shape.has_value(); }
|
||||
void clearShape() { m_shape.reset(); }
|
||||
Shape shape() const
|
||||
{
|
||||
const Shape& sh = m_shape.value(LD_ACCESS::CHECK);
|
||||
|
||||
//! NOTE Temporary for debuging
|
||||
{
|
||||
switch (m_item->type()) {
|
||||
case ElementType::BEAM: return sh;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Shape old = m_item->_internal_shape();
|
||||
return old;
|
||||
}
|
||||
|
||||
void setShape(const Shape& sh) { m_shape.set_value(sh); }
|
||||
|
||||
void setBbox(const mu::RectF& r)
|
||||
{
|
||||
|
@ -606,7 +618,7 @@ public:
|
|||
LayoutData* mutldata();
|
||||
|
||||
virtual double mag() const;
|
||||
Shape shape() const { return doCreateShape(); }
|
||||
Shape shape() const { return ldata()->shape(); }
|
||||
virtual double baseLine() const { return -height(); }
|
||||
|
||||
mu::RectF abbox(LD_ACCESS mode = LD_ACCESS::CHECK) const { return ldata()->bbox(mode).translated(pagePos()); }
|
||||
|
|
|
@ -82,11 +82,11 @@ public:
|
|||
|
||||
bool equal(const Shape& sh) const
|
||||
{
|
||||
if (m_type != sh.m_type) {
|
||||
return false;
|
||||
}
|
||||
// if (m_type != sh.m_type) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
switch (m_type) {
|
||||
switch (sh.type()) {
|
||||
case Type::Fixed: return this->bbox() == sh.bbox();
|
||||
case Type::Composite: return this->m_elements == sh.m_elements;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ using namespace mu::engraving::rendering::dev;
|
|||
|
||||
void BeamLayout::layout(Beam* item, LayoutContext& ctx)
|
||||
{
|
||||
Beam::LayoutData* ldata = item->mutldata();
|
||||
// all of the beam layout code depends on _elements being in order by tick
|
||||
// this may not be the case if two cr's were recently swapped.
|
||||
std::sort(item->elements().begin(), item->elements().end(),
|
||||
|
@ -83,7 +84,9 @@ void BeamLayout::layout(Beam* item, LayoutContext& ctx)
|
|||
}
|
||||
crl.push_back(cr);
|
||||
}
|
||||
item->setbbox(RectF());
|
||||
|
||||
Shape beamShape(Shape::Type::Composite);
|
||||
|
||||
if (!crl.empty()) {
|
||||
SpannerSegmentType st;
|
||||
if (n == 0) {
|
||||
|
@ -96,30 +99,34 @@ void BeamLayout::layout(Beam* item, LayoutContext& ctx)
|
|||
}
|
||||
layout2(item, ctx, crl, st, static_cast<int>(n));
|
||||
|
||||
double lw2 = item->beamWidth() / 2.0;
|
||||
// double lw2 = item->beamWidth() / 2.0;
|
||||
|
||||
for (const BeamSegment* bs : item->beamSegments()) {
|
||||
PolygonF a(4);
|
||||
a[0] = PointF(bs->line.x1(), bs->line.y1());
|
||||
a[1] = PointF(bs->line.x2(), bs->line.y2());
|
||||
a[2] = PointF(bs->line.x2(), bs->line.y2());
|
||||
a[3] = PointF(bs->line.x1(), bs->line.y1());
|
||||
beamShape.add(bs->shape());
|
||||
|
||||
RectF pr = a.boundingRect();
|
||||
//! TODO In some cases (/vtest/scores/beams-19.mscz) the points of the line may be nan.
|
||||
//! This is a correction of the effect, we need to find the cause.
|
||||
{
|
||||
pr.setX((std::isinf(pr.x()) || std::isnan(pr.x())) ? 0.0 : pr.x());
|
||||
pr.setY((std::isinf(pr.y()) || std::isnan(pr.y())) ? 0.0 : pr.y());
|
||||
pr.setWidth((std::isinf(pr.width()) || std::isnan(pr.width())) ? 0.0 : pr.width());
|
||||
pr.setHeight((std::isinf(pr.height()) || std::isnan(pr.height())) ? 0.0 : pr.height());
|
||||
}
|
||||
// PolygonF a(4);
|
||||
// a[0] = PointF(bs->line.x1(), bs->line.y1());
|
||||
// a[1] = PointF(bs->line.x2(), bs->line.y2());
|
||||
// a[2] = PointF(bs->line.x2(), bs->line.y2());
|
||||
// a[3] = PointF(bs->line.x1(), bs->line.y1());
|
||||
|
||||
RectF r(pr.adjusted(0.0, -lw2, 0.0, lw2));
|
||||
item->addbbox(r);
|
||||
// RectF pr = a.boundingRect();
|
||||
// //! TODO In some cases (/vtest/scores/beams-19.mscz) the points of the line may be nan.
|
||||
// //! This is a correction of the effect, we need to find the cause.
|
||||
// {
|
||||
// pr.setX((std::isinf(pr.x()) || std::isnan(pr.x())) ? 0.0 : pr.x());
|
||||
// pr.setY((std::isinf(pr.y()) || std::isnan(pr.y())) ? 0.0 : pr.y());
|
||||
// pr.setWidth((std::isinf(pr.width()) || std::isnan(pr.width())) ? 0.0 : pr.width());
|
||||
// pr.setHeight((std::isinf(pr.height()) || std::isnan(pr.height())) ? 0.0 : pr.height());
|
||||
// }
|
||||
|
||||
// RectF r(pr.adjusted(0.0, -lw2, 0.0, lw2));
|
||||
// item->addbbox(r);
|
||||
}
|
||||
}
|
||||
|
||||
ldata->setShape(beamShape);
|
||||
|
||||
// The beam may have changed shape. one-note trems within this beam need to be layed out here
|
||||
for (ChordRest* cr : item->elements()) {
|
||||
if (cr->isChord() && toChord(cr)->tremolo() && !toChord(cr)->tremolo()->twoNotes()) {
|
||||
|
|
Loading…
Reference in a new issue