コード例 #1
0
ファイル: GRDoubleBar.cpp プロジェクト: iloveican/AscoGraph
// --------------------------------------------------------------------------
void GRDoubleBar::DrawWithLines( VGDevice & hdc ) const
{
	if ((getTagType() != GRTag::SYSTEMTAG) && isSystemSlice())
		return;			// don't draw staff bars on system slices
    
    if (fSize < kMinNoteSize) // Too small, don't draw
        return;

    // - Vertical adjustement according to staff's line number
    float offsety1 = (fmod(- 0.5f * fLineNumber - 2, 3) + 1.5f) * LSPACE;
    float offsety2 = 0;

    if (fLineNumber != 0 && fLineNumber != 1)
        offsety2 = ((fLineNumber - 5) % 6) * LSPACE;

    // - Horizontal adjustement according to staff's lines size and staff's size
    const float offsetX = (fStaffThickness - 4) * 0.5f - 24;

    const float spacing = LSPACE * 0.7f * fSize;
	const float x1 = mPosition.x + offsetX;
	const float x2 = x1 + spacing;
	const float y1 = mPosition.y + mBoundingBox.top + offsety1 * fSize;
	const float y2 = y1 + mBoundingBox.bottom + offsety2 * fSize;

    float lineThickness = kLineThick * 1.5f * fSize;

    hdc.PushPenWidth(lineThickness);
    hdc.Line(x1, y1 + lineThickness / 2, x1, y2 - lineThickness / 2);
    hdc.Line(x2, y1 + lineThickness / 2, x2, y2 - lineThickness / 2);
    hdc.PopPenWidth();
}
コード例 #2
0
ファイル: GRBar.cpp プロジェクト: iloveican/AscoGraph
// --------------------------------------------------------------------------
void GRBar::DrawWithLines( VGDevice & hdc ) const
{
	if ((getTagType() != GRTag::SYSTEMTAG) && isSystemSlice())
		return;			// don't draw staff bars on system slices

    const float staffSize = mGrStaff->getSizeRatio();

    if (staffSize < kMinNoteSize) // Too small, don't draw
        return;

    // - Vertical adjustement according to staff's line number
    float offsety1 = (fmod(- 0.5f * fLineNumber - 2, 3) + 1.5f) * LSPACE;
    float offsety2 = 0;

    if (fLineNumber != 0 && fLineNumber != 1)
        offsety2 = ((fLineNumber - 5) % 6) * LSPACE;

    const float offsetX = 3 + (staffSize - 1) * 2;

    const float x = mPosition.x + offsetX;
	const float y1 = mPosition.y + mBoundingBox.top + offsety1 * staffSize;
	const float y2 = y1 + mBoundingBox.bottom + offsety2 * staffSize;

    hdc.PushPenWidth( mGrStaff ? mGrStaff->currentLineThikness() * staffSize : kLineThick * staffSize );
    hdc.Line(x, y1, x, y2);
    hdc.PopPenWidth();
}
コード例 #3
0
ファイル: GRCrescendo.cpp プロジェクト: anttirt/guidolib
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();
    }
}
コード例 #4
0
ファイル: GRBeam.cpp プロジェクト: anttirt/guidolib
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();
	}

}
コード例 #5
0
ファイル: GRTuplet.cpp プロジェクト: anttirt/guidolib
// ----------------------------------------------------------------------------
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();
    }
}