QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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"
36 
37 #include <QSettings>
38 #include <QPicture>
39 
40 // TODO:
41 // - passing of cache to QgsVectorLayer
42 
43 
45  : QgsMapLayerRenderer( layer->id() )
46  , mContext( context )
47  , mInterruptionChecker( context )
48  , mLayer( layer )
49  , mFields( layer->fields() )
50  , mRendererV2( nullptr )
51  , mCache( nullptr )
52  , mLabeling( false )
53  , mDiagrams( false )
54  , mLabelProvider( nullptr )
55  , mDiagramProvider( nullptr )
56 {
57  mSource = new QgsVectorLayerFeatureSource( layer );
58 
59  mRendererV2 = layer->rendererV2() ? layer->rendererV2()->clone() : nullptr;
61 
62  mDrawVertexMarkers = nullptr != layer->editBuffer();
63 
64  mGeometryType = layer->geometryType();
65 
67 
70 
71  QSettings settings;
72  mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
73 
74  QString markerTypeString = settings.value( "/qgis/digitizing/marker_style", "Cross" ).toString();
75  if ( markerTypeString == "Cross" )
76  {
78  }
79  else if ( markerTypeString == "SemiTransparentCircle" )
80  {
82  }
83  else
84  {
86  }
87 
88  mVertexMarkerSize = settings.value( "/qgis/digitizing/marker_size", 3 ).toInt();
89 
90  if ( !mRendererV2 )
91  return;
92 
93  QgsDebugMsg( "rendering v2:\n " + mRendererV2->dump() );
94 
95  if ( mDrawVertexMarkers )
96  {
97  // set editing vertex markers style
99  }
100 
102 
104 
105  //register label and diagram layer to the labeling engine
106  prepareLabeling( layer, mAttrNames );
107  prepareDiagrams( layer, mAttrNames );
108 
109 }
110 
111 
113 {
114  delete mRendererV2;
115  delete mSource;
116 }
117 
118 
120 {
122  return true;
123 
124  if ( !mRendererV2 )
125  {
126  mErrors.append( QObject::tr( "No renderer for drawing." ) );
127  return false;
128  }
129 
130  bool usingEffect = false;
132  {
133  usingEffect = true;
135  }
136 
137  // Per feature blending mode
138  if ( mContext.useAdvancedEffects() && mFeatureBlendMode != QPainter::CompositionMode_SourceOver )
139  {
140  // set the painter to the feature blend mode, so that features drawn
141  // on this layer will interact and blend with each other
143  }
144 
146 
147  QString rendererFilter = mRendererV2->filter( mFields );
148 
149  QgsRectangle requestExtent = mContext.extent();
150  mRendererV2->modifyRequestExtent( requestExtent, mContext );
151 
152  QgsFeatureRequest featureRequest = QgsFeatureRequest()
153  .setFilterRect( requestExtent )
156  if ( mRendererV2->orderByEnabled() )
157  {
158  featureRequest.setOrderBy( mRendererV2->orderBy() );
159  }
160 
161  const QgsFeatureFilterProvider* featureFilterProvider = mContext.featureFilterProvider();
162  if ( featureFilterProvider )
163  {
164  featureFilterProvider->filterFeatures( mLayer, featureRequest );
165  }
166  if ( !rendererFilter.isEmpty() && rendererFilter != "TRUE" )
167  {
168  featureRequest.combineFilterExpression( rendererFilter );
169  }
170 
171  // enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
172  if ( mSimplifyGeometry )
173  {
174  double map2pixelTol = mSimplifyMethod.threshold();
175  bool validTransform = true;
176 
177  const QgsMapToPixel& mtp = mContext.mapToPixel();
178  map2pixelTol *= mtp.mapUnitsPerPixel();
180 
181  // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
182  if ( ct && !( ct->isShortCircuited() ) )
183  {
184  try
185  {
186  QgsPoint center = mContext.extent().center();
187  double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
188 
189  QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
190  QgsRectangle targetRect = ct->transform( sourceRect );
191 
192  QgsDebugMsg( QString( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ) );
193  QgsDebugMsg( QString( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
194 
195  if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
196  {
197  QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
198  QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
199  QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
200  QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
201 
202  double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
203  double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
204 
205  QgsDebugMsg( QString( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
206  QgsDebugMsg( QString( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
207 
208  if ( !qgsDoubleNear( targetHypothenuse, 0.0 ) )
209  map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
210  }
211  }
212  catch ( QgsCsException &cse )
213  {
214  QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
215  validTransform = false;
216  }
217  }
218 
219  if ( validTransform )
220  {
221  QgsSimplifyMethod simplifyMethod;
223  simplifyMethod.setTolerance( map2pixelTol );
224  simplifyMethod.setThreshold( mSimplifyMethod.threshold() );
226  featureRequest.setSimplifyMethod( simplifyMethod );
227 
229  vectorMethod.setTolerance( map2pixelTol );
230  mContext.setVectorSimplifyMethod( vectorMethod );
231  }
232  else
233  {
234  QgsVectorSimplifyMethod vectorMethod;
236  mContext.setVectorSimplifyMethod( vectorMethod );
237  }
238  }
239  else
240  {
241  QgsVectorSimplifyMethod vectorMethod;
243  mContext.setVectorSimplifyMethod( vectorMethod );
244  }
245 
246  QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
247  // Attach an interruption checker so that iterators that have potentially
248  // slow fetchFeature() implementations, such as in the WFS provider, can
249  // check it, instead of relying on just the mContext.renderingStopped() check
250  // in drawRendererV2()
252 
254  drawRendererV2Levels( fit );
255  else
256  drawRendererV2( fit );
257 
258  if ( usingEffect )
259  {
261  }
262 
263  return true;
264 }
265 
267 {
268  mCache = cache;
269 
270  if ( mCache )
271  {
272  // Destroy all cached geometries and clear the references to them
274  }
275 }
276 
277 
278 
279 void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )
280 {
282  mContext.expressionContext().appendScope( symbolScope );
283 
284  QgsFeature fet;
285  while ( fit.nextFeature( fet ) )
286  {
287  try
288  {
289  if ( mContext.renderingStopped() )
290  {
291  QgsDebugMsg( QString( "Drawing of vector layer %1 cancelled." ).arg( layerID() ) );
292  break;
293  }
294 
295  if ( !fet.constGeometry() )
296  continue; // skip features without geometry
297 
299 
300  bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fet.id() );
301  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
302 
303  if ( mCache )
304  {
305  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
306  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
307  }
308 
309  // render feature
310  bool rendered = mRendererV2->renderFeature( fet, mContext, -1, sel, drawMarker );
311 
312  // labeling - register feature
313  if ( rendered )
314  {
315  if ( mContext.labelingEngine() )
316  {
317  if ( mLabeling )
318  {
320  }
321  if ( mDiagrams )
322  {
324  }
325  }
326  // new labeling engine
328  {
329  QScopedPointer<QgsGeometry> obstacleGeometry;
331 
332  if ( !symbols.isEmpty() && fet.constGeometry()->type() == QGis::Point )
333  {
334  obstacleGeometry.reset( QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, mContext, symbols ) );
335  }
336 
337  if ( !symbols.isEmpty() )
338  {
339  QgsExpressionContextUtils::updateSymbolScope( symbols.at( 0 ), symbolScope );
340  }
341 
342  if ( mLabelProvider )
343  {
344  mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
345  }
346  if ( mDiagramProvider )
347  {
348  mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
349  }
350  }
351  }
352  }
353  catch ( const QgsCsException &cse )
354  {
355  Q_UNUSED( cse );
356  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
357  .arg( fet.id() ).arg( cse.what() ) );
358  }
359  }
360 
362 
363  stopRendererV2( nullptr );
364 }
365 
366 void QgsVectorLayerRenderer::drawRendererV2Levels( QgsFeatureIterator& fit )
367 {
368  QHash< QgsSymbolV2*, QList<QgsFeature> > features; // key = symbol, value = array of features
369 
370  QgsSingleSymbolRendererV2* selRenderer = nullptr;
371  if ( !mSelectedFeatureIds.isEmpty() )
372  {
374  selRenderer->symbol()->setColor( mContext.selectionColor() );
376  selRenderer->startRender( mContext, mFields );
377  }
378 
380  mContext.expressionContext().appendScope( symbolScope );
381 
382  // 1. fetch features
383  QgsFeature fet;
384  while ( fit.nextFeature( fet ) )
385  {
386  if ( mContext.renderingStopped() )
387  {
388  qDebug( "rendering stop!" );
389  stopRendererV2( selRenderer );
391  return;
392  }
393 
394  if ( !fet.constGeometry() )
395  continue; // skip features without geometry
396 
399  if ( !sym )
400  {
401  continue;
402  }
403 
404  if ( !features.contains( sym ) )
405  {
406  features.insert( sym, QList<QgsFeature>() );
407  }
408  features[sym].append( fet );
409 
410  if ( mCache )
411  {
412  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
413  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
414  }
415 
416  if ( mContext.labelingEngine() )
417  {
419  if ( mLabeling )
420  {
422  }
423  if ( mDiagrams )
424  {
426  }
427  }
428  // new labeling engine
429  if ( mContext.labelingEngineV2() )
430  {
431  QScopedPointer<QgsGeometry> obstacleGeometry;
433 
434  if ( !symbols.isEmpty() && fet.constGeometry()->type() == QGis::Point )
435  {
436  obstacleGeometry.reset( QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, mContext, symbols ) );
437  }
438 
439  if ( !symbols.isEmpty() )
440  {
441  QgsExpressionContextUtils::updateSymbolScope( symbols.at( 0 ), symbolScope );
442  }
443 
444  if ( mLabelProvider )
445  {
446  mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
447  }
448  if ( mDiagramProvider )
449  {
450  mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
451  }
452  }
453  }
454 
456 
457  // find out the order
458  QgsSymbolV2LevelOrder levels;
460  for ( int i = 0; i < symbols.count(); i++ )
461  {
462  QgsSymbolV2* sym = symbols[i];
463  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
464  {
465  int level = sym->symbolLayer( j )->renderingPass();
466  if ( level < 0 || level >= 1000 ) // ignore invalid levels
467  continue;
468  QgsSymbolV2LevelItem item( sym, j );
469  while ( level >= levels.count() ) // append new empty levels
470  levels.append( QgsSymbolV2Level() );
471  levels[level].append( item );
472  }
473  }
474 
475  // 2. draw features in correct order
476  for ( int l = 0; l < levels.count(); l++ )
477  {
478  QgsSymbolV2Level& level = levels[l];
479  for ( int i = 0; i < level.count(); i++ )
480  {
481  QgsSymbolV2LevelItem& item = level[i];
482  if ( !features.contains( item.symbol() ) )
483  {
484  QgsDebugMsg( "level item's symbol not found!" );
485  continue;
486  }
487  int layer = item.layer();
488  QList<QgsFeature>& lst = features[item.symbol()];
490  for ( fit = lst.begin(); fit != lst.end(); ++fit )
491  {
492  if ( mContext.renderingStopped() )
493  {
494  stopRendererV2( selRenderer );
495  return;
496  }
497 
498  bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fit->id() );
499  // maybe vertex markers should be drawn only during the last pass...
500  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
501 
503 
504  try
505  {
506  mRendererV2->renderFeature( *fit, mContext, layer, sel, drawMarker );
507  }
508  catch ( const QgsCsException &cse )
509  {
510  Q_UNUSED( cse );
511  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
512  .arg( fet.id() ).arg( cse.what() ) );
513  }
514  }
515  }
516  }
517 
518  stopRendererV2( selRenderer );
519 }
520 
521 
522 void QgsVectorLayerRenderer::stopRendererV2( QgsSingleSymbolRendererV2* selRenderer )
523 {
525  if ( selRenderer )
526  {
527  selRenderer->stopRender( mContext );
528  delete selRenderer;
529  }
530 }
531 
532 
533 
534 
535 void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames )
536 {
537  if ( !mContext.labelingEngine() )
538  {
539  if ( QgsLabelingEngineV2* engine2 = mContext.labelingEngineV2() )
540  {
541  if ( layer->labeling() )
542  {
543  mLabelProvider = layer->labeling()->provider( layer );
544  if ( mLabelProvider )
545  {
546  engine2->addProvider( mLabelProvider );
547  if ( !mLabelProvider->prepare( mContext, attributeNames ) )
548  {
549  engine2->removeProvider( mLabelProvider );
550  mLabelProvider = nullptr; // deleted by engine
551  }
552  }
553  }
554  }
555  return;
556  }
557 
558  if ( mContext.labelingEngine()->prepareLayer( layer, attributeNames, mContext ) )
559  {
560  mLabeling = true;
561 
562 #if 0 // TODO: limit of labels, font not found
564 
565  // see if feature count limit is set for labeling
566  if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
567  {
568  QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
569  .setFilterRect( mContext.extent() )
570  .setSubsetOfAttributes( QgsAttributeList() ) );
571 
572  // total number of features that may be labeled
573  QgsFeature f;
574  int nFeatsToLabel = 0;
575  while ( fit.nextFeature( f ) )
576  {
577  nFeatsToLabel++;
578  }
579  palyr.mFeaturesToLabel = nFeatsToLabel;
580  }
581 
582  // notify user about any font substitution
583  if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
584  {
585  emit labelingFontNotFound( this, palyr.mTextFontFamily );
586  mLabelFontNotFoundNotified = true;
587  }
588 #endif
589  }
590 }
591 
592 void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames )
593 {
594  if ( !mContext.labelingEngine() )
595  {
596  if ( QgsLabelingEngineV2* engine2 = mContext.labelingEngineV2() )
597  {
598  if ( layer->diagramsEnabled() )
599  {
601  // need to be added before calling prepare() - uses map settings from engine
602  engine2->addProvider( mDiagramProvider );
603  if ( !mDiagramProvider->prepare( mContext, attributeNames ) )
604  {
605  engine2->removeProvider( mDiagramProvider );
606  mDiagramProvider = nullptr; // deleted by engine
607  }
608  }
609  }
610  return;
611  }
612 
613  if ( !layer->diagramsEnabled() )
614  return;
615 
616  mDiagrams = true;
617 
618  mContext.labelingEngine()->prepareDiagramLayer( layer, attributeNames, mContext ); // will make internal copy of diagSettings + initialize it
619 
620 }
621 
622 /* ----------------------------------------- */
623 /* QgsVectorLayerRendererInterruptionChecker */
624 /* ----------------------------------------- */
625 
627 ( const QgsRenderContext& context )
628  : mContext( context )
629 {
630 }
631 
633 {
634  return mContext.renderingStopped();
635 }
QgsPoint transform(const QgsPoint &p, TransformDirection direction=ForwardTransform) const
Transform the point from Source Coordinate System to Destination Coordinate System If the direction i...
QgsVectorLayerRendererInterruptionChecker mInterruptionChecker
Wrapper for iterator of features from vector data provider or vector layer.
void setThreshold(float threshold)
Sets the simplification threshold in pixels. Represents the maximum distance in pixels between two co...
A rectangle specified with double values.
Definition: qgsrectangle.h:35
QgsPoint center() const
Center point of the rectangle.
Definition: qgsrectangle.h:217
iterator insert(const Key &key, const T &value)
QgsVectorLayer * mLayer
The rendered layer.
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)=0
called when starting rendering of a layer
void setCompositionMode(CompositionMode mode)
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
virtual void stopRender(QgsRenderContext &context) override
Needs to be called when a render cycle has finished to clean up.
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 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 T & at(int i) const
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.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
bool renderingStopped() const
QPainter::CompositionMode mFeatureBlendMode
The QgsLabelingEngineV2 class provides map labeling functionality.
static QgsGeometry * getPointObstacleGeometry(QgsFeature &fet, QgsRenderContext &context, const QgsSymbolV2List &symbols)
Returns the geometry for a point feature which should be used as an obstacle for labels.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Definition: qgsfeature.cpp:82
bool mustStop() const override
return true if the iterator must stop as soon as possible
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
virtual QString filter(const QgsFields &fields=QgsFields())
If a renderer does not require all the features this method may be overridden and return an expressio...
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 qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Definition: qgis.h:353
bool mLabeling
used with old labeling engine (QgsPalLabeling): whether labeling is enabled
virtual void registerFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context)=0
called for every feature
double y() const
Get the y value of the point.
Definition: qgspoint.h:193
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QString what() const
Definition: qgsexception.h:36
void reset(T *other)
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
int renderingPass() 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)
Render a feature using this renderer in the given context.
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.
QgsVectorLayerRendererInterruptionChecker(const QgsRenderContext &context)
Constructor.
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
virtual QString dump() const
for debugging
const QgsCoordinateReferenceSystem & sourceCrs() const
int toInt(bool *ok) const
bool isEmpty() const
test if rectangle is empty.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units.
const QgsRectangle & extent() const
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
QgsVectorLayerLabelProvider * mLabelProvider
used with new labeling engine (QgsLabelingEngineV2): provider for labels.
bool isShortCircuited() const
See if the transform short circuits because src and dest are equivalent.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
QgsLabelingEngineInterface * labelingEngine() const
bool isEmpty() const
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
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)
const QgsCoordinateTransform * coordinateTransform() const
bool drawEditingInformation() const
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsVectorLayerFeatureSource * mSource
QColor selectionColor() const
QList< int > QgsAttributeList
float threshold() const
Gets the simplification threshold of the vector layer managed.
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:134
QgsFeatureRendererV2 * mRendererV2
Abstract interface for use by classes that filter the features of a layer.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
bool enabled() const
Returns whether the effect is enabled.
bool usingSymbolLevels() const
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
Single scope for storing variables and functions for use within a QgsExpressionContext.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
double mapUnitsPerPixel() const
Return current map units per pixel.
A class to represent a point.
Definition: qgspoint.h:117
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures...
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
T * data() const
bool isFinite() const
Returns true if the rectangle has finite boundaries.
iterator end()
QgsFeatureId id() const
Get the feature ID for this feature.
Definition: qgsfeature.cpp:65
const QgsFeatureFilterProvider * featureFilterProvider() const
Get the filter feature provider used for additional filtering of rendered features.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
Partial snapshot of vector layer&#39;s state (only the members necessary for access to features) ...
virtual void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest) const =0
Add additional filters to the feature request to further restrict the features returned by the reques...
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:202
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:187
bool contains(const T &value) const
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsLabelingEngineV2 * labelingEngineV2() const
Get access to new labeling engine (may be nullptr)
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
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
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.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
QPainter * painter()
const QgsMapToPixel & mapToPixel() const
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
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
QString layerID() const
Get access to the ID of the layer rendered by this class.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
void setMethodType(MethodType methodType)
Sets the simplification type.
QgsSymbolV2 * symbol()
Definition: qgsrendererv2.h:64
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
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
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:192
bool isEmpty() const
Base class for utility classes that encapsulate information necessary for rendering of map layers...
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:197
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
bool contains(const Key &key) const
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
Custom exception class for Coordinate Reference System related exceptions.
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
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.
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...
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbolV2 *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbolV2 to an expression context.
QString toString() const
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.
double x() const
Get the x value of the point.
Definition: qgspoint.h:185
void setInterruptionChecker(QgsInterruptionChecker *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped...
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
bool geographicFlag() const
Returns whether the CRS is a geographic CRS.