Skip to content

Commit

Permalink
Fix for bug 1931, removed some code parts for Qt<4.3 and some changes…
Browse files Browse the repository at this point in the history
… in svg export (but not yet enough)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11701 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Sep 22, 2009
1 parent d379a90 commit a73f1cf
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -641,6 +641,12 @@ void QgsComposer::on_mActionExportAsImage_triggered()
QgsDebugMsg( QString( "Selected filter: %1" ).arg( myFilterString ) );
QgsDebugMsg( QString( "Image type: %1" ).arg( myFilterMap[myFilterString] ) );

// Add the file type suffix to the fileName if required
if ( !myOutputFileNameQString.endsWith( myFilterMap[myFilterString] ) )
{
myOutputFileNameQString += "." + myFilterMap[myFilterString];
}

myQSettings.setValue( "/UI/lastSaveAsImageFormat", myFilterMap[myFilterString] );
myQSettings.setValue( "/UI/lastSaveAsImageFile", myOutputFileNameQString );

Expand Down Expand Up @@ -687,16 +693,9 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
m->setCheckBoxQSettingsLabel( myQSettingsLabel );
m->setMessageAsHtml( tr( "<p>The SVG export function in Qgis has several "
"problems due to bugs and deficiencies in the " )
#if QT_VERSION < 0x040300
+ tr( "Qt4 svg code. Of note, text does not "
"appear in the SVG file and there are problems "
"with the map bounding box clipping other items "
"such as the legend or scale bar.</p>" )
#else
+ tr( "Qt4 svg code. In particular, there are problems "
"with layers not being clipped to the map "
"bounding box.</p>" )
#endif
+ tr( "If you require a vector-based output file from "
"Qgis it is suggested that you try printing "
"to PostScript if the SVG output is not "
Expand Down Expand Up @@ -724,30 +723,26 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
//mView->setScene(0);//don't redraw the scene on the display while we render
mComposition->setPlotStyle( QgsComposition::Print );

#if QT_VERSION < 0x040300
Q3Picture pic;
QPainter p( &pic );
QRectF renderArea( 0, 0, ( mComposition->paperWidth() * mComposition->scale() ), ( mComposition->paperHeight() * mComposition->scale() ) );
#else
QSvgGenerator generator;
generator.setTitle( QgsProject::instance()->title() );
generator.setFileName( myOutputFileNameQString );
generator.setSize( QSize(( int )mComposition->paperWidth(), ( int )mComposition->paperHeight() ) );
generator.setResolution( 25.4 ); //because the rendering is done in mm, convert the dpi
//width in pixel
int width = ( int )( mComposition->paperWidth() * mComposition->printResolution() / 25.4 );
//height in pixel
int height = ( int )( mComposition->paperHeight() * mComposition->printResolution() / 25.4 );
generator.setSize( QSize( width, height ) );
generator.setResolution( mComposition->printResolution() ); //because the rendering is done in mm, convert the dpi

QPainter p( &generator );
QRectF renderArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
#endif
mComposition->render( &p, renderArea, renderArea );

QRectF sourceArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
QRectF targetArea( 0, 0, width, height );
mComposition->render( &p, targetArea, sourceArea );

p.end();

mComposition->setPlotStyle( QgsComposition::Preview );
//mView->setScene(mComposition->canvas()); //now that we're done, set the view to show the scene again

#if QT_VERSION < 0x040300
QRect br = pic.boundingRect();

pic.save( myOutputFileNameQString, "svg" );
#endif
}

void QgsComposer::on_mActionSelectMoveItem_triggered()
Expand Down

0 comments on commit a73f1cf

Please sign in to comment.