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

[annotations] Add support for callouts to point text, rect text and picture items #58295

Merged
merged 6 commits into from
Aug 6, 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
6 changes: 4 additions & 2 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,8 @@
# monkey patching scoped based enum
Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__ = "Item's bounding box will vary depending on map scale"
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.SupportsCallouts.__doc__ = "Item supports callouts (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__ + '\n' + '* ``SupportsCallouts``: ' + Qgis.AnnotationItemFlag.SupportsCallouts.__doc__
# --
Qgis.AnnotationItemFlags = lambda flags=0: Qgis.AnnotationItemFlag(flags)
Qgis.AnnotationItemFlag.baseClass = Qgis
Expand All @@ -2213,7 +2214,8 @@
AnnotationItemGuiFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
# monkey patching scoped based enum
Qgis.AnnotationItemNodeType.VertexHandle.__doc__ = "Node is a handle for manipulating vertices"
Qgis.AnnotationItemNodeType.__doc__ = "Annotation item node types.\n\n.. versionadded:: 3.22\n\n" + '* ``VertexHandle``: ' + Qgis.AnnotationItemNodeType.VertexHandle.__doc__
Qgis.AnnotationItemNodeType.CalloutHandle.__doc__ = "Node is a handle for manipulating callouts (since QGIS 3.40)"
Qgis.AnnotationItemNodeType.__doc__ = "Annotation item node types.\n\n.. versionadded:: 3.22\n\n" + '* ``VertexHandle``: ' + Qgis.AnnotationItemNodeType.VertexHandle.__doc__ + '\n' + '* ``CalloutHandle``: ' + Qgis.AnnotationItemNodeType.CalloutHandle.__doc__
# --
Qgis.AnnotationItemNodeType.baseClass = Qgis
# monkey patching scoped based enum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,76 @@ exactly 2mm thick when a map is rendered at 1:1000, or 1mm thick when rendered a
.. seealso:: :py:func:`symbologyReferenceScale`

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

QgsCallout *callout() const;
%Docstring
Returns the item's callout renderer, responsible for drawing item callouts.

Ownership is not transferred.

By default items do not have a callout, and it is necessary to be explicitly set
a callout style (via :py:func:`~QgsAnnotationItem.setCallout` ) and set the callout anchor geometry (via set
:py:func:`~QgsAnnotationItem.setCalloutAnchor` ).

.. note::

Callouts are only supported by items which return :py:class:`Qgis`.AnnotationItemFlag.SupportsCallouts from :py:func:`~QgsAnnotationItem.flags`.

.. seealso:: :py:func:`setCallout`

.. seealso:: :py:func:`calloutAnchor`

.. versionadded:: 3.40
%End

void setCallout( QgsCallout *callout /Transfer/ );
%Docstring
Sets the item's ``callout`` renderer, responsible for drawing item callouts.

Ownership of ``callout`` is transferred to the item.

.. note::

Callouts are only supported by items which return :py:class:`Qgis`.AnnotationItemFlag.SupportsCallouts from :py:func:`~QgsAnnotationItem.flags`.

.. seealso:: :py:func:`callout`

.. seealso:: :py:func:`setCalloutAnchor`

.. versionadded:: 3.40
%End

QgsGeometry calloutAnchor() const;
%Docstring
Returns the callout's anchor geometry.

The anchor dictates the geometry which the option item :py:func:`~QgsAnnotationItem.callout` should connect to. Depending on the
callout subclass and anchor geometry type, the actual shape of the rendered callout may vary.

The callout anchor geometry is in the parent layer's coordinate reference system.

.. seealso:: :py:func:`callout`

.. seealso:: :py:func:`setCalloutAnchor`

.. versionadded:: 3.40
%End

void setCalloutAnchor( const QgsGeometry &anchor );
%Docstring
Sets the callout's ``anchor`` geometry.

The anchor dictates the geometry which the option item :py:func:`~QgsAnnotationItem.callout` should connect to. Depending on the
callout subclass and anchor geometry type, the actual shape of the rendered callout may vary.

The callout ``anchor`` geometry must be specified in the parent layer's coordinate reference system.

.. seealso:: :py:func:`setCallout`

.. seealso:: :py:func:`calloutAnchor`

