//------------------------------------------------------------------------- bool QGuidoPainter::setGMNData( const QString& dataSource , GuidoParseFunction parseFunction ) { // Read the gmnCode and build the score's Abstract Representation, // containing all the notes, rests, staffs, lyrics ... ARHandler arh; GRHandler grh; mLastErr = parseFunction( dataSource.toAscii().data(), &arh ); if ( mLastErr != guidoNoErr ) return false; // Build a new score Graphic Representation according the score's Abstract Representation. GuidoPageFormat currentFormat; GuidoGetDefaultPageFormat ( ¤tFormat ); GuidoSetDefaultPageFormat( &mPageFormat ); mLastErr = GuidoAR2GR (arh, &mLayoutSettings , &grh); GuidoSetDefaultPageFormat( ¤tFormat ); if (mLastErr == guidoNoErr) { GuidoFreeGR( mDesc.handle ); mDesc.handle = grh; GuidoFreeAR( mARHandler ); mARHandler = arh; if ( mResizePageToMusic ) mLastErr = GuidoResizePageToMusic( mDesc.handle ); } return (mLastErr == guidoNoErr); }
//------------------------------------------------------------------------- void QGuidoPainter::setARHandler( ARHandler ar ) { if (!ar) return; if (mDesc.handle) GuidoFreeGR( mDesc.handle ); if (mARHandler) GuidoFreeAR( mARHandler ); // Build a new score Graphic Representation according the score's Abstract Representation. mARHandler = ar; mGMNCode = ""; GuidoPageFormat currentFormat; GuidoGetDefaultPageFormat ( ¤tFormat ); GuidoSetDefaultPageFormat( &mPageFormat ); GuidoAR2GR (mARHandler, &mLayoutSettings , &mDesc.handle); GuidoSetDefaultPageFormat( ¤tFormat ); if ( mResizePageToMusic ) mLastErr = GuidoResizePageToMusic( mDesc.handle ); }
ofxGuido::ofxGuido(int w, int h) : mARHandler(0), mGRHandler(0), mW(w), mH(h), mBackground(){ mGuidoDevice = mGuidoSystem.CreateMemoryDevice(w, h); mGuidoDevice->SelectFillColor(VGColor(0, 0, 0)); mGuidoInitDesc.graphicDevice = mGuidoDevice; mGuidoInitDesc.musicFont = "guido2t.ttf"; mGuidoInitDesc.textFont = "guidotext.ttf"; GuidoInit(&mGuidoInitDesc); GuidoGetDefaultLayoutSettings(&mGuidoLayoutSettings); mGuidoOnDrawDesc.hdc = mGuidoDevice; mGuidoParser = GuidoOpenParser(); // Setup a large default format to avoid system breaks. They can also be avoided // by using the GMN advanced tag \set<autoSystemBreak="off"> // Extra right margin makes room for the systems brace. GuidoPageFormat gpf = { 5000, 5000, 150, 100, 100, 100 }; // w, h, ml, mt, mr, mb GuidoSetDefaultPageFormat(&gpf); mBackground.set(0, 0, 0, 0); }