Skip to content

Commit a776092

Browse files
author
mhugent
committed
Use image cache only for the first widthScale (usually screen dpi), not for composer and quickprint. Enabled quickprint again as the map rendering should be ok now, but legend still needs a bit of work
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9546 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fd78469 commit a776092

File tree

4 files changed

+32
-22
lines changed

4 files changed

+32
-22
lines changed

src/core/symbology/qgssymbol.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ QgsSymbol::QgsSymbol( QGis::GeometryType t, QString lvalue, QString uvalue, QStr
4242
mPointSymbolName( "hard:circle" ),
4343
mPointSize( DEFAULT_POINT_SIZE ),
4444
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
45-
mWidthScale( 1.0 ),
45+
mWidthScale( -1.0 ),
4646
mCacheUpToDate( false ),
4747
mCacheUpToDate2( false ),
4848
mRotationClassificationField( -1 ),
@@ -60,7 +60,7 @@ QgsSymbol::QgsSymbol( QGis::GeometryType t, QString lvalue, QString uvalue, QStr
6060
mPointSymbolName( "hard:circle" ),
6161
mPointSize( DEFAULT_POINT_SIZE ),
6262
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
63-
mWidthScale( 1.0 ),
63+
mWidthScale( -1.0 ),
6464
mCacheUpToDate( false ),
6565
mCacheUpToDate2( false ),
6666
mRotationClassificationField( -1 ),
@@ -71,7 +71,7 @@ QgsSymbol::QgsSymbol()
7171
: mPointSymbolName( "hard:circle" ),
7272
mPointSize( DEFAULT_POINT_SIZE ),
7373
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
74-
mWidthScale( 1.0 ),
74+
mWidthScale( -1.0 ),
7575
mCacheUpToDate( false ),
7676
mCacheUpToDate2( false ),
7777
mRotationClassificationField( -1 ),
@@ -85,7 +85,7 @@ QgsSymbol::QgsSymbol( QColor c )
8585
mPointSymbolName( "hard:circle" ),
8686
mPointSize( DEFAULT_POINT_SIZE ),
8787
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
88-
mWidthScale( 1.0 ),
88+
mWidthScale( -1.0 ),
8989
mCacheUpToDate( false ),
9090
mCacheUpToDate2( false ),
9191
mRotationClassificationField( -1 ),
@@ -332,12 +332,14 @@ QImage QgsSymbol::getCachedPointSymbolAsImage( double widthScale,
332332
QImage QgsSymbol::getPointSymbolAsImage( double widthScale, bool selected, QColor selectionColor, double scale,
333333
double rotation, double rasterScaleFactor )
334334
{
335-
//QgsDebugMsg(QString("Symbol scale = %1, and rotation = %2").arg(scale).arg(rotation));
336335
if ( 1.0 == ( scale * rasterScaleFactor ) && 0 == rotation )
337-
{
338-
// If scale is 1.0 and rotation 0.0, use cached image.
339-
return getCachedPointSymbolAsImage( widthScale, selected, selectionColor );
340-
}
336+
{
337+
if(mWidthScale < 0 || widthScale == mWidthScale)
338+
{
339+
// If scale is 1.0 and rotation 0.0, use cached image.
340+
return getCachedPointSymbolAsImage( widthScale, selected, selectionColor );
341+
}
342+
}
341343

342344
QImage preRotateImage;
343345
QPen pen = mPen;

src/core/symbology/qgssymbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class CORE_EXPORT QgsSymbol
166166
/* Point symbol cache */
167167
QImage mPointSymbolImageSelected;
168168

169-
/* Current line width scale used by mPointSymbolVectorImage */
169+
/* Current line width scale used by mPointSymbolVectorImage. Equals -1.0 if not set */
170170
double mWidthScale;
171171

172172
/* Point symbol cache but with line width scale mWidthScale */

src/gui/qgsquickprint.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,25 +340,33 @@ void QgsQuickPrint::printMap()
340340
// properly in the print
341341
int myMapDimensionX = ( myDrawableWidth / 100 ) * myMapHeightPercent;
342342
int myMapDimensionY = ( myDrawableHeight / 100 ) * myMapWidthPercent;
343-
QPixmap myMapPixmap( myMapDimensionX, myMapDimensionY );
344-
myMapPixmap.fill( mMapBackgroundColour );
343+
344+
//QPixmap myMapPixmap( myMapDimensionX, myMapDimensionY );
345+
QImage myMapImage(QSize(myMapDimensionX, myMapDimensionY), QImage::Format_ARGB32);
346+
myMapImage.setDotsPerMeterX((double)(myPrinter.logicalDpiX()) / 25.4 * 1000.0);
347+
myMapImage.setDotsPerMeterY((double)(myPrinter.logicalDpiY()) / 25.4 * 1000.0);
348+
myMapImage.fill(0);
349+
//myMapPixmap.fill( mMapBackgroundColour );
345350
QPainter myMapPainter;
346-
myMapPainter.begin( &myMapPixmap );
351+
//myMapPainter.begin( &myMapPixmap );
352+
myMapPainter.begin(&myMapImage);
347353
// Now resize for print
348-
mpMapRenderer->setOutputSize(
349-
QSize( myMapDimensionX, myMapDimensionY ), myPrinter.resolution() );
350-
scalePointSymbols( mySymbolScalingAmount, ScaleUp );
351-
scaleTextLabels( mySymbolScalingAmount, ScaleUp );
354+
mpMapRenderer->setOutputSize(QSize( myMapDimensionX, myMapDimensionY ), (myPrinter.logicalDpiX() + myPrinter.logicalDpiY()) / 2 );
355+
//scalePointSymbols( mySymbolScalingAmount, ScaleUp );
356+
//scaleTextLabels( mySymbolScalingAmount, ScaleUp );
352357
mpMapRenderer->render( &myMapPainter );
353358

354359
myMapPainter.end();
355360
//draw the map pixmap onto our pdf print device
356361
myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
357362
myOriginY += myVerticalSpacing * 2;
358-
myPrintPainter.drawPixmap(
363+
364+
myPrintPainter.drawImage(myOriginX, myOriginY, myMapImage);
365+
366+
/*myPrintPainter.drawPixmap(
359367
myOriginX,
360368
myOriginY,
361-
myMapPixmap );
369+
myMapPixmap );*/
362370

363371
//
364372
// Draw the legend
@@ -658,8 +666,8 @@ void QgsQuickPrint::printMap()
658666
//
659667

660668
//reinstate the symbols scaling for screen display
661-
scalePointSymbols( mySymbolScalingAmount, ScaleDown );
662-
scaleTextLabels( mySymbolScalingAmount, ScaleDown );
669+
//scalePointSymbols( mySymbolScalingAmount, ScaleDown );
670+
//scaleTextLabels( mySymbolScalingAmount, ScaleDown );
663671

664672

665673
myPrintPainter.end();

src/plugins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ENDIF (GRASS_FOUND)
1818

1919
INSTALL(FILES qgisplugin.h qgsrendererplugin.h DESTINATION ${QGIS_INCLUDE_DIR})
2020

21-
#SUBDIRS (quick_print)
21+
SUBDIRS (quick_print)
2222

2323

2424
SUBDIRS (coordinate_capture dxf2shp_converter)

0 commit comments

Comments
 (0)