Skip to content
Permalink
Browse files

Removed use of QgsMapRenderer::rendererContext()

Deprecated QImage/QPixmap switch in QgsMapCanvas
  • Loading branch information
wonder-sk committed Nov 13, 2013
1 parent d1985a1 commit cf3d86c33c0e3d7292358bebb2a97bc977979573
@@ -2063,7 +2063,6 @@ void QgisApp::createOverview()
QSettings mySettings;
// Anti Aliasing enabled by default as of QGIS 1.7
mMapCanvas->enableAntiAliasing( mySettings.value( "/qgis/enable_anti_aliasing", true ).toBool() );
mMapCanvas->useImageToRender( mySettings.value( "/qgis/use_qimage_to_render", true ).toBool() );

int action = mySettings.value( "/qgis/wheel_action", 2 ).toInt();
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
@@ -6790,7 +6789,6 @@ void QgisApp::options()
setTheme( optionsDialog->theme() );

mMapCanvas->enableAntiAliasing( mySettings.value( "/qgis/enable_anti_aliasing" ).toBool() );
mMapCanvas->useImageToRender( mySettings.value( "/qgis/use_qimage_to_render" ).toBool() );

int action = mySettings.value( "/qgis/wheel_action", 2 ).toInt();
double zoomFactor = mySettings.value( "/qgis/zoom_factor", 2 ).toDouble();
@@ -270,17 +270,7 @@ void QgsMapToolRotatePointSymbols::createPixmapItem( QgsFeature& f )
return;
}

//get reference to current render context
QgsMapRenderer* mapRenderer = mCanvas->mapRenderer();
if ( !mapRenderer )
{
return;
}
QgsRenderContext* renderContext = mCanvas->mapRenderer()->rendererContext();
if ( !renderContext )
{
return;
}
QgsRenderContext renderContext( QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ) );

//get the image that is used for that symbol, but without point rotation
QImage pointImage;
@@ -289,14 +279,14 @@ void QgsMapToolRotatePointSymbols::createPixmapItem( QgsFeature& f )
{
QgsFeatureRendererV2* rv2 = mActiveLayer->rendererV2()->clone();
rv2->setRotationField( "" );
rv2->startRender( *renderContext, mActiveLayer );
rv2->startRender( renderContext, mActiveLayer );

QgsSymbolV2* symbolV2 = rv2->symbolForFeature( f );
if ( symbolV2 )
{
pointImage = symbolV2->bigSymbolPreviewImage();
}
rv2->stopRender( *renderContext );
rv2->stopRender( renderContext );
delete rv2;
}

@@ -200,21 +200,8 @@ void QgsMapRendererCustomPainterJob::startRender()
renderTime.start();
#endif

mRenderContext.setMapToPixel( mSettings.mapToPixel() );
mRenderContext.setExtent( mSettings.visibleExtent() );
mRenderContext.setDrawEditingInformation( mSettings.testFlag( QgsMapSettings::DrawEditingInfo ) );
mRenderContext.setForceVectorOutput( mSettings.testFlag( QgsMapSettings::ForceVectorOutput ) );
mRenderContext.setUseAdvancedEffects( mSettings.testFlag( QgsMapSettings::UseAdvancedEffects ) );
mRenderContext = QgsRenderContext::fromMapSettings( mSettings );
mRenderContext.setPainter( mPainter );
mRenderContext.setCoordinateTransform( 0 );
mRenderContext.setSelectionColor( mSettings.selectionColor() );
mRenderContext.setRasterScaleFactor( 1.0 );
mRenderContext.setScaleFactor( mSettings.outputDpi() / 25.4 ); // = pixels per mm
mRenderContext.setRendererScale( mSettings.scale() );

//this flag is only for stopping during the current rendering progress,
//so must be false at every new render operation
mRenderContext.setRenderingStopped( false );

mRenderContext.setLabelingEngine( mLabelingEngine );
if ( mLabelingEngine )
@@ -18,6 +18,8 @@

