QGIS API Documentation  2.13.0-Master
qgsrendererv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendererv2.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 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 "qgsrendererv2.h"
17 #include "qgssymbolv2.h"
18 #include "qgssymbollayerv2utils.h"
19 #include "qgsrulebasedrendererv2.h"
20 #include "qgsdatadefined.h"
21 
22 #include "qgssinglesymbolrendererv2.h" // for default renderer
23 
24 #include "qgsrendererv2registry.h"
25 
26 #include "qgsrendercontext.h"
27 #include "qgsclipper.h"
28 #include "qgsgeometry.h"
30 #include "qgsfeature.h"
31 #include "qgslogger.h"
32 #include "qgsvectorlayer.h"
33 #include "qgspainteffect.h"
34 #include "qgseffectstack.h"
35 #include "qgspainteffectregistry.h"
36 #include "qgswkbptr.h"
37 #include "qgspointv2.h"
38 
39 #include <QDomElement>
40 #include <QDomDocument>
41 #include <QPolygonF>
42 
43 
44 
46 {
49  wkbPtr >> pt.rx() >> pt.ry();
50  wkbPtr += ( QgsWKBTypes::coordDimensions( type ) - 2 ) * sizeof( double );
51 
52  if ( context.coordinateTransform() )
53  {
54  double z = 0; // dummy variable for coordiante transform
55  context.coordinateTransform()->transformInPlace( pt.rx(), pt.ry(), z );
56  }
57 
58  context.mapToPixel().transformInPlace( pt.rx(), pt.ry() );
59 
60  return wkbPtr;
61 }
62 
64 {
66  QgsWKBTypes::Type wkbType = wkbPtr.readHeader();
67  unsigned int nPoints;
68  wkbPtr >> nPoints;
69 
70  const QgsCoordinateTransform* ct = context.coordinateTransform();
71  const QgsMapToPixel& mtp = context.mapToPixel();
72 
73  //apply clipping for large lines to achieve a better rendering performance
74  if ( clipToExtent && nPoints > 1 )
75  {
76  const QgsRectangle& e = context.extent();
77  double cw = e.width() / 10;
78  double ch = e.height() / 10;
79  QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch );
80  wkbPtr -= 1 + 2 * sizeof( int );
81  wkbPtr = QgsClipper::clippedLineWKB( wkbPtr, clipRect, pts );
82  }
83  else
84  {
85  pts.resize( nPoints );
86 
87  int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double );
88 
89  QPointF* ptr = pts.data();
90  for ( unsigned int i = 0; i < nPoints; ++i, ++ptr )
91  {
92  wkbPtr >> ptr->rx() >> ptr->ry();
93  wkbPtr += skipZM;
94  }
95  }
96 
97  //transform the QPolygonF to screen coordinates
98  if ( ct )
99  {
100  ct->transformPolygon( pts );
101  }
102 
103  QPointF* ptr = pts.data();
104  for ( int i = 0; i < pts.size(); ++i, ++ptr )
105  {
106  mtp.transformInPlace( ptr->rx(), ptr->ry() );
107  }
108 
109  return wkbPtr;
110 }
111 
113 {
114  QgsDebugCall;
115  QgsWKBTypes::Type wkbType = wkbPtr.readHeader();
116  unsigned int numRings;
117  wkbPtr >> numRings;
118 
119  if ( numRings == 0 ) // sanity check for zero rings in polygon
120  return wkbPtr;
121 
122  holes.clear();
123 
124  const QgsCoordinateTransform* ct = context.coordinateTransform();
125  const QgsMapToPixel& mtp = context.mapToPixel();
126  const QgsRectangle& e = context.extent();
127  double cw = e.width() / 10;
128  double ch = e.height() / 10;
129  QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch );
130 
131  int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double );
132 
133  for ( unsigned int idx = 0; idx < numRings; idx++ )
134  {
135  unsigned int nPoints;
136  wkbPtr >> nPoints;
137 
138  QPolygonF poly( nPoints );
139 
140  // Extract the points from the WKB and store in a pair of vectors.
141  QPointF* ptr = poly.data();
142  for ( unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
143  {
144  wkbPtr >> ptr->rx() >> ptr->ry();
145  wkbPtr += skipZM;
146  }
147 
148  if ( nPoints < 1 )
149  continue;
150 
151  //clip close to view extent, if needed
152  QRectF ptsRect = poly.boundingRect();
153  if ( clipToExtent && !context.extent().contains( ptsRect ) ) QgsClipper::trimPolygon( poly, clipRect );
154 
155  //transform the QPolygonF to screen coordinates
156  if ( ct )
157  {
158  ct->transformPolygon( poly );
159  }
160 
161  ptr = poly.data();
162  for ( int i = 0; i < poly.size(); ++i, ++ptr )
163  {
164  mtp.transformInPlace( ptr->rx(), ptr->ry() );
165  }
166 
167  if ( idx == 0 )
168  pts = poly;
169  else
170  holes.append( poly );
171  }
172 
173  return wkbPtr;
174 }
175 
177 {
178  if ( symbol )
179  {
180  if ( symbol->type() == QgsSymbolV2::Marker )
181  {
182  QgsMarkerSymbolV2* ms = static_cast<QgsMarkerSymbolV2*>( symbol );
183  if ( ms )
184  {
185  ms->setScaleMethod( static_cast< QgsSymbolV2::ScaleMethod >( scaleMethod ) );
186  }
187  }
188  }
189 }
190 
192 {
193  if ( !destRenderer || !mPaintEffect )
194  return;
195 
196  destRenderer->setPaintEffect( mPaintEffect->clone() );
197  destRenderer->mOrderBy = mOrderBy;
198 }
199 
201 {
202  if ( !destRenderer || !mPaintEffect )
203  return;
204 
205  destRenderer->setPaintEffect( mPaintEffect->clone() );
206 }
207 
209  : mType( type )
210  , mUsingSymbolLevels( false )
213  , mPaintEffect( nullptr )
214  , mForceRaster( false )
215 {
217  mPaintEffect->setEnabled( false );
218 }
219 
221 {
222  delete mPaintEffect;
223 }
224 
226 {
227  return new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol( geomType ) );
228 }
229 
231 {
232  QgsRenderContext context;
234  return symbolForFeature( feature, context );
235 }
236 
238 {
239  Q_UNUSED( context );
240  // base method calls deprecated symbolForFeature to maintain API
242  return symbolForFeature( feature );
244 }
245 
247 {
249  return symbolForFeature( feature );
251 }
252 
254 {
255  return symbolForFeature( feature, context );
256 }
257 
259 {
260  Q_UNUSED( feature );
261  Q_UNUSED( context );
262  return QSet< QString >();
263 }
264 
266 {
267  startRender( context, vlayer->fields() );
268 }
269 
270 bool QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
271 {
272  QgsSymbolV2* symbol = symbolForFeature( feature, context );
273  if ( !symbol )
274  return false;
275 
276  renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
277  return true;
278 }
279 
280 void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymbolV2* symbol, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
281 {
282  symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
283 }
284 
286 {
287  return "UNKNOWN RENDERER\n";
288 }
289 
291 {
292  QgsRenderContext context;
293  return symbols( context );
294 }
295 
297 {
298  Q_UNUSED( context );
299 
300  //base implementation calls deprecated method to maintain API
302  return symbols();
304 }
305 
306 
308 {
309  // <renderer-v2 type=""> ... </renderer-v2>
310 
311  if ( element.isNull() )
312  return nullptr;
313 
314  // load renderer
315  QString rendererType = element.attribute( "type" );
316 
318  if ( !m )
319  return nullptr;
320 
321  QgsFeatureRendererV2* r = m->createRenderer( element );
322  if ( r )
323  {
324  r->setUsingSymbolLevels( element.attribute( "symbollevels", "0" ).toInt() );
325  r->setForceRasterRender( element.attribute( "forceraster", "0" ).toInt() );
326 
327  //restore layer effect
328  QDomElement effectElem = element.firstChildElement( "effect" );
329  if ( !effectElem.isNull() )
330  {
331  r->setPaintEffect( QgsPaintEffectRegistry::instance()->createEffect( effectElem ) );
332  }
333 
334  // restore order by
335  QDomElement orderByElem = element.firstChildElement( "orderby" );
336  r->mOrderBy.load( orderByElem );
337  }
338  return r;
339 }
340 
342 {
343  // create empty renderer element
344  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
345  rendererElem.setAttribute( "forceraster", ( mForceRaster ? "1" : "0" ) );
346 
348  mPaintEffect->saveProperties( doc, rendererElem );
349 
350  if ( !mOrderBy.isEmpty() )
351  {
352  QDomElement orderBy = doc.createElement( "orderby" );
353  mOrderBy.save( orderBy );
354  rendererElem.appendChild( orderBy );
355  }
356  return rendererElem;
357 }
358 
360 {
361  QDomElement element = node.toElement();
362  if ( element.isNull() )
363  return nullptr;
364 
365  // get the UserStyle element
366  QDomElement userStyleElem = element.firstChildElement( "UserStyle" );
367  if ( userStyleElem.isNull() )
368  {
369  // UserStyle element not found, nothing will be rendered
370  errorMessage = "Info: UserStyle element not found.";
371  return nullptr;
372  }
373 
374  // get the FeatureTypeStyle element
375  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( "FeatureTypeStyle" );
376  if ( featTypeStyleElem.isNull() )
377  {
378  errorMessage = "Info: FeatureTypeStyle element not found.";
379  return nullptr;
380  }
381 
382  // use the RuleRenderer when more rules are present or the rule
383  // has filters or min/max scale denominators set,
384  // otherwise use the SingleSymbol renderer
385  bool needRuleRenderer = false;
386  int ruleCount = 0;
387 
388  QDomElement ruleElem = featTypeStyleElem.firstChildElement( "Rule" );
389  while ( !ruleElem.isNull() )
390  {
391  ruleCount++;
392 
393  // more rules present, use the RuleRenderer
394  if ( ruleCount > 1 )
395  {
396  QgsDebugMsg( "more Rule elements found: need a RuleRenderer" );
397  needRuleRenderer = true;
398  break;
399  }
400 
401  QDomElement ruleChildElem = ruleElem.firstChildElement();
402  while ( !ruleChildElem.isNull() )
403  {
404  // rule has filter or min/max scale denominator, use the RuleRenderer
405  if ( ruleChildElem.localName() == "Filter" ||
406  ruleChildElem.localName() == "MinScaleDenominator" ||
407  ruleChildElem.localName() == "MaxScaleDenominator" )
408  {
409  QgsDebugMsg( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
410  needRuleRenderer = true;
411  break;
412  }
413 
414  ruleChildElem = ruleChildElem.nextSiblingElement();
415  }
416 
417  if ( needRuleRenderer )
418  {
419  break;
420  }
421 
422  ruleElem = ruleElem.nextSiblingElement( "Rule" );
423  }
424 
425  QString rendererType;
426  if ( needRuleRenderer )
427  {
428  rendererType = "RuleRenderer";
429  }
430  else
431  {
432  rendererType = "singleSymbol";
433  }
434  QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
435 
436  // create the renderer and return it
438  if ( !m )
439  {
440  errorMessage = QString( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
441  return nullptr;
442  }
443 
444  QgsFeatureRendererV2* r = m->createRendererFromSld( featTypeStyleElem, geomType );
445  return r;
446 }
447 
449 {
450  return writeSld( doc, layer.name() );
451 }
452 
454 {
455  QDomElement userStyleElem = doc.createElement( "UserStyle" );
456 
457  QDomElement nameElem = doc.createElement( "se:Name" );
458  nameElem.appendChild( doc.createTextNode( styleName ) );
459  userStyleElem.appendChild( nameElem );
460 
461  QDomElement featureTypeStyleElem = doc.createElement( "se:FeatureTypeStyle" );
462  toSld( doc, featureTypeStyleElem );
463  userStyleElem.appendChild( featureTypeStyleElem );
464 
465  return userStyleElem;
466 }
467 
469 {
470  Q_UNUSED( iconSize );
471  // empty list by default
472  return QgsLegendSymbologyList();
473 }
474 
476 {
477  return false;
478 }
479 
481 {
482  Q_UNUSED( key );
483  return false;
484 }
485 
487 {
488  Q_UNUSED( key );
489  Q_UNUSED( state );
490 }
491 
493 {
494  Q_UNUSED( key );
495  delete symbol;
496 }
497 
499 {
500  Q_UNUSED( scaleDenominator );
501  Q_UNUSED( rule );
502  return QgsLegendSymbolList();
503 }
504 
506 {
507  QgsLegendSymbolList lst = const_cast<QgsFeatureRendererV2*>( this )->legendSymbolItems();
509  int i = 0;
510  for ( QgsLegendSymbolList::const_iterator it = lst.begin(); it != lst.end(); ++it, ++i )
511  {
512  lst2 << QgsLegendSymbolItemV2( it->second, it->first, QString::number( i ), legendSymbolItemsCheckable() );
513  }
514  return lst2;
515 }
516 
518 {
521 }
522 
524 {
526  return nullptr != symbolForFeature( feat );
528 }
529 
531 {
532  return nullptr != symbolForFeature( feat, context );
533 }
534 
536 {
537  QgsVectorLayer::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
540 }
541 
543 {
544  Q_FOREACH ( QPointF pt, pts )
545  renderVertexMarker( pt, context );
546 }
547 
549 {
550  Q_FOREACH ( QPointF pt, pts )
551  renderVertexMarker( pt, context );
552 
553  if ( rings )
554  {
555  Q_FOREACH ( const QPolygonF& ring, *rings )
556  {
557  Q_FOREACH ( QPointF pt, ring )
558  renderVertexMarker( pt, context );
559  }
560  }
561 }
562 
564 {
565  QgsSymbolV2List lst;
567  QgsSymbolV2* s = symbolForFeature( feat );
569  if ( s ) lst.append( s );
570  return lst;
571 }
572 
574 {
575  QgsSymbolV2List lst;
576  QgsSymbolV2* s = symbolForFeature( feat, context );
577  if ( s ) lst.append( s );
578  return lst;
579 }
580 
582 {
583  QgsSymbolV2List lst;
587  if ( s ) lst.append( s );
588  return lst;
589 }
590 
592 {
593  QgsSymbolV2List lst;
594  QgsSymbolV2* s = originalSymbolForFeature( feat, context );
595  if ( s ) lst.append( s );
596  return lst;
597 }
598 
600 {
601  return mPaintEffect;
602 }
603 
605 {
606  delete mPaintEffect;
607  mPaintEffect = effect;
608 }
609 
611 {
612  return mOrderBy;
613 }
614 
616 {
617  mOrderBy = orderBy;
618 }
619 
621 {
622  if ( symbol->type() == QgsSymbolV2::Marker )
623  {
624  QgsMarkerSymbolV2 * s = static_cast<QgsMarkerSymbolV2 *>( symbol );
626  {
627  const QgsDataDefined dd( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" );
628  s->setDataDefinedSize( dd );
629  }
630  else
631  {
632  const QgsDataDefined dd( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" );
633  s->setDataDefinedSize( dd );
634  }
636  }
637  else if ( symbol->type() == QgsSymbolV2::Line )
638  {
639  QgsLineSymbolV2 * s = static_cast<QgsLineSymbolV2 *>( symbol );
640  const QgsDataDefined dd( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" );
641  s->setDataDefinedWidth( dd );
642  }
643 }
644 
646 {
647  if ( symbol->type() == QgsSymbolV2::Marker )
648  {
649  QgsMarkerSymbolV2 * s = static_cast<QgsMarkerSymbolV2 *>( symbol );
650  const QgsDataDefined dd(( s->angle()
651  ? QString::number( s->angle() ) + " + "
652  : QString() ) + field );
653  s->setDataDefinedAngle( dd );
654  }
655 }
void clear()
static int coordDimensions(Type type)
Returns the coordinate dimension of the geometry type as an integer.
Definition: qgswkbtypes.h:562
static QgsRendererV2Registry * instance()
#define RENDERER_TAG_NAME
Definition: qgsrendererv2.h:49
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual QSet< QString > legendKeysForFeature(QgsFeature &feature, QgsRenderContext &context)
Return legend keys matching a specified feature.
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
void setDataDefinedAngle(const QgsDataDefined &dd)
Set data defined angle for whole symbol (including all symbol layers).
A container class for data source field mapping or expression.
GeometryType
Definition: qgis.h:111
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
QgsFeatureRendererV2(const QString &type)
static QgsConstWkbPtr clippedLineWKB(QgsConstWkbPtr wkb, const QgsRectangle &clipExtent, QPolygonF &line)
Reads a polyline from WKB and clips it to clipExtent.
Definition: qgsclipper.cpp:40
QString name() const
Get the display name of the layer.
QDomNode appendChild(const QDomNode &newChild)
static QgsFeatureRendererV2 * loadSld(const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
SymbolType type() const
Definition: qgssymbolv2.h:101
void transformPolygon(QPolygonF &poly, TransformDirection direction=ForwardTransform) const
QString attribute(const QString &name, const QString &defValue) const
virtual QString dump() const
for debugging
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
static QgsConstWkbPtr _getLineString(QPolygonF &pts, QgsRenderContext &context, QgsConstWkbPtr wkb, bool clipToExtent=true)
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:196
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
QgsFields fields() const
Returns the list of fields of this layer.
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
virtual Q_DECL_DEPRECATED QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
double size() const
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
Calculate scale by the diameter.
Definition: qgssymbolv2.h:87
VertexMarkerType
Editing vertex markers.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:407
Base class for visual effects which can be applied to QPicture drawings.
QDomElement nextSiblingElement(const QString &tagName) const
Container of fields for a vector layer.
Definition: qgsfield.h:189
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
Stores metadata about one renderer class.
Line symbol.
Definition: qgssymbolv2.h:76
virtual ~QgsFeatureRendererV2()
const QgsRectangle & extent() const
void renderVertexMarkerPolyline(QPolygonF &pts, QgsRenderContext &context)
render editing vertex marker for a polyline
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, int currentVertexMarkerSize=0)
Render a feature.
const QgsCoordinateTransform * coordinateTransform() const
virtual Q_DECL_DEPRECATED bool willRenderFeature(QgsFeature &feat)
Returns whether the renderer will render a feature or not.
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
QgsRendererV2AbstractMetadata * rendererMetadata(const QString &rendererName)
get metadata for particular renderer. Returns NULL if not found in registry.
QgsPaintEffect * mPaintEffect
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
Marker symbol.
Definition: qgssymbolv2.h:75
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
void renderFeatureWithSymbol(QgsFeature &feature, QgsSymbolV2 *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
QString type() const
Definition: qgsrendererv2.h:83
QDomElement toElement() const
void renderVertexMarker(QPointF pt, QgsRenderContext &context)
render editing vertex marker at specified point
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
QgsWKBTypes::Type readHeader() const
Definition: qgswkbptr.cpp:37
T * data()
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)
Render a feature using this renderer in the given context.
void transformInPlace(double &x, double &y, double &z, TransformDirection direction=ForwardTransform) const
void transformInPlace(double &x, double &y) const
Transform device coordinates to map (world) coordinates.
QString number(int n, int base)
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
qreal x() const
qreal y() const
void append(const T &value)
double width() const
QString localName() const
void resize(int size)
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:201
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:186
static QgsPaintEffectRegistry * instance()
Returns a reference to the singleton instance of the paint effect registry.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
int mCurrentVertexMarkerSize
The current size of editing marker.
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const
bool isEmpty() const
int mCurrentVertexMarkerType
The current type of editing marker.
double angle() const
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
virtual QgsFeatureRendererV2 * createRenderer(QDomElement &elem)=0
Return new instance of the renderer given the DOM element.
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
static void convertSymbolSizeScale(QgsSymbolV2 *symbol, QgsSymbolV2::ScaleMethod method, const QString &field)
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
QDomText createTextNode(const QString &value)
#define QgsDebugCall
Definition: qgslogger.h:32
iterator end()
void copyRendererData(QgsFeatureRendererV2 *destRenderer) const
Clones generic renderer data to another renderer.
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
bool isNull() const
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:408
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
void setUsingSymbolLevels(bool usingSymbolLevels)
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
Contains information about the context of a rendering operation.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
QRectF boundingRect() const
QPainter * painter()
Q_DECL_DEPRECATED void copyPaintEffect(QgsFeatureRendererV2 *destRenderer) const
Copies paint effect of this renderer to another renderer.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
ScaleMethod
Scale method.
Definition: qgssymbolv2.h:84
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
QgsFeatureRequest::OrderBy mOrderBy
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
QDomElement firstChildElement(const QString &tagName) const
void setScaleMethodToSymbol(QgsSymbolV2 *symbol, int scaleMethod)
virtual Q_DECL_DEPRECATED QDomElement writeSld(QDomDocument &doc, const QgsVectorLayer &layer) const
create the SLD UserStyle element following the SLD v1.1 specs
void renderVertexMarkerPolygon(QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
render editing vertex marker for a polygon
qreal & rx()
qreal & ry()
Class for doing transforms between two map coordinate systems.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
const QgsMapToPixel & mapToPixel() const
Calculate scale by the area.
Definition: qgssymbolv2.h:86
static QgsConstWkbPtr _getPolygon(QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, QgsConstWkbPtr wkb, bool clipToExtent=true)
static QgsConstWkbPtr _getPoint(QPointF &pt, QgsRenderContext &context, QgsConstWkbPtr wkb)
QDomElement createElement(const QString &tagName)
double width() const
Width of the rectangle.
Definition: qgsrectangle.h:206
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
Definition: qgsclipper.h:181
virtual QgsFeatureRendererV2 * createRendererFromSld(QDomElement &elem, QGis::GeometryType geomType)
int size() const
Represents a vector layer which manages a vector based data sets.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
Definition: qgsrendererv2.h:44
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:191
iterator begin()
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
virtual void setLegendSymbolItem(const QString &key, QgsSymbolV2 *symbol)
Sets the symbol to be used for a legend symbol item.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Represents a list of OrderByClauses, with the most important first and the least important last...
double height() const
Height of the rectangle.
Definition: qgsrectangle.h:211
static void convertSymbolRotation(QgsSymbolV2 *symbol, const QString &field)