QGIS API Documentation  2.12.0-Lyon
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 
34 class QgsMapSettings;
35 
42 class CORE_EXPORT QgsRenderContext
43 {
44  public:
47 
50  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
51 
52  //getters
53 
54  QPainter* painter() {return mPainter;}
55  const QPainter* constPainter() const { return mPainter; }
56 
57  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
58 
59  const QgsRectangle& extent() const {return mExtent;}
60 
61  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
62 
63  double scaleFactor() const {return mScaleFactor;}
64 
65  double rasterScaleFactor() const {return mRasterScaleFactor;}
66 
67  bool renderingStopped() const {return mRenderingStopped;}
68 
69  bool forceVectorOutput() const {return mForceVectorOutput;}
70 
72  bool useAdvancedEffects() const {return mUseAdvancedEffects;}
74  void setUseAdvancedEffects( bool enabled ) { mUseAdvancedEffects = enabled; }
75 
76  bool drawEditingInformation() const {return mDrawEditingInformation;}
77 
78  double rendererScale() const {return mRendererScale;}
79 
80  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
81 
83  QgsLabelingEngineV2* labelingEngineV2() const { return mLabelingEngine2; }
84 
85  QColor selectionColor() const { return mSelectionColor; }
86 
93  bool showSelection() const { return mShowSelection; }
94 
95  //setters
96 
98  void setCoordinateTransform( const QgsCoordinateTransform* t );
99  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
100  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
101  void setDrawEditingInformation( bool b ) {mDrawEditingInformation = b;}
102  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
103  void setScaleFactor( double factor ) {mScaleFactor = factor;}
104  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
105  void setRendererScale( double scale ) {mRendererScale = scale;}
106  void setPainter( QPainter* p ) {mPainter = p;}
107  void setForceVectorOutput( bool force ) {mForceVectorOutput = force;}
108  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
110  void setLabelingEngineV2( QgsLabelingEngineV2* engine2 ) { mLabelingEngine2 = engine2; }
111  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
112 
119  void setShowSelection( const bool showSelection ) { mShowSelection = showSelection; }
120 
122  bool useRenderingOptimization() const { return mUseRenderingOptimization; }
123  void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
124 
126  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
127  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
128 
134  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
135 
141  QgsExpressionContext& expressionContext() { return mExpressionContext; }
142 
148  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
149 
151  const QgsAbstractGeometryV2* geometry() const { return mGeometry; }
153  void setGeometry( const QgsAbstractGeometryV2* geometry ) { mGeometry = geometry; }
154 
155  private:
156 
158  QPainter* mPainter;
159 
161  const QgsCoordinateTransform* mCoordTransform;
162 
164  bool mDrawEditingInformation;
165 
166  QgsRectangle mExtent;
167 
169  bool mForceVectorOutput;
170 
172  bool mUseAdvancedEffects;
173 
174  QgsMapToPixel mMapToPixel;
175 
177  bool mRenderingStopped;
178 
180  double mScaleFactor;
181 
183  double mRasterScaleFactor;
184 
186  double mRendererScale;
187 
189  QgsLabelingEngineInterface* mLabelingEngine;
190 
192  QgsLabelingEngineV2* mLabelingEngine2;
193 
195  bool mShowSelection;
196 
198  QColor mSelectionColor;
199 
201  bool mUseRenderingOptimization;
202 
204  QgsVectorSimplifyMethod mVectorSimplifyMethod;
205 
207  QgsExpressionContext mExpressionContext;
208 
210  const QgsAbstractGeometryV2* mGeometry;
211 };
212 
213 #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)
The QgsLabelingEngineV2 class provides map labeling functionality.
Abstract base class for all geometries.
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)
QgsLabelingEngineV2 * labelingEngineV2() const
Get access to new labeling engine (may be NULL)
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
void setLabelingEngineV2(QgsLabelingEngineV2 *engine2)
Assign new labeling engine.
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 QgsAbstractGeometryV2 * geometry() const
Returns pointer to the unsegmentized geometry.
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 setGeometry(const QgsAbstractGeometryV2 *geometry)
Sets pointer to original (unsegmentized) geometry.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsLabelingEngineInterface * labelingEngine() const