QGIS API Documentation  2.9.0-Master
qgssymbollayerv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerv2.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 "qgssymbollayerv2.h"
17 #include "qgsclipper.h"
18 #include "qgsexpression.h"
19 #include "qgsrendercontext.h"
20 #include "qgsvectorlayer.h"
21 #include "qgsdxfexport.h"
22 #include "qgsgeometrysimplifier.h"
23 #include "qgspainteffect.h"
24 #include "qgseffectstack.h"
25 #include "qgsdatadefined.h"
26 
27 #include <QSize>
28 #include <QPainter>
29 #include <QPointF>
30 #include <QPolygonF>
31 
32 const QString QgsSymbolLayerV2::EXPR_SIZE( "size" );
33 const QString QgsSymbolLayerV2::EXPR_ANGLE( "angle" );
34 const QString QgsSymbolLayerV2::EXPR_NAME( "name" );
35 const QString QgsSymbolLayerV2::EXPR_COLOR( "color" );
36 const QString QgsSymbolLayerV2::EXPR_COLOR_BORDER( "color_border" );
37 const QString QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH( "outline_width" );
38 const QString QgsSymbolLayerV2::EXPR_OUTLINE_STYLE( "outline_style" );
39 const QString QgsSymbolLayerV2::EXPR_FILL( "fill" );
40 const QString QgsSymbolLayerV2::EXPR_OUTLINE( "outline" );
41 const QString QgsSymbolLayerV2::EXPR_OFFSET( "offset" );
42 const QString QgsSymbolLayerV2::EXPR_CHAR( "char" );
43 const QString QgsSymbolLayerV2::EXPR_FILL_COLOR( "fill_color" );
44 const QString QgsSymbolLayerV2::EXPR_OUTLINE_COLOR( "outline_color" );
45 const QString QgsSymbolLayerV2::EXPR_WIDTH( "width" );
46 const QString QgsSymbolLayerV2::EXPR_HEIGHT( "height" );
47 const QString QgsSymbolLayerV2::EXPR_SYMBOL_NAME( "symbol_name" );
48 const QString QgsSymbolLayerV2::EXPR_ROTATION( "rotation" );
49 const QString QgsSymbolLayerV2::EXPR_FILL_STYLE( "fill_style" );
50 const QString QgsSymbolLayerV2::EXPR_WIDTH_BORDER( "width_border" );
51 const QString QgsSymbolLayerV2::EXPR_BORDER_STYLE( "border_style" );
52 const QString QgsSymbolLayerV2::EXPR_JOIN_STYLE( "join_style" );
53 const QString QgsSymbolLayerV2::EXPR_BORDER_COLOR( "border_color" );
54 const QString QgsSymbolLayerV2::EXPR_COLOR2( "color2" );
55 const QString QgsSymbolLayerV2::EXPR_LINEANGLE( "lineangle" );
56 const QString QgsSymbolLayerV2::EXPR_GRADIENT_TYPE( "gradient_type" );
57 const QString QgsSymbolLayerV2::EXPR_COORDINATE_MODE( "coordinate_mode" );
58 const QString QgsSymbolLayerV2::EXPR_SPREAD( "spread" );
59 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_X( "reference1_x" );
60 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_Y( "reference1_y" );
61 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_X( "reference2_x" );
62 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_Y( "reference2_y" );
63 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_ISCENTROID( "reference1_iscentroid" );
64 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_ISCENTROID( "reference2_iscentroid" );
65 const QString QgsSymbolLayerV2::EXPR_BLUR_RADIUS( "blur_radius" );
66 const QString QgsSymbolLayerV2::EXPR_DISTANCE( "distance" );
67 const QString QgsSymbolLayerV2::EXPR_USE_WHOLE_SHAPE( "use_whole_shape" );
68 const QString QgsSymbolLayerV2::EXPR_MAX_DISTANCE( "max_distance" );
69 const QString QgsSymbolLayerV2::EXPR_IGNORE_RINGS( "ignore_rings" );
70 const QString QgsSymbolLayerV2::EXPR_SVG_FILE( "svgFile" );
71 const QString QgsSymbolLayerV2::EXPR_SVG_FILL_COLOR( "svgFillColor" );
72 const QString QgsSymbolLayerV2::EXPR_SVG_OUTLINE_COLOR( "svgOutlineColor" );
73 const QString QgsSymbolLayerV2::EXPR_SVG_OUTLINE_WIDTH( "svgOutlineWidth" );
74 const QString QgsSymbolLayerV2::EXPR_LINEWIDTH( "linewidth" );
75 const QString QgsSymbolLayerV2::EXPR_DISTANCE_X( "distance_x" );
76 const QString QgsSymbolLayerV2::EXPR_DISTANCE_Y( "distance_y" );
77 const QString QgsSymbolLayerV2::EXPR_DISPLACEMENT_X( "displacement_x" );
78 const QString QgsSymbolLayerV2::EXPR_DISPLACEMENT_Y( "displacement_y" );
79 const QString QgsSymbolLayerV2::EXPR_FILE( "file" );
80 const QString QgsSymbolLayerV2::EXPR_ALPHA( "alpha" );
81 const QString QgsSymbolLayerV2::EXPR_CUSTOMDASH( "customdash" );
82 const QString QgsSymbolLayerV2::EXPR_LINE_STYLE( "line_style" );
83 const QString QgsSymbolLayerV2::EXPR_JOINSTYLE( "joinstyle" );
84 const QString QgsSymbolLayerV2::EXPR_CAPSTYLE( "capstyle" );
85 const QString QgsSymbolLayerV2::EXPR_PLACEMENT( "placement" );
86 const QString QgsSymbolLayerV2::EXPR_INTERVAL( "interval" );
87 const QString QgsSymbolLayerV2::EXPR_OFFSET_ALONG_LINE( "offset_along_line" );
88 const QString QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT( "horizontal_anchor_point" );
89 const QString QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT( "vertical_anchor_point" );
90 
91 const QgsExpression* QgsSymbolLayerV2::dataDefinedProperty( const QString& property ) const
92 {
94  return expression( property );
96 }
97 
99 {
100  if ( mDataDefinedProperties.isEmpty() )
101  return 0;
102 
103  QMap< QString, QgsDataDefined* >::const_iterator it = mDataDefinedProperties.find( property );
104  if ( it != mDataDefinedProperties.constEnd() )
105  {
106  return it.value();
107  }
108  return 0;
109 }
110 
111 QgsExpression* QgsSymbolLayerV2::expression( const QString& property ) const
112 {
113  QgsDataDefined* dd = getDataDefinedProperty( property );
114  return dd ? dd->expression() : 0;
115 }
116 
117 QString QgsSymbolLayerV2::dataDefinedPropertyString( const QString& property ) const
118 {
119  const QgsDataDefined* dd = getDataDefinedProperty( property );
120  return dd ? dd->expressionString() : QString();
121 }
122 
123 void QgsSymbolLayerV2::setDataDefinedProperty( const QString& property, const QString& expressionString )
124 {
125  setDataDefinedProperty( property, new QgsDataDefined( expressionString ) );
126 }
127 
128 void QgsSymbolLayerV2::setDataDefinedProperty( const QString &property, QgsDataDefined *dataDefined )
129 {
130  removeDataDefinedProperty( property );
131  mDataDefinedProperties.insert( property, dataDefined );
132 }
133 
134 void QgsSymbolLayerV2::removeDataDefinedProperty( const QString& property )
135 {
136  QMap< QString, QgsDataDefined* >::iterator it = mDataDefinedProperties.find( property );
137  if ( it != mDataDefinedProperties.end() )
138  {
139  delete( it.value() );
140  mDataDefinedProperties.erase( it );
141  }
142 }
143 
145 {
146  QMap< QString, QgsDataDefined* >::iterator it = mDataDefinedProperties.begin();
147  for ( ; it != mDataDefinedProperties.constEnd(); ++it )
148  {
149  delete( it.value() );
150  }
151  mDataDefinedProperties.clear();
152 }
153 
155 {
156  if ( mDataDefinedProperties.isEmpty() )
157  return false;
158 
159  QMap< QString, QgsDataDefined* >::const_iterator it = mDataDefinedProperties.constBegin();
160  for ( ; it != mDataDefinedProperties.constEnd(); ++it )
161  {
162  if ( hasDataDefinedProperty( it.key() ) )
163  return true;
164  }
165 
166  return false;
167 }
168 
169 bool QgsSymbolLayerV2::hasDataDefinedProperty( const QString& property ) const
170 {
171  if ( mDataDefinedProperties.isEmpty() )
172  return false;
173 
174  QgsDataDefined* dd = getDataDefinedProperty( property );
175  return dd && dd->isActive();
176 }
177 
178 QVariant QgsSymbolLayerV2::evaluateDataDefinedProperty( const QString &property, const QgsFeature* feature, const QVariant& defaultVal, bool *ok ) const
179 {
180  if ( ok )
181  *ok = false;
182 
183  QgsDataDefined* dd = getDataDefinedProperty( property );
184  if ( !dd || !dd->isActive() )
185  return defaultVal;
186 
187  if ( dd->useExpression() )
188  {
189  if ( dd->expression() )
190  {
191  QVariant result = dd->expression()->evaluate( feature );
192  if ( result.isValid() )
193  {
194  if ( ok )
195  *ok = true;
196  return result;
197  }
198  else
199  return defaultVal;
200  }
201  else
202  {
203  return defaultVal;
204  }
205  }
206  else if ( feature && !dd->field().isEmpty() && !mFields.isEmpty() )
207  {
208  int attributeIndex = mFields.fieldNameIndex( dd->field() );
209  if ( attributeIndex >= 0 )
210  {
211  if ( ok )
212  *ok = true;
213  return feature->attribute( attributeIndex );
214  }
215  }
216  return defaultVal;
217 }
218 
220  double mmMapUnitScaleFactor,
221  const QString& layerName,
222  const QgsSymbolV2RenderContext* context,
223  const QgsFeature* f,
224  const QPointF& shift ) const
225 {
226  Q_UNUSED( e );
227  Q_UNUSED( mmMapUnitScaleFactor );
228  Q_UNUSED( layerName );
229  Q_UNUSED( context );
230  Q_UNUSED( f );
231  Q_UNUSED( shift );
232  return false;
233 }
234 
235 double QgsSymbolLayerV2::dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const
236 {
237  Q_UNUSED( e );
238  Q_UNUSED( context );
239  return 1.0;
240 }
241 
242 double QgsSymbolLayerV2::dxfOffset( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const
243 {
244  Q_UNUSED( e );
245  Q_UNUSED( context );
246  return 0.0;
247 }
248 
250 {
251  Q_UNUSED( context );
252  return color();
253 }
254 
256 {
257  Q_UNUSED( unit );
258  return QVector<qreal>();
259 }
260 
261 Qt::PenStyle QgsSymbolLayerV2::dxfPenStyle() const
262 {
263  return Qt::SolidLine;
264 }
265 
267 {
268  Q_UNUSED( context );
269  return color();
270 }
271 
272 Qt::BrushStyle QgsSymbolLayerV2::dxfBrushStyle() const
273 {
274  return Qt::NoBrush;
275 }
276 
278 {
279  return mPaintEffect;
280 }
281 
283 {
284  delete mPaintEffect;
285  mPaintEffect = effect;
286 }
287 
289  : mType( type )
290  , mLocked( locked )
291  , mRenderingPass( 0 )
292  , mPaintEffect( 0 )
293 {
294  QgsEffectStack* stack = new QgsEffectStack();
295  stack->appendEffect( new QgsDrawSourceEffect() );
296  mPaintEffect = stack;
297  mPaintEffect->setEnabled( false );
298 }
299 
300 void QgsSymbolLayerV2::prepareExpressions( const QgsFields* fields, double scale )
301 {
302  QMap< QString, QgsDataDefined* >::iterator it = mDataDefinedProperties.begin();
303  for ( ; it != mDataDefinedProperties.end(); ++it )
304  {
305  if ( it.value() )
306  {
307  QMap<QString, QVariant> params;
308  if ( scale > 0 )
309  {
310  params.insert( "scale", scale );
311  }
312  it.value()->setExpressionParams( params );
313 
314  if ( fields )
315  {
316  it.value()->prepareExpression( *fields );
317  }
318  else
319  {
320  it.value()->prepareExpression();
321  }
322  }
323  }
324 
325  if ( fields )
326  {
327  //QgsFields is implicitly shared, so it's cheap to make a copy
328  mFields = *fields;
329  }
330 }
331 
333 {
335  delete mPaintEffect;
336 }
337 
338 QSet<QString> QgsSymbolLayerV2::usedAttributes() const
339 {
340  QStringList columns;
341 
342  QMap< QString, QgsDataDefined* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
343  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
344  {
345  if ( ddIt.value() && ddIt.value()->isActive() )
346  {
347  columns.append( ddIt.value()->referencedColumns() );
348  }
349  }
350 
351  return columns.toSet();
352 }
353 
355 {
356  QMap< QString, QgsDataDefined* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
357  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
358  {
359  if ( ddIt.value() )
360  {
361  stringMap.unite( ddIt.value()->toMap( ddIt.key() ) );
362  }
363  }
364 }
365 
367 {
368  QgsStringMap::const_iterator propIt = stringMap.constBegin();
369  for ( ; propIt != stringMap.constEnd(); ++propIt )
370  {
371  if ( propIt.key().endsWith( "_dd_expression" ) )
372  {
373  //found a data defined property
374 
375  //get data defined property name by stripping "_dd_expression" from property key
376  QString propertyName = propIt.key().left( propIt.key().length() - 14 );
377 
378  QgsDataDefined* dd = QgsDataDefined::fromMap( stringMap, propertyName );
379  if ( dd )
380  setDataDefinedProperty( propertyName, dd );
381  }
382  else if ( propIt.key().endsWith( "_expression" ) )
383  {
384  //old style data defined property, upgrade
385 
386  //get data defined property name by stripping "_expression" from property key
387  QString propertyName = propIt.key().left( propIt.key().length() - 11 );
388 
389  setDataDefinedProperty( propertyName, new QgsDataDefined( propIt.value() ) );
390  }
391  }
392 }
393 
395 {
396  if ( !destLayer )
397  return;
398 
399  destLayer->removeDataDefinedProperties();
400 
401  QMap< QString, QgsDataDefined* >::const_iterator ddIt = mDataDefinedProperties.constBegin();
402  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
403  {
404  if ( ddIt.value() )
405  {
406  destLayer->setDataDefinedProperty( ddIt.key(), new QgsDataDefined( *( ddIt.value() ) ) );
407  }
408  }
409 }
410 
412 {
413  if ( !destLayer || !mPaintEffect )
414  return;
415 
416  destLayer->setPaintEffect( mPaintEffect->clone() );
417 }
418 
420  : QgsSymbolLayerV2( QgsSymbolV2::Marker, locked )
421  , mAngle( 0 )
422  , mLineAngle( 0 )
423  , mSize( 2.0 )
424  , mSizeUnit( QgsSymbolV2::MM )
425  , mOffsetUnit( QgsSymbolV2::MM )
426  , mScaleMethod( QgsSymbolV2::ScaleArea )
427  , mHorizontalAnchorPoint( HCenter )
428  , mVerticalAnchorPoint( VCenter )
429 {
430 
431 }
432 
434  : QgsSymbolLayerV2( QgsSymbolV2::Line, locked )
435  , mWidth( 0 )
436  , mWidthUnit( QgsSymbolV2::MM )
437  , mOffset( 0 )
438  , mOffsetUnit( QgsSymbolV2::MM )
439 {
440 }
441 
443  : QgsSymbolLayerV2( QgsSymbolV2::Fill, locked )
444  , mAngle( 0.0 )
445 {
446 }
447 
449 {
450  Q_UNUSED( context );
451 }
452 
454 {
455  startRender( context );
456  renderPoint( QPointF( size.width() / 2, size.height() / 2 ), context );
457  stopRender( context );
458 }
459 
460 void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& context, double& offsetX, double& offsetY ) const
461 {
463 }
464 
465 void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& context, double width, double height, double& offsetX, double& offsetY ) const
466 {
467  markerOffset( context, width, height, mSizeUnit, mSizeUnit, offsetX, offsetY, mSizeMapUnitScale, mSizeMapUnitScale );
468 }
469 
470 void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& context, double width, double height,
471  QgsSymbolV2::OutputUnit widthUnit, QgsSymbolV2::OutputUnit heightUnit,
472  double& offsetX, double& offsetY, const QgsMapUnitScale& widthMapUnitScale, const QgsMapUnitScale& heightMapUnitScale ) const
473 {
474  offsetX = mOffset.x();
475  offsetY = mOffset.y();
476 
478  {
480  offsetX = offset.x();
481  offsetY = offset.y();
482  }
483 
486 
490  {
491  horizontalAnchorPoint = decodeHorizontalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT , context.feature() ).toString() );
492  }
494  {
495  verticalAnchorPoint = decodeVerticalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT, context.feature() ).toString() );
496  }
497 
498  //correct horizontal position according to anchor point
499  if ( horizontalAnchorPoint == HCenter && verticalAnchorPoint == VCenter )
500  {
501  return;
502  }
503 
504  double anchorPointCorrectionX = width * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), widthUnit, widthMapUnitScale ) / 2.0;
505  double anchorPointCorrectionY = height * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), heightUnit, heightMapUnitScale ) / 2.0;
506  if ( horizontalAnchorPoint == Left )
507  {
508  offsetX += anchorPointCorrectionX;
509  }
510  else if ( horizontalAnchorPoint == Right )
511  {
512  offsetX -= anchorPointCorrectionX;
513  }
514 
515  //correct vertical position according to anchor point
516  if ( verticalAnchorPoint == Top )
517  {
518  offsetY += anchorPointCorrectionY;
519  }
520  else if ( verticalAnchorPoint == Bottom )
521  {
522  offsetY -= anchorPointCorrectionY;
523  }
524 }
525 
526 QPointF QgsMarkerSymbolLayerV2::_rotatedOffset( const QPointF& offset, double angle )
527 {
528  angle = DEG2RAD( angle );
529  double c = cos( angle ), s = sin( angle );
530  return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c );
531 }
532 
533 QgsMarkerSymbolLayerV2::HorizontalAnchorPoint QgsMarkerSymbolLayerV2::decodeHorizontalAnchorPoint( const QString& str )
534 {
535  if ( str.compare( "left", Qt::CaseInsensitive ) == 0 )
536  {
538  }
539  else if ( str.compare( "right", Qt::CaseInsensitive ) == 0 )
540  {
542  }
543  else
544  {
546  }
547 }
548 
549 QgsMarkerSymbolLayerV2::VerticalAnchorPoint QgsMarkerSymbolLayerV2::decodeVerticalAnchorPoint( const QString& str )
550 {
551  if ( str.compare( "top", Qt::CaseInsensitive ) == 0 )
552  {
554  }
555  else if ( str.compare( "bottom", Qt::CaseInsensitive ) == 0 )
556  {
558  }
559  else
560  {
562  }
563 }
564 
566 {
567  mSizeUnit = unit;
568  mOffsetUnit = unit;
569 }
570 
572 {
573  if ( mOffsetUnit != mSizeUnit )
574  {
575  return QgsSymbolV2::Mixed;
576  }
577  return mOffsetUnit;
578 }
579 
581 {
582  mSizeMapUnitScale = scale;
583  mOffsetMapUnitScale = scale;
584 }
585 
587 {
589  {
590  return mSizeMapUnitScale;
591  }
592  return QgsMapUnitScale();
593 }
594 
596 {
597  mWidthUnit = unit;
598 }
599 
601 {
602  return mWidthUnit;
603 }
604 
606 {
607  mWidthMapUnitScale = scale;
608 }
609 
611 {
612  return mWidthMapUnitScale;
613 }
614 
615 
617 {
618  QPolygonF points;
619  // we're adding 0.5 to get rid of blurred preview:
620  // drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
621  points << QPointF( 0, int( size.height() / 2 ) + 0.5 ) << QPointF( size.width(), int( size.height() / 2 ) + 0.5 );
622 
623  startRender( context );
624  renderPolyline( points, context );
625  stopRender( context );
626 }
627 
628 void QgsLineSymbolLayerV2::renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context )
629 {
630  renderPolyline( points, context );
631  if ( rings )
632  {
633  foreach ( const QPolygonF& ring, *rings )
634  renderPolyline( ring, context );
635  }
636 }
637 
639 {
640  Q_UNUSED( context );
642 }
643 
644 
646 {
647  QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width(), size.height() ) );
648  startRender( context );
649  renderPolygon( poly, NULL, context );
650  stopRender( context );
651 }
652 
653 void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context )
654 {
655  if ( !p )
656  {
657  return;
658  }
659 
660  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
661  if ( points.size() <= 5 &&
664  ( p->renderHints() & QPainter::Antialiasing ) )
665  {
666  p->setRenderHint( QPainter::Antialiasing, false );
667  p->drawRect( points.boundingRect() );
668  p->setRenderHint( QPainter::Antialiasing, true );
669  return;
670  }
671 
672  if ( rings == NULL )
673  {
674  // simple polygon without holes
675  p->drawPolygon( points );
676  }
677  else
678  {
679  // polygon with holes must be drawn using painter path
680  QPainterPath path;
681  QPolygonF outerRing = points;
682  path.addPolygon( outerRing );
683 
684  QList<QPolygonF>::const_iterator it = rings->constBegin();
685  for ( ; it != rings->constEnd(); ++it )
686  {
687  QPolygonF ring = *it;
688  path.addPolygon( ring );
689  }
690 
691  p->drawPath( path );
692  }
693 }
694 
695 void QgsMarkerSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
696 {
697  QDomElement symbolizerElem = doc.createElement( "se:PointSymbolizer" );
698  if ( !props.value( "uom", "" ).isEmpty() )
699  symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
700  element.appendChild( symbolizerElem );
701 
702  // <Geometry>
703  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );
704 
705  writeSldMarker( doc, symbolizerElem, props );
706 }
707 
708 
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits)
static const QString EXPR_DISTANCE_Y
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:86
VerticalAnchorPoint verticalAnchorPoint() const
static const QString EXPR_CHAR
static const QString EXPR_OUTLINE_COLOR
static const QString EXPR_DISPLACEMENT_Y
virtual void removeDataDefinedProperties()
Removes all data defined properties from the layer and deletes associated objects.
static const QString EXPR_JOINSTYLE
QgsSymbolV2::OutputUnit outputUnit() const override
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
float threshold() const
Gets the simplification threshold of the vector layer managed.
QgsMapUnitScale mSizeMapUnitScale
virtual Qt::PenStyle dxfPenStyle() const
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
A container class for data source field mapping or expression.
static const QString EXPR_BORDER_COLOR
virtual double width() const
virtual double dxfOffset(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
HorizontalAnchorPoint horizontalAnchorPoint() const
static const QString EXPR_USE_WHOLE_SHAPE
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
static const QString EXPR_REFERENCE2_Y
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
QString field() const
static const QString EXPR_DISPLACEMENT_X
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs...
Definition: qgsfield.cpp:350
QMap< QString, QgsDataDefined * > mDataDefinedProperties
static const QString EXPR_WIDTH
static const QString EXPR_CUSTOMDASH
QGis::UnitType mapUnits() const
Definition: qgsdxfexport.h:54
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:461
#define DEG2RAD(x)
Base class for visual effects which can be applied to QPicture drawings.
QgsSymbolV2::OutputUnit outputUnit() const override
QgsPaintEffect * mPaintEffect
QgsExpression * expression()
static QPointF decodePoint(QString str)
Container of fields for a vector layer.
Definition: qgsfield.h:173
static const QString EXPR_BLUR_RADIUS
static const QString EXPR_COORDINATE_MODE
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)=0
QString expressionString() const
static const QString EXPR_COLOR2
static QgsDataDefined * fromMap(const QgsStringMap &map, const QString &baseName=QString())
Creates a QgsDataDefined from a decoded QgsStringMap.
void copyPaintEffect(QgsSymbolLayerV2 *destLayer) const
Copies paint effect of this layer to another symbol layer.
QgsSymbolLayerV2(QgsSymbolV2::SymbolType type, bool locked=false)
static const QString EXPR_VERTICAL_ANCHOR_POINT
virtual bool hasDataDefinedProperty(const QString &property) const
Checks whether the layer has a matching data defined property and if that property is currently activ...
static const QString EXPR_OFFSET_ALONG_LINE
QgsMapUnitScale mWidthMapUnitScale
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:119
virtual void removeDataDefinedProperty(const QString &property)
Removes a data defined property from the layer.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:438
static const QString EXPR_OFFSET
void setMapUnitScale(const QgsMapUnitScale &scale) override
static const QString EXPR_SIZE
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual Q_DECL_DEPRECATED QString dataDefinedPropertyString(const QString &property) const
Returns a data defined expression for a property, if set.
virtual void startRender(QgsSymbolV2RenderContext &context)=0
static const QString EXPR_JOIN_STYLE
virtual Q_DECL_DEPRECATED QgsExpression * expression(const QString &property) const
Returns the data defined expression associated with a property.
static const QString EXPR_FILL_STYLE
static const QString EXPR_REFERENCE1_Y
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const override
static const QString EXPR_BORDER_STYLE
static const QString EXPR_REFERENCE2_X
static const QString EXPR_REFERENCE2_ISCENTROID
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
static const QString EXPR_LINEWIDTH
static const QString EXPR_PLACEMENT
static const QString EXPR_FILL_COLOR
static const QString EXPR_SPREAD
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
const QgsFeature * feature() const
Current feature being rendered - may be null.
Definition: qgssymbolv2.h:243
static const QString EXPR_LINEANGLE
virtual void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)=0
virtual QVector< qreal > dxfCustomDashPattern(QgsSymbolV2::OutputUnit &unit) const
static const QString EXPR_ALPHA
The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'...
QgsMarkerSymbolLayerV2(bool locked=false)
QgsSymbolV2::OutputUnit mWidthUnit
A paint effect which consists of a stack of other chained paint effects.
virtual QColor color() const
static const QString EXPR_FILL
HorizontalAnchorPoint mHorizontalAnchorPoint
virtual void renderPolygonOutline(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
virtual void prepareExpressions(const QgsFields *fields, double scale=-1.0)
Prepares all data defined property expressions for evaluation.
static const QString EXPR_FILE
virtual QColor dxfBrushColor(const QgsSymbolV2RenderContext &context) const
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties.
void appendEffect(QgsPaintEffect *effect)
Appends an effect to the end of the stack.
static const QString EXPR_CAPSTYLE
static const QString EXPR_OUTLINE_STYLE
bool useExpression() const
virtual QColor dxfColor(const QgsSymbolV2RenderContext &context) const
static const QString EXPR_DISTANCE
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, const QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const
virtual void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const override
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
virtual void renderPolyline(const QPolygonF &points, QgsSymbolV2RenderContext &context)=0
static const QString EXPR_COLOR
static const QString EXPR_WIDTH_BORDER
static const QString EXPR_SVG_FILE
static const QString EXPR_ANGLE
double symbologyScaleDenominator() const
Definition: qgsdxfexport.h:51
static const QString EXPR_DISTANCE_X
static const QString EXPR_REFERENCE1_X
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size) override
QgsFillSymbolLayerV2(bool locked=false)
static const QString EXPR_GRADIENT_TYPE
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:462
void startRender(QgsSymbolV2RenderContext &context) override
static const QString EXPR_OUTLINE_WIDTH
static void createGeometryElement(QDomDocument &doc, QDomElement &element, QString geomFunc)
QgsMapUnitScale mapUnitScale() const override
virtual Qt::BrushStyle dxfBrushStyle() const
static const QString EXPR_SVG_FILL_COLOR
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:236
void setMapUnitScale(const QgsMapUnitScale &scale) override
static double lineWidthScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns the line width scale factor depending on the unit and the paint device.
QgsLineSymbolLayerV2(bool locked=false)
virtual QVariant evaluateDataDefinedProperty(const QString &property, const QgsFeature *feature, const QVariant &defaultVal=QVariant(), bool *ok=0) const
Evaluates the matching data defined property and returns the calculated value.
QgsMapUnitScale mapUnitScale() const override
static const QString EXPR_SVG_OUTLINE_COLOR
static const QString EXPR_NAME
virtual Q_DECL_DEPRECATED const QgsExpression * dataDefinedProperty(const QString &property) const
Returns a data defined expression for a property, if set.
QgsRenderContext & renderContext()
Definition: qgssymbolv2.h:221
virtual QgsDataDefined * getDataDefinedProperty(const QString &property) const
Returns the data defined property corresponding to the specified property key.
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size) override
static const QString EXPR_IGNORE_RINGS
static const QString EXPR_COLOR_BORDER
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
static const QString EXPR_REFERENCE1_ISCENTROID
static const QString EXPR_ROTATION
QgsSymbolV2::OutputUnit mOffsetUnit
VerticalAnchorPoint mVerticalAnchorPoint
QgsSymbolV2::OutputUnit mSizeUnit
QgsMapUnitScale mOffsetMapUnitScale
static const QString EXPR_OUTLINE
void markerOffset(const QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
static const QString EXPR_SVG_OUTLINE_WIDTH
void restoreDataDefinedProperties(const QgsStringMap &stringMap)
Restores all data defined properties from string map.
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size) override
static const QString EXPR_SYMBOL_NAME
A paint effect which draws the source picture with minor or no alterations.
void _renderPolygon(QPainter *p, const QPolygonF &points, const QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
Default method to render polygon.
static bool isGeneralizableByDeviceBoundingBox(const QgsRectangle &envelope, float mapToPixelTol=1.0f)
Returns whether the device-envelope can be replaced by its BBOX when is applied the specified toleran...
bool isEmpty() const
Check whether the container is empty.
Definition: qgsfield.cpp:274
QPointF offset() const
double size
Definition: qgssvgcache.cpp:77
static const QString EXPR_MAX_DISTANCE
static const QString EXPR_LINE_STYLE
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves all data defined properties to a string map.
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the layer.
bool isActive() const
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
static const QString EXPR_INTERVAL
QgsSymbolV2::OutputUnit widthUnit() const
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
static const QString EXPR_HEIGHT
virtual Q_DECL_DEPRECATED void setDataDefinedProperty(const QString &property, const QString &expressionString)
Sets a data defined expression for a property.
static QPointF _rotatedOffset(const QPointF &offset, double angle)
static const QString EXPR_HORIZONTAL_ANCHOR_POINT