Example #1
0
void ofxGuido::loadString(const char * s){
	ARHandler arh = GuidoString2AR(mGuidoParser, s);
	int l, c;
	const char * errstr;
	GuidoErrCode err = GuidoParserGetErrorCode(mGuidoParser, l, c, &errstr);
	if(err != guidoNoErr){
		GuidoFreeAR(arh);
		ofLogError("ofxGuido") << "GuidoParser error: " << errstr;
	}
	else{
		GRHandler grh;
		err = GuidoAR2GR(arh, &mGuidoLayoutSettings, &grh);
		if(err == guidoNoErr){
			if(mGRHandler){
				GuidoFreeGR(mGRHandler);
			}
			mGRHandler = grh;
			mARHandler = arh;
			GuidoResizePageToMusic(mGRHandler);
			mGuidoOnDrawDesc.handle = mGRHandler;
		}
		else{
			errstr = GuidoGetErrorString(err);
			ofLogError("ofxGuido") << "GuidoAR2GR error: " << errstr;
			GuidoFreeAR(arh);
		}
	}
}
Example #2
0
//----------------------------------------------------------------------------
void Guido2Image::writeImage( QGuidoPainter * guidoPainter, Guido2ImageImageFormat imageFormat, int pageIndex, const QSize& outputSizeConstraint, float zoom, const char * imageFileName )
{
	if (imageFormat == GUIDO_2_IMAGE_SVG) {
		std::string outname = imageFileName;
		outname += '.';
		outname += imageFormatToStr(imageFormat);
		std::fstream out(outname.c_str(), std::fstream::out | std::fstream::trunc);
		GuidoErrCode err = GuidoSVGExport (guidoPainter->getGRHandler(), pageIndex+1, out, 0);
		if (err != guidoNoErr)
			std::cerr << "Error writing SVG file: " << GuidoGetErrorString (err) << std::endl;
		return;
	}

	QRectF pictureRect = Guido2Image::getPictureRect( guidoPainter , pageIndex, outputSizeConstraint , zoom );
	
	QPaintDevice * paintDevice = Guido2Image::getPaintDevice( pictureRect );
	
	QPainter painter(paintDevice);
	painter.setRenderHint( QPainter::Antialiasing );
	
	if ( pageIndex )
		guidoPainter->draw(&painter,pageIndex,pictureRect.toRect());
	else
	{
		int pageCoordinateIncrement = 0;
		for (int page = 1 ; page <= guidoPainter->pageCount() ; page++ )
		{
			int pageIncrementedDimension;
			int x, y, width, height;
			QSizeF pageSize = guidoPainter->pageSizeMM(page) * zoom;
//			if ( PAGES_ALIGNMENT == QGuidoMPageItem::Horizontal )
			if ( true )
			{
				pageIncrementedDimension = pageSize.width();
				width = pageIncrementedDimension;
				height = pictureRect.height();
				x = pageCoordinateIncrement;
				y = 0;
			}
			else
			{
				pageIncrementedDimension = pageSize.height();
				height = pageIncrementedDimension;
				width = pictureRect.width();
				y = pageCoordinateIncrement;
				x = 0;
			}
			QRect pageRect( x , y , width , height );
			guidoPainter->draw( &painter , page , pageRect , QRect() );
			pageCoordinateIncrement += pageIncrementedDimension;
		}
	}

	painter.end();
	
	Guido2Image::finalizePaintDevice(paintDevice , imageFileName , imageFormat);
	
	delete paintDevice;
}
Example #3
0
//-------------------------------------------------------------------------
QString QGuidoPainter::getLastErrorMessage() const
{
	QString result = QString( GuidoGetErrorString(mLastErr) );
	if ( mLastErr == guidoErrParse )
	{
		int line = GuidoGetParseErrorLine();
		result += " (line " + QVariant(line).toString() + ")";
	}
	return result;

}
Example #4
0
/*
 * Class:     guidoengine_guido
 * Method:    GetErrorString
 * Signature: (I)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_guidoengine_guido_GetErrorString (JNIEnv * env, jclass, jint errcode)
{
	const char* str = GuidoGetErrorString( (GuidoErrCode)errcode );
	return env->NewStringUTF(str);
}