#include "qgsrendercontext.h"

#include "qgsmapsettings.h"

QgsRenderContext::QgsRenderContext()
: mPainter( 0 ),
mCoordTransform( 0 ),
@@ -37,6 +39,27 @@ QgsRenderContext::~QgsRenderContext()
{
}

QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings& mapSettings )
{
QgsRenderContext ctx;
ctx.setMapToPixel( mapSettings.mapToPixel() );
ctx.setExtent( mapSettings.visibleExtent() );
ctx.setDrawEditingInformation( mapSettings.testFlag( QgsMapSettings::DrawEditingInfo ) );
ctx.setForceVectorOutput( mapSettings.testFlag( QgsMapSettings::ForceVectorOutput ) );
ctx.setUseAdvancedEffects( mapSettings.testFlag( QgsMapSettings::UseAdvancedEffects ) );
ctx.setCoordinateTransform( 0 );
ctx.setSelectionColor( mapSettings.selectionColor() );
ctx.setRasterScaleFactor( 1.0 );
ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
ctx.setRendererScale( mapSettings.scale() );

//this flag is only for stopping during the current rendering progress,
//so must be false at every new render operation
ctx.setRenderingStopped( false );

return ctx;
}

void QgsRenderContext::setCoordinateTransform( const QgsCoordinateTransform* t )
{
mCoordTransform = t;
@@ -27,6 +27,7 @@
class QPainter;

class QgsLabelingEngineInterface;
class QgsMapSettings;

/** \ingroup core
* Contains information about the context of a rendering operation.
@@ -40,6 +41,9 @@ class CORE_EXPORT QgsRenderContext
QgsRenderContext();
~QgsRenderContext();

//! create initialized QgsRenderContext instance from given QgsMapSettings
static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );

//getters

QPainter* painter() {return mPainter;}
@@ -186,8 +186,6 @@ void QgsMapCanvas::enableAntiAliasing( bool theFlag )
void QgsMapCanvas::useImageToRender( bool theFlag )
{
Q_UNUSED(theFlag);
//mMap->useImageToRender( theFlag );
//refresh(); // redraw the map on change - prevents black map view
}

QgsMapCanvasMap* QgsMapCanvas::map()
@@ -476,11 +474,7 @@ void QgsMapCanvas::refresh()

void QgsMapCanvas::stopRendering()
{
QgsRenderContext* mypRenderContext = mMapRenderer->rendererContext();
if ( mypRenderContext )
{
mypRenderContext->setRenderingStopped( true );
}
// TODO: implement stopping (?)
}

void QgsMapCanvas::updateMap()
@@ -278,7 +278,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
bool antiAliasingEnabled() const { return mSettings.testFlag( QgsMapSettings::Antialiasing ); }

//! Select which Qt class to render with
void useImageToRender( bool theFlag );
//! @deprecated since 2.1 - does nothing because now we always render to QImage
Q_DECL_DEPRECATED void useImageToRender( bool theFlag );

// following 2 methods should be moved elsewhere or changed to private
// currently used by pan map tool
@@ -313,11 +313,12 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<IdentifyResult> *results, Qg

bool filter = false;

QgsRenderContext context( QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ) );
QgsFeatureRendererV2* renderer = layer->rendererV2();
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
// setup scale for scale dependent visibility (rule based)
renderer->startRender( *( mCanvas->mapRenderer()->rendererContext() ), layer );
renderer->startRender( context, layer );
filter = renderer->capabilities() & QgsFeatureRendererV2::Filter;
}

@@ -341,7 +342,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<IdentifyResult> *results, Qg

if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
renderer->stopRender( *( mCanvas->mapRenderer()->rendererContext() ) );
renderer->stopRender( context );
}

QgsDebugMsg( "Feature count on identify: " + QString::number( featureCount ) );

0 comments on commit cf3d86c

Please sign in to comment.
You can’t perform that action at this time.