QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  QgsRectangle requestExtent = mContext.extent();
140  mRendererV2->modifyRequestExtent( requestExtent, mContext );
141 
142  QgsFeatureRequest featureRequest = QgsFeatureRequest()
143  .setFilterRect( requestExtent )
145 
146  // enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
147  if ( mSimplifyGeometry )
148  {
149  double map2pixelTol = mSimplifyMethod.threshold();
150  bool validTransform = true;
151 
152  const QgsMapToPixel& mtp = mContext.mapToPixel();
153  map2pixelTol *= mtp.mapUnitsPerPixel();
155 
156  // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
157  if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
158  {
159  try
160  {
161  QgsPoint center = mContext.extent().center();
162  double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
163 
164  QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
165  QgsRectangle targetRect = ct->transform( sourceRect );
166 
167  QgsDebugMsg( QString( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ) );
168  QgsDebugMsg( QString( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
169 
170  if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
171  {
172  QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
173  QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
174  QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
175  QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
176 
177  double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
178  double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
179 
180  QgsDebugMsg( QString( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
181  QgsDebugMsg( QString( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
182 
183  if ( targetHypothenuse != 0 )
184  map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
185  }
186  }
187  catch ( QgsCsException &cse )
188  {
189  QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
190  validTransform = false;
191  }
192  }
193 
194  if ( validTransform )
195  {
196  QgsSimplifyMethod simplifyMethod;
198  simplifyMethod.setTolerance( map2pixelTol );
200 
201  featureRequest.setSimplifyMethod( simplifyMethod );
202 
204  mContext.setVectorSimplifyMethod( vectorMethod );
205  }
206  else
207  {
208  QgsVectorSimplifyMethod vectorMethod;
210  mContext.setVectorSimplifyMethod( vectorMethod );
211  }
212  }
213  else
214  {
215  QgsVectorSimplifyMethod vectorMethod;
217  mContext.setVectorSimplifyMethod( vectorMethod );
218  }
219 
220  QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
221 
223  drawRendererV2Levels( fit );
224  else
225  drawRendererV2( fit );
226 
227  if ( usingEffect )
228  {
230  }
231 
232  //apply layer transparency for vector layers
234  {
235  // a layer transparency has been set, so update the alpha for the flattened layer
236  // by combining it with the layer transparency
237  QColor transparentFillColor = QColor( 0, 0, 0, 255 - ( 255 * mLayerTransparency / 100 ) );
238  // use destination in composition mode to merge source's alpha with destination
239  mContext.painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
241  mContext.painter()->device()->height(), transparentFillColor );
242  }
243 
244  return true;
245 }
246 
248 {
249  mCache = cache;
250 
251  if ( mCache )
252  {
253  // Destroy all cached geometries and clear the references to them
255  }
256 }
257 
258 
259 
260 void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )
261 {
262  QgsFeature fet;
263  while ( fit.nextFeature( fet ) )
264  {
265  try
266  {
267  if ( !fet.constGeometry() )
268  continue; // skip features without geometry
269 
270  if ( mContext.renderingStopped() )
271  {
272  QgsDebugMsg( QString( "Drawing of vector layer %1 cancelled." ).arg( layerID() ) );
273  break;
274  }
275 
276  bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fet.id() );
277  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
278 
279  // render feature
280  bool rendered = mRendererV2->renderFeature( fet, mContext, -1, sel, drawMarker );
281 
282  if ( mCache )
283  {
284  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
285  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
286  }
287 
288  // labeling - register feature
289  Q_UNUSED( rendered );
290  if ( rendered && mContext.labelingEngine() )
291  {
292  if ( mLabeling )
293  {
295  }
296  if ( mDiagrams )
297  {
299  }
300  }
301  }
302  catch ( const QgsCsException &cse )
303  {
304  Q_UNUSED( cse );
305  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
306  .arg( fet.id() ).arg( cse.what() ) );
307  }
308  }
309 
310  stopRendererV2( NULL );
311 }
312 
313 void QgsVectorLayerRenderer::drawRendererV2Levels( QgsFeatureIterator& fit )
314 {
315  QHash< QgsSymbolV2*, QList<QgsFeature> > features; // key = symbol, value = array of features
316 
317  QgsSingleSymbolRendererV2* selRenderer = NULL;
318  if ( !mSelectedFeatureIds.isEmpty() )
319  {
321  selRenderer->symbol()->setColor( mContext.selectionColor() );
323  selRenderer->startRender( mContext, mFields );
324  }
325 
326  // 1. fetch features
327  QgsFeature fet;
328  while ( fit.nextFeature( fet ) )
329  {
330  if ( !fet.constGeometry() )
331  continue; // skip features without geometry
332 
333  if ( mContext.renderingStopped() )
334  {
335  qDebug( "rendering stop!" );
336  stopRendererV2( selRenderer );
337  return;
338  }
339 
341  if ( !sym )
342  {
343  continue;
344  }
345 
346  if ( !features.contains( sym ) )
347  {
348  features.insert( sym, QList<QgsFeature>() );
349  }
350  features[sym].append( fet );
351 
352  if ( mCache )
353  {
354  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
355  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
356  }
357 
358  if ( mContext.labelingEngine() )
359  {
360  if ( mLabeling )
361  {
363  }
364  if ( mDiagrams )
365  {
367  }
368  }
369  }
370 
371  // find out the order
372  QgsSymbolV2LevelOrder levels;
373  QgsSymbolV2List symbols = mRendererV2->symbols();
374  for ( int i = 0; i < symbols.count(); i++ )
375  {
376  QgsSymbolV2* sym = symbols[i];
377  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
378  {
379  int level = sym->symbolLayer( j )->renderingPass();
380  if ( level < 0 || level >= 1000 ) // ignore invalid levels
381  continue;
382  QgsSymbolV2LevelItem item( sym, j );
383  while ( level >= levels.count() ) // append new empty levels
384  levels.append( QgsSymbolV2Level() );
385  levels[level].append( item );
386  }
387  }
388 
389  // 2. draw features in correct order
390  for ( int l = 0; l < levels.count(); l++ )
391  {
392  QgsSymbolV2Level& level = levels[l];
393  for ( int i = 0; i < level.count(); i++ )
394  {
395  QgsSymbolV2LevelItem& item = level[i];
396  if ( !features.contains( item.symbol() ) )
397  {
398  QgsDebugMsg( "level item's symbol not found!" );
399  continue;
400  }
401  int layer = item.layer();
402  QList<QgsFeature>& lst = features[item.symbol()];
404  for ( fit = lst.begin(); fit != lst.end(); ++fit )
405  {
406  if ( mContext.renderingStopped() )
407  {
408  stopRendererV2( selRenderer );
409  return;
410  }
411 
412  bool sel = mSelectedFeatureIds.contains( fit->id() );
413  // maybe vertex markers should be drawn only during the last pass...
414  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
415 
416  try
417  {
418  mRendererV2->renderFeature( *fit, mContext, layer, sel, drawMarker );
419  }
420  catch ( const QgsCsException &cse )
421  {
422  Q_UNUSED( cse );
423  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
424  .arg( fet.id() ).arg( cse.what() ) );
425  }
426  }
427  }
428  }
429 
430  stopRendererV2( selRenderer );
431 }
432 
433 
434 void QgsVectorLayerRenderer::stopRendererV2( QgsSingleSymbolRendererV2* selRenderer )
435 {
437  if ( selRenderer )
438  {
439  selRenderer->stopRender( mContext );
440  delete selRenderer;
441  }
442 }
443 
444 
445 
446 
447 void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames )
448 {
449  if ( !mContext.labelingEngine() )
450  return;
451 
452  if ( mContext.labelingEngine()->prepareLayer( layer, attributeNames, mContext ) )
453  {
454  mLabeling = true;
455 
457  Q_UNUSED( palyr );
458 
459 #if 0 // TODO: limit of labels, font not found
460  // see if feature count limit is set for labeling
461  if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
462  {
463  QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
464  .setFilterRect( mContext.extent() )
465  .setSubsetOfAttributes( QgsAttributeList() ) );
466 
467  // total number of features that may be labeled
468  QgsFeature f;
469  int nFeatsToLabel = 0;
470  while ( fit.nextFeature( f ) )
471  {
472  nFeatsToLabel++;
473  }
474  palyr.mFeaturesToLabel = nFeatsToLabel;
475  }
476 
477  // notify user about any font substitution
478  if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
479  {
480  emit labelingFontNotFound( this, palyr.mTextFontFamily );
481  mLabelFontNotFoundNotified = true;
482  }
483 #endif
484  }
485 }
486 
487 void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames )
488 {
489  if ( !mContext.labelingEngine() )
490  return;
491 
492  if ( !layer->diagramsEnabled() )
493  return;
494 
495  mDiagrams = true;
496 
497  const QgsDiagramRendererV2* diagRenderer = layer->diagramRenderer();
498  const QgsDiagramLayerSettings* diagSettings = layer->diagramLayerSettings();
499 
500  mContext.labelingEngine()->addDiagramLayer( layer, diagSettings ); // will make internal copy of diagSettings + initialize it
501 
502  //add attributes needed by the diagram renderer
503  QList<QString> att = diagRenderer->diagramAttributes();
505  for ( ; attIt != att.constEnd(); ++attIt )
506  {
507  QgsExpression* expression = diagRenderer->diagram()->getExpression( *attIt, &mFields );
508  QStringList columns = expression->referencedColumns();
509  QStringList::const_iterator columnsIterator = columns.constBegin();
510  for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
511  {
512  if ( !attributeNames.contains( *columnsIterator ) )
513  attributeNames << *columnsIterator;
514  }
515  }
516 
517  const QgsLinearlyInterpolatedDiagramRenderer* linearlyInterpolatedDiagramRenderer = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer*>( layer->diagramRenderer() );
518  if ( linearlyInterpolatedDiagramRenderer != NULL )
519  {
520  if ( linearlyInterpolatedDiagramRenderer->classificationAttributeIsExpression() )
521  {
522  QgsExpression* expression = diagRenderer->diagram()->getExpression( linearlyInterpolatedDiagramRenderer->classificationAttributeExpression(), &mFields );
523  QStringList columns = expression->referencedColumns();
524  QStringList::const_iterator columnsIterator = columns.constBegin();
525  for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
526  {
527  if ( !attributeNames.contains( *columnsIterator ) )
528  attributeNames << *columnsIterator;
529  }
530  }
531  else
532  {
533  QString name = mFields.at( linearlyInterpolatedDiagramRenderer->classificationAttribute() ).name();
534  if ( !attributeNames.contains( name ) )
535  attributeNames << name;
536  }
537  }
538 
539  //and the ones needed for data defined diagram positions
540  if ( diagSettings->xPosColumn != -1 )
541  attributeNames << mFields.at( diagSettings->xPosColumn ).name();
542  if ( diagSettings->yPosColumn != -1 )
543  attributeNames << mFields.at( diagSettings->yPosColumn ).name();
544 }
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.
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
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
Definition: qgspoint.h:126
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
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.
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
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.
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
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