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 )
191 const double half = scaledSize / 2.0;
192 transform.scale( half, half );
198 transform.rotate(
mAngle );
225 bool hasDataDefinedSize =
false;
226 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
228 bool hasDataDefinedRotation =
false;
234 bool createdNewPath =
false;
252 createdNewPath =
true;
261 QTransform transform;
264 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
267 if ( hasDataDefinedSize || createdNewPath )
277 const double half = s / 2.0;
278 transform.scale( half, half );
283 transform.rotate(
angle );
292 polygon = transform.map(
mPolygon );
296 path = transform.map(
mPath );
298 draw( context, symbol, polygon, path );
303 bool hasDataDefinedSize =
false;
304 double scaledSize =
calculateSize( context, hasDataDefinedSize );
306 bool hasDataDefinedRotation =
false;
313 QTransform transform;
316 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
319 transform.rotate(
angle );
321 return transform.mapRect( QRectF( -scaledSize / 2.0, -scaledSize / 2.0, scaledSize, scaledSize ) );
328 const QString cleaned = name.toLower().trimmed();
330 if ( cleaned ==
"square"_L1 || cleaned ==
"rectangle"_L1 )
332 else if ( cleaned ==
"trapezoid"_L1 )
334 else if ( cleaned ==
"parallelogram_right"_L1 )
336 else if ( cleaned ==
"parallelogram_left"_L1 )
338 else if ( cleaned ==
"square_with_corners"_L1 )
340 else if ( cleaned ==
"rounded_square"_L1 )
342 else if ( cleaned ==
"diamond"_L1 )
344 else if ( cleaned ==
"shield"_L1 )
346 else if ( cleaned ==
"pentagon"_L1 )
348 else if ( cleaned ==
"hexagon"_L1 )
350 else if ( cleaned ==
"octagon"_L1 )
352 else if ( cleaned ==
"decagon"_L1 )
354 else if ( cleaned ==
"triangle"_L1 )
356 else if ( cleaned ==
"equilateral_triangle"_L1 )
358 else if ( cleaned ==
"star_diamond"_L1 )
360 else if ( cleaned ==
"star"_L1 || cleaned ==
"regular_star"_L1 )
362 else if ( cleaned ==
"heart"_L1 )
364 else if ( cleaned ==
"arrow"_L1 )
366 else if ( cleaned ==
"circle"_L1 )
368 else if ( cleaned ==
"cross"_L1 )
370 else if ( cleaned ==
"cross_fill"_L1 )
372 else if ( cleaned ==
"cross2"_L1 || cleaned ==
"x"_L1 )
374 else if ( cleaned ==
"line"_L1 )
376 else if ( cleaned ==
"arrowhead"_L1 )
378 else if ( cleaned ==
"filled_arrowhead"_L1 )
380 else if ( cleaned ==
"semi_circle"_L1 )
382 else if ( cleaned ==
"third_circle"_L1 )
384 else if ( cleaned ==
"quarter_circle"_L1 )
386 else if ( cleaned ==
"quarter_square"_L1 )
388 else if ( cleaned ==
"half_square"_L1 )
390 else if ( cleaned ==
"diagonal_half_square"_L1 )
392 else if ( cleaned ==
"right_half_triangle"_L1 )
394 else if ( cleaned ==
"left_half_triangle"_L1 )
396 else if ( cleaned ==
"asterisk_fill"_L1 )
398 else if ( cleaned ==
"half_arc"_L1 )
400 else if ( cleaned ==
"third_arc"_L1 )
402 else if ( cleaned ==
"quarter_arc"_L1 )
417 return u
"quarter_square"_s;
419 return u
"half_square"_s;
421 return u
"diagonal_half_square"_s;
423 return u
"parallelogram_right"_s;
425 return u
"parallelogram_left"_s;
427 return u
"trapezoid"_s;
433 return u
"pentagon"_s;
441 return u
"square_with_corners"_s;
443 return u
"rounded_square"_s;
445 return u
"triangle"_s;
447 return u
"equilateral_triangle"_s;
449 return u
"left_half_triangle"_s;
451 return u
"right_half_triangle"_s;
453 return u
"star_diamond"_s;
461 return u
"filled_arrowhead"_s;
463 return u
"cross_fill"_s;
473 return u
"arrowhead"_s;
475 return u
"semi_circle"_s;
477 return u
"third_circle"_s;
479 return u
"quarter_circle"_s;
481 return u
"asterisk_fill"_s;
483 return u
"half_arc"_s;
485 return u
"third_arc"_s;
487 return u
"quarter_arc"_s;
504 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
509 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 0.6072;
512 << 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 ) << QPointF( 1, 0.5 ) << QPointF( -1, 0.5 ) << QPointF( -0.5, -0.5 ) << QPointF( 0.5, -0.5 );
541 polygon << QPointF( 0.5, 0.5 ) << QPointF( 1, -0.5 ) << QPointF( -0.5, -0.5 ) << QPointF( -1, 0.5 ) << QPointF( 0.5, 0.5 );
545 polygon << QPointF( 1, 0.5 ) << QPointF( 0.5, -0.5 ) << QPointF( -1, -0.5 ) << QPointF( -0.5, 0.5 ) << QPointF( 1, 0.5 );
549 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 ) << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
553 polygon << QPointF( 1, 0.5 ) << QPointF( 1, -1 ) << QPointF( -1, -1 ) << QPointF( -1, 0.5 ) << QPointF( 0, 1 ) << QPointF( 1, 0.5 );
563 polygon << QPointF( -0.9511, -0.3090 ) << QPointF( -0.5878, 0.8090 ) << QPointF( 0.5878, 0.8090 ) << QPointF( 0.9511, -0.3090 ) << QPointF( 0, -1 ) << QPointF( -0.9511, -0.3090 );
574 polygon << QPointF( -0.8660, -0.5 ) << QPointF( -0.8660, 0.5 ) << QPointF( 0, 1 ) << QPointF( 0.8660, 0.5 ) << QPointF( 0.8660, -0.5 ) << QPointF( 0, -1 ) << QPointF( -0.8660, -0.5 );
579 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 1.0 / ( 1 + M_SQRT2 );
582 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 )
583 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
584 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
585 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
586 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
587 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
588 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
589 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
590 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
597 << QPointF( 0.587785252, 0.809016994 )
598 << QPointF( 0.951056516, 0.309016994 )
599 << QPointF( 0.951056516, -0.309016994 )
600 << QPointF( 0.587785252, -0.809016994 )
602 << QPointF( -0.587785252, -0.809016994 )
603 << QPointF( -0.951056516, -0.309016994 )
604 << QPointF( -0.951056516, 0.309016994 )
605 << QPointF( -0.587785252, 0.809016994 )
607 << QPointF( 0.587785252, 0.809016994 );
612 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
620 polygon << QPointF( -0.8660, 0.5 ) << QPointF( 0.8660, 0.5 ) << QPointF( 0, -1 ) << QPointF( -0.8660, 0.5 );
624 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
628 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
633 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
636 << QPointF( inner_r * std::sin(
DEG2RAD( 315.0 ) ), -inner_r * std::cos(
DEG2RAD( 315.0 ) ) )
637 << QPointF( std::sin(
DEG2RAD( 270 ) ), -std::cos(
DEG2RAD( 270 ) ) )
638 << QPointF( inner_r * std::sin(
DEG2RAD( 225.0 ) ), -inner_r * std::cos(
DEG2RAD( 225.0 ) ) )
639 << QPointF( std::sin(
DEG2RAD( 180 ) ), -std::cos(
DEG2RAD( 180 ) ) )
640 << QPointF( inner_r * std::sin(
DEG2RAD( 135.0 ) ), -inner_r * std::cos(
DEG2RAD( 135.0 ) ) )
641 << QPointF( std::sin(
DEG2RAD( 90 ) ), -std::cos(
DEG2RAD( 90 ) ) )
642 << QPointF( inner_r * std::sin(
DEG2RAD( 45.0 ) ), -inner_r * std::cos(
DEG2RAD( 45.0 ) ) )
644 << QPointF( inner_r * std::sin(
DEG2RAD( 315.0 ) ), -inner_r * std::cos(
DEG2RAD( 315.0 ) ) );
650 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
653 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), -inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
654 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), -std::cos(
DEG2RAD( 288 ) ) )
655 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), -inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
656 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), -std::cos(
DEG2RAD( 216.0 ) ) )
657 << QPointF( 0, inner_r )
658 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), -std::cos(
DEG2RAD( 144.0 ) ) )
659 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), -inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
660 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), -std::cos(
DEG2RAD( 72.0 ) ) )
661 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), -inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
663 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), -inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
668 polygon << QPointF( 0, -1 ) << QPointF( 0.5, -0.5 ) << QPointF( 0.25, -0.5 ) << QPointF( 0.25, 1 ) << QPointF( -0.25, 1 ) << QPointF( -0.25, -0.5 ) << QPointF( -0.5, -0.5 ) << QPointF( 0, -1 );
672 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
677 << QPointF( -1, -0.2 )
678 << QPointF( -1, -0.2 )
679 << QPointF( -1, 0.2 )
680 << QPointF( -0.2, 0.2 )
681 << QPointF( -0.2, 1 )
683 << QPointF( 0.2, 0.2 )
685 << QPointF( 1, -0.2 )
686 << QPointF( 0.2, -0.2 )
687 << QPointF( 0.2, -1 )
688 << QPointF( -0.2, -1 )
689 << QPointF( -0.2, -0.2 )
690 << QPointF( -1, -0.2 );
695 static constexpr double THICKNESS = 0.3;
696 static constexpr double HALF_THICKNESS = THICKNESS / 2.0;
697 static constexpr double INTERSECTION_POINT = THICKNESS / M_SQRT2;
698 static constexpr double DIAGONAL1 = M_SQRT1_2 - INTERSECTION_POINT * 0.5;
699 static constexpr double DIAGONAL2 = M_SQRT1_2 + INTERSECTION_POINT * 0.5;
702 << QPointF( -HALF_THICKNESS, -1 )
703 << QPointF( HALF_THICKNESS, -1 )
704 << QPointF( HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
705 << QPointF( DIAGONAL1, -DIAGONAL2 )
706 << QPointF( DIAGONAL2, -DIAGONAL1 )
707 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, -HALF_THICKNESS )
708 << QPointF( 1, -HALF_THICKNESS )
709 << QPointF( 1, HALF_THICKNESS )
710 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, HALF_THICKNESS )
711 << QPointF( DIAGONAL2, DIAGONAL1 )
712 << QPointF( DIAGONAL1, DIAGONAL2 )
713 << QPointF( HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
714 << QPointF( HALF_THICKNESS, 1 )
715 << QPointF( -HALF_THICKNESS, 1 )
716 << QPointF( -HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
717 << QPointF( -DIAGONAL1, DIAGONAL2 )
718 << QPointF( -DIAGONAL2, DIAGONAL1 )
719 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, HALF_THICKNESS )
720 << QPointF( -1, HALF_THICKNESS )
721 << QPointF( -1, -HALF_THICKNESS )
722 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, -HALF_THICKNESS )
723 << QPointF( -DIAGONAL2, -DIAGONAL1 )
724 << QPointF( -DIAGONAL1, -DIAGONAL2 )
725 << QPointF( -HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
726 << QPointF( -HALF_THICKNESS, -1 );
751 mPath = QPainterPath();
757 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
761 mPath.moveTo( -1, -1 );
762 mPath.addRoundedRect( -1, -1, 2, 2, 0.25, 0.25 );
766 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
767 mPath.lineTo( 0, 0 );
771 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
772 mPath.lineTo( 0, 0 );
776 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
777 mPath.lineTo( 0, 0 );
781 mPath.moveTo( 1, 0 );
782 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
786 mPath.moveTo( 0, -1 );
787 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
791 mPath.moveTo( 0, -1 );
792 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
796 mPath.moveTo( -1, 0 );
797 mPath.lineTo( 1, 0 );
798 mPath.moveTo( 0, -1 );
799 mPath.lineTo( 0, 1 );
803 mPath.moveTo( -1, -1 );
804 mPath.lineTo( 1, 1 );
805 mPath.moveTo( 1, -1 );
806 mPath.lineTo( -1, 1 );
810 mPath.moveTo( 0, -1 );
811 mPath.lineTo( 0, 1 );
815 mPath.moveTo( -1, -1 );
816 mPath.lineTo( 0, 0 );
817 mPath.lineTo( -1, 1 );
821 mPath.moveTo( 0, 0.75 );
822 mPath.arcTo( 0, -1, 1, 1, -45, 210 );
823 mPath.arcTo( -1, -1, 1, 1, 15, 210 );
824 mPath.lineTo( 0, 0.75 );
858 double scaledSize =
mSize;
862 if ( hasDataDefinedSize )
868 if ( hasDataDefinedSize && ok )
873 scaledSize = std::sqrt( scaledSize );
888 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
889 offset = QPointF( offsetX, offsetY );
891 hasDataDefinedRotation =
false;
904 hasDataDefinedRotation =
true;
909 if ( hasDataDefinedRotation )
958 if ( props.contains( u
"name"_s ) )
962 if ( props.contains( u
"color"_s ) )
964 if ( props.contains( u
"color_border"_s ) )
969 else if ( props.contains( u
"outline_color"_s ) )
973 else if ( props.contains( u
"line_color"_s ) )
977 if ( props.contains( u
"joinstyle"_s ) )
981 if ( props.contains( u
"size"_s ) )
982 size = props[u
"size"_s].toDouble();
983 if ( props.contains( u
"angle"_s ) )
984 angle = props[u
"angle"_s].toDouble();
985 if ( props.contains( u
"scale_method"_s ) )
989 if ( props.contains( u
"offset"_s ) )
991 if ( props.contains( u
"offset_unit"_s ) )
993 if ( props.contains( u
"offset_map_unit_scale"_s ) )
995 if ( props.contains( u
"size_unit"_s ) )
997 if ( props.contains( u
"size_map_unit_scale"_s ) )
1000 if ( props.contains( u
"outline_style"_s ) )
1004 else if ( props.contains( u
"line_style"_s ) )
1008 if ( props.contains( u
"outline_width"_s ) )
1012 else if ( props.contains( u
"line_width"_s ) )
1016 if ( props.contains( u
"outline_width_unit"_s ) )
1020 if ( props.contains( u
"line_width_unit"_s ) )
1024 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
1029 if ( props.contains( u
"horizontal_anchor_point"_s ) )
1033 if ( props.contains( u
"vertical_anchor_point"_s ) )
1038 if ( props.contains( u
"cap_style"_s ) )
1051 return u
"SimpleMarker"_s;
1063 QColor brushColor =
mColor;
1066 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
1069 mBrush = QBrush( brushColor );
1070 mPen = QPen( penColor );
1080 selBrushColor.setAlphaF( context.
opacity() );
1081 selPenColor.setAlphaF( context.
opacity() );
1084 mSelPen = QPen( selPenColor );
1095 && !hasDataDefinedSize
1105 mCachedOpacity = context.
opacity();
1111 mSelPen.setColor( selBrushColor );
1145 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
1148 const double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
1149 const int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
1150 const double center = imageSize / 2.0;
1156 mCache = QImage( QSize( imageSize * deviceRatio, imageSize * deviceRatio ), QImage::Format_ARGB32_Premultiplied );
1166 p.setRenderHint( QPainter::Antialiasing );
1167 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1169 p.translate( QPointF( center, center ) );
1177 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
1181 p.setRenderHint( QPainter::Antialiasing );
1182 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
1184 p.translate( QPointF( center, center ) );
1195 p.setRenderHint( QPainter::Antialiasing );
1196 p.fillRect( 0, 0, imageSize, imageSize, selColor );
1197 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1199 p.translate( QPointF( center, center ) );
1218 QColor brushColor =
mColor;
1219 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
1220 mBrush.setColor( brushColor );
1223 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
1224 mPen.setColor( penColor );
1233 c.setAlphaF(
c.alphaF() * context.
opacity() );
1243 c.setAlphaF(
c.alphaF() * context.
opacity() );
1296 p->setBrush( Qt::NoBrush );
1300 if ( !polygon.isEmpty() )
1301 p->drawPolygon( polygon );
1303 p->drawPath( path );
1321 const double s = img.width() / img.devicePixelRatioF();
1323 bool hasDataDefinedSize =
false;
1324 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
1326 bool hasDataDefinedRotation =
false;
1331 p->drawImage( QRectF( point.x() - s / 2.0 +
offset.x(), point.y() - s / 2.0 +
offset.y(), s, s ), img );
1345 map[u
"size"_s] = QString::number(
mSize );
1348 map[u
"angle"_s] = QString::number(
mAngle );
1354 map[u
"outline_width"_s] = QString::number(
mStrokeWidth );
1360 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
1387 toSld( doc, element, context );
1405 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
1406 element.appendChild( graphicElem );
1423 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
1426 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
1444 Q_UNUSED( mmScaleFactor )
1445 Q_UNUSED( mapUnitScaleFactor )
1447 QString ogrType =
"3";
1448 if ( mName ==
"square" )
1452 else if ( mName ==
"triangle" )
1456 else if ( mName ==
"star" )
1460 else if ( mName ==
"circle" )
1464 else if ( mName ==
"cross" )
1468 else if ( mName ==
"x" || mName ==
"cross2" )
1472 else if ( mName ==
"line" )
1478 ogrString.append(
"SYMBOL(" );
1479 ogrString.append(
"id:" );
1480 ogrString.append(
'\"' );
1481 ogrString.append(
"ogr-sym-" );
1482 ogrString.append( ogrType );
1483 ogrString.append(
'\"' );
1484 ogrString.append(
",c:" );
1485 ogrString.append(
mColor.name() );
1486 ogrString.append(
",o:" );
1488 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1489 ogrString.append(
')' );
1494 ogrString.append(
"PEN(" );
1495 ogrString.append(
"c:" );
1496 ogrString.append(
mColor.name() );
1497 ogrString.append(
",w:" );
1498 ogrString.append( QString::number(
mSize ) );
1499 ogrString.append(
"mm" );
1500 ogrString.append(
")" );
1508 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
1509 if ( graphicElem.isNull() )
1512 QString name = u
"square"_s;
1525 const double d = angleFunc.toDouble( &ok );
1535 double scaleFactor = 1.0;
1536 const QString uom = element.attribute( u
"uom"_s );
1563 p->drawPath(
mPath );
1576 if ( hasDataDefinedSize )
1595 size *= mmMapUnitScaleFactor;
1602 const double halfSize =
size / 2.0;
1619 QColor pc =
mPen.color();
1620 QColor bc =
mBrush.color();
1640 QPointF off( offsetX, offsetY );
1669 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1677 t.scale( halfSize, -halfSize );
1679 polygon = t.map( polygon );
1682 p.reserve( polygon.size() );
1683 for (
int i = 0; i < polygon.size(); i++ )
1688 if (
mBrush.style() != Qt::NoBrush )
1690 if (
mPen.style() != Qt::NoPen )
1695 shift += QPointF( off.x(), -off.y() );
1696 if (
mBrush.style() != Qt::NoBrush )
1698 if (
mPen.style() != Qt::NoPen )
1703 const QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1704 const QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1706 if (
mPen.style() != Qt::NoPen )
1711 if (
mPen.style() != Qt::NoPen )
1713 const QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1714 const QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1715 const QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1716 const QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1724 if (
mPen.style() != Qt::NoPen )
1726 const QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1727 const QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1728 const QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1729 const QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1737 if (
mPen.style() != Qt::NoPen )
1739 const QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1740 const QPointF pt2 = t.map( QPointF( 0, 0 ) );
1741 const QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1830 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0, penWidth / 2.0, penWidth / 2.0 );
1832 return symbolBounds;
1879 if ( props.contains( u
"name"_s ) )
1880 name = props[u
"name"_s].toString();
1881 if ( props.contains( u
"size"_s ) )
1882 size = props[u
"size"_s].toDouble();
1883 if ( props.contains( u
"angle"_s ) )
1884 angle = props[u
"angle"_s].toDouble();
1885 if ( props.contains( u
"scale_method"_s ) )
1889 if ( props.contains( u
"offset"_s ) )
1891 if ( props.contains( u
"offset_unit"_s ) )
1893 if ( props.contains( u
"offset_map_unit_scale"_s ) )
1895 if ( props.contains( u
"size_unit"_s ) )
1897 if ( props.contains( u
"size_map_unit_scale"_s ) )
1899 if ( props.contains( u
"horizontal_anchor_point"_s ) )
1903 if ( props.contains( u
"vertical_anchor_point"_s ) )
1917 return u
"FilledMarker"_s;
1957 map[u
"size"_s] = QString::number(
mSize );
1960 map[u
"angle"_s] = QString::number(
mAngle );
1966 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
2015 attr.unite( mFill->usedAttributes( context ) );
2023 if ( mFill && mFill->hasDataDefinedProperties() )
2032 mFill->setColor(
c );
2037 return mFill ? mFill->color() :
mColor;
2046 || ( mFill && mFill->usesMapUnits() );
2053 mFill->setOutputUnit( unit );
2067 const double prevOpacity = mFill->opacity();
2068 mFill->setOpacity( mFill->opacity() * context.
opacity() );
2072 p->setBrush( Qt::red );
2076 p->setBrush( Qt::NoBrush );
2078 p->setPen( Qt::black );
2084 if ( !polygon.isEmpty() )
2086 mFill->renderPolygon( polygon,
nullptr, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2090 const QPolygonF poly = path.toFillPolygon();
2091 mFill->renderPolygon( poly,
nullptr, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2096 mFill->setOpacity( prevOpacity );
2111 mColor = QColor( 35, 35, 35 );
2138 if ( props.contains( u
"name"_s ) )
2139 name = props[u
"name"_s].toString();
2140 if ( props.contains( u
"size"_s ) )
2141 size = props[u
"size"_s].toDouble();
2142 if ( props.contains( u
"angle"_s ) )
2143 angle = props[u
"angle"_s].toDouble();
2144 if ( props.contains( u
"scale_method"_s ) )
2149 if ( props.contains( u
"size_unit"_s ) )
2151 if ( props.contains( u
"size_map_unit_scale"_s ) )
2153 if ( props.contains( u
"fixedAspectRatio"_s ) )
2155 if ( props.contains( u
"offset"_s ) )
2157 if ( props.contains( u
"offset_unit"_s ) )
2159 if ( props.contains( u
"offset_map_unit_scale"_s ) )
2161 if ( props.contains( u
"fill"_s ) )
2166 else if ( props.contains( u
"color"_s ) )
2170 if ( props.contains( u
"outline"_s ) )
2175 else if ( props.contains( u
"outline_color"_s ) )
2179 else if ( props.contains( u
"line_color"_s ) )
2184 if ( props.contains( u
"outline-width"_s ) )
2189 else if ( props.contains( u
"outline_width"_s ) )
2193 else if ( props.contains( u
"line_width"_s ) )
2198 if ( props.contains( u
"outline_width_unit"_s ) )
2202 else if ( props.contains( u
"line_width_unit"_s ) )
2206 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
2209 if ( props.contains( u
"horizontal_anchor_point"_s ) )
2213 if ( props.contains( u
"vertical_anchor_point"_s ) )
2222 if ( props.contains( u
"parameters"_s ) )
2224 const QVariantMap
parameters = props[u
"parameters"_s].toMap();
2233 const QVariantMap::iterator it =
properties.find( u
"name"_s );
2252 QColor defaultFillColor, defaultStrokeColor;
2254 bool hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
2255 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
2259 hasDefaultFillColor,
2261 hasFillOpacityParam,
2262 hasDefaultFillOpacity,
2265 hasDefaultStrokeColor,
2267 hasStrokeWidthParam,
2268 hasDefaultStrokeWidth,
2270 hasStrokeOpacityParam,
2271 hasDefaultStrokeOpacity,
2275 const double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
2276 const double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
2278 if ( hasDefaultFillColor )
2280 defaultFillColor.setAlphaF( newFillOpacity );
2283 if ( hasDefaultFillOpacity )
2286 c.setAlphaF( fillOpacity );
2289 if ( hasDefaultStrokeColor )
2291 defaultStrokeColor.setAlphaF( newStrokeOpacity );
2294 if ( hasDefaultStrokeWidth )
2298 if ( hasDefaultStrokeOpacity )
2301 c.setAlphaF( strokeOpacity );
2315 const double widthScaleFactor = 3.465;
2318 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
2326 if ( aPreservedAspectRatio && !par )
2330 else if ( !aPreservedAspectRatio && par )
2345 return u
"SvgMarker"_s;
2370 bool hasDataDefinedSize =
false;
2371 const double scaledWidth = calculateSize( context, hasDataDefinedSize );
2376 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
2383 bool hasDataDefinedAspectRatio =
false;
2384 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2425 const QSizeF svgViewbox
2428 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2432 QPointF outputOffset;
2434 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2436 p->translate( point + outputOffset );
2442 bool fitsInCache =
true;
2443 bool usePict =
true;
2445 if ( ( !context.
forceVectorRendering() && !rotated ) || ( useSelectedColor && rasterizeSelected ) )
2450 if ( fitsInCache && img.width() > 1 )
2454 if ( useSelectedColor )
2462 QImage transparentImage = img.copy();
2464 if ( devicePixelRatio == 1 )
2466 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2470 p->drawImage( QRectF( -transparentImage.width() / 2.0 / devicePixelRatio, -transparentImage.height() / 2.0 / devicePixelRatio, transparentImage.width() / devicePixelRatio, transparentImage.height() / devicePixelRatio ), transparentImage );
2475 if ( devicePixelRatio == 1 )
2477 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2481 p->drawImage( QRectF( -img.width() / 2.0 / devicePixelRatio, -img.height() / 2.0 / devicePixelRatio, img.width() / devicePixelRatio, img.height() / devicePixelRatio ), img );
2487 if ( usePict || !fitsInCache )
2489 p->setOpacity( context.
opacity() );
2493 if ( pct.width() > 1 )
2503double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2505 double scaledSize =
mSize;
2509 if ( hasDataDefinedSize )
2517 if ( hasDataDefinedSize )
2524 if ( hasDataDefinedSize && ok )
2529 scaledSize = std::sqrt( scaledSize );
2542 if ( !hasDataDefinedAspectRatio )
2552 const double defaultHeight =
mSize * scaledAspectRatio;
2553 scaledAspectRatio = defaultHeight / scaledSize;
2556 double scaledHeight = scaledSize * scaledAspectRatio;
2563 if ( hasDataDefinedAspectRatio && ok )
2568 scaledHeight = sqrt( scaledHeight );
2575 scaledAspectRatio = scaledHeight / scaledSize;
2577 return scaledAspectRatio;
2580void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const
2585 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2586 offset = QPointF( offsetX, offsetY );
2596 if ( hasDataDefinedRotation )
2603 const QgsFeature *f = context.
feature();
2622 map[u
"name"_s] =
mPath;
2623 map[u
"size"_s] = QString::number(
mSize );
2627 map[u
"angle"_s] = QString::number(
mAngle );
2634 map[u
"outline_width"_s] = QString::number(
mStrokeWidth );
2638 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
2664 toSld( doc, element, context );
2713 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
2714 element.appendChild( graphicElem );
2725 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
2728 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
2747 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
2748 if ( graphicElem.isNull() )
2751 QString
path, mimeType;
2759 double scaleFactor = 1.0;
2760 const QString uom = element.attribute( u
"uom"_s );
2764 if ( mimeType !=
"image/svg+xml"_L1 )
2772 const double d = angleFunc.toDouble( &ok );
2781 QString realPath {
path };
2782 QUrl svgUrl {
path };
2785 QUrlQuery queryString;
2787 if ( svgUrl.hasQuery() && svgUrl.hasFragment() )
2789 const QString queryPart {
path.mid(
path.indexOf(
'?' ) + 1 ) };
2790 queryString.setQuery( queryPart );
2794 if ( svgUrl.scheme().isEmpty() || svgUrl.isLocalFile() )
2796 svgUrl.setQuery( QString() );
2797 realPath = svgUrl.path();
2802 QMap<QString, QgsProperty> params;
2806 if ( queryString.hasQueryItem( u
"fill"_s ) )
2808 const QColor
fillColor { queryString.queryItemValue( u
"fill"_s ) };
2812 if ( queryString.hasQueryItem( u
"fill-opacity"_s ) )
2814 const double alpha { queryString.queryItemValue( u
"fill-opacity"_s ).toDouble( &ok ) };
2821 if ( queryString.hasQueryItem( u
"outline"_s ) )
2823 const QColor
strokeColor { queryString.queryItemValue( u
"outline"_s ) };
2827 if ( queryString.hasQueryItem( u
"outline-opacity"_s ) )
2829 const double alpha { queryString.queryItemValue( u
"outline-opacity"_s ).toDouble( &ok ) };
2836 if ( queryString.hasQueryItem( u
"outline-width"_s ) )
2838 const int width { queryString.queryItemValue( u
"outline-width"_s ).toInt( &ok ) };
2845 if ( !params.isEmpty() )
2864 if ( hasDataDefinedSize )
2870 if ( hasDataDefinedSize && ok )
2884 size *= mmMapUnitScaleFactor;
2898 const double offsetX =
offset.x();
2899 const double offsetY =
offset.y();
2901 QPointF outputOffset( offsetX, offsetY );
2947 const QByteArray &svgContent
2951 QSvgRenderer r( svgContent );
2958 QSizeF outSize( r.defaultSize() );
2959 outSize.scale(
size,
size, Qt::KeepAspectRatio );
2965 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2967 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2969 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2970 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2979 bool hasDataDefinedSize =
false;
2980 double scaledWidth = calculateSize( context, hasDataDefinedSize );
2982 bool hasDataDefinedAspectRatio =
false;
2983 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2990 if (
static_cast< int >( scaledWidth ) < 1 || 10000.0 < scaledWidth )
2995 QPointF outputOffset;
2997 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
3033 const QSizeF svgViewbox
3036 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
3040 QTransform transform;
3042 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3045 transform.rotate(
angle );
3050 QRectF symbolBounds = transform.mapRect( QRectF( -scaledWidth / 2.0, -scaledHeight / 2.0, scaledWidth, scaledHeight ) );
3055 return symbolBounds;
3079 if ( props.contains( u
"imageFile"_s ) )
3080 path = props[u
"imageFile"_s].toString();
3081 if ( props.contains( u
"size"_s ) )
3082 size = props[u
"size"_s].toDouble();
3083 if ( props.contains( u
"angle"_s ) )
3084 angle = props[u
"angle"_s].toDouble();
3085 if ( props.contains( u
"scale_method"_s ) )
3089 m->setCommonProperties( props );
3095 const QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
3096 if ( graphicElem.isNull() )
3099 const QDomElement externalGraphicElem = graphicElem.firstChildElement( u
"ExternalGraphic"_s );
3100 if ( externalGraphicElem.isNull() )
3103 const QDomElement onlineResourceElem = externalGraphicElem.firstChildElement( u
"OnlineResource"_s );
3104 const QDomElement inlineContentElem = externalGraphicElem.firstChildElement( u
"InlineContent"_s );
3107 if ( !onlineResourceElem.isNull() )
3109 url = onlineResourceElem.attribute( u
"href"_s );
3112 else if ( !inlineContentElem.isNull() && inlineContentElem.attribute( u
"encoding"_s ) ==
"base64"_L1 )
3114 url = u
"base64:"_s + inlineContentElem.text();
3135 if (
properties.contains( u
"size_map_unit_scale"_s ) )
3137 if (
properties.contains( u
"fixedAspectRatio"_s ) )
3142 if (
properties.contains( u
"offset_unit"_s ) )
3144 if (
properties.contains( u
"offset_map_unit_scale"_s ) )
3147 if (
properties.contains( u
"horizontal_anchor_point"_s ) )
3151 if (
properties.contains( u
"vertical_anchor_point"_s ) )
3162 const QVariantMap::iterator it =
properties.find( u
"name"_s );
3163 if ( it !=
properties.end() && it.value().userType() == QMetaType::Type::QString )
3181 if ( aPreservedAspectRatio && !par )
3185 else if ( !aPreservedAspectRatio && par )
3204 return u
"RasterMarker"_s;
3225 if (
path.isEmpty() )
3229 double height = 0.0;
3231 bool hasDataDefinedSize =
false;
3232 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3234 bool hasDataDefinedAspectRatio =
false;
3235 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3237 QPointF outputOffset;
3244 if (
size.isEmpty() )
3247 width = ( scaledSize *
static_cast< double >(
size.width() ) ) / 100.0;
3248 height = ( scaledSize *
static_cast< double >(
size.height() ) ) / 100.0;
3251 if (
static_cast< int >( width ) < 1 || 10000.0 < width ||
static_cast< int >( height ) < 1 || 10000.0 < height )
3254 calculateOffsetAndRotation( context, width, height, outputOffset,
angle );
3264 if ( !
size.isNull() &&
size.isValid() &&
size.width() > 0 )
3266 height = width * (
static_cast< double >(
size.height() ) /
static_cast< double >(
size.width() ) );
3271 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
3274 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3278 p->translate( point + outputOffset );
3293 if ( !img.isNull() )
3296 if ( useSelectedColor )
3301 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
3307 bool cached =
false;
3311double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
3313 double scaledSize =
mSize;
3317 if ( hasDataDefinedSize )
3325 if ( hasDataDefinedSize )
3332 if ( hasDataDefinedSize && ok )
3337 scaledSize = std::sqrt( scaledSize );
3350 if ( !hasDataDefinedAspectRatio )
3360 const double defaultHeight =
mSize * scaledAspectRatio;
3361 scaledAspectRatio = defaultHeight / scaledSize;
3364 double scaledHeight = scaledSize * scaledAspectRatio;
3371 if ( hasDataDefinedAspectRatio && ok )
3376 scaledHeight = sqrt( scaledHeight );
3383 scaledAspectRatio = scaledHeight / scaledSize;
3385 return scaledAspectRatio;
3388void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const
3393 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
3394 offset = QPointF( offsetX, offsetY );
3404 if ( hasDataDefinedRotation )
3406 const QgsFeature *f = context.
feature();
3425 map[u
"imageFile"_s] =
mPath;
3426 map[u
"size"_s] = QString::number(
mSize );
3430 map[u
"angle"_s] = QString::number(
mAngle );
3431 map[u
"alpha"_s] = QString::number(
mOpacity );
3437 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
3443 auto m = std::make_unique< QgsRasterMarkerSymbolLayer >();
3490 bool hasDataDefinedSize =
false;
3491 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3493 bool hasDataDefinedAspectRatio =
false;
3494 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3498 if (
static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
3503 QPointF outputOffset;
3505 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3507 QTransform transform;
3510 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3513 transform.rotate(
angle );
3515 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0, -height / 2.0, width, height ) );
3517 return symbolBounds;
3532 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
3533 element.appendChild( graphicElem );
3536 QDomElement extGraphElem = doc.createElement( u
"se:ExternalGraphic"_s );
3537 graphicElem.appendChild( extGraphElem );
3539 QMimeDatabase mimeDB;
3543 if (
mPath.startsWith(
"base64:"_L1 ) )
3545 base64data =
mPath.mid( 7 );
3557 if ( !base64data.isEmpty() )
3560 QDomElement inlineContEleme = doc.createElement( u
"se:InlineContent"_s );
3562 inlineContEleme.setAttribute( u
"encoding"_s, u
"base64"_s );
3563 inlineContEleme.appendChild( doc.createTextNode( base64data ) );
3564 extGraphElem.appendChild( inlineContEleme );
3567 const QByteArray ba = QByteArray::fromBase64( base64data.toUtf8() );
3568 mimeType = mimeDB.mimeTypeForData( ba );
3573 QDomElement onlineResElem = doc.createElement( u
"se:OnlineResource"_s );
3574 QString url =
mPath;
3576 onlineResElem.setAttribute( u
"xlink:href"_s, url );
3577 onlineResElem.setAttribute( u
"xlink:type"_s, u
"simple"_s );
3578 extGraphElem.appendChild( onlineResElem );
3581 if (
mPath.startsWith(
"http://"_L1 ) ||
mPath.startsWith(
"https://"_L1 ) )
3585 mimeType = mimeDB.mimeTypeForName(
"image/png" );
3589 mimeType = mimeDB.mimeTypeForUrl( url );
3593 QDomElement formatElem = doc.createElement( u
"se:Format"_s );
3594 formatElem.appendChild( doc.createTextNode( mimeType.name() ) );
3595 extGraphElem.appendChild( formatElem );
3610 mOrigSize = pointSize;
3630 if ( props.contains( u
"font"_s ) )
3632 if ( props.contains( u
"chr"_s ) && props[u
"chr"_s].toString().length() > 0 )
3634 string = props[
"chr"].toString();
3635 const thread_local QRegularExpression charRegExp( u
"%1([0-9]+)%1"_s.arg(
FONTMARKER_CHR_FIX ) );
3636 QRegularExpressionMatch match = charRegExp.match(
string );
3637 while ( match.hasMatch() )
3639 QChar replacement = QChar( match.captured( 1 ).toUShort() );
3640 string =
string.mid( 0, match.capturedStart( 0 ) ) + replacement +
string.mid( match.capturedEnd( 0 ) );
3641 match = charRegExp.match(
string );
3645 if ( props.contains( u
"size"_s ) )
3646 pointSize = props[u
"size"_s].toDouble();
3647 if ( props.contains( u
"color"_s ) )
3649 if ( props.contains( u
"angle"_s ) )
3650 angle = props[u
"angle"_s].toDouble();
3654 if ( props.contains( u
"font_style"_s ) )
3656 if ( props.contains( u
"outline_color"_s ) )
3658 if ( props.contains( u
"outline_width"_s ) )
3660 if ( props.contains( u
"offset"_s ) )
3662 if ( props.contains( u
"offset_unit"_s ) )
3664 if ( props.contains( u
"offset_map_unit_scale"_s ) )
3666 if ( props.contains( u
"size_unit"_s ) )
3668 if ( props.contains( u
"size_map_unit_scale"_s ) )
3670 if ( props.contains( u
"outline_width_unit"_s ) )
3672 if ( props.contains( u
"outline_width_map_unit_scale"_s ) )
3674 if ( props.contains( u
"joinstyle"_s ) )
3676 if ( props.contains( u
"horizontal_anchor_point"_s ) )
3678 if ( props.contains( u
"vertical_anchor_point"_s ) )
3688 return u
"FontMarker"_s;
3698 QColor brushColor =
mColor;
3699 QColor penColor = mStrokeColor;
3701 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3702 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3704 mBrush = QBrush( brushColor );
3705 mPen = QPen( penColor );
3706 mPen.setJoinStyle( mPenJoinStyle );
3710 if ( !mFontStyle.isEmpty() )
3718 if ( mNonZeroFontSize && sizePixels > MAX_FONT_CHARACTER_SIZE_IN_PIXELS )
3723 mFontSizeScale = sizePixels / MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3724 sizePixels = MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3727 mFontSizeScale = 1.0;
3731 mFont.setPixelSize( std::max( 2,
static_cast< int >( std::round( sizePixels ) ) ) );
3732 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
3733 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3738 mChrOffset = QPointF( mChrWidth / 2.0, -sizePixels / 2.0 );
3745 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3755 if ( mUseCachedPath )
3757 QPointF chrOffset = mChrOffset;
3759 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3760 mCachedPath = QPainterPath();
3761 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3770QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3772 charOffset = mChrOffset;
3773 QString stringToRender = mString;
3778 if ( stringToRender != mString )
3780 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3786 charOffset = QPointF( charWidth / 2.0, -sizePixels / 2.0 );
3793 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3799 return stringToRender;
3802void QgsFontMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &angle )
const
3807 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3808 offset = QPointF( offsetX, offsetY );
3809 hasDataDefinedRotation =
false;
3823 hasDataDefinedRotation =
true;
3827 if ( hasDataDefinedRotation )
3834 const QgsFeature *f = context.
feature();
3851 double scaledSize =
mSize;
3855 if ( hasDataDefinedSize )
3861 if ( hasDataDefinedSize && ok )
3866 scaledSize = std::sqrt( scaledSize );
3878 if ( !p || !mNonZeroFontSize )
3881 QTransform transform;
3884 QColor brushColor =
mColor;
3894 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3896 mBrush.setColor( brushColor );
3898 QColor penColor = mStrokeColor;
3904 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3928 p->setBrush( mBrush );
3931 mPen.setColor( penColor );
3932 mPen.setWidthF( penWidth );
3937 p->setPen( Qt::NoPen );
3955 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
3958 QPointF chrOffset = mChrOffset;
3960 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3962 const double sizeToRender = calculateSize( context );
3964 bool hasDataDefinedRotation =
false;
3967 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation,
offset,
angle );
3969 p->translate( point.x() +
offset.x(), point.y() +
offset.y() );
3972 transform.rotate(
angle );
3976 const double s = sizeToRender / mOrigSize;
3977 transform.scale( s, s );
3981 transform.scale( mFontSizeScale, mFontSizeScale );
3983 if ( mUseCachedPath )
3985 p->drawPath( transform.map( mCachedPath ) );
3990 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3991 p->drawPath( transform.map( path ) );
3998 props[u
"font"_s] = mFontFamily;
3999 props[u
"font_style"_s] = mFontStyle;
4000 QString chr = mString;
4001 for (
int i = 0; i < 32; i++ )
4003 if ( i == 9 || i == 10 || i == 13 )
4007 chr.replace( QChar( i ), u
"%1%2%1"_s.arg(
FONTMARKER_CHR_FIX, QString::number( i ) ) );
4009 props[u
"chr"_s] = chr;
4010 props[u
"size"_s] = QString::number(
mSize );
4015 props[u
"outline_width"_s] = QString::number( mStrokeWidth );
4019 props[u
"angle"_s] = QString::number(
mAngle );
4024 props[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
4052 toSld( doc, element, context );
4070 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
4071 element.appendChild( graphicElem );
4074 const QString fontPath = u
"ttf://%1"_s.arg( mFontFamily );
4075 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
4082 const double angle = props.value( u
"angle"_s, u
"0"_s ).toDouble( &ok );
4085 angleFunc = u
"%1 + %2"_s.arg( props.value( u
"angle"_s, u
"0"_s ).toString() ).arg(
mAngle );
4112 mStrokeWidthUnit = unit;
4117 QPointF chrOffset = mChrOffset;
4118 double chrWidth = mChrWidth;
4120 ( void ) characterToRender( context, chrOffset, chrWidth );
4122 if ( !mFontMetrics )
4123 mFontMetrics = std::make_unique<QFontMetrics>( mFont );
4125 double scaledSize = calculateSize( context );
4128 chrWidth *= scaledSize / mOrigSize;
4130 chrWidth *= mFontSizeScale;
4132 bool hasDataDefinedRotation =
false;
4135 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation,
offset,
angle );
4138 QTransform transform;
4141 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
4144 transform.rotate(
angle );
4146 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0, -scaledSize / 2.0, chrWidth, scaledSize ) );
4147 return symbolBounds;
4154 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
4155 if ( graphicElem.isNull() )
4158 QString name, format;
4166 if ( !name.startsWith(
"ttf://"_L1 ) || format !=
"ttf"_L1 )
4176 const double d = angleFunc.toDouble( &ok );
4184 double scaleFactor = 1.0;
4185 const QString uom = element.attribute( u
"uom"_s );
4205 context.
pushMessage( QObject::tr(
"Font “%1” not available on system" ).arg( processedFamily ) );
4211 QMap<QString, QgsProperty>::iterator it =
mParameters.begin();
4223 QMap<QString, QgsProperty>::const_iterator it =
mParameters.constBegin();
4226 attrs.unite( it.value().referencedFields( context.
expressionContext(),
true ) );
4255 auto m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
path,
size,
angle );
4256 m->setFrameRate(
properties.value( u
"frameRate"_s, u
"10"_s ).toDouble() );
4264 return u
"AnimatedMarker"_s;
4270 res.insert( u
"frameRate"_s, mFrameRateFps );
4276 auto m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
4277 m->setFrameRate( mFrameRateFps );
4286 mPreparedPaths.clear();
4294 mStaticPath =
false;
4300 if ( !mStaticPath && !mPreparedPaths.contains(
path ) )
4303 mPreparedPaths.insert(
path );
4306 const long long mapFrameNumber = context.
currentFrame();
4308 const double markerAnimationDuration = totalFrameCount / mFrameRateFps;
4310 double animationTimeSeconds = 0;
4311 if ( mapFrameNumber >= 0 && context.
frameRate() > 0 )
4314 animationTimeSeconds = mapFrameNumber / context.
frameRate();
4319 animationTimeSeconds = QDateTime::currentMSecsSinceEpoch() / 1000.0;
4322 const double markerAnimationProgressSeconds = std::fmod( animationTimeSeconds, markerAnimationDuration );
4323 const int movieFrame =
static_cast< int >( std::floor( markerAnimationProgressSeconds * mFrameRateFps ) );
4325 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