Skip to content

Commit

Permalink
QgsMapCanvasLineSymbolItem can render linestrings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 15, 2020
1 parent 2521493 commit 76cf602
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/app/qgspointmarkeritem.cpp
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgspointmarkeritem.h
Expand Up @@ -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)
*/
Expand All @@ -151,7 +156,7 @@ class APP_EXPORT QgsMapCanvasLineSymbolItem: public QgsMapCanvasSymbolItem

private:

QLineF mLine;
QPolygonF mLine;

QgsLineSymbol *lineSymbol();
};
Expand Down

0 comments on commit 76cf602

Please sign in to comment.