QGIS API Documentation  2.12.0-Lyon
qgsvectorlayerrenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerrenderer.cpp
3  --------------------------------------
4  Date : December 2013
5  Copyright : (C) 2013 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsvectorlayerrenderer.h"
17 
18 //#include "qgsfeatureiterator.h"
19 #include "diagram/qgsdiagram.h"
20 #include "qgsdiagramrendererv2.h"
21 #include "qgsgeometrycache.h"
22 #include "qgsmessagelog.h"
23 #include "qgspallabeling.h"
24 #include "qgsrendererv2.h"
25 #include "qgsrendercontext.h"
27 #include "qgssymbollayerv2.h"
28 #include "qgssymbolv2.h"
29 #include "qgsvectorlayer.h"
32 #include "qgsvectorlayerlabeling.h"
34 #include "qgspainteffect.h"
35 
36 #include <QSettings>
37 #include <QPicture>
38 
39 // TODO:
40 // - passing of cache to QgsVectorLayer
41 
42 
44  : QgsMapLayerRenderer( layer->id() )
45  , mContext( context )
46  , mFields( layer->fields() )
47  , mRendererV2( 0 )
48  , mCache( 0 )
49  , mLabeling( false )
50  , mDiagrams( false )
51  , mLabelProvider( 0 )
52  , mDiagramProvider( 0 )
53  , mLayerTransparency( 0 )
54 {
55  mSource = new QgsVectorLayerFeatureSource( layer );
56 
57  mRendererV2 = layer->rendererV2() ? layer->rendererV2()->clone() : 0;
59 
60  mDrawVertexMarkers = ( layer->editBuffer() != 0 );
61 
62  mGeometryType = layer->geometryType();
63 
66 
69 
70  QSettings settings;
71  mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
72 
73  QString markerTypeString = settings.value( "/qgis/digitizing/marker_style", "Cross" ).toString();
74  if ( markerTypeString == "Cross" )
75  {
77  }
78  else if ( markerTypeString == "SemiTransparentCircle" )
79  {
81  }
82  else
83  {
85  }
86 
87  mVertexMarkerSize = settings.value( "/qgis/digitizing/marker_size", 3 ).toInt();
88 
89  if ( !mRendererV2 )
90  return;
91 
92  QgsDebugMsg( "rendering v2:\n " + mRendererV2->dump() );
93 
94  if ( mDrawVertexMarkers )
95  {
96  // set editing vertex markers style
98  }
99 
101 
103 
104  //register label and diagram layer to the labeling engine
105  prepareLabeling( layer, mAttrNames );
106  prepareDiagrams( layer, mAttrNames );
107 
108 }
109 
110 
112 {
113  delete mRendererV2;
114  delete mSource;
115 }
116 
117 
119 {
121  return true;
122 
123  if ( !mRendererV2 )
124  {
125  mErrors.append( QObject::tr( "No renderer for drawing." ) );
126  return false;
127  }
128 
129  bool usingEffect = false;
131  {
132  usingEffect = true;
134  }
135 
136  // Per feature blending mode
137  if ( mContext.useAdvancedEffects() && mFeatureBlendMode != QPainter::CompositionMode_SourceOver )
138  {
139  // set the painter to the feature blend mode, so that features drawn
140  // on this layer will interact and blend with each other
142  }
143 
145 
146  QString rendererFilter = mRendererV2->filter();
147 
148  QgsRectangle requestExtent = mContext.extent();
149  mRendererV2->modifyRequestExtent( requestExtent, mContext );
150 
151  QgsFeatureRequest featureRequest = QgsFeatureRequest()
152  .setFilterRect( requestExtent )
154 
155  if ( !rendererFilter.isEmpty() )
156  {
157  featureRequest.setFilterExpression( rendererFilter );
158  featureRequest.setExpressionContext( mContext.expressionContext() );
159  }
160 
161  // enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
162  if ( mSimplifyGeometry )
163  {
164  double map2pixelTol = mSimplifyMethod.threshold();
165  bool validTransform = true;
166 
167  const QgsMapToPixel& mtp = mContext.mapToPixel();
168  map2pixelTol *= mtp.mapUnitsPerPixel();
170 
171  // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
172  if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
173  {
174  try
175  {
176  QgsPoint center = mContext.extent().center();
177  double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
178 
179  QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
180  QgsRectangle targetRect = ct->transform( sourceRect );
181 
182  QgsDebugMsg( QString( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ) );
183  QgsDebugMsg( QString( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
184 
185  if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
186  {
187  QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
188  QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
189  QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
190  QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
191 
192  double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
193  double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
194 
195  QgsDebugMsg( QString( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
196  QgsDebugMsg( QString( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
197 
198  if ( targetHypothenuse != 0 )
199  map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
200  }
201  }
202  catch ( QgsCsException &cse )
203  {
204  QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
205  validTransform = false;
206  }
207  }
208 
209  if ( validTransform )
210  {
211  QgsSimplifyMethod simplifyMethod;
213  simplifyMethod.setTolerance( map2pixelTol );
215 
216  featureRequest.setSimplifyMethod( simplifyMethod );
217 
219  mContext.setVectorSimplifyMethod( vectorMethod );
220  }
221  else
222  {
223  QgsVectorSimplifyMethod vectorMethod;
225  mContext.setVectorSimplifyMethod( vectorMethod );
226  }
227  }
228  else
229  {
230  QgsVectorSimplifyMethod vectorMethod;
232  mContext.setVectorSimplifyMethod( vectorMethod );
233  }
234 
235  QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
236 
238  drawRendererV2Levels( fit );
239  else
240  drawRendererV2( fit );
241 
242  if ( usingEffect )
243  {
245  }
246 
247  //apply layer transparency for vector layers
249  {
250  // a layer transparency has been set, so update the alpha for the flattened layer
251  // by combining it with the layer transparency
252  QColor transparentFillColor = QColor( 0, 0, 0, 255 - ( 255 * mLayerTransparency / 100 ) );
253  // use destination in composition mode to merge source's alpha with destination
254  mContext.painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
256  mContext.painter()->device()->height(), transparentFillColor );
257  }
258 
259  return true;
260 }
261 
263 {
264  mCache = cache;
265 
266  if ( mCache )
267  {
268  // Destroy all cached geometries and clear the references to them
270  }
271 }
272 
273 
274 
275 void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )
276 {
277  QgsFeature fet;
278  while ( fit.nextFeature( fet ) )
279  {
280  try
281  {
282  if ( !fet.constGeometry() )
283  continue; // skip features without geometry
284 
285  if ( mContext.renderingStopped() )
286  {
287  QgsDebugMsg( QString( "Drawing of vector layer %1 cancelled." ).arg( layerID() ) );
288  break;
289  }
290 
292 
293  bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fet.id() );
294  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
295 
296  if ( mCache )
297  {
298  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
299  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
300  }
301 
302  // render feature
303  bool rendered = mRendererV2->renderFeature( fet, mContext, -1, sel, drawMarker );
304 
305  // labeling - register feature
306  Q_UNUSED( rendered );
307  if ( rendered && mContext.labelingEngine() )
308  {
309  if ( mLabeling )
310  {
312  }
313  if ( mDiagrams )
314  {
316  }
317  }
318  // new labeling engine
319  if ( rendered && mContext.labelingEngineV2() )
320  {
321  if ( mLabelProvider )
322  {
324  }
325  if ( mDiagramProvider )
326  {
328  }
329  }
330  }
331  catch ( const QgsCsException &cse )
332  {
333  Q_UNUSED( cse );
334  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
335  .arg( fet.id() ).arg( cse.what() ) );
336  }
337  }
338 
339  stopRendererV2( NULL );
340 }
341 
342 void QgsVectorLayerRenderer::drawRendererV2Levels( QgsFeatureIterator& fit )
343 {
344  QHash< QgsSymbolV2*, QList<QgsFeature> > features; // key = symbol, value = array of features
345 
346  QgsSingleSymbolRendererV2* selRenderer = NULL;
347  if ( !mSelectedFeatureIds.isEmpty() )
348  {
350  selRenderer->symbol()->setColor( mContext.selectionColor() );
352  selRenderer->startRender( mContext, mFields );
353  }
354 
355  // 1. fetch features
356  QgsFeature fet;
357  while ( fit.nextFeature( fet ) )
358  {
359  if ( !fet.constGeometry() )
360  continue; // skip features without geometry
361 
362  if ( mContext.renderingStopped() )
363  {
364  qDebug( "rendering stop!" );
365  stopRendererV2( selRenderer );
366  return;
367  }
368 
371  if ( !sym )
372  {
373  continue;
374  }
375 
376  if ( !features.contains( sym ) )
377  {
378  features.insert( sym, QList<QgsFeature>() );
379  }
380  features[sym].append( fet );
381 
382  if ( mCache )
383  {
384  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
385  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
386  }
387 
388  if ( mContext.labelingEngine() )
389  {
391  if ( mLabeling )
392  {
394  }
395  if ( mDiagrams )
396  {
398  }
399  }
400  // new labeling engine
401  if ( mContext.labelingEngineV2() )
402  {
403  if ( mLabelProvider )
404  {
406  }
407  if ( mDiagramProvider )
408  {
410  }
411  }
412  }
413 
414  // find out the order
415  QgsSymbolV2LevelOrder levels;
417  for ( int i = 0; i < symbols.count(); i++ )
418  {
419  QgsSymbolV2* sym = symbols[i];
420  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
421  {
422  int level = sym->symbolLayer( j )->renderingPass();
423  if ( level < 0 || level >= 1000 ) // ignore invalid levels
424  continue;
425  QgsSymbolV2LevelItem item( sym, j );
426  while ( level >= levels.count() ) // append new empty levels
427  levels.append( QgsSymbolV2Level() );
428  levels[level].append( item );
429  }
430  }
431 
432  // 2. draw features in correct order
433  for ( int l = 0; l < levels.count(); l++ )
434  {
435  QgsSymbolV2Level& level = levels[l];
436  for ( int i = 0; i < level.count(); i++ )
437  {
438  QgsSymbolV2LevelItem& item = level[i];
439  if ( !features.contains( item.symbol() ) )
440  {
441  QgsDebugMsg( "level item's symbol not found!" );
442  continue;
443  }
444  int layer = item.layer();
445  QList<QgsFeature>& lst = features[item.symbol()];
447  for ( fit = lst.begin(); fit != lst.end(); ++fit )
448  {
449  if ( mContext.renderingStopped() )
450  {
451  stopRendererV2( selRenderer );
452  return;
453  }
454 
455  bool sel = mSelectedFeatureIds.contains( fit->id() );
456  // maybe vertex markers should be drawn only during the last pass...
457  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
458 
460 
461  try
462  {
463  mRendererV2->renderFeature( *fit, mContext, layer, sel, drawMarker );
464  }
465  catch ( const QgsCsException &cse )
466  {
467  Q_UNUSED( cse );
468  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
469  .arg( fet.id() ).arg( cse.what() ) );
470  }
471  }
472  }
473  }
474 
475  stopRendererV2( selRenderer );
476 }
477 
478 
479 void QgsVectorLayerRenderer::stopRendererV2( QgsSingleSymbolRendererV2* selRenderer )
480 {
482  if ( selRenderer )
483  {
484  selRenderer->stopRender( mContext );
485  delete selRenderer;
486  }
487 }
488 
489 
490 
491 
492 void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames )
493 {
494  if ( !mContext.labelingEngine() )
495  {
496  if ( QgsLabelingEngineV2* engine2 = mContext.labelingEngineV2() )
497  {
498  if ( layer->labeling() )
499  {
500  mLabelProvider = layer->labeling()->provider( layer );
501  if ( mLabelProvider )
502  {
503  engine2->addProvider( mLabelProvider );
504  if ( !mLabelProvider->prepare( mContext, attributeNames ) )
505  {
506  engine2->removeProvider( mLabelProvider );
507  mLabelProvider = 0; // deleted by engine
508  }
509  }
510  }
511  }
512  return;
513  }
514 
515  if ( mContext.labelingEngine()->prepareLayer( layer, attributeNames, mContext ) )
516  {
517  mLabeling = true;
518 
519 #if 0 // TODO: limit of labels, font not found
521 
522  // see if feature count limit is set for labeling
523  if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
524  {
525  QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
526  .setFilterRect( mContext.extent() )
527  .setSubsetOfAttributes( QgsAttributeList() ) );
528 
529  // total number of features that may be labeled
530  QgsFeature f;
531  int nFeatsToLabel = 0;
532  while ( fit.nextFeature( f ) )
533  {
534  nFeatsToLabel++;
535  }
536  palyr.mFeaturesToLabel = nFeatsToLabel;
537  }
538 
539  // notify user about any font substitution
540  if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
541  {
542  emit labelingFontNotFound( this, palyr.mTextFontFamily );
543  mLabelFontNotFoundNotified = true;
544  }
545 #endif
546  }
547 }
548 
549 void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames )
550 {
551  if ( !mContext.labelingEngine() )
552  {
553  if ( QgsLabelingEngineV2* engine2 = mContext.labelingEngineV2() )
554  {
555  if ( layer->diagramsEnabled() )
556  {
558  // need to be added before calling prepare() - uses map settings from engine
559  engine2->addProvider( mDiagramProvider );
560  if ( !mDiagramProvider->prepare( mContext, attributeNames ) )
561  {
562  engine2->removeProvider( mDiagramProvider );
563  mDiagramProvider = 0; // deleted by engine
564  }
565  }
566  }
567  return;
568  }
569 
570  if ( !layer->diagramsEnabled() )
571  return;
572 
573  mDiagrams = true;
574 
575  mContext.labelingEngine()->prepareDiagramLayer( layer, attributeNames, mContext ); // will make internal copy of diagSettings + initialize it
576 
577 }
QgsFeatureId id() const
Get the feature ID for this feature.
Definition: qgsfeature.cpp:53
const QgsCoordinateReferenceSystem & sourceCrs() const
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures...
bool isEmpty() const
test if rectangle is empty.
iterator insert(const Key &key, const T &value)
float threshold() const
Gets the simplification threshold of the vector layer managed.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)=0
called when starting rendering of a layer
void fillRect(const QRectF &rectangle, const QBrush &brush)
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
void setCompositionMode(CompositionMode mode)
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
QColor selectionColor() const
virtual void stopRender(QgsRenderContext &context) override
virtual QString dump() const
for debugging
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:196
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
The geometries can be simplified using the current map2pixel context state.
virtual void registerFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context, const QString &dxfLayer=QString::null)=0
called for every feature
virtual Q_DECL_DEPRECATED QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
virtual int prepareDiagramLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)
adds a diagram layer to the labeling engine
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
virtual QString filter()
If a renderer does not require all the features this method may be overridden and return an expressio...
void setGeometryCachePointer(QgsGeometryCache *cache)
where to save the cached geometries
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
bool enabled() const
Returns whether the effect is enabled.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QPainter::CompositionMode mFeatureBlendMode
The QgsLabelingEngineV2 class provides map labeling functionality.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
const QgsRectangle & extent() const
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
QgsPoint transform(const QgsPoint &p, TransformDirection direction=ForwardTransform) const
Transform the point from Source Coordinate System to Destination Coordinate System If the direction i...
virtual QList< QString > usedAttributes()=0
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:176
const QgsCoordinateTransform * coordinateTransform() const
void setCachedGeometriesRect(const QgsRectangle &extent)
QgsVectorSimplifyMethod mSimplifyMethod
void setSimplifyHints(const SimplifyHints &simplifyHints)
Sets the simplification hints of the vector layer managed.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
QString tr(const char *sourceText, const char *disambiguation, int n)
bool mLabeling
used with old labeling engine (QgsPalLabeling): whether labeling is enabled
double x() const
Get the x value of the point.
Definition: qgspoint.h:126
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QString layerID() const
Get access to the ID of the layer rendered by this class.
virtual void stopRender(QgsRenderContext &context)=0
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
int width() const
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
void setColor(const QColor &color)
Simplify using the map2pixel data to optimize the rendering of geometries.
virtual QgsFeatureRendererV2 * clone() const =0
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
No simplification can be applied.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
void append(const T &value)
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
QgsLabelingEngineV2 * labelingEngineV2() const
Get access to new labeling engine (may be NULL)
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:201
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:186
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
bool renderingStopped() const
QgsVectorLayerLabelProvider * mLabelProvider
used with new labeling engine (QgsLabelingEngineV2): provider for labels.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
void setTolerance(double tolerance)
Sets the tolerance of simplification. Represents the maximum distance between two coordinates which c...
bool isEmpty() const
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
QPaintDevice * device() const
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsVectorLayerFeatureSource * mSource
QList< int > QgsAttributeList
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:122
double mapUnitsPerPixel() const
Return current map units per pixel.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QgsFeatureRendererV2 * mRendererV2
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
for symbol levels
A class to represent a point.
Definition: qgspoint.h:63
bool drawEditingInformation() const
iterator end()
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
int renderingPass() const
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
bool contains(const T &value) const
int layerTransparency() const
Returns the current transparency for the vector layer.
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
virtual bool render() override
Do the rendering (based on data stored in the class)
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context)
called for every diagram feature
QString what() const
Definition: qgsexception.h:35
QVariant value(const QString &key, const QVariant &defaultValue) const
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
QPainter * painter()
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request) override
Get an iterator for features matching the specified request.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
QGis::GeometryType mGeometryType
void setMethodType(MethodType methodType)
Sets the simplification type.
QgsSymbolV2 * symbol()
Definition: qgsrendererv2.h:57
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
bool usingSymbolLevels() const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Definition: qgsfeature.cpp:70
void cacheGeometry(QgsFeatureId fid, const QgsGeometry &geom)
store a geometry in the cache
Class for doing transforms between two map coordinate systems.
bool toBool() const
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
bool isEmpty() const
const QgsMapToPixel & mapToPixel() const
double y() const
Get the y value of the point.
Definition: qgspoint.h:134
Base class for utility classes that encapsulate information necessary for rendering of map layers...
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
bool contains(const Key &key) const
Custom exception class for Coordinate Reference System related exceptions.
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
int height() const
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
QgsVectorLayerDiagramProvider * mDiagramProvider
used with new labeling engine (QgsLabelingEngineV2): provider for diagrams.
Represents a vector layer which manages a vector based data sets.
bool geographicFlag() const
Get this Geographic? flag.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
virtual void startRender(QgsRenderContext &context, const QgsFields &fields) override
Needs to be called when a new render cycle is started.
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:191
QString toString() const
QgsPoint center() const
Center point of the rectangle.
Definition: qgsrectangle.h:216
iterator begin()
bool mDiagrams
used with new labeling engine (QgsPalLabeling): whether diagrams are enabled
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const =0
Factory for label provider implementation.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
QgsLabelingEngineInterface * labelingEngine() const