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 
45 const unsigned char* QgsFeatureRendererV2::_getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb )
46 {
47  QgsConstWkbPtr wkbPtr( wkb + 1 );
48  unsigned int wkbType;
49  wkbPtr >> wkbType >> pt.rx() >> pt.ry();
50 
51  if ( static_cast< QgsWKBTypes::Type >( wkbType ) == QgsWKBTypes::Point25D || static_cast< QgsWKBTypes::Type >( wkbType ) == QgsWKBTypes::PointZ )
52  wkbPtr += sizeof( double );
53 
54  if ( context.coordinateTransform() )
55  {
56  double z = 0; // dummy variable for coordiante transform
57  context.coordinateTransform()->transformInPlace( pt.rx(), pt.ry(), z );
58  }
59 
60  context.mapToPixel().transformInPlace( pt.rx(), pt.ry() );
61 
62  return wkbPtr;
63 }
64 
65 const unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent )
66 {
67  QgsConstWkbPtr wkbPtr( wkb + 1 );
68  unsigned int wkbType, nPoints;
69  wkbPtr >> wkbType >> nPoints;
70 
71  bool hasZValue = QgsWKBTypes::hasZ( static_cast< QgsWKBTypes::Type >( wkbType ) );
72  bool hasMValue = QgsWKBTypes::hasM( static_cast< QgsWKBTypes::Type >( wkbType ) );
73 
74  double x = 0.0;
75  double y = 0.0;
76  const QgsCoordinateTransform* ct = context.coordinateTransform();
77  const QgsMapToPixel& mtp = context.mapToPixel();
78 
79  //apply clipping for large lines to achieve a better rendering performance
80  if ( clipToExtent && nPoints > 1 )
81  {
82  const QgsRectangle& e = context.extent();
83  double cw = e.width() / 10;
84  double ch = e.height() / 10;
85  QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch );
86  wkbPtr = QgsConstWkbPtr( QgsClipper::clippedLineWKB( wkb, clipRect, pts ) );
87  }
88  else
89  {
90  pts.resize( nPoints );
91 
92  QPointF* ptr = pts.data();
93  for ( unsigned int i = 0; i < nPoints; ++i, ++ptr )
94  {
95  wkbPtr >> x >> y;
96  if ( hasZValue )
97  wkbPtr += sizeof( double );
98  if ( hasMValue )
99  wkbPtr += sizeof( double );
100 
101  *ptr = QPointF( x, y );
102  }
103  }
104 
105  //transform the QPolygonF to screen coordinates
106  if ( ct )
107  {
108  ct->transformPolygon( pts );
109  }
110 
111  QPointF* ptr = pts.data();
112  for ( int i = 0; i < pts.size(); ++i, ++ptr )
113  {
114  mtp.transformInPlace( ptr->rx(), ptr->ry() );
115  }
116 
117  return wkbPtr;
118 }
119 
120 const unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent )
121 {
122  QgsConstWkbPtr wkbPtr( wkb + 1 );
123 
124  unsigned int wkbType, numRings;
125  wkbPtr >> wkbType >> numRings;
126 
127  if ( numRings == 0 ) // sanity check for zero rings in polygon
128  return wkbPtr;
129 
130  bool hasZValue = QgsWKBTypes::hasZ( static_cast< QgsWKBTypes::Type >( wkbType ) );
131  bool hasMValue = QgsWKBTypes::hasM( static_cast< QgsWKBTypes::Type >( wkbType ) );
132 
133  double x, y;
134  holes.clear();
135 
136  const QgsCoordinateTransform* ct = context.coordinateTransform();
137  const QgsMapToPixel& mtp = context.mapToPixel();
138  const QgsRectangle& e = context.extent();
139  double cw = e.width() / 10;
140  double ch = e.height() / 10;
141  QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch );
142 
143  for ( unsigned int idx = 0; idx < numRings; idx++ )
144  {
145  unsigned int nPoints;
146  wkbPtr >> nPoints;
147 
148  QPolygonF poly( nPoints );
149 
150  // Extract the points from the WKB and store in a pair of vectors.
151  QPointF* ptr = poly.data();
152  for ( unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
153  {
154  wkbPtr >> x >> y;
155  if ( hasZValue )
156  wkbPtr += sizeof( double );
157  if ( hasMValue )
158  wkbPtr += sizeof( double );
159 
160  *ptr = QPointF( x, y );
161  }
162 
163  if ( nPoints < 1 )
164  continue;
165 
166  //clip close to view extent, if needed
167  QRectF ptsRect = poly.boundingRect();
168  if ( clipToExtent && !context.extent().contains( ptsRect ) ) QgsClipper::trimPolygon( poly, clipRect );
169 
170  //transform the QPolygonF to screen coordinates
171  if ( ct )
172  {
173  ct->transformPolygon( poly );
174  }
175 
176 
177  ptr = poly.data();
178  for ( int i = 0; i < poly.size(); ++i, ++ptr )
179  {
180  mtp.transformInPlace( ptr->rx(), ptr->ry() );
181  }
182 
183  if ( idx == 0 )
184  pts = poly;
185  else
186  holes.append( poly );
187  }
188 
189  return wkbPtr;
190 }
191 
193 {
194  if ( symbol )
195  {
196  if ( symbol->type() == QgsSymbolV2::Marker )
197  {
198  QgsMarkerSymbolV2* ms = static_cast<QgsMarkerSymbolV2*>( symbol );
199  if ( ms )
200  {
201  ms->setScaleMethod( static_cast< QgsSymbolV2::ScaleMethod >( scaleMethod ) );
202  }
203  }
204  }
205 }
206 
208 {
209  if ( !destRenderer || !mPaintEffect )
210  return;
211 
212  destRenderer->setPaintEffect( mPaintEffect->clone() );
213  destRenderer->mOrderBy = mOrderBy;
214 }
215 
217 {
218  if ( !destRenderer || !mPaintEffect )
219  return;
220 
221  destRenderer->setPaintEffect( mPaintEffect->clone() );
222 }
223 
225  : mType( type )
226  , mUsingSymbolLevels( false )
229  , mPaintEffect( nullptr )
230  , mForceRaster( false )
231 {
233  mPaintEffect->setEnabled( false );
234 }
235 
237 {
238  delete mPaintEffect;
239 }
240 
242 {
243  return new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol( geomType ) );
244 }
245 
247 {
248  QgsRenderContext context;
250  return symbolForFeature( feature, context );
251 }
252 
254 {
255  Q_UNUSED( context );
256  // base method calls deprecated symbolForFeature to maintain API
258  return symbolForFeature( feature );
260 }
261 
263 {
265  return symbolForFeature( feature );
267 }
268 
270 {
271  return symbolForFeature( feature, context );
272 }
273 
275 {
276  Q_UNUSED( feature );
277  Q_UNUSED( context );
278  return QSet< QString >();
279 }
280 
282 {
283  startRender( context, vlayer->fields() );
284 }
285 
286 bool QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
287 {
288  QgsSymbolV2* symbol = symbolForFeature( feature, context );
289  if ( !symbol )
290  return false;
291 
292  renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
293  return true;
294 }
295 
296 void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymbolV2* symbol, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
297 {
298  symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
299 }
300 
302 {
303  return "UNKNOWN RENDERER\n";
304 }
305 
307 {
308  QgsRenderContext context;
309  return symbols( context );
310 }
311 
313 {
314  Q_UNUSED( context );
315 
316  //base implementation calls deprecated method to maintain API
318  return symbols();
320 }
321 
322 
324 {
325  // <renderer-v2 type=""> ... </renderer-v2>
326 
327  if ( element.isNull() )
328  return nullptr;
329 
330  // load renderer
331  QString rendererType = element.attribute( "type" );
332 
334  if ( !m )
335  return nullptr;
336 
337  QgsFeatureRendererV2* r = m->createRenderer( element );
338  if ( r )
339  {
340  r->setUsingSymbolLevels( element.attribute( "symbollevels", "0" ).toInt() );
341  r->setForceRasterRender( element.attribute( "forceraster", "0" ).toInt() );
342 
343  //restore layer effect
344  QDomElement effectElem = element.firstChildElement( "effect" );
345  if ( !effectElem.isNull() )
346  {
347  r->setPaintEffect( QgsPaintEffectRegistry::instance()->createEffect( effectElem ) );
348  }
349 
350  // restore order by
351  QDomElement orderByElem = element.firstChildElement( "orderby" );
352  r->mOrderBy.load( orderByElem );
353  }
354  return r;
355 }
356 
358 {
359  // create empty renderer element
360  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
361  rendererElem.setAttribute( "forceraster", ( mForceRaster ? "1" : "0" ) );
362 
364  mPaintEffect->saveProperties( doc, rendererElem );
365 
366  if ( !mOrderBy.isEmpty() )
367  {
368  QDomElement orderBy = doc.createElement( "orderby" );
369  mOrderBy.save( orderBy );
370  rendererElem.appendChild( orderBy );
371  }
372  return rendererElem;
373 }
374 
376 {
377  QDomElement element = node.toElement();
378  if ( element.isNull() )
379  return nullptr;
380 
381  // get the UserStyle element
382  QDomElement userStyleElem = element.firstChildElement( "UserStyle" );
383  if ( userStyleElem.isNull() )
384  {
385  // UserStyle element not found, nothing will be rendered
386  errorMessage = "Info: UserStyle element not found.";
387  return nullptr;
388  }
389 
390  // get the FeatureTypeStyle element
391  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( "FeatureTypeStyle" );
392  if ( featTypeStyleElem.isNull() )
393  {
394  errorMessage = "Info: FeatureTypeStyle element not found.";
395  return nullptr;
396  }
397 
398  // use the RuleRenderer when more rules are present or the rule
399  // has filters or min/max scale denominators set,
400  // otherwise use the SingleSymbol renderer
401  bool needRuleRenderer = false;
402  int ruleCount = 0;
403 
404  QDomElement ruleElem = featTypeStyleElem.firstChildElement( "Rule" );
405  while ( !ruleElem.isNull() )
406  {
407  ruleCount++;
408 
409  // more rules present, use the RuleRenderer
410  if ( ruleCount > 1 )
411  {
412  QgsDebugMsg( "more Rule elements found: need a RuleRenderer" );
413  needRuleRenderer = true;
414  break;
415  }
416 
417  QDomElement ruleChildElem = ruleElem.firstChildElement();
418  while ( !ruleChildElem.isNull() )
419  {
420  // rule has filter or min/max scale denominator, use the RuleRenderer
421  if ( ruleChildElem.localName() == "Filter" ||
422  ruleChildElem.localName() == "MinScaleDenominator" ||
423  ruleChildElem.localName() == "MaxScaleDenominator" )
424  {
425  QgsDebugMsg( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
426  needRuleRenderer = true;
427  break;
428  }
429 
430  ruleChildElem = ruleChildElem.nextSiblingElement();
431  }
432 
433  if ( needRuleRenderer )
434  {
435  break;
436  }
437 
438  ruleElem = ruleElem.nextSiblingElement( "Rule" );
439  }
440 
441  QString rendererType;
442  if ( needRuleRenderer )
443  {
444  rendererType = "RuleRenderer";
445  }
446  else
447  {
448  rendererType = "singleSymbol";
449  }
450  QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
451 
452  // create the renderer and return it
454  if ( !m )
455  {
456  errorMessage = QString( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
457  return nullptr;
458  }
459 
460  QgsFeatureRendererV2* r = m->createRendererFromSld( featTypeStyleElem, geomType );
461  return r;
462 }
463 
465 {
466  return writeSld( doc, layer.name() );
467 }
468 
470 {
471  QDomElement userStyleElem = doc.createElement( "UserStyle" );
472 
473  QDomElement nameElem = doc.createElement( "se:Name" );
474  nameElem.appendChild( doc.createTextNode( styleName ) );
475  userStyleElem.appendChild( nameElem );
476 
477  QDomElement featureTypeStyleElem = doc.createElement( "se:FeatureTypeStyle" );
478  toSld( doc, featureTypeStyleElem );
479  userStyleElem.appendChild( featureTypeStyleElem );
480 
481  return userStyleElem;
482 }
483 
485 {
486  Q_UNUSED( iconSize );
487  // empty list by default
488  return QgsLegendSymbologyList();
489 }
490 
492 {
493  return false;
494 }
495 
497 {
498  Q_UNUSED( key );
499  return false;
500 }
501 
503 {
504  Q_UNUSED( key );
505  Q_UNUSED( state );
506 }
507 
509 {
510  Q_UNUSED( key );
511  delete symbol;
512 }
513 
515 {
516  Q_UNUSED( scaleDenominator );
517  Q_UNUSED( rule );
518  return QgsLegendSymbolList();
519 }
520 
522 {
523  QgsLegendSymbolList lst = const_cast<QgsFeatureRendererV2*>( this )->legendSymbolItems();
525  int i = 0;
526  for ( QgsLegendSymbolList::const_iterator it = lst.begin(); it != lst.end(); ++it, ++i )
527  {
528  lst2 << QgsLegendSymbolItemV2( it->second, it->first, QString::number( i ), legendSymbolItemsCheckable() );
529  }
530  return lst2;
531 }
532 
534 {
537 }
538 
540 {
542  return nullptr != symbolForFeature( feat );
544 }
545 
547 {
548  return nullptr != symbolForFeature( feat, context );
549 }
550 
552 {
553  QgsVectorLayer::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
556 }
557 
559 {
560  Q_FOREACH ( QPointF pt, pts )
561  renderVertexMarker( pt, context );
562 }
563 
565 {
566  Q_FOREACH ( QPointF pt, pts )
567  renderVertexMarker( pt, context );
568 
569  if ( rings )
570  {
571  Q_FOREACH ( const QPolygonF& ring, *rings )
572  {
573  Q_FOREACH ( QPointF pt, ring )
574  renderVertexMarker( pt, context );
575  }
576  }
577 }
578 
580 {
581  QgsSymbolV2List lst;
583  QgsSymbolV2* s = symbolForFeature( feat );
585  if ( s ) lst.append( s );
586  return lst;
587 }
588 
590 {
591  QgsSymbolV2List lst;
592  QgsSymbolV2* s = symbolForFeature( feat, context );
593  if ( s ) lst.append( s );
594  return lst;
595 }
596 
598 {
599  QgsSymbolV2List lst;
603  if ( s ) lst.append( s );
604  return lst;
605 }
606 
608 {
609  QgsSymbolV2List lst;
610  QgsSymbolV2* s = originalSymbolForFeature( feat, context );
611  if ( s ) lst.append( s );
612  return lst;
613 }
614 
616 {
617  return mPaintEffect;
618 }
619 
621 {
622  delete mPaintEffect;
623  mPaintEffect = effect;
624 }
625 
627 {
628  return mOrderBy;
629 }
630 
632 {
633  mOrderBy = orderBy;
634 }
635 
637 {
638  if ( symbol->type() == QgsSymbolV2::Marker )
639  {
640  QgsMarkerSymbolV2 * s = static_cast<QgsMarkerSymbolV2 *>( symbol );
642  {
643  const QgsDataDefined dd( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" );
644  s->setDataDefinedSize( dd );
645  }
646  else
647  {
648  const QgsDataDefined dd( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" );
649  s->setDataDefinedSize( dd );
650  }
652  }
653  else if ( symbol->type() == QgsSymbolV2::Line )
654  {
655  QgsLineSymbolV2 * s = static_cast<QgsLineSymbolV2 *>( symbol );
656  const QgsDataDefined dd( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" );
657  s->setDataDefinedWidth( dd );
658  }
659 }
660 
662 {
663  if ( symbol->type() == QgsSymbolV2::Marker )
664  {
665  QgsMarkerSymbolV2 * s = static_cast<QgsMarkerSymbolV2 *>( symbol );
666  const QgsDataDefined dd(( s->angle()
667  ? QString::number( s->angle() ) + " + "
668  : QString() ) + field );
669  s->setDataDefinedAngle( dd );
670  }
671 }
void clear()
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)
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
static const unsigned char * _getPoint(QPointF &pt, QgsRenderContext &context, const unsigned char *wkb)
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 bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:703
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
static const unsigned char * clippedLineWKB(const unsigned char *wkb, const QgsRectangle &clipExtent, QPolygonF &line)
Reads a polyline from WKB and clips it to clipExtent.
Definition: qgsclipper.cpp:40
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.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:656
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...
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
static const unsigned char * _getPolygon(QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, const unsigned char *wkb, bool clipToExtent=true)
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)
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
static const unsigned char * _getLineString(QPolygonF &pts, QgsRenderContext &context, const unsigned char *wkb, bool clipToExtent=true)
Calculate scale by the area.
Definition: qgssymbolv2.h:86
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:180
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)