diff --git a/src/Meshing/Mage.py b/src/Meshing/Mage.py index cd4e577f..393de9c4 100644 --- a/src/Meshing/Mage.py +++ b/src/Meshing/Mage.py @@ -293,6 +293,7 @@ class MeshingWithMageMailleurTT(AMeshingTool): def meshing(self, reach, step: float = 50, limites=[-1, -1], + origin=0, directrices=['un', 'np'], lplan: bool = False, lm: int = 3, @@ -310,27 +311,37 @@ class MeshingWithMageMailleurTT(AMeshingTool): proc = QProcess() proc.setWorkingDirectory(tmp) + # Mage section index start at 1 + origin += 1 + limites[0] += 1 + limites[1] += 1 + lplan = 1 if lplan else 0 linear = 1 if linear else 0 logger.info( - f"! {self._exe_path()} {st_file} {m_file} " + + f"! {self._exe_path()} " + + f"{st_file} {m_file} " + f"{str(step)} " + f"{limites[0]} {limites[1]} " + f"{directrices[0]} {directrices[1]} " + - f"{lplan} {lm} {linear}" + f"{lplan} {lm} {linear} " + + f"mesh {origin}" ) proc.start( self._exe_path(), - list(map( - str, - [ - st_file, m_file, step, - limites[0], limites[1], - directrices[0], directrices[1], - lplan, lm, linear - ] - )) + list( + map( + str, + [ + st_file, m_file, step, + limites[0], limites[1], + directrices[0], directrices[1], + lplan, lm, linear, + "mesh", origin + ] + ) + ) ) proc.waitForFinished() @@ -347,9 +358,9 @@ class MeshingWithMageMailleurTT(AMeshingTool): logger.error( f"{logger_color_red()}{errors}{logger_color_reset()}" ) - else: - self.import_m_file(reach, m_file) + return reach + self.import_m_file(reach, m_file) return reach def export_reach_to_st(self, reach, tmp): diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py index 9b2ecdc3..04a75c91 100644 --- a/src/Model/Geometry/Reach.py +++ b/src/Model/Geometry/Reach.py @@ -560,12 +560,20 @@ class Reach(SQLSubModel): # Import/Export def import_geometry(self, file_path_name: str): - if file_path_name.endswith(".st"): - return self.import_geometry_st(file_path_name) - elif file_path_name.endswith(".shp"): - return self.import_geometry_shp(file_path_name) - else: - return [] + ext = file_path_name.split(".") + if len(ext) > 0: + ext = ext[-1].lower() + + if ext in ['st', 'm']: + return self.import_geometry_st(file_path_name) + + if ext in ['shp']: + return self.import_geometry_shp(file_path_name) + + raise FileFormatError( + file_path_name, + f"Geometry file extention ({ext}) unkown" + ) @timer def import_geometry_shp(self, file_path_name: str): diff --git a/src/View/Geometry/MeshingDialog.py b/src/View/Geometry/MeshingDialog.py index 05a44846..7c7b385d 100644 --- a/src/View/Geometry/MeshingDialog.py +++ b/src/View/Geometry/MeshingDialog.py @@ -58,6 +58,7 @@ class MeshingDialog(PamhyrDialog): self._end_cs = -1 self._begin_dir = "un" self._end_dir = "np" + self._origin = self._reach.profile(0) self._init_default_values_profiles() self._init_default_values_guidelines() @@ -76,7 +77,7 @@ class MeshingDialog(PamhyrDialog): ) ) ) - self.set_combobox_text("comboBox_lm", self._lm) + self.set_combobox_text("comboBox_lm", lm_dict[self._lm]) if self._linear: self.set_radio_button("radioButton_linear", True) @@ -88,6 +89,7 @@ class MeshingDialog(PamhyrDialog): self.combobox_add_items("comboBox_begin_kp", profiles) self.combobox_add_items("comboBox_end_kp", profiles) + self.combobox_add_items("comboBox_origin", profiles) self.set_combobox_text("comboBox_begin_kp", profiles[0]) self.set_combobox_text("comboBox_end_kp", profiles[-1]) @@ -135,6 +137,10 @@ class MeshingDialog(PamhyrDialog): def lplan(self): return self._lplan + @property + def origin(self): + return self._origin + @property def lm(self): return int(self._lm) @@ -145,11 +151,11 @@ class MeshingDialog(PamhyrDialog): @property def begin_cs(self): - return self._begin_cs + 1 + return self._begin_cs @property def end_cs(self): - return self._end_cs + 1 + return self._end_cs @property def begin_dir(self): @@ -171,6 +177,9 @@ class MeshingDialog(PamhyrDialog): self._begin_cs = self.profiles.index(p1) self._end_cs = self.profiles.index(p2) + origin = self.get_combobox_text("comboBox_origin") + self._origin = self.profiles.index(origin) + self._begin_dir = self.get_combobox_text("comboBox_begin_gl") self._end_dir = self.get_combobox_text("comboBox_end_gl") diff --git a/src/View/Geometry/Translate.py b/src/View/Geometry/Translate.py index 23034fd5..4ee4fced 100644 --- a/src/View/Geometry/Translate.py +++ b/src/View/Geometry/Translate.py @@ -66,9 +66,9 @@ class GeometryTranslate(MainTranslate): } self._sub_dict["lm_dict"] = { - "1": _translate("Geometry", "First guideline"), - "2": _translate("Geometry", "Second guideline"), - "3": _translate("Geometry", "Means between the two guideline"), + "1": _translate("Geometry", "the first guide-line"), + "2": _translate("Geometry", "the second guide-line"), + "3": _translate("Geometry", "the means between the two guide-lines"), } self._sub_dict["r_lm_dict"] = {} diff --git a/src/View/Geometry/UndoCommand.py b/src/View/Geometry/UndoCommand.py index 5c587c01..3f21577d 100644 --- a/src/View/Geometry/UndoCommand.py +++ b/src/View/Geometry/UndoCommand.py @@ -26,6 +26,7 @@ from PyQt5.QtWidgets import ( ) from Model.Geometry import Reach +from Model.Except import exception_message_box from Meshing.Mage import MeshingWithMage @@ -209,8 +210,11 @@ class ImportCommand(QUndoCommand): def redo(self): if self._profiles is None: - self._profiles = self._reach.import_geometry(self._filename) - self._profiles.reverse() + try: + self._profiles = self._reach.import_geometry(self._filename) + self._profiles.reverse() + except Exception as e: + exception_message_box(e) else: for profile in self._profiles: self._reach.insert_profile(self._row, profile) diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 3631ff10..5e25bd31 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -295,6 +295,7 @@ class GeometryWindow(PamhyrWindow): data = { "step": dlg.space_step, "limites": [dlg.begin_cs, dlg.end_cs], + "origin" : dlg.origin, "directrices": [dlg.begin_dir, dlg.end_dir], "lplan": dlg.lplan, "lm": dlg.lm, diff --git a/src/View/ui/MeshingOptions.ui b/src/View/ui/MeshingOptions.ui index b2fe91f7..01bd7a53 100644 --- a/src/View/ui/MeshingOptions.ui +++ b/src/View/ui/MeshingOptions.ui @@ -6,14 +6,108 @@ 0 0 - 512 - 288 + 608 + 342 Dialog - + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Parameters + + + + + + Section space step (m) + + + + + + + + + 999999.989999999990687 + + + 50.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Type of interpolation: + + + + + + + + + Spline + + + true + + + + + + + Linear + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -66,183 +160,79 @@ - - - - - - - - true - - - First guide line - - - - - - - true - - - - - - - - - - - true - - - Last guide line - - - - - - - true - - - - - - - - + - Options + Distance computation - + - + - Section space step (m) + Original section - - - - - - 9999.989999999999782 - - - 50.000000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + - + + + + true + + + First guide-line + + + + + + + true + + + + + + + true + + + Second guide-line + + + + + + + true + + + + true - Distance computation guild line + Takes - - - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Type of interpolation: + + + + true - - - - - - Spline - - - true - - - - - - - Linear - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - -