QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
31 #include <QDomDocument>
32 #include <QDomElement>
37 : mPenStyle( penStyle )
41 mCustomDashVector << 5 << 2;
49 mCustomDashPatternUnit = unit;
67 mCustomDashPatternMapUnitScale = scale;
87 if ( props.contains( QStringLiteral(
"line_color" ) ) )
91 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
95 else if ( props.contains( QStringLiteral(
"color" ) ) )
100 if ( props.contains( QStringLiteral(
"line_width" ) ) )
102 width = props[QStringLiteral(
"line_width" )].toDouble();
104 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
106 width = props[QStringLiteral(
"outline_width" )].toDouble();
108 else if ( props.contains( QStringLiteral(
"width" ) ) )
111 width = props[QStringLiteral(
"width" )].toDouble();
113 if ( props.contains( QStringLiteral(
"line_style" ) ) )
117 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
121 else if ( props.contains( QStringLiteral(
"penstyle" ) ) )
127 if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
131 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
135 else if ( props.contains( QStringLiteral(
"width_unit" ) ) )
140 if ( props.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
142 if ( props.contains( QStringLiteral(
"offset" ) ) )
143 l->
setOffset( props[QStringLiteral(
"offset" )].toDouble() );
144 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
146 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
148 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
150 if ( props.contains( QStringLiteral(
"capstyle" ) ) )
153 if ( props.contains( QStringLiteral(
"use_custom_dash" ) ) )
157 if ( props.contains( QStringLiteral(
"customdash" ) ) )
161 if ( props.contains( QStringLiteral(
"customdash_unit" ) ) )
165 if ( props.contains( QStringLiteral(
"customdash_map_unit_scale" ) ) )
170 if ( props.contains( QStringLiteral(
"draw_inside_polygon" ) ) )
175 if ( props.contains( QStringLiteral(
"ring_filter" ) ) )
188 return QStringLiteral(
"SimpleLine" );
195 mPen.setColor( penColor );
197 mPen.setWidthF( scaledWidth );
198 if ( mUseCustomDashPattern )
200 mPen.setStyle( Qt::CustomDashLine );
203 double dashWidthDiv =
qgsDoubleNear( scaledWidth, 0 ) ? 1.0 : scaledWidth;
206 QStringList versionSplit = QString( qVersion() ).split(
'.' );
207 if ( versionSplit.size() > 1
208 && versionSplit.at( 1 ).toInt() >= 8
209 && scaledWidth < 1.0 )
213 QVector<qreal> scaledVector;
214 QVector<qreal>::const_iterator it = mCustomDashVector.constBegin();
215 for ( ; it != mCustomDashVector.constEnd(); ++it )
220 mPen.setDashPattern( scaledVector );
224 mPen.setStyle( mPenStyle );
226 mPen.setJoinStyle( mPenJoinStyle );
227 mPen.setCapStyle( mPenCapStyle );
232 selColor.setAlphaF( context.
opacity() );
233 mSelPen.setColor( selColor );
249 if ( mDrawInsidePolygon )
257 if ( mDrawInsidePolygon )
260 QPainterPath clipPath;
261 clipPath.addPolygon( points );
266 for (
auto it = rings->constBegin(); it != rings->constEnd(); ++it )
268 QPolygonF ring = *it;
269 clipPath.addPolygon( ring );
274 p->setClipPath( clipPath, Qt::IntersectClip );
293 for (
const QPolygonF &ring : qgis::as_const( *rings ) )
303 if ( mDrawInsidePolygon )
320 applyDataDefinedSymbology( context, mPen, mSelPen,
offset );
322 p->setPen( context.
selected() ? mSelPen : mPen );
323 p->setBrush( Qt::NoBrush );
326 if ( points.size() <= 2 &&
329 ( p->renderHints() & QPainter::Antialiasing ) )
331 p->setRenderHint( QPainter::Antialiasing,
false );
333 p->drawPolyline( points );
336 path.addPolygon( points );
339 p->setRenderHint( QPainter::Antialiasing,
true );
346 p->drawPolyline( points );
349 path.addPolygon( points );
364 for (
int part = 0; part < mline.count(); ++part )
367 p->drawPolyline( mline );
370 path.addPolygon( mline[ part ] );
381 map[QStringLiteral(
"line_width" )] = QString::number(
mWidth );
387 map[QStringLiteral(
"offset" )] = QString::number(
mOffset );
390 map[QStringLiteral(
"use_custom_dash" )] = ( mUseCustomDashPattern ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
394 map[QStringLiteral(
"draw_inside_polygon" )] = ( mDrawInsidePolygon ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
395 map[QStringLiteral(
"ring_filter" )] = QString::number(
static_cast< int >(
mRingFilter ) );
422 if ( mPenStyle == Qt::NoPen )
425 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:LineSymbolizer" ) );
426 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
427 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
428 element.appendChild( symbolizerElem );
434 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
435 symbolizerElem.appendChild( strokeElem );
437 Qt::PenStyle
penStyle = mUseCustomDashPattern ? Qt::CustomDashLine : mPenStyle;
446 QDomElement perpOffsetElem = doc.createElement( QStringLiteral(
"se:PerpendicularOffset" ) );
449 symbolizerElem.appendChild( perpOffsetElem );
455 if ( mUseCustomDashPattern )
458 mPen.color(), mPenJoinStyle,
459 mPenCapStyle,
mOffset, &mCustomDashVector );
472 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
473 if ( strokeElem.isNull() )
490 QDomElement perpOffsetElem = element.firstChildElement( QStringLiteral(
"PerpendicularOffset" ) );
491 if ( !perpOffsetElem.isNull() )
494 double d = perpOffsetElem.firstChild().nodeValue().toDouble( &ok );
499 QString uom = element.attribute( QStringLiteral(
"uom" ) );
513 void QgsSimpleLineSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QPen &pen, QPen &selPen,
double &offset )
519 bool hasStrokeWidthExpression =
false;
526 pen.setWidthF( scaledWidth );
527 selPen.setWidthF( scaledWidth );
528 hasStrokeWidthExpression =
true;
549 double dashWidthDiv = mPen.widthF();
551 if ( hasStrokeWidthExpression )
553 dashWidthDiv = pen.widthF();
554 scaledWidth = pen.widthF();
558 QStringList versionSplit = QString( qVersion() ).split(
'.' );
559 if ( versionSplit.size() > 1
560 && versionSplit.at( 1 ).toInt() >= 8
561 && scaledWidth < 1.0 )
566 QVector<qreal> dashVector;
568 if ( exprVal.isValid() )
570 QStringList dashList = exprVal.toString().split(
';' );
571 QStringList::const_iterator dashIt = dashList.constBegin();
572 for ( ; dashIt != dashList.constEnd(); ++dashIt )
576 pen.setDashPattern( dashVector );
585 if ( exprVal.isValid() )
594 if ( exprVal.isValid() )
603 if ( exprVal.isValid() )
610 if ( mDrawInsidePolygon )
624 unit = mCustomDashPatternUnit;
625 return mUseCustomDashPattern ? mCustomDashVector : QVector<qreal>();
686 MyLine( QPointF p1, QPointF p2 )
688 , mIncreasing( false )
700 mIncreasing = ( p2.y() > p1.y() );
705 mT = ( p2.y() - p1.y() ) / ( p2.x() - p1.x() );
706 mIncreasing = ( p2.x() > p1.x() );
710 double x = ( p2.x() - p1.x() );
711 double y = ( p2.y() - p1.y() );
712 mLength = std::sqrt( x * x + y * y );
718 double a = ( mVertical ? M_PI_2 : std::atan( mT ) );
726 QPointF diffForInterval(
double interval )
729 return ( mIncreasing ? QPointF( 0, interval ) : QPointF( 0, -interval ) );
731 double alpha = std::atan( mT );
732 double dx = std::cos( alpha ) * interval;
733 double dy = std::sin( alpha ) * interval;
734 return ( mIncreasing ? QPointF( dx, dy ) : QPointF( -dx, -dy ) );
737 double length() {
return mLength; }
752 : mRotateSymbols( rotateSymbol )
753 , mInterval( interval )
773 if ( exprVal.isValid() )
775 QString placementString = exprVal.toString();
776 if ( placementString.compare( QLatin1String(
"interval" ), Qt::CaseInsensitive ) == 0 )
780 else if ( placementString.compare( QLatin1String(
"vertex" ), Qt::CaseInsensitive ) == 0 )
784 else if ( placementString.compare( QLatin1String(
"lastvertex" ), Qt::CaseInsensitive ) == 0 )
788 else if ( placementString.compare( QLatin1String(
"firstvertex" ), Qt::CaseInsensitive ) == 0 )
792 else if ( placementString.compare( QLatin1String(
"centerpoint" ), Qt::CaseInsensitive ) == 0 )
796 else if ( placementString.compare( QLatin1String(
"curvepoint" ), Qt::CaseInsensitive ) == 0 )
800 else if ( placementString.compare( QLatin1String(
"segmentcenter" ), Qt::CaseInsensitive ) == 0 )
814 double averageOver = mAverageAngleLength;
827 renderPolylineInterval( points, context, averageOver );
831 renderPolylineCentral( points, context, averageOver );
839 renderPolylineVertex( points, context,
placement );
848 for (
int part = 0; part < mline.count(); ++part )
850 const QPolygonF &points2 = mline[ part ];
855 renderPolylineInterval( points2, context, averageOver );
859 renderPolylineCentral( points2, context, averageOver );
867 renderPolylineVertex( points2, context,
placement );
903 for (
int i = 0; i < rings->size(); ++i )
952 map[QStringLiteral(
"rotate" )] = (
rotateSymbols() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
953 map[QStringLiteral(
"interval" )] = QString::number(
interval() );
954 map[QStringLiteral(
"offset" )] = QString::number(
mOffset );
955 map[QStringLiteral(
"offset_along_line" )] = QString::number(
offsetAlongLine() );
962 map[QStringLiteral(
"average_angle_length" )] = QString::number( mAverageAngleLength );
966 switch ( mPlacement )
969 map[QStringLiteral(
"placement" )] = QStringLiteral(
"vertex" );
972 map[QStringLiteral(
"placement" )] = QStringLiteral(
"lastvertex" );
975 map[QStringLiteral(
"placement" )] = QStringLiteral(
"firstvertex" );
978 map[QStringLiteral(
"placement" )] = QStringLiteral(
"centralpoint" );
981 map[QStringLiteral(
"placement" )] = QStringLiteral(
"curvepoint" );
984 map[QStringLiteral(
"placement" )] = QStringLiteral(
"interval" );
987 map[QStringLiteral(
"placement" )] = QStringLiteral(
"segmentcenter" );
991 map[QStringLiteral(
"ring_filter" )] = QString::number(
static_cast< int >(
mRingFilter ) );
1017 if (
properties.contains( QStringLiteral(
"offset" ) ) )
1021 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
1025 if (
properties.contains( QStringLiteral(
"interval_unit" ) ) )
1029 if (
properties.contains( QStringLiteral(
"offset_along_line" ) ) )
1033 if (
properties.contains( QStringLiteral(
"offset_along_line_unit" ) ) )
1037 if (
properties.contains( ( QStringLiteral(
"offset_along_line_map_unit_scale" ) ) ) )
1042 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1046 if (
properties.contains( QStringLiteral(
"interval_map_unit_scale" ) ) )
1051 if (
properties.contains( QStringLiteral(
"average_angle_length" ) ) )
1055 if (
properties.contains( QStringLiteral(
"average_angle_unit" ) ) )
1059 if (
properties.contains( ( QStringLiteral(
"average_angle_map_unit_scale" ) ) ) )
1064 if (
properties.contains( QStringLiteral(
"placement" ) ) )
1066 if (
properties[QStringLiteral(
"placement" )] == QLatin1String(
"vertex" ) )
1068 else if (
properties[QStringLiteral(
"placement" )] == QLatin1String(
"lastvertex" ) )
1070 else if (
properties[QStringLiteral(
"placement" )] == QLatin1String(
"firstvertex" ) )
1072 else if (
properties[QStringLiteral(
"placement" )] == QLatin1String(
"centralpoint" ) )
1074 else if (
properties[QStringLiteral(
"placement" )] == QLatin1String(
"curvepoint" ) )
1076 else if (
properties[QStringLiteral(
"placement" )] == QLatin1String(
"segmentcenter" ) )
1082 if (
properties.contains( QStringLiteral(
"ring_filter" ) ) )
1090 void QgsTemplatedLineSymbolLayerBase::renderPolylineInterval(
const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageOver )
1092 if ( points.isEmpty() )
1095 double lengthLeft = 0;
1127 if ( painterUnitInterval < 0 )
1138 lengthLeft = painterUnitInterval - painterUnitOffsetAlongLine;
1140 if ( averageOver > 0 && !
qgsDoubleNear( averageOver, 0.0 ) )
1142 QVector< QPointF > angleStartPoints;
1143 QVector< QPointF > symbolPoints;
1144 QVector< QPointF > angleEndPoints;
1152 collectOffsetPoints( points, symbolPoints, painterUnitInterval, lengthLeft );
1154 if ( symbolPoints.empty() )
1160 if ( symbolPoints.count() > 1 && symbolPoints.constFirst() == symbolPoints.constLast() )
1163 symbolPoints.pop_back();
1166 angleEndPoints.reserve( symbolPoints.size() );
1167 angleStartPoints.reserve( symbolPoints.size() );
1168 if ( averageOver <= painterUnitOffsetAlongLine )
1170 collectOffsetPoints( points, angleStartPoints, painterUnitInterval, lengthLeft + averageOver, 0, symbolPoints.size() );
1174 collectOffsetPoints( points, angleStartPoints, painterUnitInterval, 0, averageOver - painterUnitOffsetAlongLine, symbolPoints.size() );
1176 collectOffsetPoints( points, angleEndPoints, painterUnitInterval, lengthLeft - averageOver, 0, symbolPoints.size() );
1179 for (
int i = 0; i < symbolPoints.size(); ++ i )
1184 const QPointF pt = symbolPoints[i];
1185 const QPointF startPt = angleStartPoints[i];
1186 const QPointF endPt = angleEndPoints[i];
1188 MyLine l( startPt, endPt );
1203 QPointF lastPt = points[0];
1204 for (
int i = 1; i < points.count(); ++i )
1209 const QPointF &pt = points[i];
1215 MyLine l( lastPt, pt );
1216 QPointF diff = l.diffForInterval( painterUnitInterval );
1220 double c = 1 - lengthLeft / painterUnitInterval;
1222 lengthLeft += l.length();
1231 while ( lengthLeft > painterUnitInterval )
1235 lengthLeft -= painterUnitInterval;
1247 static double _averageAngle( QPointF prevPt, QPointF pt, QPointF nextPt )
1250 double a1 = MyLine( prevPt, pt ).angle();
1251 double a2 = MyLine( pt, nextPt ).angle();
1252 double unitX = std::cos( a1 ) + std::cos( a2 ), unitY = std::sin( a1 ) + std::sin( a2 );
1254 return std::atan2( unitY, unitX );
1259 if ( points.isEmpty() )
1265 int i = -1, maxCount = 0;
1266 bool isRing =
false;
1339 i = points.count() - 1;
1340 maxCount = points.count();
1348 maxCount = points.count();
1349 if ( points.first() == points.last() )
1366 renderOffsetVertexAlongLine( points, i, distance, context );
1376 prevPoint = points.at( 0 );
1378 QPointF symbolPoint;
1379 for ( ; i < maxCount; ++i )
1390 QPointF currentPoint = points.at( i );
1391 symbolPoint = QPointF( 0.5 * ( currentPoint.x() + prevPoint.x() ),
1392 0.5 * ( currentPoint.y() + prevPoint.y() ) );
1395 double angle = std::atan2( currentPoint.y() - prevPoint.y(),
1396 currentPoint.x() - prevPoint.x() );
1399 prevPoint = currentPoint;
1403 symbolPoint = points.at( i );
1407 double angle = markerAngle( points, isRing, i );
1419 double QgsTemplatedLineSymbolLayerBase::markerAngle(
const QPolygonF &points,
bool isRing,
int vertex )
1422 const QPointF &pt = points[vertex];
1424 if ( isRing || ( vertex > 0 && vertex < points.count() - 1 ) )
1426 int prevIndex = vertex - 1;
1427 int nextIndex = vertex + 1;
1429 if ( isRing && ( vertex == 0 || vertex == points.count() - 1 ) )
1431 prevIndex = points.count() - 2;
1435 QPointF prevPoint, nextPoint;
1436 while ( prevIndex >= 0 )
1438 prevPoint = points[ prevIndex ];
1439 if ( prevPoint != pt )
1446 while ( nextIndex < points.count() )
1448 nextPoint = points[ nextIndex ];
1449 if ( nextPoint != pt )
1456 if ( prevIndex >= 0 && nextIndex < points.count() )
1458 angle = _averageAngle( prevPoint, pt, nextPoint );
1465 while ( vertex < points.size() - 1 )
1467 const QPointF &nextPt = points[vertex + 1];
1470 angle = MyLine( pt, nextPt ).angle();
1479 while ( vertex >= 1 )
1481 const QPointF &prevPt = points[vertex - 1];
1484 angle = MyLine( prevPt, pt ).angle();
1494 void QgsTemplatedLineSymbolLayerBase::renderOffsetVertexAlongLine(
const QPolygonF &points,
int vertex,
double distance,
QgsSymbolRenderContext &context )
1496 if ( points.isEmpty() )
1506 bool isRing =
false;
1507 if ( points.first() == points.last() )
1509 double angle = markerAngle( points, isRing, vertex );
1516 int pointIncrement = distance > 0 ? 1 : -1;
1517 QPointF previousPoint = points[vertex];
1518 int startPoint = distance > 0 ? std::min( vertex + 1, points.count() - 1 ) : std::max( vertex - 1, 0 );
1519 int endPoint = distance > 0 ? points.count() - 1 : 0;
1520 double distanceLeft = std::fabs( distance );
1522 for (
int i = startPoint; pointIncrement > 0 ? i <= endPoint : i >= endPoint; i += pointIncrement )
1524 const QPointF &pt = points[i];
1526 if ( previousPoint == pt )
1530 MyLine l( previousPoint, pt );
1532 if ( distanceLeft < l.length() )
1535 QPointF markerPoint = previousPoint + l.diffForInterval( distanceLeft );
1545 distanceLeft -= l.length();
1552 void QgsTemplatedLineSymbolLayerBase::collectOffsetPoints(
const QVector<QPointF> &p, QVector<QPointF> &dest,
double intervalPainterUnits,
double initialOffset,
double initialLag,
int numberPointsRequired )
1557 QVector< QPointF > points = p;
1558 const bool closedRing = points.first() == points.last();
1560 double lengthLeft = initialOffset;
1562 double initialLagLeft = initialLag > 0 ? -initialLag : 1;
1563 if ( initialLagLeft < 0 && closedRing )
1566 QPointF lastPt = points.constLast();
1567 QVector< QPointF > pseudoPoints;
1568 for (
int i = points.count() - 2; i > 0; --i )
1570 if ( initialLagLeft >= 0 )
1575 const QPointF &pt = points[i];
1580 MyLine l( lastPt, pt );
1581 initialLagLeft += l.length();
1586 std::reverse( pseudoPoints.begin(), pseudoPoints.end() );
1588 points = pseudoPoints;
1593 while ( initialLagLeft < 0 )
1595 dest << points.constFirst();
1596 initialLagLeft += intervalPainterUnits;
1599 if ( initialLag > 0 )
1601 lengthLeft += intervalPainterUnits - initialLagLeft;
1604 QPointF lastPt = points[0];
1605 for (
int i = 1; i < points.count(); ++i )
1607 const QPointF &pt = points[i];
1611 if ( closedRing && i == points.count() - 1 && numberPointsRequired > 0 && dest.size() < numberPointsRequired )
1620 MyLine l( lastPt, pt );
1621 QPointF diff = l.diffForInterval( intervalPainterUnits );
1625 double c = 1 - lengthLeft / intervalPainterUnits;
1627 lengthLeft += l.length();
1630 while ( lengthLeft > intervalPainterUnits ||
qgsDoubleNear( lengthLeft, intervalPainterUnits, 0.000000001 ) )
1634 lengthLeft -= intervalPainterUnits;
1637 if ( numberPointsRequired > 0 && dest.size() >= numberPointsRequired )
1642 if ( numberPointsRequired > 0 && dest.size() >= numberPointsRequired )
1646 if ( closedRing && i == points.count() - 1 && numberPointsRequired > 0 && dest.size() < numberPointsRequired )
1653 if ( !closedRing && numberPointsRequired > 0 && dest.size() < numberPointsRequired )
1656 while ( dest.size() < numberPointsRequired )
1657 dest << points.constLast();
1661 void QgsTemplatedLineSymbolLayerBase::renderPolylineCentral(
const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver )
1663 if ( !points.isEmpty() )
1667 QPolygonF::const_iterator it = points.constBegin();
1669 for ( ++it; it != points.constEnd(); ++it )
1671 length += std::sqrt( ( last.x() - it->x() ) * ( last.x() - it->x() ) +
1672 ( last.y() - it->y() ) * ( last.y() - it->y() ) );
1678 const double midPoint = length / 2;
1681 double thisSymbolAngle = 0;
1683 if ( averageAngleOver > 0 && !
qgsDoubleNear( averageAngleOver, 0.0 ) )
1685 QVector< QPointF > angleStartPoints;
1686 QVector< QPointF > symbolPoints;
1687 QVector< QPointF > angleEndPoints;
1689 collectOffsetPoints( points, symbolPoints, midPoint, midPoint, 0.0, 2 );
1690 collectOffsetPoints( points, angleStartPoints, midPoint, 0, averageAngleOver, 2 );
1691 collectOffsetPoints( points, angleEndPoints, midPoint, midPoint - averageAngleOver, 0, 2 );
1693 pt = symbolPoints.at( 1 );
1694 MyLine l( angleStartPoints.at( 1 ), angleEndPoints.at( 1 ) );
1695 thisSymbolAngle = l.angle();
1700 it = points.constBegin();
1702 qreal last_at = 0, next_at = 0;
1705 for ( ++it; it != points.constEnd(); ++it )
1708 next_at += std::sqrt( ( last.x() - it->x() ) * ( last.x() - it->x() ) +
1709 ( last.y() - it->y() ) * ( last.y() - it->y() ) );
1710 if ( next_at >= midPoint )
1718 MyLine l( last, next );
1719 qreal k = ( length * 0.5 - last_at ) / ( next_at - last_at );
1720 pt = last + ( next - last ) * k;
1721 thisSymbolAngle = l.angle();
1769 if ( props.contains( QStringLiteral(
"interval" ) ) )
1770 interval = props[QStringLiteral(
"interval" )].toDouble();
1771 if ( props.contains( QStringLiteral(
"rotate" ) ) )
1772 rotate = ( props[QStringLiteral(
"rotate" )] == QLatin1String(
"1" ) );
1774 std::unique_ptr< QgsMarkerLineSymbolLayer > x = qgis::make_unique< QgsMarkerLineSymbolLayer >( rotate,
interval );
1781 return QStringLiteral(
"MarkerLine" );
1800 QgsSymbol::RenderHints hints =
nullptr;
1803 mMarker->setRenderHints( hints );
1816 std::unique_ptr< QgsMarkerLineSymbolLayer > x = qgis::make_unique< QgsMarkerLineSymbolLayer >(
rotateSymbols(),
interval() );
1823 for (
int i = 0; i <
mMarker->symbolLayerCount(); i++ )
1825 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:LineSymbolizer" ) );
1826 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
1827 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
1828 element.appendChild( symbolizerElem );
1863 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
1864 symbolizerElem.appendChild( strokeElem );
1867 QDomElement graphicStrokeElem = doc.createElement( QStringLiteral(
"se:GraphicStroke" ) );
1868 strokeElem.appendChild( graphicStrokeElem );
1874 graphicStrokeElem.appendChild( doc.createComment( QStringLiteral(
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() ) ) );
1881 if ( !gap.isEmpty() )
1883 QDomElement gapElem = doc.createElement( QStringLiteral(
"se:Gap" ) );
1885 graphicStrokeElem.appendChild( gapElem );
1890 QDomElement perpOffsetElem = doc.createElement( QStringLiteral(
"se:PerpendicularOffset" ) );
1893 symbolizerElem.appendChild( perpOffsetElem );
1902 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
1903 if ( strokeElem.isNull() )
1906 QDomElement graphicStrokeElem = strokeElem.firstChildElement( QStringLiteral(
"GraphicStroke" ) );
1907 if ( graphicStrokeElem.isNull() )
1915 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
1917 if ( it.key() == QLatin1String(
"placement" ) )
1919 if ( it.value() == QLatin1String(
"points" ) )
1921 else if ( it.value() == QLatin1String(
"firstPoint" ) )
1923 else if ( it.value() == QLatin1String(
"lastPoint" ) )
1925 else if ( it.value() == QLatin1String(
"centralPoint" ) )
1928 else if ( it.value() == QLatin1String(
"rotateMarker" ) )
1934 std::unique_ptr< QgsMarkerSymbol > marker;
1948 QDomElement gapElem = graphicStrokeElem.firstChildElement( QStringLiteral(
"Gap" ) );
1949 if ( !gapElem.isNull() )
1952 double d = gapElem.firstChild().nodeValue().toDouble( &ok );
1958 QDomElement perpOffsetElem = graphicStrokeElem.firstChildElement( QStringLiteral(
"PerpendicularOffset" ) );
1959 if ( !perpOffsetElem.isNull() )
1962 double d = perpOffsetElem.firstChild().nodeValue().toDouble( &ok );
1967 QString uom = element.attribute( QStringLiteral(
"uom" ) );
1989 mMarker->setDataDefinedSize( property );
2011 mMarker->renderPoint( point, feature, context, layer, selected );
2021 return mMarker->size( context );
2027 mMarker->setOutputUnit( unit );
2038 attr.unite(
mMarker->usedAttributes( context ) );
2053 return (
mMarker->size( context ) / 2.0 ) +
2073 if ( props.contains( QStringLiteral(
"interval" ) ) )
2074 interval = props[QStringLiteral(
"interval" )].toDouble();
2075 if ( props.contains( QStringLiteral(
"rotate" ) ) )
2076 rotate = ( props[QStringLiteral(
"rotate" )] == QLatin1String(
"1" ) );
2078 std::unique_ptr< QgsHashedLineSymbolLayer > x = qgis::make_unique< QgsHashedLineSymbolLayer >( rotate,
interval );
2080 if ( props.contains( QStringLiteral(
"hash_angle" ) ) )
2082 x->setHashAngle( props[QStringLiteral(
"hash_angle" )].toDouble() );
2085 if ( props.contains( QStringLiteral(
"hash_length" ) ) )
2086 x->setHashLength( props[QStringLiteral(
"hash_length" )].toDouble() );
2088 if ( props.contains( QStringLiteral(
"hash_length_unit" ) ) )
2091 if ( props.contains( QStringLiteral(
"hash_length_map_unit_scale" ) ) )
2099 return QStringLiteral(
"HashLine" );
2104 mHashSymbol->setOpacity( context.
opacity() );
2107 QgsSymbol::RenderHints hints =
nullptr;
2110 mHashSymbol->setRenderHints( hints );
2123 map[ QStringLiteral(
"hash_angle" ) ] = QString::number( mHashAngle );
2125 map[QStringLiteral(
"hash_length" )] = QString::number( mHashLength );
2134 std::unique_ptr< QgsHashedLineSymbolLayer > x = qgis::make_unique< QgsHashedLineSymbolLayer >(
rotateSymbols(),
interval() );
2136 x->setHashAngle( mHashAngle );
2137 x->setHashLength( mHashLength );
2138 x->setHashLengthUnit( mHashLengthUnit );
2139 x->setHashLengthMapUnitScale( mHashLengthMapUnitScale );
2145 mHashSymbol->setColor(
color );
2151 return mHashSymbol ? mHashSymbol->color() :
mColor;
2156 return mHashSymbol.get();
2167 mHashSymbol.reset(
static_cast<QgsLineSymbol *
>( symbol ) );
2168 mColor = mHashSymbol->color();
2174 mHashLength =
width;
2189 return ( mHashSymbol->width( context ) / 2.0 )
2197 mHashSymbol->setOutputUnit( unit );
2207 attr.unite( mHashSymbol->usedAttributes( context ) );
2215 if ( mHashSymbol && mHashSymbol->hasDataDefinedProperties() )
2224 mHashSymbol->setDataDefinedWidth( property );
2231 mSymbolLineAngle =
angle;
2236 return mSymbolAngle;
2241 mSymbolAngle =
angle;
2246 double lineLength = mHashLength;
2252 const double w = context.
convertToPainterUnits( lineLength, mHashLengthUnit, mHashLengthMapUnitScale ) / 2.0;
2266 points << QPointF( start.
x(), start.
y() ) << QPointF( end.
x(), end.
y() );
2268 mHashSymbol->renderPolyline( points, feature, context, layer, selected );
QString layerType() const override
Returns a string that represents this layer type.
QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const override
Gets dash pattern.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
double width() const override
Returns the estimated width for the line symbol layer.
QgsMarkerLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setSymbolLineAngle(double angle) override
Sets the line angle modification for the symbol's angle.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsMarkerLineSymbolLayer from an SLD XML DOM element.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
void copyTemplateSymbolProperties(QgsTemplatedLineSymbolLayerBase *destLayer) const
Copies all common properties of this layer to another templated symbol layer.
void setWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line's width.
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)
QgsMapUnitScale mapUnitScale() const FINAL
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the symbol placement.
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings.
@ PropertyLineDistance
Distance between lines, or length of lines for hash line symbols.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
A store for object properties.
RenderUnit
Rendering size units.
QgsExpressionContext & expressionContext()
Gets the expression context.
@ AntialiasingSimplification
The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
double mapUnitsPerPixel() const
Returns current map units per pixel.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
@ PropertyAverageAngleLength
Length to average symbol angles over.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setRingFilter(QgsLineSymbolLayer::RenderRingFilter filter)
Sets the line symbol layer's ring filter, which controls which rings are rendered when the line symbo...
void setColor(const QColor &color) override
The fill color.
virtual double width() const
Returns the estimated width for the line symbol layer.
QgsPointXY project(double distance, double bearing) const
Returns a new point which corresponds to this point projected by a specified distance in a specified ...
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Point geometry type, with support for z-dimension and m-values.
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
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.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSimpleLineSymbolLayer, using the settings serialized in the properties map (correspo...
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
#define DEFAULT_MARKERLINE_ROTATE
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for lengths used in the custom dash pattern.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsMarkerLineSymbolLayer, using the settings serialized in the properties map (correspo...
QString layerType() const override
Returns a string that represents this layer type.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QgsWkbTypes::GeometryType geometryType)
calculate geometry shifted by a specified distance
Curve polygon geometry type.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
virtual QColor color() const
The fill color.
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mWidthMapUnitScale
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
#define DEFAULT_MARKERLINE_INTERVAL
RenderRingFilter mRingFilter
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
qreal opacity() const
Returns the opacity for the symbol.
static QString encodePenCapStyle(Qt::PenCapStyle style)
QgsHashedLineSymbolLayer(bool rotateSymbol=true, double interval=3)
Constructor for QgsHashedLineSymbolLayer.
virtual void renderSymbol(const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer=-1, bool selected=false)=0
Renders the templated symbol at the specified point, using the given render context.
static QgsSymbolLayer * createMarkerLayerFromSld(QDomElement &element)
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void setWidth(double width) override
Sets the width of the line symbol layer.
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line's offset.
@ Vertex
Place symbols on every vertex in the line.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
double hashAngle() const
Returns the angle to use when drawing the hashed lines sections, in degrees clockwise.
@ RenderMillimeters
Millimeters.
Abstract base class for marker symbol layers.
@ PropertyInterval
Line marker interval.
Placement placement() const
Returns the placement of the symbols.
@ PropertyCapStyle
Line cap style.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static QString encodePenStyle(Qt::PenStyle style)
void setUseCustomDashPattern(bool b)
Sets whether the line uses a custom dash pattern.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSimpleLineSymbolLayer from an SLD XML DOM element.
@ CurvePoint
Place symbols at every virtual curve point in the line (used when rendering curved geometry types onl...
@ PropertyStrokeColor
Stroke color.
static QString encodeRealVector(const QVector< qreal > &v)
static QColor decodeColor(const QString &str)
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
QgsMapUnitScale mapUnitScale() const override
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setOffset(double offset)
Sets the line's offset.
void setPlacement(Placement placement)
Sets the placement of the symbols.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Placement
Defines how/where the templated symbol should be placed on the line.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setSymbolAngle(double angle) override
Sets the symbol's angle, in degrees clockwise.
QgsMarkerLineSymbolLayer(bool rotateMarker=DEFAULT_MARKERLINE_ROTATE, double interval=DEFAULT_MARKERLINE_INTERVAL)
Constructor for QgsMarkerLineSymbolLayer.
#define DEFAULT_SIMPLELINE_COLOR
void setCustomDashVector(const QVector< qreal > &vector)
Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ren...
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the interval between symbols.
Qt::PenStyle penStyle() const
Returns the pen style used to render the line (e.g.
void setInterval(double interval)
Sets the interval between individual symbols.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
QgsWkbTypes::GeometryType originalGeometryType() const
Returns the geometry type for the original feature geometry being rendered.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsMapUnitScale mapUnitScale() const override
QgsUnitTypes::RenderUnit mOffsetUnit
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
void setSymbolLineAngle(double angle) override
Sets the line angle modification for the symbol's angle.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
QgsSimpleLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
@ PropertyOffset
Symbol offset.
void setDataDefinedProperty(QgsSymbolLayer::Property key, const QgsProperty &property) override
Sets a data defined property for the layer.
double symbolAngle() const override
Returns the symbol's current angle, in degrees clockwise.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
@ SegmentCenter
Place symbols at the center of every line segment.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
void setOffsetAlongLineUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QgsFields fields() const
Fields of the layer.
QColor dxfColor(QgsSymbolRenderContext &context) const override
Gets color.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void setHashAngle(double angle)
Sets the angle to use when drawing the hashed lines sections, in degrees clockwise.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's offset.
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
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,...
static void setCommonProperties(QgsTemplatedLineSymbolLayerBase *destLayer, const QgsStringMap &properties)
Sets all common symbol properties in the destLayer, using the settings serialized in the properties m...
QgsUnitTypes::RenderUnit mWidthUnit
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
double interval() const
Returns the interval between individual symbols.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
double offsetAlongLine() const
Returns the offset along the line for the symbol placement.
virtual void setSymbolAngle(double angle)=0
Sets the symbol's angle, in degrees clockwise.
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
QColor color() const override
The fill color.
void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context) FINAL
Renders the line symbol layer along the line joining points, using the given render context.
#define DEFAULT_SIMPLELINE_WIDTH
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for symbols.
@ Interval
Place symbols at regular intervals.
double symbolAngle() const override
Returns the symbol's current angle, in degrees clockwise.
float threshold() const
Gets the simplification threshold of the vector layer managed.
void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context) override
Renders the line symbol layer along the line joining points, using the given render context.
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
#define DEFAULT_SIMPLELINE_PENSTYLE
void setSymbolAngle(double angle) override
Sets the symbol's angle, in degrees clockwise.
Struct for storing maximum and minimum scales for measurements in map units.
void renderSymbol(const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer=-1, bool selected=false) override
Renders the templated symbol at the specified point, using the given render context.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
QgsUnitTypes::RenderUnit outputUnit() const FINAL
Returns the units to use for sizes and widths within the symbol layer.
QgsHashedLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void setWidth(double width) override
Sets the width of the line symbol layer.
QgsPropertyCollection mDataDefinedProperties
@ PropertyStrokeWidth
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 ...
void renderPolygonStroke(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the line symbol layer along the outline of polygon, using the given render context.
static QString ogrFeatureStylePen(double width, double mmScaleFactor, double mapUnitsScaleFactor, const QColor &c, Qt::PenJoinStyle joinStyle=Qt::MiterJoin, Qt::PenCapStyle capStyle=Qt::FlatCap, double offset=0.0, const QVector< qreal > *dashPattern=nullptr)
Create ogr feature style string for pen.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for symbols.
Single scope for storing variables and functions for use within a QgsExpressionContext....
@ InteriorRingsOnly
Render the interior rings only.
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
void setMapUnitScale(const QgsMapUnitScale &scale) FINAL
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void setColor(const QColor &color) override
The fill color.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual symbo...
@ PropertyOffsetAlongLine
Offset along line.
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
double width() const override
Returns the estimated width for the line symbol layer.
void setDataDefinedProperty(QgsSymbolLayer::Property key, const QgsProperty &property) override
Sets a data defined property for the layer.
QColor selectionColor() const
Returns the color to use when rendering selected features.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void transformInPlace(double &x, double &y) const
Transform device coordinates to map coordinates.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
QMap< QString, QString > QgsStringMap
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
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
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void renderPolygonStroke(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) FINAL
Renders the line symbol layer along the outline of polygon, using the given render context.
static QgsStringMap getVendorOptionList(QDomElement &element)
QList< QgsSymbolLayer * > QgsSymbolLayerList
QgsMapUnitScale mOffsetMapUnitScale
@ LastVertex
Place symbols on the last vertex in the line.
Utility class for identifying a unique vertex within a geometry.
@ PropertyCustomDash
Custom dash pattern.
virtual void setSymbolLineAngle(double angle)=0
Sets the line angle modification for the symbol's angle.
bool rotateSymbols() const
Returns true if the repeating symbols be rotated to match their line segment orientation.
QString layerType() const override
Returns a string that represents this layer type.
@ RenderMetersInMapUnits
Meters value as Map units.
double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets offset.
@ RenderUnknownUnit
Mixed or unknown units.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
@ AllRings
Render both exterior and interior rings.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsHashedLineSymbolLayer, using the settings serialized in the properties map (correspo...
SymbolType type() const
Returns the symbol's type.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
void renderSymbol(const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer=-1, bool selected=false) override
Renders the templated symbol at the specified point, using the given render context.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
Property
Data definable properties.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
virtual QString layerType() const =0
Returns a string that represents this layer type.
@ RenderSymbolPreview
The render is for a symbol preview only and map based properties may not be available,...
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
std::unique_ptr< QgsMarkerSymbol > mMarker
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
double symbologyScale() const
Returns the reference scale for output.
static QVector< qreal > decodeRealVector(const QString &s)
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
double offset() const
Returns the line's offset.
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
@ FirstVertex
Place symbols on the first vertex in the line.
static bool lineFromSld(QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=nullptr, Qt::PenCapStyle *penCapStyle=nullptr, QVector< qreal > *customDashPattern=nullptr, double *dashOffset=nullptr)
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line's width.
@ ExteriorRingOnly
Render the exterior ring only.
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
QPainter * painter()
Returns the destination QPainter for the render operation.
void setGeometry(const QgsAbstractGeometry *geometry)
Sets pointer to original (unsegmentized) geometry.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Single variable definition for use within a QgsExpressionContextScope.
QgsTemplatedLineSymbolLayerBase(bool rotateSymbol=true, double interval=3)
Constructor for QgsTemplatedLineSymbolLayerBase.
static Qt::PenStyle decodePenStyle(const QString &str)
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
QgsSimpleLineSymbolLayer(const QColor &color=DEFAULT_SIMPLELINE_COLOR, double width=DEFAULT_SIMPLELINE_WIDTH, Qt::PenStyle penStyle=DEFAULT_SIMPLELINE_PENSTYLE)
Constructor for QgsSimpleLineSymbolLayer.
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)
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
virtual double symbolAngle() const =0
Returns the symbol's current angle, in degrees clockwise.
@ PropertyPlacement
Line marker placement.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
@ PropertyLineAngle
Line angle, or angle of hash lines for hash line symbols.
@ RenderMapUnits
Map units.
@ CentralPoint
Place symbols at the mid point of the line.
void setAverageAngleUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
Q_DECL_DEPRECATED bool rotateMarker() const
Shall the marker be rotated.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
static bool isGeneralizableByDeviceBoundingBox(const QgsRectangle &envelope, float mapToPixelTol=1.0f)
Returns whether the device-envelope can be replaced by its BBOX when is applied the specified toleran...
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.
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.
@ PropertyJoinStyle
Line join style.
static bool createExpressionElement(QDomDocument &doc, QDomElement &element, const QString &function)
Creates a OGC Expression element based on the provided function expression.
Flags flags() const
Returns combination of flags used for rendering.
void setIntervalUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the interval between symbols.
@ PropertyWidth
Symbol width.