/** \brief Goes through the elements and finds notes and then checkes, wether the accidentals collide. */ void GRSpring::checkAccidentalCollisions() { GRAccidentalList * myacclist = 0; GuidoPos pos = grolst.GetHeadPosition(); while (pos) { GRNotationElement * el = grolst.GetNext(pos); GRSingleNote * note = dynamic_cast<GRSingleNote *>(el); if (note) { GRAccidentalList noteacclist; note->extractAccidentals( ¬eacclist ); if (myacclist == 0) myacclist = new GRAccidentalList(0); myacclist->DumpListAtTail( ¬eacclist ); } } if (myacclist && myacclist->GetCount() > 1) { // now I have the accidentals at this Spring-location .... myacclist->sort( &compaccposy ); GuidoPos pos = myacclist->GetHeadPosition(); NVPoint pt; GRAccidental * prevacc = 0; while (pos) { GRAccidental * acc = myacclist->GetNext(pos); GCoord cury = acc->getPosition().y; if (prevacc) { if (acc->getGRStaff() != prevacc->getGRStaff() || (cury - prevacc->getPosition().y) > (3 * LSPACE)) pt.x = 0; } prevacc = acc; if (!acc->getOffsetSet()) acc->addToOffset(pt); pt.x -= 2 * (acc->getRightSpace()); } // now I have to update bounding boxes of notes... pos = grolst.GetHeadPosition(); while (pos) { GRSingleNote *sngnot = dynamic_cast<GRSingleNote *>(grolst.GetNext(pos)); if (sngnot) sngnot->updateBoundingBox(); } } delete myacclist; }
void GRGlobalStem::updateGlobalStem(const GRStaff * inStaff) { // now we can adjust the headoffsets for the notes ... // maybe we should sort the mAssociated list by y-position. // then we can travers the noteheads an make the // adjustion (semi-)automatic. mAssociated->sort( &compnotposy ); const float curLSPACE = inStaff->getStaffLSPACE(); ARTHead::HEADSTATE sugHeadState; ARTHead::HEADSTATE prevHeadState = ARTHead::NOTSET; float prevposy = 0; // (JB) warning, was not initialized. I don't know if 0 // is a good init value ! TODO: verify. // the first element is in most cases the empty-event!? GRSingleNote * note = dynamic_cast<GRSingleNote *>(mFirstEl); if (note) { note->adjustHeadPosition(ARTHead::NORMAL); note->updateBoundingBox(); } if (stemdir == dirDOWN) { sugHeadState = ARTHead::RIGHT; GuidoPos pos = mAssociated->GetHeadPosition(); while (pos) { note = dynamic_cast<GRSingleNote *>(mAssociated->GetNext(pos)); if (note) { if (prevHeadState != ARTHead::NOTSET) { float cury = (float)note->getPosition().y; if (tagtype == GRTag::SYSTEMTAG) cury += (float)note->getGRStaff()->getPosition().y; // y-values are ascending. if (cury != prevposy && cury - prevposy < curLSPACE) { // then I have to reverse the headsuggestion. if (prevHeadState == ARTHead::RIGHT) sugHeadState = ARTHead::LEFT; else sugHeadState = ARTHead::RIGHT; } else if (cury - prevposy >= curLSPACE) { if (prevHeadState == ARTHead::LEFT) sugHeadState = ARTHead::RIGHT; } } ARTHead::HEADSTATE retHeadState = note->adjustHeadPosition(sugHeadState); // now we have a current headstate .... prevHeadState = retHeadState; prevposy = note->getPosition().y; if (tagtype == GRTag::SYSTEMTAG) prevposy += note->getGRStaff()->getPosition().y; note->updateBoundingBox(); } } } else if (stemdir == dirUP || stemdir == dirOFF) { sugHeadState = ARTHead::LEFT; GuidoPos pos = mAssociated->GetTailPosition(); while (pos) { note = dynamic_cast<GRSingleNote *>(mAssociated->GetPrev(pos)); if (note) { if (prevHeadState != ARTHead::NOTSET) { float cury = (float)note->getPosition().y; if (tagtype == GRTag::SYSTEMTAG) cury += note->getGRStaff()->getPosition().y; // y-values are decending. if (cury != prevposy && prevposy - cury < curLSPACE) { // then I have to reverse the headsuggestion. if (prevHeadState == ARTHead::RIGHT) sugHeadState = ARTHead::LEFT; else sugHeadState = ARTHead::RIGHT; } else if (prevposy - cury >= curLSPACE) { if (prevHeadState == ARTHead::RIGHT) sugHeadState = ARTHead::LEFT; } } ARTHead::HEADSTATE retHeadState = note->adjustHeadPosition(sugHeadState); prevHeadState = retHeadState; prevposy = note->getPosition().y; if (tagtype == GRTag::SYSTEMTAG) prevposy += note->getGRStaff()->getPosition().y; note->updateBoundingBox(); } } } else { assert(false); } }