Skip to content
Permalink
Browse files

QgsMapCanvasLineSymbolItem can render linestrings

  • Loading branch information
nyalldawson committed Sep 15, 2020
1 parent 2521493 commit 76cf6029a22afe29faa7fa5f473ea287ed6b729a
Showing with 15 additions and 5 deletions.
  1. +9 −4 src/app/qgspointmarkeritem.cpp
  2. +6 −1 src/app/qgspointmarkeritem.h
@@ -166,22 +166,27 @@ 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();
}

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()
@@ -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();
};

0 comments on commit 76cf602

Please sign in to comment.
You can’t perform that action at this time.