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

Update older annotation items to new framework #269

Open
nyalldawson opened this issue May 2, 2023 · 2 comments
Open

Update older annotation items to new framework #269

nyalldawson opened this issue May 2, 2023 · 2 comments

Comments

@nyalldawson
Copy link
Contributor

nyalldawson commented May 2, 2023

QGIS Enhancement: Update older annotation items to new framework

Date 2023/05/02

Author Nyall Dawson (@nyalldawson)

Contact nyall dot dawson at gmail dot com

maintainer @nyalldawson

Version QGIS 3.34

Summary

For decades, QGIS supported a few "annotation" item types for drawing over map canvases: text, HTML, SVG and "form" annotations. In version 3.16 a new framework for handling annotations and annotation layers was added to QGIS which was designed around modern requirements and provided a more flexible approach for annotations. This newer framework supports point, line, polygon, text-at-point and text-along-line annotations.

In order to keep existing workflows unaffected, the older annotation items (text, html, svg and form) were left untouched during the introduction of the newer framework. The unfortunate side effect of this is that users have two completely different annotation types used in QGIS, and each has a completely different means of creation, interaction and handling.

This proposal concerns moving some of the older annotation types (specifically "text" and "svg") over to the newer framework, in order to provide a more consistent and user friendly interface to QGIS users. Porting the remaining older annotation types ("html" and "form") is left as a potential follow up project. The Text and SVG items are targeted here as they are more widely used and consequently command a higher priority.

Missing Functionality

Some feature gaps exist between the existing Text and SVG annotation items and what is possible in the newer annotation layer framework. Specifically:

  1. The older annotations can be associated with another map layer, and their visibility will be controlled by the visibility of that layer.
  2. The older annotations can be associated with a fixed point on the map, and have support for controlling the appearance of a marker at that point.
  3. The older annotations can be styled with a balloon-callout style appearance pointing to the map marker.
  4. The older text annotation item has a rich text edit GUI allowing easy control over formatting of text (text color, font family, font size and bold/italic styles).

This functionality will need to be made available to the newer annotation layer framework in order to avoid loss of features.

Proposed Solution/Deliverables

First, the missing functionality described in the above section will be added to the newer QgsAnnotationItem and QgsAnnotationLayer class.

Specifically:

  • setLinkedVisibilityLayer() / linkedVisibilityLayer() will be added to QgsAnnotationLayer, and exposed through the Annotation Layer Properties dialog (under the "Rendering" tab). This will provide a means to control the visibility of an entire annotation layer (i.e. group of annotations) by toggling the visibility of a second map layer. (Addresses missing function # 1)
  • The ability to set an associated fixed point on the map will be added to QgsAnnotationItem, and exposed for the "Text at Point" and "Text along Line" annotation types. API will be added to allow a QgsMarkerSymbol to be set for this fixed map point, and this functionality will be exposed in the GUI for these annotation item types. (Addresses missing function # 2)
  • The "Text at Point" and "Text Along Line" items types will permit a QgsCallout to be set and used while rendering. This will allow these item types to be styled using the same balloon style appearance as the older Text annotation type. (Addresses missing function # 3)
  • The QgsRichTextEditor widget class will be extended to permit a limited editing mode, which only exposes the HTML formatting subset supported for rendering text annotations (i.e. font color, family, size, style and decoration). The widget for editing text annotation items will be reworked to use the rich text editor. (Addresses missing function # 4).

Then, a new QgsAnnotationPictureItem class will be created which allows for a (linked or embedded) picture to be shown on the map. This item will support SVG and raster image formats, and is intended as a direct replacement for the existing older SVG annotation type.

Finally, code will be added to QgsProject to ensure that the older text and SVG annotations are automatically translated to their newer annotation item equivalents so that older projects will appear correctly when loaded into newer QGIS releases.

Example(s)

(optional)

Affected Files

  • QgsAnnotationLayer
  • QgsAnnotationItem
  • QgsAnnotationPointTextItem
  • QgsAnnotationLineTextItem
  • QgsRichTextEditor
  • associated unit test files

Performance Implications

None

Further Considerations/Improvements

(optional)

Backwards Compatibility

Projects created using the replacement item types will NOT be compatible with earlier QGIS releases. These annotations will disappear from the projects if opened in these older releases.

Issue Tracking ID(s)

Votes

(required)

@anitagraser
Copy link
Member

Thank you for submitting your proposal to the 2024 QGIS Grant Programme. The 2 week discussion period starts today. At the end of the discussion, the proposal author has to provide a 3-line pitch of their proposal for the voter information material. (For an example from last year check qgis/PSC#58 (comment))

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Aug 1, 2024
Adds a new "Linked layer" setting to the render page for annotation
layers, which allows users to optionally set a linked visibility
layer for the annotation layer. If set, then the annotations will
only be drawn when the linked layer is visible in the map.

This is designed to mimic the similar linked layer option for
the older annotation framework, in order to close the feature
gap between old vs new annotations

Refs qgis/QGIS-Enhancement-Proposals#269
nyalldawson added a commit to qgis/QGIS that referenced this issue Aug 2, 2024
Adds a new "Linked layer" setting to the render page for annotation
layers, which allows users to optionally set a linked visibility
layer for the annotation layer. If set, then the annotations will
only be drawn when the linked layer is visible in the map.

This is designed to mimic the similar linked layer option for
the older annotation framework, in order to close the feature
gap between old vs new annotations

Refs qgis/QGIS-Enhancement-Proposals#269
@anitagraser
Copy link
Member

The final report for this proposal has already been submitted. Can the issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants