예제 #1
0
//____________________________________________________________________________________
void GRSingleNote::setPosition( const NVPoint & inPos )
{
	// - Call inherited
	GRNote::setPosition( inPos );

	// - Notify Ornament
	if ( mOrnament )
	{
		mOrnament -> tellPosition( this, getPosition() );
	}

	// - Watch for the Accidentals
	GRAccidentalList accList;
	extractAccidentals( &accList );

	GuidoPos pos = accList.GetHeadPosition();
	NVPoint pnt ( getPosition());
	pnt.x -= mNoteBreite * 0.5f;
	while (pos)
	{
		// if more than one accidental (like
		// natural AND sharp/flat)
		pnt.x -= LSPACE / 5;
		GRNotationElement * e = accList.GetNext(pos);
		e->setPosition(pnt);
		pnt.x -= // old: e->getSizeX();
			e->getLeftSpace() + e->getRightSpace();
	}
	updateBoundingBox(); // DEBUG
}
예제 #2
0
//____________________________________________________________________________________
void GRSingleNote::handleAccidental (const ARAcc* acc)
{
	// this is an Acc-Tag -> all accidentals must be shown ...
	//
	// the note has been created already ... ? has it?
	// Attention: here we do not have to look for the Accidentals that have been
	// created, but rather to the original accidentals set with the note
	ARNote * arnote = this->getARNote();
	GRAccidentalList accList;
	extractAccidentals( &accList );
	GuidoPos pos = accList.GetHeadPosition();
	if (pos == 0)
	{
		const int kNaturalAccidental = -10; // see the hard coded values in GRAccidental::accidentalID2symbol
		GRAccidental * myacc = new GRAccidental( this, mNoteBreite, kNaturalAccidental );

		// no accidentals! we need to force accidentals ...
		int mynewacc = arnote->getAccidentals() * 2 + ARNote::detune2Quarters(arnote->getDetune());
		if (mynewacc != 0) 
			myacc->setAccidentalByQuarter(mynewacc, getOffset().x, mNoteBreite);

		myacc->setPosition( getPosition());
		AddTail(myacc);
		accList.AddTail(myacc);
		pos = accList.GetHeadPosition();
	}

	while (pos)
	{
		GRAccidental * el = dynamic_cast<GRAccidental *>( accList.GetNext(pos));
		// this element is an accidental...
		// now we have to set the parameters (offset and all that...)
		NVPoint pt ( el->getOffset());
		if (acc->getDX() && acc->getDX()->TagIsSet())
			pt.x += (acc->getDX()->getValue());

		if (acc->getDY() && acc->getDY()->TagIsSet())
			pt.y -= (acc->getDY()->getValue());
		el->setOffset(pt);
		if (acc->getSize() && acc->getSize()->TagIsSet())
			el->setSize(acc->getSize()->getValue());

		if (acc->getStyle() == ARAcc::kCautionary) {
			if (el) el->setCautionary (getOffset().x, mNoteBreite);			
		}
		// color...
	}
	updateBoundingBox();
}
예제 #3
0
/** \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( &noteacclist );
			if (myacclist == 0)
				myacclist = new GRAccidentalList(0);
			
			myacclist->DumpListAtTail( &noteacclist );
		}
	}

	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;
}