Skip to content
Permalink
Browse files
Show marker sizes and line widths in composer in proportion to the page
  • Loading branch information
mhugent committed Dec 8, 2011
1 parent 06bda9c commit 365c33d01388522957b056b12ba2bd6110190116
Showing with 23 additions and 7 deletions.
  1. +12 −3 src/core/composer/qgscomposermap.cpp
  2. +1 −1 src/core/composer/qgscomposermap.h
  3. +9 −2 src/core/qgsmaprenderer.cpp
  4. +1 −1 src/core/qgsmaprenderer.h
@@ -117,7 +117,7 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const

/* This function is called by paint() and cache() to render the map. It does not override any functions
from QGraphicsItem. */
void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const QSizeF& size, double dpi )
void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const QSizeF& size, double dpi, double* forceWidthScale )
{
if ( !painter )
{
@@ -174,7 +174,14 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
bool bkLayerCaching = s.value( "/qgis/enable_render_caching", false ).toBool();
s.setValue( "/qgis/enable_render_caching", false );

theMapRenderer.render( painter );
if ( forceWidthScale ) //force wysiwyg line widths / marker sizes
{
theMapRenderer.render( painter, forceWidthScale );
}
else
{
theMapRenderer.render( painter );
}
s.setValue( "/qgis/enable_render_caching", bkLayerCaching );

theMapRenderer.setScale( bk_scale );
@@ -217,6 +224,8 @@ void QgsComposerMap::cache( void )
h = 5000;
}

double forcedWidthScaleFactor = w / requestExtent.width() / mapUnitsToMM();

mCacheImage = QImage( w, h, QImage::Format_ARGB32 );
mCacheImage.fill( brush().color().rgb() ); //consider the item background brush
double mapUnitsPerPixel = mExtent.width() / w;
@@ -226,7 +235,7 @@ void QgsComposerMap::cache( void )

QPainter p( &mCacheImage );

draw( &p, requestExtent, QSizeF( w, h ), mCacheImage.logicalDpiX() );
draw( &p, requestExtent, QSizeF( w, h ), mCacheImage.logicalDpiX(), &forcedWidthScaleFactor );
p.end();
mCacheUpdated = true;

@@ -85,7 +85,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
@param extent map extent
@param size size in scene coordinates
@param dpi scene dpi*/
void draw( QPainter *painter, const QgsRectangle& extent, const QSizeF& size, double dpi );
void draw( QPainter *painter, const QgsRectangle& extent, const QSizeF& size, double dpi, double* forceWidthScale = 0 );

/** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
@@ -213,7 +213,7 @@ void QgsMapRenderer::adjustExtentToSize()
}


void QgsMapRenderer::render( QPainter* painter )
void QgsMapRenderer::render( QPainter* painter, double* forceScaleFactor )
{
//Lock render method for concurrent threads (e.g. from globe)
QMutexLocker renderLock( &mRenderMutex );
@@ -282,7 +282,14 @@ void QgsMapRenderer::render( QPainter* painter )
double scaleFactor = 1.0;
if ( mOutputUnits == QgsMapRenderer::Millimeters )
{
scaleFactor = sceneDpi / 25.4;
if ( forceScaleFactor )
{
scaleFactor = *forceScaleFactor;
}
else
{
scaleFactor = sceneDpi / 25.4;
}
}
double rasterScaleFactor = ( thePaintDevice->logicalDpiX() + thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi;
if ( mRenderContext.rasterScaleFactor() != rasterScaleFactor )
@@ -120,7 +120,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
~QgsMapRenderer();

//! starts rendering
void render( QPainter* painter );
void render( QPainter* painter, double* forceScaleFactor = 0 );

//! sets extent and checks whether suitable (returns false if not)
bool setExtent( const QgsRectangle& extent );

0 comments on commit 365c33d

Please sign in to comment.