[QGIS Commit] r11701 - trunk/qgis/src/app/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Sep 22 11:07:27 EDT 2009
Author: mhugent
Date: 2009-09-22 11:07:25 -0400 (Tue, 22 Sep 2009)
New Revision: 11701
Modified:
trunk/qgis/src/app/composer/qgscomposer.cpp
Log:
Fix for bug 1931, removed some code parts for Qt<4.3 and some changes in svg export (but not yet enough)
Modified: trunk/qgis/src/app/composer/qgscomposer.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.cpp 2009-09-22 14:02:13 UTC (rev 11700)
+++ trunk/qgis/src/app/composer/qgscomposer.cpp 2009-09-22 15:07:25 UTC (rev 11701)
@@ -641,6 +641,12 @@
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 );
@@ -687,16 +693,9 @@
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 "
@@ -724,30 +723,26 @@
//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()
More information about the QGIS-commit
mailing list