QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrendercontext.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendercontext.h
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 #ifndef QGSRENDERCONTEXT_H
19 #define QGSRENDERCONTEXT_H
20 
21 #include <QColor>
22 
23 #include "qgscoordinatetransform.h"
24 #include "qgsmaptopixel.h"
25 #include "qgsrectangle.h"
27 #include "qgsexpressioncontext.h"
28 
29 class QPainter;
30 
32 class QgsMapSettings;
33 
40 class CORE_EXPORT QgsRenderContext
41 {
42  public:
45 
48  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
49 
50  //getters
51 
52  QPainter* painter() {return mPainter;}
53  const QPainter* constPainter() const { return mPainter; }
54 
55  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
56 
57  const QgsRectangle& extent() const {return mExtent;}
58 
59  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
60 
61  double scaleFactor() const {return mScaleFactor;}
62 
63  double rasterScaleFactor() const {return mRasterScaleFactor;}
64 
65  bool renderingStopped() const {return mRenderingStopped;}
66 
67  bool forceVectorOutput() const {return mForceVectorOutput;}
68 
70  bool useAdvancedEffects() const {return mUseAdvancedEffects;}
72  void setUseAdvancedEffects( bool enabled ) { mUseAdvancedEffects = enabled; }
73 
74  bool drawEditingInformation() const {return mDrawEditingInformation;}
75 
76  double rendererScale() const {return mRendererScale;}
77 
78  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
79 
80  QColor selectionColor() const { return mSelectionColor; }
81 
88  bool showSelection() const { return mShowSelection; }
89 
90  //setters
91 
93  void setCoordinateTransform( const QgsCoordinateTransform* t );
94  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
95  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
96  void setDrawEditingInformation( bool b ) {mDrawEditingInformation = b;}
97  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
98  void setScaleFactor( double factor ) {mScaleFactor = factor;}
99  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
100  void setRendererScale( double scale ) {mRendererScale = scale;}
101  void setPainter( QPainter* p ) {mPainter = p;}
102  void setForceVectorOutput( bool force ) {mForceVectorOutput = force;}
103  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
104  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
105 
112  void setShowSelection( const bool showSelection ) { mShowSelection = showSelection; }
113 
115  bool useRenderingOptimization() const { return mUseRenderingOptimization; }
116  void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
117 
119  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
120  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
121 
127  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
128 
134  QgsExpressionContext& expressionContext() { return mExpressionContext; }
135 
141  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
142 
143  private:
144 
146  QPainter* mPainter;
147 
149  const QgsCoordinateTransform* mCoordTransform;
150 
152  bool mDrawEditingInformation;
153 
154  QgsRectangle mExtent;
155 
157  bool mForceVectorOutput;
158 
160  bool mUseAdvancedEffects;
161 
162  QgsMapToPixel mMapToPixel;
163 
165  bool mRenderingStopped;
166 
168  double mScaleFactor;
169 
171  double mRasterScaleFactor;
172 
174  double mRendererScale;
175 
177  QgsLabelingEngineInterface* mLabelingEngine;
178 
180  bool mShowSelection;
181 
183  QColor mSelectionColor;
184 
186  bool mUseRenderingOptimization;
187 
189  QgsVectorSimplifyMethod mVectorSimplifyMethod;
190 
192  QgsExpressionContext mExpressionContext;
193 };
194 
195 #endif
void setForceVectorOutput(bool force)
void setRenderingStopped(bool stopped)
A rectangle specified with double values.
Definition: qgsrectangle.h:35
QColor selectionColor() const
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
double rendererScale() const
void setRendererScale(double scale)
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
const QgsRectangle & extent() const
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
double scaleFactor() const
const QgsCoordinateTransform * coordinateTransform() const
const QPainter * constPainter() const
void setExtent(const QgsRectangle &extent)
The QgsMapSettings class contains configuration for rendering of the map.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
void setSelectionColor(const QColor &color)
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void setScaleFactor(double factor)
bool renderingStopped() const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setDrawEditingInformation(bool b)
bool forceVectorOutput() const
void setPainter(QPainter *p)
double rasterScaleFactor() const
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
bool drawEditingInformation() const
QgsExpressionContext & expressionContext()
Gets the expression context.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
QPainter * painter()
void setLabelingEngine(QgsLabelingEngineInterface *iface)
const QgsExpressionContext & expressionContext() const
Gets the expression context (const version).
void setMapToPixel(const QgsMapToPixel &mtp)
Class for doing transforms between two map coordinate systems.
void setUseRenderingOptimization(bool enabled)
const QgsMapToPixel & mapToPixel() const
void setRasterScaleFactor(double factor)
Labeling engine interface.
void setShowSelection(const bool showSelection)
Sets whether vector selections should be shown in the rendered map.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsLabelingEngineInterface * labelingEngine() const