QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
31 #include <QSvgRenderer>
34 #include <QDomDocument>
35 #include <QDomElement>
42 static void _fixQPictureDPI( QPainter *p )
48 p->scale(
static_cast< double >(
qt_defaultDpiX() ) / p->device()->logicalDpiX(),
49 static_cast< double >(
qt_defaultDpiY() ) / p->device()->logicalDpiY() );
62 QList< Shape > shapes;
146 QTransform transform;
149 if ( !hasDataDefinedSize )
159 double half = scaledSize / 2.0;
160 transform.scale( half, half );
166 transform.rotate(
mAngle );
193 bool hasDataDefinedSize =
false;
194 double scaledSize =
calculateSize( context, hasDataDefinedSize );
196 bool hasDataDefinedRotation =
false;
202 bool createdNewPath =
false;
209 if ( exprVal.isValid() )
220 createdNewPath =
true;
229 QTransform transform;
232 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
235 if ( hasDataDefinedSize || createdNewPath )
244 double half = s / 2.0;
245 transform.scale( half, half );
250 transform.rotate(
angle );
259 polygon = transform.map(
mPolygon );
263 path = transform.map(
mPath );
265 draw( context, symbol, polygon, path );
270 bool hasDataDefinedSize =
false;
271 double scaledSize =
calculateSize( context, hasDataDefinedSize );
273 bool hasDataDefinedRotation =
false;
280 QTransform transform;
283 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
286 transform.rotate(
angle );
288 return transform.mapRect( QRectF( -scaledSize / 2.0,
298 QString cleaned = name.toLower().trimmed();
300 if ( cleaned == QLatin1String(
"square" ) || cleaned == QLatin1String(
"rectangle" ) )
302 else if ( cleaned == QLatin1String(
"diamond" ) )
304 else if ( cleaned == QLatin1String(
"pentagon" ) )
306 else if ( cleaned == QLatin1String(
"hexagon" ) )
308 else if ( cleaned == QLatin1String(
"triangle" ) )
310 else if ( cleaned == QLatin1String(
"equilateral_triangle" ) )
312 else if ( cleaned == QLatin1String(
"star" ) || cleaned == QLatin1String(
"regular_star" ) )
314 else if ( cleaned == QLatin1String(
"arrow" ) )
316 else if ( cleaned == QLatin1String(
"circle" ) )
318 else if ( cleaned == QLatin1String(
"cross" ) )
320 else if ( cleaned == QLatin1String(
"cross_fill" ) )
322 else if ( cleaned == QLatin1String(
"cross2" ) || cleaned == QLatin1String(
"x" ) )
324 else if ( cleaned == QLatin1String(
"line" ) )
326 else if ( cleaned == QLatin1String(
"arrowhead" ) )
328 else if ( cleaned == QLatin1String(
"filled_arrowhead" ) )
330 else if ( cleaned == QLatin1String(
"semi_circle" ) )
332 else if ( cleaned == QLatin1String(
"third_circle" ) )
334 else if ( cleaned == QLatin1String(
"quarter_circle" ) )
336 else if ( cleaned == QLatin1String(
"quarter_square" ) )
338 else if ( cleaned == QLatin1String(
"half_square" ) )
340 else if ( cleaned == QLatin1String(
"diagonal_half_square" ) )
342 else if ( cleaned == QLatin1String(
"right_half_triangle" ) )
344 else if ( cleaned == QLatin1String(
"left_half_triangle" ) )
357 return QStringLiteral(
"square" );
359 return QStringLiteral(
"quarter_square" );
361 return QStringLiteral(
"half_square" );
363 return QStringLiteral(
"diagonal_half_square" );
365 return QStringLiteral(
"diamond" );
367 return QStringLiteral(
"pentagon" );
369 return QStringLiteral(
"hexagon" );
371 return QStringLiteral(
"triangle" );
373 return QStringLiteral(
"equilateral_triangle" );
375 return QStringLiteral(
"left_half_triangle" );
377 return QStringLiteral(
"right_half_triangle" );
379 return QStringLiteral(
"star" );
381 return QStringLiteral(
"arrow" );
383 return QStringLiteral(
"filled_arrowhead" );
385 return QStringLiteral(
"cross_fill" );
387 return QStringLiteral(
"circle" );
389 return QStringLiteral(
"cross" );
391 return QStringLiteral(
"cross2" );
393 return QStringLiteral(
"line" );
395 return QStringLiteral(
"arrowhead" );
397 return QStringLiteral(
"semi_circle" );
399 return QStringLiteral(
"third_circle" );
401 return QStringLiteral(
"quarter_circle" );
418 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
422 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 0 ) ) );
426 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 1 ) ) );
430 polygon << QPointF( -1, -1 ) << QPointF( 1, 1 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
434 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
435 << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
445 polygon << QPointF( -0.9511, -0.3090 )
446 << QPointF( -0.5878, 0.8090 )
447 << QPointF( 0.5878, 0.8090 )
448 << QPointF( 0.9511, -0.3090 )
450 << QPointF( -0.9511, -0.3090 );
461 polygon << QPointF( -0.8660, -0.5 )
462 << QPointF( -0.8660, 0.5 )
464 << QPointF( 0.8660, 0.5 )
465 << QPointF( 0.8660, -0.5 )
467 << QPointF( -0.8660, -0.5 );
471 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
479 polygon << QPointF( -0.8660, 0.5 )
480 << QPointF( 0.8660, 0.5 )
482 << QPointF( -0.8660, 0.5 );
486 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
490 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
495 double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
497 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
498 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), - std::cos(
DEG2RAD( 288 ) ) )
499 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), - inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
500 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), - std::cos(
DEG2RAD( 216.0 ) ) )
501 << QPointF( 0, inner_r )
502 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), - std::cos(
DEG2RAD( 144.0 ) ) )
503 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), - inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
504 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), - std::cos(
DEG2RAD( 72.0 ) ) )
505 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), - inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
507 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
512 polygon << QPointF( 0, -1 )
513 << QPointF( 0.5, -0.5 )
514 << QPointF( 0.25, -0.5 )
515 << QPointF( 0.25, 1 )
516 << QPointF( -0.25, 1 )
517 << QPointF( -0.25, -0.5 )
518 << QPointF( -0.5, -0.5 )
523 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
527 polygon << QPointF( -1, -0.2 )
528 << QPointF( -1, -0.2 )
529 << QPointF( -1, 0.2 )
530 << QPointF( -0.2, 0.2 )
531 << QPointF( -0.2, 1 )
533 << QPointF( 0.2, 0.2 )
535 << QPointF( 1, -0.2 )
536 << QPointF( 0.2, -0.2 )
537 << QPointF( 0.2, -1 )
538 << QPointF( -0.2, -1 )
539 << QPointF( -0.2, -0.2 )
540 << QPointF( -1, -0.2 );
559 mPath = QPainterPath();
565 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
569 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
570 mPath.lineTo( 0, 0 );
574 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
575 mPath.lineTo( 0, 0 );
579 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
580 mPath.lineTo( 0, 0 );
584 mPath.moveTo( -1, 0 );
585 mPath.lineTo( 1, 0 );
586 mPath.moveTo( 0, -1 );
587 mPath.lineTo( 0, 1 );
591 mPath.moveTo( -1, -1 );
592 mPath.lineTo( 1, 1 );
593 mPath.moveTo( 1, -1 );
594 mPath.lineTo( -1, 1 );
598 mPath.moveTo( 0, -1 );
599 mPath.lineTo( 0, 1 );
603 mPath.moveTo( -1, -1 );
604 mPath.lineTo( 0, 0 );
605 mPath.lineTo( -1, 1 );
630 double scaledSize =
mSize;
634 if ( hasDataDefinedSize )
641 if ( hasDataDefinedSize && ok )
646 scaledSize = std::sqrt( scaledSize );
661 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
662 offset = QPointF( offsetX, offsetY );
664 hasDataDefinedRotation =
false;
677 hasDataDefinedRotation =
true;
682 if ( hasDataDefinedRotation )
711 , mStrokeColor( strokeColor )
712 , mPenJoinStyle( penJoinStyle )
727 if ( props.contains( QStringLiteral(
"name" ) ) )
731 if ( props.contains( QStringLiteral(
"color" ) ) )
733 if ( props.contains( QStringLiteral(
"color_border" ) ) )
738 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
742 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
746 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
750 if ( props.contains( QStringLiteral(
"size" ) ) )
751 size = props[QStringLiteral(
"size" )].toDouble();
752 if ( props.contains( QStringLiteral(
"angle" ) ) )
753 angle = props[QStringLiteral(
"angle" )].toDouble();
754 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
758 if ( props.contains( QStringLiteral(
"offset" ) ) )
760 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
762 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
764 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
766 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
769 if ( props.contains( QStringLiteral(
"outline_style" ) ) )
773 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
777 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
779 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
781 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
783 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
785 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
789 if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
793 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
798 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
802 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
815 return QStringLiteral(
"SimpleMarker" );
822 QColor brushColor =
mColor;
828 mBrush = QBrush( brushColor );
829 mPen = QPen( penColor );
838 selBrushColor.setAlphaF( context.
opacity() );
839 selPenColor.setAlphaF( context.
opacity() );
861 mSelPen.setColor( selBrushColor );
893 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
896 double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
897 int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
898 double center = imageSize / 2.0;
904 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
911 p.setRenderHint( QPainter::Antialiasing );
912 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
914 p.translate( QPointF( center, center ) );
922 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
926 p.setRenderHint( QPainter::Antialiasing );
927 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
929 p.translate( QPointF( center, center ) );
940 p.setRenderHint( QPainter::Antialiasing );
941 p.fillRect( 0, 0, imageSize, imageSize, selColor );
942 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
944 p.translate( QPointF( center, center ) );
1018 p->setBrush( Qt::NoBrush );
1022 if ( !polygon.isEmpty() )
1023 p->drawPolygon( polygon );
1025 p->drawPath( path );
1042 double s = img.width();
1044 bool hasDataDefinedSize =
false;
1045 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1047 bool hasDataDefinedRotation =
false;
1052 p->drawImage( QRectF( point.x() - s / 2.0 +
offset.x(),
1053 point.y() - s / 2.0 +
offset.y(),
1068 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1071 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1077 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
1108 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1109 element.appendChild( graphicElem );
1118 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
1121 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
1136 Q_UNUSED( mmScaleFactor )
1137 Q_UNUSED( mapUnitScaleFactor )
1139 QString ogrType =
"3";
1140 if ( mName ==
"square" )
1144 else if ( mName ==
"triangle" )
1148 else if ( mName ==
"star" )
1152 else if ( mName ==
"circle" )
1156 else if ( mName ==
"cross" )
1160 else if ( mName ==
"x" || mName ==
"cross2" )
1164 else if ( mName ==
"line" )
1170 ogrString.append(
"SYMBOL(" );
1171 ogrString.append(
"id:" );
1172 ogrString.append(
'\"' );
1173 ogrString.append(
"ogr-sym-" );
1174 ogrString.append( ogrType );
1175 ogrString.append(
'\"' );
1176 ogrString.append(
",c:" );
1177 ogrString.append(
mColor.name() );
1178 ogrString.append(
",o:" );
1180 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1181 ogrString.append(
')' );
1186 ogrString.append(
"PEN(" );
1187 ogrString.append(
"c:" );
1188 ogrString.append(
mColor.name() );
1189 ogrString.append(
",w:" );
1190 ogrString.append( QString::number(
mSize ) );
1191 ogrString.append(
"mm" );
1192 ogrString.append(
")" );
1200 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1201 if ( graphicElem.isNull() )
1204 QString name = QStringLiteral(
"square" );
1217 double d = angleFunc.toDouble( &ok );
1227 QString uom = element.attribute( QStringLiteral(
"uom" ) );
1253 p->drawPath(
mPath );
1266 if ( hasDataDefinedSize )
1287 size *= mmMapUnitScaleFactor;
1294 double halfSize =
size / 2.0;
1311 QColor pc =
mPen.color();
1312 QColor bc =
mBrush.color();
1332 QPointF off( offsetX, offsetY );
1361 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1369 t.scale( halfSize, -halfSize );
1371 polygon = t.map( polygon );
1374 p.reserve( polygon.size() );
1375 for (
int i = 0; i < polygon.size(); i++ )
1380 if (
mBrush.style() != Qt::NoBrush )
1382 if (
mPen.style() != Qt::NoPen )
1387 shift += QPointF( off.x(), -off.y() );
1388 if (
mBrush.style() != Qt::NoBrush )
1390 if (
mPen.style() != Qt::NoPen )
1395 QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1396 QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1398 if (
mPen.style() != Qt::NoPen )
1403 if (
mPen.style() != Qt::NoPen )
1405 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1406 QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1407 QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1408 QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1416 if (
mPen.style() != Qt::NoPen )
1418 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1419 QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1420 QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1421 QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1429 if (
mPen.style() != Qt::NoPen )
1431 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1432 QPointF pt2 = t.map( QPointF( 0, 0 ) );
1433 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1512 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1513 penWidth / 2.0, penWidth / 2.0 );
1515 return symbolBounds;
1562 if ( props.contains( QStringLiteral(
"name" ) ) )
1563 name = props[QStringLiteral(
"name" )];
1564 if ( props.contains( QStringLiteral(
"size" ) ) )
1565 size = props[QStringLiteral(
"size" )].toDouble();
1566 if ( props.contains( QStringLiteral(
"angle" ) ) )
1567 angle = props[QStringLiteral(
"angle" )].toDouble();
1568 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1572 if ( props.contains( QStringLiteral(
"offset" ) ) )
1574 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1576 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1578 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1580 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1582 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1586 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1600 return QStringLiteral(
"FilledMarker" );
1625 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1628 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1684 attr.unite( mFill->usedAttributes( context ) );
1692 if ( mFill && mFill->hasDataDefinedProperties() )
1701 mFill->setColor(
c );
1706 return mFill ? mFill->color() :
mColor;
1722 p->setBrush( Qt::red );
1726 p->setBrush( Qt::NoBrush );
1728 p->setPen( Qt::black );
1730 if ( !polygon.isEmpty() )
1736 QPolygonF poly = path.toFillPolygon();
1755 mColor = QColor( 35, 35, 35 );
1768 if ( props.contains( QStringLiteral(
"name" ) ) )
1769 name = props[QStringLiteral(
"name" )];
1770 if ( props.contains( QStringLiteral(
"size" ) ) )
1771 size = props[QStringLiteral(
"size" )].toDouble();
1772 if ( props.contains( QStringLiteral(
"angle" ) ) )
1773 angle = props[QStringLiteral(
"angle" )].toDouble();
1774 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1779 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1781 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1783 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
1785 if ( props.contains( QStringLiteral(
"offset" ) ) )
1787 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1789 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1791 if ( props.contains( QStringLiteral(
"fill" ) ) )
1796 else if ( props.contains( QStringLiteral(
"color" ) ) )
1800 if ( props.contains( QStringLiteral(
"outline" ) ) )
1805 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
1809 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
1814 if ( props.contains( QStringLiteral(
"outline-width" ) ) )
1817 m->
setStrokeWidth( props[QStringLiteral(
"outline-width" )].toDouble() );
1819 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
1821 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
1823 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
1825 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
1828 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
1832 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
1836 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1839 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1843 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1857 QgsStringMap::iterator it =
properties.find( QStringLiteral(
"name" ) );
1872 QColor defaultFillColor, defaultStrokeColor;
1874 bool hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1875 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1877 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1878 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
1879 hasStrokeWidthParam, hasDefaultStrokeWidth,
strokeWidth,
1880 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1882 double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
1883 double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
1885 if ( hasDefaultFillColor )
1887 defaultFillColor.setAlphaF( newFillOpacity );
1890 if ( hasDefaultFillOpacity )
1893 c.setAlphaF( fillOpacity );
1896 if ( hasDefaultStrokeColor )
1898 defaultStrokeColor.setAlphaF( newStrokeOpacity );
1901 if ( hasDefaultStrokeWidth )
1905 if ( hasDefaultStrokeOpacity )
1908 c.setAlphaF( strokeOpacity );
1922 double widthScaleFactor = 3.465;
1925 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
1933 if ( aPreservedAspectRatio && !par )
1937 else if ( !aPreservedAspectRatio && par )
1947 return QStringLiteral(
"SvgMarker" );
1967 bool hasDataDefinedSize =
false;
1968 double scaledWidth = calculateSize( context, hasDataDefinedSize );
1972 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
1979 bool hasDataDefinedAspectRatio =
false;
2021 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2025 QPointF outputOffset;
2027 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2029 p->translate( point + outputOffset );
2035 bool fitsInCache =
true;
2036 bool usePict =
true;
2043 if ( fitsInCache && img.width() > 1 )
2053 QImage transparentImage = img.copy();
2055 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2059 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2064 if ( usePict || !fitsInCache )
2066 p->setOpacity( context.
opacity() );
2070 if ( pct.width() > 1 )
2073 _fixQPictureDPI( p );
2074 p->drawPicture( 0, 0, pct );
2082 double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2084 double scaledSize =
mSize;
2088 if ( hasDataDefinedSize )
2096 if ( hasDataDefinedSize )
2103 if ( hasDataDefinedSize && ok )
2108 scaledSize = std::sqrt( scaledSize );
2121 if ( !hasDataDefinedAspectRatio )
2131 double defaultHeight =
mSize * scaledAspectRatio;
2132 scaledAspectRatio = defaultHeight / scaledSize;
2135 double scaledHeight = scaledSize * scaledAspectRatio;
2142 if ( hasDataDefinedAspectRatio && ok )
2147 scaledHeight = sqrt( scaledHeight );
2154 scaledAspectRatio = scaledHeight / scaledSize;
2156 return scaledAspectRatio;
2159 void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const
2164 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2165 offset = QPointF( offsetX, offsetY );
2175 if ( hasDataDefinedRotation )
2201 map[QStringLiteral(
"name" )] =
mPath;
2202 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2205 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2206 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2213 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
2276 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2277 element.appendChild( graphicElem );
2287 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2290 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2308 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
2309 if ( graphicElem.isNull() )
2312 QString
path, mimeType;
2319 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2322 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2330 double d = angleFunc.toDouble( &ok );
2356 if ( hasDataDefinedSize )
2362 if ( hasDataDefinedSize && ok )
2376 size *= mmMapUnitScaleFactor;
2390 double offsetX =
offset.x();
2391 double offsetY =
offset.y();
2393 QPointF outputOffset( offsetX, offsetY );
2441 QSvgRenderer r( svgContent );
2448 QSizeF outSize( r.defaultSize() );
2449 outSize.scale(
size,
size, Qt::KeepAspectRatio );
2455 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2457 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2459 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2460 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2469 bool hasDataDefinedSize =
false;
2470 double scaledWidth = calculateSize( context, hasDataDefinedSize );
2472 bool hasDataDefinedAspectRatio =
false;
2480 if (
static_cast< int >( scaledWidth ) < 1 || 10000.0 < scaledWidth )
2485 QPointF outputOffset;
2487 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, outputOffset,
angle );
2524 scaledHeight = svgViewbox.isValid() ? scaledWidth * svgViewbox.height() / svgViewbox.width() : scaledWidth;
2530 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2533 transform.rotate(
angle );
2538 QRectF symbolBounds = transform.mapRect( QRectF( -scaledWidth / 2.0,
2539 -scaledHeight / 2.0,
2547 return symbolBounds;
2570 if ( props.contains( QStringLiteral(
"imageFile" ) ) )
2571 path = props[QStringLiteral(
"imageFile" )];
2572 if ( props.contains( QStringLiteral(
"size" ) ) )
2573 size = props[QStringLiteral(
"size" )].toDouble();
2574 if ( props.contains( QStringLiteral(
"angle" ) ) )
2575 angle = props[QStringLiteral(
"angle" )].toDouble();
2576 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
2581 if ( props.contains( QStringLiteral(
"alpha" ) ) )
2583 m->
setOpacity( props[QStringLiteral(
"alpha" )].toDouble() );
2586 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2588 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2590 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
2593 if ( props.contains( QStringLiteral(
"offset" ) ) )
2595 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2597 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2600 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2604 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
2617 QgsStringMap::iterator it =
properties.find( QStringLiteral(
"name" ) );
2636 if ( aPreservedAspectRatio && !par )
2640 else if ( !aPreservedAspectRatio && par )
2659 return QStringLiteral(
"RasterMarker" );
2675 if (
path.isEmpty() )
2679 double height = 0.0;
2681 bool hasDataDefinedSize =
false;
2682 double scaledSize = calculateSize( context, hasDataDefinedSize );
2684 bool hasDataDefinedAspectRatio =
false;
2687 QPointF outputOffset;
2694 if (
size.isEmpty() )
2697 width = ( scaledSize *
static_cast< double >(
size.width() ) ) / 100.0;
2698 height = ( scaledSize *
static_cast< double >(
size.height() ) ) / 100.0;
2701 if (
static_cast< int >( width ) < 1 || 10000.0 < width ||
static_cast< int >( height ) < 1 || 10000.0 < height )
2704 calculateOffsetAndRotation( context, width, height, outputOffset,
angle );
2714 if ( !
size.isNull() &&
size.isValid() &&
size.width() > 0 )
2716 height = width * (
static_cast< double >(
size.height() ) /
static_cast< double >(
size.width() ) );
2721 if (
static_cast< int >( width ) < 1 || 10000.0 < width )
2724 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
2728 p->translate( point + outputOffset );
2744 if ( !img.isNull() )
2749 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2753 double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const
2755 double scaledSize =
mSize;
2759 if ( hasDataDefinedSize )
2767 if ( hasDataDefinedSize )
2774 if ( hasDataDefinedSize && ok )
2779 scaledSize = std::sqrt( scaledSize );
2792 if ( !hasDataDefinedAspectRatio )
2802 double defaultHeight =
mSize * scaledAspectRatio;
2803 scaledAspectRatio = defaultHeight / scaledSize;
2806 double scaledHeight = scaledSize * scaledAspectRatio;
2813 if ( hasDataDefinedAspectRatio && ok )
2818 scaledHeight = sqrt( scaledHeight );
2825 scaledAspectRatio = scaledHeight / scaledSize;
2827 return scaledAspectRatio;
2830 void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const
2835 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2836 offset = QPointF( offsetX, offsetY );
2846 if ( hasDataDefinedRotation )
2867 map[QStringLiteral(
"imageFile" )] =
mPath;
2868 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2871 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2872 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2873 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
2912 bool hasDataDefinedSize =
false;
2913 double scaledSize = calculateSize( context, hasDataDefinedSize );
2915 bool hasDataDefinedAspectRatio =
false;
2920 if (
static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2925 QPointF outputOffset;
2927 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset,
angle );
2932 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2935 transform.rotate(
angle );
2937 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
2942 return symbolBounds;
2954 mOrigSize = pointSize;
2973 if ( props.contains( QStringLiteral(
"font" ) ) )
2974 fontFamily = props[QStringLiteral(
"font" )];
2975 if ( props.contains( QStringLiteral(
"chr" ) ) && props[QStringLiteral(
"chr" )].length() > 0 )
2976 string = props[QStringLiteral(
"chr" )];
2977 if ( props.contains( QStringLiteral(
"size" ) ) )
2978 pointSize = props[QStringLiteral(
"size" )].toDouble();
2979 if ( props.contains( QStringLiteral(
"color" ) ) )
2981 if ( props.contains( QStringLiteral(
"angle" ) ) )
2982 angle = props[QStringLiteral(
"angle" )].toDouble();
2986 if ( props.contains( QStringLiteral(
"font_style" ) ) )
2987 m->
setFontStyle( props[QStringLiteral(
"font_style" )] );
2988 if ( props.contains( QStringLiteral(
"outline_color" ) ) )
2990 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
2991 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
2992 if ( props.contains( QStringLiteral(
"offset" ) ) )
2994 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2996 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2998 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
3000 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
3002 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
3004 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3006 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
3008 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
3010 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3020 return QStringLiteral(
"FontMarker" );
3025 QColor brushColor =
mColor;
3026 QColor penColor = mStrokeColor;
3028 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3029 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3031 mBrush = QBrush( brushColor );
3032 mPen = QPen( penColor );
3033 mPen.setJoinStyle( mPenJoinStyle );
3036 mFont = QFont( mFontFamily );
3037 if ( !mFontStyle.isEmpty() )
3046 mFont.setPixelSize( std::max( 2,
static_cast< int >( std::round( sizePixels ) ) ) );
3047 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3048 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
3049 mChrWidth = mFontMetrics->width( mString );
3051 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3053 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3060 if ( mUseCachedPath )
3062 QPointF chrOffset = mChrOffset;
3064 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3065 mCachedPath = QPainterPath();
3066 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3075 QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3077 charOffset = mChrOffset;
3078 QString stringToRender = mString;
3083 if ( stringToRender != mString )
3085 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
3086 charWidth = mFontMetrics->width( stringToRender );
3088 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3090 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3093 return stringToRender;
3098 bool &hasDataDefinedRotation,
3100 double &
angle )
const
3105 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3106 offset = QPointF( offsetX, offsetY );
3122 if ( hasDataDefinedRotation )
3146 double scaledSize =
mSize;
3150 if ( hasDataDefinedSize )
3156 if ( hasDataDefinedSize && ok )
3161 scaledSize = std::sqrt( scaledSize );
3173 if ( !p || !mNonZeroFontSize )
3176 QTransform transform;
3179 QColor brushColor =
mColor;
3188 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3190 mBrush.setColor( brushColor );
3192 QColor penColor = mStrokeColor;
3198 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3222 p->setBrush( mBrush );
3225 mPen.setColor( penColor );
3226 mPen.setWidthF( penWidth );
3231 p->setPen( Qt::NoPen );
3238 mFont.setFamily( ok ?
fontFamily : mFontFamily );
3248 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3251 QPointF chrOffset = mChrOffset;
3253 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3255 double sizeToRender = calculateSize( context );
3257 bool hasDataDefinedRotation =
false;
3260 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation,
offset,
angle );
3262 p->translate( point.x() +
offset.x(), point.y() +
offset.y() );
3265 transform.rotate(
angle );
3269 double s = sizeToRender / mOrigSize;
3270 transform.scale( s, s );
3273 if ( mUseCachedPath )
3275 p->drawPath( transform.map( mCachedPath ) );
3280 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3281 p->drawPath( transform.map( path ) );
3288 props[QStringLiteral(
"font" )] = mFontFamily;
3289 props[QStringLiteral(
"font_style" )] = mFontStyle;
3290 props[QStringLiteral(
"chr" )] = mString;
3291 props[QStringLiteral(
"size" )] = QString::number(
mSize );
3296 props[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
3300 props[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3333 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3334 element.appendChild( graphicElem );
3336 QString fontPath = QStringLiteral(
"ttf://%1" ).arg( mFontFamily );
3337 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
3344 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3347 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
3362 QPointF chrOffset = mChrOffset;
3363 double chrWidth = mChrWidth;
3365 ( void )characterToRender( context, chrOffset, chrWidth );
3367 if ( !mFontMetrics )
3368 mFontMetrics.reset(
new QFontMetrics( mFont ) );
3370 double scaledSize = calculateSize( context );
3373 chrWidth *= scaledSize / mOrigSize;
3376 bool hasDataDefinedRotation =
false;
3379 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation,
offset,
angle );
3385 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
3388 transform.rotate(
angle );
3390 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
3394 return symbolBounds;
3401 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
3402 if ( graphicElem.isNull() )
3405 QString name, format;
3413 if ( !name.startsWith( QLatin1String(
"ttf://" ) ) || format != QLatin1String(
"ttf" ) )
3423 double d = angleFunc.toDouble( &ok );
3431 QString uom = element.attribute( QStringLiteral(
"uom" ) );
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
void setColor(const QColor &c) override
The fill color.
Q_GUI_EXPORT int qt_defaultDpiX()
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
double mFixedAspectRatio
The marker fixed aspect ratio.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
QgsMapUnitScale mapUnitScale() const override
QString layerType() const override
Returns a string that represents this layer type.
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.
static QString encodeColor(const QColor &color)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
VerticalAnchorPoint
Symbol vertical anchor points.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
double size() const
Returns the symbol size.
#define DEFAULT_SIMPLEMARKER_ANGLE
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
double opacity() const
Returns the marker opacity.
RenderUnit
Rendering size units.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
double mDefaultAspectRatio
The marker default aspect ratio.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
void setStrokeWidth(double width)
Set's the marker's stroke width.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsExpressionContext & expressionContext()
Gets the expression context.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
double mapUnitsPerPixel() const
Returns current map units per pixel.
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
#define DEFAULT_SIMPLEMARKER_NAME
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
QgsMapUnitScale mapUnitScale() const override
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
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.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Point geometry type, with support for z-dimension and m-values.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
#define QgsDebugMsgLevel(str, level)
const QgsFeature * feature() const
Returns the current feature being rendered.
void setDrawingSize(QSizeF size)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
@ PropertyFontFamily
Font family.
virtual void setColor(const QColor &color)
The fill color.
QImage mSelCache
Cached image of selected marker, if using cached version.
virtual QColor color() const
The fill color.
@ PropertyFillColor
Fill color.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
@ SemiCircle
Semi circle (top half)
#define DEFAULT_FONTMARKER_ANGLE
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setAngle(double angle)
Sets the rotation angle for the marker.
qreal opacity() const
Returns the opacity for the symbol.
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
QgsSymbol::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
void setPath(const QString &path)
Set the marker SVG path.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsFilledMarkerSymbolLayer.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
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)
Gets SVG as QImage.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
@ QuarterSquare
Quarter square (top left quarter)
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Contains information about the context of a rendering operation.
@ ScaleDiameter
Calculate scale by the diameter.
#define DEFAULT_RASTERMARKER_SIZE
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
void setColor(const QColor &color) override
The fill color.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
QgsSymbol::ScaleMethod mScaleMethod
Marker size scaling method.
@ RenderMillimeters
Millimeters.
#define DEFAULT_FONTMARKER_FONT
Abstract base class for marker symbol layers.
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void setOpacity(double opacity)
Set the marker opacity.
void setStrokeColor(const QColor &color) override
Set stroke color.
static QString encodePenStyle(Qt::PenStyle style)
QgsMapUnitScale mapUnitScale() const override
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
Abstract base class for all rendered symbols.
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
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
bool prepareMarkerShape(Shape shape)
Prepares the layer for drawing the specified shape (QPolygonF version)
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
@ PropertyStrokeColor
Stroke color.
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 setMapUnitScale(const QgsMapUnitScale &scale) override
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSimpleMarkerSymbolLayer.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QColor color() const override
The fill color.
static QColor decodeColor(const QString &str)
QgsRasterMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QgsSymbolLayer * createFromSld(QDomElement &element)
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
bool prepareMarkerPath(Shape symbol)
Prepares the layer for drawing the specified shape (QPainterPath version)
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
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)
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
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.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
QBrush mSelBrush
QBrush to use as fill of selected symbols.
static void resolvePaths(QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
@ PropertyFontStyle
Font style.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
Q_GUI_EXPORT int qt_defaultDpiY()
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
QColor color() const override
The fill color.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
HorizontalAnchorPoint
Symbol horizontal anchor points.
double strokeWidth() const
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a 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 setStrokeColor(const QColor &c) override
Set stroke color.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
Abstract base class for simple marker symbol layers.
QColor strokeColor() const override
Gets stroke color.
QBrush mBrush
QBrush corresponding to marker's fill style.
#define DEFAULT_SVGMARKER_ANGLE
Shape mShape
Symbol shape.
@ PropertyOffset
Symbol offset.
@ PropertyCharacter
Character, eg for font marker symbol layers.
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
Shape
Marker symbol shapes.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
A paint device for drawing into dxf files.
QColor fillColor() const override
Gets fill color.
void setMapUnitScale(const QgsMapUnitScale &scale) override
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static const int MAXIMUM_CACHE_WIDTH
Maximum width/height of cache image.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
@ RightHalfTriangle
Right half of triangle.
QgsMapUnitScale mStrokeWidthMapUnitScale
QgsFields fields() const
Fields of the layer.
QString layerType() const override
Returns a string that represents this layer type.
void setLayer(const QString &layer)
@ DiagonalHalfSquare
Diagonal half square (bottom left half)
QColor fillColor() const override
Gets fill color.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false, bool *isMissing=nullptr)
Returns the specified path rendered as an image.
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false)
Calculates the viewbox size of a (possibly cached) SVG file.
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
void setStrokeWidth(double w)
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsFontMarkerSymbolLayer from an SLD XML element.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QString layerType() const override
Returns a string that represents this layer type.
double mapRotation() const
Returns current map rotation in degrees (clockwise)
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QString path() const
Returns the marker SVG path.
@ ArrowHeadFilled
Right facing filled arrow head.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
#define DEFAULT_FONTMARKER_SIZE
@ LeftHalfTriangle
Left half of triangle.
static double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
#define DEFAULT_FONTMARKER_CHR
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
@ PropertySize
Symbol size.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static void resolvePaths(QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
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.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
void setPath(const QString &path)
Set the marker raster image path.
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
static bool shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Returns true if a symbol shape has a fill.
#define DEFAULT_FONTMARKER_BORDERCOLOR
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
bool prepareCache(QgsSymbolRenderContext &context)
Prepares cache image.
double strokeWidth() const
Returns 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 writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
Raster marker symbol layer class.
QColor mStrokeColor
Stroke color.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
@ PropertyName
Name, eg shape name for simple markers.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
@ ThirdCircle
One third circle (top left third)
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Struct for storing maximum and minimum scales for measurements in map units.
@ CrossFill
Solid filled cross.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Scoped object for saving and restoring a QPainter object's state.
static void adjustHueSaturation(QImage &image, double saturation, const QColor &colorizeColor=QColor(), double colorizeStrength=1.0)
Alter the hue or saturation of a QImage.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
QgsPropertyCollection mDataDefinedProperties
@ PropertyStrokeWidth
Stroke width.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QVector< QgsPointSequence > QgsRingSequence
QString path() const
Returns the marker raster image path.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
static QgsSimpleMarkerSymbolLayerBase::Shape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
Qt::PenStyle mStrokeStyle
Stroke style.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
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.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
QgsRasterMarkerSymbolLayer(const QString &path=QString(), double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs raster marker symbol layer with picture from given absolute path to a raster image file.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor strokeColor() const override
Returns the marker's stroke color.
QgsSymbol::RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
QPen mSelPen
QPen to use as stroke of selected symbols.
QgsMapUnitScale mapUnitScale() const override
QColor selectionColor() const
Returns the color to use when rendering selected features.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSimpleMarkerSymbolLayer from an SLD XML element.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
QMap< QString, QString > QgsStringMap
void setMapUnitScale(const QgsMapUnitScale &scale) override
QPointF mOffset
Marker offset.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsFontMarkerSymbolLayer from a property map (see properties())
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void setFillColor(const QColor &color) override
Set fill color.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
@ QuarterCircle
Quarter circle (top left quarter)
QVector< QgsPoint > QgsPointSequence
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.
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
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath.
Perform transforms between map coordinates and device coordinates.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
@ Cross2
Rotated cross (lines only), "x" shape.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
#define DEFAULT_SVGMARKER_SIZE
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Stroke width units.
QString layerType() const override
Returns a string that represents this layer type.
@ Cross
Cross (lines only)
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
double mLineAngle
Line rotation angle (see setLineAngle() for details)
#define DEFAULT_SCALE_METHOD
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static QString encodeScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
@ PropertyAngle
Symbol angle.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
@ RenderMetersInMapUnits
Meters value as Map units.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
@ RenderUnknownUnit
Mixed or unknown units.
SymbolType type() const
Returns the symbol's type.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
double mOpacity
The marker default opacity.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
bool mUsingCache
true if using cached images of markers for drawing.
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes()
Returns a list of all available shape types.
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
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)
Gets SVG as QPicture&.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setOutputSize(const QRectF &r)
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QgsSvgMarkerSymbolLayer(const QString &path, double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs SVG marker symbol layer with picture from given absolute path to a SVG file.
QImage mCache
Cached image of marker, if using cached version.
void calculateOffsetAndRotation(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle) const
Calculates the marker offset and rotation.
#define DEFAULT_FONTMARKER_JOINSTYLE
double mAngle
Marker rotation angle, in degrees clockwise from north.
@ RenderSymbolPreview
The render is for a symbol preview only and map based properties may not be available,...
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
@ PropertyOpacity
Opacity.
QgsFilledMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsFilledMarkerSymbolLayer.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsSimpleMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::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 symbologyScale() const
Returns the reference scale for output.
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
void setShift(QPointF shift)
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
@ PropertyHeight
Symbol height.
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...
@ HalfSquare
Half square (left half)
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
@ ScaleArea
Calculate scale by the area.
#define DEFAULT_FONTMARKER_COLOR
static Qt::PenStyle decodePenStyle(const QString &str)
#define DEFAULT_SIMPLEMARKER_COLOR
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, bool *isMissingImage=nullptr)
Gets SVG content.
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
double mDefaultAspectRatio
The marker default aspect ratio.
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
QgsWkbTypes::GeometryType type
static QString encodeShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Encodes a shape to its string representation.
@ EquilateralTriangle
Equilateral triangle.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
bool shapeToPolygon(Shape shape, QPolygonF &polygon) const
Creates a polygon representing the specified shape.
QgsSimpleMarkerSymbolLayerBase(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsSimpleMarkerSymbolLayerBase.
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)
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Resolves relative paths into absolute paths and vice versa.
@ RenderMapUnits
Map units.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
double mFixedAspectRatio
The marker fixed aspect ratio.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a raster marker symbol layer from a string map of properties.
double calculateSize(QgsSymbolRenderContext &context, bool &hasDataDefinedSize) const
Calculates the desired size of the marker, considering data defined size overrides.
@ ArrowHead
Right facing arrow head (unfilled, lines only)
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QPen mPen
QPen corresponding to marker's stroke style.
void setFillColor(const QColor &color) override
Set fill color.
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 strokeWidth() const
Returns the marker's stroke width.
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
@ PropertyJoinStyle
Line join style.
void drawMarker(QPainter *p, QgsSymbolRenderContext &context)
Draws the marker shape in the specified painter.
Flags flags() const
Returns combination of flags used for rendering.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
@ PropertyWidth
Symbol width.
#define DEFAULT_RASTERMARKER_ANGLE
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
#define DEFAULT_SIMPLEMARKER_SIZE
double mStrokeWidth
Stroke width.