diff --git a/src/View/Geometry/Translate.py b/src/View/Geometry/Translate.py index 10f93bd9..1b3702da 100644 --- a/src/View/Geometry/Translate.py +++ b/src/View/Geometry/Translate.py @@ -97,6 +97,15 @@ class GeometryTranslate(MainTranslate): self._dict["format_not_exportable"] = _translate( "Geometry", "The format of the file is not exportable." ) + self._dict["export_options"] = _translate( + "Geometry", "Export options" + ) + self._dict["export_options_text"] = _translate( + "Geometry", "Choose which cross-sections to export." + ) + self._dict["export_interpolated_profiles"] = _translate( + "Geometry", "Export interpolated cross-sections" + ) self._dict["update_rk_error"] = _translate( "Geometry", "RK update can't be executed." diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 5f3ad301..4beffb58 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -739,7 +739,11 @@ class GeometryWindow(PamhyrWindow): suffix = Path(filename).suffix if suffix != "": if suffix == ".st" or suffix == ".ST": - self._export_to_file_st(filename[:-3]) + export_interpolated = self._ask_export_options() + if export_interpolated is not None: + self._export_to_file_st( + filename[:-3], export_interpolated + ) else: # Warning popup when the format is not exportable win = QtWidgets.QMessageBox() @@ -750,16 +754,45 @@ class GeometryWindow(PamhyrWindow): pass else: - self._export_to_file_st(filename) + export_interpolated = self._ask_export_options() + if export_interpolated is not None: + self._export_to_file_st(filename, export_interpolated) - def _export_to_file_st(self, filename): + def _ask_export_options(self): + win = QtWidgets.QMessageBox(self) + win.setIcon(QtWidgets.QMessageBox.Question) + win.setWindowTitle(self._trad["export_options"]) + win.setText(self._trad["export_options_text"]) + win.setStandardButtons( + QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel + ) + + export_interpolated = QCheckBox( + self._trad["export_interpolated_profiles"], win + ) + export_interpolated.setChecked(True) + win.setCheckBox(export_interpolated) + + if win.exec() != QtWidgets.QMessageBox.Ok: + return None + + return export_interpolated.isChecked() + + def _export_to_file_st(self, filename, export_interpolated=True): with open(filename+".st", "w+") as f: f.write("# Exported from Pamhyr2\n") - self._export_to_file_st_reach(f, self._reach) + self._export_to_file_st_reach( + f, self._reach, export_interpolated + ) - def _export_to_file_st_reach(self, wfile, reach): + def _export_to_file_st_reach(self, wfile, reach, + export_interpolated=True): pid = 0 for profile in reach.profiles: + is_interpolated = profile.name.lower().startswith("interpol") + if is_interpolated and not export_interpolated: + continue + self._export_to_file_st_profile(wfile, profile, pid) pid += 1