QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  const 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 
279 double QgsSymbolLayerV2::dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const
280 {
281  Q_UNUSED( e );
282  Q_UNUSED( context );
283  return 1.0;
284 }
285 
286 double QgsSymbolLayerV2::dxfOffset( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const
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( const QgsSymbolV2RenderContext& context, double& offsetX, double& offsetY ) const
527 {
529 }
530 
531 void QgsMarkerSymbolLayerV2::markerOffset( const 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( const 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  {
546  offsetX = offset.x();
547  offsetY = offset.y();
548  }
549 
552 
556  {
557  horizontalAnchorPoint = decodeHorizontalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT , context ).toString() );
558  }
560  {
561  verticalAnchorPoint = decodeVerticalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT, context ).toString() );
562  }
563 
564  //correct horizontal position according to anchor point
565  if ( horizontalAnchorPoint == HCenter && verticalAnchorPoint == VCenter )
566  {
567  return;
568  }
569 
570  double anchorPointCorrectionX = width * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), widthUnit, widthMapUnitScale ) / 2.0;
571  double anchorPointCorrectionY = height * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), heightUnit, heightMapUnitScale ) / 2.0;
572  if ( horizontalAnchorPoint == Left )
573  {
574  offsetX += anchorPointCorrectionX;
575  }
576  else if ( horizontalAnchorPoint == Right )
577  {
578  offsetX -= anchorPointCorrectionX;
579  }
580 
581  //correct vertical position according to anchor point
582  if ( verticalAnchorPoint == Top )
583  {
584  offsetY += anchorPointCorrectionY;
585  }
586  else if ( verticalAnchorPoint == Bottom )
587  {
588  offsetY -= anchorPointCorrectionY;
589  }
590 }
591 
593 {
594  angle = DEG2RAD( angle );
595  double c = cos( angle ), s = sin( angle );
596  return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c );
597 }
598 
599 QgsMarkerSymbolLayerV2::HorizontalAnchorPoint QgsMarkerSymbolLayerV2::decodeHorizontalAnchorPoint( const QString& str )
600 {
601  if ( str.compare( "left", Qt::CaseInsensitive ) == 0 )
602  {
604  }
605  else if ( str.compare( "right", Qt::CaseInsensitive ) == 0 )
606  {
608  }
609  else
610  {
612  }
613 }
614 
615 QgsMarkerSymbolLayerV2::VerticalAnchorPoint QgsMarkerSymbolLayerV2::decodeVerticalAnchorPoint( const QString& str )
616 {
617  if ( str.compare( "top", Qt::CaseInsensitive ) == 0 )
618  {
620  }
621  else if ( str.compare( "bottom", Qt::CaseInsensitive ) == 0 )
622  {
624  }
625  else
626  {
628  }
629 }
630 
632 {
633  mSizeUnit = unit;
634  mOffsetUnit = unit;
635 }
636 
638 {
639  if ( mOffsetUnit != mSizeUnit )
640  {
641  return QgsSymbolV2::Mixed;
642  }
643  return mOffsetUnit;
644 }
645 
647 {
648  mSizeMapUnitScale = scale;
649  mOffsetMapUnitScale = scale;
650 }
651 
653 {
655  {
656  return mSizeMapUnitScale;
657  }
658  return QgsMapUnitScale();
659 }
660 
662 {
663  mWidthUnit = unit;
664 }
665 
667 {
668  return mWidthUnit;
669 }
670 
672 {
673  mWidthMapUnitScale = scale;
674 }
675 
677 {
678  return mWidthMapUnitScale;
679 }
680 
681 
683 {
684  QPolygonF points;
685  // we're adding 0.5 to get rid of blurred preview:
686  // drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
687  points << QPointF( 0, int( size.height() / 2 ) + 0.5 ) << QPointF( size.width(), int( size.height() / 2 ) + 0.5 );
688 
689  startRender( context );
690  renderPolyline( points, context );
691  stopRender( context );
692 }
693 
695 {
696  renderPolyline( points, context );
697  if ( rings )
698  {
699  foreach ( const QPolygonF& ring, *rings )
700  renderPolyline( ring, context );
701  }
702 }
703 
705 {
706  Q_UNUSED( context );
708 }
709 
710 
712 {
713  QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width(), size.height() ) );
714  startRender( context );
715  renderPolygon( poly, NULL, context );
716  stopRender( context );
717 }
718 
720 {
721  if ( !p )
722  {
723  return;
724  }
725 
726  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
727  if ( points.size() <= 5 &&
730  ( p->renderHints() & QPainter::Antialiasing ) )
731  {
732  p->setRenderHint( QPainter::Antialiasing, false );
733  p->drawRect( points.boundingRect() );
734  p->setRenderHint( QPainter::Antialiasing, true );
735  return;
736  }
737 
738  if ( rings == NULL )
739  {
740  // simple polygon without holes
741  p->drawPolygon( points );
742  }
743  else
744  {
745  // polygon with holes must be drawn using painter path
746  QPainterPath path;
747  QPolygonF outerRing = points;
748  path.addPolygon( outerRing );
749 
751  for ( ; it != rings->constEnd(); ++it )
752  {
753  QPolygonF ring = *it;
754  path.addPolygon( ring );
755  }
756 
757  p->drawPath( path );
758  }
759 }
760 
762 {
763  QDomElement symbolizerElem = doc.createElement( "se:PointSymbolizer" );
764  if ( !props.value( "uom", "" ).isEmpty() )
765  symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
766  element.appendChild( symbolizerElem );
767 
768  // <Geometry>
769  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );
770 
771  writeSldMarker( doc, symbolizerElem, props );
772 }
773 
774 
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:88
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
iterator erase(iterator pos)
int width() const
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) 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
virtual double dxfOffset(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) 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
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 - case insensitive TODO: sort out case sensitive (indexFromName()) vs...
Definition: qgsfield.cpp:356
double rendererScale() const
QMap< QString, QgsDataDefined * > mDataDefinedProperties
static const QString EXPR_WIDTH
static const QString EXPR_CUSTOMDASH
QGis::UnitType mapUnits() const
Definition: qgsdxfexport.h:54
const_iterator constBegin() const
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:464
#define DEG2RAD(x)
Base class for visual effects which can be applied to QPicture drawings.
QgsSymbolV2::OutputUnit outputUnit() const override
QgsPaintEffect * mPaintEffect
QgsExpression * expression()
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
static QPointF decodePoint(QString str)
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
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:162
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
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const override
void drawRect(const QRectF &rectangle)
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
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:263
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
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)
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 QColor dxfBrushColor(const QgsSymbolV2RenderContext &context) const
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.
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
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)
static const QString EXPR_GRADIENT_TYPE
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:465
const Key key(const T &value) const
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
QRectF boundingRect() const
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:236
void setMapUnitScale(const QgsMapUnitScale &scale) override
void drawPath(const QPainterPath &path)
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 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.
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:241
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
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:269
QgsSymbolV2::OutputUnit mOffsetUnit
bool isValid() const
iterator insert(const Key &key, const T &value)
VerticalAnchorPoint mVerticalAnchorPoint
QgsSymbolV2::OutputUnit mSizeUnit
bool isEmpty() const
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.
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
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:280
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