30 #include <QSvgRenderer> 33 #include <QDomDocument> 34 #include <QDomElement> 41 static void _fixQPictureDPI( QPainter *p )
47 p->scale( static_cast< double >(
qt_defaultDpiX() ) / p->device()->logicalDpiX(),
48 static_cast< double >(
qt_defaultDpiY() ) / p->device()->logicalDpiY() );
61 QList< Shape > shapes;
145 QTransform transform;
148 if ( !hasDataDefinedSize )
151 double half = scaledSize / 2.0;
152 transform.scale( half, half );
158 transform.rotate(
mAngle );
185 bool hasDataDefinedSize =
false;
186 double scaledSize =
calculateSize( context, hasDataDefinedSize );
188 bool hasDataDefinedRotation =
false;
194 bool createdNewPath =
false;
201 if ( exprVal.isValid() )
212 createdNewPath =
true;
221 QTransform transform;
224 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
227 if ( hasDataDefinedSize || createdNewPath )
230 double half = s / 2.0;
231 transform.scale( half, half );
234 if ( !
qgsDoubleNear( angle, 0.0 ) && ( hasDataDefinedRotation || createdNewPath ) )
235 transform.rotate( angle );
243 polygon = transform.map(
mPolygon );
247 path = transform.map(
mPath );
249 draw( context, symbol, polygon, path );
254 bool hasDataDefinedSize =
false;
255 double scaledSize =
calculateSize( context, hasDataDefinedSize );
257 bool hasDataDefinedRotation =
false;
264 QTransform transform;
267 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
270 transform.rotate( angle );
272 return transform.mapRect( QRectF( -scaledSize / 2.0,
282 QString cleaned = name.toLower().trimmed();
284 if ( cleaned == QLatin1String(
"square" ) || cleaned == QLatin1String(
"rectangle" ) )
286 else if ( cleaned == QLatin1String(
"diamond" ) )
288 else if ( cleaned == QLatin1String(
"pentagon" ) )
290 else if ( cleaned == QLatin1String(
"hexagon" ) )
292 else if ( cleaned == QLatin1String(
"triangle" ) )
294 else if ( cleaned == QLatin1String(
"equilateral_triangle" ) )
296 else if ( cleaned == QLatin1String(
"star" ) || cleaned == QLatin1String(
"regular_star" ) )
298 else if ( cleaned == QLatin1String(
"arrow" ) )
300 else if ( cleaned == QLatin1String(
"circle" ) )
302 else if ( cleaned == QLatin1String(
"cross" ) )
304 else if ( cleaned == QLatin1String(
"cross_fill" ) )
306 else if ( cleaned == QLatin1String(
"cross2" ) || cleaned == QLatin1String(
"x" ) )
308 else if ( cleaned == QLatin1String(
"line" ) )
310 else if ( cleaned == QLatin1String(
"arrowhead" ) )
312 else if ( cleaned == QLatin1String(
"filled_arrowhead" ) )
314 else if ( cleaned == QLatin1String(
"semi_circle" ) )
316 else if ( cleaned == QLatin1String(
"third_circle" ) )
318 else if ( cleaned == QLatin1String(
"quarter_circle" ) )
320 else if ( cleaned == QLatin1String(
"quarter_square" ) )
322 else if ( cleaned == QLatin1String(
"half_square" ) )
324 else if ( cleaned == QLatin1String(
"diagonal_half_square" ) )
326 else if ( cleaned == QLatin1String(
"right_half_triangle" ) )
328 else if ( cleaned == QLatin1String(
"left_half_triangle" ) )
341 return QStringLiteral(
"square" );
343 return QStringLiteral(
"quarter_square" );
345 return QStringLiteral(
"half_square" );
347 return QStringLiteral(
"diagonal_half_square" );
349 return QStringLiteral(
"diamond" );
351 return QStringLiteral(
"pentagon" );
353 return QStringLiteral(
"hexagon" );
355 return QStringLiteral(
"triangle" );
357 return QStringLiteral(
"equilateral_triangle" );
359 return QStringLiteral(
"left_half_triangle" );
361 return QStringLiteral(
"right_half_triangle" );
363 return QStringLiteral(
"star" );
365 return QStringLiteral(
"arrow" );
367 return QStringLiteral(
"filled_arrowhead" );
369 return QStringLiteral(
"cross_fill" );
371 return QStringLiteral(
"circle" );
373 return QStringLiteral(
"cross" );
375 return QStringLiteral(
"cross2" );
377 return QStringLiteral(
"line" );
379 return QStringLiteral(
"arrowhead" );
381 return QStringLiteral(
"semi_circle" );
383 return QStringLiteral(
"third_circle" );
385 return QStringLiteral(
"quarter_circle" );
402 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
406 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 0 ) ) );
410 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 0, 1 ) ) );
414 polygon << QPointF( -1, -1 ) << QPointF( 1, 1 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
418 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
419 << QPointF( 1, 0 ) << QPointF( 0, -1 ) << QPointF( -1, 0 );
429 polygon << QPointF( -0.9511, -0.3090 )
430 << QPointF( -0.5878, 0.8090 )
431 << QPointF( 0.5878, 0.8090 )
432 << QPointF( 0.9511, -0.3090 )
434 << QPointF( -0.9511, -0.3090 );
445 polygon << QPointF( -0.8660, -0.5 )
446 << QPointF( -0.8660, 0.5 )
448 << QPointF( 0.8660, 0.5 )
449 << QPointF( 0.8660, -0.5 )
451 << QPointF( -0.8660, -0.5 );
455 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
463 polygon << QPointF( -0.8660, 0.5 )
464 << QPointF( 0.8660, 0.5 )
466 << QPointF( -0.8660, 0.5 );
470 polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 ) << QPointF( 0, 1 );
474 polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 ) << QPointF( -1, 1 );
479 double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
481 polygon << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) )
482 << QPointF( std::sin(
DEG2RAD( 288.0 ) ), - std::cos(
DEG2RAD( 288 ) ) )
483 << QPointF( inner_r * std::sin(
DEG2RAD( 252.0 ) ), - inner_r * std::cos(
DEG2RAD( 252.0 ) ) )
484 << QPointF( std::sin(
DEG2RAD( 216.0 ) ), - std::cos(
DEG2RAD( 216.0 ) ) )
485 << QPointF( 0, inner_r )
486 << QPointF( std::sin(
DEG2RAD( 144.0 ) ), - std::cos(
DEG2RAD( 144.0 ) ) )
487 << QPointF( inner_r * std::sin(
DEG2RAD( 108.0 ) ), - inner_r * std::cos(
DEG2RAD( 108.0 ) ) )
488 << QPointF( std::sin(
DEG2RAD( 72.0 ) ), - std::cos(
DEG2RAD( 72.0 ) ) )
489 << QPointF( inner_r * std::sin(
DEG2RAD( 36.0 ) ), - inner_r * std::cos(
DEG2RAD( 36.0 ) ) )
491 << QPointF( inner_r * std::sin(
DEG2RAD( 324.0 ) ), - inner_r * std::cos(
DEG2RAD( 324.0 ) ) );
496 polygon << QPointF( 0, -1 )
497 << QPointF( 0.5, -0.5 )
498 << QPointF( 0.25, -0.5 )
499 << QPointF( 0.25, 1 )
500 << QPointF( -0.25, 1 )
501 << QPointF( -0.25, -0.5 )
502 << QPointF( -0.5, -0.5 )
507 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 ) << QPointF( 0, 0 );
511 polygon << QPointF( -1, -0.2 )
512 << QPointF( -1, -0.2 )
513 << QPointF( -1, 0.2 )
514 << QPointF( -0.2, 0.2 )
515 << QPointF( -0.2, 1 )
517 << QPointF( 0.2, 0.2 )
519 << QPointF( 1, -0.2 )
520 << QPointF( 0.2, -0.2 )
521 << QPointF( 0.2, -1 )
522 << QPointF( -0.2, -1 )
523 << QPointF( -0.2, -0.2 )
524 << QPointF( -1, -0.2 );
543 mPath = QPainterPath();
549 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
553 mPath.arcTo( -1, -1, 2, 2, 0, 180 );
554 mPath.lineTo( 0, 0 );
558 mPath.arcTo( -1, -1, 2, 2, 90, 120 );
559 mPath.lineTo( 0, 0 );
563 mPath.arcTo( -1, -1, 2, 2, 90, 90 );
564 mPath.lineTo( 0, 0 );
568 mPath.moveTo( -1, 0 );
569 mPath.lineTo( 1, 0 );
570 mPath.moveTo( 0, -1 );
571 mPath.lineTo( 0, 1 );
575 mPath.moveTo( -1, -1 );
576 mPath.lineTo( 1, 1 );
577 mPath.moveTo( 1, -1 );
578 mPath.lineTo( -1, 1 );
582 mPath.moveTo( 0, -1 );
583 mPath.lineTo( 0, 1 );
587 mPath.moveTo( -1, -1 );
588 mPath.lineTo( 0, 0 );
589 mPath.lineTo( -1, 1 );
614 double scaledSize =
mSize;
618 if ( hasDataDefinedSize )
625 if ( hasDataDefinedSize && ok )
630 scaledSize = std::sqrt( scaledSize );
645 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
646 offset = QPointF( offsetX, offsetY );
648 hasDataDefinedRotation =
false;
661 hasDataDefinedRotation =
true;
666 if ( hasDataDefinedRotation )
695 , mStrokeColor( strokeColor )
696 , mPenJoinStyle( penJoinStyle )
711 if ( props.contains( QStringLiteral(
"name" ) ) )
713 shape =
decodeShape( props[QStringLiteral(
"name" )] );
715 if ( props.contains( QStringLiteral(
"color" ) ) )
717 if ( props.contains( QStringLiteral(
"color_border" ) ) )
722 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
726 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
730 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
734 if ( props.contains( QStringLiteral(
"size" ) ) )
735 size = props[QStringLiteral(
"size" )].toDouble();
736 if ( props.contains( QStringLiteral(
"angle" ) ) )
737 angle = props[QStringLiteral(
"angle" )].toDouble();
738 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
742 if ( props.contains( QStringLiteral(
"offset" ) ) )
744 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
746 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
748 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
750 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
753 if ( props.contains( QStringLiteral(
"outline_style" ) ) )
757 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
761 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
763 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
765 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
767 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
769 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
773 if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
777 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
782 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
786 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
799 return QStringLiteral(
"SimpleMarker" );
806 QColor brushColor =
mColor;
812 mBrush = QBrush( brushColor );
813 mPen = QPen( penColor );
822 selBrushColor.setAlphaF( context.
opacity() );
823 selPenColor.setAlphaF( context.
opacity() );
845 mSelPen.setColor( selBrushColor );
870 scaledSize = ( std::abs( std::sin(
mAngle * M_PI / 180 ) ) + std::abs( std::cos(
mAngle * M_PI / 180 ) ) ) * scaledSize;
873 double pw =
static_cast< int >( std::round( ( (
qgsDoubleNear(
mPen.widthF(), 0.0 ) ? 1 :
mPen.widthF() * 4 ) + 1 ) ) ) / 2 * 2;
874 int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
875 double center = imageSize / 2.0;
881 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
888 p.setRenderHint( QPainter::Antialiasing );
889 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
891 p.translate( QPointF( center, center ) );
899 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
903 p.setRenderHint( QPainter::Antialiasing );
904 p.setBrush( needsBrush ?
mSelBrush : Qt::NoBrush );
906 p.translate( QPointF( center, center ) );
917 p.setRenderHint( QPainter::Antialiasing );
918 p.fillRect( 0, 0, imageSize, imageSize, selColor );
919 p.setBrush( needsBrush ?
mBrush : Qt::NoBrush );
921 p.translate( QPointF( center, center ) );
995 p->setBrush( Qt::NoBrush );
999 if ( !polygon.isEmpty() )
1000 p->drawPolygon( polygon );
1002 p->drawPath( path );
1019 double s = img.width();
1021 bool hasDataDefinedSize =
false;
1022 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1024 bool hasDataDefinedRotation =
false;
1029 p->drawImage( QRectF( point.x() - s / 2.0 + offset.x(),
1030 point.y() - s / 2.0 + offset.y(),
1045 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1048 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1054 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
1085 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1086 element.appendChild( graphicElem );
1095 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
1098 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
1102 angleFunc = QString::number( angle +
mAngle );
1113 Q_UNUSED( mmScaleFactor )
1114 Q_UNUSED( mapUnitScaleFactor )
1116 QString ogrType =
"3";
1117 if ( mName ==
"square" )
1121 else if ( mName ==
"triangle" )
1125 else if ( mName ==
"star" )
1129 else if ( mName ==
"circle" )
1133 else if ( mName ==
"cross" )
1137 else if ( mName ==
"x" || mName ==
"cross2" )
1141 else if ( mName ==
"line" )
1147 ogrString.append(
"SYMBOL(" );
1148 ogrString.append(
"id:" );
1149 ogrString.append(
'\"' );
1150 ogrString.append(
"ogr-sym-" );
1151 ogrString.append( ogrType );
1152 ogrString.append(
'\"' );
1153 ogrString.append(
",c:" );
1154 ogrString.append(
mColor.name() );
1155 ogrString.append(
",o:" );
1157 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
1158 ogrString.append(
')' );
1163 ogrString.append(
"PEN(" );
1164 ogrString.append(
"c:" );
1165 ogrString.append(
mColor.name() );
1166 ogrString.append(
",w:" );
1167 ogrString.append( QString::number(
mSize ) );
1168 ogrString.append(
"mm" );
1169 ogrString.append(
")" );
1177 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1178 if ( graphicElem.isNull() )
1181 QString name = QStringLiteral(
"square" );
1194 double d = angleFunc.toDouble( &ok );
1204 QString uom = element.attribute( QStringLiteral(
"uom" ) );
1230 p->drawPath(
mPath );
1243 if ( hasDataDefinedSize )
1252 size = std::sqrt( size );
1264 size *= mmMapUnitScaleFactor;
1271 double halfSize = size / 2.0;
1288 QColor pc =
mPen.color();
1289 QColor bc =
mBrush.color();
1309 QPointF off( offsetX, offsetY );
1338 t.translate( shift.x() + off.x(), shift.y() - off.y() );
1346 t.scale( halfSize, -halfSize );
1348 polygon = t.map( polygon );
1351 p.reserve( polygon.size() );
1352 for (
int i = 0; i < polygon.size(); i++ )
1357 if (
mBrush.style() != Qt::NoBrush )
1359 if (
mPen.style() != Qt::NoPen )
1360 e.
writePolyline( p, layerName, QStringLiteral(
"CONTINUOUS" ), pc, strokeWidth );
1362 else if ( shape ==
Circle )
1364 shift += QPointF( off.x(), -off.y() );
1365 if (
mBrush.style() != Qt::NoBrush )
1367 if (
mPen.style() != Qt::NoPen )
1368 e.
writeCircle( layerName, pc,
QgsPoint( shift ), halfSize, QStringLiteral(
"CONTINUOUS" ), strokeWidth );
1370 else if ( shape ==
Line )
1372 QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
1373 QPointF pt2 = t.map( QPointF( 0, halfSize ) );
1375 if (
mPen.style() != Qt::NoPen )
1378 else if ( shape ==
Cross )
1380 if (
mPen.style() != Qt::NoPen )
1382 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
1383 QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
1384 QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
1385 QPointF pt4 = t.map( QPointF( 0, halfSize ) );
1391 else if ( shape ==
Cross2 )
1393 if (
mPen.style() != Qt::NoPen )
1395 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
1396 QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
1397 QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
1398 QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
1406 if (
mPen.style() != Qt::NoPen )
1408 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
1409 QPointF pt2 = t.map( QPointF( 0, 0 ) );
1410 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1461 double penWidth = 0.0;
1476 if ( ok && strokeStyle == QLatin1String(
"no" ) )
1485 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
1486 penWidth / 2.0, penWidth / 2.0 );
1488 return symbolBounds;
1535 if ( props.contains( QStringLiteral(
"name" ) ) )
1536 name = props[QStringLiteral(
"name" )];
1537 if ( props.contains( QStringLiteral(
"size" ) ) )
1538 size = props[QStringLiteral(
"size" )].toDouble();
1539 if ( props.contains( QStringLiteral(
"angle" ) ) )
1540 angle = props[QStringLiteral(
"angle" )].toDouble();
1541 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1545 if ( props.contains( QStringLiteral(
"offset" ) ) )
1547 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1549 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1551 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1553 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1555 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1559 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1573 return QStringLiteral(
"FilledMarker" );
1598 map[QStringLiteral(
"size" )] = QString::number(
mSize );
1601 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1634 mFill.reset( static_cast<QgsFillSymbol *>( symbol ) );
1657 attr.unite( mFill->usedAttributes( context ) );
1665 if ( mFill && mFill->hasDataDefinedProperties() )
1674 mFill->setColor( c );
1679 return mFill ? mFill->color() :
mColor;
1695 p->setBrush( Qt::red );
1699 p->setBrush( Qt::NoBrush );
1701 p->setPen( Qt::black );
1703 if ( !polygon.isEmpty() )
1709 QPolygonF poly = path.toFillPolygon();
1729 mColor = QColor( 35, 35, 35 );
1730 mStrokeColor = QColor( 35, 35, 35 );
1731 updateDefaultAspectRatio();
1742 if ( props.contains( QStringLiteral(
"name" ) ) )
1743 name = props[QStringLiteral(
"name" )];
1744 if ( props.contains( QStringLiteral(
"size" ) ) )
1745 size = props[QStringLiteral(
"size" )].toDouble();
1746 if ( props.contains( QStringLiteral(
"angle" ) ) )
1747 angle = props[QStringLiteral(
"angle" )].toDouble();
1748 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
1754 if ( !props.contains( QStringLiteral(
"fill" ) ) && !props.contains( QStringLiteral(
"color" ) ) && !props.contains( QStringLiteral(
"outline" ) ) &&
1755 !props.contains( QStringLiteral(
"outline_color" ) ) && !props.contains( QStringLiteral(
"outline-width" ) ) && !props.contains( QStringLiteral(
"outline_width" ) ) )
1758 double fillOpacity = 1.0;
1759 double strokeOpacity = 1.0;
1761 bool hasFillParam =
false, hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1762 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1764 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1765 hasStrokeParam, hasDefaultStrokeColor, strokeColor,
1766 hasStrokeWidthParam, hasDefaultStrokeWidth, strokeWidth,
1767 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1768 if ( hasDefaultFillColor )
1772 if ( hasDefaultFillOpacity )
1775 c.setAlphaF( fillOpacity );
1778 if ( hasDefaultStrokeColor )
1782 if ( hasDefaultStrokeWidth )
1786 if ( hasDefaultStrokeOpacity )
1789 c.setAlphaF( strokeOpacity );
1794 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
1796 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
1798 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
1800 if ( props.contains( QStringLiteral(
"offset" ) ) )
1802 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1804 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1806 if ( props.contains( QStringLiteral(
"fill" ) ) )
1811 else if ( props.contains( QStringLiteral(
"color" ) ) )
1815 if ( props.contains( QStringLiteral(
"outline" ) ) )
1820 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
1824 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
1829 if ( props.contains( QStringLiteral(
"outline-width" ) ) )
1832 m->
setStrokeWidth( props[QStringLiteral(
"outline-width" )].toDouble() );
1834 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
1836 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
1838 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
1840 m->
setStrokeWidth( props[QStringLiteral(
"line_width" )].toDouble() );
1843 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
1847 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
1851 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1854 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
1858 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
1872 QgsStringMap::iterator it = properties.find( QStringLiteral(
"name" ) );
1873 if ( it != properties.end() )
1885 QColor defaultFillColor, defaultStrokeColor;
1886 double strokeWidth, fillOpacity, strokeOpacity;
1887 bool hasFillParam =
false, hasFillOpacityParam =
false, hasStrokeParam =
false, hasStrokeWidthParam =
false, hasStrokeOpacityParam =
false;
1888 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultStrokeColor =
false, hasDefaultStrokeWidth =
false, hasDefaultStrokeOpacity =
false;
1890 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1891 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
1892 hasStrokeWidthParam, hasDefaultStrokeWidth, strokeWidth,
1893 hasStrokeOpacityParam, hasDefaultStrokeOpacity, strokeOpacity );
1895 double newFillOpacity = hasFillOpacityParam ?
fillColor().alphaF() : 1.0;
1896 double newStrokeOpacity = hasStrokeOpacityParam ?
strokeColor().alphaF() : 1.0;
1898 if ( hasDefaultFillColor )
1900 defaultFillColor.setAlphaF( newFillOpacity );
1903 if ( hasDefaultFillOpacity )
1906 c.setAlphaF( fillOpacity );
1909 if ( hasDefaultStrokeColor )
1911 defaultStrokeColor.setAlphaF( newStrokeOpacity );
1914 if ( hasDefaultStrokeWidth )
1916 setStrokeWidth( strokeWidth );
1918 if ( hasDefaultStrokeOpacity )
1921 c.setAlphaF( strokeOpacity );
1925 updateDefaultAspectRatio();
1930 if ( mDefaultAspectRatio == 0.0 )
1935 double widthScaleFactor = 3.465;
1938 mDefaultAspectRatio = svgViewbox.isValid() ? svgViewbox.height() / svgViewbox.width() : 0.0;
1940 return mDefaultAspectRatio;
1945 bool aPreservedAspectRatio = preservedAspectRatio();
1946 if ( aPreservedAspectRatio && !par )
1948 mFixedAspectRatio = mDefaultAspectRatio;
1950 else if ( !aPreservedAspectRatio && par )
1952 mFixedAspectRatio = 0.0;
1954 return preservedAspectRatio();
1960 return QStringLiteral(
"SvgMarker" );
1980 bool hasDataDefinedSize =
false;
1981 double scaledSize =
calculateSize( context, hasDataDefinedSize );
1985 if ( static_cast< int >( size ) < 1 || 10000.0 < size )
1992 bool hasDataDefinedAspectRatio =
false;
1993 double aspectRatio = calculateAspectRatio( context, scaledSize, hasDataDefinedAspectRatio );
1995 QPointF outputOffset;
1999 p->translate( point + outputOffset );
2005 QString path =
mPath;
2013 double strokeWidth = mStrokeWidth;
2035 bool fitsInCache =
true;
2036 bool usePict =
true;
2037 double hwRatio = 1.0;
2043 if ( fitsInCache && img.width() > 1 )
2049 QImage transparentImage = img.copy();
2051 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
2052 hwRatio =
static_cast< double >( transparentImage.height() ) / static_cast< double >( transparentImage.width() );
2056 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2057 hwRatio =
static_cast< double >( img.height() ) / static_cast< double >( img.width() );
2062 if ( usePict || !fitsInCache )
2064 p->setOpacity( context.
opacity() );
2068 if ( pct.width() > 1 )
2071 _fixQPictureDPI( p );
2072 p->drawPicture( 0, 0, pct );
2074 hwRatio =
static_cast< double >( pct.height() ) / static_cast< double >( pct.width() );
2082 if ( penWidth > size / 20 )
2085 penWidth = size / 20;
2087 double penOffset = penWidth / 2;
2088 pen.setWidth( penWidth );
2090 p->setBrush( Qt::NoBrush );
2091 double wSize = size + penOffset;
2092 double hSize = size * hwRatio + penOffset;
2093 p->drawRect( QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
2101 p->setRenderHint( QPainter::Antialiasing );
2106 double QgsSvgMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const 2108 double scaledSize =
mSize;
2112 if ( hasDataDefinedSize )
2120 if ( hasDataDefinedSize )
2127 if ( hasDataDefinedSize && ok )
2132 scaledSize = std::sqrt( scaledSize );
2145 if ( !hasDataDefinedAspectRatio )
2146 return mFixedAspectRatio;
2151 double scaledAspectRatio = mDefaultAspectRatio;
2152 if ( mFixedAspectRatio > 0.0 )
2153 scaledAspectRatio = mFixedAspectRatio;
2155 double defaultHeight =
mSize * scaledAspectRatio;
2156 scaledAspectRatio = defaultHeight / scaledSize;
2159 double scaledHeight = scaledSize * scaledAspectRatio;
2166 if ( hasDataDefinedAspectRatio && ok )
2171 scaledHeight = sqrt( scaledHeight );
2178 scaledAspectRatio = scaledHeight / scaledSize;
2180 return scaledAspectRatio;
2188 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
2189 offset = QPointF( offsetX, offsetY );
2199 if ( hasDataDefinedRotation )
2225 map[QStringLiteral(
"name" )] =
mPath;
2226 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2229 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number( mFixedAspectRatio );
2230 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2237 map[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
2269 mStrokeWidthUnit = unit;
2275 if ( unit != mStrokeWidthUnit )
2285 mStrokeWidthMapUnitScale = scale;
2292 return mStrokeWidthMapUnitScale;
2300 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2301 element.appendChild( graphicElem );
2311 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2314 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2318 angleFunc = QString::number( angle +
mAngle );
2332 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
2333 if ( graphicElem.isNull() )
2336 QString path, mimeType;
2343 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2346 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2354 double d = angleFunc.toDouble( &ok );
2380 if ( hasDataDefinedSize )
2386 if ( hasDataDefinedSize && ok )
2391 size = std::sqrt( size );
2400 size *= mmMapUnitScaleFactor;
2414 double offsetX = offset.x();
2415 double offsetY = offset.y();
2417 QPointF outputOffset( offsetX, offsetY );
2431 QString path =
mPath;
2439 double strokeWidth = mStrokeWidth;
2465 QSvgRenderer r( svgContent );
2472 QSizeF outSize( r.defaultSize() );
2473 outSize.scale( size, size, Qt::KeepAspectRatio );
2479 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
2481 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
2483 pd.
setShift( shift + QPointF( outputOffset.x(), -outputOffset.y() ) );
2484 pd.
setOutputSize( QRectF( -outSize.width() / 2.0, -outSize.height() / 2.0, outSize.width(), outSize.height() ) );
2493 bool hasDataDefinedSize =
false;
2494 double scaledSize =
calculateSize( context, hasDataDefinedSize );
2498 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2503 QPointF outputOffset;
2507 QString path =
mPath;
2515 double strokeWidth = mStrokeWidth;
2542 double scaledHeight = svgViewbox.isValid() ? scaledSize * svgViewbox.height() / svgViewbox.width() : scaledSize;
2547 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2550 transform.rotate( angle );
2553 strokeWidth += 1.0 / 2.0;
2555 QRectF symbolBounds = transform.mapRect( QRectF( -scaledSize / 2.0,
2556 -scaledHeight / 2.0,
2561 symbolBounds.adjust( -strokeWidth / 2.0, -strokeWidth / 2.0,
2562 strokeWidth / 2.0, strokeWidth / 2.0 );
2564 return symbolBounds;
2588 if ( props.contains( QStringLiteral(
"imageFile" ) ) )
2589 path = props[QStringLiteral(
"imageFile" )];
2590 if ( props.contains( QStringLiteral(
"size" ) ) )
2591 size = props[QStringLiteral(
"size" )].toDouble();
2592 if ( props.contains( QStringLiteral(
"angle" ) ) )
2593 angle = props[QStringLiteral(
"angle" )].toDouble();
2594 if ( props.contains( QStringLiteral(
"scale_method" ) ) )
2599 if ( props.contains( QStringLiteral(
"alpha" ) ) )
2601 m->
setOpacity( props[QStringLiteral(
"alpha" )].toDouble() );
2604 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2606 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
2608 if ( props.contains( QStringLiteral(
"fixedAspectRatio" ) ) )
2611 if ( props.contains( QStringLiteral(
"offset" ) ) )
2613 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2615 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2618 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
2622 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
2635 QgsStringMap::iterator it = properties.find( QStringLiteral(
"name" ) );
2636 if ( it != properties.end() )
2654 if ( aPreservedAspectRatio && !par )
2658 else if ( !aPreservedAspectRatio && par )
2670 mDefaultAspectRatio = ( !size.isNull() && size.isValid() && size.width() > 0 ) ? static_cast< double >( size.height() ) / static_cast< double >( size.width() ) : 0.0;
2677 return QStringLiteral(
"RasterMarker" );
2686 bool hasDataDefinedSize =
false;
2687 double scaledSize = calculateSize( context, hasDataDefinedSize );
2689 bool hasDataDefinedAspectRatio =
false;
2694 if ( static_cast< int >( width ) < 1 || 10000.0 < width )
2699 QString path =
mPath;
2707 if ( !size.isNull() && size.isValid() && size.width() > 0 )
2709 height = width * (
static_cast< double >( size.height() ) / static_cast< double >( size.width() ) );
2714 if ( path.isEmpty() )
2719 QPointF outputOffset;
2721 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset, angle );
2723 p->translate( point + outputOffset );
2739 if ( !img.isNull() )
2744 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
2750 double QgsRasterMarkerSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
bool &hasDataDefinedSize )
const 2752 double scaledSize =
mSize;
2756 if ( hasDataDefinedSize )
2764 if ( hasDataDefinedSize )
2771 if ( hasDataDefinedSize && ok )
2776 scaledSize = std::sqrt( scaledSize );
2789 if ( !hasDataDefinedAspectRatio )
2799 double defaultHeight =
mSize * scaledAspectRatio;
2800 scaledAspectRatio = defaultHeight / scaledSize;
2803 double scaledHeight = scaledSize * scaledAspectRatio;
2810 if ( hasDataDefinedAspectRatio && ok )
2815 scaledHeight = sqrt( scaledHeight );
2822 scaledAspectRatio = scaledHeight / scaledSize;
2824 return scaledAspectRatio;
2827 void QgsRasterMarkerSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &angle )
const 2832 markerOffset( context, scaledWidth, scaledHeight, offsetX, offsetY );
2833 offset = QPointF( offsetX, offsetY );
2843 if ( hasDataDefinedRotation )
2864 map[QStringLiteral(
"imageFile" )] =
mPath;
2865 map[QStringLiteral(
"size" )] = QString::number(
mSize );
2868 map[QStringLiteral(
"fixedAspectRatio" )] = QString::number(
mFixedAspectRatio );
2869 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
2870 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
2909 bool hasDataDefinedSize =
false;
2910 double scaledSize = calculateSize( context, hasDataDefinedSize );
2912 bool hasDataDefinedAspectRatio =
false;
2917 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
2922 QPointF outputOffset;
2924 calculateOffsetAndRotation( context, scaledSize, scaledSize * ( height / width ), outputOffset, angle );
2929 transform.translate( point.x() + outputOffset.x(), point.y() + outputOffset.y() );
2932 transform.rotate( angle );
2934 QRectF symbolBounds = transform.mapRect( QRectF( -width / 2.0,
2939 return symbolBounds;
2946 mFontFamily = fontFamily;
2951 mOrigSize = pointSize;
2963 delete mFontMetrics;
2974 if ( props.contains( QStringLiteral(
"font" ) ) )
2975 fontFamily = props[QStringLiteral(
"font" )];
2976 if ( props.contains( QStringLiteral(
"chr" ) ) && props[QStringLiteral(
"chr" )].length() > 0 )
2977 string = props[QStringLiteral(
"chr" )];
2978 if ( props.contains( QStringLiteral(
"size" ) ) )
2979 pointSize = props[QStringLiteral(
"size" )].toDouble();
2980 if ( props.contains( QStringLiteral(
"color" ) ) )
2982 if ( props.contains( QStringLiteral(
"angle" ) ) )
2983 angle = props[QStringLiteral(
"angle" )].toDouble();
2987 if ( props.contains( QStringLiteral(
"outline_color" ) ) )
2989 if ( props.contains( QStringLiteral(
"outline_width" ) ) )
2990 m->
setStrokeWidth( props[QStringLiteral(
"outline_width" )].toDouble() );
2991 if ( props.contains( QStringLiteral(
"offset" ) ) )
2993 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
2995 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2997 if ( props.contains( QStringLiteral(
"size_unit" ) ) )
2999 if ( props.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
3001 if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
3003 if ( props.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3005 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
3007 if ( props.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
3009 if ( props.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
3019 return QStringLiteral(
"FontMarker" );
3024 QColor brushColor =
mColor;
3025 QColor penColor = mStrokeColor;
3027 brushColor.setAlphaF(
mColor.alphaF() * context.
opacity() );
3028 penColor.setAlphaF( mStrokeColor.alphaF() * context.
opacity() );
3030 mBrush = QBrush( brushColor );
3031 mPen = QPen( penColor );
3032 mPen.setJoinStyle( mPenJoinStyle );
3035 mFont = QFont( mFontFamily );
3040 mFont.setPixelSize( std::max( 2, static_cast< int >( std::round( sizePixels ) ) ) );
3041 delete mFontMetrics;
3042 mFontMetrics =
new QFontMetrics( mFont );
3043 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) 3044 mChrWidth = mFontMetrics->width( mString );
3046 mChrWidth = mFontMetrics->horizontalAdvance( mString );
3048 mChrOffset = QPointF( mChrWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3053 if ( mUseCachedPath )
3055 QPointF chrOffset = mChrOffset;
3057 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3058 mCachedPath = QPainterPath();
3059 mCachedPath.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3068 QString QgsFontMarkerSymbolLayer::characterToRender(
QgsSymbolRenderContext &context, QPointF &charOffset,
double &charWidth )
3070 charOffset = mChrOffset;
3071 QString stringToRender = mString;
3076 if ( stringToRender != mString )
3078 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) 3079 charWidth = mFontMetrics->width( stringToRender );
3081 charWidth = mFontMetrics->horizontalAdvance( stringToRender );
3083 charOffset = QPointF( charWidth / 2.0, -mFontMetrics->ascent() / 2.0 );
3086 return stringToRender;
3091 bool &hasDataDefinedRotation,
3093 double &angle )
const 3098 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
3099 offset = QPointF( offsetX, offsetY );
3115 if ( hasDataDefinedRotation )
3139 double scaledSize =
mSize;
3143 if ( hasDataDefinedSize )
3149 if ( hasDataDefinedSize && ok )
3154 scaledSize = std::sqrt( scaledSize );
3166 if ( !p || !mNonZeroFontSize )
3169 QTransform transform;
3172 QColor brushColor =
mColor;
3179 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
3180 mBrush.setColor( brushColor );
3182 QColor penColor = mStrokeColor;
3188 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
3212 p->setBrush( mBrush );
3215 mPen.setColor( penColor );
3216 mPen.setWidthF( penWidth );
3221 p->setPen( Qt::NoPen );
3224 QPointF chrOffset = mChrOffset;
3226 QString charToRender = characterToRender( context, chrOffset, chrWidth );
3228 double sizeToRender = calculateSize( context );
3230 bool hasDataDefinedRotation =
false;
3233 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation, offset, angle );
3235 p->translate( point.x() + offset.x(), point.y() + offset.y() );
3238 transform.rotate( angle );
3242 double s = sizeToRender / mOrigSize;
3243 transform.scale( s, s );
3246 if ( mUseCachedPath )
3248 p->drawPath( transform.map( mCachedPath ) );
3253 path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
3254 p->drawPath( transform.map( path ) );
3263 props[QStringLiteral(
"font" )] = mFontFamily;
3264 props[QStringLiteral(
"chr" )] = mString;
3265 props[QStringLiteral(
"size" )] = QString::number(
mSize );
3270 props[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
3274 props[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3306 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3307 element.appendChild( graphicElem );
3309 QString fontPath = QStringLiteral(
"ttf://%1" ).arg( mFontFamily );
3310 int markIndex = !mString.isEmpty() ? mString.at( 0 ).unicode() : 0;
3317 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3320 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
3324 angleFunc = QString::number( angle +
mAngle );
3335 QPointF chrOffset = mChrOffset;
3336 double chrWidth = mChrWidth;
3338 ( void )characterToRender( context, chrOffset, chrWidth );
3340 if ( !mFontMetrics )
3341 mFontMetrics =
new QFontMetrics( mFont );
3343 double scaledSize = calculateSize( context );
3346 chrWidth *= scaledSize / mOrigSize;
3349 bool hasDataDefinedRotation =
false;
3352 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
3358 transform.translate( point.x() + offset.x(), point.y() + offset.y() );
3361 transform.rotate( angle );
3363 QRectF symbolBounds = transform.mapRect( QRectF( -chrWidth / 2.0,
3367 return symbolBounds;
3374 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
3375 if ( graphicElem.isNull() )
3378 QString name, format;
3386 if ( !name.startsWith( QLatin1String(
"ttf://" ) ) || format != QLatin1String(
"ttf" ) )
3389 QString fontFamily = name.mid( 6 );
3396 double d = angleFunc.toDouble( &ok );
3404 QString uom = element.attribute( QStringLiteral(
"uom" ) );
bool prepareCache(QgsSymbolRenderContext &context)
Prepares cache image.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
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)
#define DEFAULT_SIMPLEMARKER_SIZE
QgsMapUnitScale mapUnitScale() const override
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
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...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSimpleMarkerSymbolLayer from an SLD XML element.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
double symbologyScale() const
Returns the reference scale for output.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
#define DEFAULT_RASTERMARKER_SIZE
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 clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
void setColor(const QColor &c) override
The fill color.
QColor mStrokeColor
Stroke color.
QgsFields fields() const
Fields of the layer.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol 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...
Qt::PenStyle mStrokeStyle
Stroke style.
Calculate scale by the diameter.
Abstract base class for all rendered symbols.
void setMapUnitScale(const QgsMapUnitScale &scale) override
A paint device for drawing into dxf files.
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...
#define DEFAULT_SIMPLEMARKER_NAME
Use antialiasing while drawing.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke...
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
Abstract base class for simple marker symbol layers.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
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.
Right facing filled arrow head.
Right facing arrow head (unfilled, lines only)
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.
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double mLineAngle
Line rotation angle (see setLineAngle() for details)
void setDrawingSize(QSizeF size)
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
virtual QColor strokeColor() const
Gets stroke color.
QgsMapUnitScale mapUnitScale() const override
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
static const int MAXIMUM_CACHE_WIDTH
Maximum width/height of cache image.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
#define DEFAULT_FONTMARKER_COLOR
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
QBrush mSelBrush
QBrush to use as fill of selected symbols.
static QgsSimpleMarkerSymbolLayerBase::Shape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
void setStrokeWidth(double width)
Set's the marker's stroke width.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
#define DEFAULT_FONTMARKER_BORDERCOLOR
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
Flags flags() const
Returns combination of flags used for rendering.
double mFixedAspectRatio
The marker fixed aspect ratio.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
QPointF mOffset
Marker offset.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QColor strokeColor() const override
Returns the marker's stroke color.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Stroke width units.
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false)
Gets SVG content.
static QString encodeShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Encodes a shape to its string representation.
QgsMapUnitScale mapUnitScale() const override
QMap< QString, QString > QgsStringMap
Rotation of symbol may be changed during rendering and symbol should not be cached.
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.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
Name, eg shape name for simple markers.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes()
Returns a list of all available shape types.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double mapRotation() const
Returns current map rotation in degrees.
#define DEFAULT_FONTMARKER_SIZE
QColor strokeColor() const override
Gets stroke color.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
double strokeWidth() const
Returns the width of the marker's stroke.
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setPath(const QString &path)
Set the marker SVG path.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath...
static QString encodeColor(const QColor &color)
Diagonal half square (bottom left half)
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
virtual void setColor(const QColor &color)
The fill color.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
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
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...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
static QString encodePenStyle(Qt::PenStyle style)
Perform transforms between map coordinates and device coordinates.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsFilledMarkerSymbolLayer.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSimpleMarkerSymbolLayer.
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
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, otherwise returns the value un-modified.
One third circle (top left third)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
Quarter circle (top left quarter)
Raster marker symbol layer class.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
bool shapeToPolygon(Shape shape, QPolygonF &polygon) const
Creates a polygon representing the specified shape.
void setStrokeColor(const QColor &color) override
Set stroke color.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
double updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
void setColor(const QColor &color) override
The fill color.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
double opacity() const
Returns the marker opacity.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
#define QgsDebugMsgLevel(str, level)
bool mUsingCache
true if using cached images of markers for drawing.
static void adjustHueSaturation(QImage &image, double saturation, const QColor &colorizeColor=QColor(), double colorizeStrength=1.0)
Alter the hue or saturation of a QImage.
QPen mPen
QPen corresponding to marker's stroke style.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
#define DEFAULT_SCALE_METHOD
Q_GUI_EXPORT int qt_defaultDpiY()
double calculateSize(QgsSymbolRenderContext &context, bool &hasDataDefinedSize) const
Calculates the desired size of the marker, considering data defined size overrides.
Calculate scale by the area.
double mOpacity
The marker default opacity.
qreal opacity() const
Returns the opacity for the symbol.
double size() const
Returns the symbol size.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0...
double mStrokeWidth
Stroke width.
QgsMapUnitScale mapUnitScale() const override
#define DEFAULT_RASTERMARKER_ANGLE
QBrush mBrush
QBrush corresponding to marker's fill style.
QgsSimpleMarkerSymbolLayerBase(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsSimpleMarkerSymbolLayerBase.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
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 setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
#define DEFAULT_FONTMARKER_JOINSTYLE
void setLayer(const QString &layer)
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
QColor color() const override
The fill color.
void calculateOffsetAndRotation(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle) const
Calculates the marker offset and rotation.
virtual QColor color() const
The fill color.
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
void setFillColor(const QColor &color) override
Set fill color.
QColor fillColor() const override
Gets fill color.
QColor selectionColor() const
Returns the color to use when rendering selected features.
#define DEFAULT_FONTMARKER_ANGLE
void setStrokeWidth(double w)
double mAngle
Marker rotation angle, in degrees clockwise from north.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsFontMarkerSymbolLayer from a property map (see properties())
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Character, eg for font marker symbol layers.
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...
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
void setOpacity(double opacity)
Set the marker opacity.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QPen mSelPen
QPen to use as stroke of selected symbols.
QString path() const
Returns the marker raster image path.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Point geometry type, with support for z-dimension and m-values.
static Qt::PenStyle decodePenStyle(const QString &str)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
void setPath(const QString &path)
Set the marker raster image path.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style...
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 renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets 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.
HorizontalAnchorPoint
Symbol horizontal anchor points.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
virtual void setStrokeColor(const QColor &color)
Set stroke color.
VerticalAnchorPoint
Symbol vertical anchor points.
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QString layerType() const override
Returns a string that represents this layer type.
Q_GUI_EXPORT int qt_defaultDpiX()
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QgsSymbol::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
QgsRasterMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsExpressionContext & expressionContext()
Gets the expression context.
QString layerType() const override
Returns a string that represents this layer type.
static QString encodeScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QVector< QgsPoint > QgsPointSequence
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
QString layerType() const override
Returns a string that represents this layer type.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
QVector< QgsPointSequence > QgsRingSequence
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsFontMarkerSymbolLayer from an SLD XML element.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
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...
Stroke style (eg solid, dashed)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
void setShift(QPointF shift)
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
QPainter * painter()
Returns the destination QPainter for the render operation.
virtual void setFillColor(const QColor &color)
Set fill color.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QColor color() const override
The fill color.
SymbolType type() const
Returns the symbol's type.
QImage mCache
Cached image of marker, if using cached version.
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSimpleMarkerSymbolLayer * 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.
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEMARKER_ANGLE
#define DEFAULT_SIMPLEMARKER_COLOR
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Shape
Marker symbol shapes.
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.
QgsSymbol::ScaleMethod mScaleMethod
Marker size scaling method.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
const QgsFeature * feature() const
Returns the current feature being rendered.
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...
~QgsFontMarkerSymbolLayer() override
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QColor fillColor() const override
Gets fill color.
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
QImage mSelCache
Cached image of selected marker, if using cached version.
#define DEFAULT_FONTMARKER_CHR
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
void setAngle(double angle)
Sets the rotation angle for the marker.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QString layerType() const override
Returns a string that represents this layer type.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double mDefaultAspectRatio
The marker default 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
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
QgsWkbTypes::GeometryType type
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
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&.
void setFillColor(const QColor &color) override
Set fill color.
static bool shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Returns true if a symbol shape has a fill.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
Shape mShape
Symbol shape.
bool prepareMarkerShape(Shape shape)
Prepares the layer for drawing the specified shape (QPolygonF version)
Resolves relative paths into absolute paths and vice versa.
void setMapUnitScale(const QgsMapUnitScale &scale) override
bool setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a raster marker symbol layer from a string map of properties.
#define DEFAULT_SVGMARKER_SIZE
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
QgsFilledMarkerSymbolLayer(QgsSimpleMarkerSymbolLayerBase::Shape shape=Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbol::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsFilledMarkerSymbolLayer.
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false)
Returns the specified path rendered as an image.
virtual QColor fillColor() const
Gets fill color.
#define DEFAULT_SVGMARKER_ANGLE
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
Rotated cross (lines only), "x" shape.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
#define DEFAULT_FONTMARKER_FONT
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
QgsPropertyCollection mDataDefinedProperties
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.
bool prepareMarkerPath(Shape symbol)
Prepares the layer for drawing the specified shape (QPainterPath version)
Quarter square (top left quarter)
RenderUnit
Rendering size units.
static QColor decodeColor(const QString &str)
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void setOutputSize(const QRectF &r)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QgsSymbol::RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...