QGIS API Documentation  2.17.0-Master (06698cd)
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 "qgsabstractgeometryv2.h"
24 #include "qgscoordinatetransform.h"
25 #include "qgsmaptopixel.h"
26 #include "qgsrectangle.h"
28 #include "qgsexpressioncontext.h"
29 
30 class QPainter;
31 
35 class QgsMapSettings;
37 
38 
45 class CORE_EXPORT QgsRenderContext
46 {
47  public:
49 
51  QgsRenderContext& operator=( const QgsRenderContext& rh );
52 
54 
58  enum Flag
59  {
60  DrawEditingInfo = 0x01,
61  ForceVectorOutput = 0x02,
62  UseAdvancedEffects = 0x04,
63  UseRenderingOptimization = 0x08,
64  DrawSelection = 0x10,
65  DrawSymbolBounds = 0x20,
66  RenderMapTile = 0x40,
67  Antialiasing = 0x80,
68  };
69  Q_DECLARE_FLAGS( Flags, Flag )
70 
71 
74  void setFlags( const QgsRenderContext::Flags& flags );
75 
79  void setFlag( Flag flag, bool on = true );
80 
84  Flags flags() const;
85 
89  bool testFlag( Flag flag ) const;
90 
93  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
94 
95  //getters
96 
97  QPainter* painter() {return mPainter;}
98  const QPainter* constPainter() const { return mPainter; }
99 
100  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
101 
102  const QgsRectangle& extent() const {return mExtent;}
103 
104  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
105 
106  double scaleFactor() const {return mScaleFactor;}
107 
108  double rasterScaleFactor() const {return mRasterScaleFactor;}
109 
110  bool renderingStopped() const {return mRenderingStopped;}
111 
112  bool forceVectorOutput() const;
113 
116  bool useAdvancedEffects() const;
117 
120  void setUseAdvancedEffects( bool enabled );
121 
122  bool drawEditingInformation() const;
123 
124  double rendererScale() const {return mRendererScale;}
125 
126  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
127 
130  QgsLabelingEngineV2* labelingEngineV2() const { return mLabelingEngine2; }
131 
132  QColor selectionColor() const { return mSelectionColor; }
133 
140  bool showSelection() const;
141 
142  //setters
143 
145  void setCoordinateTransform( const QgsCoordinateTransform* t );
146  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
147  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
148 
149  void setDrawEditingInformation( bool b );
150 
151  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
152  void setScaleFactor( double factor ) {mScaleFactor = factor;}
153  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
154  void setRendererScale( double scale ) {mRendererScale = scale;}
155  void setPainter( QPainter* p ) {mPainter = p;}
156 
157  void setForceVectorOutput( bool force );
158 
159  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
162  void setLabelingEngineV2( QgsLabelingEngineV2* engine2 ) { mLabelingEngine2 = engine2; }
163  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
164 
171  void setShowSelection( const bool showSelection );
172 
175  bool useRenderingOptimization() const;
176 
177  void setUseRenderingOptimization( bool enabled );
178 
180  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
181  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
182 
188  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
189 
195  QgsExpressionContext& expressionContext() { return mExpressionContext; }
196 
203  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
204 
206  const QgsAbstractGeometryV2* geometry() const { return mGeometry; }
208  void setGeometry( const QgsAbstractGeometryV2* geometry ) { mGeometry = geometry; }
209 
215  void setFeatureFilterProvider( const QgsFeatureFilterProvider* ffp );
216 
222  const QgsFeatureFilterProvider* featureFilterProvider() const { return mFeatureFilterProvider; }
223 
226  void setSegmentationTolerance( double tolerance ) { mSegmentationTolerance = tolerance; }
228  double segmentationTolerance() const { return mSegmentationTolerance; }
229 
232  void setSegmentationToleranceType( QgsAbstractGeometryV2::SegmentationToleranceType type ) { mSegmentationToleranceType = type; }
235 
236  private:
237 
238  Flags mFlags;
239 
241  QPainter* mPainter;
242 
244  const QgsCoordinateTransform* mCoordTransform;
245 
246  QgsRectangle mExtent;
247 
248  QgsMapToPixel mMapToPixel;
249 
251  bool mRenderingStopped;
252 
254  double mScaleFactor;
255 
257  double mRasterScaleFactor;
258 
260  double mRendererScale;
261 
263  QgsLabelingEngineInterface* mLabelingEngine;
264 
266  QgsLabelingEngineV2* mLabelingEngine2;
267 
269  QColor mSelectionColor;
270 
272  QgsVectorSimplifyMethod mVectorSimplifyMethod;
273 
275  QgsExpressionContext mExpressionContext;
276 
278  const QgsAbstractGeometryV2* mGeometry;
279 
281  const QgsFeatureFilterProvider* mFeatureFilterProvider;
282 
283  double mSegmentationTolerance;
284 
285  QgsAbstractGeometryV2::SegmentationToleranceType mSegmentationToleranceType;
286 };
287 
288 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
289 
290 #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
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
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...
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
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.
QgsAbstractGeometryV2::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
QgsExpressionContext & expressionContext()
Gets the expression context.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
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 setSegmentationToleranceType(QgsAbstractGeometryV2::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
void setGeometry(const QgsAbstractGeometryV2 *geometry)
Sets pointer to original (unsegmentized) geometry.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsLabelingEngineInterface * labelingEngine() const