Ejemplo n.º 1
0
// --------------------------------------------------------------------------
void GRRepeatBegin::updateBoundingBox()
{
	const float halfExtent = GetSymbolExtent(mSymbol) * 0.5f;

	mBoundingBox.top    = 0;
	mBoundingBox.left   = -halfExtent;
	mBoundingBox.right  = halfExtent;
	mBoundingBox.bottom = 4 * LSPACE;

    GRStaff *staff = getGRStaff();

    if (staff)
    {
        fLineNumber = staff->getNumlines();

        int linesOffset = fLineNumber - 5;

        if (linesOffset)
            mPosition.y += staff->getStaffLSPACE() * linesOffset / 2;

        fStaffThickness = staff->getLineThickness();
        fSize = staff->getSizeRatio();
        fBaseThickness = LSPACE * 0.6f * fSize;

        mTagSize *= fSize;
    }
}
Ejemplo n.º 2
0
/** \brief Use tag parameters to calculate the control points position.
*/
void
GRBowing::manualControlPoints( GRBowingContext * bowContext, ARBowing * arBow,
														GRSystemStartEndStruct * sse )
{
	GRBowingSaveStruct * bowInfos = (GRBowingSaveStruct *)sse->p;
	GRStaff * staff = bowContext->staff;

	const float distx = bowInfos->offsets[2].x - bowInfos->offsets[0].x;
	const float disty = bowInfos->offsets[2].y - bowInfos->offsets[0].y;
	const int dir = bowContext->curveDir;

	// -- Get the initial middle control point position.
	// If the R3 factor is near zero, the control point will be near the first anchor point
	// if the R3 factor is near 1, the control point will be near the second anchor point.

	const TagParameterFloat * tagR3 =  arBow->getR3();
	const TYPE_FLOATPARAMETER valueR3 = tagR3 ? tagR3->getValue() : float(0.5);

	bowInfos->offsets[1].x = (GCoord)(distx * valueR3 );
	bowInfos->offsets[1].y = (GCoord)(disty * valueR3 * dir);

	// -- Apply the middle control point y-offset.
	const float staffLSpace = staff->getStaffLSPACE();
	const TagParameterFloat * tagH = arBow->getH();
	const TYPE_FLOATPARAMETER valueH = tagH ? tagH->getValue( staffLSpace ) : float(2);
	bowInfos->offsets[1].y += -dir * ((valueH > 0) ? valueH : -valueH);

	// - Store
	bowInfos->offsets[1] += bowInfos->offsets[0];
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------
NVPoint GRBeam::initp0 (GRSystemStartEndStruct * sse, const GREvent * startEl, PosInfos& infos)
{
	// -- Init point 0 (top left)
	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	const ARBeam * arBeam = getARBeam();

	GRStaff * refStaff;
	NVPoint offset;
	if (startEl)
	{
		st->p[0] = startEl->getStemStartPos();
		if (arBeam && arBeam->isGuidoSpecBeam())
			st->p[0].y = startEl->getPosition().y;
		refStaff = startEl->getGRStaff();
		infos.stemdir = startEl->getStemDirection();
		infos.currentSize = startEl->getSize();
	}
	else {
		st->p[0] = sse->startElement->getPosition();
		infos.currentSize = 1.0f;
		refStaff = sse->startElement->getGRStaff();
	}
	offset = refStaff->getPosition();
	if (tagtype == SYSTEMTAG)
		st->p[0] += offset;
	infos.currentLSPACE = refStaff->getStaffLSPACE();

	st->p[1] = st->p[0];
	
	// -- Adjust point 0
	if (arBeam->dx1 && arBeam->dx1->TagIsSet())
		st->p[0].x += (GCoord)(arBeam->dx1->getValue(infos.currentLSPACE));
	else
	{
		// This depends on the direction, we do not know this yet (do we?)
		if (infos.oneNote)
        {
            double result;
            bool conversionOk = TagParameterFloat::convertValue(2.0f, result, "hs", infos.currentLSPACE);

            if (conversionOk)
                st->p[0].x -= (float)result * infos.currentSize;
		}
	}

	if (arBeam->dy1 && arBeam->dy1->TagIsSet())
		st->p[0].y -= (arBeam->dy1->getValue(infos.currentLSPACE));
	return offset;
}
Ejemplo n.º 4
0
void GRArticulation::placeFermataDown(GREvent * inParent, NVPoint & ioPos)
{
	const int dir = chooseDirection(inParent);
	const bool othersAreUpward = (dir == dirUP);
	
	GRStaff * staff = inParent->getGRStaff();
	const float currLSpace = staff->getStaffLSPACE();
	
	if (othersAreUpward)	//stemsDown
	{
		ioPos.y = (ioPos.y + inParent->getStemLength() <= float(4)*currLSpace) ? 
			float(4.5f)*currLSpace : ioPos.y + (inParent->getStemLength()) + 0.5f*currLSpace; //test placement
	}
	else
	{
		placeAfterNote(inParent, ioPos, false);
	}
}
Ejemplo n.º 5
0
// ----------------------------------------------------------------------------
// 
void GRArticulation::placePizz(GREvent * inParent, NVPoint & ioPos)
{
	const int dir = chooseDirection (inParent);
	const bool upward = (dir == dirUP);

	GRStaff * staff = inParent->getGRStaff();
	const float currLSpace = staff->getStaffLSPACE();
	//const float halfSpace = float(0.5) * currLSpace;

	if( upward )	// if stemsDown
	{
		placeAfterNote( inParent, ioPos, true );
	}
	else	// if stemsUp
	{
		ioPos.y = (ioPos.y >= inParent->getStemLength()) ? -currLSpace : ioPos.y - (inParent->getStemLength()+currLSpace);
	}
}
Ejemplo n.º 6
0
//--------------------------------------------------------------------
NVPoint GRBeam::initp2 (GRSystemStartEndStruct * sse, const GREvent * endEl, PosInfos& infos)
{
	// -- Init point 2 (top right)
	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	const ARBeam * arBeam = getARBeam();

	GRStaff * refStaff;
	NVPoint offset;
	if (endEl) {
		st->p[2] = endEl->getStemEndPos();
		// beam length adjustment - DF sept 15 2009
		st->p[2].x += infos.currentLSPACE/10;
		if (arBeam && arBeam->isGuidoSpecBeam())
			st->p[2].y = endEl->getPosition().y;
		refStaff = endEl->getGRStaff();
	}
	else {
		st->p[2] = sse->endElement->getPosition();
		refStaff = sse->startElement->getGRStaff();
	}	
	offset = refStaff->getPosition();
	if (tagtype == SYSTEMTAG)
		st->p[2] += offset;
	infos.currentLSPACE = refStaff->getStaffLSPACE();

	st->p[3] = st->p[2];

	// -- Adjust point 2
	if (arBeam->dx3)
		st->p[2].x += arBeam->dx3->getValue(infos.currentLSPACE);
	if (arBeam->dy3 && arBeam->dy3->TagIsSet())
		st->p[2].y -= arBeam->dy3->getValue(infos.currentLSPACE);
	else {
		GCoord val = 0;
		if (arBeam->dy1 && arBeam->dy1->TagIsSet())
			val = arBeam->dy1->getValue(infos.currentLSPACE);
		st->p[2].y -= val;
	}
	return offset;
}
Ejemplo n.º 7
0
// -----------------------------------------------------------------------------
void
GRBowing::applyAnchorPointsOffsets( GRBowingContext * bowContext, ARBowing * arBow,
														GRSystemStartEndStruct * sse )
{
	GRBowingSaveStruct * bowInfos = (GRBowingSaveStruct *)sse->p;
	GRStaff * staff = bowContext->staff;

	// -- Applies the offset settings to the start anchor point --
	const float staffLSpace = staff->getStaffLSPACE();
	if( arBow->getDX1())
		bowInfos->offsets[0].x += (arBow->getDX1()->getValue( staffLSpace ));

	if( arBow->getDY1())
		bowInfos->offsets[0].y -= (arBow->getDY1()->getValue( staffLSpace ));

	// -- Applies the offset settings to the end anchor point --
	if( arBow->getDX2())
		bowInfos->offsets[2].x += (arBow->getDX2()->getValue( staffLSpace ));

	if( arBow->getDY2())
		bowInfos->offsets[2].y -= (arBow->getDY2()->getValue( staffLSpace ));
}
Ejemplo n.º 8
0
// ----------------------------------------------------------------------------
void GRArticulation::placeFermataUp( GREvent * inParent, NVPoint & ioPos )
{
	// - Check if the fermata (which is always upward) is on the
	// same side as other articulations (if any)
	const int dir = chooseDirection( inParent );	
	const bool othersAreUpward = (dir == dirUP);

	GRStaff * staff = inParent->getGRStaff();
	const float currLSpace = staff->getStaffLSPACE();
	/*const float halfSpace = float(0.5) * currLSpace;*/

	if( othersAreUpward )	// if stemsDown
	{
		placeAfterNote( inParent, ioPos, true );
	}
	else	// if stemsUp
	{
		ioPos.y = (ioPos.y >= inParent->getStemLength()) ? 0 : ioPos.y - (inParent->getStemLength());
		if (inParent->hasArticulation(kFlagPizz))
			ioPos.y -= (1.5f*currLSpace);
	}
}
Ejemplo n.º 9
0
void GRArticulation::placeAfterNote( GREvent * inParent, NVPoint & ioPos, bool upward )
{
	GRStaff * staff = inParent->getGRStaff();
	const float space = staff->getStaffLSPACE();
	const float halfSpace = float(0.5) * space;

	const int externalFlags = (kFlagAccent | kFlagMarcato | kFlagFermataUp);
	const bool hasExternal = inParent->hasArticulation( externalFlags );

	if( upward )
	{
		// -- Walk from the note through the possible attribute positions 
		// Stop when we've reached our attribute position.

		// - Starts at one space from the note.
		ioPos.y -= space;	
		if(( ioPos.y >= 0 ) && positionIsOnStaffLine( ioPos.y, space ))
			ioPos.y -= halfSpace;
	
		// - If we have internal mixed with externals, don't start deeper
		// than one linespace 
		if( hasExternal && ( ioPos.y > halfSpace ))
			ioPos.y = halfSpace;
	
		// - If we're a staccato or a staccatissimo, we have finished.
		if(( mArticulationFlag & ( kFlagStaccato )) != 0 )
			return;	

		// - Move by one position if we passed an existing staccato or staccatissimo
		if( inParent->hasArticulation( kFlagStaccato ))
			ioPos.y += (ioPos.y > 0) ? -space : -halfSpace;
		
		// - If we're a tenuto, then we have finished.
		if( mArticulationFlag == kFlagTenuto )
			return;	

		// - Move by one position if we passed an existing tenuto
		if( inParent->hasArticulation( kFlagTenuto ))
			ioPos.y += (ioPos.y > 0) ? -space : -halfSpace;

		// - So, we're an outside-staff symbol, force being outside-staff.	
		/*if( ioPos.y > -space )
			ioPos.y = -space;
		else
			ioPos.y -= halfSpace;*/
		if (ioPos.y > -halfSpace)
			ioPos.y = -halfSpace;
		else
			/*ioPos.y -= halfSpace*/; // only if...

		// - If we're a pizzicato then we have finished
		if((mArticulationFlag & (kFlagPizz)) != 0)
			{
				ioPos.y -= halfSpace;
				return;
			}
			
		// - Move by one linespace and a half if we passed an existing pizzicato
		if (inParent->hasArticulation(kFlagPizz))
			ioPos.y -= (1.5f*space);

		// - If we're an Accent or a Marcato, then we have finished.
		if(( mArticulationFlag & (kFlagAccent | kFlagMarcato)) != 0 )
			{
			ioPos.y -= halfSpace;
			return;	
			}

		// - Move by one position if we passed an existing Accent,
		// or by 1.5 positions if we passed an existing Marcato
		if( inParent->hasArticulation( kFlagAccent ))
			ioPos.y -= space; 
		else 
		{
			if( inParent->hasArticulation( kFlagMarcato ))
			ioPos.y -= (space + halfSpace);
			else
			ioPos.y += halfSpace; // it's a fermata : we need one less halfspace
		}
	}
	else
	{
		int linesCount = staff->getNumlines();
		const float bottom = (linesCount - 1) * space;
		
		ioPos.y += space;	
		if(( ioPos.y <= bottom ) && positionIsOnStaffLine( ioPos.y, space ))
			ioPos.y += halfSpace;
	
		// - If we have internal mixed with externals, don't start deeper
		// than one linespace 
		if( hasExternal && ( ioPos.y < ( bottom - halfSpace )))
			ioPos.y = (bottom - halfSpace);
	
		// - If we're a staccato or a staccatissimo, we have finished.
		if(( mArticulationFlag & (kFlagStaccato)) != 0 )
			return;	

		// - Move by one position if we passed an existing staccato or staccatissimo
		if( inParent->hasArticulation( kFlagStaccato ))
			ioPos.y += (ioPos.y < bottom) ? space : halfSpace;
		
		// - If we're a tenuto, then we have finished.
		if( mArticulationFlag == kFlagTenuto )
			return;	

		// - Move by one position if we passed an existing tenuto
		if( inParent->hasArticulation( kFlagTenuto ))
			ioPos.y += (ioPos.y < bottom) ? space : halfSpace;

		// - So, we're an outside-staff symbol, force being outside-staff.	
		if( ioPos.y < ( bottom + halfSpace ))
			ioPos.y = ( bottom + halfSpace );
		else
			/*ioPos.y += space*/; // ?

		// - If we're an Accent or a Marcato, then we have finished.
		if(( mArticulationFlag & (kFlagAccent | kFlagMarcato)) != 0 )
		{
			ioPos.y += halfSpace;
			return;	
		}
		// - Move by one position if we passed an existing Accent,
		// or by 1.5 positions if we passed an existing Marcato
		if( inParent->hasArticulation( kFlagAccent ))
			ioPos.y += (space + halfSpace); 
		else if( inParent->hasArticulation( kFlagMarcato ))
			ioPos.y += 2 * space;
	}
}