示例#1
0
void GRCrescendo::OnDraw( VGDevice & hdc) const
{
	if (!mDraw)
		return;

    if (fCrescInfos->points[0].x == fCrescInfos->points[1].x)
        return;

    assert(gCurSystem);

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

    const VGColor prevTextColor = hdc.GetFontColor();

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

    hdc.PushPenWidth(fCrescInfos->thickness);

    hdc.Line(fCrescInfos->points[0].x , fCrescInfos->points[0].y, fCrescInfos->points[1].x , fCrescInfos->points[1].y);
	hdc.Line(fCrescInfos->points[0].x , fCrescInfos->points[0].y, fCrescInfos->points[2].x , fCrescInfos->points[2].y);

    const float xMarkingOffset = fCrescInfos->points[1].x + 30;
    const float yMarkingOffset = fCrescInfos->points[0].y - 277 + (mTagSize - 1) * 25;

    if (fCrescInfos->fMarkingSymbol != 0)
        OnDrawSymbol(hdc, fCrescInfos->fMarkingSymbol, xMarkingOffset, yMarkingOffset, mTagSize);
    
    hdc.PopPenWidth();

    if (mColRef) {
        hdc.SetFontColor(prevTextColor);
        hdc.PopFillColor();
        hdc.PopPenColor();
    }
}
示例#2
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();
        }
	}
}
示例#3
0
// ----------------------------------------------------------------------------
void GRTuplet::OnDraw(VGDevice & hdc) const
{ 
	if(!mDraw)
		return;

	assert(gCurSystem);
	GRSystemStartEndStruct * sse = getSystemStartEndStruct(gCurSystem);

	if (sse == 0)
		return;

    VGColor prevFontColor = hdc.GetFontColor();

    if (mColRef) {
        hdc.SetFontColor(VGColor(mColRef));
        hdc.PushPenColor(VGColor(mColRef));
    }

	GRTupletSaveStruct * st = (GRTupletSaveStruct *)sse->p;	

	const ARTuplet * arTuplet = getARTuplet();

	int charCount = 0;

    float const thickness = arTuplet->getThickness();
    float const dxOffset  = (arTuplet->getDX() ? arTuplet->getDX()->getValue() : 0);

	// - Draws the number
	const int numerator = arTuplet->getNumerator();

	if (numerator > 0) {
		std::stringstream bufferNumeratorDenominatorStream;
        
		const int denominator = arTuplet->getDenominator(); 
		if (denominator > 0)
			bufferNumeratorDenominatorStream << numerator << ":" << denominator;
		else
			bufferNumeratorDenominatorStream << numerator;
	
        std::string bufferNumeratorDenominator = bufferNumeratorDenominatorStream.str();
        charCount = bufferNumeratorDenominator.size();

        const VGFont *font = 0;
        const NVstring fontName("Times New Roman");
        NVstring attrs;

        if (arTuplet->isTextBold())
            attrs = "b";

        font = FontManager::FindOrCreateFont(int(80 * arTuplet->getTextSize()), &fontName, &attrs);
        hdc.SetTextFont(font);

        /* In order that numerator/denominator stays at the same vertical position even if size is changed */
        float extentCharNumeratorDenominatorx;
        float extentCharNumeratorDenominatory;
        FontManager::gFontScriab->GetExtent(bufferNumeratorDenominator.c_str(), bufferNumeratorDenominator.size(), &extentCharNumeratorDenominatorx, &extentCharNumeratorDenominatory, &hdc);

        int offset = int(extentCharNumeratorDenominatory / 11.2 * arTuplet->getTextSize() - 40);
        /***************************************************************************************************/

		hdc.SetFontAlign(VGDevice::kAlignCenter | VGDevice::kAlignBottom);
        hdc.DrawString(st->textpos.x + dxOffset, st->textpos.y + offset, bufferNumeratorDenominator.c_str(), charCount);
	}

	// - Draws the braces
	const float middleX = (st->p1.x + st->p2.x) * 0.5f;
	const float middleY = (st->p1.y + st->p2.y) * 0.5f;
	const float slope = (st->p2.y - st->p1.y) / (st->p2.x - st->p1.x); //<- could be stored
    const float textSpace = ((float)charCount + float(0.5)) * LSPACE * float(0.5) * arTuplet->getTextSize();

	if (mShowLeftBrace | mShowRightBrace) {
		hdc.PushPenWidth(thickness);
		
		if (mShowLeftBrace) { //arTuplet->getLeftBrace()) // (mBraceState & BRACELEFT)
            float p1X = st->p1.x + dxOffset;

			if (sse->startflag == GRSystemStartEndStruct::LEFTMOST) {
				GDirection d = mDirection;
				// If a position is explicitely set, we use it.
				if (arTuplet->isPositionAbove() == 1) d = dirUP;
				else if (arTuplet->isPositionAbove() == -1) d = dirDOWN;
				hdc.Line(p1X, st->p1.y + 0.5f * LSPACE * (float)d, p1X, st->p1.y);
            }

			hdc.Line(p1X, st->p1.y, middleX - textSpace + dxOffset, middleY - slope * textSpace );
		}

		if (mShowRightBrace) { //arTuplet->getRightBrace()) // (mBraceState & BRACERIGHT)
            float p2X = st->p2.x + dxOffset;

			hdc.Line(middleX + textSpace + dxOffset, middleY + slope * textSpace, p2X, st->p2.y);

			if (sse->endflag == GRSystemStartEndStruct::RIGHTMOST) {
				GDirection d = mDirection;
				// If a position is explicitely set, we use it.
				if (arTuplet->isPositionAbove() == 1) d = dirUP;
				else if (arTuplet->isPositionAbove() == -1) d = dirDOWN;
				hdc.Line(p2X, st->p2.y, p2X, st->p2.y + 0.5f * LSPACE * (float)d);
            }
		}

		hdc.PopPenWidth();
	}

    if (mColRef) {
        hdc.SetFontColor(prevFontColor);
        hdc.PopPenColor();
    }
}