.. versionadded:: 3.40
%End

protected:
Expand Down Expand Up @@ -281,6 +351,15 @@ Reads common properties from the base class from the given DOM ``element``.
.. seealso:: :py:func:`readXml`

.. versionadded:: 3.22
%End

void renderCallout( QgsRenderContext &context, const QRectF &rect, double angle, QgsCallout::QgsCalloutContext &calloutContext, QgsFeedback *feedback );
%Docstring
Renders the item's callout.

The item must have valid :py:func:`~QgsAnnotationItem.callout` set.

.. versionadded:: 3.40
%End

private:
Expand Down
2 changes: 2 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ The development version
{
ScaleDependentBoundingBox,
SupportsReferenceScale,
SupportsCallouts,
};
typedef QFlags<Qgis::AnnotationItemFlag> AnnotationItemFlags;

Expand All @@ -1301,6 +1302,7 @@ The development version
enum class AnnotationItemNodeType /BaseType=IntEnum/
{
VertexHandle,
CalloutHandle,
};

enum class AnnotationItemEditOperationResult /BaseType=IntEnum/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ A widget for configuring common properties for :py:class:`QgsAnnotationItems`
%Docstring
Constructor for QgsAnnotationItemCommonPropertiesWidget.
%End
~QgsAnnotationItemCommonPropertiesWidget();

void setItem( QgsAnnotationItem *item );
%Docstring
Expand Down
6 changes: 3 additions & 3 deletions python/PyQt6/gui/auto_generated/qgsrubberband.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Set to an invalid color to avoid drawing the secondary stroke.
Returns the current secondary stroke color.
%End

void setWidth( int width );
void setWidth( double width );
%Docstring
Sets the width of the line. Stroke width for polygon.

Expand Down Expand Up @@ -157,12 +157,12 @@ Calling this function automatically calls setIcon(ICON_SVG)
Returns the current icon type to highlight point geometries.
%End

void setIconSize( int iconSize );
void setIconSize( double iconSize );
%Docstring
Sets the size of the point icons
%End

int iconSize() const;
double iconSize() const;
%Docstring
Returns the current icon size of the point icons.
%End
Expand Down
6 changes: 4 additions & 2 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,8 @@
# monkey patching scoped based enum
Qgis.AnnotationItemFlag.ScaleDependentBoundingBox.__doc__ = "Item's bounding box will vary depending on map scale"
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.SupportsCallouts.__doc__ = "Item supports callouts (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__ + '\n' + '* ``SupportsCallouts``: ' + Qgis.AnnotationItemFlag.SupportsCallouts.__doc__
# --
Qgis.AnnotationItemFlag.baseClass = Qgis
Qgis.AnnotationItemFlags.baseClass = Qgis
Expand All @@ -2171,7 +2172,8 @@
AnnotationItemGuiFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
# monkey patching scoped based enum
Qgis.AnnotationItemNodeType.VertexHandle.__doc__ = "Node is a handle for manipulating vertices"
Qgis.AnnotationItemNodeType.__doc__ = "Annotation item node types.\n\n.. versionadded:: 3.22\n\n" + '* ``VertexHandle``: ' + Qgis.AnnotationItemNodeType.VertexHandle.__doc__
Qgis.AnnotationItemNodeType.CalloutHandle.__doc__ = "Node is a handle for manipulating callouts (since QGIS 3.40)"
Qgis.AnnotationItemNodeType.__doc__ = "Annotation item node types.\n\n.. versionadded:: 3.22\n\n" + '* ``VertexHandle``: ' + Qgis.AnnotationItemNodeType.VertexHandle.__doc__ + '\n' + '* ``CalloutHandle``: ' + Qgis.AnnotationItemNodeType.CalloutHandle.__doc__
# --
Qgis.AnnotationItemNodeType.baseClass = Qgis
# monkey patching scoped based enum
Expand Down
79 changes: 79 additions & 0 deletions python/core/auto_generated/annotations/qgsannotationitem.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,76 @@ exactly 2mm thick when a map is rendered at 1:1000, or 1mm thick when rendered a
.. seealso:: :py:func:`symbologyReferenceScale`

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

QgsCallout *callout() const;
%Docstring
Returns the item's callout renderer, responsible for drawing item callouts.

