mirror of https://gitlab.com/pamhyr/pamhyr2
GeoTIFF: Integrate geotiff menu to mainwindow and fix bounds update.
parent
9308a73e8e
commit
deb9b2069f
|
|
@ -85,7 +85,8 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
def setup_graph(self):
|
def setup_graph(self):
|
||||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||||
self.canvas.setObjectName("canvas")
|
self.canvas.setObjectName("canvas")
|
||||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout_geotiff")
|
self.plot_layout = self.find(QVBoxLayout,
|
||||||
|
"verticalLayout_geotiff")
|
||||||
self.plot_layout.addWidget(self.canvas)
|
self.plot_layout.addWidget(self.canvas)
|
||||||
|
|
||||||
self.plot = PlotXY(
|
self.plot = PlotXY(
|
||||||
|
|
@ -109,20 +110,10 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
self.set_line_edit_text("lineEdit_description",
|
self.set_line_edit_text("lineEdit_description",
|
||||||
self._geotiff.description)
|
self._geotiff.description)
|
||||||
|
|
||||||
self._values = {
|
bounds = list(self._geotiff.coordinates.values())
|
||||||
"bottom": self._geotiff.coord_bottom,
|
self._set_values_from_bounds(bounds)
|
||||||
"top": self._geotiff.coord_top,
|
self._set_default_values_from_bounds(bounds)
|
||||||
"left": self._geotiff.coord_left,
|
self._reset_spinboxes()
|
||||||
"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()
|
|
||||||
|
|
||||||
if self._study.is_read_only():
|
if self._study.is_read_only():
|
||||||
self.set_check_box_enable("checkBox", False)
|
self.set_check_box_enable("checkBox", False)
|
||||||
|
|
@ -137,6 +128,8 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
"left": bounds[1],
|
"left": bounds[1],
|
||||||
"right": bounds[3],
|
"right": bounds[3],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _set_default_values_from_bounds(self, bounds):
|
||||||
self._values_default = {
|
self._values_default = {
|
||||||
"bottom": bounds[0],
|
"bottom": bounds[0],
|
||||||
"top": bounds[2],
|
"top": bounds[2],
|
||||||
|
|
@ -144,14 +137,15 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
"right": bounds[3],
|
"right": bounds[3],
|
||||||
}
|
}
|
||||||
|
|
||||||
self._reset_values()
|
def _reset_spinboxes(self):
|
||||||
|
|
||||||
def _reset_values(self):
|
|
||||||
for key in self._values:
|
for key in self._values:
|
||||||
self._reset_values_key(key)
|
self._reset_spinbox(key)
|
||||||
|
|
||||||
def _reset_values_key(self, key):
|
def _reset_spinbox(self, key):
|
||||||
self.set_double_spin_box(f"doubleSpinBox_{key}", self._values_default[key])
|
self.set_double_spin_box(
|
||||||
|
f"doubleSpinBox_{key}",
|
||||||
|
self._values_default[key]
|
||||||
|
)
|
||||||
|
|
||||||
def setup_connection(self):
|
def setup_connection(self):
|
||||||
self.find(QPushButton, "pushButton_cancel")\
|
self.find(QPushButton, "pushButton_cancel")\
|
||||||
|
|
@ -163,15 +157,18 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
|
|
||||||
for key in self._values:
|
for key in self._values:
|
||||||
self.find(QPushButton, f"pushButton_{key}")\
|
self.find(QPushButton, f"pushButton_{key}")\
|
||||||
.clicked.connect(lambda: self._reset_values_key(key))
|
.clicked.connect(lambda: self._reset_spinbox(key))
|
||||||
|
|
||||||
self.find(QDoubleSpinBox, f"doubleSpinBox_{key}")\
|
self.find(QDoubleSpinBox, f"doubleSpinBox_{key}")\
|
||||||
.valueChanged.connect(lambda: self.update_spinbox_value(key))
|
.valueChanged.connect(
|
||||||
|
lambda: self.update_values_from_spinbox(key)
|
||||||
|
)
|
||||||
|
|
||||||
def update_spinbox_value(self, key):
|
def update_values_from_spinbox(self, key):
|
||||||
self._values[key] = self.get_double_spin_box(f"doubleSpinBox_{key}")
|
self._values[key] = self.get_double_spin_box(f"doubleSpinBox_{key}")
|
||||||
|
|
||||||
self._plot_img.set_extent(list(self._values.values()))
|
self._plot_img.set_extent(list(self._values.values()))
|
||||||
|
self.plot.idle()
|
||||||
|
|
||||||
def draw_geotiff(self, memfile=None):
|
def draw_geotiff(self, memfile=None):
|
||||||
if not _rasterio_loaded:
|
if not _rasterio_loaded:
|
||||||
|
|
@ -184,13 +181,13 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
with rasterio.open(self._file_name) as data:
|
with rasterio.open(self._file_name) as data:
|
||||||
img = data.read()
|
img = data.read()
|
||||||
b = data.bounds[:]
|
b = data.bounds[:]
|
||||||
|
|
||||||
|
self._set_values_from_bounds(b)
|
||||||
else:
|
else:
|
||||||
with memfile.open() as gt:
|
with memfile.open() as gt:
|
||||||
img = gt.read()
|
img = gt.read()
|
||||||
b = gt.bounds[:]
|
b = gt.bounds[:]
|
||||||
|
|
||||||
self._set_values_from_bounds(b)
|
|
||||||
|
|
||||||
if self._plot_img is not None:
|
if self._plot_img is not None:
|
||||||
self._plot_img.remove()
|
self._plot_img.remove()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ define_model_action = [
|
||||||
"action_menu_boundary_conditions_sediment",
|
"action_menu_boundary_conditions_sediment",
|
||||||
"action_menu_rep_additional_lines", "action_menu_output_rk",
|
"action_menu_rep_additional_lines", "action_menu_output_rk",
|
||||||
"action_menu_run_adists", "action_menu_pollutants",
|
"action_menu_run_adists", "action_menu_pollutants",
|
||||||
"action_menu_d90", "action_menu_dif",
|
"action_menu_d90", "action_menu_dif", "action_menu_edit_geotiff"
|
||||||
]
|
]
|
||||||
|
|
||||||
action = (
|
action = (
|
||||||
|
|
@ -298,6 +298,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
self.open_reach_sediment_layers,
|
self.open_reach_sediment_layers,
|
||||||
"action_menu_additional_file": self.open_additional_files,
|
"action_menu_additional_file": self.open_additional_files,
|
||||||
"action_menu_rep_additional_lines": self.open_rep_lines,
|
"action_menu_rep_additional_lines": self.open_rep_lines,
|
||||||
|
"action_menu_edit_geotiff": self.open_geotiff,
|
||||||
"action_menu_close": self.close_model,
|
"action_menu_close": self.close_model,
|
||||||
"action_menu_results_last": self.open_last_results,
|
"action_menu_results_last": self.open_last_results,
|
||||||
"action_menu_open_results_from_file": self.open_results_from_file,
|
"action_menu_open_results_from_file": self.open_results_from_file,
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@
|
||||||
<string>&Geometry</string>
|
<string>&Geometry</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="action_menu_edit_geometry"/>
|
<addaction name="action_menu_edit_geometry"/>
|
||||||
|
<addaction name="action_menu_edit_geotiff"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_run">
|
<widget class="QMenu" name="menu_run">
|
||||||
<property name="locale">
|
<property name="locale">
|
||||||
|
|
@ -811,6 +812,11 @@
|
||||||
<string>Compare results</string>
|
<string>Compare results</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="action_menu_edit_geotiff">
|
||||||
|
<property name="text">
|
||||||
|
<string>GeoTIFF</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue