QGIS API Documentation  2.11.0-Master
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"
31 #include "qgspainteffect.h"
32 
33 #include <QSettings>
34 #include <QPicture>
35 
36 // TODO:
37 // - passing of cache to QgsVectorLayer
38 
39 
41  : QgsMapLayerRenderer( layer->id() )
42  , mContext( context )
43  , mFields( layer->pendingFields() )
44  , mRendererV2( 0 )
45  , mCache( 0 )
46  , mLabeling( false )
47  , mDiagrams( false )
48  , mLayerTransparency( 0 )
49 {
50  mSource = new QgsVectorLayerFeatureSource( layer );
51 
52  mRendererV2 = layer->rendererV2() ? layer->rendererV2()->clone() : 0;
54 
55  mDrawVertexMarkers = ( layer->editBuffer() != 0 );
56 
57  mGeometryType = layer->geometryType();
58 
61 
64 
65  QSettings settings;
66  mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
67 
68  QString markerTypeString = settings.value( "/qgis/digitizing/marker_style", "Cross" ).toString();
69  if ( markerTypeString == "Cross" )
70  {
72  }
73  else if ( markerTypeString == "SemiTransparentCircle" )
74  {
76  }
77  else
78  {
80  }
81 
82  mVertexMarkerSize = settings.value( "/qgis/digitizing/marker_size", 3 ).toInt();
83 
84  if ( !mRendererV2 )
85  return;
86 
87  QgsDebugMsg( "rendering v2:\n " + mRendererV2->dump() );
88 
89  if ( mDrawVertexMarkers )
90  {
91  // set editing vertex markers style
93  }
94 
96 
97  //register label and diagram layer to the labeling engine
98  prepareLabeling( layer, mAttrNames );
99  prepareDiagrams( layer, mAttrNames );
100 
101 }
102 
103 
105 {
106  delete mRendererV2;
107  delete mSource;
108 }
109 
110 
112 {
114  return true;
115 
116  if ( !mRendererV2 )
117  {
118  mErrors.append( QObject::tr( "No renderer for drawing." ) );
119  return false;
120  }
121 
122  bool usingEffect = false;
124  {
125  usingEffect = true;
127  }
128 
129  // Per feature blending mode
130  if ( mContext.useAdvancedEffects() && mFeatureBlendMode != QPainter::CompositionMode_SourceOver )
131  {
132  // set the painter to the feature blend mode, so that features drawn
133  // on this layer will interact and blend with each other
135  }
136 
138 
139  QString rendererFilter = mRendererV2->filter();
140 
141  QgsRectangle requestExtent = mContext.extent();
142  mRendererV2->modifyRequestExtent( requestExtent, mContext );
143 
144  QgsFeatureRequest featureRequest = QgsFeatureRequest()
145  .setFilterRect( requestExtent )
147 
148  if ( !rendererFilter.isNull() )
149  {
150  featureRequest.setFilterExpression( rendererFilter );
151  }
152 
153  // enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
154  if ( mSimplifyGeometry )
155  {
156  double map2pixelTol = mSimplifyMethod.threshold();
157  bool validTransform = true;
158 
159  const QgsMapToPixel& mtp = mContext.mapToPixel();
160  map2pixelTol *= mtp.mapUnitsPerPixel();
162 
163  // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
164  if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
165  {
166  try
167  {
168  QgsPoint center = mContext.extent().center();
169  double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
170 
171  QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
172  QgsRectangle targetRect = ct->transform( sourceRect );
173 
174  QgsDebugMsg( QString( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ) );
175  QgsDebugMsg( QString( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
176 
177  if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
178  {
179  QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
180  QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
181  QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
182  QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
183 
184  double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
185  double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
186 
187  QgsDebugMsg( QString( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
188  QgsDebugMsg( QString( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
189 
190  if ( targetHypothenuse != 0 )
191  map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
192  }
193  }
194  catch ( QgsCsException &cse )
195  {
196  QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
197  validTransform = false;
198  }
199  }
200 
201  if ( validTransform )
202  {
203  QgsSimplifyMethod simplifyMethod;
205  simplifyMethod.setTolerance( map2pixelTol );
207 
208  featureRequest.setSimplifyMethod( simplifyMethod );
209 
211  mContext.setVectorSimplifyMethod( vectorMethod );
212  }
213  else
214  {
215  QgsVectorSimplifyMethod vectorMethod;
217  mContext.setVectorSimplifyMethod( vectorMethod );
218  }
219  }
220  else
221  {
222  QgsVectorSimplifyMethod vectorMethod;
224  mContext.setVectorSimplifyMethod( vectorMethod );
225  }
226 
227  QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
228 
230  drawRendererV2Levels( fit );
231  else
232  drawRendererV2( fit );
233 
234  if ( usingEffect )
235  {
237  }
238 
239  //apply layer transparency for vector layers
241  {
242  // a layer transparency has been set, so update the alpha for the flattened layer
243  // by combining it with the layer transparency
244  QColor transparentFillColor = QColor( 0, 0, 0, 255 - ( 255 * mLayerTransparency / 100 ) );
245  // use destination in composition mode to merge source's alpha with destination
246  mContext.painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
248  mContext.painter()->device()->height(), transparentFillColor );
249  }
250 
251  return true;
252 }
253 
255 {
256  mCache = cache;
257 
258  if ( mCache )
259  {
260  // Destroy all cached geometries and clear the references to them
262  }
263 }
264 
265 
266 
267 void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )
268 {
269  QgsFeature fet;
270  while ( fit.nextFeature( fet ) )
271  {
272  try
273  {
274  if ( !fet.constGeometry() )
275  continue; // skip features without geometry
276 
277  if ( mContext.renderingStopped() )
278  {
279  QgsDebugMsg( QString( "Drawing of vector layer %1 cancelled." ).arg( layerID() ) );
280  break;
281  }
282 
283  bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fet.id() );
284  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
285 
286  if ( mCache )
287  {
288  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
289  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
290  }
291 
292  // render feature
293  bool rendered = mRendererV2->renderFeature( fet, mContext, -1, sel, drawMarker );
294 
295  // labeling - register feature
296  Q_UNUSED( rendered );
297  if ( rendered && mContext.labelingEngine() )
298  {
299  if ( mLabeling )
300  {
302  }
303  if ( mDiagrams )
304  {
306  }
307  }
308  }
309  catch ( const QgsCsException &cse )
310  {
311  Q_UNUSED( cse );
312  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
313  .arg( fet.id() ).arg( cse.what() ) );
314  }
315  }
316 
317  stopRendererV2( NULL );
318 }
319 
320 void QgsVectorLayerRenderer::drawRendererV2Levels( QgsFeatureIterator& fit )
321 {
322  QHash< QgsSymbolV2*, QList<QgsFeature> > features; // key = symbol, value = array of features
323 
324  QgsSingleSymbolRendererV2* selRenderer = NULL;
325  if ( !mSelectedFeatureIds.isEmpty() )
326  {
328  selRenderer->symbol()->setColor( mContext.selectionColor() );
330  selRenderer->startRender( mContext, mFields );
331  }
332 
333  // 1. fetch features
334  QgsFeature fet;
335  while ( fit.nextFeature( fet ) )
336  {
337  if ( !fet.constGeometry() )
338  continue; // skip features without geometry
339 
340  if ( mContext.renderingStopped() )
341  {
342  qDebug( "rendering stop!" );
343  stopRendererV2( selRenderer );
344  return;
345  }
346 
348  if ( !sym )
349  {
350  continue;
351  }
352 
353  if ( !features.contains( sym ) )
354  {
355  features.insert( sym, QList<QgsFeature>() );
356  }
357  features[sym].append( fet );
358 
359  if ( mCache )
360  {
361  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
362  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
363  }
364 
365  if ( mContext.labelingEngine() )
366  {
367  if ( mLabeling )
368  {
370  }
371  if ( mDiagrams )
372  {
374  }
375  }
376  }
377 
378  // find out the order
379  QgsSymbolV2LevelOrder levels;
380  QgsSymbolV2List symbols = mRendererV2->symbols();
381  for ( int i = 0; i < symbols.count(); i++ )
382  {
383  QgsSymbolV2* sym = symbols[i];
384  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
385  {
386  int level = sym->symbolLayer( j )->renderingPass();
387  if ( level < 0 || level >= 1000 ) // ignore invalid levels
388  continue;
389  QgsSymbolV2LevelItem item( sym, j );
390  while ( level >= levels.count() ) // append new empty levels
391  levels.append( QgsSymbolV2Level() );
392  levels[level].append( item );
393  }
394  }
395 
396  // 2. draw features in correct order
397  for ( int l = 0; l < levels.count(); l++ )
398  {
399  QgsSymbolV2Level& level = levels[l];
400  for ( int i = 0; i < level.count(); i++ )
401  {
402  QgsSymbolV2LevelItem& item = level[i];
403  if ( !features.contains( item.symbol() ) )
404  {
405  QgsDebugMsg( "level item's symbol not found!" );
406  continue;
407  }
408  int layer = item.layer();
409  QList<QgsFeature>& lst = features[item.symbol()];
411  for ( fit = lst.begin(); fit != lst.end(); ++fit )
412  {
413  if ( mContext.renderingStopped() )
414  {
415  stopRendererV2( selRenderer );
416  return;
417  }
418 
419  bool sel = mSelectedFeatureIds.contains( fit->id() );
420  // maybe vertex markers should be drawn only during the last pass...
421  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
422 
423  try
424  {
425  mRendererV2->renderFeature( *fit, mContext, layer, sel, drawMarker );
426  }
427  catch ( const QgsCsException &cse )
428  {
429  Q_UNUSED( cse );
430  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
431  .arg( fet.id() ).arg( cse.what() ) );
432  }
433  }
434  }
435  }
436 
437  stopRendererV2( selRenderer );
438 }
439 
440 
441 void QgsVectorLayerRenderer::stopRendererV2( QgsSingleSymbolRendererV2* selRenderer )
442 {
444  if ( selRenderer )
445  {
446  selRenderer->stopRender( mContext );
447  delete selRenderer;
448  }
449 }
450 
451 
452 
453 
454 void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames )
455 {
456  if ( !mContext.labelingEngine() )
457  return;
458 
459  if ( mContext.labelingEngine()->prepareLayer( layer, attributeNames, mContext ) )
460  {
461  mLabeling = true;
462 
464  Q_UNUSED( palyr );
465 
466 #if 0 // TODO: limit of labels, font not found
467  // see if feature count limit is set for labeling
468  if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
469  {
470  QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
471  .setFilterRect( mContext.extent() )
472  .setSubsetOfAttributes( QgsAttributeList() ) );
473 
474  // total number of features that may be labeled
475  QgsFeature f;
476  int nFeatsToLabel = 0;
477  while ( fit.nextFeature( f ) )
478  {
479  nFeatsToLabel++;
480  }
481  palyr.mFeaturesToLabel = nFeatsToLabel;
482  }
483 
484  // notify user about any font substitution
485  if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
486  {
487  emit labelingFontNotFound( this, palyr.mTextFontFamily );
488  mLabelFontNotFoundNotified = true;
489  }
490 #endif
491  }
492 }
493 
494 void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames )
495 {
496  if ( !mContext.labelingEngine() )
497  return;
498 
499  if ( !layer->diagramsEnabled() )
500  return;
501 
502  mDiagrams = true;
503 
504  const QgsDiagramRendererV2* diagRenderer = layer->diagramRenderer();
505  const QgsDiagramLayerSettings* diagSettings = layer->diagramLayerSettings();
506 
507  mContext.labelingEngine()->addDiagramLayer( layer, diagSettings ); // will make internal copy of diagSettings + initialize it
508 
509  //add attributes needed by the diagram renderer
510  QList<QString> att = diagRenderer->diagramAttributes();
512  for ( ; attIt != att.constEnd(); ++attIt )
513  {
514  QgsExpression* expression = diagRenderer->diagram()->getExpression( *attIt, &mFields );
515  QStringList columns = expression->referencedColumns();
516  QStringList::const_iterator columnsIterator = columns.constBegin();
517  for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
518  {
519  if ( !attributeNames.contains( *columnsIterator ) )
520  attributeNames << *columnsIterator;
521  }
522  }
523 
524  const QgsLinearlyInterpolatedDiagramRenderer* linearlyInterpolatedDiagramRenderer = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer*>( layer->diagramRenderer() );
525  if ( linearlyInterpolatedDiagramRenderer != NULL )
526  {
527  if ( linearlyInterpolatedDiagramRenderer->classificationAttributeIsExpression() )
528  {
529  QgsExpression* expression = diagRenderer->diagram()->getExpression( linearlyInterpolatedDiagramRenderer->classificationAttributeExpression(), &mFields );
530  QStringList columns = expression->referencedColumns();
531  QStringList::const_iterator columnsIterator = columns.constBegin();
532  for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
533  {
534  if ( !attributeNames.contains( *columnsIterator ) )
535  attributeNames << *columnsIterator;
536  }
537  }
538  else
539  {
540  QString name = mFields.at( linearlyInterpolatedDiagramRenderer->classificationAttribute() ).name();
541  if ( !attributeNames.contains( name ) )
542  attributeNames << name;
543  }
544  }
545 
546  //and the ones needed for data defined diagram positions
547  if ( diagSettings->xPosColumn != -1 )
548  attributeNames << mFields.at( diagSettings->xPosColumn ).name();
549  if ( diagSettings->yPosColumn != -1 )
550  attributeNames << mFields.at( diagSettings->yPosColumn ).name();
551 }
QgsFeatureId id() const
Get the feature ID for this feature.
Definition: qgsfeature.cpp:51
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:86
const QString & name() const
Gets the name of the field.
Definition: qgsfield.cpp:69
const QgsCoordinateReferenceSystem & sourceCrs() const
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
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.
QStringList referencedColumns() const
Get list of columns referenced by the expression.
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)
void setCompositionMode(CompositionMode mode)
QColor selectionColor() const
virtual void stopRender(QgsRenderContext &context) override
virtual QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
virtual QString dump() const
for debugging
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
QgsExpression * getExpression(const QString &expression, const QgsFields *fields)
Definition: qgsdiagram.cpp:47
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:192
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
The geometries can be simplified using the current map2pixel context state.
QgsDiagram * diagram() const
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
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.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QPainter::CompositionMode mFeatureBlendMode
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
virtual int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s)
adds a diagram layer to the labeling engine
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:162
const QgsDiagramLayerSettings * diagramLayerSettings() const
const QgsCoordinateTransform * coordinateTransform() const
void setCachedGeometriesRect(const QgsRectangle &extent)
QgsVectorSimplifyMethod mSimplifyMethod
QString tr(const char *sourceText, const char *disambiguation, int n)
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.
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
bool isNull() const
Returns diagram settings for a feature.
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
virtual QgsSymbolV2List symbols()=0
for symbol levels
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
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
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 filter expression. {.
int count(const T &value) const
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.
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:197
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:182
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
bool renderingStopped() const
void setTolerance(double tolerance)
Sets the tolerance of simplification. Represents the maximum distance between two coordinates which c...
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:113
double mapUnitsPerPixel() const
Return current map units per pixel.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QgsFeatureRendererV2 * mRendererV2
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.cpp:303
const QgsDiagramRendererV2 * diagramRenderer() const
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
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)
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
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
virtual void registerFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext(), QString dxfLayer=QString::null)=0
called for every feature
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:68
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
const_iterator constEnd() const
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())
called for every diagram feature
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 QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
To be overridden.
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:187
QString toString() const
QgsPoint center() const
Center point of the rectangle.
Definition: qgsrectangle.h:212
iterator begin()
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
QgsLabelingEngineInterface * labelingEngine() const