33#include <QSvgRenderer>
36#include <QDomDocument>
45static constexpr int MAX_FONT_CHARACTER_SIZE_IN_PIXELS = 500;
47static void _fixQPictureDPI( QPainter *p )
53 p->scale(
static_cast< double >(
qt_defaultDpiX() ) / p->device()->logicalDpiX(),
54 static_cast< double >(
qt_defaultDpiY() ) / p->device()->logicalDpiY() );
67 QList< Qgis::MarkerShape > shapes;
116 mSizeUnit = Qgis::RenderUnit::Millimeters;
182 QTransform transform;
185 if ( !hasDataDefinedSize )
195 const double half = scaledSize / 2.0;
196 transform.scale( half, half );
202 transform.rotate(
mAngle );
229 bool hasDataDefinedSize =
false;
230 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
232 bool hasDataDefinedRotation =
false;
238 bool createdNewPath =
false;
256 createdNewPath =
true;
265 QTransform transform;
268 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
271 if ( hasDataDefinedSize || createdNewPath )
280 const double half = s / 2.0;
281 transform.scale( half, half );
286 transform.rotate(
angle );
295 polygon = transform.map(
mPolygon );
299 path = transform.map(
mPath );
301 draw( context, symbol, polygon, path );
306 bool hasDataDefinedSize =
false;
307 double scaledSize =
calculateSize( context, hasDataDefinedSize );
309 bool hasDataDefinedRotation =
false;
316 QTransform transform;
319 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
322 transform.rotate(
angle );
324 return transform.mapRect( QRectF( -scaledSize / 2.0,
334 const QString cleaned = name.toLower().trimmed();
336 if ( cleaned == QLatin1String(
"square" ) || cleaned == QLatin1String(
"rectangle" ) )
338 else if ( cleaned == QLatin1String(
"trapezoid" ) )
340 else if ( cleaned == QLatin1String(
"parallelogram_right" ) )
342 else if ( cleaned == QLatin1String(
"parallelogram_left" ) )
344 else if ( cleaned == QLatin1String(
"square_with_corners" ) )
346 else if ( cleaned == QLatin1String(
"rounded_square" ) )
348 else if ( cleaned == QLatin1String(
"diamond" ) )
350 else if ( cleaned == QLatin1String(
"shield" ) )
352 else if ( cleaned == QLatin1String(
"pentagon" ) )
354 else if ( cleaned == QLatin1String(
"hexagon" ) )
356 else if ( cleaned == QLatin1String(
"octagon" ) )
358 else if ( cleaned == QLatin1String(
"decagon" ) )
360 else if ( cleaned == QLatin1String(
"triangle" ) )
362 else if ( cleaned == QLatin1String(
"equilateral_triangle" ) )
364 else if ( cleaned == QLatin1String(
"star_diamond" ) )
366 else if ( cleaned == QLatin1String(
"star" ) || cleaned == QLatin1String(
"regular_star" ) )
368 else if ( cleaned == QLatin1String(
"heart" ) )
370 else if ( cleaned == QLatin1String(
"arrow" ) )
372 else if ( cleaned == QLatin1String(
"circle" ) )
374 else if ( cleaned == QLatin1String(
"cross" ) )
376 else if ( cleaned == QLatin1String(
"cross_fill" ) )
378 else if ( cleaned == QLatin1String(
"cross2" ) || cleaned == QLatin1String(
"x" ) )
380 else if ( cleaned == QLatin1String(
"line" ) )
382 else if ( cleaned == QLatin1String(
"arrowhead" ) )
384 else if ( cleaned == QLatin1String(
"filled_arrowhead" ) )
386 else if ( cleaned == QLatin1String(
"semi_circle" ) )
388 else if ( cleaned == QLatin1String(
"third_circle" ) )
390 else if ( cleaned == QLatin1String(
"quarter_circle" ) )
392 else if ( cleaned == QLatin1String(
"quarter_square" ) )
394 else if ( cleaned == QLatin1String(
"half_square" ) )
396 else if ( cleaned == QLatin1String(
"diagonal_half_square" ) )
398 else if ( cleaned == QLatin1String(
"right_half_triangle" ) )
400 else if ( cleaned == QLatin1String(
"left_half_triangle" ) )
402 else if ( cleaned == QLatin1String(
"asterisk_fill" ) )
404 else if ( cleaned == QLatin1String(
"half_arc" ) )
406 else if ( cleaned == QLatin1String(
"third_arc" ) )
408 else if ( cleaned == QLatin1String(
"quarter_arc" ) )
421 return QStringLiteral(
"square" );
423 return QStringLiteral(
"quarter_square" );
425 return QStringLiteral(
"half_square" );
427 return QStringLiteral(
"diagonal_half_square" );
429 return QStringLiteral(
"parallelogram_right" );
431 return QStringLiteral(
"parallelogram_left" );
433 return QStringLiteral(
"trapezoid" );
435 return QStringLiteral(
"shield" );
437 return QStringLiteral(
"diamond" );
439 return QStringLiteral(
"pentagon" );
441 return QStringLiteral(
"hexagon" );
443 return QStringLiteral(
"octagon" );
445 return QStringLiteral(
"decagon" );
447 return QStringLiteral(
"square_with_corners" );
449 return QStringLiteral(
"rounded_square" );
451 return QStringLiteral(
"triangle" );
453 return QStringLiteral(
"equilateral_triangle" );
455 return QStringLiteral(
"left_half_triangle" );
457 return QStringLiteral(
"right_half_triangle" );
459 return QStringLiteral(
"star_diamond" );
461 return QStringLiteral(
"star" );
463 return QStringLiteral(
"heart" );
465 return QStringLiteral(
"arrow" );
467 return QStringLiteral(
"filled_arrowhead" );
469 return QStringLiteral(
"cross_fill" );
471 return QStringLiteral(
"circle" );
473 return QStringLiteral(
"cross" );
475 return QStringLiteral(
"cross2" );
477 return QStringLiteral(
"line" );
479 return QStringLiteral(
"arrowhead" );
481 return QStringLiteral(
"semi_circle" );
483 return QStringLiteral(
"third_circle" );
485 return QStringLiteral(
"quarter_circle" );
487 return QStringLiteral(
"asterisk_fill" );
489 return QStringLiteral(
"half_arc" );
491 return QStringLiteral(
"third_arc" );
493 return QStringLiteral(
"quarter_arc" );
510 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
515 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 0.6072;
517 polygon << QPointF( - VERTEX_OFFSET_FROM_ORIGIN, 1 )
518 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
519 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
520 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
521 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
522 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
523 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
524 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
525 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
530 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 0 ) ) );
534 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 1 ) ) );
538 polygon << QPointF( -1, -1 ) << QPointF( 1, 1 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
542 polygon << QPointF( 0.5, -0.5 )
544 << QPointF( -1, 0.5 )
545 << QPointF( -0.5, -0.5 )
546 << QPointF( 0.5, -0.5 );
550 polygon << QPointF( 0.5, 0.5 )
551 << QPointF( 1, -0.5 )
552 << QPointF( -0.5, -0.5 )
553 << QPointF( -1, 0.5 )
554 << QPointF( 0.5, 0.5 );
558 polygon << QPointF( 1, 0.5 )
559 << QPointF( 0.5, -0.5 )
560 << QPointF( -1, -0.5 )
561 << QPointF( -0.5, 0.5 )
562 << QPointF( 1, 0.5 );
566 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
567 << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
571 polygon << QPointF( 1, 0.5 )
574 << QPointF( -1, 0.5 )
576 << QPointF( 1, 0.5 );
586 polygon << QPointF( -0.9511, -0.3090 )
587 << QPointF( -0.5878, 0.8090 )
588 << QPointF( 0.5878, 0.8090 )
589 << QPointF( 0.9511, -0.3090 )
591 << QPointF( -0.9511, -0.3090 );
602 polygon << QPointF( -0.8660, -0.5 )
603 << QPointF( -0.8660, 0.5 )
605 << QPointF( 0.8660, 0.5 )
606 << QPointF( 0.8660, -0.5 )
608 << QPointF( -0.8660, -0.5 );
613 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 1.0 / ( 1 + M_SQRT2 );
615 polygon << QPointF( - VERTEX_OFFSET_FROM_ORIGIN, 1 )
616 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
617 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
618 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
619 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
620 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
621 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
622 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
623 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
630 polygon << 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 )
636 << QPointF( -0.951056516, -0.309016994 )
637 << QPointF( -0.951056516, 0.309016994 )
638 << QPointF( -0.587785252, 0.809016994 )
640 << QPointF( 0.587785252, 0.809016994 );
645 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
653 polygon << QPointF( -0.8660, 0.5 )
654 << QPointF( 0.8660, 0.5 )
656 << QPointF( -0.8660, 0.5 );
660 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
664 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
669 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
671 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 315.0 ) ), - inner_r * std::cos(
DEG2RAD( 315.0 ) ) )
672 << QPointF( std::sin(
DEG2RAD( 270 ) ), - std::cos(
DEG2RAD( 270 ) ) )
673 << QPointF( inner_r * std::sin(
DEG2RAD( 225.0 ) ), - inner_r * std::cos(
DEG2RAD( 225.0 ) ) )
674 << QPointF( std::sin(
DEG2RAD( 180 ) ), - std::cos(
DEG2RAD( 180 ) ) )
675 << QPointF( inner_r * std::sin(
DEG2RAD( 135.0 ) ), - inner_r * std::cos(
DEG2RAD( 135.0 ) ) )
676 << QPointF( std::sin(
DEG2RAD( 90 ) ), - std::cos(
DEG2RAD( 90 ) ) )
677 << QPointF( inner_r * std::sin(
DEG2RAD( 45.0 ) ), - inner_r * std::cos(
DEG2RAD( 45.0 ) ) )
678 << QPointF( std::sin(
DEG2RAD( 0 ) ), - std::cos(
DEG2RAD( 0 ) ) );
684 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
686 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
687 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), - std::cos(
DEG2RAD( 288 ) ) )
688 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), - inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
689 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), - std::cos(
DEG2RAD( 216.0 ) ) )
690 << QPointF( 0, inner_r )
691 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), - std::cos(
DEG2RAD( 144.0 ) ) )
692 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), - inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
693 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), - std::cos(
DEG2RAD( 72.0 ) ) )
694 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), - inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
696 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
701 polygon << QPointF( 0, -1 )
702 << QPointF( 0.5, -0.5 )
703 << QPointF( 0.25, -0.5 )
704 << QPointF( 0.25, 1 )
705 << QPointF( -0.25, 1 )
706 << QPointF( -0.25, -0.5 )
707 << QPointF( -0.5, -0.5 )
712 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
716 polygon << QPointF( -1, -0.2 )
717 << QPointF( -1, -0.2 )
718 << QPointF( -1, 0.2 )
719 << QPointF( -0.2, 0.2 )
720 << QPointF( -0.2, 1 )
722 << QPointF( 0.2, 0.2 )
724 << QPointF( 1, -0.2 )
725 << QPointF( 0.2, -0.2 )
726 << QPointF( 0.2, -1 )
727 << QPointF( -0.2, -1 )
728 << QPointF( -0.2, -0.2 )
729 << QPointF( -1, -0.2 );
734 static constexpr double THICKNESS = 0.3;
735 static constexpr double HALF_THICKNESS = THICKNESS / 2.0;
736 static constexpr double INTERSECTION_POINT = THICKNESS / M_SQRT2;
737 static constexpr double DIAGONAL1 = M_SQRT1_2 - INTERSECTION_POINT * 0.5;
738 static constexpr double DIAGONAL2 = M_SQRT1_2 + INTERSECTION_POINT * 0.5;
740 polygon << QPointF( -HALF_THICKNESS, -1 )
741 << QPointF( HALF_THICKNESS, -1 )
742 << QPointF( HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
743 << QPointF( DIAGONAL1, -DIAGONAL2 )
744 << QPointF( DIAGONAL2, -DIAGONAL1 )
745 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, -HALF_THICKNESS )
746 << QPointF( 1, -HALF_THICKNESS )
747 << QPointF( 1, HALF_THICKNESS )
748 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, HALF_THICKNESS )
749 << QPointF( DIAGONAL2, DIAGONAL1 )
750 << QPointF( DIAGONAL1, DIAGONAL2 )
751 << QPointF( HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
752 << QPointF( HALF_THICKNESS, 1 )
753 << QPointF( -HALF_THICKNESS, 1 )
754 << QPointF( -HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
755 << QPointF( -DIAGONAL1, DIAGONAL2 )
756 << QPointF( -DIAGONAL2, DIAGONAL1 )
757 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, HALF_THICKNESS )
758 << QPointF( -1, HALF_THICKNESS )
759 << QPointF( -1, -HALF_THICKNESS )
760 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, -HALF_THICKNESS )
761 << QPointF( -DIAGONAL2, -DIAGONAL1 )
762 << QPointF( -DIAGONAL1, -DIAGONAL2 )
763 << QPointF( -HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
764 << QPointF( -HALF_THICKNESS, -1 );
789 mPath = QPainterPath();
795 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
799 mPath.moveTo( -1, -1 );
800 mPath.addRoundedRect( -1, -1, 2, 2, 0.25, 0.25 );
804 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
805 mPath.lineTo( 0, 0 );
809 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
810 mPath.lineTo( 0, 0 );
814 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
815 mPath.lineTo( 0, 0 );
819 mPath.moveTo( 1, 0 );
820 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
824 mPath.moveTo( 0, -1 );
825 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
829 mPath.moveTo( 0, -1 );
830 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
834 mPath.moveTo( -1, 0 );
835 mPath.lineTo( 1, 0 );
836 mPath.moveTo( 0, -1 );
837 mPath.lineTo( 0, 1 );
841 mPath.moveTo( -1, -1 );
842 mPath.lineTo( 1, 1 );
843 mPath.moveTo( 1, -1 );
844 mPath.lineTo( -1, 1 );
848 mPath.moveTo( 0, -1 );
849 mPath.lineTo( 0, 1 );
853 mPath.moveTo( -1, -1 );
854 mPath.lineTo( 0, 0 );
855 mPath.lineTo( -1, 1 );
859 mPath.moveTo( 0, 0.75 );
860 mPath.arcTo( 0, -1, 1, 1, -45, 210 );
861 mPath.arcTo( -1, -1, 1, 1, 15, 210 );
862 mPath.lineTo( 0, 0.75 );
896 double scaledSize =
mSize;
900 if ( hasDataDefinedSize )
907 if ( hasDataDefinedSize && ok )
912 scaledSize = std::sqrt( scaledSize );
927 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
928 offset = QPointF( offsetX, offsetY );
930 hasDataDefinedRotation =
false;
943 hasDataDefinedRotation =
true;
948 if ( hasDataDefinedRotation )
977 , mStrokeColor( strokeColor )
978 , mPenJoinStyle( penJoinStyle )
995 if ( props.contains( QStringLiteral(
"name" ) ) )
999 if ( props.contains( QStringLiteral(
"color" ) ) )
1001 if ( props.contains( QStringLiteral(
"color_border" ) ) )
1006 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
1010 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
1014 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
1018 if ( props.contains( QStringLiteral(
"size" ) ) )
1019 size = props[QStringLiteral(
"size" )].toDouble();
1020 if ( props.contains( QStringLiteral(
"angle" ) ) )
1021 angle = props[QStringLiteral(
"angle" )].toDouble();
1022 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1026 if ( props.contains( QStringLiteral(
"offset" ) ) )
1028 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1030 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1032 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1034 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1037 if ( props.contains( QStringLiteral(
"outline_style" ) ) )
1041 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
1045 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
1047 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
1049 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
1051 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
1053 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
1057 if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
1061 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1066 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1070 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1075 if ( props.contains( QStringLiteral(
"cap_style" ) ) )
1088 return QStringLiteral(
"SimpleMarker" );
1095 QColor brushColor =
mColor;
1098 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
1101 mBrush = QBrush( brushColor );
1102 mPen = QPen( penColor );
1112 selBrushColor.setAlphaF( context.
opacity() );
1113 selPenColor.setAlphaF( context.
opacity() );
1116 mSelPen = QPen( selPenColor );
1132 mCachedOpacity = context.
opacity();
1138 mSelPen.setColor( selBrushColor );
1170 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
1173 const double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
1174 const int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
1175 const double center = imageSize / 2.0;
1181 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
1188 p.setRenderHint( QPainter::Antialiasing );
1189 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1191 p.translate( QPointF( center, center ) );
1199 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
1203 p.setRenderHint( QPainter::Antialiasing );
1204 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
1206 p.translate( QPointF( center, center ) );
1217 p.setRenderHint( QPainter::Antialiasing );
1218 p.fillRect( 0, 0, imageSize, imageSize, selColor );
1219 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1221 p.translate( QPointF( center, center ) );
1240 QColor brushColor =
mColor;
1241 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
1242 mBrush.setColor( brushColor );
1245 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
1246 mPen.setColor( penColor );
1255 c.setAlphaF(
c.alphaF() * context.
opacity() );
1265 c.setAlphaF(
c.alphaF() * context.
opacity() );
1317 p->setBrush( Qt::NoBrush );
1321 if ( !polygon.isEmpty() )
1322 p->drawPolygon( polygon );
1324 p->drawPath( path );
1341 const double s = img.width();
1343 bool hasDataDefinedSize =
false;
1344 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
1346 bool hasDataDefinedRotation =
false;
1351 p->drawImage( QRectF( point.x() - s / 2.0 +
offset.x(),
1352 point.y() - s / 2.0 +
offset.y(),
1367 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1370 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1376 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
1409 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1410 element.appendChild( graphicElem );
1426 const double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
1429 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
1446 Q_UNUSED( mmScaleFactor )
1447 Q_UNUSED( mapUnitScaleFactor )
1449 QString ogrType =
"3";
1450 if ( mName ==
"square" )
1454 else if ( mName ==
"triangle" )
1458 else if ( mName ==
"star" )
1462 else if ( mName ==
"circle" )
1466 else if ( mName ==
"cross" )
1470 else if ( mName ==
"x" || mName ==
"cross2" )
1474 else if ( mName ==
"line" )
1480 ogrString.append(
"SYMBOL(" );
1481 ogrString.append(
"id:" );
1482 ogrString.append(
'\"' );
1483 ogrString.append(
"ogr-sym-" );
1484 ogrString.append( ogrType );
1485 ogrString.append(
'\"' );
1486 ogrString.append(
",c:" );
1487 ogrString.append(
mColor.name() );
1488 ogrString.append(
",o:" );
1490 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1491 ogrString.append(
')' );
1496 ogrString.append(
"PEN(" );
1497 ogrString.append(
"c:" );
1498 ogrString.append(
mColor.name() );
1499 ogrString.append(
",w:" );
1500 ogrString.append( QString::number(
mSize ) );
1501 ogrString.append(
"mm" );
1502 ogrString.append(
")" );
1510 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1511 if ( graphicElem.isNull() )
1514 QString name = QStringLiteral(
"square" );
1527 const double d = angleFunc.toDouble( &ok );
1537 double scaleFactor = 1.0;
1538 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
1565 p->drawPath(
mPath );
1578 if ( hasDataDefinedSize )
1597 if (
mSizeUnit == Qgis::RenderUnit::Millimeters )
1599 size *= mmMapUnitScaleFactor;
1602 if (
mSizeUnit == Qgis::RenderUnit::MapUnits )
1606 const double halfSize =
size / 2.0;
1617 if (
mSizeUnit == Qgis::RenderUnit::MapUnits )
1623 QColor pc =
mPen.color();
1624 QColor bc =
mBrush.color();
1644 QPointF off( offsetX, offsetY );
1673 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1681 t.scale( halfSize, -halfSize );
1683 polygon = t.map( polygon );
1686 p.reserve( polygon.size() );
1687 for (
int i = 0; i < polygon.size(); i++ )
1692 if (
mBrush.style() != Qt::NoBrush )
1694 if (
mPen.style() != Qt::NoPen )
1699 shift += QPointF( off.x(), -off.y() );
1700 if (
mBrush.style() != Qt::NoBrush )
1702 if (
mPen.style() != Qt::NoPen )
1707 const QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1708 const QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1710 if (
mPen.style() != Qt::NoPen )
1715 if (
mPen.style() != Qt::NoPen )
1717 const QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1718 const QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1719 const QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1720 const QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1728 if (
mPen.style() != Qt::NoPen )
1730 const QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1731 const QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1732 const QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1733 const QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1741 if (
mPen.style() != Qt::NoPen )
1743 const QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1744 const QPointF pt2 = t.map( QPointF( 0, 0 ) );
1745 const QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1773 return Qgis::RenderUnit::Unknown;
1793 return mSizeUnit == Qgis::RenderUnit::MapUnits ||
mSizeUnit == Qgis::RenderUnit::MetersInMapUnits
1831 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1832 penWidth / 2.0, penWidth / 2.0 );
1834 return symbolBounds;
1883 if ( props.contains( QStringLiteral(
"name" ) ) )
1884 name = props[QStringLiteral(
"name" )].toString();
1885 if ( props.contains( QStringLiteral(
"size" ) ) )
1886 size = props[QStringLiteral(
"size" )].toDouble();
1887 if ( props.contains( QStringLiteral(
"angle" ) ) )
1888 angle = props[QStringLiteral(
"angle" )].toDouble();
1889 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1893 if ( props.contains( QStringLiteral(
"offset" ) ) )
1895 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1897 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1899 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1901 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1903 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1907 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1921 return QStringLiteral(
"FilledMarker" );
1946 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1949 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2005 attr.unite( mFill->usedAttributes( context ) );
2013 if ( mFill && mFill->hasDataDefinedProperties() )
2022 mFill->setColor(
c );
2027 return mFill ? mFill->color() :
mColor;
2032 return mSizeUnit == Qgis::RenderUnit::MapUnits ||
mSizeUnit == Qgis::RenderUnit::MetersInMapUnits
2034 || ( mFill && mFill->usesMapUnits() );
2041 mFill->setOutputUnit( unit );
2055 const double prevOpacity = mFill->opacity();
2056 mFill->setOpacity( mFill->opacity() * context.
opacity() );
2060 p->setBrush( Qt::red );
2064 p->setBrush( Qt::NoBrush );
2066 p->setPen( Qt::black );
2071 if ( !polygon.isEmpty() )
2077 const QPolygonF poly = path.toFillPolygon();
2083 mFill->setOpacity( prevOpacity );
2098 mColor = QColor( 35, 35, 35 );
2112 if ( props.contains( QStringLiteral(
"name" ) ) )
2113 name = props[QStringLiteral(
"name" )].toString();
2114 if ( props.contains( QStringLiteral(
"size" ) ) )
2115 size = props[QStringLiteral(
"size" )].toDouble();
2116 if ( props.contains( QStringLiteral(
"angle" ) ) )
2117 angle = props[QStringLiteral(
"angle" )].toDouble();
2118 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
2123 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2125 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2127 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
2129 if ( props.contains( QStringLiteral(
"offset" ) ) )
2131 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2133 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2135 if ( props.contains( QStringLiteral(
"fill" ) ) )
2140 else if ( props.contains( QStringLiteral(
"color" ) ) )
2144 if ( props.contains( QStringLiteral(
"outline" ) ) )
2149 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
2153 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
2158 if ( props.contains( QStringLiteral(
"outline-width" ) ) )
2161 m->
setStrokeWidth( props[QStringLiteral(
"outline-width" )].toDouble() );
2163 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
2165 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
2167 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
2169 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
2172 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
2176 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
2180 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2183 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2187 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
2196 if ( props.contains( QStringLiteral(
"parameters" ) ) )
2198 const QVariantMap
parameters = props[QStringLiteral(
"parameters" )].toMap();
2207 const QVariantMap::iterator it =
properties.find( QStringLiteral(
"name" ) );
2226 QColor defaultFillColor, defaultStrokeColor;
2228 bool hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
2229 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
2231 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
2232 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2233 hasStrokeWidthParam, hasDefaultStrokeWidth,
strokeWidth,
2234 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
2236 const double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
2237 const double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
2239 if ( hasDefaultFillColor )
2241 defaultFillColor.setAlphaF( newFillOpacity );
2244 if ( hasDefaultFillOpacity )
2247 c.setAlphaF( fillOpacity );
2250 if ( hasDefaultStrokeColor )
2252 defaultStrokeColor.setAlphaF( newStrokeOpacity );
2255 if ( hasDefaultStrokeWidth )
2259 if ( hasDefaultStrokeOpacity )
2262 c.setAlphaF( strokeOpacity );
2276 const double widthScaleFactor = 3.465;
2279 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
2287 if ( aPreservedAspectRatio && !par )
2291 else if ( !aPreservedAspectRatio && par )
2306 return QStringLiteral(
"SvgMarker" );
2326 bool hasDataDefinedSize =
false;
2327 const double scaledWidth = calculateSize( context, hasDataDefinedSize );
2331 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
2338 bool hasDataDefinedAspectRatio =
false;
2339 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2382 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2386 QPointF outputOffset;
2388 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2390 p->translate( point + outputOffset );
2396 bool fitsInCache =
true;
2397 bool usePict =
true;
2404 if ( fitsInCache && img.width() > 1 )
2416 QImage transparentImage = img.copy();
2418 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2422 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2427 if ( usePict || !fitsInCache )
2429 p->setOpacity( context.
opacity() );
2433 if ( pct.width() > 1 )
2436 _fixQPictureDPI( p );
2437 p->drawPicture( 0, 0, pct );
2445double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2447 double scaledSize =
mSize;
2451 if ( hasDataDefinedSize )
2459 if ( hasDataDefinedSize )
2466 if ( hasDataDefinedSize && ok )
2471 scaledSize = std::sqrt( scaledSize );
2484 if ( !hasDataDefinedAspectRatio )
2494 const double defaultHeight =
mSize * scaledAspectRatio;
2495 scaledAspectRatio = defaultHeight / scaledSize;
2498 double scaledHeight = scaledSize * scaledAspectRatio;
2505 if ( hasDataDefinedAspectRatio && ok )
2510 scaledHeight = sqrt( scaledHeight );
2517 scaledAspectRatio = scaledHeight / scaledSize;
2519 return scaledAspectRatio;
2522void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const
2527 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2528 offset = QPointF( offsetX, offsetY );
2538 if ( hasDataDefinedRotation )
2564 map[QStringLiteral(
"name" )] =
mPath;
2565 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2568 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2569 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2576 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
2589 return mSizeUnit == Qgis::RenderUnit::MapUnits ||
mSizeUnit == Qgis::RenderUnit::MetersInMapUnits
2628 return Qgis::RenderUnit::Unknown;
2651 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2652 element.appendChild( graphicElem );
2662 const double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2665 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
2683 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
2684 if ( graphicElem.isNull() )
2687 QString
path, mimeType;
2695 double scaleFactor = 1.0;
2696 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
2700 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2708 const double d = angleFunc.toDouble( &ok );
2717 QString realPath {
path };
2718 QUrl svgUrl {
path };
2721 QUrlQuery queryString;
2723 if ( svgUrl.hasQuery() && svgUrl.hasFragment() )
2725 const QString queryPart {
path.mid(
path.indexOf(
'?' ) + 1 ) };
2726 queryString.setQuery( queryPart );
2730 if ( svgUrl.scheme().isEmpty() || svgUrl.isLocalFile() )
2732 svgUrl.setQuery( QString() );
2733 realPath = svgUrl.path();
2738 QMap<QString, QgsProperty> params;
2742 if ( queryString.hasQueryItem( QStringLiteral(
"fill" ) ) )
2744 const QColor
fillColor { queryString.queryItemValue( QStringLiteral(
"fill" ) ) };
2748 if ( queryString.hasQueryItem( QStringLiteral(
"fill-opacity" ) ) )
2750 const double alpha { queryString.queryItemValue( QStringLiteral(
"fill-opacity" ) ).toDouble( &ok ) };
2757 if ( queryString.hasQueryItem( QStringLiteral(
"outline" ) ) )
2759 const QColor
strokeColor { queryString.queryItemValue( QStringLiteral(
"outline" ) ) };
2763 if ( queryString.hasQueryItem( QStringLiteral(
"outline-opacity" ) ) )
2765 const double alpha { queryString.queryItemValue( QStringLiteral(
"outline-opacity" ) ).toDouble( &ok ) };
2772 if ( queryString.hasQueryItem( QStringLiteral(
"outline-width" ) ) )
2774 const int width { queryString.queryItemValue( QStringLiteral(
"outline-width" ) ).toInt( &ok )};
2781 if ( ! params.isEmpty() )
2800 if ( hasDataDefinedSize )
2806 if ( hasDataDefinedSize && ok )
2818 if (
mSizeUnit == Qgis::RenderUnit::Millimeters )
2820 size *= mmMapUnitScaleFactor;
2834 const double offsetX =
offset.x();
2835 const double offsetY =
offset.y();
2837 QPointF outputOffset( offsetX, offsetY );
2887 QSvgRenderer r( svgContent );
2894 QSizeF outSize( r.defaultSize() );
2895 outSize.scale(
size,
size, Qt::KeepAspectRatio );
2901 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2903 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2905 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2906 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2915 bool hasDataDefinedSize =
false;
2916 double scaledWidth = calculateSize( context, hasDataDefinedSize );
2918 bool hasDataDefinedAspectRatio =
false;
2919 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2926 if (
static_cast< int >( scaledWidth ) < 1 || 10000.0 < scaledWidth )
2931 QPointF outputOffset;
2933 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2972 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2976 QTransform transform;
2978 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2981 transform.rotate(
angle );
2986 QRectF symbolBounds = transform.mapRect( QRectF( -scaledWidth / 2.0,
2987 -scaledHeight / 2.0,
2995 return symbolBounds;
3019 if ( props.contains( QStringLiteral(
"imageFile" ) ) )
3020 path = props[QStringLiteral(
"imageFile" )].toString();
3021 if ( props.contains( QStringLiteral(
"size" ) ) )
3022 size = props[QStringLiteral(
"size" )].toDouble();
3023 if ( props.contains( QStringLiteral(
"angle" ) ) )
3024 angle = props[QStringLiteral(
"angle" )].toDouble();
3025 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
3028 std::unique_ptr< QgsRasterMarkerSymbolLayer > m = std::make_unique< QgsRasterMarkerSymbolLayer >(
path,
size,
angle,
scaleMethod );
3029 m->setCommonProperties( props );
3035 if (
properties.contains( QStringLiteral(
"alpha" ) ) )
3040 if (
properties.contains( QStringLiteral(
"size_unit" ) ) )
3042 if (
properties.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
3044 if (
properties.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
3047 if (
properties.contains( QStringLiteral(
"offset" ) ) )
3049 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
3051 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3054 if (
properties.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
3058 if (
properties.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3069 const QVariantMap::iterator it =
properties.find( QStringLiteral(
"name" ) );
3070 if ( it !=
properties.end() && it.value().type() == QVariant::String )
3088 if ( aPreservedAspectRatio && !par )
3092 else if ( !aPreservedAspectRatio && par )
3111 return QStringLiteral(
"RasterMarker" );
3127 if (
path.isEmpty() )
3131 double height = 0.0;
3133 bool hasDataDefinedSize =
false;
3134 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3136 bool hasDataDefinedAspectRatio =
false;
3137 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3139 QPointF outputOffset;
3143 if (
mSizeUnit == Qgis::RenderUnit::Percentage )
3146 if (
size.isEmpty() )
3149 width = ( scaledSize *
static_cast< double >(
size.width() ) ) / 100.0;
3150 height = ( scaledSize *
static_cast< double >(
size.height() ) ) / 100.0;
3153 if (
static_cast< int >( width ) < 1 || 10000.0 < width ||
static_cast< int >( height ) < 1 || 10000.0 < height )
3156 calculateOffsetAndRotation( context, width, height, outputOffset,
angle );
3166 if ( !
size.isNull() &&
size.isValid() &&
size.width() > 0 )
3168 height = width * (
static_cast< double >(
size.height() ) /
static_cast< double >(
size.width() ) );
3173 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
3176 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3180 p->translate( point + outputOffset );
3195 if ( !img.isNull() )
3202 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
3208 bool cached =
false;
3212double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
3214 double scaledSize =
mSize;
3218 if ( hasDataDefinedSize )
3226 if ( hasDataDefinedSize )
3233 if ( hasDataDefinedSize && ok )
3238 scaledSize = std::sqrt( scaledSize );
3251 if ( !hasDataDefinedAspectRatio )
3261 const double defaultHeight =
mSize * scaledAspectRatio;
3262 scaledAspectRatio = defaultHeight / scaledSize;
3265 double scaledHeight = scaledSize * scaledAspectRatio;
3272 if ( hasDataDefinedAspectRatio && ok )
3277 scaledHeight = sqrt( scaledHeight );
3284 scaledAspectRatio = scaledHeight / scaledSize;
3286 return scaledAspectRatio;
3289void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const
3294 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
3295 offset = QPointF( offsetX, offsetY );
3305 if ( hasDataDefinedRotation )
3326 map[QStringLiteral(
"imageFile" )] =
mPath;
3327 map[QStringLiteral(
"size" )] = QString::number(
mSize );
3330 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
3331 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3332 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
3344 std::unique_ptr< QgsRasterMarkerSymbolLayer > m = std::make_unique< QgsRasterMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
3367 return mSizeUnit == Qgis::RenderUnit::MapUnits ||
mSizeUnit == Qgis::RenderUnit::MetersInMapUnits
3388 bool hasDataDefinedSize =
false;
3389 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3391 bool hasDataDefinedAspectRatio =
false;
3392 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3396 if (
static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
3401 QPointF outputOffset;
3403 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3405 QTransform transform;
3408 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3411 transform.rotate(
angle );
3413 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
3418 return symbolBounds;
3430 mOrigSize = pointSize;
3431 mSizeUnit = Qgis::RenderUnit::Millimeters;
3436 mStrokeWidthUnit = Qgis::RenderUnit::Millimeters;
3450 if ( props.contains( QStringLiteral(
"font" ) ) )
3451 fontFamily = props[QStringLiteral(
"font" )].toString();
3452 if ( props.contains( QStringLiteral(
"chr" ) ) && props[QStringLiteral(
"chr" )].toString().length() > 0 )
3453 string = props[QStringLiteral(
"chr" )].toString();
3454 if ( props.contains( QStringLiteral(
"size" ) ) )
3455 pointSize = props[QStringLiteral(
"size" )].toDouble();
3456 if ( props.contains( QStringLiteral(
"color" ) ) )
3458 if ( props.contains( QStringLiteral(
"angle" ) ) )
3459 angle = props[QStringLiteral(
"angle" )].toDouble();
3463 if ( props.contains( QStringLiteral(
"font_style" ) ) )
3464 m->
setFontStyle( props[QStringLiteral(
"font_style" )].toString() );
3465 if ( props.contains( QStringLiteral(
"outline_color" ) ) )
3467 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
3468 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
3469 if ( props.contains( QStringLiteral(
"offset" ) ) )
3471 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
3473 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3475 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
3477 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
3479 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
3481 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3483 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
3485 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
3487 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3497 return QStringLiteral(
"FontMarker" );
3502 QColor brushColor =
mColor;
3503 QColor penColor = mStrokeColor;
3505 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3506 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3508 mBrush = QBrush( brushColor );
3509 mPen = QPen( penColor );
3510 mPen.setJoinStyle( mPenJoinStyle );
3514 if ( !mFontStyle.isEmpty() )
3522 if ( mNonZeroFontSize && sizePixels > MAX_FONT_CHARACTER_SIZE_IN_PIXELS )
3527 mFontSizeScale = sizePixels / MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3528 sizePixels = MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3531 mFontSizeScale = 1.0;
3535 mFont.setPixelSize( std::max( 2,
static_cast< int >( std::round( sizePixels ) ) ) );
3536 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3537 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3538 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3545 if ( mUseCachedPath )
3547 QPointF chrOffset = mChrOffset;
3549 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3550 mCachedPath = QPainterPath();
3551 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3560QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3562 charOffset = mChrOffset;
3563 QString stringToRender = mString;
3568 if ( stringToRender != mString )
3570 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3571 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3574 return stringToRender;
3579 bool &hasDataDefinedRotation,
3581 double &
angle )
const
3586 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3587 offset = QPointF( offsetX, offsetY );
3603 if ( hasDataDefinedRotation )
3627 double scaledSize =
mSize;
3631 if ( hasDataDefinedSize )
3637 if ( hasDataDefinedSize && ok )
3642 scaledSize = std::sqrt( scaledSize );
3654 if ( !p || !mNonZeroFontSize )
3657 QTransform transform;
3660 QColor brushColor =
mColor;
3669 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3671 mBrush.setColor( brushColor );
3673 QColor penColor = mStrokeColor;
3679 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3703 p->setBrush( mBrush );
3706 mPen.setColor( penColor );
3707 mPen.setWidthF( penWidth );
3712 p->setPen( Qt::NoPen );
3720 mFont.setFamily( processedFamily );
3730 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3733 QPointF chrOffset = mChrOffset;
3735 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3737 const double sizeToRender = calculateSize( context );
3739 bool hasDataDefinedRotation =
false;
3742 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation,
offset,
angle );
3744 p->translate( point.x() +
offset.x(), point.y() +
offset.y() );
3747 transform.rotate(
angle );
3751 const double s = sizeToRender / mOrigSize;
3752 transform.scale( s, s );
3756 transform.scale( mFontSizeScale, mFontSizeScale );
3758 if ( mUseCachedPath )
3760 p->drawPath( transform.map( mCachedPath ) );
3765 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3766 p->drawPath( transform.map( path ) );
3773 props[QStringLiteral(
"font" )] = mFontFamily;
3774 props[QStringLiteral(
"font_style" )] = mFontStyle;
3775 props[QStringLiteral(
"chr" )] = mString;
3776 props[QStringLiteral(
"size" )] = QString::number(
mSize );
3781 props[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
3785 props[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3818 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3819 element.appendChild( graphicElem );
3821 const QString fontPath = QStringLiteral(
"ttf://%1" ).arg( mFontFamily );
3822 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
3829 const double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3832 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
3847 return mSizeUnit == Qgis::RenderUnit::MapUnits ||
mSizeUnit == Qgis::RenderUnit::MetersInMapUnits
3848 || mStrokeWidthUnit == Qgis::RenderUnit::MapUnits || mStrokeWidthUnit == Qgis::RenderUnit::MetersInMapUnits
3855 mStrokeWidthUnit = unit;
3860 QPointF chrOffset = mChrOffset;
3861 double chrWidth = mChrWidth;
3863 ( void )characterToRender( context, chrOffset, chrWidth );
3865 if ( !mFontMetrics )
3866 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3868 double scaledSize = calculateSize( context );
3871 chrWidth *= scaledSize / mOrigSize;
3873 chrWidth *= mFontSizeScale;
3875 bool hasDataDefinedRotation =
false;
3878 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation,
offset,
angle );
3881 QTransform transform;
3884 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
3887 transform.rotate(
angle );
3889 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
3893 return symbolBounds;
3900 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
3901 if ( graphicElem.isNull() )
3904 QString name, format;
3912 if ( !name.startsWith( QLatin1String(
"ttf://" ) ) || format != QLatin1String(
"ttf" ) )
3922 const double d = angleFunc.toDouble( &ok );
3930 double scaleFactor = 1.0;
3931 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
3952 context.
pushMessage( QObject::tr(
"Font “%1” not available on system" ).arg( processedFamily ) );
3958 QMap<QString, QgsProperty>::iterator it =
mParameters.begin();
3970 QMap<QString, QgsProperty>::const_iterator it =
mParameters.constBegin();
3973 attrs.unite( it.value().referencedFields( context.
expressionContext(),
true ) );
3997 if (
properties.contains( QStringLiteral(
"imageFile" ) ) )
3999 if (
properties.contains( QStringLiteral(
"size" ) ) )
4001 if (
properties.contains( QStringLiteral(
"angle" ) ) )
4004 std::unique_ptr< QgsAnimatedMarkerSymbolLayer > m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
path,
size,
angle );
4005 m->setFrameRate(
properties.value( QStringLiteral(
"frameRate" ), QStringLiteral(
"10" ) ).toDouble() );
4013 return QStringLiteral(
"AnimatedMarker" );
4019 res.insert( QStringLiteral(
"frameRate" ), mFrameRateFps );
4025 std::unique_ptr< QgsAnimatedMarkerSymbolLayer > m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
4026 m->setFrameRate( mFrameRateFps );
4035 mPreparedPaths.clear();
4043 mStaticPath =
false;
4049 if ( !mStaticPath && !mPreparedPaths.contains(
path ) )
4052 mPreparedPaths.insert(
path );
4055 const long long mapFrameNumber = context.
currentFrame();
4057 const double markerAnimationDuration = totalFrameCount / mFrameRateFps;
4059 double animationTimeSeconds = 0;
4060 if ( mapFrameNumber >= 0 && context.
frameRate() > 0 )
4063 animationTimeSeconds = mapFrameNumber / context.
frameRate();
4068 animationTimeSeconds = QDateTime::currentMSecsSinceEpoch() / 1000.0;
4071 const double markerAnimationProgressSeconds = std::fmod( animationTimeSeconds, markerAnimationDuration );
4072 const int movieFrame =
static_cast< int >( std::floor( markerAnimationProgressSeconds * mFrameRateFps ) );
4074 bool cached =
false;
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
ScaleMethod
Scale methods.
@ ScaleDiameter
Calculate scale by the diameter.
@ ScaleArea
Calculate scale by the area.
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 (since QGIS 3.28)
@ AsteriskFill
A filled asterisk shape (since QGIS 3.18)
@ Octagon
Octagon (since QGIS 3.18)
@ HalfArc
A line-only half arc (since QGIS 3.20)
@ QuarterSquare
Quarter square (top left quarter)
@ Cross2
Rotated cross (lines only), 'x' shape.
@ Trapezoid
Trapezoid (since QGIS 3.28)
@ ArrowHeadFilled
Right facing filled arrow head.
@ Shield
A shape consisting of a triangle attached to a rectangle (since QGIS 3.28)
@ HalfSquare
Half square (left half)
@ CrossFill
Solid filled cross.
@ Decagon
Decagon (since QGIS 3.28)
@ RoundedSquare
A square with rounded corners (since QGIS 3.28)
@ RightHalfTriangle
Right half of triangle.
@ ThirdCircle
One third circle (top left third)
@ ThirdArc
A line-only one third arc (since QGIS 3.20)
@ SquareWithCorners
A square with diagonal corners (since QGIS 3.18)
@ QuarterArc
A line-only one quarter arc (since QGIS 3.20)
@ DiamondStar
A 4-sided star (since QGIS 3.28)
@ Cross
Cross (lines only)
@ ParallelogramLeft
Parallelogram that slants left (since QGIS 3.28)
@ Heart
Heart (since QGIS 3.28)
@ DiagonalHalfSquare
Diagonal half square (bottom left half)
RenderUnit
Rendering size 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,...
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color.
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.
Animated marker symbol layer class.
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...
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 QgsFillSymbol * createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
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.
~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.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
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())
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
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.
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.
Abstract base class for marker symbol layers.
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)
HorizontalAnchorPoint
Symbol horizontal anchor points.
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.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QPointF mOffset
Marker offset.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
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.
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
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.
VerticalAnchorPoint
Symbol vertical anchor points.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
VerticalAnchorPoint mVerticalAnchorPoint
Vertical 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
Resolves relative paths into absolute paths and vice versa.
Point geometry type, with support for z-dimension and m-values.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
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.
Raster marker symbol layer class.
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.
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.
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.
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.
The class is used as a container of context for various read/write operations on other 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.
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
long long currentFrame() const
Returns the current frame number of the map (in frames per second), for maps which are part of an ani...
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.
Abstract base class for simple marker symbol layers.
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)
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
QPen mSelPen
QPen to use as stroke of selected symbols.
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
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.
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
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.
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.
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.
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.
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 QColor decodeColor(const QString &str)
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 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 void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
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 void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
static QString encodeScaleMethod(Qgis::ScaleMethod scaleMethod)
Encodes a symbol scale method to a string.
static Qt::PenStyle decodePenStyle(const QString &str)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
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.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
@ PropertyCapStyle
Line cap style.
@ PropertyAngle
Symbol angle.
@ PropertySize
Symbol size.
@ PropertyJoinStyle
Line join style.
@ PropertyOpacity
Opacity.
@ PropertyCharacter
Character, eg for font marker symbol layers.
@ PropertyOffset
Symbol offset.
@ PropertyStrokeWidth
Stroke width.
@ PropertyFillColor
Fill color.
@ PropertyFontStyle
Font style.
@ PropertyHeight
Symbol height.
@ PropertyFontFamily
Font family.
@ PropertyName
Name, eg shape name for simple markers.
@ PropertyStrokeColor
Stroke color.
@ PropertyWidth
Symbol width.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
virtual void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
QgsPropertyCollection mDataDefinedProperties
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
const QgsFeature * feature() const
Returns the current feature being rendered.
QgsFields fields() const
Fields of the layer.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
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.
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)
Returns true if the specified variant should be considered a NULL value.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
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)
Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()
#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