Ownership is not transferred.

By default items do not have a callout, and it is necessary to be explicitly set
a callout style (via :py:func:`~QgsAnnotationItem.setCallout` ) and set the callout anchor geometry (via set
:py:func:`~QgsAnnotationItem.setCalloutAnchor` ).

.. note::

Callouts are only supported by items which return :py:class:`Qgis`.AnnotationItemFlag.SupportsCallouts from :py:func:`~QgsAnnotationItem.flags`.

.. seealso:: :py:func:`setCallout`

.. seealso:: :py:func:`calloutAnchor`

.. versionadded:: 3.40
%End

void setCallout( QgsCallout *callout /Transfer/ );
%Docstring
Sets the item's ``callout`` renderer, responsible for drawing item callouts.

Ownership of ``callout`` is transferred to the item.

.. note::

Callouts are only supported by items which return :py:class:`Qgis`.AnnotationItemFlag.SupportsCallouts from :py:func:`~QgsAnnotationItem.flags`.

.. seealso:: :py:func:`callout`

.. seealso:: :py:func:`setCalloutAnchor`

.. versionadded:: 3.40
%End

QgsGeometry calloutAnchor() const;
%Docstring
Returns the callout's anchor geometry.

The anchor dictates the geometry which the option item :py:func:`~QgsAnnotationItem.callout` should connect to. Depending on the
callout subclass and anchor geometry type, the actual shape of the rendered callout may vary.

The callout anchor geometry is in the parent layer's coordinate reference system.

.. seealso:: :py:func:`callout`

.. seealso:: :py:func:`setCalloutAnchor`

.. versionadded:: 3.40
%End

void setCalloutAnchor( const QgsGeometry &anchor );
%Docstring
Sets the callout's ``anchor`` geometry.

The anchor dictates the geometry which the option item :py:func:`~QgsAnnotationItem.callout` should connect to. Depending on the
callout subclass and anchor geometry type, the actual shape of the rendered callout may vary.

The callout ``anchor`` geometry must be specified in the parent layer's coordinate reference system.

.. seealso:: :py:func:`setCallout`

.. seealso:: :py:func:`calloutAnchor`

.. versionadded:: 3.40
%End

protected:
Expand Down Expand Up @@ -281,6 +351,15 @@ Reads common properties from the base class from the given DOM ``element``.
.. seealso:: :py:func:`readXml`

.. versionadded:: 3.22
%End

void renderCallout( QgsRenderContext &context, const QRectF &rect, double angle, QgsCallout::QgsCalloutContext &calloutContext, QgsFeedback *feedback );
%Docstring
Renders the item's callout.

The item must have valid :py:func:`~QgsAnnotationItem.callout` set.

.. versionadded:: 3.40
%End

private:
Expand Down
2 changes: 2 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ The development version
{
ScaleDependentBoundingBox,
SupportsReferenceScale,
SupportsCallouts,
};
typedef QFlags<Qgis::AnnotationItemFlag> AnnotationItemFlags;

Expand All @@ -1301,6 +1302,7 @@ The development version
enum class AnnotationItemNodeType
{
VertexHandle,
CalloutHandle,
};

enum class AnnotationItemEditOperationResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ A widget for configuring common properties for :py:class:`QgsAnnotationItems`
%Docstring
Constructor for QgsAnnotationItemCommonPropertiesWidget.
%End
~QgsAnnotationItemCommonPropertiesWidget();

void setItem( QgsAnnotationItem *item );
%Docstring
Expand Down
6 changes: 3 additions & 3 deletions python/gui/auto_generated/qgsrubberband.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Set to an invalid color to avoid drawing the secondary stroke.
Returns the current secondary stroke color.
%End

void setWidth( int width );
void setWidth( double width );
%Docstring
Sets the width of the line. Stroke width for polygon.

Expand Down Expand Up @@ -157,12 +157,12 @@ Calling this function automatically calls setIcon(ICON_SVG)
Returns the current icon type to highlight point geometries.
%End

void setIconSize( int iconSize );
void setIconSize( double iconSize );
%Docstring
Sets the size of the point icons
%End

int iconSize() const;
double iconSize() const;
%Docstring
Returns the current icon size of the point icons.
%End
Expand Down
Loading
Loading