diff --git a/src/Model/GeoTIFF/GeoTIFF.py b/src/Model/GeoTIFF/GeoTIFF.py index e86588be..c35bc875 100644 --- a/src/Model/GeoTIFF/GeoTIFF.py +++ b/src/Model/GeoTIFF/GeoTIFF.py @@ -112,7 +112,8 @@ class GeoTIFF(SQLSubModel): elif key == "description": self.description = value elif key == "file_name": - self.read_file(value) + if self._file_name != value: + self.read_file(value) elif key == "coordinates": self.coordinates = value elif key == "coordinates_bottom": diff --git a/src/View/GeoTIFF/Edit/Window.py b/src/View/GeoTIFF/Edit/Window.py index 8559710f..91c083da 100644 --- a/src/View/GeoTIFF/Edit/Window.py +++ b/src/View/GeoTIFF/Edit/Window.py @@ -22,8 +22,8 @@ from Modules import Modules from View.Tools.PamhyrWindow import PamhyrWindow from PyQt5.QtWidgets import ( - QLabel, QPlainTextEdit, QPushButton, - QCheckBox, QFileDialog, QVBoxLayout, + QLabel, QPlainTextEdit, QPushButton, QCheckBox, + QFileDialog, QVBoxLayout, QDoubleSpinBox, ) from PyQt5.QtCore import ( @@ -78,8 +78,8 @@ class EditGeoTIFFWindow(PamhyrWindow): self._undo = undo - self.setup_graph() self.setup_values() + self.setup_graph() self.setup_connection() def setup_graph(self): @@ -115,6 +115,12 @@ class EditGeoTIFFWindow(PamhyrWindow): "left": self._geotiff.coord_left, "right": self._geotiff.coord_right, } + self._values_default = { + "bottom": self._geotiff.coord_bottom, + "top": self._geotiff.coord_top, + "left": self._geotiff.coord_left, + "right": self._geotiff.coord_right, + } self._reset_values() @@ -131,6 +137,12 @@ class EditGeoTIFFWindow(PamhyrWindow): "left": bounds[1], "right": bounds[3], } + self._values_default = { + "bottom": bounds[0], + "top": bounds[2], + "left": bounds[1], + "right": bounds[3], + } self._reset_values() @@ -139,7 +151,7 @@ class EditGeoTIFFWindow(PamhyrWindow): self._reset_values_key(key) def _reset_values_key(self, key): - self.set_double_spin_box(f"doubleSpinBox_{key}", self._values[key]) + self.set_double_spin_box(f"doubleSpinBox_{key}", self._values_default[key]) def setup_connection(self): self.find(QPushButton, "pushButton_cancel")\ @@ -153,6 +165,14 @@ class EditGeoTIFFWindow(PamhyrWindow): self.find(QPushButton, f"pushButton_{key}")\ .clicked.connect(lambda: self._reset_values_key(key)) + self.find(QDoubleSpinBox, f"doubleSpinBox_{key}")\ + .valueChanged.connect(lambda: self.update_spinbox_value(key)) + + def update_spinbox_value(self, key): + self._values[key] = self.get_double_spin_box(f"doubleSpinBox_{key}") + + self._plot_img.set_extent(list(self._values.values())) + def draw_geotiff(self, memfile=None): if not _rasterio_loaded: return @@ -169,14 +189,14 @@ class EditGeoTIFFWindow(PamhyrWindow): img = gt.read() b = gt.bounds[:] + self._set_values_from_bounds(b) + if self._plot_img is not None: self._plot_img.remove() - self._set_values_from_bounds(b) - self._plot_img = self.canvas.axes.imshow( img.transpose((1, 2, 0)), - extent=[b[0], b[2], b[1], b[3]] + extent=list(self._values.values()) ) self.plot.idle() @@ -202,7 +222,7 @@ class EditGeoTIFFWindow(PamhyrWindow): if filename != "": self._file_name = filename - self. draw_geotiff() + self.draw_geotiff() def accept(self): if self._study.is_editable(): diff --git a/src/View/GeoTIFF/Window.py b/src/View/GeoTIFF/Window.py index e87db148..64bd2d3c 100644 --- a/src/View/GeoTIFF/Window.py +++ b/src/View/GeoTIFF/Window.py @@ -134,7 +134,7 @@ class GeoTIFFListWindow(PamhyrWindow): self._plot_img = {} - for geotiff in self._study.river.geotiff.lst: + for geotiff in self._study.river.geotiff.files: self.draw_geotiff(geotiff) def selected_rows(self):