QGIS API Documentation  2.12.0-Lyon
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 "qgspainteffectregistry.h"
26 #include "qgsdatadefined.h"
27 #include "qgsexpressioncontext.h"
28 
29 #include <QSize>
30 #include <QPainter>
31 #include <QPointF>
32 #include <QPolygonF>
33 
34 const QString QgsSymbolLayerV2::EXPR_SIZE( "size" );
35 const QString QgsSymbolLayerV2::EXPR_ANGLE( "angle" );
36 const QString QgsSymbolLayerV2::EXPR_NAME( "name" );
37 const QString QgsSymbolLayerV2::EXPR_COLOR( "color" );
38 const QString QgsSymbolLayerV2::EXPR_COLOR_BORDER( "color_border" );
39 const QString QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH( "outline_width" );
40 const QString QgsSymbolLayerV2::EXPR_OUTLINE_STYLE( "outline_style" );
41 const QString QgsSymbolLayerV2::EXPR_FILL( "fill" );
42 const QString QgsSymbolLayerV2::EXPR_OUTLINE( "outline" );
43 const QString QgsSymbolLayerV2::EXPR_OFFSET( "offset" );
44 const QString QgsSymbolLayerV2::EXPR_CHAR( "char" );
45 const QString QgsSymbolLayerV2::EXPR_FILL_COLOR( "fill_color" );
46 const QString QgsSymbolLayerV2::EXPR_OUTLINE_COLOR( "outline_color" );
47 const QString QgsSymbolLayerV2::EXPR_WIDTH( "width" );
48 const QString QgsSymbolLayerV2::EXPR_HEIGHT( "height" );
49 const QString QgsSymbolLayerV2::EXPR_SYMBOL_NAME( "symbol_name" );
50 const QString QgsSymbolLayerV2::EXPR_ROTATION( "rotation" );
51 const QString QgsSymbolLayerV2::EXPR_FILL_STYLE( "fill_style" );
52 const QString QgsSymbolLayerV2::EXPR_WIDTH_BORDER( "width_border" );
53 const QString QgsSymbolLayerV2::EXPR_BORDER_STYLE( "border_style" );
54 const QString QgsSymbolLayerV2::EXPR_JOIN_STYLE( "join_style" );
55 const QString QgsSymbolLayerV2::EXPR_BORDER_COLOR( "border_color" );
56 const QString QgsSymbolLayerV2::EXPR_COLOR2( "color2" );
57 const QString QgsSymbolLayerV2::EXPR_LINEANGLE( "lineangle" );
58 const QString QgsSymbolLayerV2::EXPR_GRADIENT_TYPE( "gradient_type" );
59 const QString QgsSymbolLayerV2::EXPR_COORDINATE_MODE( "coordinate_mode" );
60 const QString QgsSymbolLayerV2::EXPR_SPREAD( "spread" );
61 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_X( "reference1_x" );
62 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_Y( "reference1_y" );
63 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_X( "reference2_x" );
64 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_Y( "reference2_y" );
65 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_ISCENTROID( "reference1_iscentroid" );
66 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_ISCENTROID( "reference2_iscentroid" );
67 const QString QgsSymbolLayerV2::EXPR_BLUR_RADIUS( "blur_radius" );
68 const QString QgsSymbolLayerV2::EXPR_DISTANCE( "distance" );
69 const QString QgsSymbolLayerV2::EXPR_USE_WHOLE_SHAPE( "use_whole_shape" );
70 const QString QgsSymbolLayerV2::EXPR_MAX_DISTANCE( "max_distance" );
71 const QString QgsSymbolLayerV2::EXPR_IGNORE_RINGS( "ignore_rings" );
72 const QString QgsSymbolLayerV2::EXPR_SVG_FILE( "svgFile" );
73 const QString QgsSymbolLayerV2::EXPR_SVG_FILL_COLOR( "svgFillColor" );
74 const QString QgsSymbolLayerV2::EXPR_SVG_OUTLINE_COLOR( "svgOutlineColor" );
75 const QString QgsSymbolLayerV2::EXPR_SVG_OUTLINE_WIDTH( "svgOutlineWidth" );
76 const QString QgsSymbolLayerV2::EXPR_LINEWIDTH( "linewidth" );
77 const QString QgsSymbolLayerV2::EXPR_DISTANCE_X( "distance_x" );
78 const QString QgsSymbolLayerV2::EXPR_DISTANCE_Y( "distance_y" );
79 const QString QgsSymbolLayerV2::EXPR_DISPLACEMENT_X( "displacement_x" );
80 const QString QgsSymbolLayerV2::EXPR_DISPLACEMENT_Y( "displacement_y" );
81 const QString QgsSymbolLayerV2::EXPR_FILE( "file" );
82 const QString QgsSymbolLayerV2::EXPR_ALPHA( "alpha" );
83 const QString QgsSymbolLayerV2::EXPR_CUSTOMDASH( "customdash" );
84 const QString QgsSymbolLayerV2::EXPR_LINE_STYLE( "line_style" );
85 const QString QgsSymbolLayerV2::EXPR_JOINSTYLE( "joinstyle" );
86 const QString QgsSymbolLayerV2::EXPR_CAPSTYLE( "capstyle" );
87 const QString QgsSymbolLayerV2::EXPR_PLACEMENT( "placement" );
88 const QString QgsSymbolLayerV2::EXPR_INTERVAL( "interval" );
89 const QString QgsSymbolLayerV2::EXPR_OFFSET_ALONG_LINE( "offset_along_line" );
90 const QString QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT( "horizontal_anchor_point" );
91 const QString QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT( "vertical_anchor_point" );
92 
94 {
96  return expression( property );
98 }
99 
101 {
103  return 0;
104 
106  if ( it != mDataDefinedProperties.constEnd() )
107  {
108  return it.value();
109  }
110  return 0;
111 }
112 
114 {
115  QgsDataDefined* dd = getDataDefinedProperty( property );
116  return dd ? dd->expression() : 0;
117 }
118 
120 {
121  const QgsDataDefined* dd = getDataDefinedProperty( property );
122  return dd ? dd->expressionString() : QString();
123 }
124 
125 void QgsSymbolLayerV2::setDataDefinedProperty( const QString& property, const QString& expressionString )
126 {
127  setDataDefinedProperty( property, new QgsDataDefined( expressionString ) );
128 }
129 
131 {
132  removeDataDefinedProperty( property );
133  mDataDefinedProperties.insert( property, dataDefined );
134 }
135 
137 {
139  if ( it != mDataDefinedProperties.end() )
140  {
141  delete( it.value() );
143  }
144 }
145 
147 {
149  for ( ; it != mDataDefinedProperties.constEnd(); ++it )
150  {
151  delete( it.value() );
152  }
154 }
155 
157 {
159  return false;
160 
162  for ( ; it != mDataDefinedProperties.constEnd(); ++it )
163  {
164  if ( hasDataDefinedProperty( it.key() ) )
165  return true;
166  }
167 
168  return false;
169 }
170 
172 {
174  return false;
175 
176  QgsDataDefined* dd = getDataDefinedProperty( property );
177  return dd && dd->isActive();
178 }
179 
180 QVariant QgsSymbolLayerV2::evaluateDataDefinedProperty( const QString &property, const QgsFeature* feature, const QVariant& defaultVal, bool *ok ) const
181 {
182  if ( ok )
183  *ok = false;
184 
185  QgsDataDefined* dd = getDataDefinedProperty( property );
186  if ( !dd || !dd->isActive() )
187  return defaultVal;
188 
189  if ( dd->useExpression() )
190  {
191  if ( dd->expression() )
192  {
194  QVariant result = dd->expression()->evaluate( &context );
195  if ( result.isValid() )
196  {
197  if ( ok )
198  *ok = true;
199  return result;
200  }
201  else
202  return defaultVal;
203  }
204  else
205  {
206  return defaultVal;
207  }
208  }
209  else if ( feature && !dd->field().isEmpty() && !mFields.isEmpty() )
210  {
211  int attributeIndex = mFields.fieldNameIndex( dd->field() );
212  if ( attributeIndex >= 0 )
213  {
214  if ( ok )
215  *ok = true;
216  return feature->attribute( attributeIndex );
217  }
218  }
219  return defaultVal;
220 }
221 
222 QVariant QgsSymbolLayerV2::evaluateDataDefinedProperty( const QString& property, const QgsSymbolV2RenderContext& context, const QVariant& defaultVal, bool* ok ) const
223 {
224  if ( ok )
225  *ok = false;
226 
227  QgsDataDefined* dd = getDataDefinedProperty( property );
228  if ( !dd || !dd->isActive() )
229  return defaultVal;
230 
231  if ( dd->useExpression() )
232  {
233  if ( dd->expression() )
234  {
235  QVariant result = dd->expression()->evaluate( &context.renderContext().expressionContext() );
236  if ( result.isValid() )
237  {
238  if ( ok )
239  *ok = true;
240  return result;
241  }
242  else
243  return defaultVal;
244  }
245  else
246  {
247  return defaultVal;
248  }
249  }
250  else if ( context.feature() && !dd->field().isEmpty() && !mFields.isEmpty() )
251  {
252  int attributeIndex = mFields.fieldNameIndex( dd->field() );
253  if ( attributeIndex >= 0 )
254  {
255  if ( ok )
256  *ok = true;
257  return context.feature()->attribute( attributeIndex );
258  }
259  }
260  return defaultVal;
261 }
262 
264  double mmMapUnitScaleFactor,
265  const QString& layerName,
266  QgsSymbolV2RenderContext *context,
267  const QgsFeature* f,
268  const QPointF& shift ) const
269 {
270  Q_UNUSED( e );
271  Q_UNUSED( mmMapUnitScaleFactor );
272  Q_UNUSED( layerName );
273  Q_UNUSED( context );
274  Q_UNUSED( f );
275  Q_UNUSED( shift );
276  return false;
277 }
278 
280 {
281  Q_UNUSED( e );
282  Q_UNUSED( context );
283  return 1.0;
284 }
285 
287 {
288  Q_UNUSED( e );
289  Q_UNUSED( context );
290  return 0.0;
291 }
292 
294 {
295  Q_UNUSED( context );
296  return color();
297 }
298 
300 {
301  Q_UNUSED( unit );
302  return QVector<qreal>();
303 }
304 
305 Qt::PenStyle QgsSymbolLayerV2::dxfPenStyle() const
306 {
307  return Qt::SolidLine;
308 }
309 
311 {
312  Q_UNUSED( context );
313  return color();
314 }
315 
316 Qt::BrushStyle QgsSymbolLayerV2::dxfBrushStyle() const
317 {
318  return Qt::NoBrush;
319 }
320 
322 {
323  return mPaintEffect;
324 }
325 
327 {
328  delete mPaintEffect;
329  mPaintEffect = effect;
330 }
331 
333  : mType( type )
334  , mLocked( locked )
335  , mRenderingPass( 0 )
336  , mPaintEffect( 0 )
337 {
339  mPaintEffect->setEnabled( false );
340 }
341 
342 void QgsSymbolLayerV2::prepareExpressions( const QgsFields* fields, double scale )
343 {
345  for ( ; it != mDataDefinedProperties.end(); ++it )
346  {
347  if ( it.value() )
348  {
350  if ( scale > 0 )
351  {
352  params.insert( "scale", scale );
353  }
354  it.value()->setExpressionParams( params );
355 
356  if ( fields )
357  {
358  it.value()->prepareExpression( QgsExpressionContextUtils::createFeatureBasedContext( QgsFeature(), *fields ) );
359  }
360  else
361  {
362  it.value()->prepareExpression();
363  }
364  }
365  }
366 
367  if ( fields )
368  {
369  //QgsFields is implicitly shared, so it's cheap to make a copy
370  mFields = *fields;
371  }
372 }
373 
375 {
377  for ( ; it != mDataDefinedProperties.end(); ++it )
378  {
379  if ( it.value() )
380  {
382  if ( context.renderContext().rendererScale() > 0 )
383  {
384  params.insert( "scale", context.renderContext().rendererScale() );
385  }
386  it.value()->setExpressionParams( params );
387  it.value()->prepareExpression( context.renderContext().expressionContext() );
388  }
389  }
390 
391  if ( context.fields() )
392  {
393  //QgsFields is implicitly shared, so it's cheap to make a copy
394  mFields = *context.fields();
395  }
396 }
397 
399 {
401  delete mPaintEffect;
402 }
403 
405 {
406  QStringList columns;
407 
409  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
410  {
411  if ( ddIt.value() && ddIt.value()->isActive() )
412  {
413  columns.append( ddIt.value()->referencedColumns() );
414  }
415  }
416 
417  return columns.toSet();
418 }
419 
421 {
423  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
424  {
425  if ( ddIt.value() )
426  {
427  stringMap.unite( ddIt.value()->toMap( ddIt.key() ) );
428  }
429  }
430 }
431 
433 {
434  QgsStringMap::const_iterator propIt = stringMap.constBegin();
435  for ( ; propIt != stringMap.constEnd(); ++propIt )
436  {
437  if ( propIt.key().endsWith( "_dd_expression" ) )
438  {
439  //found a data defined property
440 
441  //get data defined property name by stripping "_dd_expression" from property key
442  QString propertyName = propIt.key().left( propIt.key().length() - 14 );
443 
444  QgsDataDefined* dd = QgsDataDefined::fromMap( stringMap, propertyName );
445  if ( dd )
446  setDataDefinedProperty( propertyName, dd );
447  }
448  else if ( propIt.key().endsWith( "_expression" ) )
449  {
450  //old style data defined property, upgrade
451 
452  //get data defined property name by stripping "_expression" from property key
453  QString propertyName = propIt.key().left( propIt.key().length() - 11 );
454 
455  setDataDefinedProperty( propertyName, new QgsDataDefined( propIt.value() ) );
456  }
457  }
458 }
459 
461 {
462  if ( !destLayer )
463  return;
464 
465  destLayer->removeDataDefinedProperties();
466 
468  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
469  {
470  if ( ddIt.value() )
471  {
472  destLayer->setDataDefinedProperty( ddIt.key(), new QgsDataDefined( *( ddIt.value() ) ) );
473  }
474  }
475 }
476 
478 {
479  if ( !destLayer || !mPaintEffect )
480  return;
481 
482  destLayer->setPaintEffect( mPaintEffect->clone() );
483 }
484 
486  : QgsSymbolLayerV2( QgsSymbolV2::Marker, locked )
487  , mAngle( 0 )
488  , mLineAngle( 0 )
489  , mSize( 2.0 )
490  , mSizeUnit( QgsSymbolV2::MM )
491  , mOffsetUnit( QgsSymbolV2::MM )
492  , mScaleMethod( QgsSymbolV2::ScaleArea )
493  , mHorizontalAnchorPoint( HCenter )
494  , mVerticalAnchorPoint( VCenter )
495 {
496 
497 }
498 
500  : QgsSymbolLayerV2( QgsSymbolV2::Line, locked )
501  , mWidth( 0 )
502  , mWidthUnit( QgsSymbolV2::MM )
503  , mOffset( 0 )
504  , mOffsetUnit( QgsSymbolV2::MM )
505 {
506 }
507 
509  : QgsSymbolLayerV2( QgsSymbolV2::Fill, locked )
510  , mAngle( 0.0 )
511 {
512 }
513 
515 {
516  Q_UNUSED( context );
517 }
518 
520 {
521  startRender( context );
522  renderPoint( QPointF( size.width() / 2, size.height() / 2 ), context );
523  stopRender( context );
524 }
525 
526 void QgsMarkerSymbolLayerV2::markerOffset( QgsSymbolV2RenderContext& context, double& offsetX, double& offsetY ) const
527 {
529 }
530 
531 void QgsMarkerSymbolLayerV2::markerOffset( QgsSymbolV2RenderContext& context, double width, double height, double& offsetX, double& offsetY ) const
532 {
533  markerOffset( context, width, height, mSizeUnit, mSizeUnit, offsetX, offsetY, mSizeMapUnitScale, mSizeMapUnitScale );
534 }
535 
536 void QgsMarkerSymbolLayerV2::markerOffset( QgsSymbolV2RenderContext& context, double width, double height,
537  QgsSymbolV2::OutputUnit widthUnit, QgsSymbolV2::OutputUnit heightUnit,
538  double& offsetX, double& offsetY, const QgsMapUnitScale& widthMapUnitScale, const QgsMapUnitScale& heightMapUnitScale ) const
539 {
540  offsetX = mOffset.x();
541  offsetY = mOffset.y();
542 
544  {
547  offsetX = offset.x();
548  offsetY = offset.y();
549  }
550 
553 
557  {
558  horizontalAnchorPoint = decodeHorizontalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT , context ).toString() );
559  }
561  {
562  verticalAnchorPoint = decodeVerticalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT, context ).toString() );
563  }
564 
565  //correct horizontal position according to anchor point
566  if ( horizontalAnchorPoint == HCenter && verticalAnchorPoint == VCenter )
567  {
568  return;
569  }
570 
571  double anchorPointCorrectionX = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), width, widthUnit, widthMapUnitScale ) / 2.0;
572  double anchorPointCorrectionY = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), height, heightUnit, heightMapUnitScale ) / 2.0;
573  if ( horizontalAnchorPoint == Left )
574  {
575  offsetX += anchorPointCorrectionX;
576  }
577  else if ( horizontalAnchorPoint == Right )
578  {
579  offsetX -= anchorPointCorrectionX;
580  }
581 
582  //correct vertical position according to anchor point
583  if ( verticalAnchorPoint == Top )
584  {
585  offsetY += anchorPointCorrectionY;
586  }
587  else if ( verticalAnchorPoint == Bottom )
588  {
589  offsetY -= anchorPointCorrectionY;
590  }
591 }
592 
594 {
595  angle = DEG2RAD( angle );
596  double c = cos( angle ), s = sin( angle );
597  return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c );
598 }
599 
600 QgsMarkerSymbolLayerV2::HorizontalAnchorPoint QgsMarkerSymbolLayerV2::decodeHorizontalAnchorPoint( const QString& str )
601 {
602  if ( str.compare( "left", Qt::CaseInsensitive ) == 0 )
603  {
605  }
606  else if ( str.compare( "right", Qt::CaseInsensitive ) == 0 )
607  {
609  }
610  else
611  {
613  }
614 }
615 
616 QgsMarkerSymbolLayerV2::VerticalAnchorPoint QgsMarkerSymbolLayerV2::decodeVerticalAnchorPoint( const QString& str )
617 {
618  if ( str.compare( "top", Qt::CaseInsensitive ) == 0 )
619  {
621  }
622  else if ( str.compare( "bottom", Qt::CaseInsensitive ) == 0 )
623  {
625  }
626  else
627  {
629  }
630 }
631 
633 {
634  mSizeUnit = unit;
635  mOffsetUnit = unit;
636 }
637 
639 {
640  if ( mOffsetUnit != mSizeUnit )
641  {
642  return QgsSymbolV2::Mixed;
643  }
644  return mOffsetUnit;
645 }
646 
648 {
649  mSizeMapUnitScale = scale;
650  mOffsetMapUnitScale = scale;
651 }
652 
654 {
656  {
657  return mSizeMapUnitScale;
658  }
659  return QgsMapUnitScale();
660 }
661 
663 {
664  mWidthUnit = unit;
665 }
666 
668 {
669  return mWidthUnit;
670 }
671 
673 {
674  mWidthMapUnitScale = scale;
675 }
676 
678 {
679  return mWidthMapUnitScale;
680 }
681 
682 
684 {
685  QPolygonF points;
686  // we're adding 0.5 to get rid of blurred preview:
687  // drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
688  points << QPointF( 0, int( size.height() / 2 ) + 0.5 ) << QPointF( size.width(), int( size.height() / 2 ) + 0.5 );
689 
690  startRender( context );
691  renderPolyline( points, context );
692  stopRender( context );
693 }
694 
696 {
697  renderPolyline( points, context );
698  if ( rings )
699  {
700  Q_FOREACH ( const QPolygonF& ring, *rings )
701  renderPolyline( ring, context );
702  }
703 }
704 
706 {
707  Q_UNUSED( context );
709 }
710 
711 
713 {
714  QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width(), size.height() ) );
715  startRender( context );
716  renderPolygon( poly, NULL, context );
717  stopRender( context );
718 }
719 
721 {
722  if ( !p )
723  {
724  return;
725  }
726 
727  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
728  if ( points.size() <= 5 &&
731  ( p->renderHints() & QPainter::Antialiasing ) )
732  {
733  p->setRenderHint( QPainter::Antialiasing, false );
734  p->drawRect( points.boundingRect() );
735  p->setRenderHint( QPainter::Antialiasing, true );
736  return;
737  }
738 
739  if ( rings == NULL )
740  {
741  // simple polygon without holes
742  p->drawPolygon( points );
743  }
744  else
745  {
746  // polygon with holes must be drawn using painter path
747  QPainterPath path;
748  QPolygonF outerRing = points;
749  path.addPolygon( outerRing );
750 
752  for ( ; it != rings->constEnd(); ++it )
753  {
754  QPolygonF ring = *it;
755  path.addPolygon( ring );
756  }
757 
758  p->drawPath( path );
759  }
760 }
761 
762 void QgsMarkerSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const
763 {
764  QDomElement symbolizerElem = doc.createElement( "se:PointSymbolizer" );
765  if ( !props.value( "uom", "" ).isEmpty() )
766  symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
767  element.appendChild( symbolizerElem );
768 
769  // <Geometry>
770  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );
771 
772  writeSldMarker( doc, symbolizerElem, props );
773 }
774 
775 
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:92
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.
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:55
float threshold() const
Gets the simplification threshold of the vector layer managed.
QgsMapUnitScale mSizeMapUnitScale
virtual Qt::PenStyle dxfPenStyle() const
iterator erase(iterator pos)
int width() const
A container class for data source field mapping or expression.
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
static const QString EXPR_BORDER_COLOR
virtual double width() const
void setRenderHint(RenderHint hint, bool on)
HorizontalAnchorPoint horizontalAnchorPoint() const
QDomNode appendChild(const QDomNode &newChild)
static const QString EXPR_USE_WHOLE_SHAPE
RenderHints renderHints() const
static const QString EXPR_REFERENCE2_Y
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
QMap< Key, T > & unite(const QMap< Key, T > &other)
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
QString field() const
Get the field which this QgsDataDefined represents.
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
static const QString EXPR_DISPLACEMENT_X
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
Definition: qgsfield.cpp:382
double rendererScale() const
QMap< QString, QgsDataDefined * > mDataDefinedProperties
static const QString EXPR_WIDTH
static const QString EXPR_CUSTOMDASH
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
QGis::UnitType mapUnits() const
Definition: qgsdxfexport.h:54
const_iterator constBegin() const
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:390
#define DEG2RAD(x)
Base class for visual effects which can be applied to QPicture drawings.
QgsSymbolV2::OutputUnit outputUnit() const override
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
QgsPaintEffect * mPaintEffect
QgsExpression * expression()
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
Container of fields for a vector layer.
Definition: qgsfield.h:177
static const QString EXPR_BLUR_RADIUS
static const QString EXPR_COORDINATE_MODE
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)=0
static QPointF decodePoint(const QString &str)
QString expressionString() const
Returns the expression string of this QgsDataDefined.
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.
QSet< T > toSet() const
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:176
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
void clear()
virtual void removeDataDefinedProperty(const QString &property)
Removes a data defined property from the layer.
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
void drawRect(const QRectF &rectangle)
static const QString EXPR_BORDER_STYLE
static const QString EXPR_REFERENCE2_X
static const QString EXPR_REFERENCE2_ISCENTROID
Mixed units in symbol layers.
Definition: qgssymbolv2.h:59
static const QString EXPR_LINEWIDTH
static const QString EXPR_PLACEMENT
static const QString EXPR_FILL_COLOR
void markerOffset(QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
qreal x() const
qreal y() const
void append(const T &value)
static const QString EXPR_SPREAD
void addPolygon(const QPolygonF &polygon)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
const QgsFeature * feature() const
Current feature being rendered - may be null.
Definition: qgssymbolv2.h:283
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
static const QString EXPR_LINEANGLE
virtual void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)=0
const Key & key() const
static QString encodePoint(QPointF point)
static double convertToPainterUnits(const QgsRenderContext &c, double size, QgsSymbolV2::OutputUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale())
Converts a size from the specied units to painter units.
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
void setAttribute(const QString &name, const QString &value)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isEmpty() const
const_iterator constEnd() const
const T & value() const
virtual QColor color() const
static const QString EXPR_FILL
HorizontalAnchorPoint mHorizontalAnchorPoint
virtual void renderPolygonOutline(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const
iterator end()
virtual Q_DECL_DEPRECATED void prepareExpressions(const QgsFields *fields, double scale=-1.0)
Prepares all data defined property expressions for evaluation.
static const QString EXPR_FILE
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties.
iterator begin()
static const QString EXPR_CAPSTYLE
static const QString EXPR_OUTLINE_STYLE
bool useExpression() const
Returns if the field or the expression part is active.
static const QString EXPR_DISTANCE
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
QgsExpressionContext & expressionContext()
Gets the expression context.
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)
SymbolType
Type of the symbol.
Definition: qgssymbolv2.h:68
static const QString EXPR_GRADIENT_TYPE
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:391
const Key key(const T &value) const
void startRender(QgsSymbolV2RenderContext &context) override
static const QString EXPR_OUTLINE_WIDTH
QgsMapUnitScale mapUnitScale() const override
virtual Qt::BrushStyle dxfBrushStyle() const
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
static const QString EXPR_SVG_FILL_COLOR
QRectF boundingRect() const
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:238
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
void setMapUnitScale(const QgsMapUnitScale &scale) override
void drawPath(const QPainterPath &path)
QgsLineSymbolLayerV2(bool locked=false)
virtual Q_DECL_DEPRECATED 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.
Struct for storing maximum and minimum scales for measurements in map units.
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:254
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
int height() const
virtual QColor dxfColor(QgsSymbolV2RenderContext &context) const
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
const QgsFields * fields() const
Fields of the layer.
Definition: qgssymbolv2.h:289
QgsSymbolV2::OutputUnit mOffsetUnit
bool isValid() const
iterator insert(const Key &key, const T &value)
VerticalAnchorPoint mVerticalAnchorPoint
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
QgsSymbolV2::OutputUnit mSizeUnit
bool isEmpty() const
QgsMapUnitScale mOffsetMapUnitScale
static const QString EXPR_OUTLINE
static const QString EXPR_SVG_OUTLINE_WIDTH
void restoreDataDefinedProperties(const QgsStringMap &stringMap)
Restores all data defined properties from string map.
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size) override
static const QString EXPR_SYMBOL_NAME
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const override
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...
int size() const
bool isEmpty() const
Check whether the container is empty.
Definition: qgsfield.cpp:306
QPointF offset() const
int compare(const QString &other) const
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
iterator find(const Key &key)
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
const T value(const Key &key) const
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