Skip to content
Permalink
Browse files
Use image cache only for the first widthScale (usually screen dpi), n…
…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 a776092bebb9a557be80c230d62cc0d1ae5ba8f9
Showing with 32 additions and 22 deletions.
  1. +11 −9 src/core/symbology/qgssymbol.cpp
  2. +1 −1 src/core/symbology/qgssymbol.h
  3. +19 −11 src/gui/qgsquickprint.cpp
  4. +1 −1 src/plugins/CMakeLists.txt
@@ -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 ),
@@ -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 ),
@@ -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 ),
@@ -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 ),
@@ -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;
@@ -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 */
@@ -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
@@ -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();
@@ -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)

0 comments on commit a776092

Please sign in to comment.