Beispiel #1
0
/** \brief Break a tag at a previously saved PBreak-Location.

	It sets the sse-Positions ...
	(It is somewhat equivalent to StaffFinished
	with the difference, that assocpos is
	used). assocpos is the tail-position of the
	mAssociated list at the time of the pbreak-
	situation.
*/
void GRBeam::BreakTag( GRStaff * grstaff, GuidoPos & assocpos)
{
	if (!grstaff) return;

	// do the "basic" stuff.
	GRPositionTag::BreakTag(grstaff,assocpos);

	if (error) return;

	GRSystemStartEndStruct *sse = getSystemStartEndStruct(grstaff->getGRSystem());
	assert(sse);
//	GRBeamSaveStruct *st = (GRBeamSaveStruct *) sse->p;
	GREvent * grn;

	checkNotes(grstaff);
	if (error) return;

	GuidoPos pos = sse->startpos;
	while (pos)
	{
		GuidoPos prevpos = pos;
		grn = GREvent::cast(mAssociated->GetNext(pos));
		if (grn)
			grn->setFlagOnOff(0);

		if (prevpos == sse->endpos)
			break;
	}
}
Beispiel #2
0
void GRBeam::setError(const GRStaff * grstaff, int p_error)
{
	GRTag::setError(p_error);
	if (error && mAssociated)
	{
		GuidoPos pos = mAssociated->GetHeadPosition();
		while (pos)
		{
			GREvent * grnot = GREvent::cast (mAssociated->GetNext(pos));
			if (grnot)
			{
				grnot->setFlagOnOff(1);
			}
		}
	}

	// this just removes the associations from
	// all active SSE's. The SSE's themselves
	// stay, where they are, so that they are
	// delete properly later ....
	DeleteAllSSEs();

	delete mAssociated;
	mAssociated = NULL;
}
Beispiel #3
0
void GRBeam::StaffFinished(GRStaff * grstaff)
{
	assert(false);
	assert(grstaff);

	// first, all the BASIC stuff is handled ...
	GRPositionTag::StaffFinished(grstaff);

	if (error) return;

	GRSystemStartEndStruct * sse = getSystemStartEndStruct(grstaff->getGRSystem());

	assert(sse);

	GuidoPos syststpos = sse->startpos;
	if (syststpos)
	{
		// this is all done so that I really get a correct first staff to
		// test my stuff ...
		while (syststpos && 
			!/*ynamic_cast<GRNotationElement *>*/(mAssociated->GetAt(syststpos)))
		{
			mAssociated->GetNext(syststpos);
		}
		const GRStaff *tststaff = mAssociated->GetNext(syststpos)->getGRStaff();
		while (syststpos)
		{
			GRNotationElement * el = mAssociated->GetNext(syststpos);
			if (el)
			{
				if (el->getGRStaff() != tststaff)
				{
					tagtype = GRTag::SYSTEMTAG;
					GRSystemTag * mysystag = new GRSystemTag(this);
					el->getGRSystemSlice()->addSystemTag(mysystag);
					break;
				}
			}		
		}
	}

	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	GREvent * grn;
	checkNotes(grstaff);

	if (error) return;

	GuidoPos pos = sse->startpos;
	while (pos)
	{
		grn = GREvent::cast(mAssociated->GetNext(pos));
		if (grn)
		{
			if (!st->dirset)
			{
				if (st->direction > 0)
					grn->setStemDirection(dirUP);
				else
					grn->setStemDirection(dirDOWN);
			}
			grn->setFlagOnOff(false);
		}
	}
}
Beispiel #4
0
void GRBeam::RangeEnd(GRStaff * grstaff)
{
	assert(grstaff);

	GRPositionTag::RangeEnd(grstaff);

	if (error) return;
	if (!mAssociated) return;
	
	GRSystemStartEndStruct * sse = getSystemStartEndStruct(grstaff->getGRSystem());
	assert(sse);

	if (mAssociated && (mAssociated->GetCount() == 1) && isAutoBeam())
	{
		GREvent * ev = GREvent::cast(mAssociated->GetHead());
		if (ev)
		{
			ev->setFlagOnOff(true);
			ev->decBeamCount();
			if (sse->startElement)	// something did not work, if the starElement is a glue ... and not an event
				ev->removeAssociation(this);
			if (sse->endElement)
				ev->removeAssociation(this);
		}
		return;
	}

	GREvent * grn;
	GuidoPos syststpos = sse->startpos;
	if (syststpos)
	{
		// this is all done so that I really get a correct first staff to test my stuff ...
		while (syststpos && !(mAssociated->GetAt(syststpos)))
		{
			mAssociated->GetNext(syststpos);
		}
		int tststaffnum = mAssociated->GetNext(syststpos)->getStaffNumber(); 
		while (syststpos)
		{
			GRNotationElement * el = mAssociated->GetNext(syststpos);
			if (el)
			{
				if (el->getStaffNumber() != tststaffnum)
				{
					tagtype = GRTag::SYSTEMTAG;
					GRSystemTag * mysystag = new GRSystemTag(this);
					el->getGRSystemSlice()->addSystemTag(mysystag);
					break;
				}
			}		
		}
	}

	GuidoPos pos = sse->startpos;
	GRBeamSaveStruct * st = (GRBeamSaveStruct *) sse->p;
	bool first = true;

	GDirection mytmpdir = dirOFF;
	while (pos)
	{
		grn = GREvent::cast(mAssociated->GetNext(pos));
		if (grn)
		{
			if (!st->dirset)
			{
				if (first)
				{
					// get the stemdir of the first !? maybe it now has been set?
					mytmpdir = grn->getStemDirection();
				}
				if (mytmpdir != dirOFF)
					grn->setStemDirection(mytmpdir);
				else if (st->direction>=0)
					grn->setStemDirection(dirUP);
				else
					grn->setStemDirection(dirDOWN);
			}
			grn->setFlagOnOff(false);
			first = false;
		}
	}
}
Beispiel #5
0
void GRBeam::addAssociation(GRNotationElement * grnot)
{
	if (error || !grnot) return ;

	const GRStaff * grstf = grnot->getGRStaff();
	if (grstf == 0) return;

    GRNote * grnote = dynamic_cast<GRNote*>(grnot);
    bool isGrace = grnote ? grnote->isGraceNote() : false;
    
	if (grnot->getDuration() == DURATION_0 && !isGrace)
	{
		GREvent * grn = GREvent::cast(grnot);
		if (!grn || grn->getGlobalStem() == NULL)
			return;
	}

	// if we are an autobeam we do not beam rests ....

	const bool isautobeam = isAutoBeam(); // (dynamic cast<GRAutoBeam *>(this) != 0);

	GREvent * grn = GREvent::cast(grnot);
	if (grn == 0) 
	{
		setError(grstf,1);
		return ;
	}

	const bool isRest = (dynamic_cast<GRRest *>(grnot) != 0);
	if (isautobeam && isRest)
	{
		if (mAssociated && mAssociated->GetCount() > 0)
			mHasRestInMiddle = true;
	}

	if (mHasRestInMiddle && !isRest)
	{
		// then we have a real Error
		setError(grstf,1);
		return;
	}

	// ignore all elements with duration 0
	// but only, if I already have the stem
	if (grnot->getDuration() == DURATION_0 && !isGrace)
	{
		if (mAssociated)
		{
			GRNotationElement * el = mAssociated->GetTail();
			if (el)
			{
				GREvent * ev = GREvent::cast(el);
				
				if (ev->getGlobalStem() == NULL ||
					ev->getGlobalStem() == grn->getGlobalStem())
					return;
			}
		}
	}

	if (dynamic_cast<GRSingleRest *>(grn))
	{
		// ignoriere Pausen !
		// setError(grstf,1);
		return;
	}

	if (grn->getNumFaehnchen() == 0)
	{
		setError(grstf,1);
		return ;
	} 

	GRSystemStartEndStruct * sse = getSystemStartEndStruct(grstf->getGRSystem());
	if (!sse) return ;

	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	
	if (grn->getStemDirSet())
	{
		st->dirset = 1;
	}
	else
	{
		if (grn->getStemDirection() == dirUP)
			st->direction++;
		else if (grn->getStemDirection() == dirDOWN)
			st->direction--;
	}

	GRPTagARNotationElement::addAssociation(grnot);
		
	// this is a test ...
	// and cannot be done that way.
	// otherwise we do not get the flags on again ...
	grn->setFlagOnOff(false);
	//if we increment the beamCount, we can't allow several beams to be superposed
//	grn->incBeamCount();
}