//------------------------------------------------------------------------- void QGuidoItemContainer::loadFromMimeData( const QMimeData * mimeData ) { load( mimeData ); if ( mimeData->hasFormat(GMN_CONTAINER_MIME_PROPORTIONAL_ON) ) mIsProportionalOn = mimeData->data( GMN_CONTAINER_MIME_PROPORTIONAL_ON ).toInt(); else mIsProportionalOn = DEFAULT_PROPORTIONAL; if ( mimeData->hasFormat(GMN_CONTAINER_MIME_OPTIMAL_PAGE_FILL_ON) ) mIsOptimalPageFillOn = mimeData->data( GMN_CONTAINER_MIME_OPTIMAL_PAGE_FILL_ON ).toInt(); else mIsOptimalPageFillOn = DEFAULT_OPTIMAL_PAGE_FILL; if ( mimeData->hasFormat(GMN_CONTAINER_MIME_RESIZE_PAGE_ON) ) setResizePageToMusic( mimeData->data( GMN_CONTAINER_MIME_RESIZE_PAGE_ON ).toInt() ); else setResizePageToMusic( DEFAULT_RESIZE_PAGE ); if ( mimeData->hasFormat( GMN_CONTAINER_MIME_SCALE ) ) { float scale = mimeData->data( GMN_CONTAINER_MIME_SCALE ).toDouble(); resize( scale , scale ); } updateLayoutSettings(); mGuidoItem->setGridWidth( mimeData->data( GMN_CONTAINER_MIME_GRID_WIDTH ).toInt() ); mGuidoItem->setGridHeight( mimeData->data( GMN_CONTAINER_MIME_GRID_HEIGHT ).toInt() ); setCurrentPage( mimeData->data( GMN_CONTAINER_MIME_PAGE_INDEX ).toInt() ); }
//------------------------------------------------------------------------- void QGuidoItemContainer::loadFromOtherContainer( const QGuidoItemContainer * otherContainer ) { setResizePageToMusic( otherContainer->mGuidoItem->isResizePageToMusic() ); load( otherContainer ); mIsOptimalPageFillOn = otherContainer->mIsOptimalPageFillOn; mIsProportionalOn = otherContainer->mIsProportionalOn; mGuidoItem->scale( otherContainer->mGuidoItem->transform().m11() , otherContainer->mGuidoItem->transform().m22() ); updateLayoutSettings(); mGuidoItem->setGridWidth(otherContainer->mGuidoItem->gridWidth()); mGuidoItem->setGridHeight(otherContainer->mGuidoItem->gridHeight()); setCurrentPage( otherContainer->mGuidoItem->firstVisiblePage()); }
//void GuidoViewer::export2Image (const File& file, ImageFileFormat* format) int guido2img::convert (guidosession* const currentSession) { ImageFileFormat *format; switch (currentSession->format_) { case GUIDO_WEB_API_PNG : format = new PNGImageFormat (); break; case GUIDO_WEB_API_JPEG : format = new JPEGImageFormat (); break; case GUIDO_WEB_API_GIF : format = new GIFImageFormat (); break; case GUIDO_WEB_API_SVG : assert (false); default : format = new PNGImageFormat (); break; } setGMNCode (currentSession->gmn_.c_str()); setPage (currentSession->page_); setResizePageToMusic (currentSession->resizeToPage_); GuidoPageFormat pagef; currentSession->fillGuidoPageFormatUsingCurrentSettings(&pagef); setGuidoPageFormat(pagef); Image::PixelFormat pf = Image::RGB; if (currentSession->format_ == GUIDO_WEB_API_PNG) pf = Image::ARGB; SoftwareImageType type; Image img (pf, currentSession->width_, currentSession->height_, true, type); Graphics g (img); if (pf == Image::RGB) { g.setColour (Colours::white); g.fillRect (0, 0, currentSession->width_, currentSession->height_); } GuidoComponent::paint(g); format->writeImageToStream (img, fBuffer); delete format; return 0; // need to fix this... }
//------------------------------------------------------------------------- void QGuidoItemContainer::loadFromOtherContainer( const QGuidoItemContainer * otherContainer ) { setResizePageToMusic( otherContainer->mGuidoItem->isResizePageToMusicOn() ); load( otherContainer ); mIsOptimalPageFillOn = otherContainer->mIsOptimalPageFillOn; mIsProportionalRenderingOn = otherContainer->mIsProportionalRenderingOn; float xs = otherContainer->mGuidoItem->transform().m11(); float ys = otherContainer->mGuidoItem->transform().m22(); float newscale = (xs > ys ? xs : ys) * mGuidoItem->scale(); mGuidoItem->setScale( newscale ); // mGuidoItem->scale( otherContainer->mGuidoItem->transform().m11() , otherContainer->mGuidoItem->transform().m22() ); // mGuidoItem->setTransform(QTransform::fromScale(xs, ys), true); updateLayoutSettings(); mGuidoItem->setGridWidth(otherContainer->mGuidoItem->gridWidth()); mGuidoItem->setGridHeight(otherContainer->mGuidoItem->gridHeight()); setCurrentPage( otherContainer->mGuidoItem->firstVisiblePage()); }
//------------------------------------------------------------------------- void QGuidoItemContainer::loadFromDomElement( const QDomElement * e) { if ( e->tagName() != DOM_LANGUAGE_ITEM ) return; mIsProportionalOn = QVariant( e->attribute( DOM_GUIDO_ITEM_PROPORTIONAL_LAYOUT, "#DEFAULT_PROPORTIONAL" ) ).toBool(); mIsOptimalPageFillOn = QVariant( e->attribute( DOM_GUIDO_ITEM_OPTIMAL_PAGE_FILL, "#DEFAULT_OPTIMAL_PAGE_FILL" ) ).toBool(); setResizePageToMusic( QVariant( e->attribute( DOM_GUIDO_ITEM_RESIZE_PAGE_ON, "#DEFAULT_RESIZE_PAGE" ) ).toBool() ); load( e ); float scale = QVariant( e->attribute( DOM_GUIDO_ITEM_SCALE, "1" ) ).toDouble(); resize( scale , scale ); updateLayoutSettings(); int currentPage = QVariant( e->attribute( DOM_GUIDO_ITEM_CURRENT_PAGE, "1" ) ).toInt(); int gridWidth = QVariant( e->attribute( DOM_GUIDO_ITEM_GRID_WIDTH, "1" ) ).toInt(); int gridHeight = QVariant( e->attribute( DOM_GUIDO_ITEM_GRID_HEIGHT, "1" ) ).toInt(); mGuidoItem->setGridWidth(gridWidth); mGuidoItem->setGridHeight(gridHeight); setCurrentPage( currentPage ); }
//------------------------------------------------------------------------- void QGuidoItemContainer::switchResizePage() { setResizePageToMusic( !mGuidoItem->isResizePageToMusic() ); }