Skip to content

Commit

Permalink
Use image cache only for the first widthScale (usually screen dpi), n…
Browse files Browse the repository at this point in the history
…ot 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
  • Loading branch information
mhugent committed Oct 25, 2008
1 parent fd78469 commit a776092
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
20 changes: 11 additions & 9 deletions src/core/symbology/qgssymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ QgsSymbol::QgsSymbol( QGis::GeometryType t, QString lvalue, QString uvalue, QStr
mPointSymbolName( "hard:circle" ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
mWidthScale( 1.0 ),
mWidthScale( -1.0 ),
mCacheUpToDate( false ),
mCacheUpToDate2( false ),
mRotationClassificationField( -1 ),
Expand All @@ -60,7 +60,7 @@ QgsSymbol::QgsSymbol( QGis::GeometryType t, QString lvalue, QString uvalue, QStr
mPointSymbolName( "hard:circle" ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
mWidthScale( 1.0 ),
mWidthScale( -1.0 ),
mCacheUpToDate( false ),
mCacheUpToDate2( false ),
mRotationClassificationField( -1 ),
Expand All @@ -71,7 +71,7 @@ QgsSymbol::QgsSymbol()
: mPointSymbolName( "hard:circle" ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
mWidthScale( 1.0 ),
mWidthScale( -1.0 ),
mCacheUpToDate( false ),
mCacheUpToDate2( false ),
mRotationClassificationField( -1 ),
Expand All @@ -85,7 +85,7 @@ QgsSymbol::QgsSymbol( QColor c )
mPointSymbolName( "hard:circle" ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage( 1, 1, QImage::Format_ARGB32_Premultiplied ),
mWidthScale( 1.0 ),
mWidthScale( -1.0 ),
mCacheUpToDate( false ),
mCacheUpToDate2( false ),
mRotationClassificationField( -1 ),
Expand Down Expand Up @@ -332,12 +332,14 @@ QImage QgsSymbol::getCachedPointSymbolAsImage( double widthScale,
QImage QgsSymbol::getPointSymbolAsImage( double widthScale, bool selected, QColor selectionColor, double scale,
double rotation, double rasterScaleFactor )
{
//QgsDebugMsg(QString("Symbol scale = %1, and rotation = %2").arg(scale).arg(rotation));
if ( 1.0 == ( scale * rasterScaleFactor ) && 0 == rotation )
{
// If scale is 1.0 and rotation 0.0, use cached image.
return getCachedPointSymbolAsImage( widthScale, selected, selectionColor );
}
{
if(mWidthScale < 0 || widthScale == mWidthScale)
{
// If scale is 1.0 and rotation 0.0, use cached image.
return getCachedPointSymbolAsImage( widthScale, selected, selectionColor );
}
}

QImage preRotateImage;
QPen pen = mPen;
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgssymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class CORE_EXPORT QgsSymbol
/* Point symbol cache */
QImage mPointSymbolImageSelected;

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

/* Point symbol cache but with line width scale mWidthScale */
Expand Down
30 changes: 19 additions & 11 deletions src/gui/qgsquickprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,25 +340,33 @@ void QgsQuickPrint::printMap()
// properly in the print
int myMapDimensionX = ( myDrawableWidth / 100 ) * myMapHeightPercent;
int myMapDimensionY = ( myDrawableHeight / 100 ) * myMapWidthPercent;
QPixmap myMapPixmap( myMapDimensionX, myMapDimensionY );
myMapPixmap.fill( mMapBackgroundColour );

//QPixmap myMapPixmap( myMapDimensionX, myMapDimensionY );
QImage myMapImage(QSize(myMapDimensionX, myMapDimensionY), QImage::Format_ARGB32);
myMapImage.setDotsPerMeterX((double)(myPrinter.logicalDpiX()) / 25.4 * 1000.0);
myMapImage.setDotsPerMeterY((double)(myPrinter.logicalDpiY()) / 25.4 * 1000.0);
myMapImage.fill(0);
//myMapPixmap.fill( mMapBackgroundColour );
QPainter myMapPainter;
myMapPainter.begin( &myMapPixmap );
//myMapPainter.begin( &myMapPixmap );
myMapPainter.begin(&myMapImage);
// Now resize for print
mpMapRenderer->setOutputSize(
QSize( myMapDimensionX, myMapDimensionY ), myPrinter.resolution() );
scalePointSymbols( mySymbolScalingAmount, ScaleUp );
scaleTextLabels( mySymbolScalingAmount, ScaleUp );
mpMapRenderer->setOutputSize(QSize( myMapDimensionX, myMapDimensionY ), (myPrinter.logicalDpiX() + myPrinter.logicalDpiY()) / 2 );
//scalePointSymbols( mySymbolScalingAmount, ScaleUp );
//scaleTextLabels( mySymbolScalingAmount, ScaleUp );
mpMapRenderer->render( &myMapPainter );

myMapPainter.end();
//draw the map pixmap onto our pdf print device
myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
myOriginY += myVerticalSpacing * 2;
myPrintPainter.drawPixmap(

myPrintPainter.drawImage(myOriginX, myOriginY, myMapImage);

/*myPrintPainter.drawPixmap(
myOriginX,
myOriginY,
myMapPixmap );
myMapPixmap );*/

//
// Draw the legend
Expand Down Expand Up @@ -658,8 +666,8 @@ void QgsQuickPrint::printMap()
//

//reinstate the symbols scaling for screen display
scalePointSymbols( mySymbolScalingAmount, ScaleDown );
scaleTextLabels( mySymbolScalingAmount, ScaleDown );
//scalePointSymbols( mySymbolScalingAmount, ScaleDown );
//scaleTextLabels( mySymbolScalingAmount, ScaleDown );


myPrintPainter.end();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ENDIF (GRASS_FOUND)

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

#SUBDIRS (quick_print)
SUBDIRS (quick_print)


SUBDIRS (coordinate_capture dxf2shp_converter)
Expand Down

0 comments on commit a776092

Please sign in to comment.