QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
28 #include <QSize>
29 #include <QPainter>
30 #include <QPointF>
31 #include <QPolygonF>
32 
33 const QString QgsSymbolLayerV2::EXPR_SIZE( "size" );
34 const QString QgsSymbolLayerV2::EXPR_ANGLE( "angle" );
35 const QString QgsSymbolLayerV2::EXPR_NAME( "name" );
36 const QString QgsSymbolLayerV2::EXPR_COLOR( "color" );
37 const QString QgsSymbolLayerV2::EXPR_COLOR_BORDER( "color_border" );
38 const QString QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH( "outline_width" );
39 const QString QgsSymbolLayerV2::EXPR_OUTLINE_STYLE( "outline_style" );
40 const QString QgsSymbolLayerV2::EXPR_FILL( "fill" );
41 const QString QgsSymbolLayerV2::EXPR_OUTLINE( "outline" );
42 const QString QgsSymbolLayerV2::EXPR_OFFSET( "offset" );
43 const QString QgsSymbolLayerV2::EXPR_CHAR( "char" );
44 const QString QgsSymbolLayerV2::EXPR_FILL_COLOR( "fill_color" );
45 const QString QgsSymbolLayerV2::EXPR_OUTLINE_COLOR( "outline_color" );
46 const QString QgsSymbolLayerV2::EXPR_WIDTH( "width" );
47 const QString QgsSymbolLayerV2::EXPR_HEIGHT( "height" );
48 const QString QgsSymbolLayerV2::EXPR_SYMBOL_NAME( "symbol_name" );
49 const QString QgsSymbolLayerV2::EXPR_ROTATION( "rotation" );
50 const QString QgsSymbolLayerV2::EXPR_FILL_STYLE( "fill_style" );
51 const QString QgsSymbolLayerV2::EXPR_WIDTH_BORDER( "width_border" );
52 const QString QgsSymbolLayerV2::EXPR_BORDER_STYLE( "border_style" );
53 const QString QgsSymbolLayerV2::EXPR_JOIN_STYLE( "join_style" );
54 const QString QgsSymbolLayerV2::EXPR_BORDER_COLOR( "border_color" );
55 const QString QgsSymbolLayerV2::EXPR_COLOR2( "color2" );
56 const QString QgsSymbolLayerV2::EXPR_LINEANGLE( "lineangle" );
57 const QString QgsSymbolLayerV2::EXPR_GRADIENT_TYPE( "gradient_type" );
58 const QString QgsSymbolLayerV2::EXPR_COORDINATE_MODE( "coordinate_mode" );
59 const QString QgsSymbolLayerV2::EXPR_SPREAD( "spread" );
60 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_X( "reference1_x" );
61 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_Y( "reference1_y" );
62 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_X( "reference2_x" );
63 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_Y( "reference2_y" );
64 const QString QgsSymbolLayerV2::EXPR_REFERENCE1_ISCENTROID( "reference1_iscentroid" );
65 const QString QgsSymbolLayerV2::EXPR_REFERENCE2_ISCENTROID( "reference2_iscentroid" );
66 const QString QgsSymbolLayerV2::EXPR_BLUR_RADIUS( "blur_radius" );
67 const QString QgsSymbolLayerV2::EXPR_DISTANCE( "distance" );
68 const QString QgsSymbolLayerV2::EXPR_USE_WHOLE_SHAPE( "use_whole_shape" );
69 const QString QgsSymbolLayerV2::EXPR_MAX_DISTANCE( "max_distance" );
70 const QString QgsSymbolLayerV2::EXPR_IGNORE_RINGS( "ignore_rings" );
71 const QString QgsSymbolLayerV2::EXPR_SVG_FILE( "svgFile" );
72 const QString QgsSymbolLayerV2::EXPR_SVG_FILL_COLOR( "svgFillColor" );
73 const QString QgsSymbolLayerV2::EXPR_SVG_OUTLINE_COLOR( "svgOutlineColor" );
74 const QString QgsSymbolLayerV2::EXPR_SVG_OUTLINE_WIDTH( "svgOutlineWidth" );
75 const QString QgsSymbolLayerV2::EXPR_LINEWIDTH( "linewidth" );
76 const QString QgsSymbolLayerV2::EXPR_DISTANCE_X( "distance_x" );
77 const QString QgsSymbolLayerV2::EXPR_DISTANCE_Y( "distance_y" );
78 const QString QgsSymbolLayerV2::EXPR_DISPLACEMENT_X( "displacement_x" );
79 const QString QgsSymbolLayerV2::EXPR_DISPLACEMENT_Y( "displacement_y" );
80 const QString QgsSymbolLayerV2::EXPR_FILE( "file" );
81 const QString QgsSymbolLayerV2::EXPR_ALPHA( "alpha" );
82 const QString QgsSymbolLayerV2::EXPR_CUSTOMDASH( "customdash" );
83 const QString QgsSymbolLayerV2::EXPR_LINE_STYLE( "line_style" );
84 const QString QgsSymbolLayerV2::EXPR_JOINSTYLE( "joinstyle" );
85 const QString QgsSymbolLayerV2::EXPR_CAPSTYLE( "capstyle" );
86 const QString QgsSymbolLayerV2::EXPR_PLACEMENT( "placement" );
87 const QString QgsSymbolLayerV2::EXPR_INTERVAL( "interval" );
88 const QString QgsSymbolLayerV2::EXPR_OFFSET_ALONG_LINE( "offset_along_line" );
89 const QString QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT( "horizontal_anchor_point" );
90 const QString QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT( "vertical_anchor_point" );
91 
93 {
95  return expression( property );
97 }
98 
100 {
102  return 0;
103 
105  if ( it != mDataDefinedProperties.constEnd() )
106  {
107  return it.value();
108  }
109  return 0;
110 }
111 
113 {
114  QgsDataDefined* dd = getDataDefinedProperty( property );
115  return dd ? dd->expression() : 0;
116 }
117 
119 {
120  const QgsDataDefined* dd = getDataDefinedProperty( property );
121  return dd ? dd->expressionString() : QString();
122 }
123 
124 void QgsSymbolLayerV2::setDataDefinedProperty( const QString& property, const QString& expressionString )
125 {
126  setDataDefinedProperty( property, new QgsDataDefined( expressionString ) );
127 }
128 
130 {
131  removeDataDefinedProperty( property );
132  mDataDefinedProperties.insert( property, dataDefined );
133 }
134 
136 {
138  if ( it != mDataDefinedProperties.end() )
139  {
140  delete( it.value() );
142  }
143 }
144 
146 {
148  for ( ; it != mDataDefinedProperties.constEnd(); ++it )
149  {
150  delete( it.value() );
151  }
153 }
154 
156 {
158  return false;
159 
161  for ( ; it != mDataDefinedProperties.constEnd(); ++it )
162  {
163  if ( hasDataDefinedProperty( it.key() ) )
164  return true;
165  }
166 
167  return false;
168 }
169 
171 {
173  return false;
174 
175  QgsDataDefined* dd = getDataDefinedProperty( property );
176  return dd && dd->isActive();
177 }
178 
179 QVariant QgsSymbolLayerV2::evaluateDataDefinedProperty( const QString &property, const QgsFeature* feature, const QVariant& defaultVal, bool *ok ) const
180 {
181  if ( ok )
182  *ok = false;
183 
184  QgsDataDefined* dd = getDataDefinedProperty( property );
185  if ( !dd || !dd->isActive() )
186  return defaultVal;
187 
188  if ( dd->useExpression() )
189  {
190  if ( dd->expression() )
191  {
192  QVariant result = dd->expression()->evaluate( feature );
193  if ( result.isValid() )
194  {
195  if ( ok )
196  *ok = true;
197  return result;
198  }
199  else
200  return defaultVal;
201  }
202  else
203  {
204  return defaultVal;
205  }
206  }
207  else if ( feature && !dd->field().isEmpty() && !mFields.isEmpty() )
208  {
209  int attributeIndex = mFields.fieldNameIndex( dd->field() );
210  if ( attributeIndex >= 0 )
211  {
212  if ( ok )
213  *ok = true;
214  return feature->attribute( attributeIndex );
215  }
216  }
217  return defaultVal;
218 }
219 
221  double mmMapUnitScaleFactor,
222  const QString& layerName,
223  const QgsSymbolV2RenderContext* context,
224  const QgsFeature* f,
225  const QPointF& shift ) const
226 {
227  Q_UNUSED( e );
228  Q_UNUSED( mmMapUnitScaleFactor );
229  Q_UNUSED( layerName );
230  Q_UNUSED( context );
231  Q_UNUSED( f );
232  Q_UNUSED( shift );
233  return false;
234 }
235 
236 double QgsSymbolLayerV2::dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const
237 {
238  Q_UNUSED( e );
239  Q_UNUSED( context );
240  return 1.0;
241 }
242 
243 double QgsSymbolLayerV2::dxfOffset( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const
244 {
245  Q_UNUSED( e );
246  Q_UNUSED( context );
247  return 0.0;
248 }
249 
251 {
252  Q_UNUSED( context );
253  return color();
254 }
255 
257 {
258  Q_UNUSED( unit );
259  return QVector<qreal>();
260 }
261 
262 Qt::PenStyle QgsSymbolLayerV2::dxfPenStyle() const
263 {
264  return Qt::SolidLine;
265 }
266 
268 {
269  Q_UNUSED( context );
270  return color();
271 }
272 
273 Qt::BrushStyle QgsSymbolLayerV2::dxfBrushStyle() const
274 {
275  return Qt::NoBrush;
276 }
277 
279 {
280  return mPaintEffect;
281 }
282 
284 {
285  delete mPaintEffect;
286  mPaintEffect = effect;
287 }
288 
290  : mType( type )
291  , mLocked( locked )
292  , mRenderingPass( 0 )
293  , mPaintEffect( 0 )
294 {
296  mPaintEffect->setEnabled( false );
297 }
298 
299 void QgsSymbolLayerV2::prepareExpressions( const QgsFields* fields, double scale )
300 {
302  for ( ; it != mDataDefinedProperties.end(); ++it )
303  {
304  if ( it.value() )
305  {
307  if ( scale > 0 )
308  {
309  params.insert( "scale", scale );
310  }
311  it.value()->setExpressionParams( params );
312 
313  if ( fields )
314  {
315  it.value()->prepareExpression( *fields );
316  }
317  else
318  {
319  it.value()->prepareExpression();
320  }
321  }
322  }
323 
324  if ( fields )
325  {
326  //QgsFields is implicitly shared, so it's cheap to make a copy
327  mFields = *fields;
328  }
329 }
330 
332 {
334  delete mPaintEffect;
335 }
336 
338 {
339  QStringList columns;
340 
342  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
343  {
344  if ( ddIt.value() && ddIt.value()->isActive() )
345  {
346  columns.append( ddIt.value()->referencedColumns() );
347  }
348  }
349 
350  return columns.toSet();
351 }
352 
354 {
356  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
357  {
358  if ( ddIt.value() )
359  {
360  stringMap.unite( ddIt.value()->toMap( ddIt.key() ) );
361  }
362  }
363 }
364 
366 {
367  QgsStringMap::const_iterator propIt = stringMap.constBegin();
368  for ( ; propIt != stringMap.constEnd(); ++propIt )
369  {
370  if ( propIt.key().endsWith( "_dd_expression" ) )
371  {
372  //found a data defined property
373 
374  //get data defined property name by stripping "_dd_expression" from property key
375  QString propertyName = propIt.key().left( propIt.key().length() - 14 );
376 
377  QgsDataDefined* dd = QgsDataDefined::fromMap( stringMap, propertyName );
378  if ( dd )
379  setDataDefinedProperty( propertyName, dd );
380  }
381  else if ( propIt.key().endsWith( "_expression" ) )
382  {
383  //old style data defined property, upgrade
384 
385  //get data defined property name by stripping "_expression" from property key
386  QString propertyName = propIt.key().left( propIt.key().length() - 11 );
387 
388  setDataDefinedProperty( propertyName, new QgsDataDefined( propIt.value() ) );
389  }
390  }
391 }
392 
394 {
395  if ( !destLayer )
396  return;
397 
398  destLayer->removeDataDefinedProperties();
399 
401  for ( ; ddIt != mDataDefinedProperties.constEnd(); ++ddIt )
402  {
403  if ( ddIt.value() )
404  {
405  destLayer->setDataDefinedProperty( ddIt.key(), new QgsDataDefined( *( ddIt.value() ) ) );
406  }
407  }
408 }
409 
411 {
412  if ( !destLayer || !mPaintEffect )
413  return;
414 
415  destLayer->setPaintEffect( mPaintEffect->clone() );
416 }
417 
419  : QgsSymbolLayerV2( QgsSymbolV2::Marker, locked )
420  , mAngle( 0 )
421  , mLineAngle( 0 )
422  , mSize( 2.0 )
423  , mSizeUnit( QgsSymbolV2::MM )
424  , mOffsetUnit( QgsSymbolV2::MM )
425  , mScaleMethod( QgsSymbolV2::ScaleArea )
426  , mHorizontalAnchorPoint( HCenter )
427  , mVerticalAnchorPoint( VCenter )
428 {
429 
430 }
431 
433  : QgsSymbolLayerV2( QgsSymbolV2::Line, locked )
434  , mWidth( 0 )
435  , mWidthUnit( QgsSymbolV2::MM )
436  , mOffset( 0 )
437  , mOffsetUnit( QgsSymbolV2::MM )
438 {
439 }
440 
442  : QgsSymbolLayerV2( QgsSymbolV2::Fill, locked )
443  , mAngle( 0.0 )
444 {
445 }
446 
448 {
449  Q_UNUSED( context );
450 }
451 
453 {
454  startRender( context );
455  renderPoint( QPointF( size.width() / 2, size.height() / 2 ), context );
456  stopRender( context );
457 }
458 
459 void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& context, double& offsetX, double& offsetY ) const
460 {
462 }
463 
464 void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& context, double width, double height, double& offsetX, double& offsetY ) const
465 {
466  markerOffset( context, width, height, mSizeUnit, mSizeUnit, offsetX, offsetY, mSizeMapUnitScale, mSizeMapUnitScale );
467 }
468 
469 void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& context, double width, double height,
470  QgsSymbolV2::OutputUnit widthUnit, QgsSymbolV2::OutputUnit heightUnit,
471  double& offsetX, double& offsetY, const QgsMapUnitScale& widthMapUnitScale, const QgsMapUnitScale& heightMapUnitScale ) const
472 {
473  offsetX = mOffset.x();
474  offsetY = mOffset.y();
475 
477  {
479  offsetX = offset.x();
480  offsetY = offset.y();
481  }
482 
485 
489  {
490  horizontalAnchorPoint = decodeHorizontalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HORIZONTAL_ANCHOR_POINT , context.feature() ).toString() );
491  }
493  {
494  verticalAnchorPoint = decodeVerticalAnchorPoint( evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_VERTICAL_ANCHOR_POINT, context.feature() ).toString() );
495  }
496 
497  //correct horizontal position according to anchor point
498  if ( horizontalAnchorPoint == HCenter && verticalAnchorPoint == VCenter )
499  {
500  return;
501  }
502 
503  double anchorPointCorrectionX = width * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), widthUnit, widthMapUnitScale ) / 2.0;
504  double anchorPointCorrectionY = height * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), heightUnit, heightMapUnitScale ) / 2.0;
505  if ( horizontalAnchorPoint == Left )
506  {
507  offsetX += anchorPointCorrectionX;
508  }
509  else if ( horizontalAnchorPoint == Right )
510  {
511  offsetX -= anchorPointCorrectionX;
512  }
513 
514  //correct vertical position according to anchor point
515  if ( verticalAnchorPoint == Top )
516  {
517  offsetY += anchorPointCorrectionY;
518  }
519  else if ( verticalAnchorPoint == Bottom )
520  {
521  offsetY -= anchorPointCorrectionY;
522  }
523 }
524 
526 {
527  angle = DEG2RAD( angle );
528  double c = cos( angle ), s = sin( angle );
529  return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c );
530 }
531 
532 QgsMarkerSymbolLayerV2::HorizontalAnchorPoint QgsMarkerSymbolLayerV2::decodeHorizontalAnchorPoint( const QString& str )
533 {
534  if ( str.compare( "left", Qt::CaseInsensitive ) == 0 )
535  {
537  }
538  else if ( str.compare( "right", Qt::CaseInsensitive ) == 0 )
539  {
541  }
542  else
543  {
545  }
546 }
547 
548 QgsMarkerSymbolLayerV2::VerticalAnchorPoint QgsMarkerSymbolLayerV2::decodeVerticalAnchorPoint( const QString& str )
549 {
550  if ( str.compare( "top", Qt::CaseInsensitive ) == 0 )
551  {
553  }
554  else if ( str.compare( "bottom", Qt::CaseInsensitive ) == 0 )
555  {
557  }
558  else
559  {
561  }
562 }
563 
565 {
566  mSizeUnit = unit;
567  mOffsetUnit = unit;
568 }
569 
571 {
572  if ( mOffsetUnit != mSizeUnit )
573  {
574  return QgsSymbolV2::Mixed;
575  }
576  return mOffsetUnit;
577 }
578 
580 {
581  mSizeMapUnitScale = scale;
582  mOffsetMapUnitScale = scale;
583 }
584 
586 {
588  {
589  return mSizeMapUnitScale;
590  }
591  return QgsMapUnitScale();
592 }
593 
595 {
596  mWidthUnit = unit;
597 }
598 
600 {
601  return mWidthUnit;
602 }
603 
605 {
606  mWidthMapUnitScale = scale;
607 }
608 
610 {
611  return mWidthMapUnitScale;
612 }
613 
614 
616 {
617  QPolygonF points;
618  // we're adding 0.5 to get rid of blurred preview:
619  // drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
620  points << QPointF( 0, int( size.height() / 2 ) + 0.5 ) << QPointF( size.width(), int( size.height() / 2 ) + 0.5 );
621 
622  startRender( context );
623  renderPolyline( points, context );
624  stopRender( context );
625 }
626 
628 {
629  renderPolyline( points, context );
630  if ( rings )
631  {
632  foreach ( const QPolygonF& ring, *rings )
633  renderPolyline( ring, context );
634  }
635 }
636 
638 {
639  Q_UNUSED( context );
641 }
642 
643 
645 {
646  QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width(), size.height() ) );
647  startRender( context );
648  renderPolygon( poly, NULL, context );
649  stopRender( context );
650 }
651 
653 {
654  if ( !p )
655  {
656  return;
657  }
658 
659  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
660  if ( points.size() <= 5 &&
663  ( p->renderHints() & QPainter::Antialiasing ) )
664  {
665  p->setRenderHint( QPainter::Antialiasing, false );
666  p->drawRect( points.boundingRect() );
667  p->setRenderHint( QPainter::Antialiasing, true );
668  return;
669  }
670 
671  if ( rings == NULL )
672  {
673  // simple polygon without holes
674  p->drawPolygon( points );
675  }
676  else
677  {
678  // polygon with holes must be drawn using painter path
679  QPainterPath path;
680  QPolygonF outerRing = points;
681  path.addPolygon( outerRing );
682 
684  for ( ; it != rings->constEnd(); ++it )
685  {
686  QPolygonF ring = *it;
687  path.addPolygon( ring );
688  }
689 
690  p->drawPath( path );
691  }
692 }
693 
695 {
696  QDomElement symbolizerElem = doc.createElement( "se:PointSymbolizer" );
697  if ( !props.value( "uom", "" ).isEmpty() )
698  symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
699  element.appendChild( symbolizerElem );
700 
701  // <Geometry>
702  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );
703 
704  writeSldMarker( doc, symbolizerElem, props );
705 }
706 
707 
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
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.
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
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
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
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:354
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: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.
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:243
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)
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 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
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: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 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
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
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:278
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