Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add picture annotation item type #58126

Merged
merged 9 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,13 +2187,20 @@
Qgis.Axis.baseClass = Qgis
# monkey patching scoped based enum
Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__ = "Item's bounding box will vary depending on map scale"
Qgis.AnnotationItemFlag.__doc__ = "Flags for annotation items.\n\n.. versionadded:: 3.22\n\n" + '* ``ScaleDependentBoundingBox``: ' + Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__
Qgis.AnnotationItemFlag.SupportsReferenceScale.__doc__ = "Item supports reference scale based rendering (since QGIS 3.40)"
Qgis.AnnotationItemFlag.__doc__ = "Flags for annotation items.\n\n.. versionadded:: 3.22\n\n" + '* ``ScaleDependentBoundingBox``: ' + Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__ + '\n' + '* ``SupportsReferenceScale``: ' + Qgis.AnnotationItemFlag.SupportsReferenceScale.__doc__
# --
Qgis.AnnotationItemFlags = lambda flags=0: Qgis.AnnotationItemFlag(flags)
Qgis.AnnotationItemFlag.baseClass = Qgis
Qgis.AnnotationItemFlags.baseClass = Qgis
AnnotationItemFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
# monkey patching scoped based enum
Qgis.AnnotationPictureSizeMode.SpatialBounds.__doc__ = "Picture is rendered inside spatial bounds, and size will depend on map scale"
Qgis.AnnotationPictureSizeMode.FixedSize.__doc__ = "Picture is rendered at a fixed size, regardless of map scale"
Qgis.AnnotationPictureSizeMode.__doc__ = "Picture annotation item size modes.\n\n.. versionadded:: 3.40\n\n" + '* ``SpatialBounds``: ' + Qgis.AnnotationPictureSizeMode.SpatialBounds.__doc__ + '\n' + '* ``FixedSize``: ' + Qgis.AnnotationPictureSizeMode.FixedSize.__doc__
# --
Qgis.AnnotationPictureSizeMode.baseClass = Qgis
# monkey patching scoped based enum
Qgis.AnnotationItemGuiFlag.FlagNoCreationTools.__doc__ = "Do not show item creation tools for the item type"
Qgis.AnnotationItemGuiFlag.__doc__ = "Flags for controlling how an annotation item behaves in the GUI.\n\n.. versionadded:: 3.22\n\n" + '* ``FlagNoCreationTools``: ' + Qgis.AnnotationItemGuiFlag.FlagNoCreationTools.__doc__
# --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Abstract base class for annotation items which are drawn with :py:class:`QgsAnno
{
sipType = sipType_QgsAnnotationLineTextItem;
}
else if ( sipCpp->type() == QLatin1String( "picture" ) )
{
sipType = sipType_QgsAnnotationPictureItem;
}
else
{
sipType = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Constructor for QgsAnnotationLineItem, with the specified ``curve``.

virtual QgsAnnotationItemEditOperationTransientResults *transientEditResultsV2( QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context ) /Factory/;

virtual Qgis::AnnotationItemFlags flags() const;


static QgsAnnotationLineItem *create() /Factory/;
%Docstring
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/annotations/qgsannotationpictureitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsAnnotationPictureItem : QgsAnnotationItem
{
%Docstring(signature="appended")
An annotation item which renders a picture.

.. versionadded:: 3.40
%End

%TypeHeaderCode
#include "qgsannotationpictureitem.h"
%End
public:

QgsAnnotationPictureItem( Qgis::PictureFormat format, const QString &path, const QgsRectangle &bounds );
%Docstring
Constructor for QgsAnnotationPictureItem, rendering the specified image ``path``
within the specified ``bounds`` geometry.
%End
~QgsAnnotationPictureItem();

virtual QString type() const;

virtual Qgis::AnnotationItemFlags flags() const;

virtual void render( QgsRenderContext &context, QgsFeedback *feedback );

virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;

virtual QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const;

virtual Qgis::AnnotationItemEditOperationResult applyEditV2( QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context );

virtual QgsAnnotationItemEditOperationTransientResults *transientEditResultsV2( QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context ) /Factory/;


static QgsAnnotationPictureItem *create() /Factory/;
%Docstring
Creates a new polygon annotation item.
%End

virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context );

virtual QgsAnnotationPictureItem *clone() const /Factory/;

virtual QgsRectangle boundingBox() const;

virtual QgsRectangle boundingBox( QgsRenderContext &context ) const;


QgsRectangle bounds() const;
%Docstring
Returns the bounds of the picture.

The coordinate reference system for the bounds will be the parent layer's :py:func:`QgsAnnotationLayer.crs()`.

When the :py:func:`~QgsAnnotationPictureItem.sizeMode` is :py:class:`Qgis`.AnnotationPictureSizeMode.FixedSize then the picture will be placed
at the center of the bounds.

.. seealso:: :py:func:`setBounds`
%End

void setBounds( const QgsRectangle &bounds );
%Docstring
Sets the ``bounds`` of the picture.

The coordinate reference system for the bounds will be the parent layer's :py:func:`QgsAnnotationLayer.crs()`.

When the :py:func:`~QgsAnnotationPictureItem.sizeMode` is :py:class:`Qgis`.AnnotationPictureSizeMode.FixedSize then the picture will be placed
at the center of the bounds.

.. seealso:: :py:func:`bounds`
%End

QString path() const;
%Docstring
Returns the path of the image used to render the item.

.. seealso:: :py:func:`setPath`
%End

Qgis::PictureFormat format() const;
%Docstring
Returns the picture format.
%End

void setPath( Qgis::PictureFormat format, const QString &path );
%Docstring
Sets the ``format`` and ``path`` of the image used to render the item.

.. seealso:: :py:func:`path`

.. seealso:: :py:func:`format`
%End

Qgis::AnnotationPictureSizeMode sizeMode() const;
%Docstring
Returns the size mode for the picture.

.. seealso:: :py:func:`setSizeMode`
%End

void setSizeMode( Qgis::AnnotationPictureSizeMode mode );
%Docstring
Sets the size ``mode`` for the picture.

.. seealso:: :py:func:`sizeMode`
%End

QSizeF fixedSize() const;
%Docstring
Returns the fixed size to use for the picture, when the :py:func:`~QgsAnnotationPictureItem.sizeMode` is :py:class:`Qgis`.AnnotationPictureSizeMode.FixedSize.

Units are retrieved via :py:func:`~QgsAnnotationPictureItem.fixedSizeUnit`

.. seealso:: :py:func:`setFixedSize`

.. seealso:: :py:func:`fixedSizeUnit`
%End

void setFixedSize( const QSizeF &size );
%Docstring
Sets the fixed ``size`` to use for the picture, when the :py:func:`~QgsAnnotationPictureItem.sizeMode` is :py:class:`Qgis`.AnnotationPictureSizeMode.FixedSize.

Units are set via :py:func:`~QgsAnnotationPictureItem.setFixedSizeUnit`

.. seealso:: :py:func:`fixedSize`

.. seealso:: :py:func:`setFixedSizeUnit`
%End

Qgis::RenderUnit fixedSizeUnit() const;
%Docstring
Returns the units to use for fixed picture sizes, when the :py:func:`~QgsAnnotationPictureItem.sizeMode` is :py:class:`Qgis`.AnnotationPictureSizeMode.FixedSize.

.. seealso:: :py:func:`setFixedSizeUnit`

.. seealso:: :py:func:`fixedSize`
%End

void setFixedSizeUnit( Qgis::RenderUnit unit );
%Docstring
Sets the ``unit`` to use for fixed picture sizes, when the :py:func:`~QgsAnnotationPictureItem.sizeMode` is :py:class:`Qgis`.AnnotationPictureSizeMode.FixedSize.

.. seealso:: :py:func:`fixedSizeUnit`

.. seealso:: :py:func:`setFixedSize`
%End

bool lockAspectRatio() const;
%Docstring
Returns ``True`` if the aspect ratio of the picture will be retained.

.. seealso:: :py:func:`setLockAspectRatio`
%End

void setLockAspectRatio( bool locked );
%Docstring
Sets whether the aspect ratio of the picture will be retained.

.. seealso:: :py:func:`lockAspectRatio`
%End

bool backgroundEnabled() const;
%Docstring
Returns ``True`` if the item's background should be rendered.

.. seealso:: :py:func:`setBackgroundEnabled`

.. seealso:: :py:func:`backgroundSymbol`
%End

void setBackgroundEnabled( bool enabled );
%Docstring
Sets whether the item's background should be rendered.

.. seealso:: :py:func:`backgroundEnabled`

.. seealso:: :py:func:`setBackgroundSymbol`
%End

const QgsFillSymbol *backgroundSymbol() const;
%Docstring
Returns the symbol used to render the item's background.

.. seealso:: :py:func:`backgroundEnabled`

.. seealso:: :py:func:`setBackgroundSymbol`
%End

void setBackgroundSymbol( QgsFillSymbol *symbol /Transfer/ );
%Docstring
Sets the ``symbol`` used to render the item's background.

The item takes ownership of the symbol.

.. seealso:: :py:func:`backgroundSymbol`

.. seealso:: :py:func:`setBackgroundEnabled`
%End

bool frameEnabled() const;
%Docstring
Returns ``True`` if the item's frame should be rendered.

.. seealso:: :py:func:`setFrameEnabled`

.. seealso:: :py:func:`frameSymbol`
%End

void setFrameEnabled( bool enabled );
%Docstring
Sets whether the item's frame should be rendered.

.. seealso:: :py:func:`frameEnabled`

.. seealso:: :py:func:`setFrameSymbol`
%End

const QgsFillSymbol *frameSymbol() const;
%Docstring
Returns the symbol used to render the item's frame.

.. seealso:: :py:func:`frameEnabled`

.. seealso:: :py:func:`setFrameSymbol`
%End

void setFrameSymbol( QgsFillSymbol *symbol /Transfer/ );
%Docstring
Sets the ``symbol`` used to render the item's frame.

The item takes ownership of the symbol.

.. seealso:: :py:func:`frameSymbol`

.. seealso:: :py:func:`setBackgroundEnabled`
%End

private:
QgsAnnotationPictureItem( const QgsAnnotationPictureItem &other );
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/annotations/qgsannotationpictureitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Constructor for QgsAnnotationPolygonItem, with the specified ``polygon`` geometr

virtual QgsAnnotationItemEditOperationTransientResults *transientEditResultsV2( QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context ) /Factory/;

virtual Qgis::AnnotationItemFlags flags() const;


static QgsAnnotationPolygonItem *create() /Factory/;
%Docstring
Expand Down
8 changes: 8 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,17 @@ The development version
enum class AnnotationItemFlag /BaseType=IntFlag/
{
ScaleDependentBoundingBox,
SupportsReferenceScale,
};
typedef QFlags<Qgis::AnnotationItemFlag> AnnotationItemFlags;


enum class AnnotationPictureSizeMode /BaseType=IntEnum/
{
SpatialBounds,
FixedSize,
};

enum class AnnotationItemGuiFlag /BaseType=IntFlag/
{
FlagNoCreationTools,
Expand Down Expand Up @@ -2607,6 +2614,7 @@ The development version
Unknown,
};


enum class ScaleBarAlignment /BaseType=IntEnum/
{
Left,
Expand Down
1 change: 1 addition & 0 deletions python/PyQt6/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
%Include auto_generated/annotations/qgsannotationlinetextitem.sip
%Include auto_generated/annotations/qgsannotationmarkeritem.sip
%Include auto_generated/annotations/qgsannotationmanager.sip
%Include auto_generated/annotations/qgsannotationpictureitem.sip
%Include auto_generated/annotations/qgsannotationpointtextitem.sip
%Include auto_generated/annotations/qgsannotationpolygonitem.sip
%Include auto_generated/annotations/qgshtmlannotation.sip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ whenever this signal is emitted.
%End
public:


virtual ~QgsCreateAnnotationItemMapToolInterface();

virtual QgsCreateAnnotationItemMapToolHandler *handler() = 0;
Expand Down
9 changes: 8 additions & 1 deletion python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,12 +2147,19 @@
Qgis.Axis.baseClass = Qgis
# monkey patching scoped based enum
Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__ = "Item's bounding box will vary depending on map scale"
Qgis.AnnotationItemFlag.__doc__ = "Flags for annotation items.\n\n.. versionadded:: 3.22\n\n" + '* ``ScaleDependentBoundingBox``: ' + Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__
Qgis.AnnotationItemFlag.SupportsReferenceScale.__doc__ = "Item supports reference scale based rendering (since QGIS 3.40)"
Qgis.AnnotationItemFlag.__doc__ = "Flags for annotation items.\n\n.. versionadded:: 3.22\n\n" + '* ``ScaleDependentBoundingBox``: ' + Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__ + '\n' + '* ``SupportsReferenceScale``: ' + Qgis.AnnotationItemFlag.SupportsReferenceScale.__doc__
# --
Qgis.AnnotationItemFlag.baseClass = Qgis
Qgis.AnnotationItemFlags.baseClass = Qgis
AnnotationItemFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
# monkey patching scoped based enum
Qgis.AnnotationPictureSizeMode.SpatialBounds.__doc__ = "Picture is rendered inside spatial bounds, and size will depend on map scale"
Qgis.AnnotationPictureSizeMode.FixedSize.__doc__ = "Picture is rendered at a fixed size, regardless of map scale"
Qgis.AnnotationPictureSizeMode.__doc__ = "Picture annotation item size modes.\n\n.. versionadded:: 3.40\n\n" + '* ``SpatialBounds``: ' + Qgis.AnnotationPictureSizeMode.SpatialBounds.__doc__ + '\n' + '* ``FixedSize``: ' + Qgis.AnnotationPictureSizeMode.FixedSize.__doc__
# --
Qgis.AnnotationPictureSizeMode.baseClass = Qgis
# monkey patching scoped based enum
Qgis.AnnotationItemGuiFlag.FlagNoCreationTools.__doc__ = "Do not show item creation tools for the item type"
Qgis.AnnotationItemGuiFlag.__doc__ = "Flags for controlling how an annotation item behaves in the GUI.\n\n.. versionadded:: 3.22\n\n" + '* ``FlagNoCreationTools``: ' + Qgis.AnnotationItemGuiFlag.FlagNoCreationTools.__doc__
# --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Abstract base class for annotation items which are drawn with :py:class:`QgsAnno
{
sipType = sipType_QgsAnnotationLineTextItem;
}
else if ( sipCpp->type() == QLatin1String( "picture" ) )
{
sipType = sipType_QgsAnnotationPictureItem;
}
else
{
sipType = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Constructor for QgsAnnotationLineItem, with the specified ``curve``.

virtual QgsAnnotationItemEditOperationTransientResults *transientEditResultsV2( QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context ) /Factory/;

virtual Qgis::AnnotationItemFlags flags() const;


static QgsAnnotationLineItem *create() /Factory/;
%Docstring
Expand Down
Loading
Loading