39#include <QDomDocument>
42#include <QMimeDatabase>
46#include <QSvgRenderer>
49using namespace Qt::StringLiterals;
51static constexpr int MAX_FONT_CHARACTER_SIZE_IN_PIXELS = 500;
62 QList< Qgis::MarkerShape > shapes;
177 QTransform transform;
180 if ( !hasDataDefinedSize )
190 const double half = scaledSize / 2.0;
191 transform.scale( half, half );
197 transform.rotate(
mAngle );
224 bool hasDataDefinedSize =
false;
225 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
227 bool hasDataDefinedRotation =
false;
233 bool createdNewPath =
false;
251 createdNewPath =
true;
260 QTransform transform;
263 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
266 if ( hasDataDefinedSize || createdNewPath )
275 const double half = s / 2.0;
276 transform.scale( half, half );
281 transform.rotate(
angle );
290 polygon = transform.map(
mPolygon );
294 path = transform.map(
mPath );
296 draw( context, symbol, polygon, path );
301 bool hasDataDefinedSize =
false;
302 double scaledSize =
calculateSize( context, hasDataDefinedSize );
304 bool hasDataDefinedRotation =
false;
311 QTransform transform;
314 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
317 transform.rotate(
angle );
319 return transform.mapRect( QRectF( -scaledSize / 2.0,
329 const QString cleaned = name.toLower().trimmed();
331 if ( cleaned ==
"square"_L1 || cleaned ==
"rectangle"_L1 )
333 else if ( cleaned ==
"trapezoid"_L1 )
335 else if ( cleaned ==
"parallelogram_right"_L1 )
337 else if ( cleaned ==
"parallelogram_left"_L1 )
339 else if ( cleaned ==
"square_with_corners"_L1 )
341 else if ( cleaned ==
"rounded_square"_L1 )
343 else if ( cleaned ==
"diamond"_L1 )
345 else if ( cleaned ==
"shield"_L1 )
347 else if ( cleaned ==
"pentagon"_L1 )
349 else if ( cleaned ==
"hexagon"_L1 )
351 else if ( cleaned ==
"octagon"_L1 )
353 else if ( cleaned ==
"decagon"_L1 )
355 else if ( cleaned ==
"triangle"_L1 )
357 else if ( cleaned ==
"equilateral_triangle"_L1 )
359 else if ( cleaned ==
"star_diamond"_L1 )
361 else if ( cleaned ==
"star"_L1 || cleaned ==
"regular_star"_L1 )
363 else if ( cleaned ==
"heart"_L1 )
365 else if ( cleaned ==
"arrow"_L1 )
367 else if ( cleaned ==
"circle"_L1 )
369 else if ( cleaned ==
"cross"_L1 )
371 else if ( cleaned ==
"cross_fill"_L1 )
373 else if ( cleaned ==
"cross2"_L1 || cleaned ==
"x"_L1 )
375 else if ( cleaned ==
"line"_L1 )
377 else if ( cleaned ==
"arrowhead"_L1 )
379 else if ( cleaned ==
"filled_arrowhead"_L1 )
381 else if ( cleaned ==
"semi_circle"_L1 )
383 else if ( cleaned ==
"third_circle"_L1 )
385 else if ( cleaned ==
"quarter_circle"_L1 )
387 else if ( cleaned ==
"quarter_square"_L1 )
389 else if ( cleaned ==
"half_square"_L1 )
391 else if ( cleaned ==
"diagonal_half_square"_L1 )
393 else if ( cleaned ==
"right_half_triangle"_L1 )
395 else if ( cleaned ==
"left_half_triangle"_L1 )
397 else if ( cleaned ==
"asterisk_fill"_L1 )
399 else if ( cleaned ==
"half_arc"_L1 )
401 else if ( cleaned ==
"third_arc"_L1 )
403 else if ( cleaned ==
"quarter_arc"_L1 )
418 return u
"quarter_square"_s;
420 return u
"half_square"_s;
422 return u
"diagonal_half_square"_s;
424 return u
"parallelogram_right"_s;
426 return u
"parallelogram_left"_s;
428 return u
"trapezoid"_s;
434 return u
"pentagon"_s;
442 return u
"square_with_corners"_s;
444 return u
"rounded_square"_s;
446 return u
"triangle"_s;
448 return u
"equilateral_triangle"_s;
450 return u
"left_half_triangle"_s;
452 return u
"right_half_triangle"_s;
454 return u
"star_diamond"_s;
462 return u
"filled_arrowhead"_s;
464 return u
"cross_fill"_s;
474 return u
"arrowhead"_s;
476 return u
"semi_circle"_s;
478 return u
"third_circle"_s;
480 return u
"quarter_circle"_s;
482 return u
"asterisk_fill"_s;
484 return u
"half_arc"_s;
486 return u
"third_arc"_s;
488 return u
"quarter_arc"_s;
505 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
510 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 0.6072;
512 polygon << QPointF( - VERTEX_OFFSET_FROM_ORIGIN, 1 )
513 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
514 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
515 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
516 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
517 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
518 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
519 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
520 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
525 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 0 ) ) );
529 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 1 ) ) );
533 polygon << QPointF( -1, -1 ) << QPointF( 1, 1 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
537 polygon << QPointF( 0.5, -0.5 )
539 << QPointF( -1, 0.5 )
540 << QPointF( -0.5, -0.5 )
541 << QPointF( 0.5, -0.5 );
545 polygon << QPointF( 0.5, 0.5 )
546 << QPointF( 1, -0.5 )
547 << QPointF( -0.5, -0.5 )
548 << QPointF( -1, 0.5 )
549 << QPointF( 0.5, 0.5 );
553 polygon << QPointF( 1, 0.5 )
554 << QPointF( 0.5, -0.5 )
555 << QPointF( -1, -0.5 )
556 << QPointF( -0.5, 0.5 )
557 << QPointF( 1, 0.5 );
561 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
562 << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
566 polygon << QPointF( 1, 0.5 )
569 << QPointF( -1, 0.5 )
571 << QPointF( 1, 0.5 );
581 polygon << QPointF( -0.9511, -0.3090 )
582 << QPointF( -0.5878, 0.8090 )
583 << QPointF( 0.5878, 0.8090 )
584 << QPointF( 0.9511, -0.3090 )
586 << QPointF( -0.9511, -0.3090 );
597 polygon << QPointF( -0.8660, -0.5 )
598 << QPointF( -0.8660, 0.5 )
600 << QPointF( 0.8660, 0.5 )
601 << QPointF( 0.8660, -0.5 )
603 << QPointF( -0.8660, -0.5 );
608 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 1.0 / ( 1 + M_SQRT2 );
610 polygon << QPointF( - VERTEX_OFFSET_FROM_ORIGIN, 1 )
611 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
612 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
613 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
614 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
615 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
616 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
617 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
618 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
625 polygon << QPointF( 0.587785252, 0.809016994 )
626 << QPointF( 0.951056516, 0.309016994 )
627 << QPointF( 0.951056516, -0.309016994 )
628 << QPointF( 0.587785252, -0.809016994 )
630 << QPointF( -0.587785252, -0.809016994 )
631 << QPointF( -0.951056516, -0.309016994 )
632 << QPointF( -0.951056516, 0.309016994 )
633 << QPointF( -0.587785252, 0.809016994 )
635 << QPointF( 0.587785252, 0.809016994 );
640 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
648 polygon << QPointF( -0.8660, 0.5 )
649 << QPointF( 0.8660, 0.5 )
651 << QPointF( -0.8660, 0.5 );
655 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
659 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
664 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
666 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 315.0 ) ), - inner_r * std::cos(
DEG2RAD( 315.0 ) ) )
667 << QPointF( std::sin(
DEG2RAD( 270 ) ), - std::cos(
DEG2RAD( 270 ) ) )
668 << QPointF( inner_r * std::sin(
DEG2RAD( 225.0 ) ), - inner_r * std::cos(
DEG2RAD( 225.0 ) ) )
669 << QPointF( std::sin(
DEG2RAD( 180 ) ), - std::cos(
DEG2RAD( 180 ) ) )
670 << QPointF( inner_r * std::sin(
DEG2RAD( 135.0 ) ), - inner_r * std::cos(
DEG2RAD( 135.0 ) ) )
671 << QPointF( std::sin(
DEG2RAD( 90 ) ), - std::cos(
DEG2RAD( 90 ) ) )
672 << QPointF( inner_r * std::sin(
DEG2RAD( 45.0 ) ), - inner_r * std::cos(
DEG2RAD( 45.0 ) ) )
673 << QPointF( std::sin(
DEG2RAD( 0 ) ), - std::cos(
DEG2RAD( 0 ) ) )
674 << QPointF( inner_r * std::sin(
DEG2RAD( 315.0 ) ), - inner_r * std::cos(
DEG2RAD( 315.0 ) ) );
680 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
682 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
683 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), - std::cos(
DEG2RAD( 288 ) ) )
684 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), - inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
685 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), - std::cos(
DEG2RAD( 216.0 ) ) )
686 << QPointF( 0, inner_r )
687 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), - std::cos(
DEG2RAD( 144.0 ) ) )
688 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), - inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
689 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), - std::cos(
DEG2RAD( 72.0 ) ) )
690 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), - inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
692 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
697 polygon << QPointF( 0, -1 )
698 << QPointF( 0.5, -0.5 )
699 << QPointF( 0.25, -0.5 )
700 << QPointF( 0.25, 1 )
701 << QPointF( -0.25, 1 )
702 << QPointF( -0.25, -0.5 )
703 << QPointF( -0.5, -0.5 )
708 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
712 polygon << QPointF( -1, -0.2 )
713 << QPointF( -1, -0.2 )
714 << QPointF( -1, 0.2 )
715 << QPointF( -0.2, 0.2 )
716 << QPointF( -0.2, 1 )
718 << QPointF( 0.2, 0.2 )
720 << QPointF( 1, -0.2 )
721 << QPointF( 0.2, -0.2 )
722 << QPointF( 0.2, -1 )
723 << QPointF( -0.2, -1 )
724 << QPointF( -0.2, -0.2 )
725 << QPointF( -1, -0.2 );
730 static constexpr double THICKNESS = 0.3;
731 static constexpr double HALF_THICKNESS = THICKNESS / 2.0;
732 static constexpr double INTERSECTION_POINT = THICKNESS / M_SQRT2;
733 static constexpr double DIAGONAL1 = M_SQRT1_2 - INTERSECTION_POINT * 0.5;
734 static constexpr double DIAGONAL2 = M_SQRT1_2 + INTERSECTION_POINT * 0.5;
736 polygon << QPointF( -HALF_THICKNESS, -1 )
737 << QPointF( HALF_THICKNESS, -1 )
738 << QPointF( HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
739 << QPointF( DIAGONAL1, -DIAGONAL2 )
740 << QPointF( DIAGONAL2, -DIAGONAL1 )
741 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, -HALF_THICKNESS )
742 << QPointF( 1, -HALF_THICKNESS )
743 << QPointF( 1, HALF_THICKNESS )
744 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, HALF_THICKNESS )
745 << QPointF( DIAGONAL2, DIAGONAL1 )
746 << QPointF( DIAGONAL1, DIAGONAL2 )
747 << QPointF( HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
748 << QPointF( HALF_THICKNESS, 1 )
749 << QPointF( -HALF_THICKNESS, 1 )
750 << QPointF( -HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
751 << QPointF( -DIAGONAL1, DIAGONAL2 )
752 << QPointF( -DIAGONAL2, DIAGONAL1 )
753 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, HALF_THICKNESS )
754 << QPointF( -1, HALF_THICKNESS )
755 << QPointF( -1, -HALF_THICKNESS )
756 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, -HALF_THICKNESS )
757 << QPointF( -DIAGONAL2, -DIAGONAL1 )
758 << QPointF( -DIAGONAL1, -DIAGONAL2 )
759 << QPointF( -HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
760 << QPointF( -HALF_THICKNESS, -1 );
785 mPath = QPainterPath();
791 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
795 mPath.moveTo( -1, -1 );
796 mPath.addRoundedRect( -1, -1, 2, 2, 0.25, 0.25 );
800 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
801 mPath.lineTo( 0, 0 );
805 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
806 mPath.lineTo( 0, 0 );
810 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
811 mPath.lineTo( 0, 0 );
815 mPath.moveTo( 1, 0 );
816 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
820 mPath.moveTo( 0, -1 );
821 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
825 mPath.moveTo( 0, -1 );
826 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
830 mPath.moveTo( -1, 0 );
831 mPath.lineTo( 1, 0 );
832 mPath.moveTo( 0, -1 );
833 mPath.lineTo( 0, 1 );
837 mPath.moveTo( -1, -1 );
838 mPath.lineTo( 1, 1 );
839 mPath.moveTo( 1, -1 );
840 mPath.lineTo( -1, 1 );
844 mPath.moveTo( 0, -1 );
845 mPath.lineTo( 0, 1 );
849 mPath.moveTo( -1, -1 );
850 mPath.lineTo( 0, 0 );
851 mPath.lineTo( -1, 1 );
855 mPath.moveTo( 0, 0.75 );
856 mPath.arcTo( 0, -1, 1, 1, -45, 210 );
857 mPath.arcTo( -1, -1, 1, 1, 15, 210 );
858 mPath.lineTo( 0, 0.75 );
892 double scaledSize =
mSize;
896 if ( hasDataDefinedSize )
903 if ( hasDataDefinedSize && ok )
908 scaledSize = std::sqrt( scaledSize );
923 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
924 offset = QPointF( offsetX, offsetY );
926 hasDataDefinedRotation =
false;
939 hasDataDefinedRotation =
true;
944 if ( hasDataDefinedRotation )
991 if ( props.contains( u
"name"_s ) )
995 if ( props.contains( u
"color"_s ) )
997 if ( props.contains( u
"color_border"_s ) )
1002 else if ( props.contains( u
"outline_color"_s ) )
1006 else if ( props.contains( u
"line_color"_s ) )
1010 if ( props.contains( u
"joinstyle"_s ) )
1014 if ( props.contains( u
"size"_s ) )
1015 size = props[u
"size"_s].toDouble();
1016 if ( props.contains( u
"angle"_s ) )
1017 angle = props[u
"angle"_s].toDouble();
1018 if ( props.contains( u
"scale_method"_s ) )
1022 if ( props.contains( u
"offset"_s ) )
1024 if ( props.contains( u
"offset_unit"_s ) )
1026 if ( props.contains( u
"offset_map_unit_scale"_s ) )
1028 if ( props.contains( u
"size_unit"_s ) )
1030 if ( props.contains( u
"size_map_unit_scale"_s ) )
1033 if ( props.contains( u
"outline_style"_s ) )
1037 else if ( props.contains( u
"line_style"_s ) )
1041 if ( props.contains( u
"outline_width"_s ) )
1045 else if ( props.contains( u
"line_width"_s ) )
1049 if ( props.contains( u
"outline_width_unit"_s ) )
1053 if ( props.contains( u
"line_width_unit"_s ) )
1057 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
1062 if ( props.contains( u
"horizontal_anchor_point"_s ) )
1066 if ( props.contains( u
"vertical_anchor_point"_s ) )
1071 if ( props.contains( u
"cap_style"_s ) )
1084 return u
"SimpleMarker"_s;
1096 QColor brushColor =
mColor;
1099 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
1102 mBrush = QBrush( brushColor );
1103 mPen = QPen( penColor );
1113 selBrushColor.setAlphaF( context.
opacity() );
1114 selPenColor.setAlphaF( context.
opacity() );
1117 mSelPen = QPen( selPenColor );
1133 mCachedOpacity = context.
opacity();
1139 mSelPen.setColor( selBrushColor );
1172 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
1175 const double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
1176 const int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
1177 const double center = imageSize / 2.0;
1183 mCache = QImage( QSize( imageSize * deviceRatio,
1184 imageSize * deviceRatio ), QImage::Format_ARGB32_Premultiplied );
1194 p.setRenderHint( QPainter::Antialiasing );
1195 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1197 p.translate( QPointF( center, center ) );
1205 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
1209 p.setRenderHint( QPainter::Antialiasing );
1210 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
1212 p.translate( QPointF( center, center ) );
1223 p.setRenderHint( QPainter::Antialiasing );
1224 p.fillRect( 0, 0, imageSize, imageSize, selColor );
1225 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1227 p.translate( QPointF( center, center ) );
1246 QColor brushColor =
mColor;
1247 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
1248 mBrush.setColor( brushColor );
1251 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
1252 mPen.setColor( penColor );
1261 c.setAlphaF(
c.alphaF() * context.
opacity() );
1271 c.setAlphaF(
c.alphaF() * context.
opacity() );
1324 p->setBrush( Qt::NoBrush );
1328 if ( !polygon.isEmpty() )
1329 p->drawPolygon( polygon );
1331 p->drawPath( path );
1349 const double s = img.width() / img.devicePixelRatioF();
1351 bool hasDataDefinedSize =
false;
1352 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
1354 bool hasDataDefinedRotation =
false;
1359 p->drawImage( QRectF( point.x() - s / 2.0 +
offset.x(),
1360 point.y() - s / 2.0 +
offset.y(),
1375 map[u
"size"_s] = QString::number(
mSize );
1378 map[u
"angle"_s] = QString::number(
mAngle );
1384 map[u
"outline_width"_s] = QString::number(
mStrokeWidth );
1390 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
1418 toSld( doc, element, context );
1436 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
1437 element.appendChild( graphicElem );
1454 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
1457 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
1475 Q_UNUSED( mmScaleFactor )
1476 Q_UNUSED( mapUnitScaleFactor )
1478 QString ogrType =
"3";
1479 if ( mName ==
"square" )
1483 else if ( mName ==
"triangle" )
1487 else if ( mName ==
"star" )
1491 else if ( mName ==
"circle" )
1495 else if ( mName ==
"cross" )
1499 else if ( mName ==
"x" || mName ==
"cross2" )
1503 else if ( mName ==
"line" )
1509 ogrString.append(
"SYMBOL(" );
1510 ogrString.append(
"id:" );
1511 ogrString.append(
'\"' );
1512 ogrString.append(
"ogr-sym-" );
1513 ogrString.append( ogrType );
1514 ogrString.append(
'\"' );
1515 ogrString.append(
",c:" );
1516 ogrString.append(
mColor.name() );
1517 ogrString.append(
",o:" );
1519 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1520 ogrString.append(
')' );
1525 ogrString.append(
"PEN(" );
1526 ogrString.append(
"c:" );
1527 ogrString.append(
mColor.name() );
1528 ogrString.append(
",w:" );
1529 ogrString.append( QString::number(
mSize ) );
1530 ogrString.append(
"mm" );
1531 ogrString.append(
")" );
1539 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
1540 if ( graphicElem.isNull() )
1543 QString name = u
"square"_s;
1556 const double d = angleFunc.toDouble( &ok );
1566 double scaleFactor = 1.0;
1567 const QString uom = element.attribute( u
"uom"_s );
1594 p->drawPath(
mPath );
1607 if ( hasDataDefinedSize )
1626 size *= mmMapUnitScaleFactor;
1633 const double halfSize =
size / 2.0;
1650 QColor pc =
mPen.color();
1651 QColor bc =
mBrush.color();
1671 QPointF off( offsetX, offsetY );
1700 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1708 t.scale( halfSize, -halfSize );
1710 polygon = t.map( polygon );
1713 p.reserve( polygon.size() );
1714 for (
int i = 0; i < polygon.size(); i++ )
1719 if (
mBrush.style() != Qt::NoBrush )
1721 if (
mPen.style() != Qt::NoPen )
1726 shift += QPointF( off.x(), -off.y() );
1727 if (
mBrush.style() != Qt::NoBrush )
1729 if (
mPen.style() != Qt::NoPen )
1734 const QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1735 const QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1737 if (
mPen.style() != Qt::NoPen )
1742 if (
mPen.style() != Qt::NoPen )
1744 const QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1745 const QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1746 const QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1747 const QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1755 if (
mPen.style() != Qt::NoPen )
1757 const QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1758 const QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1759 const QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1760 const QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1768 if (
mPen.style() != Qt::NoPen )
1770 const QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1771 const QPointF pt2 = t.map( QPointF( 0, 0 ) );
1772 const QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1858 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1859 penWidth / 2.0, penWidth / 2.0 );
1861 return symbolBounds;
1910 if ( props.contains( u
"name"_s ) )
1911 name = props[u
"name"_s].toString();
1912 if ( props.contains( u
"size"_s ) )
1913 size = props[u
"size"_s].toDouble();
1914 if ( props.contains( u
"angle"_s ) )
1915 angle = props[u
"angle"_s].toDouble();
1916 if ( props.contains( u
"scale_method"_s ) )
1920 if ( props.contains( u
"offset"_s ) )
1922 if ( props.contains( u
"offset_unit"_s ) )
1924 if ( props.contains( u
"offset_map_unit_scale"_s ) )
1926 if ( props.contains( u
"size_unit"_s ) )
1928 if ( props.contains( u
"size_map_unit_scale"_s ) )
1930 if ( props.contains( u
"horizontal_anchor_point"_s ) )
1934 if ( props.contains( u
"vertical_anchor_point"_s ) )
1948 return u
"FilledMarker"_s;
1988 map[u
"size"_s] = QString::number(
mSize );
1991 map[u
"angle"_s] = QString::number(
mAngle );
1997 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
2047 attr.unite( mFill->usedAttributes( context ) );
2055 if ( mFill && mFill->hasDataDefinedProperties() )
2064 mFill->setColor(
c );
2069 return mFill ? mFill->color() :
mColor;
2076 || ( mFill && mFill->usesMapUnits() );
2083 mFill->setOutputUnit( unit );
2097 const double prevOpacity = mFill->opacity();
2098 mFill->setOpacity( mFill->opacity() * context.
opacity() );
2102 p->setBrush( Qt::red );
2106 p->setBrush( Qt::NoBrush );
2108 p->setPen( Qt::black );
2114 if ( !polygon.isEmpty() )
2116 mFill->renderPolygon( polygon,
nullptr, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2120 const QPolygonF poly = path.toFillPolygon();
2121 mFill->renderPolygon( poly,
nullptr, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2126 mFill->setOpacity( prevOpacity );
2141 mColor = QColor( 35, 35, 35 );
2169 if ( props.contains( u
"name"_s ) )
2170 name = props[u
"name"_s].toString();
2171 if ( props.contains( u
"size"_s ) )
2172 size = props[u
"size"_s].toDouble();
2173 if ( props.contains( u
"angle"_s ) )
2174 angle = props[u
"angle"_s].toDouble();
2175 if ( props.contains( u
"scale_method"_s ) )
2180 if ( props.contains( u
"size_unit"_s ) )
2182 if ( props.contains( u
"size_map_unit_scale"_s ) )
2184 if ( props.contains( u
"fixedAspectRatio"_s ) )
2186 if ( props.contains( u
"offset"_s ) )
2188 if ( props.contains( u
"offset_unit"_s ) )
2190 if ( props.contains( u
"offset_map_unit_scale"_s ) )
2192 if ( props.contains( u
"fill"_s ) )
2197 else if ( props.contains( u
"color"_s ) )
2201 if ( props.contains( u
"outline"_s ) )
2206 else if ( props.contains( u
"outline_color"_s ) )
2210 else if ( props.contains( u
"line_color"_s ) )
2215 if ( props.contains( u
"outline-width"_s ) )
2220 else if ( props.contains( u
"outline_width"_s ) )
2224 else if ( props.contains( u
"line_width"_s ) )
2229 if ( props.contains( u
"outline_width_unit"_s ) )
2233 else if ( props.contains( u
"line_width_unit"_s ) )
2237 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
2240 if ( props.contains( u
"horizontal_anchor_point"_s ) )
2244 if ( props.contains( u
"vertical_anchor_point"_s ) )
2253 if ( props.contains( u
"parameters"_s ) )
2255 const QVariantMap
parameters = props[u
"parameters"_s].toMap();
2264 const QVariantMap::iterator it =
properties.find( u
"name"_s );
2283 QColor defaultFillColor, defaultStrokeColor;
2285 bool hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
2286 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
2288 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
2289 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2290 hasStrokeWidthParam, hasDefaultStrokeWidth,
strokeWidth,
2291 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
2293 const double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
2294 const double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
2296 if ( hasDefaultFillColor )
2298 defaultFillColor.setAlphaF( newFillOpacity );
2301 if ( hasDefaultFillOpacity )
2304 c.setAlphaF( fillOpacity );
2307 if ( hasDefaultStrokeColor )
2309 defaultStrokeColor.setAlphaF( newStrokeOpacity );
2312 if ( hasDefaultStrokeWidth )
2316 if ( hasDefaultStrokeOpacity )
2319 c.setAlphaF( strokeOpacity );
2333 const double widthScaleFactor = 3.465;
2336 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
2344 if ( aPreservedAspectRatio && !par )
2348 else if ( !aPreservedAspectRatio && par )
2363 return u
"SvgMarker"_s;
2388 bool hasDataDefinedSize =
false;
2389 const double scaledWidth = calculateSize( context, hasDataDefinedSize );
2394 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
2401 bool hasDataDefinedAspectRatio =
false;
2402 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2446 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2450 QPointF outputOffset;
2452 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2454 p->translate( point + outputOffset );
2460 bool fitsInCache =
true;
2461 bool usePict =
true;
2463 if ( ( !context.
forceVectorRendering() && !rotated ) || ( useSelectedColor && rasterizeSelected ) )
2468 if ( fitsInCache && img.width() > 1 )
2472 if ( useSelectedColor )
2480 QImage transparentImage = img.copy();
2482 if ( devicePixelRatio == 1 )
2484 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2488 p->drawImage( QRectF( -transparentImage.width() / 2.0 / devicePixelRatio, -transparentImage.height() / 2.0 / devicePixelRatio,
2489 transparentImage.width() / devicePixelRatio, transparentImage.height() / devicePixelRatio
2490 ), transparentImage );
2495 if ( devicePixelRatio == 1 )
2497 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2501 p->drawImage( QRectF( -img.width() / 2.0 / devicePixelRatio, -img.height() / 2.0 / devicePixelRatio,
2502 img.width() / devicePixelRatio, img.height() / devicePixelRatio ), img );
2508 if ( usePict || !fitsInCache )
2510 p->setOpacity( context.
opacity() );
2514 if ( pct.width() > 1 )
2524double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2526 double scaledSize =
mSize;
2530 if ( hasDataDefinedSize )
2538 if ( hasDataDefinedSize )
2545 if ( hasDataDefinedSize && ok )
2550 scaledSize = std::sqrt( scaledSize );
2563 if ( !hasDataDefinedAspectRatio )
2573 const double defaultHeight =
mSize * scaledAspectRatio;
2574 scaledAspectRatio = defaultHeight / scaledSize;
2577 double scaledHeight = scaledSize * scaledAspectRatio;
2584 if ( hasDataDefinedAspectRatio && ok )
2589 scaledHeight = sqrt( scaledHeight );
2596 scaledAspectRatio = scaledHeight / scaledSize;
2598 return scaledAspectRatio;
2601void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const
2606 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2607 offset = QPointF( offsetX, offsetY );
2617 if ( hasDataDefinedRotation )
2624 const QgsFeature *f = context.
feature();
2643 map[u
"name"_s] =
mPath;
2644 map[u
"size"_s] = QString::number(
mSize );
2648 map[u
"angle"_s] = QString::number(
mAngle );
2655 map[u
"outline_width"_s] = QString::number(
mStrokeWidth );
2659 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
2682 toSld( doc, element, context );
2731 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
2732 element.appendChild( graphicElem );
2743 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
2746 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
2765 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
2766 if ( graphicElem.isNull() )
2769 QString
path, mimeType;
2777 double scaleFactor = 1.0;
2778 const QString uom = element.attribute( u
"uom"_s );
2782 if ( mimeType !=
"image/svg+xml"_L1 )
2790 const double d = angleFunc.toDouble( &ok );
2799 QString realPath {
path };
2800 QUrl svgUrl {
path };
2803 QUrlQuery queryString;
2805 if ( svgUrl.hasQuery() && svgUrl.hasFragment() )
2807 const QString queryPart {
path.mid(
path.indexOf(
'?' ) + 1 ) };
2808 queryString.setQuery( queryPart );
2812 if ( svgUrl.scheme().isEmpty() || svgUrl.isLocalFile() )
2814 svgUrl.setQuery( QString() );
2815 realPath = svgUrl.path();
2820 QMap<QString, QgsProperty> params;
2824 if ( queryString.hasQueryItem( u
"fill"_s ) )
2826 const QColor
fillColor { queryString.queryItemValue( u
"fill"_s ) };
2830 if ( queryString.hasQueryItem( u
"fill-opacity"_s ) )
2832 const double alpha { queryString.queryItemValue( u
"fill-opacity"_s ).toDouble( &ok ) };
2839 if ( queryString.hasQueryItem( u
"outline"_s ) )
2841 const QColor
strokeColor { queryString.queryItemValue( u
"outline"_s ) };
2845 if ( queryString.hasQueryItem( u
"outline-opacity"_s ) )
2847 const double alpha { queryString.queryItemValue( u
"outline-opacity"_s ).toDouble( &ok ) };
2854 if ( queryString.hasQueryItem( u
"outline-width"_s ) )
2856 const int width { queryString.queryItemValue( u
"outline-width"_s ).toInt( &ok )};
2863 if ( ! params.isEmpty() )
2882 if ( hasDataDefinedSize )
2888 if ( hasDataDefinedSize && ok )
2902 size *= mmMapUnitScaleFactor;
2916 const double offsetX =
offset.x();
2917 const double offsetY =
offset.y();
2919 QPointF outputOffset( offsetX, offsetY );
2969 QSvgRenderer r( svgContent );
2976 QSizeF outSize( r.defaultSize() );
2977 outSize.scale(
size,
size, Qt::KeepAspectRatio );
2983 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2985 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2987 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2988 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2997 bool hasDataDefinedSize =
false;
2998 double scaledWidth = calculateSize( context, hasDataDefinedSize );
3000 bool hasDataDefinedAspectRatio =
false;
3001 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
3008 if (
static_cast< int >( scaledWidth ) < 1 || 10000.0 < scaledWidth )
3013 QPointF outputOffset;
3015 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
3054 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
3058 QTransform transform;
3060 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3063 transform.rotate(
angle );
3068 QRectF symbolBounds = transform.mapRect( QRectF( -scaledWidth / 2.0,
3069 -scaledHeight / 2.0,
3077 return symbolBounds;
3101 if ( props.contains( u
"imageFile"_s ) )
3102 path = props[u
"imageFile"_s].toString();
3103 if ( props.contains( u
"size"_s ) )
3104 size = props[u
"size"_s].toDouble();
3105 if ( props.contains( u
"angle"_s ) )
3106 angle = props[u
"angle"_s].toDouble();
3107 if ( props.contains( u
"scale_method"_s ) )
3111 m->setCommonProperties( props );
3117 const QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
3118 if ( graphicElem.isNull() )
3121 const QDomElement externalGraphicElem = graphicElem.firstChildElement( u
"ExternalGraphic"_s );
3122 if ( externalGraphicElem.isNull() )
3125 const QDomElement onlineResourceElem = externalGraphicElem.firstChildElement( u
"OnlineResource"_s );
3126 const QDomElement inlineContentElem = externalGraphicElem.firstChildElement( u
"InlineContent"_s );
3129 if ( !onlineResourceElem.isNull() )
3131 url = onlineResourceElem.attribute( u
"href"_s );
3134 else if ( !inlineContentElem.isNull() && inlineContentElem.attribute( u
"encoding"_s ) ==
"base64"_L1 )
3136 url = u
"base64:"_s + inlineContentElem.text();
3157 if (
properties.contains( u
"size_map_unit_scale"_s ) )
3159 if (
properties.contains( u
"fixedAspectRatio"_s ) )
3164 if (
properties.contains( u
"offset_unit"_s ) )
3166 if (
properties.contains( u
"offset_map_unit_scale"_s ) )
3169 if (
properties.contains( u
"horizontal_anchor_point"_s ) )
3173 if (
properties.contains( u
"vertical_anchor_point"_s ) )
3184 const QVariantMap::iterator it =
properties.find( u
"name"_s );
3185 if ( it !=
properties.end() && it.value().userType() == QMetaType::Type::QString )
3203 if ( aPreservedAspectRatio && !par )
3207 else if ( !aPreservedAspectRatio && par )
3226 return u
"RasterMarker"_s;
3247 if (
path.isEmpty() )
3251 double height = 0.0;
3253 bool hasDataDefinedSize =
false;
3254 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3256 bool hasDataDefinedAspectRatio =
false;
3257 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3259 QPointF outputOffset;
3266 if (
size.isEmpty() )
3269 width = ( scaledSize *
static_cast< double >(
size.width() ) ) / 100.0;
3270 height = ( scaledSize *
static_cast< double >(
size.height() ) ) / 100.0;
3273 if (
static_cast< int >( width ) < 1 || 10000.0 < width ||
static_cast< int >( height ) < 1 || 10000.0 < height )
3276 calculateOffsetAndRotation( context, width, height, outputOffset,
angle );
3286 if ( !
size.isNull() &&
size.isValid() &&
size.width() > 0 )
3288 height = width * (
static_cast< double >(
size.height() ) /
static_cast< double >(
size.width() ) );
3293 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
3296 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3300 p->translate( point + outputOffset );
3315 if ( !img.isNull() )
3318 if ( useSelectedColor )
3323 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
3329 bool cached =
false;
3333double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
3335 double scaledSize =
mSize;
3339 if ( hasDataDefinedSize )
3347 if ( hasDataDefinedSize )
3354 if ( hasDataDefinedSize && ok )
3359 scaledSize = std::sqrt( scaledSize );
3372 if ( !hasDataDefinedAspectRatio )
3382 const double defaultHeight =
mSize * scaledAspectRatio;
3383 scaledAspectRatio = defaultHeight / scaledSize;
3386 double scaledHeight = scaledSize * scaledAspectRatio;
3393 if ( hasDataDefinedAspectRatio && ok )
3398 scaledHeight = sqrt( scaledHeight );
3405 scaledAspectRatio = scaledHeight / scaledSize;
3407 return scaledAspectRatio;
3410void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const
3415 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
3416 offset = QPointF( offsetX, offsetY );
3426 if ( hasDataDefinedRotation )
3428 const QgsFeature *f = context.
feature();
3447 map[u
"imageFile"_s] =
mPath;
3448 map[u
"size"_s] = QString::number(
mSize );
3452 map[u
"angle"_s] = QString::number(
mAngle );
3453 map[u
"alpha"_s] = QString::number(
mOpacity );
3459 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
3465 auto m = std::make_unique< QgsRasterMarkerSymbolLayer >();
3514 bool hasDataDefinedSize =
false;
3515 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3517 bool hasDataDefinedAspectRatio =
false;
3518 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3522 if (
static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
3527 QPointF outputOffset;
3529 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3531 QTransform transform;
3534 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3537 transform.rotate(
angle );
3539 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
3544 return symbolBounds;
3559 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
3560 element.appendChild( graphicElem );
3563 QDomElement extGraphElem = doc.createElement( u
"se:ExternalGraphic"_s );
3564 graphicElem.appendChild( extGraphElem );
3566 QMimeDatabase mimeDB;
3570 if (
mPath.startsWith(
"base64:"_L1 ) )
3572 base64data =
mPath.mid( 7 );
3584 if ( !base64data.isEmpty() )
3587 QDomElement inlineContEleme = doc.createElement( u
"se:InlineContent"_s );
3589 inlineContEleme.setAttribute( u
"encoding"_s, u
"base64"_s );
3590 inlineContEleme.appendChild( doc.createTextNode( base64data ) );
3591 extGraphElem.appendChild( inlineContEleme );
3594 const QByteArray ba = QByteArray::fromBase64( base64data.toUtf8() );
3595 mimeType = mimeDB.mimeTypeForData( ba );
3600 QDomElement onlineResElem = doc.createElement( u
"se:OnlineResource"_s );
3601 QString url =
mPath;
3603 onlineResElem.setAttribute( u
"xlink:href"_s, url );
3604 onlineResElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
3605 extGraphElem.appendChild( onlineResElem );
3608 if (
mPath.startsWith(
"http://"_L1 ) ||
mPath.startsWith(
"https://"_L1 ) )
3612 mimeType = mimeDB.mimeTypeForName(
"image/png" );
3616 mimeType = mimeDB.mimeTypeForUrl( url );
3620 QDomElement formatElem = doc.createElement( u
"se:Format"_s );
3621 formatElem.appendChild( doc.createTextNode( mimeType.name() ) );
3622 extGraphElem.appendChild( formatElem );
3637 mOrigSize = pointSize;
3657 if ( props.contains( u
"font"_s ) )
3659 if ( props.contains( u
"chr"_s ) && props[u
"chr"_s].toString().length() > 0 )
3661 string = props[
"chr"].toString();
3662 const thread_local QRegularExpression charRegExp( u
"%1([0-9]+)%1"_s.arg(
FONTMARKER_CHR_FIX ) );
3663 QRegularExpressionMatch match = charRegExp.match(
string );
3664 while ( match.hasMatch() )
3666 QChar replacement = QChar( match.captured( 1 ).toUShort() );
3667 string =
string.mid( 0, match.capturedStart( 0 ) ) + replacement +
string.mid( match.capturedEnd( 0 ) );
3668 match = charRegExp.match(
string );
3672 if ( props.contains( u
"size"_s ) )
3673 pointSize = props[u
"size"_s].toDouble();
3674 if ( props.contains( u
"color"_s ) )
3676 if ( props.contains( u
"angle"_s ) )
3677 angle = props[u
"angle"_s].toDouble();
3681 if ( props.contains( u
"font_style"_s ) )
3683 if ( props.contains( u
"outline_color"_s ) )
3685 if ( props.contains( u
"outline_width"_s ) )
3687 if ( props.contains( u
"offset"_s ) )
3689 if ( props.contains( u
"offset_unit"_s ) )
3691 if ( props.contains( u
"offset_map_unit_scale"_s ) )
3693 if ( props.contains( u
"size_unit"_s ) )
3695 if ( props.contains( u
"size_map_unit_scale"_s ) )
3697 if ( props.contains( u
"outline_width_unit"_s ) )
3699 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
3701 if ( props.contains( u
"joinstyle"_s ) )
3703 if ( props.contains( u
"horizontal_anchor_point"_s ) )
3705 if ( props.contains( u
"vertical_anchor_point"_s ) )
3715 return u
"FontMarker"_s;
3725 QColor brushColor =
mColor;
3726 QColor penColor = mStrokeColor;
3728 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3729 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3731 mBrush = QBrush( brushColor );
3732 mPen = QPen( penColor );
3733 mPen.setJoinStyle( mPenJoinStyle );
3737 if ( !mFontStyle.isEmpty() )
3745 if ( mNonZeroFontSize && sizePixels > MAX_FONT_CHARACTER_SIZE_IN_PIXELS )
3750 mFontSizeScale = sizePixels / MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3751 sizePixels = MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3754 mFontSizeScale = 1.0;
3758 mFont.setPixelSize( std::max( 2,
static_cast< int >( std::round( sizePixels ) ) ) );
3759 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
3760 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3765 mChrOffset = QPointF( mChrWidth / 2.0, -sizePixels / 2.0 );
3772 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3782 if ( mUseCachedPath )
3784 QPointF chrOffset = mChrOffset;
3786 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3787 mCachedPath = QPainterPath();
3788 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3797QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3799 charOffset = mChrOffset;
3800 QString stringToRender = mString;
3805 if ( stringToRender != mString )
3807 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3813 charOffset = QPointF( charWidth / 2.0, -sizePixels / 2.0 );
3820 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3826 return stringToRender;
3831 bool &hasDataDefinedRotation,
3833 double &angle )
const
3838 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3839 offset = QPointF( offsetX, offsetY );
3840 hasDataDefinedRotation =
false;
3854 hasDataDefinedRotation =
true;
3858 if ( hasDataDefinedRotation )
3865 const QgsFeature *f = context.
feature();
3882 double scaledSize =
mSize;
3886 if ( hasDataDefinedSize )
3892 if ( hasDataDefinedSize && ok )
3897 scaledSize = std::sqrt( scaledSize );
3909 if ( !p || !mNonZeroFontSize )
3912 QTransform transform;
3915 QColor brushColor =
mColor;
3925 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3927 mBrush.setColor( brushColor );
3929 QColor penColor = mStrokeColor;
3935 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3959 p->setBrush( mBrush );
3962 mPen.setColor( penColor );
3963 mPen.setWidthF( penWidth );
3968 p->setPen( Qt::NoPen );
3986 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
3989 QPointF chrOffset = mChrOffset;
3991 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3993 const double sizeToRender = calculateSize( context );
3995 bool hasDataDefinedRotation =
false;
3998 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation,
offset,
angle );
4000 p->translate( point.x() +
offset.x(), point.y() +
offset.y() );
4003 transform.rotate(
angle );
4007 const double s = sizeToRender / mOrigSize;
4008 transform.scale( s, s );
4012 transform.scale( mFontSizeScale, mFontSizeScale );
4014 if ( mUseCachedPath )
4016 p->drawPath( transform.map( mCachedPath ) );
4021 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
4022 p->drawPath( transform.map( path ) );
4029 props[u
"font"_s] = mFontFamily;
4030 props[u
"font_style"_s] = mFontStyle;
4031 QString chr = mString;
4032 for (
int i = 0; i < 32; i++ )
4034 if ( i == 9 || i == 10 || i == 13 )
4038 chr.replace( QChar( i ), u
"%1%2%1"_s.arg(
FONTMARKER_CHR_FIX, QString::number( i ) ) );
4040 props[u
"chr"_s] = chr;
4041 props[u
"size"_s] = QString::number(
mSize );
4046 props[u
"outline_width"_s] = QString::number( mStrokeWidth );
4050 props[u
"angle"_s] = QString::number(
mAngle );
4055 props[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
4084 toSld( doc, element, context );
4102 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
4103 element.appendChild( graphicElem );
4106 const QString fontPath = u
"ttf://%1"_s.arg( mFontFamily );
4107 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
4114 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
4117 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
4141 mStrokeWidthUnit = unit;
4146 QPointF chrOffset = mChrOffset;
4147 double chrWidth = mChrWidth;
4149 ( void )characterToRender( context, chrOffset, chrWidth );
4151 if ( !mFontMetrics )
4152 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
4154 double scaledSize = calculateSize( context );
4157 chrWidth *= scaledSize / mOrigSize;
4159 chrWidth *= mFontSizeScale;
4161 bool hasDataDefinedRotation =
false;
4164 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation,
offset,
angle );
4167 QTransform transform;
4170 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
4173 transform.rotate(
angle );
4175 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
4179 return symbolBounds;
4186 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
4187 if ( graphicElem.isNull() )
4190 QString name, format;
4198 if ( !name.startsWith(
"ttf://"_L1 ) || format !=
"ttf"_L1 )
4208 const double d = angleFunc.toDouble( &ok );
4216 double scaleFactor = 1.0;
4217 const QString uom = element.attribute( u
"uom"_s );
4238 context.
pushMessage( QObject::tr(
"Font “%1” not available on system" ).arg( processedFamily ) );
4244 QMap<QString, QgsProperty>::iterator it =
mParameters.begin();
4256 QMap<QString, QgsProperty>::const_iterator it =
mParameters.constBegin();
4259 attrs.unite( it.value().referencedFields( context.
expressionContext(),
true ) );
4290 auto m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
path,
size,
angle );
4291 m->setFrameRate(
properties.value( u
"frameRate"_s, u
"10"_s ).toDouble() );
4299 return u
"AnimatedMarker"_s;
4305 res.insert( u
"frameRate"_s, mFrameRateFps );
4311 auto m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
4312 m->setFrameRate( mFrameRateFps );
4321 mPreparedPaths.clear();
4329 mStaticPath =
false;
4335 if ( !mStaticPath && !mPreparedPaths.contains(
path ) )
4338 mPreparedPaths.insert(
path );
4341 const long long mapFrameNumber = context.
currentFrame();
4343 const double markerAnimationDuration = totalFrameCount / mFrameRateFps;
4345 double animationTimeSeconds = 0;
4346 if ( mapFrameNumber >= 0 && context.
frameRate() > 0 )
4349 animationTimeSeconds = mapFrameNumber / context.
frameRate();
4354 animationTimeSeconds = QDateTime::currentMSecsSinceEpoch() / 1000.0;
4357 const double markerAnimationProgressSeconds = std::fmod( animationTimeSeconds, markerAnimationDuration );
4358 const int movieFrame =
static_cast< int >( std::floor( markerAnimationProgressSeconds * mFrameRateFps ) );
4360 bool cached =
false;
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
@ IsSymbolLayerSubSymbol
Symbol is being rendered as a sub-symbol of a QgsSymbolLayer.
@ CanCalculateMaskGeometryPerFeature
If present, indicates that mask geometry can safely be calculated per feature for the symbol layer....
ScaleMethod
Scale methods.
@ ScaleDiameter
Calculate scale by the diameter.
@ ScaleArea
Calculate scale by the area.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
MarkerShape
Marker shapes.
@ EquilateralTriangle
Equilateral triangle.
@ SemiCircle
Semi circle (top half).
@ QuarterCircle
Quarter circle (top left quarter).
@ LeftHalfTriangle
Left half of triangle.
@ ArrowHead
Right facing arrow head (unfilled, lines only).
@ ParallelogramRight
Parallelogram that slants right.
@ AsteriskFill
A filled asterisk shape.
@ HalfArc
A line-only half arc.
@ QuarterSquare
Quarter square (top left quarter).
@ Cross2
Rotated cross (lines only), 'x' shape.
@ ArrowHeadFilled
Right facing filled arrow head.
@ Shield
A shape consisting of a triangle attached to a rectangle.
@ HalfSquare
Half square (left half).
@ CrossFill
Solid filled cross.
@ RoundedSquare
A square with rounded corners.
@ RightHalfTriangle
Right half of triangle.
@ ThirdCircle
One third circle (top left third).
@ ThirdArc
A line-only one third arc.
@ SquareWithCorners
A square with diagonal corners.
@ QuarterArc
A line-only one quarter arc.
@ DiamondStar
A 4-sided star.
@ Cross
Cross (lines only).
@ ParallelogramLeft
Parallelogram that slants left.
@ DiagonalHalfSquare
Diagonal half square (bottom left half).
VerticalAnchorPoint
Marker symbol vertical anchor points.
@ Bottom
Align to bottom of symbol.
@ Center
Align to vertical center of symbol.
@ Baseline
Align to baseline of symbol, e.g. font baseline for font marker symbol layers. Treated as Bottom if n...
@ Top
Align to top of symbol.
RenderUnit
Rendering size units.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size).
@ Millimeters
Millimeters.
@ Unknown
Mixed or unknown units.
@ MetersInMapUnits
Meters value as Map units.
@ RenderingSubSymbol
Set whenever a sub-symbol of a parent symbol is currently being rendered. Can be used during symbol a...
@ RenderSymbolPreview
The render is for a symbol preview only and map based properties may not be available,...
@ RenderLayerTree
The render is for a layer tree display where map based properties are not available and where avoidan...
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
static bool parseBase64DataUrl(const QString &path, QString *mimeType=nullptr, QString *data=nullptr)
Parses a path to determine if it represents a base 64 encoded HTML data URL, and if so,...
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.
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.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsAnimatedMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
~QgsAnimatedMarkerSymbolLayer() override
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QImage fetchImage(QgsRenderContext &context, const QString &path, QSize size, bool preserveAspectRatio, double opacity) const override
Fetches the image to render.
QgsAnimatedMarkerSymbolLayer(const QString &path=QString(), double size=DEFAULT_RASTERMARKER_SIZE, double angle=DEFAULT_RASTERMARKER_ANGLE)
Constructor for animated marker symbol layer using the specified source image path.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates an animated marker symbol layer from a string map of properties.
QString layerType() const override
Returns a string that represents this layer type.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QgsFontManager * fontManager()
Returns the application font manager, which manages available fonts and font installation for the QGI...
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
Exports QGIS layers to the DXF format.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch).
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline).
static double mapUnitScaleFactor(double scale, Qgis::RenderUnit symbolUnits, Qgis::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
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 writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH).
Qgis::DistanceUnit mapUnits() const
Retrieve map units.
double symbologyScale() const
Returns the reference scale for output.
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE).
A paint device for drawing into dxf files.
void setShift(QPointF shift)
void setLayer(const QString &layer)
void setOutputSize(const QRectF &r)
void setDrawingSize(QSizeF size)
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static std::unique_ptr< QgsFillSymbol > createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QColor color() const override
Returns the "representative" color of the symbol layer.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
~QgsFilledMarkerSymbolLayer() override
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setColor(const QColor &c) override
Sets the "representative" color for the symbol layer.
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsFilledMarkerSymbolLayer.
QgsFilledMarkerSymbolLayer(Qgis::MarkerShape shape=Qgis::MarkerShape::Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsFilledMarkerSymbolLayer.
QString processFontFamilyName(const QString &name) const
Processes a font family name, applying any matching fontFamilyReplacements() to the name.
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the stroke width unit.
~QgsFontMarkerSymbolLayer() override
void setStrokeColor(const QColor &color) override
Sets the stroke color for the symbol layer.
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.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
double strokeWidth() const
Returns the marker's stroke width.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void setStrokeWidth(double width)
Set's the marker's stroke width.
static void resolveFonts(const QVariantMap &properties, const QgsReadWriteContext &context)
Resolves fonts from a properties map, raising warnings in the specified context if the required fonts...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsFontMarkerSymbolLayer from an SLD XML element.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsFontMarkerSymbolLayer from a property map (see properties()).
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
static QFont createFont(const QString &family, int pointSize=-1, int weight=-1, bool italic=false)
Creates a font with the specified family.
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=nullptr, bool *match=nullptr)
Check whether font family is on system.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
int totalFrameCount(const QString &path, bool blocking=false)
Returns the total frame count of the image at the specified path.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false, double targetDpi=96, int frameNumber=-1, bool *isMissing=nullptr)
Returns the specified path rendered as an image.
void prepareAnimation(const QString &path)
Prepares for optimized retrieval of frames for the animation at the given path.
static void overlayColor(QImage &image, const QColor &color)
Overlays a color onto an image.
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
Struct for storing maximum and minimum scales for measurements in map units.
void setVerticalAnchorPoint(Qgis::VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)
Qgis::RenderUnit mOffsetUnit
Offset units.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
double mLineAngle
Line rotation angle (see setLineAngle() for details).
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's offset.
void setAngle(double angle)
Sets the rotation angle for the marker.
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
bool toSld(QDomDocument &doc, QDomElement &element, QgsSldExportContext &context) const override
Saves the symbol layer as SLD.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QPointF mOffset
Marker offset.
QgsMapUnitScale mapUnitScale() const override
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
double size() const
Returns the symbol size.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
Qgis::VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
void setHorizontalAnchorPoint(Qgis::HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
Qgis::ScaleMethod mScaleMethod
Marker size scaling method.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Qgis::RenderUnit mSizeUnit
Marker size unit.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
Qgis::HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double mAngle
Marker rotation angle, in degrees clockwise from north.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setMapUnitScale(const QgsMapUnitScale &scale) override
static void drawPicture(QPainter *painter, const QPointF &point, const QPicture &picture)
Draws a picture onto a painter, correctly applying workarounds to avoid issues with incorrect scaling...
Resolves relative paths into absolute paths and vice versa.
Point geometry type, with support for z-dimension and m-values.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
static QVariantMap propertyMapToVariantMap(const QMap< QString, QgsProperty > &propertyMap)
Convert a map of QgsProperty to a map of QVariant This is useful to save a map of properties.
static QMap< QString, QgsProperty > variantMapToPropertyMap(const QVariantMap &variantMap)
Convert a map of QVariant to a map of QgsProperty This is useful to restore a map of properties.
static QgsProperty fromValue(const QVariant &value, bool isActive=true)
Returns a new StaticProperty created from the specified value.
double mFixedAspectRatio
The marker fixed aspect ratio.
QColor color() const override
Returns the "representative" color of the symbol layer.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsRasterMarkerSymbolLayer from an SLD XML element.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mapUnitScale() const override
void copyCommonProperties(QgsRasterMarkerSymbolLayer *other) const
Copies common properties to another layer.
void setOpacity(double opacity)
Set the marker opacity.
QString path() const
Returns the marker raster image path.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
QgsRasterMarkerSymbolLayer(const QString &path=QString(), double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs raster marker symbol layer with picture from given absolute path to a raster image file.
void setPath(const QString &path)
Set the marker raster image path.
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
virtual QImage fetchImage(QgsRenderContext &context, const QString &path, QSize size, bool preserveAspectRatio, double opacity) const
Fetches the image to render.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setCommonProperties(const QVariantMap &properties)
Sets common class properties from a properties map.
QgsRasterMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
static void resolvePaths(QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
~QgsRasterMarkerSymbolLayer() override
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a raster marker symbol layer from a string map of properties.
double mOpacity
The marker default opacity.
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
double mDefaultAspectRatio
The marker default aspect ratio.
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QString layerType() const override
Returns a string that represents this layer type.
double opacity() const
Returns the marker opacity.
A container for the context for various read/write operations on objects.
void pushMessage(const QString &message, Qgis::MessageLevel level=Qgis::MessageLevel::Warning) const
Append a message to the context.
Contains information about the context of a rendering operation.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QPainter * painter()
Returns the destination QPainter for the render operation.
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
QgsExpressionContext & expressionContext()
Gets the expression context.
long long currentFrame() const
Returns the current frame number of the map (in frames per second), for maps which are part of an ani...
float devicePixelRatio() const
Returns the device pixel ratio.
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected).
double frameRate() const
Returns the frame rate of the map, for maps which are part of an animation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QColor selectionColor() const
Returns the color to use when rendering selected features.
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
Scoped object for saving and restoring a QPainter object's state.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void calculateOffsetAndRotation(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle) const
Calculates the marker offset and rotation.
Qgis::MarkerShape mShape
Symbol shape.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath.
bool shapeToPolygon(Qgis::MarkerShape shape, QPolygonF &polygon) const
Creates a polygon representing the specified shape.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
static QList< Qgis::MarkerShape > availableShapes()
Returns a list of all available shape types.
~QgsSimpleMarkerSymbolLayerBase() override
static bool shapeIsFilled(Qgis::MarkerShape shape)
Returns true if a symbol shape has a fill.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
Qgis::MarkerShape shape() const
Returns the shape for the rendered marker symbol.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QgsSimpleMarkerSymbolLayerBase(Qgis::MarkerShape shape=Qgis::MarkerShape::Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsSimpleMarkerSymbolLayerBase.
static QString encodeShape(Qgis::MarkerShape shape)
Encodes a shape to its string representation.
double calculateSize(QgsSymbolRenderContext &context, bool &hasDataDefinedSize) const
Calculates the desired size of the marker, considering data defined size overrides.
static Qgis::MarkerShape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
bool prepareMarkerPath(Qgis::MarkerShape symbol)
Prepares the layer for drawing the specified shape (QPainterPath version).
bool prepareMarkerShape(Qgis::MarkerShape shape)
Prepares the layer for drawing the specified shape (QPolygonF version).
QPen mSelPen
QPen to use as stroke of selected symbols.
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
QColor mStrokeColor
Stroke color.
QImage mSelCache
Cached image of selected marker, if using cached version.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QImage mCache
Cached image of marker, if using cached version.
QBrush mSelBrush
QBrush to use as fill of selected symbols.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
void drawMarker(QPainter *p, QgsSymbolRenderContext &context)
Draws the marker shape in the specified painter.
QPen mPen
QPen corresponding to marker's stroke style.
Qgis::RenderUnit mStrokeWidthUnit
Stroke width units.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSimpleMarkerSymbolLayer.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void setMapUnitScale(const QgsMapUnitScale &scale) override
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setStrokeWidthUnit(Qgis::RenderUnit u)
Sets the unit for the width of the marker's stroke.
QColor color() const override
Returns the "representative" color of the symbol layer.
QgsMapUnitScale mapUnitScale() const override
Qt::PenStyle mStrokeStyle
Stroke style.
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSimpleMarkerSymbolLayer from an SLD XML element.
~QgsSimpleMarkerSymbolLayer() override
Qt::PenCapStyle mPenCapStyle
Stroke pen cap style.
QString layerType() const override
Returns a string that represents this layer type.
double mStrokeWidth
Stroke width.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc).
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QColor fillColor() const override
Returns the fill color for the symbol layer.
QColor strokeColor() const override
Returns the marker's stroke color.
QBrush mBrush
QBrush corresponding to marker's fill style.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc).
bool mUsingCache
true if using cached images of markers for drawing.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static const int MAXIMUM_CACHE_WIDTH
Maximum width/height of cache image.
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
bool prepareCache(QgsSymbolRenderContext &context)
Prepares cache image.
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
QgsSimpleMarkerSymbolLayer(Qgis::MarkerShape shape=Qgis::MarkerShape::Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, Qgis::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.
double strokeWidth() const
Returns the width of the marker's stroke.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
QVariantMap extraProperties() const
Returns the open ended set of properties that can drive/inform the SLD encoding.
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Calculates the viewbox size of a (possibly cached) SVG file.
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, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QPicture.
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.
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, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >(), bool *isMissingImage=nullptr)
Gets the SVG content corresponding to the given path.
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QColor fillColor() const override
Returns the fill color for the symbol layer.
QgsMapUnitScale mapUnitScale() const override
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol.
double mDefaultAspectRatio
The marker default aspect ratio.
QString layerType() const override
Returns a string that represents this layer type.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QString path() const
Returns the marker SVG path.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
void setStrokeWidth(double w)
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void prepareExpressions(const QgsSymbolRenderContext &context) override
Prepares all data defined property expressions for evaluation.
QMap< QString, QgsProperty > mParameters
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the stroke width.
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
double strokeWidth() const
QgsSvgMarkerSymbolLayer(const QString &path, double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs SVG marker symbol layer with picture from given absolute path to a SVG file.
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
~QgsSvgMarkerSymbolLayer() override
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
static void resolvePaths(QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
QgsMapUnitScale mStrokeWidthMapUnitScale
Qgis::RenderUnit mStrokeWidthUnit
void setParameters(const QMap< QString, QgsProperty > ¶meters)
Sets the dynamic SVG parameters.
double mFixedAspectRatio
The marker fixed 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
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
void setPath(const QString &path)
Set the marker SVG path.
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static QString encodePenStyle(Qt::PenStyle style)
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsStringMap evaluatePropertiesMap(const QMap< QString, QgsProperty > &propertiesMap, const QgsExpressionContext &context)
Evaluates a map of properties using the given context and returns a variant map with evaluated expres...
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static double rescaleUom(double size, Qgis::RenderUnit unit, const QVariantMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
static Q_DECL_DEPRECATED 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...
static Qgis::ScaleMethod decodeScaleMethod(const QString &str)
Decodes a symbol scale method from a string.
static QString encodePenCapStyle(Qt::PenCapStyle style)
static Q_DECL_DEPRECATED void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
Exports a marker to an SLD definition.
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
Extracts properties from an SLD marker definition.
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QString encodeColor(const QColor &color)
static Qgis::RenderUnit decodeSldUom(const QString &str, double *scaleFactor=nullptr)
Decodes a SLD unit of measure string to a render unit.
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
Exports a marker to SLD.
static QString encodeScaleMethod(Qgis::ScaleMethod scaleMethod)
Encodes a symbol scale method to a string.
static Qt::PenStyle decodePenStyle(const QString &str)
static Q_DECL_DEPRECATED void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
Creates SLD rotation element.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
bool shouldRenderUsingSelectionColor(const QgsSymbolRenderContext &context) const
Returns true if the symbol layer should be rendered using the selection color from the render context...
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
bool installMasks(QgsRenderContext &context, bool recursive, const QRectF &rect=QRectF())
When rendering, install masks on context painter.
void removeMasks(QgsRenderContext &context, bool recursive)
When rendering, remove previously installed masks from context painter if recursive is true masks are...
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
@ StrokeStyle
Stroke style (eg solid, dashed).
@ Name
Name, eg shape name for simple markers.
@ Character
Character, eg for font marker symbol layers.
@ StrokeColor
Stroke color.
@ CapStyle
Line cap style.
@ JoinStyle
Line join style.
@ StrokeWidth
Stroke width.
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
virtual void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
virtual Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Saves the symbol layer as SLD.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
virtual void setOutputUnit(Qgis::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
virtual Qgis::SymbolLayerFlags flags() const
Returns flags which control the symbol layer's behavior.
QgsPropertyCollection mDataDefinedProperties
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
const QgsFeature * feature() const
Returns the current feature being rendered.
QgsFields fields() const
Fields of the layer.
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
bool forceVectorRendering() const
Returns true if symbol must be rendered using vector methods, and optimisations like pre-rendered ima...
qreal opacity() const
Returns the opacity for the symbol.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Abstract base class for all rendered symbols.
Qgis::SymbolType type() const
Returns the symbol's type.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
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
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QMap< QString, QString > QgsStringMap
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
#define DEFAULT_FONTMARKER_JOINSTYLE
#define DEFAULT_RASTERMARKER_ANGLE
#define DEFAULT_RASTERMARKER_SIZE
#define DEFAULT_SVGMARKER_ANGLE
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
#define DEFAULT_FONTMARKER_CHR
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
#define DEFAULT_SIMPLEMARKER_SIZE
#define DEFAULT_SIMPLEMARKER_NAME
#define DEFAULT_SIMPLEMARKER_ANGLE
#define DEFAULT_SVGMARKER_SIZE
#define DEFAULT_FONTMARKER_FONT
#define DEFAULT_FONTMARKER_BORDERCOLOR
#define DEFAULT_FONTMARKER_ANGLE
#define DEFAULT_FONTMARKER_COLOR
#define DEFAULT_FONTMARKER_SIZE
#define DEFAULT_SIMPLEMARKER_COLOR
#define DEFAULT_SCALE_METHOD
#define FONTMARKER_CHR_FIX