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

Auto upgrade SVG and text annotations to annotation layer items on project load #58405

Merged
merged 15 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
5 changes: 4 additions & 1 deletion python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3738,7 +3738,10 @@
QgsProject.ForceReadOnlyLayers = Qgis.ProjectReadFlag.ForceReadOnlyLayers
QgsProject.ForceReadOnlyLayers.is_monkey_patched = True
QgsProject.ForceReadOnlyLayers.__doc__ = "Open layers in a read-only mode. (since QGIS 3.28)"
Qgis.ProjectReadFlag.__doc__ = "Flags which control project read behavior.\n\n.. note::\n\n Prior to QGIS 3.26 this was available as :py:class:`QgsProject`.ReadFlag\n\n.. versionadded:: 3.26\n\n" + '* ``FlagDontResolveLayers``: ' + Qgis.ProjectReadFlag.DontResolveLayers.__doc__ + '\n' + '* ``FlagDontLoadLayouts``: ' + Qgis.ProjectReadFlag.DontLoadLayouts.__doc__ + '\n' + '* ``FlagTrustLayerMetadata``: ' + Qgis.ProjectReadFlag.TrustLayerMetadata.__doc__ + '\n' + '* ``FlagDontStoreOriginalStyles``: ' + Qgis.ProjectReadFlag.DontStoreOriginalStyles.__doc__ + '\n' + '* ``FlagDontLoad3DViews``: ' + Qgis.ProjectReadFlag.DontLoad3DViews.__doc__ + '\n' + '* ``DontLoadProjectStyles``: ' + Qgis.ProjectReadFlag.DontLoadProjectStyles.__doc__ + '\n' + '* ``ForceReadOnlyLayers``: ' + Qgis.ProjectReadFlag.ForceReadOnlyLayers.__doc__
QgsProject.DontUpgradeAnnotations = Qgis.ProjectReadFlag.DontUpgradeAnnotations
QgsProject.DontUpgradeAnnotations.is_monkey_patched = True
QgsProject.DontUpgradeAnnotations.__doc__ = "Don't upgrade old annotation items to QgsAnnotationItem (since QGIS 3.40)"
Qgis.ProjectReadFlag.__doc__ = "Flags which control project read behavior.\n\n.. note::\n\n Prior to QGIS 3.26 this was available as :py:class:`QgsProject`.ReadFlag\n\n.. versionadded:: 3.26\n\n" + '* ``FlagDontResolveLayers``: ' + Qgis.ProjectReadFlag.DontResolveLayers.__doc__ + '\n' + '* ``FlagDontLoadLayouts``: ' + Qgis.ProjectReadFlag.DontLoadLayouts.__doc__ + '\n' + '* ``FlagTrustLayerMetadata``: ' + Qgis.ProjectReadFlag.TrustLayerMetadata.__doc__ + '\n' + '* ``FlagDontStoreOriginalStyles``: ' + Qgis.ProjectReadFlag.DontStoreOriginalStyles.__doc__ + '\n' + '* ``FlagDontLoad3DViews``: ' + Qgis.ProjectReadFlag.DontLoad3DViews.__doc__ + '\n' + '* ``DontLoadProjectStyles``: ' + Qgis.ProjectReadFlag.DontLoadProjectStyles.__doc__ + '\n' + '* ``ForceReadOnlyLayers``: ' + Qgis.ProjectReadFlag.ForceReadOnlyLayers.__doc__ + '\n' + '* ``DontUpgradeAnnotations``: ' + Qgis.ProjectReadFlag.DontUpgradeAnnotations.__doc__
# --
Qgis.ProjectReadFlag.baseClass = Qgis
Qgis.ProjectReadFlags = lambda flags=0: Qgis.ProjectReadFlag(flags)
Expand Down
5 changes: 5 additions & 0 deletions python/PyQt6/core/auto_additions/qgsannotationrectitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The following has been generated automatically from src/core/annotations/qgsannotationrectitem.h
try:
QgsAnnotationRectItem.__group__ = ['annotations']
except NameError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,14 @@ Sets the ``unit`` for the :py:func:`~QgsAnnotationItem.offsetFromCallout`.

