Beispiel #1
0
/** \brief Sets the scaling of input graphic device context, according to 
		input sizes.
	(was setMapping)
*/
void GRPage::setScaling( VGDevice & hdc, float vsizex, float vsizey ) const
{
	float newScaleX = vsizex;
	float newScaleY = vsizey;
	
	getScaling (newScaleX, newScaleY);
	hdc.SetScale( newScaleX, newScaleY ); // ok
	
//	const float sizex = getPageWidth();	// Get the logical (virtual) size
//	const float sizey = getPageHeight(); //	used internaly by Guido.
//
//	if( sizex <= 0 ) return;
//	if( sizey <= 0 ) return;
//
//	// - Calculate the new device context scaling factors.
//	float newScaleX = vsizex / sizex;
//	float newScaleY = vsizey / sizey;
//	
//	// - Force the page to be proportional. 
//	// (This could be a setting for GuidoSetSetting(): proportionnal or non-proportionnal)
//	if( newScaleX > newScaleY )		newScaleX = newScaleY;
//	if( newScaleY > newScaleX )		newScaleY = newScaleX;
//
//	// - Scale the device context to match desired size & zoom.
//	hdc.SetScale( newScaleX, newScaleY ); // ok
}
Beispiel #2
0
/** Draws the note corresponding to a given symbolic musical duration.
*/
float GRTempo::DrawNote( VGDevice & hdc, const TYPE_DURATION & noteDur, float xOffset, float yOffset ) const
{
	float offsetX = 0;

	// - Choose notehead
	unsigned int theSymbol = kNoneSymbol;
	if (noteDur>=DURATION_1) {
		theSymbol = kWholeNoteHeadSymbol;
	}
	else if (noteDur == DURATION_2 || noteDur == DURATION_3_4 || noteDur == DURATION_7_8) {
   		theSymbol = kHalfNoteHeadSymbol;
	}
	else {
		theSymbol = kFullHeadSymbol;
	}

	// - Choose flag
	unsigned int theFlagSymbol = kNoneSymbol;
	if (noteDur==DURATION_8 ||  noteDur == DURATION_3_16 || noteDur == DURATION_7_32) {
		theFlagSymbol = GRFlag::H8U;
	}
	else if(noteDur==DURATION_16 || noteDur == DURATION_3_32 || noteDur == DURATION_7_64) {
		theFlagSymbol = GRFlag::H16U;
	}
	else if(noteDur == DURATION_32) {
		theFlagSymbol =  GRFlag::H32U;
	}
	else if (noteDur == DURATION_64) {
		theFlagSymbol = GRFlag::H64U;
	}

	// - Choose dot
	unsigned int theDotSymbol = kNoneSymbol;
//	if (noteDur == DURATION_3_4 || noteDur == DURATION_3_8 || noteDur == DURATION_3_16 || noteDur == DURATION_3_32) {
	if (noteDur.getNumerator() == 3) {
		theDotSymbol = kNoteDotSymbol;
	}

	// - Setup zoom
    hdc.selectfont(1); // Not very beautiful but avoid a bug during SVG export
	const float cueScale = 0.70f;
	hdc.SetScale(cueScale, cueScale);

	// - Calculate the position of the head
	float w, h;

	hdc.GetMusicFont()->GetExtent(theSymbol, &w, &h, &hdc);
	float xPos = (xOffset + mPosition.x) / cueScale;
	float yPos = (yOffset + mPosition.y - w / 2.5f) / cueScale;

	// - Draw Head
	hdc.DrawMusicSymbol(xPos, yPos, theSymbol);
	offsetX = w * cueScale;

	// - Draw Stem
	if (theSymbol != kWholeNoteHeadSymbol)
    {
		float		stemLen = 3 * LSPACE;
		float		stemTagSize = 1;

		const float stemCharSize = LSPACE * stemTagSize;
		const float halfStemCharSize = 0.5f * stemCharSize;

		hdc.DrawMusicSymbol( xPos, yPos, kStemUp1Symbol );

		// - Draws until the length has been completed ...
		float offsy = -halfStemCharSize;

		while( -offsy < stemLen ) // * mSize)
		{
			if(( stemCharSize - offsy ) > stemLen ) // * mSize)
			{
				offsy =  (-(stemLen) // * mSize)
					+ stemCharSize );
				hdc.DrawMusicSymbol( xPos, yPos + offsy, kStemUp2Symbol );
				break;
			}
			hdc.DrawMusicSymbol( xPos, yPos + offsy, kStemUp2Symbol );
			offsy -= halfStemCharSize;
		}
	}

	// - Draw flag
	if (theFlagSymbol != kNoneSymbol) hdc.DrawMusicSymbol( xPos, yPos - 4 * LSPACE, theFlagSymbol );

	// - Draw Dot
	if (theDotSymbol != kNoneSymbol)
    {
		hdc.GetMusicFont()->GetExtent(theDotSymbol, &w, &h, &hdc);
		hdc.DrawMusicSymbol( xPos + 2 * LSPACE, yPos, theDotSymbol);
		offsetX += LSPACE;
	}

	// - Cleanup
	hdc.SetScale(1 / cueScale, 1 / cueScale);
	return offsetX;
}