Skip to content

Commit

Permalink
Merge commit '960bd5a5976e79ea5f60b348aebae70479db77c8' into hotfix/0…
Browse files Browse the repository at this point in the history
….6.7

* commit '960bd5a5976e79ea5f60b348aebae70479db77c8':
  issues moved to regression tests
  change log
  fix slur issues: slurs tellPosition is now called after beaming is done
  remove commented code
  add isGRSlur method
  add methods (TopLeft and BottomRight)
  partial fix for issue grame-cncm#96
  • Loading branch information
arshiacont committed Feb 25, 2020
2 parents 66a45c6 + 960bd5a commit bc09263
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 76 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GUIDO Engine history
- fix incorrect slur position for beamed chords (issue #100)
- fix incorrect tuplets on chords (issue #103)
- fix incorrect tremolo on chords preceded by a grace note (issue #108)
- fix incorrect incorrect slur position (issue #94)

----------------------------------------------------------------
version 1.6.7
Expand Down
26 changes: 13 additions & 13 deletions open-issues/g-issue96.gmn
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
(*
Issue #96
Cross Staff Beaming Part 3
upper staff notes are not included in the beaming
in addition, clef, meter and time signature are not displayed
when the rest is commented (likely because the first note is not on the staff)
*)

{
[
\clef<"g2"> \key<-5> \meter<"C">
% _
\stemsUp
\slurBegin:1<curve="down">
\beam (\staff<2> a&0/16 \staff<1> e&1/16 g&/16 \staff<2> g&0/16 )
\slurEnd:1
]
,
[
\clef<"f4"> \key<-5> {a&-2/1, a&-1/1} \bar
]
}
[ \staff<1>
\clef<"g2"> \key<-5> \meter<"C">
\staff<2> \stemsUp
\slurBegin:1<curve="down"> \beamBegin:1 \beamBegin:2 a&0/16 \staff<1> e&1/16 g&/16 \staff<2> g&0/16 \slurEnd:1 \beamEnd:2 \beamEnd:1
\slurBegin:1<curve="down"> \beamBegin:1 \beamBegin:2 a&/16 \staff<1> d&1/16 f/16 \staff<2> f0/16 \slurEnd:1 \beamEnd:2 \beamEnd:1
\slurBegin:1<curve="down"> \beamBegin:1 \beamBegin:2 a&/16 \staff<1> d&1/16 f/16 \staff<2> f0/16 \slurEnd:1 \beamEnd:2 \beamEnd:1
\slurBegin:1<curve="down"> \beamBegin:1 \beamBegin:2 a&/16 \staff<1> d&1/16 f/16 \staff<2> f0/16 \slurEnd:1 \beamEnd:2 \beamEnd:1 \staff<1> \bar
],
[ \staff<2> \clef<"f4"> \key<-5> {a&-2/1, a&-1/1} \bar ]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
\beam (e&3/8. d/16 c/8) \beam(b&2/8. a&/16 g/8) \bar
\beam(f/8. g/16 e/8) \beam(f/8. d&/16 d/8) \bar
% \beam(f/8. g/16 e/8) \beam(f/8. d&/16 d/8) \bar
%\newLine
\newLine
\beam(e&/8. f/16 d/8) \beam(e&/8. c&/16 d&/8) \bar
e&/4. b&1/8
\slurEnd:1
Expand Down
File renamed without changes.
63 changes: 41 additions & 22 deletions src/engine/graphic/GRBeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void GRBeam::initp0 (GRSystemStartEndStruct * sse, const GREvent * startEl, PosI
infos.currentSize = refEvt ? refEvt->getSize() : 1;
infos.currentLSPACE = refStaff->getStaffLSPACE();
st->p[0] = refEvt ? refEvt->getStemStartPos() : refStaff->getPosition();
//cerr << "GRBeam::initp0 " << refEvt << " " << st->p[0] << " " << refEvt->getStemLength() << endl;

if (arBeam && arBeam->isGuidoSpecBeam() && refEvt)
st->p[0].y = refEvt->getPosition().y;

Expand Down Expand Up @@ -483,9 +483,6 @@ void GRBeam::initp2 (GRSystemStartEndStruct * sse, const GREvent * endEl, PosInf
GRStaff * refStaff = endEl ? endEl->getGRStaff() : getGRStaff();
infos.currentLSPACE = refStaff->getStaffLSPACE();

//cerr << "GRBeam::initp2 " << endEl << " " << st->p[2] << endl;
//cerr << "GRBeam::initp2 " << endEl->getGlobalStem()->getPosition() << " " << endEl->getGlobalStem()->getStemLength() << endl;

if (getTagType() == SYSTEMTAG) {
st->p[2] += refStaff->getPosition();
if (infos.stavesStartEnd && !infos.stemsReverse && !endEl->getStemLengthSet()) {
Expand Down Expand Up @@ -548,11 +545,26 @@ void GRBeam::initp3 (GRSystemStartEndStruct * sse, PosInfos& infos)
void GRBeam::slopeAdjust (GRSystemStartEndStruct * sse, const GREvent * startEl, const GREvent * endEl, float slope, PosInfos& infos)
{
GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
if (startEl && endEl && infos.stemdir != endEl->getStemDirection())

if (endEl == 0)
{
// then we have an empty-event make the slope even ....
// or make it dependant on generell direction of beam (how ...)
st->p[2].y = st->p[0].y;
st->p[3].y = st->p[1].y;
}
else if (startEl == 0)
{
st->p[0].y = st->p[2].y;
st->p[1].y = st->p[3].y;
}

// if (startEl && endEl && infos.stemdir != endEl->getStemDirection())
else if (infos.stemdir != endEl->getStemDirection())
{
// then we should try an optimizing strategy which is not implemented now ....
}
else if (startEl && endEl && slope > 0.1f )
else if (slope > 0.1f )
{
// adjust the length of the stem for second st->p ...
if( infos.stemdir == dirDOWN) {
Expand All @@ -570,7 +582,7 @@ void GRBeam::slopeAdjust (GRSystemStartEndStruct * sse, const GREvent * startEl,
st->p[3].y += (GCoord) diff;
}
}
else if (startEl && endEl && slope < -0.1f)
else if (slope < -0.1f)
{
if (infos.stemdir == dirDOWN)
{
Expand All @@ -589,18 +601,6 @@ void GRBeam::slopeAdjust (GRSystemStartEndStruct * sse, const GREvent * startEl,
st->p[1].y += (GCoord) diff;
}
}
else if (endEl == 0)
{
// then we have an empty-event make the slope even ....
// or make it dependant on generell direction of beam (how ...)
st->p[2].y = st->p[0].y;
st->p[3].y = st->p[1].y;
}
else if (startEl == 0)
{
st->p[0].y = st->p[2].y;
st->p[1].y = st->p[3].y;
}
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -1102,6 +1102,25 @@ bool GRBeam::reverseStems (const NEPointerList* assoc) const
return false;
}

//--------------------------------------------------------------------
void GRBeam::scanStaves (const NEPointerList* assoc, float& highStaff, float& lowStaff) const
{
float high = 10000.f;
float low = 0.f;
GuidoPos pos = assoc->GetHeadPosition();
while (pos) {
const GREvent* ev = assoc->GetNext(pos)->isGREvent();
if (ev) {
const GRStaff* currentStaff = ev->getGRStaff();
float ypos = currentStaff->getPosition().y ;
if (ypos > low) low = ypos;
if (ypos < high) high = ypos;
}
}
highStaff = high;
lowStaff = low;
}

//--------------------------------------------------------------------
void GRBeam::yRange (const NEPointerList* assoc, const GREvent*& high, const GREvent*& low) const
{
Expand Down Expand Up @@ -1213,6 +1232,7 @@ void GRBeam::tellPosition( GObject * gobj, const NVPoint & p_pos)
if (getTagType() == SYSTEMTAG) {
infos.startStaff = startEl->getGRStaff()->getPosition();
infos.endStaff = endEl->getGRStaff()->getPosition();
scanStaves(mAssociated, infos.highStaff, infos.lowStaff);
yRange(mAssociated, infos.highNote, infos.lowNote);
}

Expand Down Expand Up @@ -1256,10 +1276,9 @@ void GRBeam::tellPosition( GObject * gobj, const NVPoint & p_pos)
// and if we are note in the case of a chained feather beam
if ( (startEl && startEl->getStemLengthSet() && endEl && endEl->getStemLengthSet())
|| getTagType() == SYSTEMTAG || (arBeam && isSpecBeam) || (fIsFeathered && startEl && startEl->stemHasBeenChanged()))
{
needsadjust = false;
}
else slopeAdjust (sse, startEl, endEl, slope, infos);
if (infos.fixCrossStaffUp()) needsadjust = true;
if (needsadjust) slopeAdjust (sse, startEl, endEl, slope, infos);

if (arBeam && isSpecBeam)
{
Expand Down
6 changes: 6 additions & 0 deletions src/engine/graphic/GRBeam.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ class GRBeam : public GRPTagARNotationElement, public GRSystemTagInterface
const GREvent* highNote; // the highest note (y position)
const GREvent* lowNote; // the lowest note
NVPoint startStaff; // the start staff position
float highStaff; // the higher staff y position
float lowStaff; // the lower staff y position
NVPoint endStaff; // the end staff position

bool fixCrossStaffUp () const { return (stemdir == dirUP) && (!stemsReverse) && (highStaff < startStaff.y) && (highStaff != endStaff.y); }

} PosInfos;

void initp0 (GRSystemStartEndStruct * sse, const GREvent * startEl, PosInfos& infos);
Expand All @@ -108,6 +113,7 @@ class GRBeam : public GRPTagARNotationElement, public GRSystemTagInterface
void setBeams (GRSystemStartEndStruct * sse, PosInfos& infos, float yFact1, float yFact2, int direction);
bool reverseStems (const NEPointerList* assoc) const;
void yRange (const NEPointerList* assoc, const GREvent*& high, const GREvent*& low) const;
void scanStaves (const NEPointerList* assoc, float& highStaff, float& lowStaff) const;
void checkEndStemsReverse (GREvent* ev, const SimpleBeamList * beams) const;

bool fIsFeathered;
Expand Down
34 changes: 21 additions & 13 deletions src/engine/graphic/GRBowing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ GRBowing::GRBowing(GRStaff * grstaff, GRNotationElement * startEl, GRNotationEle
setStartElement(grstaff, startEl);
else // no start element: we're left-opened
{
setStartElement(grstaff, /*dynamic cast<GRNotationElement *>*/(grstaff->getSecondGlue()));
setStartElement(grstaff, grstaff->getSecondGlue());
sse->startflag = GRSystemStartEndStruct::OPENLEFT;
}

Expand All @@ -66,7 +66,7 @@ GRBowing::GRBowing(GRStaff * grstaff, GRNotationElement * startEl, GRNotationEle
}
else // no end element: we're righ-opened
{
setEndElement(grstaff, /*dynamic cast<GRNotationElement *>*/(grstaff->getEndGlue()));
setEndElement(grstaff, grstaff->getEndGlue());
sse->endflag = GRSystemStartEndStruct::OPENRIGHT;
}

Expand Down Expand Up @@ -600,16 +600,24 @@ void GRBowing::setOffset(int n_point,const NVPoint & p)
// here an array must be used (need lists and arrays)
}

#ifndef WIN32
#warning ("TODO: revise GRBowing::tellPosition");
#endif

// -----------------------------------------------------------------------------
void GRBowing::tellPosition(GObject * caller, const NVPoint & newPosition)
{
GRNotationElement * el = dynamic_cast<GRNotationElement *>(caller);
if (el == 0 ) return;

if (isGRSlur()) {
fDeferredTellPostion.push(el);
return; // slurs are handled at the end
}
tellPositionEnd (el);
}

// -----------------------------------------------------------------------------
void GRBowing::tellPositionEnd (GRNotationElement * el)
{
if (el == 0 ) return;

GRStaff * staff = el->getGRStaff();
if (staff == 0 ) return;

Expand All @@ -618,15 +626,10 @@ void GRBowing::tellPosition(GObject * caller, const NVPoint & newPosition)

const GRNotationElement * const startElement = sse->startElement;
const GRNotationElement * const endElement = sse->endElement;

//cerr << "GRBowing::tellPosition caller " << el->getRelativeTimePosition() << " " << el << " flags: " << sse->startflag << " " << sse->endflag << endl;
//cerr << "GRBowing::tellPosition start " << startElement << " spos: " << mAssociated->GetAt(sse->startpos) << endl;
//cerr << "GRBowing::tellPosition end " << endElement << " epos: " << mAssociated->GetAt(sse->endpos) << endl;

if( el == endElement || ( endElement == 0 && el == startElement)) {
const GRNote * start = startElement->isGRNote();
const GRNote * end = endElement ? endElement->isGRNote() : 0;
NEPointerList* al = getAssociations();
const GRSingleNote * start = startElement->isSingleNote();
const GRSingleNote * end = endElement ? endElement->isSingleNote() : 0;
int n = al ? al->size() : 0;
bool grace = ((n == 2) && start && end && start->isGraceNote() && !end->isGraceNote());
updateBow( staff, grace );
Expand Down Expand Up @@ -722,6 +725,11 @@ void GRBowing::OnDraw( VGDevice & hdc) const

// restore old pen and brush
if (mColRef) hdc.PopFillColor();

// hdc.Frame(fStartBox.left, fStartBox.top, fStartBox.right, fStartBox.bottom);
// hdc.Frame(fEndBox.left, fEndBox.top, fEndBox.right, fEndBox.bottom);
// hdc.Frame(fMidBox.left, fMidBox.top, fMidBox.right, fMidBox.bottom);
//cerr << "GRBowing::OnDraw high : " << fMidBox.TopLeft() << " low: " << fMidBox.BottomRight() << endl;
}

// -----------------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions src/engine/graphic/GRBowing.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

#include <queue>

#include "GRPTagARNotationElement.h"

class ARBowing;
Expand All @@ -33,8 +35,9 @@ void drawSlur( VGDevice & hdc, float x1, float y1, float x2, float y2, float x3,
*/
class GRBowing : public GRPTagARNotationElement
{
public:

protected:
std::queue<GRNotationElement*> fDeferredTellPostion;

/** \brief Save informations needed to draw the bow
when different staves are needed, see GRPositionTag for comment.
*/
Expand Down Expand Up @@ -90,6 +93,7 @@ class GRBowing : public GRPTagARNotationElement
virtual void removeAssociation(GRNotationElement * el );
virtual void addAssociation(GRNotationElement * );

virtual void tellPositionEnd(GRNotationElement * caller);
virtual void tellPosition(GObject * caller, const NVPoint & newPosition);
virtual GRNotationElement * getStartElement(GRStaff * grstaff) const;
virtual GRNotationElement * getEndElement(GRStaff * grstaff) const;
Expand Down
1 change: 1 addition & 0 deletions src/engine/graphic/GRNotationElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class GRNotationElement : public GObject, public GRVisitable
virtual const GRBar * isGRBar() const { return 0; }
virtual const GRDynamics * isGRDynamic() const { return 0; }
virtual GRFingering * isGRFingering() { return 0; }
virtual GRSlur * isGRSlur() { return 0; }

protected:

Expand Down
2 changes: 1 addition & 1 deletion src/engine/graphic/GRPositionTag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void GRPositionTag::StaffFinished(GRStaff * grstaff)
// there is no old lastendelement in this case
assert(lastendElement == NULL);

setEndElement(grstaff, /*ynamic_cast<GRNotationElement *>*/(grstaff->getEndGlue()));
setEndElement(grstaff, grstaff->getEndGlue());
sse->endflag = GRSystemStartEndStruct::OPENRIGHT;
sse->endpos = associated->GetTailPosition();

Expand Down
6 changes: 2 additions & 4 deletions src/engine/graphic/GRSlur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,19 @@ void GRSlur::automaticControlPoints( const GRBowingContext * context, const ARBo

// - Find the best slopes for the left and right segments of the triangle, such
// that no object is above them (or below, if the bow goes downward).

GuidoPos pos = mAssociated->GetHeadPosition();
int size = mAssociated->size() - 2;
mAssociated->GetNext(pos); // skip the first element
while( pos && size--) // and the last element
{
GRNotationElement * el = mAssociated->GetNext(pos);
GREvent * el = mAssociated->GetNext(pos)->isGREvent();
if( el && !el->isEmpty()) {
// - Get this element box
NVRect elBox ( el->getBoundingBox());
if( elBox.Width() == 0 && elBox.Height() == 0 ) continue; // useless ?
NVPoint elPos = el->getPosition();
elBox += elPos;

// - Get the two corners we must deal with (depends of curve direction up/down)
x1 = elBox.left;
x2 = elBox.right;
Expand All @@ -314,7 +313,6 @@ void GRSlur::automaticControlPoints( const GRBowingContext * context, const ARBo
endA = a;
}
}

// -- Tune the slopes so the triangle is isocele
float startAngle = atan(startA) - baseAngle;
float endAngle = atan(endA) - baseAngle;
Expand Down
5 changes: 5 additions & 0 deletions src/engine/graphic/GRSlur.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ class GRSlur : public GRBowing
GRSlur (GRStaff * grstaff, const ARSlur * inAR ) : GRBowing(grstaff, inAR ) {}
virtual ~GRSlur() {}

GRNotationElement* nextDeferred() { GRNotationElement* elt= fDeferredTellPostion.front(); fDeferredTellPostion.pop(); return elt; }
size_t countDeferred() { return fDeferredTellPostion.size(); }

protected:
virtual void automaticCurveDirection( GRBowingContext * context, const ARBowing * arBow, GRSystemStartEndStruct * sse );
virtual void automaticAnchorPoints ( const GRBowingContext * context, const ARBowing * arBow, GRSystemStartEndStruct * sse );
virtual void automaticControlPoints ( const GRBowingContext * context, const ARBowing * arBow, GRSystemStartEndStruct * sse );
virtual void accept (GRVisitor& visitor);

virtual GRSlur * isGRSlur() { return this; }

private:
float getEltOffset (const GRNotationElement* el ) const;
NVRect getElementBox (const GRBowingContext * context, const GRNotationElement* el ) const;
Expand Down
Loading

0 comments on commit bc09263

Please sign in to comment.