Skip to content

Commit

Permalink
Port shape items to layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 18, 2017
1 parent 38cbbe2 commit b4f5025
Show file tree
Hide file tree
Showing 12 changed files with 651 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -383,6 +383,7 @@
%Include layout/qgslayoutitem.sip %Include layout/qgslayoutitem.sip
%Include layout/qgslayoutitemmap.sip %Include layout/qgslayoutitemmap.sip
%Include layout/qgslayoutitemregistry.sip %Include layout/qgslayoutitemregistry.sip
%Include layout/qgslayoutitemshape.sip
%Include layout/qgslayoutobject.sip %Include layout/qgslayoutobject.sip
%Include symbology-ng/qgscptcityarchive.sip %Include symbology-ng/qgscptcityarchive.sip
%Include symbology-ng/qgssvgcache.sip %Include symbology-ng/qgssvgcache.sip
Expand Down
3 changes: 3 additions & 0 deletions python/core/layout/qgslayoutitemregistry.sip
Expand Up @@ -101,6 +101,9 @@ class QgsLayoutItemRegistry : QObject


// known // known
LayoutPage, LayoutPage,
LayoutRectangle,
LayoutEllipse,
LayoutTriangle,


// item // item
PluginItem, PluginItem,
Expand Down
156 changes: 156 additions & 0 deletions python/core/layout/qgslayoutitemshape.sip
@@ -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 *
************************************************************************/
30 changes: 30 additions & 0 deletions python/gui/layout/qgslayoutviewrubberband.sip
Expand Up @@ -179,6 +179,36 @@ class QgsLayoutViewEllipticalRubberBand : QgsLayoutViewRubberBand
virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = 0 ); 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 * * This file has been generated automatically from *
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -354,6 +354,7 @@ SET(QGIS_CORE_SRCS
layout/qgslayoutitem.cpp layout/qgslayoutitem.cpp
layout/qgslayoutitemmap.cpp layout/qgslayoutitemmap.cpp
layout/qgslayoutitemregistry.cpp layout/qgslayoutitemregistry.cpp
layout/qgslayoutitemshape.cpp
layout/qgslayoutmeasurement.cpp layout/qgslayoutmeasurement.cpp
layout/qgslayoutmeasurementconverter.cpp layout/qgslayoutmeasurementconverter.cpp
layout/qgslayoutobject.cpp layout/qgslayoutobject.cpp
Expand Down Expand Up @@ -677,6 +678,7 @@ SET(QGIS_CORE_MOC_HDRS
layout/qgslayoutitem.h layout/qgslayoutitem.h
layout/qgslayoutitemmap.h layout/qgslayoutitemmap.h
layout/qgslayoutitemregistry.h layout/qgslayoutitemregistry.h
layout/qgslayoutitemshape.h
layout/qgslayoutobject.h layout/qgslayoutobject.h


symbology-ng/qgscptcityarchive.h symbology-ng/qgscptcityarchive.h
Expand Down
5 changes: 5 additions & 0 deletions src/core/layout/qgslayoutitemregistry.cpp
Expand Up @@ -15,6 +15,7 @@
***************************************************************************/ ***************************************************************************/


#include "qgslayoutitemregistry.h" #include "qgslayoutitemregistry.h"
#include "qgslayoutitemshape.h"
#include "qgsgloweffect.h" #include "qgsgloweffect.h"
#include "qgseffectstack.h" #include "qgseffectstack.h"
#include <QPainter> #include <QPainter>
Expand All @@ -41,6 +42,10 @@ bool QgsLayoutItemRegistry::populate()
}; };


addLayoutItemType( new QgsLayoutItemMetadata( 101, QStringLiteral( "temp type" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLabel.svg" ) ), createTemporaryItem ) ); 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; return true;
} }


Expand Down
3 changes: 3 additions & 0 deletions src/core/layout/qgslayoutitemregistry.h
Expand Up @@ -183,6 +183,9 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject


// known item types // known item types
LayoutPage, //!< Page items LayoutPage, //!< Page items
LayoutRectangle, //!< Rectangular shape item
LayoutEllipse, //!< Ellipse shape item
LayoutTriangle, //!< Triangle shape item


// item types provided by plugins // item types provided by plugins
PluginItem, //!< Starting point for plugin item types PluginItem, //!< Starting point for plugin item types
Expand Down

0 comments on commit b4f5025

Please sign in to comment.