QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 "diagram/qgsdiagram.h"
19 
20 #include "qgsdiagramrenderer.h"
21 #include "qgsmessagelog.h"
22 #include "qgspallabeling.h"
23 #include "qgsrenderer.h"
24 #include "qgsrendercontext.h"
26 #include "qgssymbollayer.h"
27 #include "qgssymbollayerutils.h"
28 #include "qgssymbol.h"
29 #include "qgsvectorlayer.h"
32 #include "qgsvectorlayerlabeling.h"
34 #include "qgspainteffect.h"
36 #include "qgsexception.h"
37 #include "qgslogger.h"
42 #include "qgsmapclippingutils.h"
44 
45 #include <QPicture>
46 #include <QTimer>
47 
49  : QgsMapLayerRenderer( layer->id(), &context )
50  , mFeedback( std::make_unique< QgsFeedback >() )
51  , mLayer( layer )
52  , mFields( layer->fields() )
53  , mSource( std::make_unique< QgsVectorLayerFeatureSource >( layer ) )
54 {
55  std::unique_ptr< QgsFeatureRenderer > mainRenderer( layer->renderer() ? layer->renderer()->clone() : nullptr );
56 
57  if ( !mainRenderer )
58  return;
59 
60  QList< const QgsFeatureRendererGenerator * > generators = layer->featureRendererGenerators();
61  std::sort( generators.begin(), generators.end(), []( const QgsFeatureRendererGenerator * g1, const QgsFeatureRendererGenerator * g2 )
62  {
63  return g1->level() < g2->level();
64  } );
65 
66  bool insertedMainRenderer = false;
67  double prevLevel = std::numeric_limits< double >::lowest();
68  mRenderer = mainRenderer.get();
69  for ( const QgsFeatureRendererGenerator *generator : std::as_const( generators ) )
70  {
71  if ( generator->level() >= 0 && prevLevel < 0 && !insertedMainRenderer )
72  {
73  // insert main renderer when level changes from <0 to >0
74  mRenderers.emplace_back( std::move( mainRenderer ) );
75  insertedMainRenderer = true;
76  }
77  mRenderers.emplace_back( generator->createRenderer() );
78  prevLevel = generator->level();
79  }
80  // cppcheck-suppress accessMoved
81  if ( mainRenderer )
82  {
83  // cppcheck-suppress accessMoved
84  mRenderers.emplace_back( std::move( mainRenderer ) );
85  }
86 
87  mSelectedFeatureIds = layer->selectedFeatureIds();
88 
89  mDrawVertexMarkers = nullptr != layer->editBuffer();
90 
91  mGeometryType = layer->geometryType();
92 
93  mFeatureBlendMode = layer->featureBlendMode();
94 
95  if ( context.isTemporal() )
96  {
97  QgsVectorLayerTemporalContext temporalContext;
98  temporalContext.setLayer( layer );
99  mTemporalFilter = qobject_cast< const QgsVectorLayerTemporalProperties * >( layer->temporalProperties() )->createFilterString( temporalContext, context.temporalRange() );
100  QgsDebugMsgLevel( "Rendering with Temporal Filter: " + mTemporalFilter, 2 );
101  }
102 
103  // if there's already a simplification method specified via the context, we respect that. Otherwise, we fall back
104  // to the layer's individual setting
105  if ( renderContext()->vectorSimplifyMethod().simplifyHints() != QgsVectorSimplifyMethod::NoSimplification )
106  {
107  mSimplifyMethod = renderContext()->vectorSimplifyMethod();
110  }
111  else
112  {
113  mSimplifyMethod = layer->simplifyMethod();
115  }
116 
118 
120  if ( markerTypeString == QLatin1String( "Cross" ) )
121  {
122  mVertexMarkerStyle = Qgis::VertexMarkerType::Cross;
123  }
124  else if ( markerTypeString == QLatin1String( "SemiTransparentCircle" ) )
125  {
127  }
128  else
129  {
130  mVertexMarkerStyle = Qgis::VertexMarkerType::NoMarker;
131  }
132 
134 
135  QgsDebugMsgLevel( "rendering v2:\n " + mRenderer->dump(), 2 );
136 
137  if ( mDrawVertexMarkers )
138  {
139  // set editing vertex markers style (main renderer only)
140  mRenderer->setVertexMarkerAppearance( mVertexMarkerStyle, mVertexMarkerSize );
141  }
143 
144  for ( const std::unique_ptr< QgsFeatureRenderer > &renderer : mRenderers )
145  {
146  mAttrNames.unite( renderer->usedAttributes( context ) );
147  }
148  if ( context.hasRenderedFeatureHandlers() )
149  {
150  const QList< QgsRenderedFeatureHandlerInterface * > handlers = context.renderedFeatureHandlers();
151  for ( QgsRenderedFeatureHandlerInterface *handler : handlers )
152  mAttrNames.unite( handler->usedAttributes( layer, context ) );
153  }
154 
155  //register label and diagram layer to the labeling engine
156  prepareLabeling( layer, mAttrNames );
157  prepareDiagrams( layer, mAttrNames );
158 
159  mClippingRegions = QgsMapClippingUtils::collectClippingRegionsForLayer( context, layer );
160 
161  if ( std::any_of( mRenderers.begin(), mRenderers.end(), []( const auto & renderer ) { return renderer->forceRasterRender(); } ) )
162  {
163  //raster rendering is forced for this layer
164  mForceRasterRender = true;
165  }
166 
168  ( ( layer->blendMode() != QPainter::CompositionMode_SourceOver )
169  || ( layer->featureBlendMode() != QPainter::CompositionMode_SourceOver )
170  || ( !qgsDoubleNear( layer->opacity(), 1.0 ) ) ) )
171  {
172  //layer properties require rasterization
173  mForceRasterRender = true;
174  }
175 
176  mReadyToCompose = false;
177 }
178 
180 
182 {
183  mRenderTimeHint = time;
184 }
185 
187 {
188  return mFeedback.get();
189 }
190 
192 {
193  return mForceRasterRender;
194 }
195 
197 {
198  if ( mGeometryType == QgsWkbTypes::NullGeometry || mGeometryType == QgsWkbTypes::UnknownGeometry )
199  {
200  mReadyToCompose = true;
201  return true;
202  }
203 
204  if ( mRenderers.empty() )
205  {
206  mReadyToCompose = true;
207  mErrors.append( QObject::tr( "No renderer for drawing." ) );
208  return false;
209  }
210 
211  // if the previous layer render was relatively quick (e.g. less than 3 seconds), the we show any previously
212  // cached version of the layer during rendering instead of the usual progressive updates
213  if ( mRenderTimeHint > 0 && mRenderTimeHint <= MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE )
214  {
215  mBlockRenderUpdates = true;
216  mElapsedTimer.start();
217  }
218 
219  bool res = true;
220  for ( const std::unique_ptr< QgsFeatureRenderer > &renderer : mRenderers )
221  {
222  res = renderInternal( renderer.get() ) && res;
223  }
224 
225  mReadyToCompose = true;
226  return res && !renderContext()->renderingStopped();
227 }
228 
229 bool QgsVectorLayerRenderer::renderInternal( QgsFeatureRenderer *renderer )
230 {
231  const bool isMainRenderer = renderer == mRenderer;
232 
233  QgsRenderContext &context = *renderContext();
234  context.setSymbologyReferenceScale( renderer->referenceScale() );
235 
236  if ( renderer->type() == QLatin1String( "nullSymbol" ) )
237  {
238  // a little shortcut for the null symbol renderer - most of the time it is not going to render anything
239  // so we can even skip the whole loop to fetch features
240  if ( !isMainRenderer ||
241  ( !mDrawVertexMarkers && !mLabelProvider && !mDiagramProvider && mSelectedFeatureIds.isEmpty() ) )
242  return true;
243  }
244 
245  QgsScopedQPainterState painterState( context.painter() );
246 
247  bool usingEffect = false;
248  if ( renderer->paintEffect() && renderer->paintEffect()->enabled() )
249  {
250  usingEffect = true;
251  renderer->paintEffect()->begin( context );
252  }
253 
254  // Per feature blending mode
255  if ( context.useAdvancedEffects() && mFeatureBlendMode != QPainter::CompositionMode_SourceOver )
256  {
257  // set the painter to the feature blend mode, so that features drawn
258  // on this layer will interact and blend with each other
259  context.painter()->setCompositionMode( mFeatureBlendMode );
260  }
261 
262  renderer->startRender( context, mFields );
263 
264  QString rendererFilter = renderer->filter( mFields );
265 
266  QgsRectangle requestExtent = context.extent();
267  if ( !mClippingRegions.empty() )
268  {
269  mClipFilterGeom = QgsMapClippingUtils::calculateFeatureRequestGeometry( mClippingRegions, context, mApplyClipFilter );
270  requestExtent = requestExtent.intersect( mClipFilterGeom.boundingBox() );
271 
272  mClipFeatureGeom = QgsMapClippingUtils::calculateFeatureIntersectionGeometry( mClippingRegions, context, mApplyClipGeometries );
273 
274  bool needsPainterClipPath = false;
275  const QPainterPath path = QgsMapClippingUtils::calculatePainterClipRegion( mClippingRegions, context, QgsMapLayerType::VectorLayer, needsPainterClipPath );
276  if ( needsPainterClipPath )
277  context.painter()->setClipPath( path, Qt::IntersectClip );
278 
279  mLabelClipFeatureGeom = QgsMapClippingUtils::calculateLabelIntersectionGeometry( mClippingRegions, context, mApplyLabelClipGeometries );
280 
281  if ( mDiagramProvider )
282  mDiagramProvider->setClipFeatureGeometry( mLabelClipFeatureGeom );
283  }
284  renderer->modifyRequestExtent( requestExtent, context );
285 
286  QgsFeatureRequest featureRequest = QgsFeatureRequest()
287  .setFilterRect( requestExtent )
288  .setSubsetOfAttributes( mAttrNames, mFields )
290  if ( renderer->orderByEnabled() )
291  {
292  featureRequest.setOrderBy( renderer->orderBy() );
293  }
294 
295  const QgsFeatureFilterProvider *featureFilterProvider = context.featureFilterProvider();
296  if ( featureFilterProvider )
297  {
298  featureFilterProvider->filterFeatures( mLayer, featureRequest );
299  }
300  if ( !rendererFilter.isEmpty() && rendererFilter != QLatin1String( "TRUE" ) )
301  {
302  featureRequest.combineFilterExpression( rendererFilter );
303  }
304  if ( !mTemporalFilter.isEmpty() )
305  {
306  featureRequest.combineFilterExpression( mTemporalFilter );
307  }
308 
309  if ( renderer->usesEmbeddedSymbols() )
310  {
311  featureRequest.setFlags( featureRequest.flags() | QgsFeatureRequest::EmbeddedSymbols );
312  }
313 
314  // enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
315  if ( mSimplifyGeometry )
316  {
317  double map2pixelTol = mSimplifyMethod.threshold();
318  bool validTransform = true;
319 
320  const QgsMapToPixel &mtp = context.mapToPixel();
321  map2pixelTol *= mtp.mapUnitsPerPixel();
322  const QgsCoordinateTransform ct = context.coordinateTransform();
323 
324  // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
325  if ( ct.isValid() && !ct.isShortCircuited() )
326  {
327  try
328  {
329  QgsCoordinateTransform toleranceTransform = ct;
330  QgsPointXY center = context.extent().center();
331  double rectSize = toleranceTransform.sourceCrs().mapUnits() == QgsUnitTypes::DistanceDegrees ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
332 
333  QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
334  toleranceTransform.setBallparkTransformsAreAppropriate( true );
335  QgsRectangle targetRect = toleranceTransform.transform( sourceRect );
336 
337  QgsDebugMsgLevel( QStringLiteral( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ), 4 );
338  QgsDebugMsgLevel( QStringLiteral( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ), 4 );
339 
340  if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
341  {
342  QgsPointXY minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
343  QgsPointXY maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
344  QgsPointXY minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
345  QgsPointXY maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
346 
347  double sourceHypothenuse = std::sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
348  double targetHypothenuse = std::sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
349 
350  QgsDebugMsgLevel( QStringLiteral( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ), 4 );
351  QgsDebugMsgLevel( QStringLiteral( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ), 4 );
352 
353  if ( !qgsDoubleNear( targetHypothenuse, 0.0 ) )
354  map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
355  }
356  }
357  catch ( QgsCsException &cse )
358  {
359  QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
360  validTransform = false;
361  }
362  }
363 
364  if ( validTransform )
365  {
366  QgsSimplifyMethod simplifyMethod;
368  simplifyMethod.setTolerance( map2pixelTol );
369  simplifyMethod.setThreshold( mSimplifyMethod.threshold() );
370  simplifyMethod.setForceLocalOptimization( mSimplifyMethod.forceLocalOptimization() );
371  featureRequest.setSimplifyMethod( simplifyMethod );
372 
373  QgsVectorSimplifyMethod vectorMethod = mSimplifyMethod;
374  vectorMethod.setTolerance( map2pixelTol );
375  context.setVectorSimplifyMethod( vectorMethod );
376  }
377  else
378  {
379  QgsVectorSimplifyMethod vectorMethod;
381  context.setVectorSimplifyMethod( vectorMethod );
382  }
383  }
384  else
385  {
386  QgsVectorSimplifyMethod vectorMethod;
388  context.setVectorSimplifyMethod( vectorMethod );
389  }
390 
391  featureRequest.setFeedback( mFeedback.get() );
392  // also set the interruption checker for the expression context, in case the renderer uses some complex expression
393  // which could benefit from early exit paths...
394  context.expressionContext().setFeedback( mFeedback.get() );
395 
396  QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
397  // Attach an interruption checker so that iterators that have potentially
398  // slow fetchFeature() implementations, such as in the WFS provider, can
399  // check it, instead of relying on just the mContext.renderingStopped() check
400  // in drawRenderer()
401  fit.setInterruptionChecker( mFeedback.get() );
402 
403  if ( ( renderer->capabilities() & QgsFeatureRenderer::SymbolLevels ) && renderer->usingSymbolLevels() )
404  drawRendererLevels( renderer, fit );
405  else
406  drawRenderer( renderer, fit );
407 
408  if ( !fit.isValid() )
409  {
410  mErrors.append( QStringLiteral( "Data source invalid" ) );
411  }
412 
413  if ( usingEffect )
414  {
415  renderer->paintEffect()->end( context );
416  }
417 
418  context.expressionContext().setFeedback( nullptr );
419  return true;
420 }
421 
422 
423 void QgsVectorLayerRenderer::drawRenderer( QgsFeatureRenderer *renderer, QgsFeatureIterator &fit )
424 {
425  const bool isMainRenderer = renderer == mRenderer;
426 
428  QgsRenderContext &context = *renderContext();
429  context.expressionContext().appendScope( symbolScope );
430 
431  std::unique_ptr< QgsGeometryEngine > clipEngine;
432  if ( mApplyClipFilter )
433  {
434  clipEngine.reset( QgsGeometry::createGeometryEngine( mClipFilterGeom.constGet() ) );
435  clipEngine->prepareGeometry();
436  }
437 
438  QgsFeature fet;
439  while ( fit.nextFeature( fet ) )
440  {
441  try
442  {
443  if ( context.renderingStopped() )
444  {
445  QgsDebugMsgLevel( QStringLiteral( "Drawing of vector layer %1 canceled." ).arg( layerId() ), 2 );
446  break;
447  }
448 
449  if ( !fet.hasGeometry() || fet.geometry().isEmpty() )
450  continue; // skip features without geometry
451 
452  if ( clipEngine && !clipEngine->intersects( fet.geometry().constGet() ) )
453  continue; // skip features outside of clipping region
454 
455  if ( mApplyClipGeometries )
456  context.setFeatureClipGeometry( mClipFeatureGeom );
457 
458  context.expressionContext().setFeature( fet );
459 
460  bool sel = isMainRenderer && context.showSelection() && mSelectedFeatureIds.contains( fet.id() );
461  bool drawMarker = isMainRenderer && ( mDrawVertexMarkers && context.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
462 
463  // render feature
464  bool rendered = renderer->renderFeature( fet, context, -1, sel, drawMarker );
465 
466  // labeling - register feature
467  if ( rendered )
468  {
469  // as soon as first feature is rendered, we can start showing layer updates.
470  // but if we are blocking render updates (so that a previously cached image is being shown), we wait
471  // at most e.g. 3 seconds before we start forcing progressive updates.
472  if ( !mBlockRenderUpdates || mElapsedTimer.elapsed() > MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE )
473  {
474  mReadyToCompose = true;
475  }
476 
477  // new labeling engine
478  if ( isMainRenderer && context.labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
479  {
480  QgsGeometry obstacleGeometry;
481  QgsSymbolList symbols = renderer->originalSymbolsForFeature( fet, context );
482  QgsSymbol *symbol = nullptr;
483  if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
484  {
485  obstacleGeometry = QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, context, symbols );
486  }
487 
488  if ( !symbols.isEmpty() )
489  {
490  symbol = symbols.at( 0 );
491  QgsExpressionContextUtils::updateSymbolScope( symbol, symbolScope );
492  }
493 
494  if ( mApplyLabelClipGeometries )
495  context.setFeatureClipGeometry( mLabelClipFeatureGeom );
496 
497  if ( mLabelProvider )
498  {
499  mLabelProvider->registerFeature( fet, context, obstacleGeometry, symbol );
500  }
501  if ( mDiagramProvider )
502  {
503  mDiagramProvider->registerFeature( fet, context, obstacleGeometry );
504  }
505 
506  if ( mApplyLabelClipGeometries )
507  context.setFeatureClipGeometry( QgsGeometry() );
508  }
509  }
510  }
511  catch ( const QgsCsException &cse )
512  {
513  Q_UNUSED( cse )
514  QgsDebugMsg( QStringLiteral( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
515  .arg( fet.id() ).arg( cse.what() ) );
516  }
517  }
518 
519  delete context.expressionContext().popScope();
520 
521  stopRenderer( renderer, nullptr );
522 }
523 
524 void QgsVectorLayerRenderer::drawRendererLevels( QgsFeatureRenderer *renderer, QgsFeatureIterator &fit )
525 {
526  const bool isMainRenderer = renderer == mRenderer;
527 
528  QHash< QgsSymbol *, QList<QgsFeature> > features; // key = symbol, value = array of features
529  QgsRenderContext &context = *renderContext();
530 
531  QgsSingleSymbolRenderer *selRenderer = nullptr;
532  if ( !mSelectedFeatureIds.isEmpty() )
533  {
534  selRenderer = new QgsSingleSymbolRenderer( QgsSymbol::defaultSymbol( mGeometryType ) );
535  selRenderer->symbol()->setColor( context.selectionColor() );
536  selRenderer->setVertexMarkerAppearance( mVertexMarkerStyle, mVertexMarkerSize );
537  selRenderer->startRender( context, mFields );
538  }
539 
541  std::unique_ptr< QgsExpressionContextScopePopper > scopePopper = std::make_unique< QgsExpressionContextScopePopper >( context.expressionContext(), symbolScope );
542 
543 
544  std::unique_ptr< QgsGeometryEngine > clipEngine;
545  if ( mApplyClipFilter )
546  {
547  clipEngine.reset( QgsGeometry::createGeometryEngine( mClipFilterGeom.constGet() ) );
548  clipEngine->prepareGeometry();
549  }
550 
551  if ( mApplyLabelClipGeometries )
552  context.setFeatureClipGeometry( mLabelClipFeatureGeom );
553 
554  // 1. fetch features
555  QgsFeature fet;
556  while ( fit.nextFeature( fet ) )
557  {
558  if ( context.renderingStopped() )
559  {
560  qDebug( "rendering stop!" );
561  stopRenderer( renderer, selRenderer );
562  return;
563  }
564 
565  if ( !fet.hasGeometry() )
566  continue; // skip features without geometry
567 
568  if ( clipEngine && !clipEngine->intersects( fet.geometry().constGet() ) )
569  continue; // skip features outside of clipping region
570 
571  context.expressionContext().setFeature( fet );
572  QgsSymbol *sym = renderer->symbolForFeature( fet, context );
573  if ( !sym )
574  {
575  continue;
576  }
577 
578  if ( !features.contains( sym ) )
579  {
580  features.insert( sym, QList<QgsFeature>() );
581  }
582  features[sym].append( fet );
583 
584  // new labeling engine
585  if ( isMainRenderer && context.labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
586  {
587  QgsGeometry obstacleGeometry;
588  QgsSymbolList symbols = renderer->originalSymbolsForFeature( fet, context );
589  QgsSymbol *symbol = nullptr;
590  if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
591  {
592  obstacleGeometry = QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, context, symbols );
593  }
594 
595  if ( !symbols.isEmpty() )
596  {
597  symbol = symbols.at( 0 );
598  QgsExpressionContextUtils::updateSymbolScope( symbol, symbolScope );
599  }
600 
601  if ( mLabelProvider )
602  {
603  mLabelProvider->registerFeature( fet, context, obstacleGeometry, symbol );
604  }
605  if ( mDiagramProvider )
606  {
607  mDiagramProvider->registerFeature( fet, context, obstacleGeometry );
608  }
609  }
610  }
611 
612  if ( mApplyLabelClipGeometries )
613  context.setFeatureClipGeometry( QgsGeometry() );
614 
615  scopePopper.reset();
616 
617  if ( features.empty() )
618  {
619  // nothing to draw
620  stopRenderer( renderer, selRenderer );
621  return;
622  }
623 
624  // find out the order
625  QgsSymbolLevelOrder levels;
626  QgsSymbolList symbols = renderer->symbols( context );
627  for ( int i = 0; i < symbols.count(); i++ )
628  {
629  QgsSymbol *sym = symbols[i];
630  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
631  {
632  int level = sym->symbolLayer( j )->renderingPass();
633  if ( level < 0 || level >= 1000 ) // ignore invalid levels
634  continue;
635  QgsSymbolLevelItem item( sym, j );
636  while ( level >= levels.count() ) // append new empty levels
637  levels.append( QgsSymbolLevel() );
638  levels[level].append( item );
639  }
640  }
641 
642  if ( mApplyClipGeometries )
643  context.setFeatureClipGeometry( mClipFeatureGeom );
644 
645  // 2. draw features in correct order
646  for ( int l = 0; l < levels.count(); l++ )
647  {
648  QgsSymbolLevel &level = levels[l];
649  for ( int i = 0; i < level.count(); i++ )
650  {
651  QgsSymbolLevelItem &item = level[i];
652  if ( !features.contains( item.symbol() ) )
653  {
654  QgsDebugMsg( QStringLiteral( "level item's symbol not found!" ) );
655  continue;
656  }
657  int layer = item.layer();
658  QList<QgsFeature> &lst = features[item.symbol()];
659  QList<QgsFeature>::iterator fit;
660  for ( fit = lst.begin(); fit != lst.end(); ++fit )
661  {
662  if ( context.renderingStopped() )
663  {
664  stopRenderer( renderer, selRenderer );
665  return;
666  }
667 
668  bool sel = isMainRenderer && context.showSelection() && mSelectedFeatureIds.contains( fit->id() );
669  // maybe vertex markers should be drawn only during the last pass...
670  bool drawMarker = isMainRenderer && ( mDrawVertexMarkers && context.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
671 
672  context.expressionContext().setFeature( *fit );
673 
674  try
675  {
676  renderer->renderFeature( *fit, context, layer, sel, drawMarker );
677 
678  // as soon as first feature is rendered, we can start showing layer updates.
679  // but if we are blocking render updates (so that a previously cached image is being shown), we wait
680  // at most e.g. 3 seconds before we start forcing progressive updates.
681  if ( !mBlockRenderUpdates || mElapsedTimer.elapsed() > MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE )
682  {
683  mReadyToCompose = true;
684  }
685  }
686  catch ( const QgsCsException &cse )
687  {
688  Q_UNUSED( cse )
689  QgsDebugMsg( QStringLiteral( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
690  .arg( fet.id() ).arg( cse.what() ) );
691  }
692  }
693  }
694  }
695 
696  stopRenderer( renderer, selRenderer );
697 }
698 
699 void QgsVectorLayerRenderer::stopRenderer( QgsFeatureRenderer *renderer, QgsSingleSymbolRenderer *selRenderer )
700 {
701  QgsRenderContext &context = *renderContext();
702  renderer->stopRender( context );
703  if ( selRenderer )
704  {
705  selRenderer->stopRender( context );
706  delete selRenderer;
707  }
708 }
709 
710 void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer *layer, QSet<QString> &attributeNames )
711 {
712  QgsRenderContext &context = *renderContext();
713  // TODO: add attributes for geometry generator
714  if ( QgsLabelingEngine *engine2 = context.labelingEngine() )
715  {
716  if ( layer->labelsEnabled() )
717  {
718  mLabelProvider = layer->labeling()->provider( layer );
719  if ( mLabelProvider )
720  {
721  engine2->addProvider( mLabelProvider );
722  if ( !mLabelProvider->prepare( context, attributeNames ) )
723  {
724  engine2->removeProvider( mLabelProvider );
725  mLabelProvider = nullptr; // deleted by engine
726  }
727  }
728  }
729  }
730 
731 #if 0 // TODO: limit of labels, font not found
732  QgsPalLayerSettings &palyr = mContext.labelingEngine()->layer( mLayerID );
733 
734  // see if feature count limit is set for labeling
735  if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
736  {
737  QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
738  .setFilterRect( mContext.extent() )
739  .setNoAttributes() );
740 
741  // total number of features that may be labeled
742  QgsFeature f;
743  int nFeatsToLabel = 0;
744  while ( fit.nextFeature( f ) )
745  {
746  nFeatsToLabel++;
747  }
748  palyr.mFeaturesToLabel = nFeatsToLabel;
749  }
750 
751  // notify user about any font substitution
752  if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
753  {
754  emit labelingFontNotFound( this, palyr.mTextFontFamily );
755  mLabelFontNotFoundNotified = true;
756  }
757 #endif
758 }
759 
760 void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer *layer, QSet<QString> &attributeNames )
761 {
762  QgsRenderContext &context = *renderContext();
763  if ( QgsLabelingEngine *engine2 = context.labelingEngine() )
764  {
765  if ( layer->diagramsEnabled() )
766  {
767  mDiagramProvider = new QgsVectorLayerDiagramProvider( layer );
768  // need to be added before calling prepare() - uses map settings from engine
769  engine2->addProvider( mDiagramProvider );
770  if ( !mDiagramProvider->prepare( context, attributeNames ) )
771  {
772  engine2->removeProvider( mDiagramProvider );
773  mDiagramProvider = nullptr; // deleted by engine
774  }
775  }
776  }
777 }
778 
@ UseAdvancedEffects
Enable layer opacity and blending effects.
@ SemiTransparentCircle
Semi-transparent circle marker.
@ Cross
Cross marker.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const
Factory for label provider implementation.
Q_GADGET QgsUnitTypes::DistanceUnit mapUnits
Class for doing transforms between two map coordinate systems.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source coordinate reference system, which the transform will transform coordinates from.
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent.
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
QgsPointXY transform(const QgsPointXY &point, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward) const SIP_THROW(QgsCsException)
Transform the point from the source CRS to the destination CRS.
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
QString what() const
Definition: qgsexception.h:48
Single scope for storing variables and functions for use within a QgsExpressionContext.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the expression engine to check if expressio...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Abstract interface for use by classes that filter the features or attributes of a layer.
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...
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped.
bool isValid() const
Will return if this iterator is valid.
An interface for objects which generate feature renderers for vector layers.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
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...
Definition: qgsrenderer.h:206
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
QString type() const
Definition: qgsrenderer.h:142
virtual bool usesEmbeddedSymbols() const
Returns true if the renderer uses embedded symbols for features.
double referenceScale() const
Returns the symbology reference scale.
Definition: qgsrenderer.h:452
bool usingSymbolLevels() const
Definition: qgsrenderer.h:292
virtual QString dump() const
Returns debug information about this renderer.
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
Definition: qgsrenderer.h:283
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
Definition: qgsrenderer.h:263
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:96
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) SIP_THROW(QgsCsException)
Render a feature using this renderer in the given context.
void setVertexMarkerAppearance(Qgis::VertexMarkerType type, double size)
Sets type and size of editing vertex markers for subsequent rendering.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
Flags flags() const
Returns the flags which affect how features are fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the iterator to check if it should be cance...
@ EmbeddedSymbols
Retrieve any embedded feature symbology (since QGIS 3.20)
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
QgsGeometry geometry
Definition: qgsfeature.h:67
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:223
Q_GADGET QgsFeatureId id
Definition: qgsfeature.h:64
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:125
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:128
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
The QgsLabelingEngine class provides map labeling functionality.
static QList< QgsMapClippingRegion > collectClippingRegionsForLayer(const QgsRenderContext &context, const QgsMapLayer *layer)
Collects the list of map clipping regions from a context which apply to a map layer.
static QPainterPath calculatePainterClipRegion(const QList< QgsMapClippingRegion > &regions, const QgsRenderContext &context, QgsMapLayerType layerType, bool &shouldClip)
Returns a QPainterPath representing the intersection of clipping regions from context which should be...
static QgsGeometry calculateLabelIntersectionGeometry(const QList< QgsMapClippingRegion > &regions, const QgsRenderContext &context, bool &shouldClip)
Returns the geometry representing the intersection of clipping regions from context which should be u...
static QgsGeometry calculateFeatureIntersectionGeometry(const QList< QgsMapClippingRegion > &regions, const QgsRenderContext &context, bool &shouldClip)
Returns the geometry representing the intersection of clipping regions from context which should be u...
static QgsGeometry calculateFeatureRequestGeometry(const QList< QgsMapClippingRegion > &regions, const QgsRenderContext &context, bool &shouldFilter)
Returns the geometry representing the intersection of clipping regions from context.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
bool mReadyToCompose
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws funct...
static constexpr int MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE
Maximum time (in ms) to allow display of a previously cached preview image while rendering layers,...
QString layerId() const
Gets access to the ID of the layer rendered by this class.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double opacity
Definition: qgsmaplayer.h:82
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:39
double mapUnitsPerPixel() const
Returns the current map units per pixel.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
bool enabled() const
Returns whether the effect is enabled.
Contains settings for how a map layer will be labeled.
A class to represent a 2D point.
Definition: qgspointxy.h:59
double y
Definition: qgspointxy.h:63
Q_GADGET double x
Definition: qgspointxy.h:62
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:193
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:183
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:188
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:198
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:469
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Definition: qgsrectangle.h:333
bool isFinite() const
Returns true if the rectangle has finite boundaries.
Definition: qgsrectangle.h:559
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
Definition: qgsrectangle.h:251
Contains information about the context of a rendering operation.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
void setFeatureClipGeometry(const QgsGeometry &geometry)
Sets a geometry to use to clip features at render time.
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
void setSymbologyReferenceScale(double scale)
Sets the symbology reference scale.
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
QColor selectionColor() const
Returns the color to use when rendering selected features.
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
An interface for classes which provider custom handlers for features rendered as part of a map render...
Scoped object for saving and restoring a QPainter object's state.
bool value(const QString &dynamicKeyPart=QString(), bool useDefaultValueOverride=false, bool defaultValueOverride=false) const
Returns settings value.
double value(const QString &dynamicKeyPart=QString(), bool useDefaultValueOverride=false, double defaultValueOverride=0.0) const
Returns settings value.
QString value(const QString &dynamicKeyPart=QString(), bool useDefaultValueOverride=false, const QString &defaultValueOverride=QString()) const
Returns settings value.
static const QgsSettingsEntryString settingsDigitizingMarkerStyle
Settings entry digitizing marker style.
static const QgsSettingsEntryDouble settingsDigitizingMarkerSizeMm
Settings entry digitizing marker size mm.
static const QgsSettingsEntryBool settingsDigitizingMarkerOnlyForSelected
Settings entry digitizing marker only for selected.
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
void setThreshold(float threshold)
Sets the simplification threshold in pixels. Represents the maximum distance in pixels between two co...
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider,...
void setMethodType(MethodType methodType)
Sets the simplification type.
@ OptimizeForRendering
Simplify using the map2pixel data to optimize the rendering of geometries.
QgsSymbol * symbol() const
Returns the symbol which will be rendered for every feature.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
int renderingPass() const
Specifies the rendering pass in which this symbol layer should be rendered.
int layer() const
The layer of this symbol level.
QgsSymbol * symbol() const
The symbol of this symbol level.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Definition: qgssymbol.cpp:420
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Definition: qgssymbol.cpp:355
void setColor(const QColor &color)
Sets the color for the symbol.
Definition: qgssymbol.cpp:541
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:160
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
bool isTemporal() const
Returns true if the object's temporal range is enabled, and the object will be filtered when renderin...
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
Definition: qgsunittypes.h:75
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine.
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures.
void setClipFeatureGeometry(const QgsGeometry &geometry)
Sets a geometry to use to clip features to when registering them as diagrams.
Partial snapshot of vector layer's state (only the members necessary for access to features)
virtual bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
static QgsGeometry getPointObstacleGeometry(QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols)
Returns the geometry for a point feature which should be used as an obstacle for labels.
virtual QList< QgsLabelFeature * > registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels.
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
~QgsVectorLayerRenderer() override
void setLayerRenderingTimeHint(int time) override
Sets approximate render time (in ms) for the layer to render.
bool render() override
Do the rendering (based on data stored in the class).
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
Encapsulates the context in which a QgsVectorLayer's temporal capabilities will be applied.
void setLayer(QgsVectorLayer *layer)
Sets the associated layer.
Represents a vector layer which manages a vector based data sets.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns temporal properties associated with the vector layer.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
QList< const QgsFeatureRendererGenerator * > featureRendererGenerators() const
Returns a list of the feature renderer generators owned by the layer.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
This class contains information how to simplify geometries fetched from a vector layer.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported,...
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
float threshold() const
Gets the simplification threshold of the vector layer managed.
@ GeometrySimplification
The geometries can be simplified using the current map2pixel context state.
@ FullSimplification
All simplification hints can be applied ( Geometry + AA-disabling )
@ NoSimplification
No simplification can be applied.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:1246
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QList< QgsSymbolLevel > QgsSymbolLevelOrder
Definition: qgsrenderer.h:88
QList< QgsSymbolLevelItem > QgsSymbolLevel
Definition: qgsrenderer.h:84
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44