QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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->fields() )
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 
98 
99  //register label and diagram layer to the labeling engine
100  prepareLabeling( layer, mAttrNames );
101  prepareDiagrams( layer, mAttrNames );
102 
103 }
104 
105 
107 {
108  delete mRendererV2;
109  delete mSource;
110 }
111 
112 
114 {
116  return true;
117 
118  if ( !mRendererV2 )
119  {
120  mErrors.append( QObject::tr( "No renderer for drawing." ) );
121  return false;
122  }
123 
124  bool usingEffect = false;
126  {
127  usingEffect = true;
129  }
130 
131  // Per feature blending mode
132  if ( mContext.useAdvancedEffects() && mFeatureBlendMode != QPainter::CompositionMode_SourceOver )
133  {
134  // set the painter to the feature blend mode, so that features drawn
135  // on this layer will interact and blend with each other
137  }
138 
140 
141  QString rendererFilter = mRendererV2->filter();
142 
143  QgsRectangle requestExtent = mContext.extent();
144  mRendererV2->modifyRequestExtent( requestExtent, mContext );
145 
146  QgsFeatureRequest featureRequest = QgsFeatureRequest()
147  .setFilterRect( requestExtent )
149 
150  if ( !rendererFilter.isEmpty() )
151  {
152  featureRequest.setFilterExpression( rendererFilter );
153  featureRequest.setExpressionContext( mContext.expressionContext() );
154  }
155 
156  // enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
157  if ( mSimplifyGeometry )
158  {
159  double map2pixelTol = mSimplifyMethod.threshold();
160  bool validTransform = true;
161 
162  const QgsMapToPixel& mtp = mContext.mapToPixel();
163  map2pixelTol *= mtp.mapUnitsPerPixel();
165 
166  // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
167  if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
168  {
169  try
170  {
171  QgsPoint center = mContext.extent().center();
172  double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
173 
174  QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
175  QgsRectangle targetRect = ct->transform( sourceRect );
176 
177  QgsDebugMsg( QString( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ) );
178  QgsDebugMsg( QString( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
179 
180  if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
181  {
182  QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
183  QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
184  QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
185  QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
186 
187  double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
188  double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
189 
190  QgsDebugMsg( QString( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
191  QgsDebugMsg( QString( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
192 
193  if ( targetHypothenuse != 0 )
194  map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
195  }
196  }
197  catch ( QgsCsException &cse )
198  {
199  QgsMessageLog::logMessage( QObject::tr( "Simplify transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
200  validTransform = false;
201  }
202  }
203 
204  if ( validTransform )
205  {
206  QgsSimplifyMethod simplifyMethod;
208  simplifyMethod.setTolerance( map2pixelTol );
210 
211  featureRequest.setSimplifyMethod( simplifyMethod );
212 
214  mContext.setVectorSimplifyMethod( vectorMethod );
215  }
216  else
217  {
218  QgsVectorSimplifyMethod vectorMethod;
220  mContext.setVectorSimplifyMethod( vectorMethod );
221  }
222  }
223  else
224  {
225  QgsVectorSimplifyMethod vectorMethod;
227  mContext.setVectorSimplifyMethod( vectorMethod );
228  }
229 
230  QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
231 
233  drawRendererV2Levels( fit );
234  else
235  drawRendererV2( fit );
236 
237  if ( usingEffect )
238  {
240  }
241 
242  //apply layer transparency for vector layers
244  {
245  // a layer transparency has been set, so update the alpha for the flattened layer
246  // by combining it with the layer transparency
247  QColor transparentFillColor = QColor( 0, 0, 0, 255 - ( 255 * mLayerTransparency / 100 ) );
248  // use destination in composition mode to merge source's alpha with destination
249  mContext.painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
251  mContext.painter()->device()->height(), transparentFillColor );
252  }
253 
254  return true;
255 }
256 
258 {
259  mCache = cache;
260 
261  if ( mCache )
262  {
263  // Destroy all cached geometries and clear the references to them
265  }
266 }
267 
268 
269 
270 void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )
271 {
272  QgsFeature fet;
273  while ( fit.nextFeature( fet ) )
274  {
275  try
276  {
277  if ( !fet.constGeometry() )
278  continue; // skip features without geometry
279 
280  if ( mContext.renderingStopped() )
281  {
282  QgsDebugMsg( QString( "Drawing of vector layer %1 cancelled." ).arg( layerID() ) );
283  break;
284  }
285 
287 
288  bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fet.id() );
289  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
290 
291  if ( mCache )
292  {
293  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
294  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
295  }
296 
297  // render feature
298  bool rendered = mRendererV2->renderFeature( fet, mContext, -1, sel, drawMarker );
299 
300  // labeling - register feature
301  Q_UNUSED( rendered );
302  if ( rendered && mContext.labelingEngine() )
303  {
304  if ( mLabeling )
305  {
307  }
308  if ( mDiagrams )
309  {
311  }
312  }
313  }
314  catch ( const QgsCsException &cse )
315  {
316  Q_UNUSED( cse );
317  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
318  .arg( fet.id() ).arg( cse.what() ) );
319  }
320  }
321 
322  stopRendererV2( NULL );
323 }
324 
325 void QgsVectorLayerRenderer::drawRendererV2Levels( QgsFeatureIterator& fit )
326 {
327  QHash< QgsSymbolV2*, QList<QgsFeature> > features; // key = symbol, value = array of features
328 
329  QgsSingleSymbolRendererV2* selRenderer = NULL;
330  if ( !mSelectedFeatureIds.isEmpty() )
331  {
333  selRenderer->symbol()->setColor( mContext.selectionColor() );
335  selRenderer->startRender( mContext, mFields );
336  }
337 
338  // 1. fetch features
339  QgsFeature fet;
340  while ( fit.nextFeature( fet ) )
341  {
342  if ( !fet.constGeometry() )
343  continue; // skip features without geometry
344 
345  if ( mContext.renderingStopped() )
346  {
347  qDebug( "rendering stop!" );
348  stopRendererV2( selRenderer );
349  return;
350  }
351 
354  if ( !sym )
355  {
356  continue;
357  }
358 
359  if ( !features.contains( sym ) )
360  {
361  features.insert( sym, QList<QgsFeature>() );
362  }
363  features[sym].append( fet );
364 
365  if ( mCache )
366  {
367  // Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
368  mCache->cacheGeometry( fet.id(), *fet.constGeometry() );
369  }
370 
371  if ( mContext.labelingEngine() )
372  {
374  if ( mLabeling )
375  {
377  }
378  if ( mDiagrams )
379  {
381  }
382  }
383  }
384 
385  // find out the order
386  QgsSymbolV2LevelOrder levels;
388  for ( int i = 0; i < symbols.count(); i++ )
389  {
390  QgsSymbolV2* sym = symbols[i];
391  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
392  {
393  int level = sym->symbolLayer( j )->renderingPass();
394  if ( level < 0 || level >= 1000 ) // ignore invalid levels
395  continue;
396  QgsSymbolV2LevelItem item( sym, j );
397  while ( level >= levels.count() ) // append new empty levels
398  levels.append( QgsSymbolV2Level() );
399  levels[level].append( item );
400  }
401  }
402 
403  // 2. draw features in correct order
404  for ( int l = 0; l < levels.count(); l++ )
405  {
406  QgsSymbolV2Level& level = levels[l];
407  for ( int i = 0; i < level.count(); i++ )
408  {
409  QgsSymbolV2LevelItem& item = level[i];
410  if ( !features.contains( item.symbol() ) )
411  {
412  QgsDebugMsg( "level item's symbol not found!" );
413  continue;
414  }
415  int layer = item.layer();
416  QList<QgsFeature>& lst = features[item.symbol()];
418  for ( fit = lst.begin(); fit != lst.end(); ++fit )
419  {
420  if ( mContext.renderingStopped() )
421  {
422  stopRendererV2( selRenderer );
423  return;
424  }
425 
426  bool sel = mSelectedFeatureIds.contains( fit->id() );
427  // maybe vertex markers should be drawn only during the last pass...
428  bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );
429 
431 
432  try
433  {
434  mRendererV2->renderFeature( *fit, mContext, layer, sel, drawMarker );
435  }
436  catch ( const QgsCsException &cse )
437  {
438  Q_UNUSED( cse );
439  QgsDebugMsg( QString( "Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
440  .arg( fet.id() ).arg( cse.what() ) );
441  }
442  }
443  }
444  }
445 
446  stopRendererV2( selRenderer );
447 }
448 
449 
450 void QgsVectorLayerRenderer::stopRendererV2( QgsSingleSymbolRendererV2* selRenderer )
451 {
453  if ( selRenderer )
454  {
455  selRenderer->stopRender( mContext );
456  delete selRenderer;
457  }
458 }
459 
460 
461 
462 
463 void QgsVectorLayerRenderer::prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames )
464 {
465  if ( !mContext.labelingEngine() )
466  return;
467 
468  if ( mContext.labelingEngine()->prepareLayer( layer, attributeNames, mContext ) )
469  {
470  mLabeling = true;
471 
473  Q_UNUSED( palyr );
474 
475 #if 0 // TODO: limit of labels, font not found
476  // see if feature count limit is set for labeling
477  if ( palyr.limitNumLabels && palyr.maxNumLabels > 0 )
478  {
479  QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
480  .setFilterRect( mContext.extent() )
481  .setSubsetOfAttributes( QgsAttributeList() ) );
482 
483  // total number of features that may be labeled
484  QgsFeature f;
485  int nFeatsToLabel = 0;
486  while ( fit.nextFeature( f ) )
487  {
488  nFeatsToLabel++;
489  }
490  palyr.mFeaturesToLabel = nFeatsToLabel;
491  }
492 
493  // notify user about any font substitution
494  if ( !palyr.mTextFontFound && !mLabelFontNotFoundNotified )
495  {
496  emit labelingFontNotFound( this, palyr.mTextFontFamily );
497  mLabelFontNotFoundNotified = true;
498  }
499 #endif
500  }
501 }
502 
503 void QgsVectorLayerRenderer::prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames )
504 {
505  if ( !mContext.labelingEngine() )
506  return;
507 
508  if ( !layer->diagramsEnabled() )
509  return;
510 
511  mDiagrams = true;
512 
513  const QgsDiagramRendererV2* diagRenderer = layer->diagramRenderer();
514  const QgsDiagramLayerSettings* diagSettings = layer->diagramLayerSettings();
515 
516  mContext.labelingEngine()->addDiagramLayer( layer, diagSettings ); // will make internal copy of diagSettings + initialize it
517 
518  //add attributes needed by the diagram renderer
519  QList<QString> att = diagRenderer->diagramAttributes();
521  for ( ; attIt != att.constEnd(); ++attIt )
522  {
523  QgsExpression* expression = diagRenderer->diagram()->getExpression( *attIt, mContext.expressionContext() );
524  QStringList columns = expression->referencedColumns();
525  QStringList::const_iterator columnsIterator = columns.constBegin();
526  for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
527  {
528  if ( !attributeNames.contains( *columnsIterator ) )
529  attributeNames << *columnsIterator;
530  }
531  }
532 
533  const QgsLinearlyInterpolatedDiagramRenderer* linearlyInterpolatedDiagramRenderer = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer*>( layer->diagramRenderer() );
534  if ( linearlyInterpolatedDiagramRenderer != NULL )
535  {
536  if ( linearlyInterpolatedDiagramRenderer->classificationAttributeIsExpression() )
537  {
538  QgsExpression* expression = diagRenderer->diagram()->getExpression( linearlyInterpolatedDiagramRenderer->classificationAttributeExpression(), mContext.expressionContext() );
539  QStringList columns = expression->referencedColumns();
540  QStringList::const_iterator columnsIterator = columns.constBegin();
541  for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
542  {
543  if ( !attributeNames.contains( *columnsIterator ) )
544  attributeNames << *columnsIterator;
545  }
546  }
547  else
548  {
549  QString name = mFields.at( linearlyInterpolatedDiagramRenderer->classificationAttribute() ).name();
550  if ( !attributeNames.contains( name ) )
551  attributeNames << name;
552  }
553  }
554 
555  //and the ones needed for data defined diagram positions
556  if ( diagSettings->xPosColumn != -1 )
557  attributeNames << mFields.at( diagSettings->xPosColumn ).name();
558  if ( diagSettings->yPosColumn != -1 )
559  attributeNames << mFields.at( diagSettings->yPosColumn ).name();
560 }
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:88
const QString & name() const
Gets the name of the field.
Definition: qgsfield.cpp:70
const QgsCoordinateReferenceSystem & sourceCrs() const
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
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.
Q_DECL_DEPRECATED 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
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
The geometries can be simplified using the current map2pixel context state.
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)
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
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
void setColor(const QColor &color)
Simplify using the map2pixel data to optimize the rendering of geometries.
virtual QgsFeatureRendererV2 * clone() const =0
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
No simplification can be applied.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
void append(const T &value)
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
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...
bool isEmpty() const
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
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
for symbol levels
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.cpp:305
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
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
bool contains(const T &value) const
int layerTransparency() const
Returns the current transparency for the vector layer.
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
virtual bool render() override
Do the rendering (based on data stored in the class)
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
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
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 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