QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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  mShowSelection( true ),
35  mUseRenderingOptimization( true )
36 {
38 }
39 
41 {
42 }
43 
45 {
46  QgsRenderContext ctx;
47  ctx.setMapToPixel( mapSettings.mapToPixel() );
48  ctx.setExtent( mapSettings.visibleExtent() );
53  ctx.setCoordinateTransform( 0 );
54  ctx.setSelectionColor( mapSettings.selectionColor() );
56  ctx.setRasterScaleFactor( 1.0 );
57  ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
58  ctx.setRendererScale( mapSettings.scale() );
59 
60  //this flag is only for stopping during the current rendering progress,
61  //so must be false at every new render operation
62  ctx.setRenderingStopped( false );
63 
64  return ctx;
65 }
66 
68 {
69  mCoordTransform = t;
70 }
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
void setRenderingStopped(bool stopped)
double scale() const
Return the calculated scale of the map.
QColor selectionColor() const
Get color that is used for drawing of selected vector features.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
void setRendererScale(double scale)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
const QgsMapToPixel & mapToPixel() const
Enable layer transparency and blending effects.
void setExtent(const QgsRectangle &extent)
QgsVectorSimplifyMethod mVectorSimplifyMethod
Simplification object which holds the information about how to simplify the features for fast renderi...
Vector graphics should not be cached and drawn as raster images.
The QgsMapSettings class contains configuration for rendering of the map.
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
void setSelectionColor(const QColor &color)
Added in QGIS v2.0.
No simplification can be applied.
int outputDpi() const
Return DPI used for conversion between real world units (e.g.
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void setScaleFactor(double factor)
Whether vector selections should be shown in the rendered map.
void setDrawEditingInformation(bool b)
Enable drawing of vertex markers for layers in editing mode.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
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 setUseRenderingOptimization(bool enabled)
Enable vector simplification and other rendering optimizations.
void setRasterScaleFactor(double factor)
void setShowSelection(const bool showSelection)
Sets whether vector selections should be shown in the rendered map.