Skip to content

Commit

Permalink
fix: annotations staying after saving (#231)
Browse files Browse the repository at this point in the history
Co-authored-by: koebi <koebi@ezelo.de>
  • Loading branch information
merydian and koebi authored May 10, 2024
1 parent 476a557 commit 0e0ad02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ RELEASING:
14. Create new release in GitHub with tag version and release title of `vX.X.X`
-->

# Unreleased
- Add option to export order of optimization route points ([#145](https://github.com/GIScience/orstools-qgis-plugin/issues/145))

## Unreleased

### Fixed
- QGis crashes when selecting more than two vertices for deletion ([#230](https://github.com/GIScience/orstools-qgis-plugin/issues/230))
- Vertices on canvas not depicted fully with n having more than one digit in length ([#235](https://github.com/GIScience/orstools-qgis-plugin/issues/235))
- Replace qt QSettings with QgsSettings for centralized configuration management ([#239](https://github.com/GIScience/orstools-qgis-plugin/issues/239))
- Fix: Point Annotations stay after saving project and not deleting them manually([#229](https://github.com/GIScience/orstools-qgis-plugin/issues/229))

### Added
- Add support for decimal ranges with isochrones([#237](https://github.com/GIScience/orstools-qgis-plugin/issues/237))
- Add hint for joining with `Layer ID Field` ([#143](https://github.com/GIScience/orstools-qgis-plugin/issues/143))
- Add option to export order of optimization route points ([#145](https://github.com/GIScience/orstools-qgis-plugin/issues/145))

### Changed
- Rename `Ok` button in configuration window to `Save` for clarification([#241](https://github.com/GIScience/orstools-qgis-plugin/issues/241))
Expand Down
9 changes: 5 additions & 4 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ def __init__(self, iface, parent=None):
self.routing_fromline_list.model().rowsMoved.connect(self._reindex_list_items)
self.routing_fromline_list.model().rowsRemoved.connect(self._reindex_list_items)

self.annotation_canvas = self._iface.mapCanvas()

def _save_vertices_to_layer(self):
"""Saves the vertices list to a temp layer"""
items = [
Expand Down Expand Up @@ -550,11 +552,12 @@ def _linetool_annotate_point(self, point, idx, crs=None):
annotation.setMapPosition(point)
annotation.setMapPositionCrs(crs)

return QgsMapCanvasAnnotationItem(annotation, self._iface.mapCanvas()).annotation()
return QgsMapCanvasAnnotationItem(annotation, self.annotation_canvas).annotation()

def _clear_annotations(self):
"""Clears annotations"""
for annotation in self.annotations:
for annotation_item in self.annotation_canvas.annotationItems():
annotation = annotation_item.annotation()
if annotation in self.project.annotationManager().annotations():
self.project.annotationManager().removeAnnotation(annotation)
self.annotations = []
Expand Down Expand Up @@ -586,7 +589,6 @@ def _on_linetool_map_click(self, point, idx):
self.routing_fromline_list.addItem(f"Point {idx}: {point_wgs.x():.6f}, {point_wgs.y():.6f}")

annotation = self._linetool_annotate_point(point, idx)
self.annotations.append(annotation)
self.project.annotationManager().addAnnotation(annotation)

def _reindex_list_items(self):
Expand All @@ -606,7 +608,6 @@ def _reindex_list_items(self):

self.routing_fromline_list.addItem(item)
annotation = self._linetool_annotate_point(point, idx, crs)
self.annotations.append(annotation)
self.project.annotationManager().addAnnotation(annotation)

def _on_linetool_map_doubleclick(self):
Expand Down

0 comments on commit 0e0ad02

Please sign in to comment.