示例#1
0
void GRSimpleBeam::OnDraw( VGDevice & hdc ) const
{
	const unsigned char * colref = getColRef();

	if (colref) {
		VGColor color ( colref ); 	// custom or black
		hdc.PushFillColor( color );
		hdc.PushPen( color, 1 );
	}
	float ax [4] = { fPoints[0].x, fPoints[1].x, fPoints[3].x, fPoints[2].x };
	float ay [4] = { fPoints[0].y, fPoints[1].y, fPoints[3].y, fPoints[2].y };


// DF added to check for incorrect coordinates
// makes sure that the right point is not to the left of the left point :-)
// actually this should be checked at coordinates computation time
// todo: check the object that computes the beam coordinates
	if (ax[0] > ax[2]) { ax[2] = ax[0]; }
	if (ax[1] > ax[3]) { ax[3] = ax[1]; }
	
	// This does the drawing!
	hdc.Polygon( ax, ay, 4 );

	// - Cleanup
	if (colref) {
		hdc.PopPen();
		hdc.PopFillColor();
	}
}
示例#2
0
void GRBeam::OnDraw( VGDevice & hdc) const
{
	if (error) return;

	GRSystemStartEndStruct * sse = getSystemStartEndStruct( gCurSystem );
	if (sse == 0) return;

	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	assert(st);

	if (mColRef) {
		VGColor color ( mColRef ); 	// custom or black
		hdc.PushFillColor( color );
		hdc.PushPen( color, 1);
	}
		
	float ax [4] = { st->p[0].x, st->p[1].x, st->p[3].x, st->p[2].x };
	float ay [4] = { st->p[0].y, st->p[1].y, st->p[3].y, st->p[2].y };
	
	// This does the drawing!
	hdc.Polygon( ax, ay, 4 );
	
	if (st->simpleBeams)
	{
		GuidoPos smplpos = st->simpleBeams->GetHeadPosition();
		while (smplpos)
		{
			GRSimpleBeam * smplbeam = st->simpleBeams->GetNext(smplpos);
			smplbeam->OnDraw(hdc);
		}
	}

	if (mColRef) {
		hdc.PopPen();
		hdc.PopFillColor();
	}
}
示例#3
0
void GRCluster::OnDraw(VGDevice &hdc) const
{
    if (mDraw) {
        if (fNoteFormatColor) {
            VGColor color(fNoteFormatColor);
            hdc.PushPen(color, 1);

            if (!mColRef)
                hdc.PushFillColor(color);
        }

    	if (mColRef) {
            VGColor color(mColRef);
            hdc.PushFillColor(color);
            hdc.PushPenColor(color);
        }

    	// - Quarter notes and less
    	if (fDuration < DURATION_2) {
            const float xCoords [] = {
                mMapping.left,
                mMapping.right,
                mMapping.right,
                mMapping.left};
            const float yCoords [] = {
                mMapping.top,
                mMapping.top,
                mMapping.bottom,
                mMapping.bottom};

            hdc.Polygon(xCoords, yCoords, 4);
        }
	    else {
            const float xCoords1 [] = {
                mMapping.left,
                mMapping.right,
                mMapping.right,
                mMapping.left};
            const float yCoords1 [] = {
                mMapping.top,
                mMapping.top,
                mMapping.top + 6 * mTagSize * fsize,
                mMapping.top + 6 * mTagSize * fsize};
            const float xCoords2 [] = {
                mMapping.right - 6 * mTagSize * fsize,
                mMapping.right,
                mMapping.right,
                mMapping.right - 6 * mTagSize * fsize};
            const float yCoords2 [] = {
                mMapping.top,
                mMapping.top,
                mMapping.bottom,
                mMapping.bottom};
            const float xCoords3 [] = {
                mMapping.left,
                mMapping.right,
                mMapping.right,
                mMapping.left};
            const float yCoords3 [] = {
                mMapping.bottom - 6 * mTagSize * fsize,
                mMapping.bottom - 6 * mTagSize * fsize,
                mMapping.bottom,
                mMapping.bottom};
            const float xCoords4 [] = {
                mMapping.left,
                mMapping.left + 6 * mTagSize * fsize,
                mMapping.left + 6 * mTagSize * fsize,
                mMapping.left};
            const float yCoords4 [] = {
                mMapping.top,
                mMapping.top,
                mMapping.bottom,
                mMapping.bottom};

            hdc.Polygon(xCoords1, yCoords1, 4);
            hdc.Polygon(xCoords2, yCoords2, 4);
            hdc.Polygon(xCoords3, yCoords3, 4);
            hdc.Polygon(xCoords4, yCoords4, 4);
        }

	    // - Restore context
	    if (mColRef) {
            hdc.PopPenColor();
		    hdc.PopFillColor();
        }

        if (fNoteFormatColor) {
            if (!mColRef)
                hdc.PopFillColor();

            hdc.PopPen();
        }
	}
}
示例#4
0
/** \brief Draws a slur.

	(JB) experimental modifications to original code

	It takes 3 control points x1,y1,x2,y2,x3,y3 and draws a curv from x1, y1
	through x2,y2 (approximately) to x3, y3.  The thickness of the slur is
	set by SLUR_THICKNESS (1 - 10)
*/
void drawSlur(VGDevice & hdc, float x1, float y1, float x2, float y2,
								float x3, float y3, float inflexion )
{
	float delx1, delx2, ratio;
	float addY2, addX, addY, x2a, y2a, x2b, y2b;
	float maxD;//, h1, h2;

	// if start and endpoint is the same, just don't do anything.
	// this is a hack, whatsoever, because this should not really happen!
	if (x1==x3) return;

	const float oneOverDeltaX = (1.0f / (x3 - x1));

	maxD = (SLUR_THICKNESS * 1.25f);
	ratio = (y3 - y1) * oneOverDeltaX;
	addY2 = (y2 - y1) / 3;
	addX = (x3 - x1) / (2 + inflexion);	// defines the attack of the curve.
	addY = addX * ratio;
	x2a = x2 - addX;
	y2a = y2 - addY + addY2;
	x2b = x2 + addX;
	y2b = y2 - addY + addY2;
//	h1 = (y2a > y1) ? (y2a - y1) : (y1 - y2a);
//	h2 = (y2b > y3) ? (y2b - y3) : (y3 - y2b);
//	if (x2a - x1 > h1) x2a = x1 + h1;
//	if (x3 - x2b > h2) x2b = x3 - h2;
	delx1 = ((y3 - y1) * SLUR_THICKNESS) * oneOverDeltaX;
	delx2 = ((y3 - y1) * SLUR_THICKNESS) * oneOverDeltaX;
	if (delx1 > maxD) delx1 = maxD;
	if (delx2 > maxD) delx2 = maxD;
	if (delx1 < -maxD) delx1 = -maxD;
	if (delx2 < -maxD) delx2 = -maxD;

	const int ptCount = (2 * ( NSEGS + 3 ));

	NVPoint thePoints[ ptCount ]; //ptCount ];

	// CALCULATE THE FIRST CURVE
	// PROBABLY YOU WANT TO START A POLYGON NOW
	int index = 0;
	makeCurve( x1, y1, x2a, y2a, x2b, y2b, x3, y3, NSEGS, thePoints, &index );

	y2a = (y2a < y1 ? y2a + SLUR_THICKNESS : y2a - SLUR_THICKNESS);
	y2b = (y2b < y3 ? y2b + SLUR_THICKNESS : y2b - SLUR_THICKNESS);
	x2a += delx1;
	x2b += delx2;

	// CALCULATE THE SECOND CURVE
	makeCurve( x3, y3, x2b, y2b, x2a, y2a, x1, y1, NSEGS, thePoints, &index );

	//PROBABLY YOU WANT TO CLOSE THE POLYGON NOW AND FILL IT
	float xPoints [ ptCount ];
	float yPoints [ ptCount ];
	for( int currPt = 0; currPt < index; ++ currPt )
	{
		xPoints [ currPt ] = thePoints[ currPt ].x;
		yPoints [ currPt ] = thePoints[ currPt ].y;
	}

	hdc.Polygon( xPoints, yPoints, index );

	/* - DEBUG ->
	hdc.PushPen( GColor( 200, 0, 0 ), 5 );

	hdc.Line( x1 - 20, y1 - 20, x1 + 20, y1 + 20);
	hdc.Line( x1 - 20, y1 + 20, x1 + 20, y1 - 20);

	hdc.PushPen( GColor( 200, 0, 200 ), 5 );
	hdc.Line( x2 - 20, y2 - 20, x2 + 20, y2 + 20);
	hdc.Line( x2 - 20, y2 + 20, x2 + 20, y2 - 20);
	hdc.PopPen();

	hdc.Line( x2a - 20, y2a - 20, x2a + 20, y2a + 20);
	hdc.Line( x2a - 20, y2a + 20, x2a + 20, y2a - 20);

	hdc.Line( x2b - 20, y2b - 20, x2b + 20, y2b + 20);
	hdc.Line( x2b - 20, y2b + 20, x2b + 20, y2b - 20);

	hdc.Line( x3 - 20, y3 - 20, x3 + 20, y3 + 20);
	hdc.Line( x3 - 20, y3 + 20, x3 + 20, y3 - 20);


	hdc.PopPen();
	// <- */
}
示例#5
0
void GRBeam::OnDraw( VGDevice & hdc) const
{
	if (error) return;

	if(!mDraw)
		return;

	GRSystemStartEndStruct * sse = getSystemStartEndStruct( gCurSystem );
	if (sse == 0) return;

	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	assert(st);

	if (mColRef) {
		VGColor color ( mColRef ); 	// custom or black
		hdc.PushFillColor( color );
		hdc.PushPen( color, 1);
	}
		
	float ax [4] = { st->p[0].x, st->p[1].x, st->p[3].x, st->p[2].x };
	float ay [4] = { st->p[0].y, st->p[1].y, st->p[3].y, st->p[2].y };
	
	// This does the drawing!
	hdc.Polygon(ax, ay, 4);
	
	if (st->simpleBeams)
	{
		GuidoPos smplpos = st->simpleBeams->GetHeadPosition();
		while (smplpos)
		{
			GRSimpleBeam * smplbeam = st->simpleBeams->GetNext(smplpos);
			smplbeam->OnDraw(hdc);
		}
	}

	if(drawDur)
	{
		const char * fraction = st->duration.c_str();
		size_t n = st->duration.length();

        hdc.PushPenWidth(4);

		if(sse->startflag != GRSystemStartEndStruct::OPENLEFT)
		{	
			hdc.Line(st->DurationLine[0].x, st->DurationLine[0].y, st->DurationLine[1].x, st->DurationLine[1].y);
			hdc.Line(st->DurationLine[1].x, st->DurationLine[1].y, st->DurationLine[2].x, st->DurationLine[2].y);
			hdc.Line(st->DurationLine[3].x, st->DurationLine[3].y, st->DurationLine[4].x, st->DurationLine[4].y);
		}
		else
			hdc.Line(st->DurationLine[1].x, st->DurationLine[1].y, st->DurationLine[4].x, st->DurationLine[4].y);
		if(sse->endflag != GRSystemStartEndStruct::OPENRIGHT)
			hdc.Line(st->DurationLine[4].x, st->DurationLine[4].y, st->DurationLine[5].x, st->DurationLine[5].y);
		
		const VGFont* hmyfont;
		hmyfont = FontManager::gFontText;
		hdc.SetTextFont( hmyfont );

		if (sse->startflag != GRSystemStartEndStruct::OPENLEFT)
			hdc.DrawString(st->DurationLine[2].x + LSPACE/4, st->DurationLine[2].y + LSPACE / 2, fraction, n);

        hdc.PopPenWidth();
	}

	if (mColRef)
    {
		hdc.PopPen();
		hdc.PopFillColor();
	}

}