mirror of https://gitlab.com/pamhyr/pamhyr2
Mesh: give choice to export only handwritten points in geometry, or all points with interpolated ones
parent
059d7203a9
commit
ef5430ae2c
|
|
@ -97,6 +97,15 @@ class GeometryTranslate(MainTranslate):
|
||||||
self._dict["format_not_exportable"] = _translate(
|
self._dict["format_not_exportable"] = _translate(
|
||||||
"Geometry", "The format of the file is not exportable."
|
"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(
|
self._dict["update_rk_error"] = _translate(
|
||||||
"Geometry",
|
"Geometry",
|
||||||
"RK update can't be executed."
|
"RK update can't be executed."
|
||||||
|
|
|
||||||
|
|
@ -739,7 +739,11 @@ class GeometryWindow(PamhyrWindow):
|
||||||
suffix = Path(filename).suffix
|
suffix = Path(filename).suffix
|
||||||
if suffix != "":
|
if suffix != "":
|
||||||
if suffix == ".st" or suffix == ".ST":
|
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:
|
else:
|
||||||
# Warning popup when the format is not exportable
|
# Warning popup when the format is not exportable
|
||||||
win = QtWidgets.QMessageBox()
|
win = QtWidgets.QMessageBox()
|
||||||
|
|
@ -750,16 +754,45 @@ class GeometryWindow(PamhyrWindow):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
else:
|
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:
|
with open(filename+".st", "w+") as f:
|
||||||
f.write("# Exported from Pamhyr2\n")
|
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
|
pid = 0
|
||||||
for profile in reach.profiles:
|
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)
|
self._export_to_file_st_profile(wfile, profile, pid)
|
||||||
pid += 1
|
pid += 1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue