34#include <QSvgRenderer>
37#include <QDomDocument>
46static constexpr int MAX_FONT_CHARACTER_SIZE_IN_PIXELS = 500;
48static void _fixQPictureDPI( QPainter *p )
54 p->scale(
static_cast< double >(
qt_defaultDpiX() ) / p->device()->logicalDpiX(),
55 static_cast< double >(
qt_defaultDpiY() ) / p->device()->logicalDpiY() );
68 QList< Qgis::MarkerShape > shapes;
183 QTransform transform;
186 if ( !hasDataDefinedSize )
196 const double half = scaledSize / 2.0;
197 transform.scale( half, half );
203 transform.rotate(
mAngle );
230 bool hasDataDefinedSize =
false;
231 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
233 bool hasDataDefinedRotation =
false;
239 bool createdNewPath =
false;
257 createdNewPath =
true;
266 QTransform transform;
269 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
272 if ( hasDataDefinedSize || createdNewPath )
281 const double half = s / 2.0;
282 transform.scale( half, half );
287 transform.rotate(
angle );
296 polygon = transform.map(
mPolygon );
300 path = transform.map(
mPath );
302 draw( context, symbol, polygon, path );
307 bool hasDataDefinedSize =
false;
308 double scaledSize =
calculateSize( context, hasDataDefinedSize );
310 bool hasDataDefinedRotation =
false;
317 QTransform transform;
320 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
323 transform.rotate(
angle );
325 return transform.mapRect( QRectF( -scaledSize / 2.0,
335 const QString cleaned = name.toLower().trimmed();
337 if ( cleaned == QLatin1String(
"square" ) || cleaned == QLatin1String(
"rectangle" ) )
339 else if ( cleaned == QLatin1String(
"trapezoid" ) )
341 else if ( cleaned == QLatin1String(
"parallelogram_right" ) )
343 else if ( cleaned == QLatin1String(
"parallelogram_left" ) )
345 else if ( cleaned == QLatin1String(
"square_with_corners" ) )
347 else if ( cleaned == QLatin1String(
"rounded_square" ) )
349 else if ( cleaned == QLatin1String(
"diamond" ) )
351 else if ( cleaned == QLatin1String(
"shield" ) )
353 else if ( cleaned == QLatin1String(
"pentagon" ) )
355 else if ( cleaned == QLatin1String(
"hexagon" ) )
357 else if ( cleaned == QLatin1String(
"octagon" ) )
359 else if ( cleaned == QLatin1String(
"decagon" ) )
361 else if ( cleaned == QLatin1String(
"triangle" ) )
363 else if ( cleaned == QLatin1String(
"equilateral_triangle" ) )
365 else if ( cleaned == QLatin1String(
"star_diamond" ) )
367 else if ( cleaned == QLatin1String(
"star" ) || cleaned == QLatin1String(
"regular_star" ) )
369 else if ( cleaned == QLatin1String(
"heart" ) )
371 else if ( cleaned == QLatin1String(
"arrow" ) )
373 else if ( cleaned == QLatin1String(
"circle" ) )
375 else if ( cleaned == QLatin1String(
"cross" ) )
377 else if ( cleaned == QLatin1String(
"cross_fill" ) )
379 else if ( cleaned == QLatin1String(
"cross2" ) || cleaned == QLatin1String(
"x" ) )
381 else if ( cleaned == QLatin1String(
"line" ) )
383 else if ( cleaned == QLatin1String(
"arrowhead" ) )
385 else if ( cleaned == QLatin1String(
"filled_arrowhead" ) )
387 else if ( cleaned == QLatin1String(
"semi_circle" ) )
389 else if ( cleaned == QLatin1String(
"third_circle" ) )
391 else if ( cleaned == QLatin1String(
"quarter_circle" ) )
393 else if ( cleaned == QLatin1String(
"quarter_square" ) )
395 else if ( cleaned == QLatin1String(
"half_square" ) )
397 else if ( cleaned == QLatin1String(
"diagonal_half_square" ) )
399 else if ( cleaned == QLatin1String(
"right_half_triangle" ) )
401 else if ( cleaned == QLatin1String(
"left_half_triangle" ) )
403 else if ( cleaned == QLatin1String(
"asterisk_fill" ) )
405 else if ( cleaned == QLatin1String(
"half_arc" ) )
407 else if ( cleaned == QLatin1String(
"third_arc" ) )
409 else if ( cleaned == QLatin1String(
"quarter_arc" ) )
422 return QStringLiteral(
"square" );
424 return QStringLiteral(
"quarter_square" );
426 return QStringLiteral(
"half_square" );
428 return QStringLiteral(
"diagonal_half_square" );
430 return QStringLiteral(
"parallelogram_right" );
432 return QStringLiteral(
"parallelogram_left" );
434 return QStringLiteral(
"trapezoid" );
436 return QStringLiteral(
"shield" );
438 return QStringLiteral(
"diamond" );
440 return QStringLiteral(
"pentagon" );
442 return QStringLiteral(
"hexagon" );
444 return QStringLiteral(
"octagon" );
446 return QStringLiteral(
"decagon" );
448 return QStringLiteral(
"square_with_corners" );
450 return QStringLiteral(
"rounded_square" );
452 return QStringLiteral(
"triangle" );
454 return QStringLiteral(
"equilateral_triangle" );
456 return QStringLiteral(
"left_half_triangle" );
458 return QStringLiteral(
"right_half_triangle" );
460 return QStringLiteral(
"star_diamond" );
462 return QStringLiteral(
"star" );
464 return QStringLiteral(
"heart" );
466 return QStringLiteral(
"arrow" );
468 return QStringLiteral(
"filled_arrowhead" );
470 return QStringLiteral(
"cross_fill" );
472 return QStringLiteral(
"circle" );
474 return QStringLiteral(
"cross" );
476 return QStringLiteral(
"cross2" );
478 return QStringLiteral(
"line" );
480 return QStringLiteral(
"arrowhead" );
482 return QStringLiteral(
"semi_circle" );
484 return QStringLiteral(
"third_circle" );
486 return QStringLiteral(
"quarter_circle" );
488 return QStringLiteral(
"asterisk_fill" );
490 return QStringLiteral(
"half_arc" );
492 return QStringLiteral(
"third_arc" );
494 return QStringLiteral(
"quarter_arc" );
511 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
516 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 0.6072;
518 polygon << QPointF( - VERTEX_OFFSET_FROM_ORIGIN, 1 )
519 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
520 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
521 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
522 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
523 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
524 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
525 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
526 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
531 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 0 ) ) );
535 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 1 ) ) );
539 polygon << QPointF( -1, -1 ) << QPointF( 1, 1 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
543 polygon << QPointF( 0.5, -0.5 )
545 << QPointF( -1, 0.5 )
546 << QPointF( -0.5, -0.5 )
547 << QPointF( 0.5, -0.5 );
551 polygon << QPointF( 0.5, 0.5 )
552 << QPointF( 1, -0.5 )
553 << QPointF( -0.5, -0.5 )
554 << QPointF( -1, 0.5 )
555 << QPointF( 0.5, 0.5 );
559 polygon << QPointF( 1, 0.5 )
560 << QPointF( 0.5, -0.5 )
561 << QPointF( -1, -0.5 )
562 << QPointF( -0.5, 0.5 )
563 << QPointF( 1, 0.5 );
567 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
568 << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
572 polygon << QPointF( 1, 0.5 )
575 << QPointF( -1, 0.5 )
577 << QPointF( 1, 0.5 );
587 polygon << QPointF( -0.9511, -0.3090 )
588 << QPointF( -0.5878, 0.8090 )
589 << QPointF( 0.5878, 0.8090 )
590 << QPointF( 0.9511, -0.3090 )
592 << QPointF( -0.9511, -0.3090 );
603 polygon << QPointF( -0.8660, -0.5 )
604 << QPointF( -0.8660, 0.5 )
606 << QPointF( 0.8660, 0.5 )
607 << QPointF( 0.8660, -0.5 )
609 << QPointF( -0.8660, -0.5 );
614 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 1.0 / ( 1 + M_SQRT2 );
616 polygon << QPointF( - VERTEX_OFFSET_FROM_ORIGIN, 1 )
617 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, 1 )
618 << QPointF( 1, VERTEX_OFFSET_FROM_ORIGIN )
619 << QPointF( 1, -VERTEX_OFFSET_FROM_ORIGIN )
620 << QPointF( VERTEX_OFFSET_FROM_ORIGIN, -1 )
621 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, -1 )
622 << QPointF( -1, -VERTEX_OFFSET_FROM_ORIGIN )
623 << QPointF( -1, VERTEX_OFFSET_FROM_ORIGIN )
624 << QPointF( -VERTEX_OFFSET_FROM_ORIGIN, 1 );
631 polygon << QPointF( 0.587785252, 0.809016994 )
632 << QPointF( 0.951056516, 0.309016994 )
633 << QPointF( 0.951056516, -0.309016994 )
634 << QPointF( 0.587785252, -0.809016994 )
636 << QPointF( -0.587785252, -0.809016994 )
637 << QPointF( -0.951056516, -0.309016994 )
638 << QPointF( -0.951056516, 0.309016994 )
639 << QPointF( -0.587785252, 0.809016994 )
641 << QPointF( 0.587785252, 0.809016994 );
646 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
654 polygon << QPointF( -0.8660, 0.5 )
655 << QPointF( 0.8660, 0.5 )
657 << QPointF( -0.8660, 0.5 );
661 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
665 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
670 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
672 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 315.0 ) ), - inner_r * std::cos(
DEG2RAD( 315.0 ) ) )
673 << QPointF( std::sin(
DEG2RAD( 270 ) ), - std::cos(
DEG2RAD( 270 ) ) )
674 << QPointF( inner_r * std::sin(
DEG2RAD( 225.0 ) ), - inner_r * std::cos(
DEG2RAD( 225.0 ) ) )
675 << QPointF( std::sin(
DEG2RAD( 180 ) ), - std::cos(
DEG2RAD( 180 ) ) )
676 << QPointF( inner_r * std::sin(
DEG2RAD( 135.0 ) ), - inner_r * std::cos(
DEG2RAD( 135.0 ) ) )
677 << QPointF( std::sin(
DEG2RAD( 90 ) ), - std::cos(
DEG2RAD( 90 ) ) )
678 << QPointF( inner_r * std::sin(
DEG2RAD( 45.0 ) ), - inner_r * std::cos(
DEG2RAD( 45.0 ) ) )
679 << QPointF( std::sin(
DEG2RAD( 0 ) ), - std::cos(
DEG2RAD( 0 ) ) );
685 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
687 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
688 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), - std::cos(
DEG2RAD( 288 ) ) )
689 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), - inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
690 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), - std::cos(
DEG2RAD( 216.0 ) ) )
691 << QPointF( 0, inner_r )
692 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), - std::cos(
DEG2RAD( 144.0 ) ) )
693 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), - inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
694 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), - std::cos(
DEG2RAD( 72.0 ) ) )
695 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), - inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
697 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
702 polygon << QPointF( 0, -1 )
703 << QPointF( 0.5, -0.5 )
704 << QPointF( 0.25, -0.5 )
705 << QPointF( 0.25, 1 )
706 << QPointF( -0.25, 1 )
707 << QPointF( -0.25, -0.5 )
708 << QPointF( -0.5, -0.5 )
713 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
717 polygon << QPointF( -1, -0.2 )
718 << QPointF( -1, -0.2 )
719 << QPointF( -1, 0.2 )
720 << QPointF( -0.2, 0.2 )
721 << QPointF( -0.2, 1 )
723 << QPointF( 0.2, 0.2 )
725 << QPointF( 1, -0.2 )
726 << QPointF( 0.2, -0.2 )
727 << QPointF( 0.2, -1 )
728 << QPointF( -0.2, -1 )
729 << QPointF( -0.2, -0.2 )
730 << QPointF( -1, -0.2 );
735 static constexpr double THICKNESS = 0.3;
736 static constexpr double HALF_THICKNESS = THICKNESS / 2.0;
737 static constexpr double INTERSECTION_POINT = THICKNESS / M_SQRT2;
738 static constexpr double DIAGONAL1 = M_SQRT1_2 - INTERSECTION_POINT * 0.5;
739 static constexpr double DIAGONAL2 = M_SQRT1_2 + INTERSECTION_POINT * 0.5;
741 polygon << QPointF( -HALF_THICKNESS, -1 )
742 << QPointF( HALF_THICKNESS, -1 )
743 << QPointF( HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
744 << QPointF( DIAGONAL1, -DIAGONAL2 )
745 << QPointF( DIAGONAL2, -DIAGONAL1 )
746 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, -HALF_THICKNESS )
747 << QPointF( 1, -HALF_THICKNESS )
748 << QPointF( 1, HALF_THICKNESS )
749 << QPointF( HALF_THICKNESS + INTERSECTION_POINT, HALF_THICKNESS )
750 << QPointF( DIAGONAL2, DIAGONAL1 )
751 << QPointF( DIAGONAL1, DIAGONAL2 )
752 << QPointF( HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
753 << QPointF( HALF_THICKNESS, 1 )
754 << QPointF( -HALF_THICKNESS, 1 )
755 << QPointF( -HALF_THICKNESS, HALF_THICKNESS + INTERSECTION_POINT )
756 << QPointF( -DIAGONAL1, DIAGONAL2 )
757 << QPointF( -DIAGONAL2, DIAGONAL1 )
758 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, HALF_THICKNESS )
759 << QPointF( -1, HALF_THICKNESS )
760 << QPointF( -1, -HALF_THICKNESS )
761 << QPointF( -HALF_THICKNESS - INTERSECTION_POINT, -HALF_THICKNESS )
762 << QPointF( -DIAGONAL2, -DIAGONAL1 )
763 << QPointF( -DIAGONAL1, -DIAGONAL2 )
764 << QPointF( -HALF_THICKNESS, -HALF_THICKNESS - INTERSECTION_POINT )
765 << QPointF( -HALF_THICKNESS, -1 );
790 mPath = QPainterPath();
796 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
800 mPath.moveTo( -1, -1 );
801 mPath.addRoundedRect( -1, -1, 2, 2, 0.25, 0.25 );
805 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
806 mPath.lineTo( 0, 0 );
810 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
811 mPath.lineTo( 0, 0 );
815 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
816 mPath.lineTo( 0, 0 );
820 mPath.moveTo( 1, 0 );
821 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
825 mPath.moveTo( 0, -1 );
826 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
830 mPath.moveTo( 0, -1 );
831 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
835 mPath.moveTo( -1, 0 );
836 mPath.lineTo( 1, 0 );
837 mPath.moveTo( 0, -1 );
838 mPath.lineTo( 0, 1 );
842 mPath.moveTo( -1, -1 );
843 mPath.lineTo( 1, 1 );
844 mPath.moveTo( 1, -1 );
845 mPath.lineTo( -1, 1 );
849 mPath.moveTo( 0, -1 );
850 mPath.lineTo( 0, 1 );
854 mPath.moveTo( -1, -1 );
855 mPath.lineTo( 0, 0 );
856 mPath.lineTo( -1, 1 );
860 mPath.moveTo( 0, 0.75 );
861 mPath.arcTo( 0, -1, 1, 1, -45, 210 );
862 mPath.arcTo( -1, -1, 1, 1, 15, 210 );
863 mPath.lineTo( 0, 0.75 );
897 double scaledSize =
mSize;
901 if ( hasDataDefinedSize )
908 if ( hasDataDefinedSize && ok )
913 scaledSize = std::sqrt( scaledSize );
928 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
929 offset = QPointF( offsetX, offsetY );
931 hasDataDefinedRotation =
false;
944 hasDataDefinedRotation =
true;
949 if ( hasDataDefinedRotation )
978 , mStrokeColor( strokeColor )
979 , mPenJoinStyle( penJoinStyle )
996 if ( props.contains( QStringLiteral(
"name" ) ) )
1000 if ( props.contains( QStringLiteral(
"color" ) ) )
1002 if ( props.contains( QStringLiteral(
"color_border" ) ) )
1007 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
1011 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
1015 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
1019 if ( props.contains( QStringLiteral(
"size" ) ) )
1020 size = props[QStringLiteral(
"size" )].toDouble();
1021 if ( props.contains( QStringLiteral(
"angle" ) ) )
1022 angle = props[QStringLiteral(
"angle" )].toDouble();
1023 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1027 if ( props.contains( QStringLiteral(
"offset" ) ) )
1029 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1031 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1033 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1035 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1038 if ( props.contains( QStringLiteral(
"outline_style" ) ) )
1042 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
1046 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
1048 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
1050 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
1052 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
1054 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
1058 if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
1062 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1067 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1071 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1076 if ( props.contains( QStringLiteral(
"cap_style" ) ) )
1089 return QStringLiteral(
"SimpleMarker" );
1096 QColor brushColor =
mColor;
1099 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
1102 mBrush = QBrush( brushColor );
1103 mPen = QPen( penColor );
1113 selBrushColor.setAlphaF( context.
opacity() );
1114 selPenColor.setAlphaF( context.
opacity() );
1117 mSelPen = QPen( selPenColor );
1133 mCachedOpacity = context.
opacity();
1139 mSelPen.setColor( selBrushColor );
1171 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
1174 const double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
1175 const int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
1176 const double center = imageSize / 2.0;
1182 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
1189 p.setRenderHint( QPainter::Antialiasing );
1190 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1192 p.translate( QPointF( center, center ) );
1200 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
1204 p.setRenderHint( QPainter::Antialiasing );
1205 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
1207 p.translate( QPointF( center, center ) );
1218 p.setRenderHint( QPainter::Antialiasing );
1219 p.fillRect( 0, 0, imageSize, imageSize, selColor );
1220 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
1222 p.translate( QPointF( center, center ) );
1241 QColor brushColor =
mColor;
1242 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
1243 mBrush.setColor( brushColor );
1246 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
1247 mPen.setColor( penColor );
1256 c.setAlphaF(
c.alphaF() * context.
opacity() );
1266 c.setAlphaF(
c.alphaF() * context.
opacity() );
1318 p->setBrush( Qt::NoBrush );
1322 if ( !polygon.isEmpty() )
1323 p->drawPolygon( polygon );
1325 p->drawPath( path );
1342 const double s = img.width();
1344 bool hasDataDefinedSize =
false;
1345 const double scaledSize =
calculateSize( context, hasDataDefinedSize );
1347 bool hasDataDefinedRotation =
false;
1352 p->drawImage( QRectF( point.x() - s / 2.0 +
offset.x(),
1353 point.y() - s / 2.0 +
offset.y(),
1368 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1371 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1377 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
1410 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1411 element.appendChild( graphicElem );
1420 const double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
1423 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
1438 Q_UNUSED( mmScaleFactor )
1439 Q_UNUSED( mapUnitScaleFactor )
1441 QString ogrType =
"3";
1442 if ( mName ==
"square" )
1446 else if ( mName ==
"triangle" )
1450 else if ( mName ==
"star" )
1454 else if ( mName ==
"circle" )
1458 else if ( mName ==
"cross" )
1462 else if ( mName ==
"x" || mName ==
"cross2" )
1466 else if ( mName ==
"line" )
1472 ogrString.append(
"SYMBOL(" );
1473 ogrString.append(
"id:" );
1474 ogrString.append(
'\"' );
1475 ogrString.append(
"ogr-sym-" );
1476 ogrString.append( ogrType );
1477 ogrString.append(
'\"' );
1478 ogrString.append(
",c:" );
1479 ogrString.append(
mColor.name() );
1480 ogrString.append(
",o:" );
1482 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1483 ogrString.append(
')' );
1488 ogrString.append(
"PEN(" );
1489 ogrString.append(
"c:" );
1490 ogrString.append(
mColor.name() );
1491 ogrString.append(
",w:" );
1492 ogrString.append( QString::number(
mSize ) );
1493 ogrString.append(
"mm" );
1494 ogrString.append(
")" );
1502 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1503 if ( graphicElem.isNull() )
1506 QString name = QStringLiteral(
"square" );
1519 const double d = angleFunc.toDouble( &ok );
1529 double scaleFactor = 1.0;
1530 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
1557 p->drawPath(
mPath );
1570 if ( hasDataDefinedSize )
1591 size *= mmMapUnitScaleFactor;
1598 const double halfSize =
size / 2.0;
1615 QColor pc =
mPen.color();
1616 QColor bc =
mBrush.color();
1636 QPointF off( offsetX, offsetY );
1665 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1673 t.scale( halfSize, -halfSize );
1675 polygon = t.map( polygon );
1678 p.reserve( polygon.size() );
1679 for (
int i = 0; i < polygon.size(); i++ )
1684 if (
mBrush.style() != Qt::NoBrush )
1686 if (
mPen.style() != Qt::NoPen )
1691 shift += QPointF( off.x(), -off.y() );
1692 if (
mBrush.style() != Qt::NoBrush )
1694 if (
mPen.style() != Qt::NoPen )
1699 const QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1700 const QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1702 if (
mPen.style() != Qt::NoPen )
1707 if (
mPen.style() != Qt::NoPen )
1709 const QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1710 const QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1711 const QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1712 const QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1720 if (
mPen.style() != Qt::NoPen )
1722 const QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1723 const QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1724 const QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1725 const QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1733 if (
mPen.style() != Qt::NoPen )
1735 const QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1736 const QPointF pt2 = t.map( QPointF( 0, 0 ) );
1737 const QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1823 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1824 penWidth / 2.0, penWidth / 2.0 );
1826 return symbolBounds;
1875 if ( props.contains( QStringLiteral(
"name" ) ) )
1876 name = props[QStringLiteral(
"name" )].toString();
1877 if ( props.contains( QStringLiteral(
"size" ) ) )
1878 size = props[QStringLiteral(
"size" )].toDouble();
1879 if ( props.contains( QStringLiteral(
"angle" ) ) )
1880 angle = props[QStringLiteral(
"angle" )].toDouble();
1881 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1885 if ( props.contains( QStringLiteral(
"offset" ) ) )
1887 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1889 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1891 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1893 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1895 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1899 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1913 return QStringLiteral(
"FilledMarker" );
1938 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1941 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1997 attr.unite( mFill->usedAttributes( context ) );
2005 if ( mFill && mFill->hasDataDefinedProperties() )
2014 mFill->setColor(
c );
2019 return mFill ? mFill->color() :
mColor;
2026 || ( mFill && mFill->usesMapUnits() );
2033 mFill->setOutputUnit( unit );
2047 const double prevOpacity = mFill->opacity();
2048 mFill->setOpacity( mFill->opacity() * context.
opacity() );
2052 p->setBrush( Qt::red );
2056 p->setBrush( Qt::NoBrush );
2058 p->setPen( Qt::black );
2063 if ( !polygon.isEmpty() )
2069 const QPolygonF poly = path.toFillPolygon();
2075 mFill->setOpacity( prevOpacity );
2090 mColor = QColor( 35, 35, 35 );
2104 if ( props.contains( QStringLiteral(
"name" ) ) )
2105 name = props[QStringLiteral(
"name" )].toString();
2106 if ( props.contains( QStringLiteral(
"size" ) ) )
2107 size = props[QStringLiteral(
"size" )].toDouble();
2108 if ( props.contains( QStringLiteral(
"angle" ) ) )
2109 angle = props[QStringLiteral(
"angle" )].toDouble();
2110 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
2115 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2117 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2119 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
2121 if ( props.contains( QStringLiteral(
"offset" ) ) )
2123 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2125 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2127 if ( props.contains( QStringLiteral(
"fill" ) ) )
2132 else if ( props.contains( QStringLiteral(
"color" ) ) )
2136 if ( props.contains( QStringLiteral(
"outline" ) ) )
2141 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
2145 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
2150 if ( props.contains( QStringLiteral(
"outline-width" ) ) )
2153 m->
setStrokeWidth( props[QStringLiteral(
"outline-width" )].toDouble() );
2155 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
2157 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
2159 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
2161 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
2164 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
2168 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
2172 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2175 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2179 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
2188 if ( props.contains( QStringLiteral(
"parameters" ) ) )
2190 const QVariantMap
parameters = props[QStringLiteral(
"parameters" )].toMap();
2199 const QVariantMap::iterator it =
properties.find( QStringLiteral(
"name" ) );
2218 QColor defaultFillColor, defaultStrokeColor;
2220 bool hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
2221 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
2223 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
2224 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2225 hasStrokeWidthParam, hasDefaultStrokeWidth,
strokeWidth,
2226 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
2228 const double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
2229 const double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
2231 if ( hasDefaultFillColor )
2233 defaultFillColor.setAlphaF( newFillOpacity );
2236 if ( hasDefaultFillOpacity )
2239 c.setAlphaF( fillOpacity );
2242 if ( hasDefaultStrokeColor )
2244 defaultStrokeColor.setAlphaF( newStrokeOpacity );
2247 if ( hasDefaultStrokeWidth )
2251 if ( hasDefaultStrokeOpacity )
2254 c.setAlphaF( strokeOpacity );
2268 const double widthScaleFactor = 3.465;
2271 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
2279 if ( aPreservedAspectRatio && !par )
2283 else if ( !aPreservedAspectRatio && par )
2298 return QStringLiteral(
"SvgMarker" );
2318 bool hasDataDefinedSize =
false;
2319 const double scaledWidth = calculateSize( context, hasDataDefinedSize );
2323 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
2330 bool hasDataDefinedAspectRatio =
false;
2331 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2374 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2378 QPointF outputOffset;
2380 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2382 p->translate( point + outputOffset );
2388 bool fitsInCache =
true;
2389 bool usePict =
true;
2396 if ( fitsInCache && img.width() > 1 )
2408 QImage transparentImage = img.copy();
2410 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2414 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2419 if ( usePict || !fitsInCache )
2421 p->setOpacity( context.
opacity() );
2425 if ( pct.width() > 1 )
2428 _fixQPictureDPI( p );
2429 p->drawPicture( 0, 0, pct );
2437double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2439 double scaledSize =
mSize;
2443 if ( hasDataDefinedSize )
2451 if ( hasDataDefinedSize )
2458 if ( hasDataDefinedSize && ok )
2463 scaledSize = std::sqrt( scaledSize );
2476 if ( !hasDataDefinedAspectRatio )
2486 const double defaultHeight =
mSize * scaledAspectRatio;
2487 scaledAspectRatio = defaultHeight / scaledSize;
2490 double scaledHeight = scaledSize * scaledAspectRatio;
2497 if ( hasDataDefinedAspectRatio && ok )
2502 scaledHeight = sqrt( scaledHeight );
2509 scaledAspectRatio = scaledHeight / scaledSize;
2511 return scaledAspectRatio;
2514void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const
2519 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2520 offset = QPointF( offsetX, offsetY );
2530 if ( hasDataDefinedRotation )
2556 map[QStringLiteral(
"name" )] =
mPath;
2557 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2560 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2561 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2568 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
2643 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2644 element.appendChild( graphicElem );
2654 const double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2657 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
2675 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
2676 if ( graphicElem.isNull() )
2679 QString
path, mimeType;
2687 double scaleFactor = 1.0;
2688 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
2692 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2700 const double d = angleFunc.toDouble( &ok );
2709 QString realPath {
path };
2710 QUrl svgUrl {
path };
2713 QUrlQuery queryString;
2715 if ( svgUrl.hasQuery() && svgUrl.hasFragment() )
2717 const QString queryPart {
path.mid(
path.indexOf(
'?' ) + 1 ) };
2718 queryString.setQuery( queryPart );
2722 if ( svgUrl.scheme().isEmpty() || svgUrl.isLocalFile() )
2724 svgUrl.setQuery( QString() );
2725 realPath = svgUrl.path();
2730 QMap<QString, QgsProperty> params;
2734 if ( queryString.hasQueryItem( QStringLiteral(
"fill" ) ) )
2736 const QColor
fillColor { queryString.queryItemValue( QStringLiteral(
"fill" ) ) };
2740 if ( queryString.hasQueryItem( QStringLiteral(
"fill-opacity" ) ) )
2742 const double alpha { queryString.queryItemValue( QStringLiteral(
"fill-opacity" ) ).toDouble( &ok ) };
2749 if ( queryString.hasQueryItem( QStringLiteral(
"outline" ) ) )
2751 const QColor
strokeColor { queryString.queryItemValue( QStringLiteral(
"outline" ) ) };
2755 if ( queryString.hasQueryItem( QStringLiteral(
"outline-opacity" ) ) )
2757 const double alpha { queryString.queryItemValue( QStringLiteral(
"outline-opacity" ) ).toDouble( &ok ) };
2764 if ( queryString.hasQueryItem( QStringLiteral(
"outline-width" ) ) )
2766 const int width { queryString.queryItemValue( QStringLiteral(
"outline-width" ) ).toInt( &ok )};
2773 if ( ! params.isEmpty() )
2792 if ( hasDataDefinedSize )
2798 if ( hasDataDefinedSize && ok )
2812 size *= mmMapUnitScaleFactor;
2826 const double offsetX =
offset.x();
2827 const double offsetY =
offset.y();
2829 QPointF outputOffset( offsetX, offsetY );
2879 QSvgRenderer r( svgContent );
2886 QSizeF outSize( r.defaultSize() );
2887 outSize.scale(
size,
size, Qt::KeepAspectRatio );
2893 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2895 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2897 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2898 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2907 bool hasDataDefinedSize =
false;
2908 double scaledWidth = calculateSize( context, hasDataDefinedSize );
2910 bool hasDataDefinedAspectRatio =
false;
2911 const double aspectRatio =
calculateAspectRatio( context, scaledWidth, hasDataDefinedAspectRatio );
2918 if (
static_cast< int >( scaledWidth ) < 1 || 10000.0 < scaledWidth )
2923 QPointF outputOffset;
2925 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2964 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2968 QTransform transform;
2970 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2973 transform.rotate(
angle );
2978 QRectF symbolBounds = transform.mapRect( QRectF( -scaledWidth / 2.0,
2979 -scaledHeight / 2.0,
2987 return symbolBounds;
3011 if ( props.contains( QStringLiteral(
"imageFile" ) ) )
3012 path = props[QStringLiteral(
"imageFile" )].toString();
3013 if ( props.contains( QStringLiteral(
"size" ) ) )
3014 size = props[QStringLiteral(
"size" )].toDouble();
3015 if ( props.contains( QStringLiteral(
"angle" ) ) )
3016 angle = props[QStringLiteral(
"angle" )].toDouble();
3017 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
3020 std::unique_ptr< QgsRasterMarkerSymbolLayer > m = std::make_unique< QgsRasterMarkerSymbolLayer >(
path,
size,
angle,
scaleMethod );
3021 m->setCommonProperties( props );
3027 if (
properties.contains( QStringLiteral(
"alpha" ) ) )
3032 if (
properties.contains( QStringLiteral(
"size_unit" ) ) )
3034 if (
properties.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
3036 if (
properties.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
3039 if (
properties.contains( QStringLiteral(
"offset" ) ) )
3041 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
3043 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3046 if (
properties.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
3050 if (
properties.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3061 const QVariantMap::iterator it =
properties.find( QStringLiteral(
"name" ) );
3062 if ( it !=
properties.end() && it.value().type() == QVariant::String )
3080 if ( aPreservedAspectRatio && !par )
3084 else if ( !aPreservedAspectRatio && par )
3103 return QStringLiteral(
"RasterMarker" );
3119 if (
path.isEmpty() )
3123 double height = 0.0;
3125 bool hasDataDefinedSize =
false;
3126 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3128 bool hasDataDefinedAspectRatio =
false;
3129 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3131 QPointF outputOffset;
3138 if (
size.isEmpty() )
3141 width = ( scaledSize *
static_cast< double >(
size.width() ) ) / 100.0;
3142 height = ( scaledSize *
static_cast< double >(
size.height() ) ) / 100.0;
3145 if (
static_cast< int >( width ) < 1 || 10000.0 < width ||
static_cast< int >( height ) < 1 || 10000.0 < height )
3148 calculateOffsetAndRotation( context, width, height, outputOffset,
angle );
3158 if ( !
size.isNull() &&
size.isValid() &&
size.width() > 0 )
3160 height = width * (
static_cast< double >(
size.height() ) /
static_cast< double >(
size.width() ) );
3165 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
3168 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3172 p->translate( point + outputOffset );
3187 if ( !img.isNull() )
3194 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
3200 bool cached =
false;
3204double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
3206 double scaledSize =
mSize;
3210 if ( hasDataDefinedSize )
3218 if ( hasDataDefinedSize )
3225 if ( hasDataDefinedSize && ok )
3230 scaledSize = std::sqrt( scaledSize );
3243 if ( !hasDataDefinedAspectRatio )
3253 const double defaultHeight =
mSize * scaledAspectRatio;
3254 scaledAspectRatio = defaultHeight / scaledSize;
3257 double scaledHeight = scaledSize * scaledAspectRatio;
3264 if ( hasDataDefinedAspectRatio && ok )
3269 scaledHeight = sqrt( scaledHeight );
3276 scaledAspectRatio = scaledHeight / scaledSize;
3278 return scaledAspectRatio;
3281void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const
3286 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
3287 offset = QPointF( offsetX, offsetY );
3297 if ( hasDataDefinedRotation )
3318 map[QStringLiteral(
"imageFile" )] =
mPath;
3319 map[QStringLiteral(
"size" )] = QString::number(
mSize );
3322 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
3323 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3324 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
3336 std::unique_ptr< QgsRasterMarkerSymbolLayer > m = std::make_unique< QgsRasterMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
3380 bool hasDataDefinedSize =
false;
3381 const double scaledSize = calculateSize( context, hasDataDefinedSize );
3383 bool hasDataDefinedAspectRatio =
false;
3384 const double aspectRatio =
calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
3388 if (
static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
3393 QPointF outputOffset;
3395 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
3397 QTransform transform;
3400 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
3403 transform.rotate(
angle );
3405 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
3410 return symbolBounds;
3422 mOrigSize = pointSize;
3442 if ( props.contains( QStringLiteral(
"font" ) ) )
3443 fontFamily = props[QStringLiteral(
"font" )].toString();
3444 if ( props.contains( QStringLiteral(
"chr" ) ) && props[QStringLiteral(
"chr" )].toString().length() > 0 )
3445 string = props[QStringLiteral(
"chr" )].toString();
3446 if ( props.contains( QStringLiteral(
"size" ) ) )
3447 pointSize = props[QStringLiteral(
"size" )].toDouble();
3448 if ( props.contains( QStringLiteral(
"color" ) ) )
3450 if ( props.contains( QStringLiteral(
"angle" ) ) )
3451 angle = props[QStringLiteral(
"angle" )].toDouble();
3455 if ( props.contains( QStringLiteral(
"font_style" ) ) )
3456 m->
setFontStyle( props[QStringLiteral(
"font_style" )].toString() );
3457 if ( props.contains( QStringLiteral(
"outline_color" ) ) )
3459 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
3460 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
3461 if ( props.contains( QStringLiteral(
"offset" ) ) )
3463 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
3465 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3467 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
3469 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
3471 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
3473 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3475 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
3477 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
3479 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3489 return QStringLiteral(
"FontMarker" );
3494 QColor brushColor =
mColor;
3495 QColor penColor = mStrokeColor;
3497 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3498 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3500 mBrush = QBrush( brushColor );
3501 mPen = QPen( penColor );
3502 mPen.setJoinStyle( mPenJoinStyle );
3506 if ( !mFontStyle.isEmpty() )
3514 if ( mNonZeroFontSize && sizePixels > MAX_FONT_CHARACTER_SIZE_IN_PIXELS )
3519 mFontSizeScale = sizePixels / MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3520 sizePixels = MAX_FONT_CHARACTER_SIZE_IN_PIXELS;
3523 mFontSizeScale = 1.0;
3527 mFont.setPixelSize( std::max( 2,
static_cast< int >( std::round( sizePixels ) ) ) );
3528 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3529 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3530 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3537 if ( mUseCachedPath )
3539 QPointF chrOffset = mChrOffset;
3541 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3542 mCachedPath = QPainterPath();
3543 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3552QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3554 charOffset = mChrOffset;
3555 QString stringToRender = mString;
3560 if ( stringToRender != mString )
3562 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3563 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3566 return stringToRender;
3571 bool &hasDataDefinedRotation,
3573 double &
angle )
const
3578 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3579 offset = QPointF( offsetX, offsetY );
3595 if ( hasDataDefinedRotation )
3619 double scaledSize =
mSize;
3623 if ( hasDataDefinedSize )
3629 if ( hasDataDefinedSize && ok )
3634 scaledSize = std::sqrt( scaledSize );
3646 if ( !p || !mNonZeroFontSize )
3649 QTransform transform;
3652 QColor brushColor =
mColor;
3661 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3663 mBrush.setColor( brushColor );
3665 QColor penColor = mStrokeColor;
3671 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3695 p->setBrush( mBrush );
3698 mPen.setColor( penColor );
3699 mPen.setWidthF( penWidth );
3704 p->setPen( Qt::NoPen );
3712 mFont.setFamily( processedFamily );
3722 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3725 QPointF chrOffset = mChrOffset;
3727 const QString charToRender = characterToRender( context, chrOffset, chrWidth );
3729 const double sizeToRender = calculateSize( context );
3731 bool hasDataDefinedRotation =
false;
3734 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation,
offset,
angle );
3736 p->translate( point.x() +
offset.x(), point.y() +
offset.y() );
3739 transform.rotate(
angle );
3743 const double s = sizeToRender / mOrigSize;
3744 transform.scale( s, s );
3748 transform.scale( mFontSizeScale, mFontSizeScale );
3750 if ( mUseCachedPath )
3752 p->drawPath( transform.map( mCachedPath ) );
3757 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3758 p->drawPath( transform.map( path ) );
3765 props[QStringLiteral(
"font" )] = mFontFamily;
3766 props[QStringLiteral(
"font_style" )] = mFontStyle;
3767 props[QStringLiteral(
"chr" )] = mString;
3768 props[QStringLiteral(
"size" )] = QString::number(
mSize );
3773 props[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
3777 props[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3810 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3811 element.appendChild( graphicElem );
3813 const QString fontPath = QStringLiteral(
"ttf://%1" ).arg( mFontFamily );
3814 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
3821 const double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3824 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
3847 mStrokeWidthUnit = unit;
3852 QPointF chrOffset = mChrOffset;
3853 double chrWidth = mChrWidth;
3855 ( void )characterToRender( context, chrOffset, chrWidth );
3857 if ( !mFontMetrics )
3858 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3860 double scaledSize = calculateSize( context );
3863 chrWidth *= scaledSize / mOrigSize;
3865 chrWidth *= mFontSizeScale;
3867 bool hasDataDefinedRotation =
false;
3870 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation,
offset,
angle );
3873 QTransform transform;
3876 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
3879 transform.rotate(
angle );
3881 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
3885 return symbolBounds;
3892 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
3893 if ( graphicElem.isNull() )
3896 QString name, format;
3904 if ( !name.startsWith( QLatin1String(
"ttf://" ) ) || format != QLatin1String(
"ttf" ) )
3914 const double d = angleFunc.toDouble( &ok );
3922 double scaleFactor = 1.0;
3923 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
3944 context.
pushMessage( QObject::tr(
"Font “%1” not available on system" ).arg( processedFamily ) );
3950 QMap<QString, QgsProperty>::iterator it =
mParameters.begin();
3962 QMap<QString, QgsProperty>::const_iterator it =
mParameters.constBegin();
3965 attrs.unite( it.value().referencedFields( context.
expressionContext(),
true ) );
3989 if (
properties.contains( QStringLiteral(
"imageFile" ) ) )
3991 if (
properties.contains( QStringLiteral(
"size" ) ) )
3993 if (
properties.contains( QStringLiteral(
"angle" ) ) )
3996 std::unique_ptr< QgsAnimatedMarkerSymbolLayer > m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
path,
size,
angle );
3997 m->setFrameRate(
properties.value( QStringLiteral(
"frameRate" ), QStringLiteral(
"10" ) ).toDouble() );
4005 return QStringLiteral(
"AnimatedMarker" );
4011 res.insert( QStringLiteral(
"frameRate" ), mFrameRateFps );
4017 std::unique_ptr< QgsAnimatedMarkerSymbolLayer > m = std::make_unique< QgsAnimatedMarkerSymbolLayer >(
mPath,
mSize,
mAngle );
4018 m->setFrameRate( mFrameRateFps );
4027 mPreparedPaths.clear();
4035 mStaticPath =
false;
4041 if ( !mStaticPath && !mPreparedPaths.contains(
path ) )
4044 mPreparedPaths.insert(
path );
4047 const long long mapFrameNumber = context.
currentFrame();
4049 const double markerAnimationDuration = totalFrameCount / mFrameRateFps;
4051 double animationTimeSeconds = 0;
4052 if ( mapFrameNumber >= 0 && context.
frameRate() > 0 )
4055 animationTimeSeconds = mapFrameNumber / context.
frameRate();
4060 animationTimeSeconds = QDateTime::currentMSecsSinceEpoch() / 1000.0;
4063 const double markerAnimationProgressSeconds = std::fmod( animationTimeSeconds, markerAnimationDuration );
4064 const int movieFrame =
static_cast< int >( std::floor( markerAnimationProgressSeconds * mFrameRateFps ) );
4066 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)
@ 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)
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)
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
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.
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.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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.
~QgsFontMarkerSymbolLayer() override
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
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 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.
QgsWkbTypes::GeometryType type
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.
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 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.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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.
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.
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
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.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
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.
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.
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 ...
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
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 setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
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.
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).
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void drawMarker(QPainter *p, QgsSymbolRenderContext &context)
Draws the marker shape in the specified painter.
QPen mPen
QPen corresponding to marker's stroke style.
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
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.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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)
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Stroke width units.
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.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
QString layerType() const override
Returns a string that represents this layer type.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QString path() const
Returns the marker SVG path.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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 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...
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
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 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
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 double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QVariantMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
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 Qt::PenCapStyle decodePenCapStyle(const QString &str)
static QgsUnitTypes::RenderUnit decodeSldUom(const QString &str, double *scaleFactor=nullptr)
Decodes a SLD unit of measure string to a render unit.
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 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 QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
RenderUnit
Rendering size units.
@ RenderUnknownUnit
Mixed or unknown units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
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