Skip to content
Permalink
Browse files

[layouts] Use polyline shape instead of bounding box for selection, m…

…akes polylines selectable via single click

Fixes #20940

(cherry picked from commit 1cdff21)
  • Loading branch information
jdugge authored and nyalldawson committed Jan 28, 2019
1 parent a9466cd commit 33660cedea4fe7cbf5049e5b34a262500f5fed52
@@ -53,6 +53,8 @@ The caller takes responsibility for deleting the returned object.

virtual QString displayName() const;

virtual QPainterPath shape() const;


QgsLineSymbol *symbol();
%Docstring
@@ -25,6 +25,7 @@
#include "qgssvgcache.h"
#include <QSvgRenderer>
#include <limits>
#include <QGraphicsPathItem>

QgsLayoutItemPolyline::QgsLayoutItemPolyline( QgsLayout *layout )
: QgsLayoutNodesItem( layout )
@@ -312,6 +313,19 @@ void QgsLayoutItemPolyline::setArrowHeadWidth( double width )
update();
}

QPainterPath QgsLayoutItemPolyline::shape() const
{
QPainterPath path;
path.addPolygon( mPolygon );

QPainterPathStroker ps;

ps.setWidth( 2 * mMaxSymbolBleed );
QPainterPath strokedOutline = ps.createStroke( path );

return strokedOutline;
}

void QgsLayoutItemPolyline::setStartSvgMarkerPath( const QString &path )
{
QSvgRenderer r;
@@ -20,6 +20,9 @@
#include "qgis_core.h"
#include "qgslayoutitemnodeitem.h"
#include "qgssymbol.h"
#include <QGraphicsPathItem>
#include "qgslogger.h"
#include "qgslayout.h"

/**
* \ingroup core
@@ -61,6 +64,7 @@ class CORE_EXPORT QgsLayoutItemPolyline: public QgsLayoutNodesItem
int type() const override;
QIcon icon() const override;
QString displayName() const override;
QPainterPath shape() const override;

/**
* Returns the line symbol used to draw the shape.

0 comments on commit 33660ce

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