QGIS API Documentation  2.14.11-Essen
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  Antialiasing = 0x80,
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 
223  private:
224 
225  Flags mFlags;
226 
228  QPainter* mPainter;
229 
231  const QgsCoordinateTransform* mCoordTransform;
232 
233  QgsRectangle mExtent;
234 
235  QgsMapToPixel mMapToPixel;
236 
238  bool mRenderingStopped;
239 
241  double mScaleFactor;
242 
244  double mRasterScaleFactor;
245 
247  double mRendererScale;
248 
250  QgsLabelingEngineInterface* mLabelingEngine;
251 
253  QgsLabelingEngineV2* mLabelingEngine2;
254 
256  QColor mSelectionColor;
257 
259  QgsVectorSimplifyMethod mVectorSimplifyMethod;
260 
262  QgsExpressionContext mExpressionContext;
263 
265  const QgsAbstractGeometryV2* mGeometry;
266 
268  const QgsFeatureFilterProvider* mFeatureFilterProvider;
269 
270 };
271 
272 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
273 
274 #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.
Flag
Enumeration of flags that affect rendering operations.
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.
void setGeometry(const QgsAbstractGeometryV2 *geometry)
Sets pointer to original (unsegmentized) geometry.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsLabelingEngineInterface * labelingEngine() const