QGIS API Documentation  2.17.0-Master (f49f7ce)
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  RenderPartialOutput = 0x100,
69  };
70  Q_DECLARE_FLAGS( Flags, Flag )
71 
72 
75  void setFlags( const QgsRenderContext::Flags& flags );
76 
80  void setFlag( Flag flag, bool on = true );
81 
85  Flags flags() const;
86 
90  bool testFlag( Flag flag ) const;
91 
94  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
95 
96  //getters
97 
98  QPainter* painter() {return mPainter;}
99  const QPainter* constPainter() const { return mPainter; }
100 
101  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
102 
103  const QgsRectangle& extent() const {return mExtent;}
104 
105  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
106 
107  double scaleFactor() const {return mScaleFactor;}
108 
109  double rasterScaleFactor() const {return mRasterScaleFactor;}
110 
111  bool renderingStopped() const {return mRenderingStopped;}
112 
113  bool forceVectorOutput() const;
114 
117  bool useAdvancedEffects() const;
118 
121  void setUseAdvancedEffects( bool enabled );
122 
123  bool drawEditingInformation() const;
124 
125  double rendererScale() const {return mRendererScale;}
126 
127  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
128 
131  QgsLabelingEngineV2* labelingEngineV2() const { return mLabelingEngine2; }
132 
133  QColor selectionColor() const { return mSelectionColor; }
134 
141  bool showSelection() const;
142 
143  //setters
144 
146  void setCoordinateTransform( const QgsCoordinateTransform* t );
147  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
148  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
149 
150  void setDrawEditingInformation( bool b );
151 
152  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
153  void setScaleFactor( double factor ) {mScaleFactor = factor;}
154  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
155  void setRendererScale( double scale ) {mRendererScale = scale;}
156  void setPainter( QPainter* p ) {mPainter = p;}
157 
158  void setForceVectorOutput( bool force );
159 
160  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
163  void setLabelingEngineV2( QgsLabelingEngineV2* engine2 ) { mLabelingEngine2 = engine2; }
164  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
165 
172  void setShowSelection( const bool showSelection );
173 
176  bool useRenderingOptimization() const;
177 
178  void setUseRenderingOptimization( bool enabled );
179 
181  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
182  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
183 
189  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
190 
196  QgsExpressionContext& expressionContext() { return mExpressionContext; }
197 
204  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
205 
207  const QgsAbstractGeometryV2* geometry() const { return mGeometry; }
209  void setGeometry( const QgsAbstractGeometryV2* geometry ) { mGeometry = geometry; }
210 
216  void setFeatureFilterProvider( const QgsFeatureFilterProvider* ffp );
217 
223  const QgsFeatureFilterProvider* featureFilterProvider() const { return mFeatureFilterProvider; }
224 
227  void setSegmentationTolerance( double tolerance ) { mSegmentationTolerance = tolerance; }
229  double segmentationTolerance() const { return mSegmentationTolerance; }
230 
233  void setSegmentationToleranceType( QgsAbstractGeometryV2::SegmentationToleranceType type ) { mSegmentationToleranceType = type; }
236 
237  private:
238 
239  Flags mFlags;
240 
242  QPainter* mPainter;
243 
245  const QgsCoordinateTransform* mCoordTransform;
246 
247  QgsRectangle mExtent;
248 
249  QgsMapToPixel mMapToPixel;
250 
252  bool mRenderingStopped;
253 
255  double mScaleFactor;
256 
258  double mRasterScaleFactor;
259 
261  double mRendererScale;
262 
264  QgsLabelingEngineInterface* mLabelingEngine;
265 
267  QgsLabelingEngineV2* mLabelingEngine2;
268 
270  QColor mSelectionColor;
271 
273  QgsVectorSimplifyMethod mVectorSimplifyMethod;
274 
276  QgsExpressionContext mExpressionContext;
277 
279  const QgsAbstractGeometryV2* mGeometry;
280 
282  const QgsFeatureFilterProvider* mFeatureFilterProvider;
283 
284  double mSegmentationTolerance;
285 
286  QgsAbstractGeometryV2::SegmentationToleranceType mSegmentationToleranceType;
287 };
288 
289 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
290 
291 #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