diff --git a/src/app/qgspointmarkeritem.cpp b/src/app/qgspointmarkeritem.cpp index f11ef9d1730..4739478fab6 100644 --- a/src/app/qgspointmarkeritem.cpp +++ b/src/app/qgspointmarkeritem.cpp @@ -166,12 +166,19 @@ QgsMapCanvasLineSymbolItem::QgsMapCanvasLineSymbolItem( QgsMapCanvas *canvas ) setSymbol( qgis::make_unique< QgsLineSymbol >() ); } -void QgsMapCanvasLineSymbolItem::setLine( const QLineF &line ) +void QgsMapCanvasLineSymbolItem::setLine( const QPolygonF &line ) { mLine = line; update(); } +void QgsMapCanvasLineSymbolItem::setLine( const QLineF &line ) +{ + mLine.clear(); + mLine << line.p1() << line.p2(); + update(); +} + QRectF QgsMapCanvasLineSymbolItem::boundingRect() const { return mMapCanvas->rect(); @@ -179,9 +186,7 @@ QRectF QgsMapCanvasLineSymbolItem::boundingRect() const void QgsMapCanvasLineSymbolItem::renderSymbol( QgsRenderContext &context, const QgsFeature &feature ) { - QPolygonF points; - points << mLine.p1() << mLine.p2(); - lineSymbol()->renderPolyline( points, &feature, context ); + lineSymbol()->renderPolyline( mLine, &feature, context ); } QgsLineSymbol *QgsMapCanvasLineSymbolItem::lineSymbol() diff --git a/src/app/qgspointmarkeritem.h b/src/app/qgspointmarkeritem.h index bec7abf333d..351f3bffd54 100644 --- a/src/app/qgspointmarkeritem.h +++ b/src/app/qgspointmarkeritem.h @@ -140,6 +140,11 @@ class APP_EXPORT QgsMapCanvasLineSymbolItem: public QgsMapCanvasSymbolItem QgsMapCanvasLineSymbolItem( QgsMapCanvas *canvas = nullptr ); + /** + * Sets the line to draw (in map coordinates) + */ + void setLine( const QPolygonF &line ); + /** * Sets the line to draw (in map coordinates) */ @@ -151,7 +156,7 @@ class APP_EXPORT QgsMapCanvasLineSymbolItem: public QgsMapCanvasSymbolItem private: - QLineF mLine; + QPolygonF mLine; QgsLineSymbol *lineSymbol(); };