QGIS API Documentation  2.99.0-Master (c558d51)
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 "qgsabstractgeometry.h"
24 #include "qgscoordinatetransform.h"
25 #include "qgsmaptopixel.h"
26 #include "qgsrectangle.h"
28 #include "qgsexpressioncontext.h"
29 
30 class QPainter;
31 
34 class QgsLabelingEngine;
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( 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 
104  QgsCoordinateTransform coordinateTransform() const {return mCoordTransform;}
105 
106  const QgsRectangle& extent() const {return mExtent;}
107 
108  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
109 
110  double scaleFactor() const {return mScaleFactor;}
111 
112  double rasterScaleFactor() const {return mRasterScaleFactor;}
113 
114  bool renderingStopped() const {return mRenderingStopped;}
115 
116  bool forceVectorOutput() const;
117 
120  bool useAdvancedEffects() const;
121 
124  void setUseAdvancedEffects( bool enabled );
125 
126  bool drawEditingInformation() const;
127 
128  double rendererScale() const {return mRendererScale;}
129 
130  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
131 
134  QgsLabelingEngine* labelingEngineV2() const { return mLabelingEngine2; }
135 
136  QColor selectionColor() const { return mSelectionColor; }
137 
144  bool showSelection() const;
145 
146  //setters
147 
149  void setCoordinateTransform( const QgsCoordinateTransform& t );
150  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
151  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
152 
153  void setDrawEditingInformation( bool b );
154 
155  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
156  void setScaleFactor( double factor ) {mScaleFactor = factor;}
157  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
158  void setRendererScale( double scale ) {mRendererScale = scale;}
159  void setPainter( QPainter* p ) {mPainter = p;}
160 
161  void setForceVectorOutput( bool force );
162 
163  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
166  void setLabelingEngineV2( QgsLabelingEngine* engine2 ) { mLabelingEngine2 = engine2; }
167  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
168 
175  void setShowSelection( const bool showSelection );
176 
179  bool useRenderingOptimization() const;
180 
181  void setUseRenderingOptimization( bool enabled );
182 
184  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
185  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
186 
192  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
193 
199  QgsExpressionContext& expressionContext() { return mExpressionContext; }
200 
207  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
208 
210  const QgsAbstractGeometry* geometry() const { return mGeometry; }
212  void setGeometry( const QgsAbstractGeometry* geometry ) { mGeometry = geometry; }
213 
219  void setFeatureFilterProvider( const QgsFeatureFilterProvider* ffp );
220 
226  const QgsFeatureFilterProvider* featureFilterProvider() const { return mFeatureFilterProvider; }
227 
230  void setSegmentationTolerance( double tolerance ) { mSegmentationTolerance = tolerance; }
232  double segmentationTolerance() const { return mSegmentationTolerance; }
233 
236  void setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType type ) { mSegmentationToleranceType = type; }
238  QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const { return mSegmentationToleranceType; }
239 
240  private:
241 
242  Flags mFlags;
243 
245  QPainter* mPainter;
246 
248  QgsCoordinateTransform mCoordTransform;
249 
250  QgsRectangle mExtent;
251 
252  QgsMapToPixel mMapToPixel;
253 
255  bool mRenderingStopped;
256 
258  double mScaleFactor;
259 
261  double mRasterScaleFactor;
262 
264  double mRendererScale;
265 
267  QgsLabelingEngineInterface* mLabelingEngine;
268 
270  QgsLabelingEngine* mLabelingEngine2;
271 
273  QColor mSelectionColor;
274 
276  QgsVectorSimplifyMethod mVectorSimplifyMethod;
277 
279  QgsExpressionContext mExpressionContext;
280 
282  const QgsAbstractGeometry* mGeometry;
283 
285  const QgsFeatureFilterProvider* mFeatureFilterProvider;
286 
287  double mSegmentationTolerance;
288 
289  QgsAbstractGeometry::SegmentationToleranceType mSegmentationToleranceType;
290 };
291 
292 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
293 
294 #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)
QgsLabelingEngine * labelingEngineV2() const
Get access to new labeling engine (may be nullptr)
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
const QgsRectangle & extent() const
double scaleFactor() const
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
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.
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:33
void setSelectionColor(const QColor &color)
void setScaleFactor(double factor)
void setGeometry(const QgsAbstractGeometry *geometry)
Sets pointer to original (unsegmentized) geometry.
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 setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
Abstract base class for all geometries.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
The QgsLabelingEngine class provides map labeling functionality.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
void setLabelingEngineV2(QgsLabelingEngine *engine2)
Assign new labeling engine.
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.
const QgsMapToPixel & mapToPixel() const
void setRasterScaleFactor(double factor)
Labeling engine interface.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context, or an invalid transform is no coordinate tr...
Flag
Enumeration of flags that affect rendering operations.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsLabelingEngineInterface * labelingEngine() const