QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrendercontext.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendercontext.cpp
3  --------------------
4  begin : March 16, 2008
5  copyright : (C) 2008 by Marco Hugentobler
6  email : marco dot hugentobler at karto dot baug dot ethz dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #include "qgsrendercontext.h"
20 
21 #include "qgsmapsettings.h"
22 
24  : mPainter( 0 ),
25  mCoordTransform( 0 ),
26  mDrawEditingInformation( true ),
27  mForceVectorOutput( false ),
28  mUseAdvancedEffects( true ),
29  mRenderingStopped( false ),
30  mScaleFactor( 1.0 ),
31  mRasterScaleFactor( 1.0 ),
32  mRendererScale( 1.0 ),
33  mLabelingEngine( NULL ),
34  mUseRenderingOptimization( true )
35 {
36 
37 }
38 
40 {
41 }
42 
44 {
45  QgsRenderContext ctx;
46  ctx.setMapToPixel( mapSettings.mapToPixel() );
47  ctx.setExtent( mapSettings.visibleExtent() );
51  ctx.setCoordinateTransform( 0 );
52  ctx.setSelectionColor( mapSettings.selectionColor() );
53  ctx.setRasterScaleFactor( 1.0 );
54  ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
55  ctx.setRendererScale( mapSettings.scale() );
56 
57  //this flag is only for stopping during the current rendering progress,
58  //so must be false at every new render operation
59  ctx.setRenderingStopped( false );
60 
61  return ctx;
62 }
63 
65 {
66  mCoordTransform = t;
67 }
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
void setRenderingStopped(bool stopped)
double scale() const
QColor selectionColor() const
void setRendererScale(double scale)
QgsRectangle visibleExtent() const
const QgsMapToPixel & mapToPixel() const
void setExtent(const QgsRectangle &extent)
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
void setSelectionColor(const QColor &color)
Added in QGIS v2.0.
int outputDpi() const
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void setScaleFactor(double factor)
void setDrawEditingInformation(bool b)
bool testFlag(Flag flag) const
const QgsCoordinateTransform * mCoordTransform
For transformation between coordinate systems.
Contains information about the context of a rendering operation.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setMapToPixel(const QgsMapToPixel &mtp)
Class for doing transforms between two map coordinate systems.
void setRasterScaleFactor(double factor)