protected:

void copyCommonProperties( const QgsAnnotationItem *other );
virtual void copyCommonProperties( const QgsAnnotationItem *other );
%Docstring
Copies common properties from the base class from an ``other`` item.

.. versionadded:: 3.22
%End

bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
virtual bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
Writes common properties from the base class into an XML ``element``.

Expand All @@ -396,7 +396,7 @@ Writes common properties from the base class into an XML ``element``.
.. versionadded:: 3.22
%End

bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
virtual bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
%Docstring
Reads common properties from the base class from the given DOM ``element``.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Contains information about a node used for editing an annotation item.

QgsAnnotationItemNode();

QgsAnnotationItemNode( const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type );
QgsAnnotationItemNode( const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type, Qt::CursorShape cursor = Qt::CursorShape::ArrowCursor );
%Docstring
Constructor for QgsAnnotationItemNode, with the specified ``id``, ``point`` and ``type``.
%End
Expand Down Expand Up @@ -73,6 +73,24 @@ Returns the node type.
Sets the node type.

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

Qt::CursorShape cursor() const;
%Docstring
Returns the mouse cursor shape to use when hovering the node.

.. seealso:: :py:func:`setCursor`

.. versionadded:: 3.34
%End

void setCursor( Qt::CursorShape shape );
%Docstring
Sets the mouse cursor ``shape`` to use when hovering the node.

.. seealso:: :py:func:`cursor`

.. versionadded:: 3.34
%End

bool operator==( const QgsAnnotationItemNode &other ) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ present in the XML document.
.. seealso:: :py:func:`writeXml`
%End


QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Returns a DOM element representing the state of the manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



class QgsAnnotationPictureItem : QgsAnnotationItem
class QgsAnnotationPictureItem : QgsAnnotationRectItem
{
%Docstring(signature="appended")
An annotation item which renders a picture.
Expand All @@ -31,55 +31,16 @@ within the specified ``bounds`` geometry.

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.placementMode` is :py:class:`Qgis`.AnnotationPlacementMode.FixedSize then the picture will be placed
at the center of the bounds.

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

void setBounds( const QgsRectangle &bounds );
static QgsAnnotationPictureItem *create() /Factory/;
%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.placementMode` is :py:class:`Qgis`.AnnotationPlacementMode.FixedSize then the picture will be placed
at the center of the bounds.

.. seealso:: :py:func:`bounds`
Creates a new polygon annotation item.
%End

QString path() const;
Expand All @@ -101,60 +62,6 @@ Sets the ``format`` and ``path`` of the image used to render the item.
.. seealso:: :py:func:`path`

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

Qgis::AnnotationPlacementMode placementMode() const;
%Docstring
Returns the placement mode for the picture.

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

void setPlacementMode( Qgis::AnnotationPlacementMode mode );
%Docstring
Sets the placement ``mode`` for the picture.

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

QSizeF fixedSize() const;
%Docstring
Returns the fixed size to use for the picture, when the :py:func:`~QgsAnnotationPictureItem.placementMode` is :py:class:`Qgis`.AnnotationPlacementMode.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.placementMode` is :py:class:`Qgis`.AnnotationPlacementMode.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.placementMode` is :py:class:`Qgis`.AnnotationPlacementMode.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.placementMode` is :py:class:`Qgis`.AnnotationPlacementMode.FixedSize.

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

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

bool lockAspectRatio() const;
Expand All @@ -171,81 +78,10 @@ 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.
protected:

.. seealso:: :py:func:`frameEnabled`
virtual void renderInBounds( QgsRenderContext &context, const QRectF &painterBounds, QgsFeedback *feedback );

.. 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 );
Expand Down
Loading
Loading