mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-02 00:02:12 -05:00
QgsMapCanvasLineSymbolItem can render linestrings
This commit is contained in:
parent
252149375c
commit
76cf6029a2
@ -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()
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user