Port shape items to layouts

This commit is contained in:
Nyall Dawson 2017-07-17 17:11:44 +10:00
parent 38cbbe23aa
commit b4f5025d4f
12 changed files with 651 additions and 1 deletions

View File

@ -383,6 +383,7 @@
%Include layout/qgslayoutitem.sip
%Include layout/qgslayoutitemmap.sip
%Include layout/qgslayoutitemregistry.sip
%Include layout/qgslayoutitemshape.sip
%Include layout/qgslayoutobject.sip
%Include symbology-ng/qgscptcityarchive.sip
%Include symbology-ng/qgssvgcache.sip

View File

@ -101,6 +101,9 @@ class QgsLayoutItemRegistry : QObject
// known
LayoutPage,
LayoutRectangle,
LayoutEllipse,
LayoutTriangle,
// item
PluginItem,

View File

@ -0,0 +1,156 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitemshape.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsLayoutItemShape : QgsLayoutItem
{
%Docstring
Base class for layout items which are basic shapes (e.g. rectangles, ellipses).
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutitemshape.h"
%End
public:
void setSymbol( QgsFillSymbol *symbol );
%Docstring
Sets the fill ``symbol`` used to draw the shape. Ownership is not transferred
and a clone of the symbol is made.
.. seealso:: symbol()
%End
QgsFillSymbol *symbol();
%Docstring
Returns the fill symbol used to draw the shape.
.. seealso:: setSymbol()
:rtype: QgsFillSymbol
%End
protected:
explicit QgsLayoutItemShape( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutItemShape, with the specified parent ``layout``.
%End
};
class QgsLayoutItemRectangularShape : QgsLayoutItemShape
{
%Docstring
A rectangular shape item for layouts.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutitemshape.h"
%End
public:
explicit QgsLayoutItemRectangularShape( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutItemRectangularShape, with the specified parent ``layout``.
%End
virtual int type() const;
static QgsLayoutItemRectangularShape *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
%Docstring
:rtype: QgsLayoutItemRectangularShape
%End
void setCornerRadius( QgsLayoutMeasurement radius );
%Docstring
Sets the corner ``radius`` for rounded rectangle corners.
.. seealso:: cornerRadius()
%End
QgsLayoutMeasurement cornerRadius() const;
%Docstring
Returns the corner radius for rounded rectangle corners.
.. seealso:: setCornerRadius()
:rtype: QgsLayoutMeasurement
%End
protected:
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
};
class QgsLayoutItemEllipseShape : QgsLayoutItemShape
{
%Docstring
A ellipse shape item for layouts.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutitemshape.h"
%End
public:
explicit QgsLayoutItemEllipseShape( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutItemEllipseShape, with the specified parent ``layout``.
%End
virtual int type() const;
static QgsLayoutItemEllipseShape *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
%Docstring
:rtype: QgsLayoutItemEllipseShape
%End
protected:
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
};
class QgsLayoutItemTriangleShape : QgsLayoutItemShape
{
%Docstring
A triangle shape item for layouts.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutitemshape.h"
%End
public:
explicit QgsLayoutItemTriangleShape( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutItemTriangleShape, with the specified parent ``layout``.
%End
virtual int type() const;
static QgsLayoutItemTriangleShape *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
%Docstring
:rtype: QgsLayoutItemTriangleShape
%End
protected:
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitemshape.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -179,6 +179,36 @@ class QgsLayoutViewEllipticalRubberBand : QgsLayoutViewRubberBand
virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = 0 );
};
class QgsLayoutViewTriangleRubberBand : QgsLayoutViewRubberBand
{
%Docstring
QgsLayoutViewTriangleRubberBand is triangular rubber band for use within QgsLayoutView widgets.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutviewrubberband.h"
%End
public:
QgsLayoutViewTriangleRubberBand( QgsLayoutView *view = 0 );
%Docstring
Constructor for QgsLayoutViewTriangleRubberBand.
%End
virtual QgsLayoutViewTriangleRubberBand *create( QgsLayoutView *view ) const /Factory/;
~QgsLayoutViewTriangleRubberBand();
virtual void start( QPointF position, Qt::KeyboardModifiers modifiers );
virtual void update( QPointF position, Qt::KeyboardModifiers modifiers );
virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = 0 );
};
/************************************************************************
* This file has been generated automatically from *

View File

@ -354,6 +354,7 @@ SET(QGIS_CORE_SRCS
layout/qgslayoutitem.cpp
layout/qgslayoutitemmap.cpp
layout/qgslayoutitemregistry.cpp
layout/qgslayoutitemshape.cpp
layout/qgslayoutmeasurement.cpp
layout/qgslayoutmeasurementconverter.cpp
layout/qgslayoutobject.cpp
@ -677,6 +678,7 @@ SET(QGIS_CORE_MOC_HDRS
layout/qgslayoutitem.h
layout/qgslayoutitemmap.h
layout/qgslayoutitemregistry.h
layout/qgslayoutitemshape.h
layout/qgslayoutobject.h
symbology-ng/qgscptcityarchive.h

View File

@ -15,6 +15,7 @@
***************************************************************************/
#include "qgslayoutitemregistry.h"
#include "qgslayoutitemshape.h"
#include "qgsgloweffect.h"
#include "qgseffectstack.h"
#include <QPainter>
@ -41,6 +42,10 @@ bool QgsLayoutItemRegistry::populate()
};
addLayoutItemType( new QgsLayoutItemMetadata( 101, QStringLiteral( "temp type" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLabel.svg" ) ), createTemporaryItem ) );
addLayoutItemType( new QgsLayoutItemMetadata( LayoutRectangle, QStringLiteral( "Rectangle" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), QgsLayoutItemRectangularShape::create ) );
addLayoutItemType( new QgsLayoutItemMetadata( LayoutEllipse, QStringLiteral( "Ellipse" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicCircle.svg" ) ), QgsLayoutItemEllipseShape::create ) );
addLayoutItemType( new QgsLayoutItemMetadata( LayoutTriangle, QStringLiteral( "Triangle" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicTriangle.svg" ) ), QgsLayoutItemTriangleShape::create ) );
return true;
}

View File

@ -183,6 +183,9 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
// known item types
LayoutPage, //!< Page items
LayoutRectangle, //!< Rectangular shape item
LayoutEllipse, //!< Ellipse shape item
LayoutTriangle, //!< Triangle shape item
// item types provided by plugins
PluginItem, //!< Starting point for plugin item types

View File

@ -0,0 +1,173 @@
/***************************************************************************
qgslayoutitemshape.cpp
-----------------------
begin : July 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslayoutitemshape.h"
#include "qgslayout.h"
#include "qgslayoututils.h"
#include <QPainter>
QgsLayoutItemShape::QgsLayoutItemShape( QgsLayout *layout )
: QgsLayoutItem( layout )
{
QgsStringMap properties;
properties.insert( QStringLiteral( "color" ), QStringLiteral( "white" ) );
properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "solid" ) );
properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "black" ) );
properties.insert( QStringLiteral( "width_border" ), QStringLiteral( "0.3" ) );
properties.insert( QStringLiteral( "joinstyle" ), QStringLiteral( "miter" ) );
mShapeStyleSymbol.reset( QgsFillSymbol::createSimple( properties ) );
}
void QgsLayoutItemShape::setSymbol( QgsFillSymbol *symbol )
{
if ( !symbol )
return;
mShapeStyleSymbol.reset( symbol->clone() );
}
//
// QgsLayoutItemRectangularShape
//
QgsLayoutItemRectangularShape::QgsLayoutItemRectangularShape( QgsLayout *layout )
: QgsLayoutItemShape( layout )
, mCornerRadius( 0.0 )
{
}
QgsLayoutItemRectangularShape *QgsLayoutItemRectangularShape::create( QgsLayout *layout, const QVariantMap &settings )
{
Q_UNUSED( settings );
return new QgsLayoutItemRectangularShape( layout );
}
void QgsLayoutItemRectangularShape::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
{
QPainter *painter = context.painter();
painter->setPen( Qt::NoPen );
painter->setBrush( Qt::NoBrush );
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
QPolygonF shapePolygon;
if ( mCornerRadius.length() > 0 )
{
//shapes with curves must be enlarged before conversion to QPolygonF, or
//the curves are approximated too much and appear jaggy
QTransform t = QTransform::fromScale( 100, 100 );
//inverse transform used to scale created polygons back to expected size
QTransform ti = t.inverted();
QPainterPath roundedRectPath;
double radius = mLayout->convertToLayoutUnits( mCornerRadius ) * scale;
roundedRectPath.addRoundedRect( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ), radius, radius );
QPolygonF roundedPoly = roundedRectPath.toFillPolygon( t );
shapePolygon = ti.map( roundedPoly );
}
else
{
shapePolygon = QPolygonF( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) );
}
QList<QPolygonF> rings; //empty list
symbol()->startRender( context );
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context );
symbol()->stopRender( context );
}
//
// QgsLayoutItemEllipseShape
//
QgsLayoutItemEllipseShape::QgsLayoutItemEllipseShape( QgsLayout *layout )
: QgsLayoutItemShape( layout )
{
}
QgsLayoutItemEllipseShape *QgsLayoutItemEllipseShape::create( QgsLayout *layout, const QVariantMap &settings )
{
Q_UNUSED( settings );
return new QgsLayoutItemEllipseShape( layout );
}
void QgsLayoutItemEllipseShape::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
{
QPainter *painter = context.painter();
painter->setPen( Qt::NoPen );
painter->setBrush( Qt::NoBrush );
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
//shapes with curves must be enlarged before conversion to QPolygonF, or
//the curves are approximated too much and appear jaggy
QTransform t = QTransform::fromScale( 100, 100 );
//inverse transform used to scale created polygons back to expected size
QTransform ti = t.inverted();
//create an ellipse
QPainterPath ellipsePath;
ellipsePath.addEllipse( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) );
QPolygonF ellipsePoly = ellipsePath.toFillPolygon( t );
QPolygonF shapePolygon = ti.map( ellipsePoly );
QList<QPolygonF> rings; //empty list
symbol()->startRender( context );
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context );
symbol()->stopRender( context );
}
//
// QgsLayoutItemTriangleShape
//
QgsLayoutItemTriangleShape::QgsLayoutItemTriangleShape( QgsLayout *layout )
: QgsLayoutItemShape( layout )
{
}
QgsLayoutItemTriangleShape *QgsLayoutItemTriangleShape::create( QgsLayout *layout, const QVariantMap &settings )
{
Q_UNUSED( settings );
return new QgsLayoutItemTriangleShape( layout );
}
void QgsLayoutItemTriangleShape::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
{
QPainter *painter = context.painter();
painter->setPen( Qt::NoPen );
painter->setBrush( Qt::NoBrush );
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
QPolygonF shapePolygon = QPolygonF() << QPointF( 0, rect().height() * scale )
<< QPointF( rect().width() * scale, rect().height() * scale )
<< QPointF( rect().width() / 2.0 * scale, 0 )
<< QPointF( 0, rect().height() * scale );
QList<QPolygonF> rings; //empty list
symbol()->startRender( context );
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context );
symbol()->stopRender( context );
}

View File

@ -0,0 +1,158 @@
/***************************************************************************
qgslayoutitemshape.h
---------------------
begin : July 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYOUTITEMSHAPE_H
#define QGSLAYOUTITEMSHAPE_H
#include "qgis_core.h"
#include "qgslayoutitem.h"
#include "qgslayoutitemregistry.h"
#include "qgssymbol.h"
#include "qgslayoutmeasurement.h"
/**
* \ingroup core
* \class QgsLayoutItemShape
* \brief Base class for layout items which are basic shapes (e.g. rectangles, ellipses).
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayoutItemShape : public QgsLayoutItem
{
Q_OBJECT
public:
/**
* Sets the fill \a symbol used to draw the shape. Ownership is not transferred
* and a clone of the symbol is made.
* \see symbol()
*/
void setSymbol( QgsFillSymbol *symbol );
/**
* Returns the fill symbol used to draw the shape.
* \see setSymbol()
*/
QgsFillSymbol *symbol() { return mShapeStyleSymbol.get(); }
protected:
/**
* Constructor for QgsLayoutItemShape, with the specified parent \a layout.
*/
explicit QgsLayoutItemShape( QgsLayout *layout );
private:
std::unique_ptr< QgsFillSymbol > mShapeStyleSymbol;
};
/**
* \ingroup core
* \class QgsLayoutItemRectangularShape
* \brief A rectangular shape item for layouts.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayoutItemRectangularShape : public QgsLayoutItemShape
{
Q_OBJECT
public:
/**
* Constructor for QgsLayoutItemRectangularShape, with the specified parent \a layout.
*/
explicit QgsLayoutItemRectangularShape( QgsLayout *layout );
virtual int type() const override { return QgsLayoutItemRegistry::LayoutRectangle; }
static QgsLayoutItemRectangularShape *create( QgsLayout *layout, const QVariantMap &settings ) SIP_FACTORY;
/**
* Sets the corner \a radius for rounded rectangle corners.
* \see cornerRadius()
*/
void setCornerRadius( QgsLayoutMeasurement radius ) { mCornerRadius = radius; }
/**
* Returns the corner radius for rounded rectangle corners.
* \see setCornerRadius()
*/
QgsLayoutMeasurement cornerRadius() const { return mCornerRadius; }
protected:
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
private:
QgsLayoutMeasurement mCornerRadius;
};
/**
* \ingroup core
* \class QgsLayoutItemEllipseShape
* \brief A ellipse shape item for layouts.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayoutItemEllipseShape : public QgsLayoutItemShape
{
Q_OBJECT
public:
/**
* Constructor for QgsLayoutItemEllipseShape, with the specified parent \a layout.
*/
explicit QgsLayoutItemEllipseShape( QgsLayout *layout );
virtual int type() const override { return QgsLayoutItemRegistry::LayoutEllipse; }
static QgsLayoutItemEllipseShape *create( QgsLayout *layout, const QVariantMap &settings ) SIP_FACTORY;
protected:
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
};
/**
* \ingroup core
* \class QgsLayoutItemTriangleShape
* \brief A triangle shape item for layouts.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayoutItemTriangleShape : public QgsLayoutItemShape
{
Q_OBJECT
public:
/**
* Constructor for QgsLayoutItemTriangleShape, with the specified parent \a layout.
*/
explicit QgsLayoutItemTriangleShape( QgsLayout *layout );
virtual int type() const override { return QgsLayoutItemRegistry::LayoutTriangle; }
static QgsLayoutItemTriangleShape *create( QgsLayout *layout, const QVariantMap &settings ) SIP_FACTORY;
protected:
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
};
#endif //QGSLAYOUTITEMSHAPE_H

View File

@ -16,6 +16,7 @@
#include "qgslayoutitemguiregistry.h"
#include "qgslayoutviewrubberband.h"
#include "qgslayoutitemregistry.h"
#include <QPainter>
@ -40,13 +41,23 @@ bool QgsLayoutItemGuiRegistry::populate()
if ( !mMetadata.isEmpty() )
return false;
// add temporary item to register
auto createRubberBand = ( []( QgsLayoutView * view )->QgsLayoutViewRubberBand *
{
return new QgsLayoutViewRectangularRubberBand( view );
} );
auto createEllipseBand = ( []( QgsLayoutView * view )->QgsLayoutViewRubberBand *
{
return new QgsLayoutViewEllipticalRubberBand( view );
} );
auto createTriangleBand = ( []( QgsLayoutView * view )->QgsLayoutViewRubberBand *
{
return new QgsLayoutViewTriangleRubberBand( view );
} );
addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( 101, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLabel.svg" ) ), nullptr, createRubberBand ) );
addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutRectangle, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), nullptr, createRubberBand ) );
addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutEllipse, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicCircle.svg" ) ), nullptr, createEllipseBand ) );
addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutTriangle, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicTriangle.svg" ) ), nullptr, createTriangleBand ) );
return true;
}

View File

@ -19,6 +19,7 @@
#include "qgslayoutview.h"
#include <QGraphicsRectItem>
#include <QGraphicsEllipseItem>
#include <QGraphicsPolygonItem>
QgsLayoutViewRubberBand::QgsLayoutViewRubberBand( QgsLayoutView *view )
: mView( view )
@ -248,3 +249,78 @@ QRectF QgsLayoutViewEllipticalRubberBand::finish( QPointF position, Qt::Keyboard
}
return updateRect( mRubberBandStartPos, position, constrainSquare, fromCenter );
}
//
// QgsLayoutViewTriangleRubberBand
//
QgsLayoutViewTriangleRubberBand::QgsLayoutViewTriangleRubberBand( QgsLayoutView *view )
: QgsLayoutViewRubberBand( view )
{
}
QgsLayoutViewTriangleRubberBand *QgsLayoutViewTriangleRubberBand::create( QgsLayoutView *view ) const
{
return new QgsLayoutViewTriangleRubberBand( view );
}
QgsLayoutViewTriangleRubberBand::~QgsLayoutViewTriangleRubberBand()
{
if ( mRubberBandItem )
{
layout()->removeItem( mRubberBandItem );
delete mRubberBandItem;
}
}
void QgsLayoutViewTriangleRubberBand::start( QPointF position, Qt::KeyboardModifiers )
{
QTransform t;
mRubberBandItem = new QGraphicsPolygonItem();
mRubberBandItem->setBrush( brush() );
mRubberBandItem->setPen( pen() );
mRubberBandStartPos = position;
t.translate( position.x(), position.y() );
mRubberBandItem->setTransform( t );
mRubberBandItem->setZValue( QgsLayout::ZMapTool );
layout()->addItem( mRubberBandItem );
layout()->update();
}
void QgsLayoutViewTriangleRubberBand::update( QPointF position, Qt::KeyboardModifiers modifiers )
{
if ( !mRubberBandItem )
{
return;
}
bool constrainSquare = modifiers & Qt::ShiftModifier;
bool fromCenter = modifiers & Qt::AltModifier;
QRectF newRect = updateRect( mRubberBandStartPos, position, constrainSquare, fromCenter );
QPolygonF shapePolygon = QPolygonF() << QPointF( 0, newRect.height() )
<< QPointF( newRect.width(), newRect.height() )
<< QPointF( newRect.width() / 2.0, 0 )
<< QPointF( 0, newRect.height() );
mRubberBandItem->setPolygon( shapePolygon );
QTransform t;
t.translate( newRect.x(), newRect.y() );
mRubberBandItem->setTransform( t );
}
QRectF QgsLayoutViewTriangleRubberBand::finish( QPointF position, Qt::KeyboardModifiers modifiers )
{
bool constrainSquare = modifiers & Qt::ShiftModifier;
bool fromCenter = modifiers & Qt::AltModifier;
if ( mRubberBandItem )
{
layout()->removeItem( mRubberBandItem );
delete mRubberBandItem;
mRubberBandItem = nullptr;
}
return updateRect( mRubberBandStartPos, position, constrainSquare, fromCenter );
}

View File

@ -26,6 +26,7 @@
class QgsLayoutView;
class QGraphicsRectItem;
class QGraphicsEllipseItem;
class QGraphicsPolygonItem;
class QgsLayout;
/**
@ -199,5 +200,36 @@ class GUI_EXPORT QgsLayoutViewEllipticalRubberBand : public QgsLayoutViewRubberB
//! Start of rubber band creation
QPointF mRubberBandStartPos;
};
/**
* \ingroup gui
* QgsLayoutViewTriangleRubberBand is triangular rubber band for use within QgsLayoutView widgets.
* \since QGIS 3.0
*/
class GUI_EXPORT QgsLayoutViewTriangleRubberBand : public QgsLayoutViewRubberBand
{
public:
/**
* Constructor for QgsLayoutViewTriangleRubberBand.
*/
QgsLayoutViewTriangleRubberBand( QgsLayoutView *view = nullptr );
QgsLayoutViewTriangleRubberBand *create( QgsLayoutView *view ) const override SIP_FACTORY;
~QgsLayoutViewTriangleRubberBand();
void start( QPointF position, Qt::KeyboardModifiers modifiers ) override;
void update( QPointF position, Qt::KeyboardModifiers modifiers ) override;
QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = 0 ) override;
private:
//! Rubber band item
QGraphicsPolygonItem *mRubberBandItem = nullptr;
//! Start of rubber band creation
QPointF mRubberBandStartPos;
};
#endif // QGSLAYOUTVIEWRUBBERBAND_H