QGIS API Documentation  2.15.0-Master (13f053b)
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  };
68  Q_DECLARE_FLAGS( Flags, Flag )
69 
70 
73  void setFlags( const QgsRenderContext::Flags& flags );
74 
78  void setFlag( Flag flag, bool on = true );
79 
83  Flags flags() const;
84 
88  bool testFlag( Flag flag ) const;
89 
92  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
93 
94  //getters
95 
96  QPainter* painter() {return mPainter;}
97  const QPainter* constPainter() const { return mPainter; }
98 
99  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
100 
101  const QgsRectangle& extent() const {return mExtent;}
102 
103  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
104 
105  double scaleFactor() const {return mScaleFactor;}
106 
107  double rasterScaleFactor() const {return mRasterScaleFactor;}
108 
109  bool renderingStopped() const {return mRenderingStopped;}
110 
111  bool forceVectorOutput() const;
112 
115  bool useAdvancedEffects() const;
116 
119  void setUseAdvancedEffects( bool enabled );
120 
121  bool drawEditingInformation() const;
122 
123  double rendererScale() const {return mRendererScale;}
124 
125  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
126 
129  QgsLabelingEngineV2* labelingEngineV2() const { return mLabelingEngine2; }
130 
131  QColor selectionColor() const { return mSelectionColor; }
132 
139  bool showSelection() const;
140 
141  //setters
142 
144  void setCoordinateTransform( const QgsCoordinateTransform* t );
145  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
146  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
147 
148  void setDrawEditingInformation( bool b );
149 
150  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
151  void setScaleFactor( double factor ) {mScaleFactor = factor;}
152  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
153  void setRendererScale( double scale ) {mRendererScale = scale;}
154  void setPainter( QPainter* p ) {mPainter = p;}
155 
156  void setForceVectorOutput( bool force );
157 
158  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
161  void setLabelingEngineV2( QgsLabelingEngineV2* engine2 ) { mLabelingEngine2 = engine2; }
162  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
163 
170  void setShowSelection( const bool showSelection );
171 
174  bool useRenderingOptimization() const;
175 
176  void setUseRenderingOptimization( bool enabled );
177 
179  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
180  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
181 
187  void setExpressionContext( const QgsExpressionContext& context ) { mExpressionContext = context; }
188 
194  QgsExpressionContext& expressionContext() { return mExpressionContext; }
195 
202  const QgsExpressionContext& expressionContext() const { return mExpressionContext; }
203 
205  const QgsAbstractGeometryV2* geometry() const { return mGeometry; }
207  void setGeometry( const QgsAbstractGeometryV2* geometry ) { mGeometry = geometry; }
208 
214  void setFeatureFilterProvider( const QgsFeatureFilterProvider* ffp );
215 
221  const QgsFeatureFilterProvider* featureFilterProvider() const { return mFeatureFilterProvider; }
222 
225  void setSegmentationTolerance( double tolerance ) { mSegmentationTolerance = tolerance; }
227  double segmentationTolerance() const { return mSegmentationTolerance; }
228 
231  void setSegmentationToleranceType( QgsAbstractGeometryV2::SegmentationToleranceType type ) { mSegmentationToleranceType = type; }
234 
235  private:
236 
237  Flags mFlags;
238 
240  QPainter* mPainter;
241 
243  const QgsCoordinateTransform* mCoordTransform;
244 
245  QgsRectangle mExtent;
246 
247  QgsMapToPixel mMapToPixel;
248 
250  bool mRenderingStopped;
251 
253  double mScaleFactor;
254 
256  double mRasterScaleFactor;
257 
259  double mRendererScale;
260 
262  QgsLabelingEngineInterface* mLabelingEngine;
263 
265  QgsLabelingEngineV2* mLabelingEngine2;
266 
268  QColor mSelectionColor;
269 
271  QgsVectorSimplifyMethod mVectorSimplifyMethod;
272 
274  QgsExpressionContext mExpressionContext;
275 
277  const QgsAbstractGeometryV2* mGeometry;
278 
280  const QgsFeatureFilterProvider* mFeatureFilterProvider;
281 
282  double mSegmentationTolerance;
283 
284  QgsAbstractGeometryV2::SegmentationToleranceType mSegmentationToleranceType;
285 };
286 
287 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
288 
289 #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