QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
21 #include "qgssinglesymbolrendererv2.h" // for default renderer
22 
23 #include "qgsrendererv2registry.h"
24 
25 #include "qgsrendercontext.h"
26 #include "qgsclipper.h"
27 #include "qgsgeometry.h"
28 #include "qgsfeature.h"
29 #include "qgslogger.h"
30 #include "qgsvectorlayer.h"
31 #include "qgspainteffect.h"
32 #include "qgseffectstack.h"
33 #include "qgspainteffectregistry.h"
34 
35 #include <QDomElement>
36 #include <QDomDocument>
37 #include <QPolygonF>
38 
39 
40 
41 const unsigned char* QgsFeatureRendererV2::_getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb )
42 {
43  QgsConstWkbPtr wkbPtr( wkb + 1 );
44  unsigned int wkbType;
45  wkbPtr >> wkbType >> pt.rx() >> pt.ry();
46 
47  if ( wkbType == QGis::WKBPoint25D )
48  wkbPtr += sizeof( double );
49 
50  if ( context.coordinateTransform() )
51  {
52  double z = 0; // dummy variable for coordiante transform
53  context.coordinateTransform()->transformInPlace( pt.rx(), pt.ry(), z );
54  }
55 
56  context.mapToPixel().transformInPlace( pt.rx(), pt.ry() );
57 
58  return wkbPtr;
59 }
60 
61 const unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent )
62 {
63  QgsConstWkbPtr wkbPtr( wkb + 1 );
64  unsigned int wkbType, nPoints;
65  wkbPtr >> wkbType >> nPoints;
66 
67  bool hasZValue = wkbType == QGis::WKBLineString25D;
68 
69  double x = 0.0;
70  double y = 0.0;
71  const QgsCoordinateTransform* ct = context.coordinateTransform();
72  const QgsMapToPixel& mtp = context.mapToPixel();
73 
74  //apply clipping for large lines to achieve a better rendering performance
75  if ( clipToExtent && nPoints > 1 )
76  {
77  const QgsRectangle& e = context.extent();
78  double cw = e.width() / 10; double ch = e.height() / 10;
79  QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch );
80  wkbPtr = QgsConstWkbPtr( QgsClipper::clippedLineWKB( wkb, clipRect, pts ) );
81  }
82  else
83  {
84  pts.resize( nPoints );
85 
86  QPointF* ptr = pts.data();
87  for ( unsigned int i = 0; i < nPoints; ++i, ++ptr )
88  {
89  wkbPtr >> x >> y;
90  if ( hasZValue )
91  wkbPtr += sizeof( double );
92 
93  *ptr = QPointF( x, y );
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 
112 const unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent )
113 {
114  QgsConstWkbPtr wkbPtr( wkb + 1 );
115 
116  unsigned int wkbType, numRings;
117  wkbPtr >> wkbType >> numRings;
118 
119  if ( numRings == 0 ) // sanity check for zero rings in polygon
120  return wkbPtr;
121 
122  bool hasZValue = ( wkbType == QGis::WKBPolygon25D );
123 
124  double x, y;
125  holes.clear();
126 
127  const QgsCoordinateTransform* ct = context.coordinateTransform();
128  const QgsMapToPixel& mtp = context.mapToPixel();
129  const QgsRectangle& e = context.extent();
130  double cw = e.width() / 10; double ch = e.height() / 10;
131  QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch );
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 >> x >> y;
145  if ( hasZValue )
146  wkbPtr += sizeof( double );
147 
148  *ptr = QPointF( x, y );
149  }
150 
151  if ( nPoints < 1 )
152  continue;
153 
154  //clip close to view extent, if needed
155  QRectF ptsRect = poly.boundingRect();
156  if ( clipToExtent && !context.extent().contains( ptsRect ) ) QgsClipper::trimPolygon( poly, clipRect );
157 
158  //transform the QPolygonF to screen coordinates
159  if ( ct )
160  {
161  ct->transformPolygon( poly );
162  }
163 
164 
165  ptr = poly.data();
166  for ( int i = 0; i < poly.size(); ++i, ++ptr )
167  {
168  mtp.transformInPlace( ptr->rx(), ptr->ry() );
169  }
170 
171  if ( idx == 0 )
172  pts = poly;
173  else
174  holes.append( poly );
175  }
176 
177  return wkbPtr;
178 }
179 
181 {
182  if ( symbol )
183  {
184  if ( symbol->type() == QgsSymbolV2::Marker )
185  {
186  QgsMarkerSymbolV2* ms = static_cast<QgsMarkerSymbolV2*>( symbol );
187  if ( ms )
188  {
189  ms->setScaleMethod(( QgsSymbolV2::ScaleMethod )scaleMethod );
190  }
191  }
192  }
193 }
194 
196 {
197  if ( !destRenderer || !mPaintEffect )
198  return;
199 
200  destRenderer->setPaintEffect( mPaintEffect->clone() );
201 }
202 
203 
205  : mType( type )
206  , mUsingSymbolLevels( false )
207  , mCurrentVertexMarkerType( QgsVectorLayer::Cross )
208  , mCurrentVertexMarkerSize( 3 )
209  , mPaintEffect( 0 )
210 {
211  QgsEffectStack* stack = new QgsEffectStack();
212  stack->appendEffect( new QgsDrawSourceEffect() );
213  mPaintEffect = stack;
214  mPaintEffect->setEnabled( false );
215 }
216 
218 {
219  delete mPaintEffect;
220 }
221 
223 {
224  return new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol( geomType ) );
225 }
226 
228 {
229  startRender( context, vlayer->pendingFields() );
230 }
231 
232 bool QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
233 {
234  QgsSymbolV2* symbol = symbolForFeature( feature );
235  if ( symbol == NULL )
236  return false;
237 
238  renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
239  return true;
240 }
241 
242 void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymbolV2* symbol, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
243 {
244  QgsSymbolV2::SymbolType symbolType = symbol->type();
245 
246  QgsGeometry* geom = feature.geometry();
247  switch ( geom->wkbType() )
248  {
249  case QGis::WKBPoint:
250  case QGis::WKBPoint25D:
251  {
252  if ( symbolType != QgsSymbolV2::Marker )
253  {
254  QgsDebugMsg( "point can be drawn only with marker symbol!" );
255  break;
256  }
257  QPointF pt;
258  _getPoint( pt, context, geom->asWkb() );
259  (( QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
260 
261  //if ( drawVertexMarker )
262  // renderVertexMarker( pt, context );
263  }
264  break;
265 
266  case QGis::WKBLineString:
268  {
269  if ( symbolType != QgsSymbolV2::Line )
270  {
271  QgsDebugMsg( "linestring can be drawn only with line symbol!" );
272  break;
273  }
274  QPolygonF pts;
275  _getLineString( pts, context, geom->asWkb(), symbol->clipFeaturesToExtent() );
276  (( QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
277 
278  if ( drawVertexMarker )
279  renderVertexMarkerPolyline( pts, context );
280  }
281  break;
282 
283  case QGis::WKBPolygon:
284  case QGis::WKBPolygon25D:
285  {
286  if ( symbolType != QgsSymbolV2::Fill )
287  {
288  QgsDebugMsg( "polygon can be drawn only with fill symbol!" );
289  break;
290  }
291  QPolygonF pts;
292  QList<QPolygonF> holes;
293  _getPolygon( pts, holes, context, geom->asWkb(), symbol->clipFeaturesToExtent() );
294  (( QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
295 
296  if ( drawVertexMarker )
297  renderVertexMarkerPolygon( pts, ( holes.count() ? &holes : NULL ), context );
298  }
299  break;
300 
301  case QGis::WKBMultiPoint:
303  {
304  if ( symbolType != QgsSymbolV2::Marker )
305  {
306  QgsDebugMsg( "multi-point can be drawn only with marker symbol!" );
307  break;
308  }
309 
310  QgsConstWkbPtr wkbPtr( geom->asWkb() + 1 + sizeof( int ) );
311  unsigned int num;
312  wkbPtr >> num;
313  const unsigned char* ptr = wkbPtr;
314  QPointF pt;
315 
316  for ( unsigned int i = 0; i < num; ++i )
317  {
318  ptr = QgsConstWkbPtr( _getPoint( pt, context, ptr ) );
319  (( QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
320 
321  //if ( drawVertexMarker )
322  // renderVertexMarker( pt, context );
323  }
324  }
325  break;
326 
329  {
330  if ( symbolType != QgsSymbolV2::Line )
331  {
332  QgsDebugMsg( "multi-linestring can be drawn only with line symbol!" );
333  break;
334  }
335 
336  QgsConstWkbPtr wkbPtr( geom->asWkb() + 1 + sizeof( int ) );
337  unsigned int num;
338  wkbPtr >> num;
339  const unsigned char* ptr = wkbPtr;
340  QPolygonF pts;
341 
342  for ( unsigned int i = 0; i < num; ++i )
343  {
344  ptr = QgsConstWkbPtr( _getLineString( pts, context, ptr, symbol->clipFeaturesToExtent() ) );
345  (( QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
346 
347  if ( drawVertexMarker )
348  renderVertexMarkerPolyline( pts, context );
349  }
350  }
351  break;
352 
355  {
356  if ( symbolType != QgsSymbolV2::Fill )
357  {
358  QgsDebugMsg( "multi-polygon can be drawn only with fill symbol!" );
359  break;
360  }
361 
362  QgsConstWkbPtr wkbPtr( geom->asWkb() + 1 + sizeof( int ) );
363  unsigned int num;
364  wkbPtr >> num;
365  const unsigned char* ptr = wkbPtr;
366  QPolygonF pts;
367  QList<QPolygonF> holes;
368 
369  for ( unsigned int i = 0; i < num; ++i )
370  {
371  ptr = _getPolygon( pts, holes, context, ptr, symbol->clipFeaturesToExtent() );
372  (( QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
373 
374  if ( drawVertexMarker )
375  renderVertexMarkerPolygon( pts, ( holes.count() ? &holes : NULL ), context );
376  }
377  }
378  break;
379 
380  default:
381  QgsDebugMsg( QString( "feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.id() ).arg( geom->wkbType(), 0, 16 ) );
382  }
383 }
384 
386 {
387  return "UNKNOWN RENDERER\n";
388 }
389 
390 
392 {
393  // <renderer-v2 type=""> ... </renderer-v2>
394 
395  if ( element.isNull() )
396  return NULL;
397 
398  // load renderer
399  QString rendererType = element.attribute( "type" );
400 
402  if ( m == NULL )
403  return NULL;
404 
405  QgsFeatureRendererV2* r = m->createRenderer( element );
406  if ( r )
407  {
408  r->setUsingSymbolLevels( element.attribute( "symbollevels", "0" ).toInt() );
409 
410  //restore layer effect
411  QDomElement effectElem = element.firstChildElement( "effect" );
412  if ( !effectElem.isNull() )
413  {
414  r->setPaintEffect( QgsPaintEffectRegistry::instance()->createEffect( effectElem ) );
415  }
416  }
417  return r;
418 }
419 
420 QDomElement QgsFeatureRendererV2::save( QDomDocument& doc )
421 {
422  // create empty renderer element
423  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
424 
425  if ( mPaintEffect )
426  mPaintEffect->saveProperties( doc, rendererElem );
427 
428  return rendererElem;
429 }
430 
431 QgsFeatureRendererV2* QgsFeatureRendererV2::loadSld( const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage )
432 {
433  QDomElement element = node.toElement();
434  if ( element.isNull() )
435  return NULL;
436 
437  // get the UserStyle element
438  QDomElement userStyleElem = element.firstChildElement( "UserStyle" );
439  if ( userStyleElem.isNull() )
440  {
441  // UserStyle element not found, nothing will be rendered
442  errorMessage = "Info: UserStyle element not found.";
443  return NULL;
444  }
445 
446  // get the FeatureTypeStyle element
447  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( "FeatureTypeStyle" );
448  if ( featTypeStyleElem.isNull() )
449  {
450  errorMessage = "Info: FeatureTypeStyle element not found.";
451  return NULL;
452  }
453 
454  // use the RuleRenderer when more rules are present or the rule
455  // has filters or min/max scale denominators set,
456  // otherwise use the SingleSymbol renderer
457  bool needRuleRenderer = false;
458  int ruleCount = 0;
459 
460  QDomElement ruleElem = featTypeStyleElem.firstChildElement( "Rule" );
461  while ( !ruleElem.isNull() )
462  {
463  ruleCount++;
464 
465  // more rules present, use the RuleRenderer
466  if ( ruleCount > 1 )
467  {
468  QgsDebugMsg( "more Rule elements found: need a RuleRenderer" );
469  needRuleRenderer = true;
470  break;
471  }
472 
473  QDomElement ruleChildElem = ruleElem.firstChildElement();
474  while ( !ruleChildElem.isNull() )
475  {
476  // rule has filter or min/max scale denominator, use the RuleRenderer
477  if ( ruleChildElem.localName() == "Filter" ||
478  ruleChildElem.localName() == "MinScaleDenominator" ||
479  ruleChildElem.localName() == "MaxScaleDenominator" )
480  {
481  QgsDebugMsg( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
482  needRuleRenderer = true;
483  break;
484  }
485 
486  ruleChildElem = ruleChildElem.nextSiblingElement();
487  }
488 
489  if ( needRuleRenderer )
490  {
491  break;
492  }
493 
494  ruleElem = ruleElem.nextSiblingElement( "Rule" );
495  }
496 
497  QString rendererType;
498  if ( needRuleRenderer )
499  {
500  rendererType = "RuleRenderer";
501  }
502  else
503  {
504  rendererType = "singleSymbol";
505  }
506  QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
507 
508  // create the renderer and return it
510  if ( m == NULL )
511  {
512  errorMessage = QString( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
513  return NULL;
514  }
515 
516  QgsFeatureRendererV2* r = m->createRendererFromSld( featTypeStyleElem, geomType );
517  return r;
518 }
519 
520 QDomElement QgsFeatureRendererV2::writeSld( QDomDocument& doc, const QgsVectorLayer &layer ) const
521 {
522  return writeSld( doc, layer.name() );
523 }
524 
525 QDomElement QgsFeatureRendererV2::writeSld( QDomDocument& doc, const QString& styleName ) const
526 {
527  QDomElement userStyleElem = doc.createElement( "UserStyle" );
528 
529  QDomElement nameElem = doc.createElement( "se:Name" );
530  nameElem.appendChild( doc.createTextNode( styleName ) );
531  userStyleElem.appendChild( nameElem );
532 
533  QDomElement featureTypeStyleElem = doc.createElement( "se:FeatureTypeStyle" );
534  toSld( doc, featureTypeStyleElem );
535  userStyleElem.appendChild( featureTypeStyleElem );
536 
537  return userStyleElem;
538 }
539 
541 {
542  Q_UNUSED( iconSize );
543  // empty list by default
544  return QgsLegendSymbologyList();
545 }
546 
548 {
549  return false;
550 }
551 
553 {
554  Q_UNUSED( key );
555  return false;
556 }
557 
558 void QgsFeatureRendererV2::checkLegendSymbolItem( QString key, bool state )
559 {
560  Q_UNUSED( key );
561  Q_UNUSED( state );
562 }
563 
564 QgsLegendSymbolList QgsFeatureRendererV2::legendSymbolItems( double scaleDenominator, QString rule )
565 {
566  Q_UNUSED( scaleDenominator );
567  Q_UNUSED( rule );
568  return QgsLegendSymbolList();
569 }
570 
572 {
573  QgsLegendSymbolList lst = const_cast<QgsFeatureRendererV2*>( this )->legendSymbolItems();
575  int i = 0;
576  for ( QgsLegendSymbolList::const_iterator it = lst.begin(); it != lst.end(); ++it, ++i )
577  {
578  lst2 << QgsLegendSymbolItemV2( it->second, it->first, QString::number( i ), legendSymbolItemsCheckable() );
579  }
580  return lst2;
581 }
582 
584 {
587 }
588 
590 {
591  QgsVectorLayer::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
594 }
595 
597 {
598  foreach ( QPointF pt, pts )
599  renderVertexMarker( pt, context );
600 }
601 
602 void QgsFeatureRendererV2::renderVertexMarkerPolygon( QPolygonF& pts, QList<QPolygonF>* rings, QgsRenderContext& context )
603 {
604  foreach ( QPointF pt, pts )
605  renderVertexMarker( pt, context );
606 
607  if ( rings )
608  {
609  foreach ( QPolygonF ring, *rings )
610  {
611  foreach ( QPointF pt, ring )
612  renderVertexMarker( pt, context );
613  }
614  }
615 }
616 
618 {
619  QgsSymbolV2List lst;
620  QgsSymbolV2* s = symbolForFeature( feat );
621  if ( s ) lst.append( s );
622  return lst;
623 }
624 
626 {
627  QgsSymbolV2List lst;
629  if ( s ) lst.append( s );
630  return lst;
631 }
632 
634 {
635  return mPaintEffect;
636 }
637 
639 {
640  delete mPaintEffect;
641  mPaintEffect = effect;
642 }
QgsFeatureId id() const
Get the feature id for this feature.
Definition: qgsfeature.cpp:100
static QgsRendererV2Registry * instance()
#define RENDERER_TAG_NAME
Definition: qgsrendererv2.h:48
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
Definition: qgsrendererv2.h:96
virtual void checkLegendSymbolItem(QString key, bool state=true)
item in symbology was checked
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
QList< QgsSymbolV2 * > QgsSymbolV2List
Definition: qgsrendererv2.h:39
QgsRendererV2AbstractMetadata * rendererMetadata(QString rendererName)
get metadata for particular renderer. Returns NULL if not found in registry.
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:85
static const unsigned char * _getPoint(QPointF &pt, QgsRenderContext &context, const unsigned char *wkb)
void transformPolygon(QPolygonF &poly, TransformDirection direction=ForwardTransform) const
virtual QString dump() const
for debugging
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:188
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
void transformInPlace(qreal &x, qreal &y) 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:39
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
Definition: qgsfeature.cpp:112
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
static QgsPaintEffectRegistry * instance()
Definition: qgssingleton.h:23
double clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
Definition: qgssymbolv2.h:182
Base class for visual effects which can be applied to QPicture drawings.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
return a list of item text / symbol
Stores metadata about one renderer class.
virtual ~QgsFeatureRendererV2()
GeometryType
Definition: qgis.h:155
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:113
const QgsCoordinateTransform * coordinateTransform() const
QgsPaintEffect * mPaintEffect
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
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
void renderFeatureWithSymbol(QgsFeature &feature, QgsSymbolV2 *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
QString type() const
Definition: qgsrendererv2.h:82
const QString & name() const
Get the display name of the layer.
virtual QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
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 transformInPlace(double &x, double &y, double &z, TransformDirection direction=ForwardTransform) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:193
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:178
virtual bool legendSymbolItemChecked(QString key)
items of symbology items in legend is checked
int mCurrentVertexMarkerSize
The current size of editing marker.
VertexMarkerType
Editing vertex markers.
int mCurrentVertexMarkerType
The current type of editing marker.
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.
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
A paint effect which consists of a stack of other chained paint effects.
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
void appendEffect(QgsPaintEffect *effect)
Appends an effect to the end of the stack.
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
QgsFeatureRendererV2(QString type)
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
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.
QPainter * painter()
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
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return 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.
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
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
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)
QList< QgsLegendSymbolItemV2 > QgsLegendSymbolListV2
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
A paint effect which draws the source picture with minor or no alterations.
double width() const
Width of the rectangle.
Definition: qgsrectangle.h:198
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
Definition: qgsclipper.h:178
virtual QgsFeatureRendererV2 * createRendererFromSld(QDomElement &elem, QGis::GeometryType geomType)
Represents a vector layer which manages a vector based data sets.
double size
Definition: qgssvgcache.cpp:77
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
Definition: qgsrendererv2.h:43
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:183
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
void renderVertexMarker(QPointF &pt, QgsRenderContext &context)
render editing vertex marker at specified point
double height() const
Height of the rectangle.
Definition: qgsrectangle.h:203