QGIS API Documentation  2.13.0-Master
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;
36 
37 
44 class CORE_EXPORT QgsRenderContext
45 {
46  public:
48 
50  QgsRenderContext& operator=( const QgsRenderContext& rh );
51 
53 
57  enum Flag
58  {
59  DrawEditingInfo = 0x01,
60  ForceVectorOutput = 0x02,
61  UseAdvancedEffects = 0x04,
62  UseRenderingOptimization = 0x08,
63  DrawSelection = 0x10,
64  DrawSymbolBounds = 0x20,
65  RenderMapTile = 0x40,
66  };
67  Q_DECLARE_FLAGS( Flags, Flag )
68 
69 
72  void setFlags( const QgsRenderContext::Flags& flags );
73 
77  void setFlag( Flag flag, bool on = true );
78 
82  Flags flags() const;
83 
87  bool testFlag( Flag flag ) const;
88 
91  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
92 
93  //getters
94 
95  QPainter* painter() {return mPainter;}
96  const QPainter* constPainter() const { return mPainter; }
97 
98  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
99 
100  const QgsRectangle& extent() const {return mExtent;}
101 
102  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
103 
104  double scaleFactor() const {return mScaleFactor;}
105 
106  double rasterScaleFactor() const {return mRasterScaleFactor;}
107 
108  bool renderingStopped() const {return mRenderingStopped;}
109 
110  bool forceVectorOutput() const;
111 
114  bool useAdvancedEffects() const;
115 
118  void setUseAdvancedEffects( bool enabled );
119 
120  bool drawEditingInformation() const;
121 
122  double rendererScale() const {return mRendererScale;}
123 
124  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
125 
128  QgsLabelingEngineV2* labelingEngineV2() const { return mLabelingEngine2; }
129 
130  QColor selectionColor() const { return mSelectionColor; }
131 
138  bool showSelection() const;
139 
140  //setters
141 
143  void setCoordinateTransform( const QgsCoordinateTransform* t );
144  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
145  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
146 
147  void setDrawEditingInformation( bool b );
148 
149  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
150  void setScaleFactor( double factor ) {mScaleFactor = factor;}
151  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
152  void setRendererScale( double scale ) {mRendererScale = scale;}
153  void setPainter( QPainter* p ) {mPainter = p;}
154 
155  void setForceVectorOutput( bool force );
156 
157  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
160  void setLabelingEngineV2( QgsLabelingEngineV2* engine2 ) { mLabelingEngine2 = engine2; }
161  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
162 
169  void setShowSelection( const bool showSelection );
170 
173  bool useRenderingOptimization() const;
174 
175  void setUseRenderingOptimization( bool enabled );
176 
178  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
179  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
180 
186  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
187 
193  QgsExpressionContext& expressionContext() { return mExpressionContext; }
194 
201  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
202 
204  const QgsAbstractGeometryV2* geometry() const { return mGeometry; }
206  void setGeometry( const QgsAbstractGeometryV2* geometry ) { mGeometry = geometry; }
207 
213  void setFeatureFilterProvider( const QgsFeatureFilterProvider* ffp );
214 
220  const QgsFeatureFilterProvider* featureFilterProvider() const { return mFeatureFilterProvider; }
221 
222  private:
223 
224  Flags mFlags;
225 
227  QPainter* mPainter;
228 
230  const QgsCoordinateTransform* mCoordTransform;
231 
232  QgsRectangle mExtent;
233 
234  QgsMapToPixel mMapToPixel;
235 
237  bool mRenderingStopped;
238 
240  double mScaleFactor;
241 
243  double mRasterScaleFactor;
244 
246  double mRendererScale;
247 
249  QgsLabelingEngineInterface* mLabelingEngine;
250 
252  QgsLabelingEngineV2* mLabelingEngine2;
253 
255  QColor mSelectionColor;
256 
258  QgsVectorSimplifyMethod mVectorSimplifyMethod;
259 
261  QgsExpressionContext mExpressionContext;
262 
264  const QgsAbstractGeometryV2* mGeometry;
265 
267  const QgsFeatureFilterProvider* mFeatureFilterProvider;
268 
269 };
270 
271 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
272 
273 #endif
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
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.
const QgsFeatureFilterProvider * featureFilterProvider() const
Get the filter feature provider used for additional filtering of rendered features.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
void setSelectionColor(const QColor &color)
void setScaleFactor(double factor)
QgsLabelingEngineV2 * labelingEngineV2() const
Get access to new labeling engine (may be nullptr)
bool renderingStopped() const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setPainter(QPainter *p)
double rasterScaleFactor() const
Abstract interface for use by classes that filter the features of a layer.
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.
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.
const QgsMapToPixel & mapToPixel() const
void setRasterScaleFactor(double factor)
Labeling engine interface.
Flag
Enumeration of flags that affect rendering operations.
void setGeometry(const QgsAbstractGeometryV2 *geometry)
Sets pointer to original (unsegmentized) geometry.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsLabelingEngineInterface * labelingEngine() const