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 );
864 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
867 double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
868 int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
869 double center = imageSize / 2.0;
875 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
882 p.setRenderHint( QPainter::Antialiasing );
883 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
885 p.translate( QPointF( center, center ) );
893 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
897 p.setRenderHint( QPainter::Antialiasing );
898 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
900 p.translate( QPointF( center, center ) );
911 p.setRenderHint( QPainter::Antialiasing );
912 p.fillRect( 0, 0, imageSize, imageSize, selColor );
913 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
915 p.translate( QPointF( center, center ) );
989 p->setBrush( Qt::NoBrush );
993 if ( !polygon.isEmpty() )
994 p->drawPolygon( polygon );
1013 double s = img.width();
1015 bool hasDataDefinedSize =
false;
1016 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1018 bool hasDataDefinedRotation =
false;
1023 p->drawImage( QRectF( point.x() - s / 2.0 + offset.x(),
1024 point.y() - s / 2.0 + offset.y(),
1039 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1042 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1048 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
1079 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1080 element.appendChild( graphicElem );
1089 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
1092 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
1096 angleFunc = QString::number( angle +
mAngle );
1107 Q_UNUSED( mmScaleFactor )
1108 Q_UNUSED( mapUnitScaleFactor )
1110 QString ogrType =
"3";
1111 if ( mName ==
"square" )
1115 else if ( mName ==
"triangle" )
1119 else if ( mName ==
"star" )
1123 else if ( mName ==
"circle" )
1127 else if ( mName ==
"cross" )
1131 else if ( mName ==
"x" || mName ==
"cross2" )
1135 else if ( mName ==
"line" )
1141 ogrString.append(
"SYMBOL(" );
1142 ogrString.append(
"id:" );
1143 ogrString.append(
'\"' );
1144 ogrString.append(
"ogr-sym-" );
1145 ogrString.append( ogrType );
1146 ogrString.append(
'\"' );
1147 ogrString.append(
",c:" );
1148 ogrString.append(
mColor.name() );
1149 ogrString.append(
",o:" );
1151 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1152 ogrString.append(
')' );
1157 ogrString.append(
"PEN(" );
1158 ogrString.append(
"c:" );
1159 ogrString.append(
mColor.name() );
1160 ogrString.append(
",w:" );
1161 ogrString.append( QString::number(
mSize ) );
1162 ogrString.append(
"mm" );
1163 ogrString.append(
")" );
1171 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1172 if ( graphicElem.isNull() )
1175 QString name = QStringLiteral(
"square" );
1188 double d = angleFunc.toDouble( &ok );
1198 QString uom = element.attribute( QStringLiteral(
"uom" ) );
1224 p->drawPath(
mPath );
1230 Q_UNUSED( mmMapUnitScaleFactor )
1239 if ( hasDataDefinedSize )
1248 size = std::sqrt( size );
1261 double halfSize = size / 2.0;
1278 QColor pc =
mPen.color();
1279 QColor bc =
mBrush.color();
1299 QPointF off( offsetX, offsetY );
1328 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1336 t.scale( halfSize, -halfSize );
1338 polygon = t.map( polygon );
1341 p.reserve( polygon.size() );
1342 for (
int i = 0; i < polygon.size(); i++ )
1347 if (
mBrush.style() != Qt::NoBrush )
1349 if (
mPen.style() != Qt::NoPen )
1350 e.
writePolyline( p, layerName, QStringLiteral(
"CONTINUOUS" ), pc, strokeWidth );
1352 else if ( shape ==
Circle )
1354 shift += QPointF( off.x(), -off.y() );
1355 if (
mBrush.style() != Qt::NoBrush )
1357 if (
mPen.style() != Qt::NoPen )
1358 e.
writeCircle( layerName, pc,
QgsPoint( shift ), halfSize, QStringLiteral(
"CONTINUOUS" ), strokeWidth );
1360 else if ( shape ==
Line )
1362 QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1363 QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1365 if (
mPen.style() != Qt::NoPen )
1368 else if ( shape ==
Cross )
1370 if (
mPen.style() != Qt::NoPen )
1372 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1373 QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1374 QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1375 QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1381 else if ( shape ==
Cross2 )
1383 if (
mPen.style() != Qt::NoPen )
1385 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1386 QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1387 QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1388 QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1396 if (
mPen.style() != Qt::NoPen )
1398 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1399 QPointF pt2 = t.map( QPointF( 0, 0 ) );
1400 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1451 double penWidth = 0.0;
1466 if ( ok && strokeStyle == QLatin1String(
"no" ) )
1475 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1476 penWidth / 2.0, penWidth / 2.0 );
1478 return symbolBounds;
1525 if ( props.contains( QStringLiteral(
"name" ) ) )
1526 name = props[QStringLiteral(
"name" )];
1527 if ( props.contains( QStringLiteral(
"size" ) ) )
1528 size = props[QStringLiteral(
"size" )].toDouble();
1529 if ( props.contains( QStringLiteral(
"angle" ) ) )
1530 angle = props[QStringLiteral(
"angle" )].toDouble();
1531 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1535 if ( props.contains( QStringLiteral(
"offset" ) ) )
1537 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1539 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1541 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1543 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1545 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1549 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1563 return QStringLiteral(
"FilledMarker" );
1588 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1591 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1624 mFill.reset( static_cast<QgsFillSymbol *>( symbol ) );
1647 attr.unite( mFill->usedAttributes( context ) );
1655 if ( mFill && mFill->hasDataDefinedProperties() )
1664 mFill->setColor( c );
1669 return mFill ? mFill->color() :
mColor;
1685 p->setBrush( Qt::red );
1689 p->setBrush( Qt::NoBrush );
1691 p->setPen( Qt::black );
1693 if ( !polygon.isEmpty() )
1699 QPolygonF poly = path.toFillPolygon();
1719 mColor = QColor( 35, 35, 35 );
1720 mStrokeColor = QColor( 35, 35, 35 );
1721 updateDefaultAspectRatio();
1732 if ( props.contains( QStringLiteral(
"name" ) ) )
1733 name = props[QStringLiteral(
"name" )];
1734 if ( props.contains( QStringLiteral(
"size" ) ) )
1735 size = props[QStringLiteral(
"size" )].toDouble();
1736 if ( props.contains( QStringLiteral(
"angle" ) ) )
1737 angle = props[QStringLiteral(
"angle" )].toDouble();
1738 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1744 if ( !props.contains( QStringLiteral(
"fill" ) ) && !props.contains( QStringLiteral(
"color" ) ) && !props.contains( QStringLiteral(
"outline" ) ) &&
1745 !props.contains( QStringLiteral(
"outline_color" ) ) && !props.contains( QStringLiteral(
"outline-width" ) ) && !props.contains( QStringLiteral(
"outline_width" ) ) )
1748 double fillOpacity = 1.0;
1749 double strokeOpacity = 1.0;
1751 bool hasFillParam =
false, hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1752 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1754 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1755 hasStrokeParam, hasDefaultStrokeColor, strokeColor,
1756 hasStrokeWidthParam, hasDefaultStrokeWidth, strokeWidth,
1757 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1758 if ( hasDefaultFillColor )
1762 if ( hasDefaultFillOpacity )
1765 c.setAlphaF( fillOpacity );
1768 if ( hasDefaultStrokeColor )
1772 if ( hasDefaultStrokeWidth )
1776 if ( hasDefaultStrokeOpacity )
1779 c.setAlphaF( strokeOpacity );
1784 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1786 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1788 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
1790 if ( props.contains( QStringLiteral(
"offset" ) ) )
1792 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1794 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1796 if ( props.contains( QStringLiteral(
"fill" ) ) )
1801 else if ( props.contains( QStringLiteral(
"color" ) ) )
1805 if ( props.contains( QStringLiteral(
"outline" ) ) )
1810 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
1814 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
1819 if ( props.contains( QStringLiteral(
"outline-width" ) ) )
1822 m->
setStrokeWidth( props[QStringLiteral(
"outline-width" )].toDouble() );
1824 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
1826 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
1828 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
1830 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
1833 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
1837 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
1841 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1844 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1848 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1862 QgsStringMap::iterator it = properties.find( QStringLiteral(
"name" ) );
1863 if ( it != properties.end() )
1875 QColor defaultFillColor, defaultStrokeColor;
1876 double strokeWidth, fillOpacity, strokeOpacity;
1877 bool hasFillParam =
false, hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1878 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1880 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1881 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
1882 hasStrokeWidthParam, hasDefaultStrokeWidth, strokeWidth,
1883 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1885 double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
1886 double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
1888 if ( hasDefaultFillColor )
1890 defaultFillColor.setAlphaF( newFillOpacity );
1893 if ( hasDefaultFillOpacity )
1896 c.setAlphaF( fillOpacity );
1899 if ( hasDefaultStrokeColor )
1901 defaultStrokeColor.setAlphaF( newStrokeOpacity );
1904 if ( hasDefaultStrokeWidth )
1906 setStrokeWidth( strokeWidth );
1908 if ( hasDefaultStrokeOpacity )
1911 c.setAlphaF( strokeOpacity );
1915 updateDefaultAspectRatio();
1920 if ( mDefaultAspectRatio == 0.0 )
1925 double widthScaleFactor = 3.465;
1928 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
1930 return mDefaultAspectRatio;
1935 bool aPreservedAspectRatio = preservedAspectRatio();
1936 if ( aPreservedAspectRatio && !par )
1938 mFixedAspectRatio = mDefaultAspectRatio;
1940 else if ( !aPreservedAspectRatio && par )
1942 mFixedAspectRatio = 0.0;
1944 return preservedAspectRatio();
1950 return QStringLiteral(
"SvgMarker" );
1970 bool hasDataDefinedSize =
false;
1971 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1975 if ( static_cast< int >( size ) < 1 || 10000.0 < size )
1982 bool hasDataDefinedAspectRatio =
false;
1983 double aspectRatio = calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
1985 QPointF outputOffset;
1989 p->translate( point + outputOffset );
1995 QString path =
mPath;
2003 double strokeWidth = mStrokeWidth;
2025 bool fitsInCache =
true;
2026 bool usePict =
true;
2027 double hwRatio = 1.0;
2033 if ( fitsInCache && img.width() > 1 )
2039 QImage transparentImage = img.copy();
2041 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2042 hwRatio =
static_cast< double >( transparentImage.height() ) / static_cast< double >( transparentImage.width() );
2046 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2047 hwRatio =
static_cast< double >( img.height() ) / static_cast< double >( img.width() );
2052 if ( usePict || !fitsInCache )
2054 p->setOpacity( context.
opacity() );
2058 if ( pct.width() > 1 )
2061 _fixQPictureDPI( p );
2062 p->drawPicture( 0, 0, pct );
2064 hwRatio =
static_cast< double >( pct.height() ) / static_cast< double >( pct.width() );
2072 if ( penWidth > size / 20 )
2075 penWidth = size / 20;
2077 double penOffset = penWidth / 2;
2078 pen.setWidth( penWidth );
2080 p->setBrush( Qt::NoBrush );
2081 double wSize = size + penOffset;
2082 double hSize = size * hwRatio + penOffset;
2083 p->drawRect( QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
2091 p->setRenderHint( QPainter::Antialiasing );
2096 double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const 2098 double scaledSize =
mSize;
2102 if ( hasDataDefinedSize )
2110 if ( hasDataDefinedSize )
2117 if ( hasDataDefinedSize && ok )
2122 scaledSize = std::sqrt( scaledSize );
2135 if ( !hasDataDefinedAspectRatio )
2136 return mFixedAspectRatio;
2141 double scaledAspectRatio = mDefaultAspectRatio;
2142 if ( mFixedAspectRatio > 0.0 )
2143 scaledAspectRatio = mFixedAspectRatio;
2145 double defaultHeight =
mSize * scaledAspectRatio;
2146 scaledAspectRatio = defaultHeight / scaledSize;
2149 double scaledHeight = scaledSize * scaledAspectRatio;
2156 if ( hasDataDefinedAspectRatio && ok )
2161 scaledHeight = sqrt( scaledHeight );
2168 scaledAspectRatio = scaledHeight / scaledSize;
2170 return scaledAspectRatio;
2178 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
2179 offset = QPointF( offsetX, offsetY );
2189 if ( hasDataDefinedRotation )
2215 map[QStringLiteral(
"name" )] =
mPath;
2216 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2219 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number( mFixedAspectRatio );
2220 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2227 map[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
2259 mStrokeWidthUnit = unit;
2265 if ( unit != mStrokeWidthUnit )
2275 mStrokeWidthMapUnitScale = scale;
2282 return mStrokeWidthMapUnitScale;
2290 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2291 element.appendChild( graphicElem );
2301 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2304 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2308 angleFunc = QString::number( angle +
mAngle );
2322 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
2323 if ( graphicElem.isNull() )
2326 QString path, mimeType;
2333 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2336 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2344 double d = angleFunc.toDouble( &ok );
2370 if ( hasDataDefinedSize )
2376 if ( hasDataDefinedSize && ok )
2381 size = std::sqrt( size );
2390 size *= mmMapUnitScaleFactor;
2404 double offsetX = offset.x();
2405 double offsetY = offset.y();
2407 QPointF outputOffset( offsetX, offsetY );
2421 QString path =
mPath;
2429 double strokeWidth = mStrokeWidth;
2455 QSvgRenderer r( svgContent );
2462 QSizeF outSize( r.defaultSize() );
2463 outSize.scale( size, size, Qt::KeepAspectRatio );
2469 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2471 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2473 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2474 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2483 bool hasDataDefinedSize =
false;
2484 double scaledSize =
calculateSize( context, hasDataDefinedSize );
2488 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2493 QPointF outputOffset;
2497 QString path =
mPath;
2505 double strokeWidth = mStrokeWidth;
2532 double scaledHeight = svgViewbox.isValid() ? scaledSize * svgViewbox.height() / svgViewbox.width() : scaledSize;
2537 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2540 transform.rotate( angle );
2543 strokeWidth += 1.0 / 2.0;
2545 QRectF symbolBounds = transform.mapRect( QRectF( -scaledSize / 2.0,
2546 -scaledHeight / 2.0,
2551 symbolBounds.adjust( -strokeWidth / 2.0, -strokeWidth / 2.0,
2552 strokeWidth / 2.0, strokeWidth / 2.0 );
2554 return symbolBounds;
2578 if ( props.contains( QStringLiteral(
"imageFile" ) ) )
2579 path = props[QStringLiteral(
"imageFile" )];
2580 if ( props.contains( QStringLiteral(
"size" ) ) )
2581 size = props[QStringLiteral(
"size" )].toDouble();
2582 if ( props.contains( QStringLiteral(
"angle" ) ) )
2583 angle = props[QStringLiteral(
"angle" )].toDouble();
2584 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
2589 if ( props.contains( QStringLiteral(
"alpha" ) ) )
2591 m->
setOpacity( props[QStringLiteral(
"alpha" )].toDouble() );
2594 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2596 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2598 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
2601 if ( props.contains( QStringLiteral(
"offset" ) ) )
2603 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2605 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2608 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2612 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
2625 QgsStringMap::iterator it = properties.find( QStringLiteral(
"name" ) );
2626 if ( it != properties.end() )
2644 if ( aPreservedAspectRatio && !par )
2648 else if ( !aPreservedAspectRatio && par )
2660 mDefaultAspectRatio = ( !size.isNull() && size.isValid() && size.width() > 0 ) ? static_cast< double >( size.height() ) / static_cast< double >( size.width() ) : 0.0;
2667 return QStringLiteral(
"RasterMarker" );
2676 bool hasDataDefinedSize =
false;
2677 double scaledSize = calculateSize( context, hasDataDefinedSize );
2679 bool hasDataDefinedAspectRatio =
false;
2684 if ( static_cast< int >( width ) < 1 || 10000.0 < width )
2689 QString path =
mPath;
2697 if ( !size.isNull() && size.isValid() && size.width() > 0 )
2699 height = width * (
static_cast< double >( size.height() ) / static_cast< double >( size.width() ) );
2704 if ( path.isEmpty() )
2709 QPointF outputOffset;
2711 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset, angle );
2713 p->translate( point + outputOffset );
2729 if ( !img.isNull() )
2734 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2740 double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const 2742 double scaledSize =
mSize;
2746 if ( hasDataDefinedSize )
2754 if ( hasDataDefinedSize )
2761 if ( hasDataDefinedSize && ok )
2766 scaledSize = std::sqrt( scaledSize );
2779 if ( !hasDataDefinedAspectRatio )
2789 double defaultHeight =
mSize * scaledAspectRatio;
2790 scaledAspectRatio = defaultHeight / scaledSize;
2793 double scaledHeight = scaledSize * scaledAspectRatio;
2800 if ( hasDataDefinedAspectRatio && ok )
2805 scaledHeight = sqrt( scaledHeight );
2812 scaledAspectRatio = scaledHeight / scaledSize;
2814 return scaledAspectRatio;
2817 void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const 2822 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2823 offset = QPointF( offsetX, offsetY );
2833 if ( hasDataDefinedRotation )
2854 map[QStringLiteral(
"imageFile" )] =
mPath;
2855 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2858 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2859 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2860 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
2899 bool hasDataDefinedSize =
false;
2900 double scaledSize = calculateSize( context, hasDataDefinedSize );
2902 bool hasDataDefinedAspectRatio =
false;
2907 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2912 QPointF outputOffset;
2914 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset, angle );
2919 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2922 transform.rotate( angle );
2924 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
2929 return symbolBounds;
2936 mFontFamily = fontFamily;
2941 mOrigSize = pointSize;
2953 delete mFontMetrics;
2964 if ( props.contains( QStringLiteral(
"font" ) ) )
2965 fontFamily = props[QStringLiteral(
"font" )];
2966 if ( props.contains( QStringLiteral(
"chr" ) ) && props[QStringLiteral(
"chr" )].length() > 0 )
2967 string = props[QStringLiteral(
"chr" )];
2968 if ( props.contains( QStringLiteral(
"size" ) ) )
2969 pointSize = props[QStringLiteral(
"size" )].toDouble();
2970 if ( props.contains( QStringLiteral(
"color" ) ) )
2972 if ( props.contains( QStringLiteral(
"angle" ) ) )
2973 angle = props[QStringLiteral(
"angle" )].toDouble();
2977 if ( props.contains( QStringLiteral(
"outline_color" ) ) )
2979 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
2980 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
2981 if ( props.contains( QStringLiteral(
"offset" ) ) )
2983 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2985 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2987 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2989 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2991 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
2993 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2995 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
2997 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2999 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3009 return QStringLiteral(
"FontMarker" );
3014 QColor brushColor =
mColor;
3015 QColor penColor = mStrokeColor;
3017 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3018 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3020 mBrush = QBrush( brushColor );
3021 mPen = QPen( penColor );
3022 mPen.setJoinStyle( mPenJoinStyle );
3025 mFont = QFont( mFontFamily );
3030 mFont.setPixelSize( std::max( 2, static_cast< int >( std::round( sizePixels ) ) ) );
3031 delete mFontMetrics;
3032 mFontMetrics =
new QFontMetrics( mFont );
3033 mChrWidth = mFontMetrics->width( mString );
3034 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3039 if ( mUseCachedPath )
3041 QPointF chrOffset = mChrOffset;
3043 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3044 mCachedPath = QPainterPath();
3045 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3054 QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3056 charOffset = mChrOffset;
3057 QString stringToRender = mString;
3062 if ( stringToRender != mString )
3064 charWidth = mFontMetrics->width( stringToRender );
3065 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3068 return stringToRender;
3073 bool &hasDataDefinedRotation,
3075 double &angle )
const 3080 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3081 offset = QPointF( offsetX, offsetY );
3086 bool usingDataDefinedRotation =
false;
3091 usingDataDefinedRotation = ok;
3095 if ( hasDataDefinedRotation )
3119 double scaledSize =
mSize;
3123 if ( hasDataDefinedSize )
3129 if ( hasDataDefinedSize && ok )
3134 scaledSize = std::sqrt( scaledSize );
3146 if ( !p || !mNonZeroFontSize )
3149 QTransform transform;
3152 QColor brushColor =
mColor;
3159 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3160 mBrush.setColor( brushColor );
3162 QColor penColor = mStrokeColor;
3168 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3192 p->setBrush( mBrush );
3195 mPen.setColor( penColor );
3196 mPen.setWidthF( penWidth );
3201 p->setPen( Qt::NoPen );
3204 QPointF chrOffset = mChrOffset;
3206 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3208 double sizeToRender = calculateSize( context );
3210 bool hasDataDefinedRotation =
false;
3213 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation, offset, angle );
3215 p->translate( point.x() + offset.x(), point.y() + offset.y() );
3218 transform.rotate( angle );
3222 double s = sizeToRender / mOrigSize;
3223 transform.scale( s, s );
3226 if ( mUseCachedPath )
3228 p->drawPath( transform.map( mCachedPath ) );
3233 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3234 p->drawPath( transform.map( path ) );
3243 props[QStringLiteral(
"font" )] = mFontFamily;
3244 props[QStringLiteral(
"chr" )] = mString;
3245 props[QStringLiteral(
"size" )] = QString::number(
mSize );
3250 props[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
3254 props[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3286 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3287 element.appendChild( graphicElem );
3289 QString fontPath = QStringLiteral(
"ttf://%1" ).arg( mFontFamily );
3290 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
3297 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3300 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
3304 angleFunc = QString::number( angle +
mAngle );
3315 QPointF chrOffset = mChrOffset;
3316 double chrWidth = mChrWidth;
3318 ( void )characterToRender( context, chrOffset, chrWidth );
3320 if ( !mFontMetrics )
3321 mFontMetrics =
new QFontMetrics( mFont );
3323 double scaledSize = calculateSize( context );
3326 chrWidth *= scaledSize / mOrigSize;
3329 bool hasDataDefinedRotation =
false;
3332 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
3338 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
3341 transform.rotate( angle );
3343 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
3347 return symbolBounds;
3354 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
3355 if ( graphicElem.isNull() )
3358 QString name, format;
3366 if ( !name.startsWith( QLatin1String(
"ttf://" ) ) || format != QLatin1String(
"ttf" ) )
3369 QString fontFamily = name.mid( 6 );
3376 double d = angleFunc.toDouble( &ok );
3384 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)
#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.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
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.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false)
Gets SVG as QImage.
Right facing filled arrow head.
Right facing arrow head (unfilled, lines only)
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an svg file contains parameters for fill, stroke color, stroke width.
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.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false)
Gets SVG content.
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.
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false)
Calculates the viewbox size of a (possibly cached) SVG file.
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.
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.
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
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.
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.
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.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
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...
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
QPicture svgAsPicture(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool forceVectorOutput=false, double fixedAspectRatio=0, bool blocking=false)
Gets SVG as QPicture&.
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.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false)
Returns the specified path rendered as an image.
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)
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...