[QGIS Commit] r12186 - trunk/qgis/src/core/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Nov 19 06:19:33 EST 2009
Author: mhugent
Date: 2009-11-19 06:19:32 -0500 (Thu, 19 Nov 2009)
New Revision: 12186
Modified:
trunk/qgis/src/core/composer/qgscomposerpicture.cpp
trunk/qgis/src/core/composer/qgscomposerpicture.h
Log:
Better preview for composer picture
Modified: trunk/qgis/src/core/composer/qgscomposerpicture.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerpicture.cpp 2009-11-19 10:55:58 UTC (rev 12185)
+++ trunk/qgis/src/core/composer/qgscomposerpicture.cpp 2009-11-19 11:19:32 UTC (rev 12186)
@@ -26,12 +26,13 @@
#include <QPainter>
#include <QSvgRenderer>
+
QgsComposerPicture::QgsComposerPicture( QgsComposition *composition ): QgsComposerItem( composition ), mMode( Unknown ), \
- mSvgCacheUpToDate( false ), mCachedDpi( 0 ), mCachedRotation( 0 ), mRotationMap( 0 )
+ mSvgCacheUpToDate( false ), mCachedDpi( 0 ), mCachedRotation( 0 ), mCachedViewScaleFactor( -1 ), mRotationMap( 0 )
{
}
-QgsComposerPicture::QgsComposerPicture(): QgsComposerItem( 0 ), mMode( Unknown ), mSvgCacheUpToDate( false ), mCachedRotation( 0 ), mRotationMap( 0 )
+QgsComposerPicture::QgsComposerPicture(): QgsComposerItem( 0 ), mMode( Unknown ), mSvgCacheUpToDate( false ), mCachedRotation( 0 ), mCachedViewScaleFactor( -1 ), mRotationMap( 0 )
{
}
@@ -51,7 +52,9 @@
drawBackground( painter );
int newDpi = ( painter->device()->logicalDpiX() + painter->device()->logicalDpiY() ) / 2;
- if ( newDpi != mCachedDpi || mCachedRotation != mRotation )
+ double viewScaleFactor = horizontalViewScaleFactor();
+
+ if ( newDpi != mCachedDpi || mCachedRotation != mRotation || mCachedViewScaleFactor != viewScaleFactor )
{
mSvgCacheUpToDate = false;
}
@@ -82,6 +85,12 @@
{
if ( !mSvgCacheUpToDate )
{
+ //make nicer preview
+ if ( mComposition && mComposition->plotStyle() == QgsComposition::Preview )
+ {
+ rotatedBoundImageWidth *= std::min( viewScaleFactor, 10.0 );
+ rotatedBoundImageHeight *= std::min( viewScaleFactor, 10.0 );
+ }
mImage = QImage( rotatedBoundImageWidth, rotatedBoundImageHeight, QImage::Format_ARGB32 );
updateImageFromSvg();
}
@@ -91,6 +100,12 @@
painter->translate( boundRectWidthMM / 2.0, boundRectHeightMM / 2.0 );
painter->rotate( mRotation );
painter->translate( -rotatedBoundImageWidthMM / 2.0, -rotatedBoundImageHeightMM / 2.0 );
+
+ /*if ( mComposition && mComposition->plotStyle() == QgsComposition::Preview )
+ {
+ rotatedBoundImageWidthMM /= std::min( viewScaleFactor, 10.0 );
+ rotatedBoundImageHeightMM /= std::min( viewScaleFactor, 10.0 );
+ }*/
painter->drawImage( QRectF( 0, 0, rotatedBoundImageWidthMM, rotatedBoundImageHeightMM ), mImage, QRectF( 0, 0, mImage.width(), mImage.height() ) );
painter->restore();
@@ -98,6 +113,7 @@
mCachedDpi = newDpi;
mCachedRotation = mRotation;
+ mCachedViewScaleFactor = viewScaleFactor;
//frame and selection boxes
drawFrame( painter );
Modified: trunk/qgis/src/core/composer/qgscomposerpicture.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerpicture.h 2009-11-19 10:55:58 UTC (rev 12185)
+++ trunk/qgis/src/core/composer/qgscomposerpicture.h 2009-11-19 11:19:32 UTC (rev 12186)
@@ -89,6 +89,8 @@
bool mSvgCacheUpToDate;
int mCachedDpi; //store dpis for which the svg cache is valid
double mCachedRotation; //store last rotation value to generate new pixmap from svg on change
+ double mCachedViewScaleFactor;
+
QSize mDefaultSvgSize;
/**Map that sets the rotation (or 0 if this picture uses map independent rotation)*/
const QgsComposerMap* mRotationMap;
More information about the QGIS-commit
mailing list