30 #include <QSvgRenderer> 33 #include <QDomDocument> 34 #include <QDomElement> 41 static void _fixQPictureDPI( QPainter *p )
47 p->scale( static_cast< double >(
qt_defaultDpiX() ) / p->device()->logicalDpiX(),
48 static_cast< double >(
qt_defaultDpiY() ) / p->device()->logicalDpiY() );
61 QList< Shape > shapes;
145 QTransform transform;
148 if ( !hasDataDefinedSize )
151 double half = scaledSize / 2.0;
152 transform.scale( half, half );
158 transform.rotate(
mAngle );
185 bool hasDataDefinedSize =
false;
186 double scaledSize =
calculateSize( context, hasDataDefinedSize );
188 bool hasDataDefinedRotation =
false;
194 bool createdNewPath =
false;
201 if ( exprVal.isValid() )
212 createdNewPath =
true;
221 QTransform transform;
224 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
227 if ( hasDataDefinedSize || createdNewPath )
230 double half = s / 2.0;
231 transform.scale( half, half );
234 if ( !
qgsDoubleNear( angle, 0.0 ) && ( hasDataDefinedRotation || createdNewPath ) )
235 transform.rotate( angle );
243 polygon = transform.map(
mPolygon );
247 path = transform.map(
mPath );
249 draw( context, symbol, polygon, path );
254 bool hasDataDefinedSize =
false;
255 double scaledSize =
calculateSize( context, hasDataDefinedSize );
257 bool hasDataDefinedRotation =
false;
264 QTransform transform;
267 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
270 transform.rotate( angle );
272 return transform.mapRect( QRectF( -scaledSize / 2.0,
282 QString cleaned = name.toLower().trimmed();
284 if ( cleaned == QLatin1String(
"square" ) || cleaned == QLatin1String(
"rectangle" ) )
286 else if ( cleaned == QLatin1String(
"diamond" ) )
288 else if ( cleaned == QLatin1String(
"pentagon" ) )
290 else if ( cleaned == QLatin1String(
"hexagon" ) )
292 else if ( cleaned == QLatin1String(
"triangle" ) )
294 else if ( cleaned == QLatin1String(
"equilateral_triangle" ) )
296 else if ( cleaned == QLatin1String(
"star" ) || cleaned == QLatin1String(
"regular_star" ) )
298 else if ( cleaned == QLatin1String(
"arrow" ) )
300 else if ( cleaned == QLatin1String(
"circle" ) )
302 else if ( cleaned == QLatin1String(
"cross" ) )
304 else if ( cleaned == QLatin1String(
"cross_fill" ) )
306 else if ( cleaned == QLatin1String(
"cross2" ) || cleaned == QLatin1String(
"x" ) )
308 else if ( cleaned == QLatin1String(
"line" ) )
310 else if ( cleaned == QLatin1String(
"arrowhead" ) )
312 else if ( cleaned == QLatin1String(
"filled_arrowhead" ) )
314 else if ( cleaned == QLatin1String(
"semi_circle" ) )
316 else if ( cleaned == QLatin1String(
"third_circle" ) )
318 else if ( cleaned == QLatin1String(
"quarter_circle" ) )
320 else if ( cleaned == QLatin1String(
"quarter_square" ) )
322 else if ( cleaned == QLatin1String(
"half_square" ) )
324 else if ( cleaned == QLatin1String(
"diagonal_half_square" ) )
326 else if ( cleaned == QLatin1String(
"right_half_triangle" ) )
328 else if ( cleaned == QLatin1String(
"left_half_triangle" ) )
341 return QStringLiteral(
"square" );
343 return QStringLiteral(
"quarter_square" );
345 return QStringLiteral(
"half_square" );
347 return QStringLiteral(
"diagonal_half_square" );
349 return QStringLiteral(
"diamond" );
351 return QStringLiteral(
"pentagon" );
353 return QStringLiteral(
"hexagon" );
355 return QStringLiteral(
"triangle" );
357 return QStringLiteral(
"equilateral_triangle" );
359 return QStringLiteral(
"left_half_triangle" );
361 return QStringLiteral(
"right_half_triangle" );
363 return QStringLiteral(
"star" );
365 return QStringLiteral(
"arrow" );
367 return QStringLiteral(
"filled_arrowhead" );
369 return QStringLiteral(
"cross_fill" );
371 return QStringLiteral(
"circle" );
373 return QStringLiteral(
"cross" );
375 return QStringLiteral(
"cross2" );
377 return QStringLiteral(
"line" );
379 return QStringLiteral(
"arrowhead" );
381 return QStringLiteral(
"semi_circle" );
383 return QStringLiteral(
"third_circle" );
385 return QStringLiteral(
"quarter_circle" );
402 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
406 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 0 ) ) );
410 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 1 ) ) );
414 polygon << QPointF( -1, -1 ) << QPointF( 1, 1 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
418 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
419 << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
429 polygon << QPointF( -0.9511, -0.3090 )
430 << QPointF( -0.5878, 0.8090 )
431 << QPointF( 0.5878, 0.8090 )
432 << QPointF( 0.9511, -0.3090 )
434 << QPointF( -0.9511, -0.3090 );
445 polygon << QPointF( -0.8660, -0.5 )
446 << QPointF( -0.8660, 0.5 )
448 << QPointF( 0.8660, 0.5 )
449 << QPointF( 0.8660, -0.5 )
451 << QPointF( -0.8660, -0.5 );
455 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
463 polygon << QPointF( -0.8660, 0.5 )
464 << QPointF( 0.8660, 0.5 )
466 << QPointF( -0.8660, 0.5 );
470 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
474 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
479 double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
481 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
482 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), - std::cos(
DEG2RAD( 288 ) ) )
483 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), - inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
484 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), - std::cos(
DEG2RAD( 216.0 ) ) )
485 << QPointF( 0, inner_r )
486 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), - std::cos(
DEG2RAD( 144.0 ) ) )
487 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), - inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
488 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), - std::cos(
DEG2RAD( 72.0 ) ) )
489 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), - inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
491 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
496 polygon << QPointF( 0, -1 )
497 << QPointF( 0.5, -0.5 )
498 << QPointF( 0.25, -0.5 )
499 << QPointF( 0.25, 1 )
500 << QPointF( -0.25, 1 )
501 << QPointF( -0.25, -0.5 )
502 << QPointF( -0.5, -0.5 )
507 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
511 polygon << QPointF( -1, -0.2 )
512 << QPointF( -1, -0.2 )
513 << QPointF( -1, 0.2 )
514 << QPointF( -0.2, 0.2 )
515 << QPointF( -0.2, 1 )
517 << QPointF( 0.2, 0.2 )
519 << QPointF( 1, -0.2 )
520 << QPointF( 0.2, -0.2 )
521 << QPointF( 0.2, -1 )
522 << QPointF( -0.2, -1 )
523 << QPointF( -0.2, -0.2 )
524 << QPointF( -1, -0.2 );
543 mPath = QPainterPath();
549 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
553 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
554 mPath.lineTo( 0, 0 );
558 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
559 mPath.lineTo( 0, 0 );
563 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
564 mPath.lineTo( 0, 0 );
568 mPath.moveTo( -1, 0 );
569 mPath.lineTo( 1, 0 );
570 mPath.moveTo( 0, -1 );
571 mPath.lineTo( 0, 1 );
575 mPath.moveTo( -1, -1 );
576 mPath.lineTo( 1, 1 );
577 mPath.moveTo( 1, -1 );
578 mPath.lineTo( -1, 1 );
582 mPath.moveTo( 0, -1 );
583 mPath.lineTo( 0, 1 );
587 mPath.moveTo( -1, -1 );
588 mPath.lineTo( 0, 0 );
589 mPath.lineTo( -1, 1 );
614 double scaledSize =
mSize;
618 if ( hasDataDefinedSize )
625 if ( hasDataDefinedSize && ok )
630 scaledSize = std::sqrt( scaledSize );
645 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
646 offset = QPointF( offsetX, offsetY );
651 bool usingDataDefinedRotation =
false;
656 usingDataDefinedRotation = ok;
660 if ( hasDataDefinedRotation )
689 , mStrokeColor( strokeColor )
690 , mPenJoinStyle( penJoinStyle )
705 if ( props.contains( QStringLiteral(
"name" ) ) )
707 shape =
decodeShape( props[QStringLiteral(
"name" )] );
709 if ( props.contains( QStringLiteral(
"color" ) ) )
711 if ( props.contains( QStringLiteral(
"color_border" ) ) )
716 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
720 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
724 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
728 if ( props.contains( QStringLiteral(
"size" ) ) )
729 size = props[QStringLiteral(
"size" )].toDouble();
730 if ( props.contains( QStringLiteral(
"angle" ) ) )
731 angle = props[QStringLiteral(
"angle" )].toDouble();
732 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
736 if ( props.contains( QStringLiteral(
"offset" ) ) )
738 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
740 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
742 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
744 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
747 if ( props.contains( QStringLiteral(
"outline_style" ) ) )
751 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
755 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
757 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
759 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
761 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
763 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
767 if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
771 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
776 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
780 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
793 return QStringLiteral(
"SimpleMarker" );
800 QColor brushColor =
mColor;
806 mBrush = QBrush( brushColor );
807 mPen = QPen( penColor );
816 selBrushColor.setAlphaF( context.
opacity() );
817 selPenColor.setAlphaF( context.
opacity() );
839 mSelPen.setColor( selBrushColor );
863 double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
864 int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
865 double center = imageSize / 2.0;
872 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
879 p.setRenderHint( QPainter::Antialiasing );
880 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
882 p.translate( QPointF( center, center ) );
890 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
894 p.setRenderHint( QPainter::Antialiasing );
895 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
897 p.translate( QPointF( center, center ) );
908 p.setRenderHint( QPainter::Antialiasing );
909 p.fillRect( 0, 0, imageSize, imageSize, selColor );
910 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
912 p.translate( QPointF( center, center ) );
986 p->setBrush( Qt::NoBrush );
990 if ( !polygon.isEmpty() )
991 p->drawPolygon( polygon );
1010 double s = img.width();
1012 bool hasDataDefinedSize =
false;
1013 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1015 bool hasDataDefinedRotation =
false;
1020 p->drawImage( QRectF( point.x() - s / 2.0 + offset.x(),
1021 point.y() - s / 2.0 + offset.y(),
1036 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1039 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1045 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
1076 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1077 element.appendChild( graphicElem );
1086 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
1089 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
1093 angleFunc = QString::number( angle +
mAngle );
1104 Q_UNUSED( mmScaleFactor )
1105 Q_UNUSED( mapUnitScaleFactor )
1107 QString ogrType =
"3";
1108 if ( mName ==
"square" )
1112 else if ( mName ==
"triangle" )
1116 else if ( mName ==
"star" )
1120 else if ( mName ==
"circle" )
1124 else if ( mName ==
"cross" )
1128 else if ( mName ==
"x" || mName ==
"cross2" )
1132 else if ( mName ==
"line" )
1138 ogrString.append(
"SYMBOL(" );
1139 ogrString.append(
"id:" );
1140 ogrString.append(
'\"' );
1141 ogrString.append(
"ogr-sym-" );
1142 ogrString.append( ogrType );
1143 ogrString.append(
'\"' );
1144 ogrString.append(
",c:" );
1145 ogrString.append(
mColor.name() );
1146 ogrString.append(
",o:" );
1148 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1149 ogrString.append(
')' );
1154 ogrString.append(
"PEN(" );
1155 ogrString.append(
"c:" );
1156 ogrString.append(
mColor.name() );
1157 ogrString.append(
",w:" );
1158 ogrString.append( QString::number(
mSize ) );
1159 ogrString.append(
"mm" );
1160 ogrString.append(
")" );
1168 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1169 if ( graphicElem.isNull() )
1172 QString name = QStringLiteral(
"square" );
1185 double d = angleFunc.toDouble( &ok );
1195 QString uom = element.attribute( QStringLiteral(
"uom" ) );
1221 p->drawPath(
mPath );
1227 Q_UNUSED( mmMapUnitScaleFactor )
1236 if ( hasDataDefinedSize )
1245 size = std::sqrt( size );
1258 double halfSize = size / 2.0;
1275 QColor pc =
mPen.color();
1276 QColor bc =
mBrush.color();
1296 QPointF off( offsetX, offsetY );
1325 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1333 t.scale( halfSize, -halfSize );
1335 polygon = t.map( polygon );
1338 p.reserve( polygon.size() );
1339 for (
int i = 0; i < polygon.size(); i++ )
1344 if (
mBrush.style() != Qt::NoBrush )
1346 if (
mPen.style() != Qt::NoPen )
1347 e.
writePolyline( p, layerName, QStringLiteral(
"CONTINUOUS" ), pc, strokeWidth );
1349 else if ( shape ==
Circle )
1351 shift += QPointF( off.x(), -off.y() );
1352 if (
mBrush.style() != Qt::NoBrush )
1354 if (
mPen.style() != Qt::NoPen )
1355 e.
writeCircle( layerName, pc,
QgsPoint( shift ), halfSize, QStringLiteral(
"CONTINUOUS" ), strokeWidth );
1357 else if ( shape ==
Line )
1359 QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1360 QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1362 if (
mPen.style() != Qt::NoPen )
1365 else if ( shape ==
Cross )
1367 if (
mPen.style() != Qt::NoPen )
1369 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1370 QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1371 QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1372 QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1378 else if ( shape ==
Cross2 )
1380 if (
mPen.style() != Qt::NoPen )
1382 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1383 QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1384 QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1385 QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1393 if (
mPen.style() != Qt::NoPen )
1395 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1396 QPointF pt2 = t.map( QPointF( 0, 0 ) );
1397 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1448 double penWidth = 0.0;
1463 if ( ok && strokeStyle == QLatin1String(
"no" ) )
1472 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1473 penWidth / 2.0, penWidth / 2.0 );
1475 return symbolBounds;
1522 if ( props.contains( QStringLiteral(
"name" ) ) )
1523 name = props[QStringLiteral(
"name" )];
1524 if ( props.contains( QStringLiteral(
"size" ) ) )
1525 size = props[QStringLiteral(
"size" )].toDouble();
1526 if ( props.contains( QStringLiteral(
"angle" ) ) )
1527 angle = props[QStringLiteral(
"angle" )].toDouble();
1528 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1532 if ( props.contains( QStringLiteral(
"offset" ) ) )
1534 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1536 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1538 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1540 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1542 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1546 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1560 return QStringLiteral(
"FilledMarker" );
1585 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1588 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1621 mFill.reset( static_cast<QgsFillSymbol *>( symbol ) );
1644 attr.unite( mFill->usedAttributes( context ) );
1652 if ( mFill && mFill->hasDataDefinedProperties() )
1661 mFill->setColor( c );
1666 return mFill ? mFill->color() :
mColor;
1682 p->setBrush( Qt::red );
1686 p->setBrush( Qt::NoBrush );
1688 p->setPen( Qt::black );
1690 if ( !polygon.isEmpty() )
1696 QPolygonF poly = path.toFillPolygon();
1716 mColor = QColor( 35, 35, 35 );
1717 mStrokeColor = QColor( 35, 35, 35 );
1718 updateDefaultAspectRatio();
1729 if ( props.contains( QStringLiteral(
"name" ) ) )
1730 name = props[QStringLiteral(
"name" )];
1731 if ( props.contains( QStringLiteral(
"size" ) ) )
1732 size = props[QStringLiteral(
"size" )].toDouble();
1733 if ( props.contains( QStringLiteral(
"angle" ) ) )
1734 angle = props[QStringLiteral(
"angle" )].toDouble();
1735 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1741 if ( !props.contains( QStringLiteral(
"fill" ) ) && !props.contains( QStringLiteral(
"color" ) ) && !props.contains( QStringLiteral(
"outline" ) ) &&
1742 !props.contains( QStringLiteral(
"outline_color" ) ) && !props.contains( QStringLiteral(
"outline-width" ) ) && !props.contains( QStringLiteral(
"outline_width" ) ) )
1745 double fillOpacity = 1.0;
1746 double strokeOpacity = 1.0;
1748 bool hasFillParam =
false, hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1749 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1751 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1752 hasStrokeParam, hasDefaultStrokeColor, strokeColor,
1753 hasStrokeWidthParam, hasDefaultStrokeWidth, strokeWidth,
1754 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1755 if ( hasDefaultFillColor )
1759 if ( hasDefaultFillOpacity )
1762 c.setAlphaF( fillOpacity );
1765 if ( hasDefaultStrokeColor )
1769 if ( hasDefaultStrokeWidth )
1773 if ( hasDefaultStrokeOpacity )
1776 c.setAlphaF( strokeOpacity );
1781 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1783 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1785 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
1787 if ( props.contains( QStringLiteral(
"offset" ) ) )
1789 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1791 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1793 if ( props.contains( QStringLiteral(
"fill" ) ) )
1798 else if ( props.contains( QStringLiteral(
"color" ) ) )
1802 if ( props.contains( QStringLiteral(
"outline" ) ) )
1807 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
1811 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
1816 if ( props.contains( QStringLiteral(
"outline-width" ) ) )
1819 m->
setStrokeWidth( props[QStringLiteral(
"outline-width" )].toDouble() );
1821 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
1823 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
1825 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
1827 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
1830 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
1834 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
1838 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1841 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1845 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1859 QgsStringMap::iterator it = properties.find( QStringLiteral(
"name" ) );
1860 if ( it != properties.end() )
1872 QColor defaultFillColor, defaultStrokeColor;
1873 double strokeWidth, fillOpacity, strokeOpacity;
1874 bool hasFillParam =
false, hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1875 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1877 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1878 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
1879 hasStrokeWidthParam, hasDefaultStrokeWidth, strokeWidth,
1880 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1882 double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
1883 double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
1885 if ( hasDefaultFillColor )
1887 defaultFillColor.setAlphaF( newFillOpacity );
1890 if ( hasDefaultFillOpacity )
1893 c.setAlphaF( fillOpacity );
1896 if ( hasDefaultStrokeColor )
1898 defaultStrokeColor.setAlphaF( newStrokeOpacity );
1901 if ( hasDefaultStrokeWidth )
1903 setStrokeWidth( strokeWidth );
1905 if ( hasDefaultStrokeOpacity )
1908 c.setAlphaF( strokeOpacity );
1912 updateDefaultAspectRatio();
1917 if ( mDefaultAspectRatio == 0.0 )
1922 double widthScaleFactor = 3.465;
1925 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
1927 return mDefaultAspectRatio;
1932 bool aPreservedAspectRatio = preservedAspectRatio();
1933 if ( aPreservedAspectRatio && !par )
1935 mFixedAspectRatio = mDefaultAspectRatio;
1937 else if ( !aPreservedAspectRatio && par )
1939 mFixedAspectRatio = 0.0;
1941 return preservedAspectRatio();
1947 return QStringLiteral(
"SvgMarker" );
1967 bool hasDataDefinedSize =
false;
1968 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1972 if ( static_cast< int >( size ) < 1 || 10000.0 < size )
1979 bool hasDataDefinedAspectRatio =
false;
1980 double aspectRatio = calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
1982 QPointF outputOffset;
1986 p->translate( point + outputOffset );
1992 QString path =
mPath;
2000 double strokeWidth = mStrokeWidth;
2022 bool fitsInCache =
true;
2023 bool usePict =
true;
2024 double hwRatio = 1.0;
2029 if ( fitsInCache && img.width() > 1 )
2035 QImage transparentImage = img.copy();
2037 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2038 hwRatio =
static_cast< double >( transparentImage.height() ) / static_cast< double >( transparentImage.width() );
2042 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2043 hwRatio =
static_cast< double >( img.height() ) / static_cast< double >( img.width() );
2048 if ( usePict || !fitsInCache )
2050 p->setOpacity( context.
opacity() );
2053 if ( pct.width() > 1 )
2056 _fixQPictureDPI( p );
2057 p->drawPicture( 0, 0, pct );
2059 hwRatio =
static_cast< double >( pct.height() ) / static_cast< double >( pct.width() );
2067 if ( penWidth > size / 20 )
2070 penWidth = size / 20;
2072 double penOffset = penWidth / 2;
2073 pen.setWidth( penWidth );
2075 p->setBrush( Qt::NoBrush );
2076 double wSize = size + penOffset;
2077 double hSize = size * hwRatio + penOffset;
2078 p->drawRect( QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
2086 p->setRenderHint( QPainter::Antialiasing );
2091 double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const 2093 double scaledSize =
mSize;
2097 if ( hasDataDefinedSize )
2105 if ( hasDataDefinedSize )
2112 if ( hasDataDefinedSize && ok )
2117 scaledSize = std::sqrt( scaledSize );
2130 if ( !hasDataDefinedAspectRatio )
2131 return mFixedAspectRatio;
2136 double scaledAspectRatio = mDefaultAspectRatio;
2137 if ( mFixedAspectRatio > 0.0 )
2138 scaledAspectRatio = mFixedAspectRatio;
2140 double defaultHeight =
mSize * scaledAspectRatio;
2141 scaledAspectRatio = defaultHeight / scaledSize;
2144 double scaledHeight = scaledSize * scaledAspectRatio;
2151 if ( hasDataDefinedAspectRatio && ok )
2156 scaledHeight = sqrt( scaledHeight );
2163 scaledAspectRatio = scaledHeight / scaledSize;
2165 return scaledAspectRatio;
2173 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
2174 offset = QPointF( offsetX, offsetY );
2184 if ( hasDataDefinedRotation )
2210 map[QStringLiteral(
"name" )] =
mPath;
2211 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2214 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number( mFixedAspectRatio );
2215 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2222 map[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
2254 mStrokeWidthUnit = unit;
2260 if ( unit != mStrokeWidthUnit )
2270 mStrokeWidthMapUnitScale = scale;
2277 return mStrokeWidthMapUnitScale;
2285 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2286 element.appendChild( graphicElem );
2296 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2299 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2303 angleFunc = QString::number( angle +
mAngle );
2317 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
2318 if ( graphicElem.isNull() )
2321 QString path, mimeType;
2328 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2331 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2339 double d = angleFunc.toDouble( &ok );
2365 if ( hasDataDefinedSize )
2371 if ( hasDataDefinedSize && ok )
2376 size = std::sqrt( size );
2385 size *= mmMapUnitScaleFactor;
2398 double offsetX = offset.x();
2399 double offsetY = offset.y();
2401 QPointF outputOffset( offsetX, offsetY );
2415 QString path =
mPath;
2423 double strokeWidth = mStrokeWidth;
2448 QSvgRenderer r( svgContent );
2455 QSizeF outSize( r.defaultSize() );
2456 outSize.scale( size, size, Qt::KeepAspectRatio );
2462 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2464 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2466 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2467 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2476 bool hasDataDefinedSize =
false;
2477 double scaledSize =
calculateSize( context, hasDataDefinedSize );
2481 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2486 QPointF outputOffset;
2490 QString path =
mPath;
2498 double strokeWidth = mStrokeWidth;
2524 double scaledHeight = svgViewbox.isValid() ? scaledSize * svgViewbox.height() / svgViewbox.width() : scaledSize;
2529 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2532 transform.rotate( angle );
2535 strokeWidth += 1.0 / 2.0;
2537 QRectF symbolBounds = transform.mapRect( QRectF( -scaledSize / 2.0,
2538 -scaledHeight / 2.0,
2543 symbolBounds.adjust( -strokeWidth / 2.0, -strokeWidth / 2.0,
2544 strokeWidth / 2.0, strokeWidth / 2.0 );
2546 return symbolBounds;
2570 if ( props.contains( QStringLiteral(
"imageFile" ) ) )
2571 path = props[QStringLiteral(
"imageFile" )];
2572 if ( props.contains( QStringLiteral(
"size" ) ) )
2573 size = props[QStringLiteral(
"size" )].toDouble();
2574 if ( props.contains( QStringLiteral(
"angle" ) ) )
2575 angle = props[QStringLiteral(
"angle" )].toDouble();
2576 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
2581 if ( props.contains( QStringLiteral(
"alpha" ) ) )
2583 m->
setOpacity( props[QStringLiteral(
"alpha" )].toDouble() );
2586 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2588 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2590 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
2593 if ( props.contains( QStringLiteral(
"offset" ) ) )
2595 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2597 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2600 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2604 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
2617 QgsStringMap::iterator it = properties.find( QStringLiteral(
"name" ) );
2618 if ( it != properties.end() )
2636 if ( aPreservedAspectRatio && !par )
2640 else if ( !aPreservedAspectRatio && par )
2652 mDefaultAspectRatio = ( !size.isNull() && size.isValid() && size.width() > 0 ) ? static_cast< double >( size.height() ) / static_cast< double >( size.width() ) : 0.0;
2659 return QStringLiteral(
"RasterMarker" );
2668 bool hasDataDefinedSize =
false;
2669 double scaledSize = calculateSize( context, hasDataDefinedSize );
2671 bool hasDataDefinedAspectRatio =
false;
2676 if ( static_cast< int >( width ) < 1 || 10000.0 < width )
2681 QString path =
mPath;
2689 if ( !size.isNull() && size.isValid() && size.width() > 0 )
2691 height = width * (
static_cast< double >( size.height() ) / static_cast< double >( size.width() ) );
2696 if ( path.isEmpty() )
2701 QPointF outputOffset;
2703 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset, angle );
2705 p->translate( point + outputOffset );
2721 if ( !img.isNull() )
2726 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2732 double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const 2734 double scaledSize =
mSize;
2738 if ( hasDataDefinedSize )
2746 if ( hasDataDefinedSize )
2753 if ( hasDataDefinedSize && ok )
2758 scaledSize = std::sqrt( scaledSize );
2771 if ( !hasDataDefinedAspectRatio )
2781 double defaultHeight =
mSize * scaledAspectRatio;
2782 scaledAspectRatio = defaultHeight / scaledSize;
2785 double scaledHeight = scaledSize * scaledAspectRatio;
2792 if ( hasDataDefinedAspectRatio && ok )
2797 scaledHeight = sqrt( scaledHeight );
2804 scaledAspectRatio = scaledHeight / scaledSize;
2806 return scaledAspectRatio;
2809 void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const 2814 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2815 offset = QPointF( offsetX, offsetY );
2825 if ( hasDataDefinedRotation )
2846 map[QStringLiteral(
"imageFile" )] =
mPath;
2847 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2850 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2851 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2852 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
2891 bool hasDataDefinedSize =
false;
2892 double scaledSize = calculateSize( context, hasDataDefinedSize );
2894 bool hasDataDefinedAspectRatio =
false;
2899 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2904 QPointF outputOffset;
2906 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset, angle );
2911 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2914 transform.rotate( angle );
2916 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
2921 return symbolBounds;
2928 mFontFamily = fontFamily;
2933 mOrigSize = pointSize;
2945 delete mFontMetrics;
2956 if ( props.contains( QStringLiteral(
"font" ) ) )
2957 fontFamily = props[QStringLiteral(
"font" )];
2958 if ( props.contains( QStringLiteral(
"chr" ) ) && props[QStringLiteral(
"chr" )].length() > 0 )
2959 string = props[QStringLiteral(
"chr" )];
2960 if ( props.contains( QStringLiteral(
"size" ) ) )
2961 pointSize = props[QStringLiteral(
"size" )].toDouble();
2962 if ( props.contains( QStringLiteral(
"color" ) ) )
2964 if ( props.contains( QStringLiteral(
"angle" ) ) )
2965 angle = props[QStringLiteral(
"angle" )].toDouble();
2969 if ( props.contains( QStringLiteral(
"outline_color" ) ) )
2971 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
2972 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
2973 if ( props.contains( QStringLiteral(
"offset" ) ) )
2975 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2977 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2979 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2981 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2983 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
2985 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2987 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
2989 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2991 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3001 return QStringLiteral(
"FontMarker" );
3006 QColor brushColor =
mColor;
3007 QColor penColor = mStrokeColor;
3009 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3010 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3012 mBrush = QBrush( brushColor );
3013 mPen = QPen( penColor );
3014 mPen.setJoinStyle( mPenJoinStyle );
3017 mFont = QFont( mFontFamily );
3019 delete mFontMetrics;
3020 mFontMetrics =
new QFontMetrics( mFont );
3021 mChrWidth = mFontMetrics->width( mString );
3022 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3031 QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3033 charOffset = mChrOffset;
3034 QString stringToRender = mString;
3039 if ( stringToRender != mString )
3041 charWidth = mFontMetrics->width( stringToRender );
3042 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3045 return stringToRender;
3050 bool &hasDataDefinedRotation,
3052 double &angle )
const 3057 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3058 offset = QPointF( offsetX, offsetY );
3063 bool usingDataDefinedRotation =
false;
3068 usingDataDefinedRotation = ok;
3072 if ( hasDataDefinedRotation )
3096 double scaledSize =
mSize;
3100 if ( hasDataDefinedSize )
3106 if ( hasDataDefinedSize && ok )
3111 scaledSize = std::sqrt( scaledSize );
3126 QTransform transform;
3129 QColor brushColor =
mColor;
3136 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3137 mBrush.setColor( brushColor );
3139 QColor penColor = mStrokeColor;
3145 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3168 p->setBrush( mBrush );
3171 mPen.setColor( penColor );
3172 mPen.setWidthF( penWidth );
3177 p->setPen( Qt::NoPen );
3181 QPointF chrOffset = mChrOffset;
3183 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3185 double sizeToRender = calculateSize( context );
3187 bool hasDataDefinedRotation =
false;
3190 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation, offset, angle );
3192 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
3195 transform.rotate( angle );
3199 double s = sizeToRender / mOrigSize;
3200 transform.scale( s, s );
3204 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3205 p->drawPath( transform.map( path ) );
3212 props[QStringLiteral(
"font" )] = mFontFamily;
3213 props[QStringLiteral(
"chr" )] = mString;
3214 props[QStringLiteral(
"size" )] = QString::number(
mSize );
3219 props[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
3223 props[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3255 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3256 element.appendChild( graphicElem );
3258 QString fontPath = QStringLiteral(
"ttf://%1" ).arg( mFontFamily );
3259 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
3266 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3269 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
3273 angleFunc = QString::number( angle +
mAngle );
3284 QPointF chrOffset = mChrOffset;
3285 double chrWidth = mChrWidth;
3287 ( void )characterToRender( context, chrOffset, chrWidth );
3289 if ( !mFontMetrics )
3290 mFontMetrics =
new QFontMetrics( mFont );
3292 double scaledSize = calculateSize( context );
3295 chrWidth *= scaledSize / mOrigSize;
3298 bool hasDataDefinedRotation =
false;
3301 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
3307 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
3310 transform.rotate( angle );
3312 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
3316 return symbolBounds;
3323 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
3324 if ( graphicElem.isNull() )
3327 QString name, format;
3335 if ( !name.startsWith( QLatin1String(
"ttf://" ) ) || format != QLatin1String(
"ttf" ) )
3338 QString fontFamily = name.mid( 6 );
3345 double d = angleFunc.toDouble( &ok );
3353 QString uom = element.attribute( QStringLiteral(
"uom" ) );
bool prepareCache(QgsSymbolRenderContext &context)
Prepares cache image.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
static void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
QPicture svgAsPicture(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool forceVectorOutput=false, double fixedAspectRatio=0)
Gets SVG as QPicture&.
#define DEFAULT_SIMPLEMARKER_SIZE
QgsMapUnitScale mapUnitScale() const override
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSimpleMarkerSymbolLayer from an SLD XML element.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
double symbologyScale() const
Returns the reference scale for output.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
#define DEFAULT_RASTERMARKER_SIZE
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Write line (as a polyline)
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
void setColor(const QColor &c) override
The fill color.
QColor mStrokeColor
Stroke color.
QgsFields fields() const
Fields of the layer.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsRasterMarkerSymbolLayer(const QString &path=QString(), double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs raster marker symbol layer with picture from given absolute path to a raster image file...
Qt::PenStyle mStrokeStyle
Stroke style.
Calculate scale by the diameter.
Abstract base class for all rendered symbols.
void setMapUnitScale(const QgsMapUnitScale &scale) override
A paint device for drawing into dxf files.
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double...
#define DEFAULT_SIMPLEMARKER_NAME
Use antialiasing while drawing.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke...
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
Abstract base class for simple marker symbol layers.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0)
Gets SVG as QImage.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Right facing filled arrow head.
Right facing arrow head (unfilled, lines only)
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void startRender(QgsSymbolRenderContext &context) override
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double mLineAngle
Line rotation angle (see setLineAngle() for details)
void setDrawingSize(QSizeF size)
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
virtual QColor strokeColor() const
Gets stroke color.
QgsMapUnitScale mapUnitScale() const override
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
static const int MAXIMUM_CACHE_WIDTH
Maximum width/height of cache image.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
#define DEFAULT_FONTMARKER_COLOR
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
QBrush mSelBrush
QBrush to use as fill of selected symbols.
static QgsSimpleMarkerSymbolLayerBase::Shape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
void setStrokeWidth(double width)
Set's the marker's stroke width.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
#define DEFAULT_FONTMARKER_BORDERCOLOR
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
Flags flags() const
Returns combination of flags used for rendering.
double mFixedAspectRatio
The marker fixed aspect ratio.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
QPointF mOffset
Marker offset.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QColor strokeColor() const override
Returns the marker's stroke color.
void startRender(QgsSymbolRenderContext &context) override
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Stroke width units.
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
bool hasGeometry() const
Returns true if the feature has an associated geometry.
static QString encodeShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Encodes a shape to its string representation.
QgsMapUnitScale mapUnitScale() const override
QMap< QString, QString > QgsStringMap
Rotation of symbol may be changed during rendering and symbol should not be cached.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
Name, eg shape name for simple markers.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes()
Returns a list of all available shape types.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double mapRotation() const
Returns current map rotation in degrees.
#define DEFAULT_FONTMARKER_SIZE
QColor strokeColor() const override
Gets stroke color.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
double strokeWidth() const
Returns the width of the marker's stroke.
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setPath(const QString &path)
Set the marker SVG path.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath...
static QString encodeColor(const QColor &color)
Diagonal half square (bottom left half)
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
virtual void setColor(const QColor &color)
The fill color.
void startRender(QgsSymbolRenderContext &context) override
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
static QString encodePenStyle(Qt::PenStyle style)
Perform transforms between map coordinates and device coordinates.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsFilledMarkerSymbolLayer.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSimpleMarkerSymbolLayer.
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
static double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified.
One third circle (top left third)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
Quarter circle (top left quarter)
Raster marker symbol layer class.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
bool shapeToPolygon(Shape shape, QPolygonF &polygon) const
Creates a polygon representing the specified shape.
void setStrokeColor(const QColor &color) override
Set stroke color.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
void setColor(const QColor &color) override
The fill color.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void stopRender(QgsSymbolRenderContext &context) override
double opacity() const
Returns the marker opacity.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
bool mUsingCache
true if using cached images of markers for drawing.
static void adjustHueSaturation(QImage &image, double saturation, const QColor &colorizeColor=QColor(), double colorizeStrength=1.0)
Alter the hue or saturation of a QImage.
QPen mPen
QPen corresponding to marker's stroke style.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
#define DEFAULT_SCALE_METHOD
Q_GUI_EXPORT int qt_defaultDpiY()
double calculateSize(QgsSymbolRenderContext &context, bool &hasDataDefinedSize) const
Calculates the desired size of the marker, considering data defined size overrides.
Calculate scale by the area.
double mOpacity
The marker default opacity.
qreal opacity() const
Returns the opacity for the symbol.
double size() const
Returns the symbol size.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0...
double mStrokeWidth
Stroke width.
QgsMapUnitScale mapUnitScale() const override
#define DEFAULT_RASTERMARKER_ANGLE
QBrush mBrush
QBrush corresponding to marker's fill style.
QgsSimpleMarkerSymbolLayerBase(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsSimpleMarkerSymbolLayerBase.
QSize originalSize(const QString &path) const
Returns the original size (in pixels) of the image at the specified path.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
static void resolvePaths(QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
#define DEFAULT_FONTMARKER_JOINSTYLE
void setLayer(const QString &layer)
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
QColor color() const override
The fill color.
void calculateOffsetAndRotation(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle) const
Calculates the marker offset and rotation.
virtual QColor color() const
The fill color.
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
void setFillColor(const QColor &color) override
Set fill color.
QColor fillColor() const override
Gets fill color.
QColor selectionColor() const
Returns the color to use when rendering selected features.
#define DEFAULT_FONTMARKER_ANGLE
void setStrokeWidth(double w)
double mAngle
Marker rotation angle, in degrees clockwise from north.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsFontMarkerSymbolLayer from a property map (see properties())
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Character, eg for font marker symbol layers.
static void parametricSvgToSld(QDomDocument &doc, QDomElement &graphicElem, const QString &path, const QColor &fillColor, double size, const QColor &strokeColor, double strokeWidth)
Encodes a reference to a parametric SVG into SLD, as a succession of parametric SVG using URL paramet...
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
void setOpacity(double opacity)
Set the marker opacity.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QPen mSelPen
QPen to use as stroke of selected symbols.
QString path() const
Returns the marker raster image path.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Point geometry type, with support for z-dimension and m-values.
static Qt::PenStyle decodePenStyle(const QString &str)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
void setPath(const QString &path)
Set the marker raster image path.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void startRender(QgsSymbolRenderContext &context) override
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style...
static void resolvePaths(QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing...
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void drawMarker(QPainter *p, QgsSymbolRenderContext &context)
Draws the marker shape in the specified painter.
HorizontalAnchorPoint
Symbol horizontal anchor points.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
virtual void setStrokeColor(const QColor &color)
Set stroke color.
VerticalAnchorPoint
Symbol vertical anchor points.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QString layerType() const override
Returns a string that represents this layer type.
Q_GUI_EXPORT int qt_defaultDpiX()
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QgsSymbol::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
QgsRasterMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsExpressionContext & expressionContext()
Gets the expression context.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth) const
Tests if an svg file contains parameters for fill, stroke color, stroke width.
QString layerType() const override
Returns a string that represents this layer type.
static QString encodeScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
void startRender(QgsSymbolRenderContext &context) override
QVector< QgsPoint > QgsPointSequence
void stopRender(QgsSymbolRenderContext &context) override
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
QString layerType() const override
Returns a string that represents this layer type.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
QVector< QgsPointSequence > QgsRingSequence
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsFontMarkerSymbolLayer from an SLD XML element.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string...
Stroke style (eg solid, dashed)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
void setShift(QPointF shift)
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
QPainter * painter()
Returns the destination QPainter for the render operation.
virtual void setFillColor(const QColor &color)
Set fill color.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QColor color() const override
The fill color.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache)
Returns the specified path rendered as an image.
SymbolType type() const
Returns the symbol's type.
QImage mCache
Cached image of marker, if using cached version.
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Struct for storing maximum and minimum scales for measurements in map units.
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEMARKER_ANGLE
#define DEFAULT_SIMPLEMARKER_COLOR
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void startRender(QgsSymbolRenderContext &context) override
Shape
Marker symbol shapes.
QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD, const QColor &color=DEFAULT_SIMPLEMARKER_COLOR, const QColor &strokeColor=DEFAULT_SIMPLEMARKER_BORDERCOLOR, Qt::PenJoinStyle penJoinStyle=DEFAULT_SIMPLEMARKER_JOINSTYLE)
Constructor for QgsSimpleMarkerSymbolLayer.
QgsSymbol::ScaleMethod mScaleMethod
Marker size scaling method.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
const QgsFeature * feature() const
Returns the current feature being rendered.
QgsSvgMarkerSymbolLayer(const QString &path, double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs SVG marker symbol layer with picture from given absolute path to a SVG file...
~QgsFontMarkerSymbolLayer() override
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0)
Gets SVG content.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QColor fillColor() const override
Gets fill color.
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
QImage mSelCache
Cached image of selected marker, if using cached version.
#define DEFAULT_FONTMARKER_CHR
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
void setAngle(double angle)
Sets the rotation angle for the marker.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QString layerType() const override
Returns a string that represents this layer type.
void stopRender(QgsSymbolRenderContext &context) override
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double mDefaultAspectRatio
The marker default aspect ratio.
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
QgsWkbTypes::GeometryType type
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
void stopRender(QgsSymbolRenderContext &context) override
void setFillColor(const QColor &color) override
Set fill color.
static bool shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Returns true if a symbol shape has a fill.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
Shape mShape
Symbol shape.
bool prepareMarkerShape(Shape shape)
Prepares the layer for drawing the specified shape (QPolygonF version)
Resolves relative paths into absolute paths and vice versa.
void setMapUnitScale(const QgsMapUnitScale &scale) override
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a raster marker symbol layer from a string map of properties.
#define DEFAULT_SVGMARKER_SIZE
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
QgsFilledMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsFilledMarkerSymbolLayer.
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
virtual QColor fillColor() const
Gets fill color.
#define DEFAULT_SVGMARKER_ANGLE
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
Rotated cross (lines only), "x" shape.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
#define DEFAULT_FONTMARKER_FONT
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
QgsPropertyCollection mDataDefinedProperties
QgsFontMarkerSymbolLayer(const QString &fontFamily=DEFAULT_FONTMARKER_FONT, QString chr=DEFAULT_FONTMARKER_CHR, double pointSize=DEFAULT_FONTMARKER_SIZE, const QColor &color=DEFAULT_FONTMARKER_COLOR, double angle=DEFAULT_FONTMARKER_ANGLE)
Constructs a font marker symbol layer.
bool prepareMarkerPath(Shape symbol)
Prepares the layer for drawing the specified shape (QPainterPath version)
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0)
Calculates the viewbox size of a (possibly cached) SVG file.
Quarter square (top left quarter)
RenderUnit
Rendering size units.
static QColor decodeColor(const QString &str)
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void setOutputSize(const QRectF &r)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QgsSymbol::RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...