/** \brief Low-level symbol drawing. */ void GRNotationElement::DrawSymbol( VGDevice & hdc, unsigned int inSymbol, float inOffsetX, float inOffsetY, float inFontSize ) const { if(!mDraw) return; // - Setup font const VGFont* myfont = FontManager::gFontScriab; const float theSize = (inFontSize != 0) ? inFontSize : getSize(); if (theSize < kMinNoteSize) return; // element is too small, don't draw it if (theSize != float(1.0)) { const int newFontSize = (int)(theSize * 4 * LSPACE + 0.5f ); // +0.5 to round from float to int. myfont = FontManager::FindOrCreateFont( newFontSize ); } // hdc.SelectFont( myfont ); hdc.SetMusicFont( myfont ); // - Setup position const NVPoint & offset = getOffset(); const NVPoint & refpos = getReferencePosition(); const float xPos = mPosition.x + offset.x + (refpos.x * theSize) + inOffsetX; const float yPos = mPosition.y + offset.y + (refpos.y * theSize) + inOffsetY; // - Draw hdc.DrawMusicSymbol( xPos, yPos, inSymbol ); #ifdef SHOWRODS // draw the rods .... const float leftspc = getLeftSpace(); const float rightspc = getRightSpace(); if (leftspc) { const float myposy = 350; hdc.PushPen(VGColor( 0, 0, 200 ), 5 ); // Always blue hdc.Line( mPosition.x-leftspc,myposy-30, mPosition.x-leftspc,myposy+30 ); hdc.Line( mPosition.x-leftspc, myposy, mPosition.x, myposy ); hdc.PopPen(); } if (rightspc) { const float myposy = 350; hdc.PushPen(VGColor( 0, 0, 200 ), 5 ); // Always blue hdc.Line( mPosition.x+rightspc, myposy-30, mPosition.x+rightspc, myposy+30 ); hdc.LineTo( mPosition.x+rightspc, myposy, mPosition.x, myposy ); hdc.PopPen(); } #endif // #ifdef SHOWRODS }
/** 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; }