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 ) );
1417 toSld( doc, element, context );
1435 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
1436 element.appendChild( graphicElem );
1453 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
1456 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
1474 Q_UNUSED( mmScaleFactor )
1475 Q_UNUSED( mapUnitScaleFactor )
1477 QString ogrType =
"3";
1478 if ( mName ==
"square" )
1482 else if ( mName ==
"triangle" )
1486 else if ( mName ==
"star" )
1490 else if ( mName ==
"circle" )
1494 else if ( mName ==
"cross" )
1498 else if ( mName ==
"x" || mName ==
"cross2" )
1502 else if ( mName ==
"line" )
1508 ogrString.append(
"SYMBOL(" );
1509 ogrString.append(
"id:" );
1510 ogrString.append(
'\"' );
1511 ogrString.append(
"ogr-sym-" );
1512 ogrString.append( ogrType );
1513 ogrString.append(
'\"' );
1514 ogrString.append(
",c:" );
1515 ogrString.append(
mColor.name() );
1516 ogrString.append(
",o:" );
1518 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1519 ogrString.append(
')' );
1524 ogrString.append(
"PEN(" );
1525 ogrString.append(
"c:" );
1526 ogrString.append(
mColor.name() );
1527 ogrString.append(
",w:" );
1528 ogrString.append( QString::number(
mSize ) );
1529 ogrString.append(
"mm" );
1530 ogrString.append(
")" );
1538 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
1539 if ( graphicElem.isNull() )
1542 QString name = u
"square"_s;
1555 const double d = angleFunc.toDouble( &ok );
1565 double scaleFactor = 1.0;
1566 const QString uom = element.attribute( u
"uom"_s );
1593 p->drawPath(
mPath );
1606 if ( hasDataDefinedSize )
1625 size *= mmMapUnitScaleFactor;
1632 const double halfSize =
size / 2.0;
1649 QColor pc =
mPen.color();
1650 QColor bc =
mBrush.color();
1670 QPointF off( offsetX, offsetY );
1699 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1707 t.scale( halfSize, -halfSize );
1709 polygon = t.map( polygon );
1712 p.reserve( polygon.size() );
1713 for (
int i = 0; i < polygon.size(); i++ )
1718 if (
mBrush.style() != Qt::NoBrush )
1720 if (
mPen.style() != Qt::NoPen )
1725 shift += QPointF( off.x(), -off.y() );
1726 if (
mBrush.style() != Qt::NoBrush )
1728 if (
mPen.style() != Qt::NoPen )
1733 const QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1734 const QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1736 if (
mPen.style() != Qt::NoPen )
1741 if (
mPen.style() != Qt::NoPen )
1743 const QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1744 const QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1745 const QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1746 const QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1754 if (
mPen.style() != Qt::NoPen )
1756 const QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1757 const QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1758 const QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1759 const QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1767 if (
mPen.style() != Qt::NoPen )
1769 const QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1770 const QPointF pt2 = t.map( QPointF( 0, 0 ) );
1771 const QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1857 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1858 penWidth / 2.0, penWidth / 2.0 );
1860 return symbolBounds;
1909 if ( props.contains( u
"name"_s ) )
1910 name = props[u
"name"_s].toString();
1911 if ( props.contains( u
"size"_s ) )
1912 size = props[u
"size"_s].toDouble();
1913 if ( props.contains( u
"angle"_s ) )
1914 angle = props[u
"angle"_s].toDouble();
1915 if ( props.contains( u
"scale_method"_s ) )
1919 if ( props.contains( u
"offset"_s ) )
1921 if ( props.contains( u
"offset_unit"_s ) )
1923 if ( props.contains( u
"offset_map_unit_scale"_s ) )
1925 if ( props.contains( u
"size_unit"_s ) )
1927 if ( props.contains( u
"size_map_unit_scale"_s ) )
1929 if ( props.contains( u
"horizontal_anchor_point"_s ) )
1933 if ( props.contains( u
"vertical_anchor_point"_s ) )
1947 return u
"FilledMarker"_s;
1987 map[u
"size"_s] = QString::number(
mSize );
1990 map[u
"angle"_s] = QString::number(
mAngle );
1996 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
2045 attr.unite( mFill->usedAttributes( context ) );
2053 if ( mFill && mFill->hasDataDefinedProperties() )
2062 mFill->setColor(
c );
2067 return mFill ? mFill->color() :
mColor;
2074 || ( mFill && mFill->usesMapUnits() );
2081 mFill->setOutputUnit( unit );
2095 const double prevOpacity = mFill->opacity();
2096 mFill->setOpacity( mFill->opacity() * context.
opacity() );
2100 p->setBrush( Qt::red );
2104 p->setBrush( Qt::NoBrush );
2106 p->setPen( Qt::black );
2112 if ( !polygon.isEmpty() )
2114 mFill->renderPolygon( polygon,
nullptr, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2118 const QPolygonF poly = path.toFillPolygon();
2119 mFill->renderPolygon( poly,
nullptr, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2124 mFill->setOpacity( prevOpacity );
2139 mColor = QColor( 35, 35, 35 );
2167 if ( props.contains( u
"name"_s ) )
2168 name = props[u
"name"_s].toString();
2169 if ( props.contains( u
"size"_s ) )
2170 size = props[u
"size"_s].toDouble();
2171 if ( props.contains( u
"angle"_s ) )
2172 angle = props[u
"angle"_s].toDouble();
2173 if ( props.contains( u
"scale_method"_s ) )
2178 if ( props.contains( u
"size_unit"_s ) )
2180 if ( props.contains( u
"size_map_unit_scale"_s ) )
2182 if ( props.contains( u
"fixedAspectRatio"_s ) )
2184 if ( props.contains( u
"offset"_s ) )
2186 if ( props.contains( u
"offset_unit"_s ) )
2188 if ( props.contains( u
"offset_map_unit_scale"_s ) )
2190 if ( props.contains( u
"fill"_s ) )
2195 else if ( props.contains( u
"color"_s ) )
2199 if ( props.contains( u
"outline"_s ) )
2204 else if ( props.contains( u
"outline_color"_s ) )
2208 else if ( props.contains( u
"line_color"_s ) )
2213 if ( props.contains( u
"outline-width"_s ) )
2218 else if ( props.contains( u
"outline_width"_s ) )
2222 else if ( props.contains( u
"line_width"_s ) )
2227 if ( props.contains( u
"outline_width_unit"_s ) )
2231 else if ( props.contains( u
"line_width_unit"_s ) )
2235 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
2238 if ( props.contains( u
"horizontal_anchor_point"_s ) )
2242 if ( props.contains( u
"vertical_anchor_point"_s ) )
2251 if ( props.contains( u
"parameters"_s ) )
2253 const QVariantMap
parameters = props[u
"parameters"_s].toMap();
2262 const QVariantMap::iterator it =
properties.find( u
"name"_s );
2281 QColor defaultFillColor, defaultStrokeColor;
2283 bool hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
2284 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
2286 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
2287 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2288 hasStrokeWidthParam, hasDefaultStrokeWidth,
strokeWidth,
2289 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
2291 const double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
2292 const double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
2294 if ( hasDefaultFillColor )
2296 defaultFillColor.setAlphaF( newFillOpacity );
2299 if ( hasDefaultFillOpacity )
2302 c.setAlphaF( fillOpacity );
2305 if ( hasDefaultStrokeColor )
2307 defaultStrokeColor.setAlphaF( newStrokeOpacity );
2310 if ( hasDefaultStrokeWidth )
2314 if ( hasDefaultStrokeOpacity )
2317 c.setAlphaF( strokeOpacity );
2331 const double widthScaleFactor = 3.465;
2334 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
2342 if ( aPreservedAspectRatio && !par )
2346 else if ( !aPreservedAspectRatio && par )
2361 return u
"SvgMarker"_s;
2386 bool hasDataDefinedSize =
false;
2387 const double scaledWidth = calculateSize( context, hasDataDefinedSize );
2392 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
2399 bool hasDataDefinedAspectRatio =
false;
2400 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2444 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2448 QPointF outputOffset;
2450 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2452 p->translate( point + outputOffset );
2458 bool fitsInCache =
true;
2459 bool usePict =
true;
2461 if ( ( !context.
forceVectorRendering() && !rotated ) || ( useSelectedColor && rasterizeSelected ) )
2466 if ( fitsInCache && img.width() > 1 )
2470 if ( useSelectedColor )
2478 QImage transparentImage = img.copy();
2480 if ( devicePixelRatio == 1 )
2482 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2486 p->drawImage( QRectF( -transparentImage.width() / 2.0 / devicePixelRatio, -transparentImage.height() / 2.0 / devicePixelRatio,
2487 transparentImage.width() / devicePixelRatio, transparentImage.height() / devicePixelRatio
2488 ), transparentImage );
2493 if ( devicePixelRatio == 1 )
2495 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2499 p->drawImage( QRectF( -img.width() / 2.0 / devicePixelRatio, -img.height() / 2.0 / devicePixelRatio,
2500 img.width() / devicePixelRatio, img.height() / devicePixelRatio ), img );
2506 if ( usePict || !fitsInCache )
2508 p->setOpacity( context.
opacity() );
2512 if ( pct.width() > 1 )
2522double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2524 double scaledSize =
mSize;
2528 if ( hasDataDefinedSize )
2536 if ( hasDataDefinedSize )
2543 if ( hasDataDefinedSize && ok )
2548 scaledSize = std::sqrt( scaledSize );
2561 if ( !hasDataDefinedAspectRatio )
2571 const double defaultHeight =
mSize * scaledAspectRatio;
2572 scaledAspectRatio = defaultHeight / scaledSize;
2575 double scaledHeight = scaledSize * scaledAspectRatio;
2582 if ( hasDataDefinedAspectRatio && ok )
2587 scaledHeight = sqrt( scaledHeight );
2594 scaledAspectRatio = scaledHeight / scaledSize;
2596 return scaledAspectRatio;
2599void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const
2604 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2605 offset = QPointF( offsetX, offsetY );
2615 if ( hasDataDefinedRotation )
2622 const QgsFeature *f = context.
feature();
2641 map[u
"name"_s] =
mPath;
2642 map[u
"size"_s] = QString::number(
mSize );
2646 map[u
"angle"_s] = QString::number(
mAngle );
2653 map[u
"outline_width"_s] = QString::number(
mStrokeWidth );
2657 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
2680 toSld( doc, element, context );
2729 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
2730 element.appendChild( graphicElem );
2741 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
2744 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
2763 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
2764 if ( graphicElem.isNull() )
2767 QString
path, mimeType;
2775 double scaleFactor = 1.0;
2776 const QString uom = element.attribute( u
"uom"_s );
2780 if ( mimeType !=
"image/svg+xml"_L1 )
2788 const double d = angleFunc.toDouble( &ok );
2797 QString realPath {
path };
2798 QUrl svgUrl {
path };
2801 QUrlQuery queryString;
2803 if ( svgUrl.hasQuery() && svgUrl.hasFragment() )
2805 const QString queryPart {
path.mid(
path.indexOf(
'?' ) + 1 ) };
2806 queryString.setQuery( queryPart );
2810 if ( svgUrl.scheme().isEmpty() || svgUrl.isLocalFile() )
2812 svgUrl.setQuery( QString() );
2813 realPath = svgUrl.path();
2818 QMap<QString, QgsProperty> params;
2822 if ( queryString.hasQueryItem( u
"fill"_s ) )
2824 const QColor
fillColor { queryString.queryItemValue( u
"fill"_s ) };
2828 if ( queryString.hasQueryItem( u
"fill-opacity"_s ) )
2830 const double alpha { queryString.queryItemValue( u
"fill-opacity"_s ).toDouble( &ok ) };
2837 if ( queryString.hasQueryItem( u
"outline"_s ) )
2839 const QColor
strokeColor { queryString.queryItemValue( u
"outline"_s ) };
2843 if ( queryString.hasQueryItem( u
"outline-opacity"_s ) )
2845 const double alpha { queryString.queryItemValue( u
"outline-opacity"_s ).toDouble( &ok ) };
2852 if ( queryString.hasQueryItem( u
"outline-width"_s ) )
2854 const int width { queryString.queryItemValue( u
"outline-width"_s ).toInt( &ok )};
2861 if ( ! params.isEmpty() )
2880 if ( hasDataDefinedSize )
2886 if ( hasDataDefinedSize && ok )
2900 size *= mmMapUnitScaleFactor;
2914 const double offsetX =
offset.x();
2915 const double offsetY =
offset.y();
2917 QPointF outputOffset( offsetX, offsetY );
2967 QSvgRenderer r( svgContent );
2974 QSizeF outSize( r.defaultSize() );
2975 outSize.scale(
size,
size, Qt::KeepAspectRatio );
2981 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2983 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2985 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2986 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2995 bool hasDataDefinedSize =
false;
2996 double scaledWidth = calculateSize( context, hasDataDefinedSize );
2998 bool hasDataDefinedAspectRatio =
false;
2999 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
3006 if (
static_cast< int >( scaledWidth ) < 1 || 10000.0 < scaledWidth )
3011 QPointF outputOffset;
3013 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
3052 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
3056 QTransform transform;
3058 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3061 transform.rotate(
angle );
3066 QRectF symbolBounds = transform.mapRect( QRectF( -scaledWidth / 2.0,
3067 -scaledHeight / 2.0,
3075 return symbolBounds;
3099 if ( props.contains( u
"imageFile"_s ) )
3100 path = props[u
"imageFile"_s].toString();
3101 if ( props.contains( u
"size"_s ) )
3102 size = props[u
"size"_s].toDouble();
3103 if ( props.contains( u
"angle"_s ) )
3104 angle = props[u
"angle"_s].toDouble();
3105 if ( props.contains( u
"scale_method"_s ) )
3109 m->setCommonProperties( props );
3115 const QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
3116 if ( graphicElem.isNull() )
3119 const QDomElement externalGraphicElem = graphicElem.firstChildElement( u
"ExternalGraphic"_s );
3120 if ( externalGraphicElem.isNull() )
3123 const QDomElement onlineResourceElem = externalGraphicElem.firstChildElement( u
"OnlineResource"_s );
3124 const QDomElement inlineContentElem = externalGraphicElem.firstChildElement( u
"InlineContent"_s );
3127 if ( !onlineResourceElem.isNull() )
3129 url = onlineResourceElem.attribute( u
"href"_s );
3132 else if ( !inlineContentElem.isNull() && inlineContentElem.attribute( u
"encoding"_s ) ==
"base64"_L1 )
3134 url = u
"base64:"_s + inlineContentElem.text();
3155 if (
properties.contains( u
"size_map_unit_scale"_s ) )
3157 if (
properties.contains( u
"fixedAspectRatio"_s ) )
3162 if (
properties.contains( u
"offset_unit"_s ) )
3164 if (
properties.contains( u
"offset_map_unit_scale"_s ) )
3167 if (
properties.contains( u
"horizontal_anchor_point"_s ) )
3171 if (
properties.contains( u
"vertical_anchor_point"_s ) )
3182 const QVariantMap::iterator it =
properties.find( u
"name"_s );
3183 if ( it !=
properties.end() && it.value().userType() == QMetaType::Type::QString )
3201 if ( aPreservedAspectRatio && !par )
3205 else if ( !aPreservedAspectRatio && par )
3224 return u
"RasterMarker"_s;
3245 if (
path.isEmpty() )
3249 double height = 0.0;
3251 bool hasDataDefinedSize =
false;
3252 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3254 bool hasDataDefinedAspectRatio =
false;
3255 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3257 QPointF outputOffset;
3264 if (
size.isEmpty() )
3267 width = ( scaledSize *
static_cast< double >(
size.width() ) ) / 100.0;
3268 height = ( scaledSize *
static_cast< double >(
size.height() ) ) / 100.0;
3271 if (
static_cast< int >( width ) < 1 || 10000.0 < width ||
static_cast< int >( height ) < 1 || 10000.0 < height )
3274 calculateOffsetAndRotation( context, width, height, outputOffset,
angle );
3284 if ( !
size.isNull() &&
size.isValid() &&
size.width() > 0 )
3286 height = width * (
static_cast< double >(
size.height() ) /
static_cast< double >(
size.width() ) );
3291 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
3294 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3298 p->translate( point + outputOffset );
3313 if ( !img.isNull() )
3316 if ( useSelectedColor )
3321 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
3327 bool cached =
false;
3331double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
3333 double scaledSize =
mSize;
3337 if ( hasDataDefinedSize )
3345 if ( hasDataDefinedSize )
3352 if ( hasDataDefinedSize && ok )
3357 scaledSize = std::sqrt( scaledSize );
3370 if ( !hasDataDefinedAspectRatio )
3380 const double defaultHeight =
mSize * scaledAspectRatio;
3381 scaledAspectRatio = defaultHeight / scaledSize;
3384 double scaledHeight = scaledSize * scaledAspectRatio;
3391 if ( hasDataDefinedAspectRatio && ok )
3396 scaledHeight = sqrt( scaledHeight );
3403 scaledAspectRatio = scaledHeight / scaledSize;
3405 return scaledAspectRatio;
3408void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const
3413 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
3414 offset = QPointF( offsetX, offsetY );
3424 if ( hasDataDefinedRotation )
3426 const QgsFeature *f = context.
feature();
3445 map[u
"imageFile"_s] =
mPath;
3446 map[u
"size"_s] = QString::number(
mSize );
3450 map[u
"angle"_s] = QString::number(
mAngle );
3451 map[u
"alpha"_s] = QString::number(
mOpacity );
3457 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
3463 auto m = std::make_unique< QgsRasterMarkerSymbolLayer >();
3511 bool hasDataDefinedSize =
false;
3512 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3514 bool hasDataDefinedAspectRatio =
false;
3515 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3519 if (
static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
3524 QPointF outputOffset;
3526 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3528 QTransform transform;
3531 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3534 transform.rotate(
angle );
3536 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
3541 return symbolBounds;
3556 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
3557 element.appendChild( graphicElem );
3560 QDomElement extGraphElem = doc.createElement( u
"se:ExternalGraphic"_s );
3561 graphicElem.appendChild( extGraphElem );
3563 QMimeDatabase mimeDB;
3567 if (
mPath.startsWith(
"base64:"_L1 ) )
3569 base64data =
mPath.mid( 7 );
3581 if ( !base64data.isEmpty() )
3584 QDomElement inlineContEleme = doc.createElement( u
"se:InlineContent"_s );
3586 inlineContEleme.setAttribute( u
"encoding"_s, u
"base64"_s );
3587 inlineContEleme.appendChild( doc.createTextNode( base64data ) );
3588 extGraphElem.appendChild( inlineContEleme );
3591 const QByteArray ba = QByteArray::fromBase64( base64data.toUtf8() );
3592 mimeType = mimeDB.mimeTypeForData( ba );
3597 QDomElement onlineResElem = doc.createElement( u
"se:OnlineResource"_s );
3598 QString url =
mPath;
3600 onlineResElem.setAttribute( u
"xlink:href"_s, url );
3601 onlineResElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
3602 extGraphElem.appendChild( onlineResElem );
3605 if (
mPath.startsWith(
"http://"_L1 ) ||
mPath.startsWith(
"https://"_L1 ) )
3609 mimeType = mimeDB.mimeTypeForName(
"image/png" );
3613 mimeType = mimeDB.mimeTypeForUrl( url );
3617 QDomElement formatElem = doc.createElement( u
"se:Format"_s );
3618 formatElem.appendChild( doc.createTextNode( mimeType.name() ) );
3619 extGraphElem.appendChild( formatElem );
3634 mOrigSize = pointSize;
3654 if ( props.contains( u
"font"_s ) )
3656 if ( props.contains( u
"chr"_s ) && props[u
"chr"_s].toString().length() > 0 )
3658 string = props[
"chr"].toString();
3659 const thread_local QRegularExpression charRegExp( u
"%1([0-9]+)%1"_s.arg(
FONTMARKER_CHR_FIX ) );
3660 QRegularExpressionMatch match = charRegExp.match(
string );
3661 while ( match.hasMatch() )
3663 QChar replacement = QChar( match.captured( 1 ).toUShort() );
3664 string =
string.mid( 0, match.capturedStart( 0 ) ) + replacement +
string.mid( match.capturedEnd( 0 ) );
3665 match = charRegExp.match(
string );
3669 if ( props.contains( u
"size"_s ) )
3670 pointSize = props[u
"size"_s].toDouble();
3671 if ( props.contains( u
"color"_s ) )
3673 if ( props.contains( u
"angle"_s ) )
3674 angle = props[u
"angle"_s].toDouble();
3678 if ( props.contains( u
"font_style"_s ) )
3680 if ( props.contains( u
"outline_color"_s ) )
3682 if ( props.contains( u
"outline_width"_s ) )
3684 if ( props.contains( u
"offset"_s ) )
3686 if ( props.contains( u
"offset_unit"_s ) )
3688 if ( props.contains( u
"offset_map_unit_scale"_s ) )
3690 if ( props.contains( u
"size_unit"_s ) )
3692 if ( props.contains( u
"size_map_unit_scale"_s ) )
3694 if ( props.contains( u
"outline_width_unit"_s ) )
3696 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
3698 if ( props.contains( u
"joinstyle"_s ) )
3700 if ( props.contains( u
"horizontal_anchor_point"_s ) )
3702 if ( props.contains( u
"vertical_anchor_point"_s ) )
3712 return u
"FontMarker"_s;
3722 QColor brushColor =
mColor;
3723 QColor penColor = mStrokeColor;
3725 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3726 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3728 mBrush = QBrush( brushColor );
3729 mPen = QPen( penColor );
3730 mPen.setJoinStyle( mPenJoinStyle );
3734 if ( !mFontStyle.isEmpty() )
3742 if ( mNonZeroFontSize && sizePixels > MAX_FONT_CHARACTER_SIZE_IN_PIXELS )
3747 mFontSizeScale = sizePixels / MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3748 sizePixels = MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3751 mFontSizeScale = 1.0;
3755 mFont.setPixelSize( std::max( 2,
static_cast< int >( std::round( sizePixels ) ) ) );
3756 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
3757 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3762 mChrOffset = QPointF( mChrWidth / 2.0, -sizePixels / 2.0 );
3769 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3779 if ( mUseCachedPath )
3781 QPointF chrOffset = mChrOffset;
3783 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3784 mCachedPath = QPainterPath();
3785 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3794QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3796 charOffset = mChrOffset;
3797 QString stringToRender = mString;
3802 if ( stringToRender != mString )
3804 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3810 charOffset = QPointF( charWidth / 2.0, -sizePixels / 2.0 );
3817 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3823 return stringToRender;
3828 bool &hasDataDefinedRotation,
3830 double &angle )
const
3835 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3836 offset = QPointF( offsetX, offsetY );
3837 hasDataDefinedRotation =
false;
3851 hasDataDefinedRotation =
true;
3855 if ( hasDataDefinedRotation )
3862 const QgsFeature *f = context.
feature();
3879 double scaledSize =
mSize;
3883 if ( hasDataDefinedSize )
3889 if ( hasDataDefinedSize && ok )
3894 scaledSize = std::sqrt( scaledSize );
3906 if ( !p || !mNonZeroFontSize )
3909 QTransform transform;
3912 QColor brushColor =
mColor;
3922 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3924 mBrush.setColor( brushColor );
3926 QColor penColor = mStrokeColor;
3932 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3956 p->setBrush( mBrush );
3959 mPen.setColor( penColor );
3960 mPen.setWidthF( penWidth );
3965 p->setPen( Qt::NoPen );
3983 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
3986 QPointF chrOffset = mChrOffset;
3988 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3990 const double sizeToRender = calculateSize( context );
3992 bool hasDataDefinedRotation =
false;
3995 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation,
offset,
angle );
3997 p->translate( point.x() +
offset.x(), point.y() +
offset.y() );
4000 transform.rotate(
angle );
4004 const double s = sizeToRender / mOrigSize;
4005 transform.scale( s, s );
4009 transform.scale( mFontSizeScale, mFontSizeScale );
4011 if ( mUseCachedPath )
4013 p->drawPath( transform.map( mCachedPath ) );
4018 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
4019 p->drawPath( transform.map( path ) );
4026 props[u
"font"_s] = mFontFamily;
4027 props[u
"font_style"_s] = mFontStyle;
4028 QString chr = mString;
4029 for (
int i = 0; i < 32; i++ )
4031 if ( i == 9 || i == 10 || i == 13 )
4035 chr.replace( QChar( i ), u
"%1%2%1"_s.arg(
FONTMARKER_CHR_FIX, QString::number( i ) ) );
4037 props[u
"chr"_s] = chr;
4038 props[u
"size"_s] = QString::number(
mSize );
4043 props[u
"outline_width"_s] = QString::number( mStrokeWidth );
4047 props[u
"angle"_s] = QString::number(
mAngle );
4052 props[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
4080 toSld( doc, element, context );
4098 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
4099 element.appendChild( graphicElem );
4102 const QString fontPath = u
"ttf://%1"_s.arg( mFontFamily );
4103 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
4110 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
4113 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
4137 mStrokeWidthUnit = unit;
4142 QPointF chrOffset = mChrOffset;
4143 double chrWidth = mChrWidth;
4145 ( void )characterToRender( context, chrOffset, chrWidth );
4147 if ( !mFontMetrics )
4148 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
4150 double scaledSize = calculateSize( context );
4153 chrWidth *= scaledSize / mOrigSize;
4155 chrWidth *= mFontSizeScale;
4157 bool hasDataDefinedRotation =
false;
4160 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation,
offset,
angle );
4163 QTransform transform;
4166 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
4169 transform.rotate(
angle );
4171 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
4175 return symbolBounds;
4182 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
4183 if ( graphicElem.isNull() )
4186 QString name, format;
4194 if ( !name.startsWith(
"ttf://"_L1 ) || format !=
"ttf"_L1 )
4204 const double d = angleFunc.toDouble( &ok );
4212 double scaleFactor = 1.0;
4213 const QString uom = element.attribute( u
"uom"_s );
4234 context.
pushMessage( QObject::tr(
"Font “%1” not available on system" ).arg( processedFamily ) );
4240 QMap<QString, QgsProperty>::iterator it =
mParameters.begin();
4252 QMap<QString, QgsProperty>::const_iterator it =
mParameters.constBegin();
4255 attrs.unite( it.value().referencedFields( context.
expressionContext(),
true ) );
4286 auto m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
path,
size,
angle );
4287 m->setFrameRate(
properties.value( u
"frameRate"_s, u
"10"_s ).toDouble() );
4295 return u
"AnimatedMarker"_s;
4301 res.insert( u
"frameRate"_s, mFrameRateFps );
4307 auto m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
4308 m->setFrameRate( mFrameRateFps );
4317 mPreparedPaths.clear();
4325 mStaticPath =
false;
4331 if ( !mStaticPath && !mPreparedPaths.contains(
path ) )
4334 mPreparedPaths.insert(
path );
4337 const long long mapFrameNumber = context.
currentFrame();
4339 const double markerAnimationDuration = totalFrameCount / mFrameRateFps;
4341 double animationTimeSeconds = 0;
4342 if ( mapFrameNumber >= 0 && context.
frameRate() > 0 )
4345 animationTimeSeconds = mapFrameNumber / context.
frameRate();
4350 animationTimeSeconds = QDateTime::currentMSecsSinceEpoch() / 1000.0;
4353 const double markerAnimationProgressSeconds = std::fmod( animationTimeSeconds, markerAnimationDuration );
4354 const int movieFrame =
static_cast< int >( std::floor( markerAnimationProgressSeconds * mFrameRateFps ) );
4356 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.
void copyCommonProperties(QgsSymbolLayer *destLayer) const
Copies all common base class properties from this layer to another symbol layer.
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.
@ 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.
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