diff --git a/src/Meshing/Mage.py b/src/Meshing/Mage.py
index 9ce8f357..90f44d56 100644
--- a/src/Meshing/Mage.py
+++ b/src/Meshing/Mage.py
@@ -297,7 +297,8 @@ class MeshingWithMageMailleurTT(AMeshingTool):
directrices=['un', 'np'],
lplan: bool = False,
lm: int = 3,
- linear: bool = False):
+ linear: bool = False,
+ origin_value = 0.0):
if reach is None or len(reach.profiles) == 0:
return reach
@@ -320,11 +321,12 @@ class MeshingWithMageMailleurTT(AMeshingTool):
logger.info(
f"! {self._exe_path()} " +
f"{st_file} {m_file} " +
+ f"mesh " +
f"{str(step)} " +
f"{limites[0]} {limites[1]} " +
f"{directrices[0]} {directrices[1]} " +
f"{lplan} {lm} {linear} " +
- f"mesh {origin}"
+ f"{origin} "
)
proc.start(
self._exe_path(),
@@ -332,11 +334,86 @@ class MeshingWithMageMailleurTT(AMeshingTool):
map(
str,
[
- st_file, m_file, step,
+ st_file, m_file,
+ "mesh", step,
limites[0], limites[1],
directrices[0], directrices[1],
- lplan, lm, linear,
- "mesh", origin
+ lplan, lm, linear, origin, origin_value
+ ]
+ )
+ )
+ )
+ proc.waitForFinished()
+
+ if proc.exitCode() != 0:
+ logger.error(
+ f"{logger_color_red()}" +
+ f"MailleurTT error: {proc.exitCode()}" +
+ f"{logger_color_reset()}"
+ )
+ outputs = proc.readAllStandardOutput()
+ logger.debug(outputs)
+
+ errors = proc.readAllStandardError()
+ logger.error(
+ f"{logger_color_red()}{errors}{logger_color_reset()}"
+ )
+ return reach
+
+ self.import_m_file(reach, m_file)
+ return reach
+
+ def update_kp(self, reach,
+ step: float = 50,
+ limites=[-1, -1],
+ origin=0,
+ directrices=['un', 'np'],
+ lplan: bool = False,
+ lm: int = 3,
+ linear: bool = False,
+ origin_value = 0.0):
+ if reach is None or len(reach.profiles) == 0:
+ return reach
+
+ with tempfile.TemporaryDirectory() as tmp:
+ logger.debug(f"temp file: {tmp}")
+ st_file = self.export_reach_to_st(reach, tmp)
+ m_file = st_file.rsplit(".ST", 1)[0] + ".M"
+
+ os.sync()
+
+ proc = QProcess()
+ proc.setWorkingDirectory(tmp)
+
+ # Mage section indices 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()} " +
+ f"{st_file} {m_file} " +
+ f"update_kp " +
+ f"{str(step)} " +
+ f"{limites[0]} {limites[1]} " +
+ f"{directrices[0]} {directrices[1]} " +
+ f"{lplan} {lm} {linear} " +
+ f"{origin} "
+ )
+ proc.start(
+ self._exe_path(),
+ list(
+ map(
+ str,
+ [
+ st_file, m_file,
+ "update_kp", step,
+ limites[0], limites[1],
+ directrices[0], directrices[1],
+ lplan, lm, linear, origin, origin_value
]
)
)
diff --git a/src/View/Geometry/MeshingDialog.py b/src/View/Geometry/MeshingDialog.py
index 7c7b385d..974aa187 100644
--- a/src/View/Geometry/MeshingDialog.py
+++ b/src/View/Geometry/MeshingDialog.py
@@ -68,17 +68,6 @@ class MeshingDialog(PamhyrDialog):
self._space_step
)
- lm_dict = self._trad.get_dict("lm_dict")
- self.combobox_add_items(
- "comboBox_lm", list(
- map(
- lambda x: lm_dict[x],
- ["1", "2", "3"]
- )
- )
- )
- self.set_combobox_text("comboBox_lm", lm_dict[self._lm])
-
if self._linear:
self.set_radio_button("radioButton_linear", True)
else:
@@ -89,7 +78,6 @@ 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])
@@ -120,8 +108,8 @@ class MeshingDialog(PamhyrDialog):
gl, _ = self._reach.compute_guidelines()
gl = list(gl)
- bgl = ['un'] + gl
- egl = gl + ['np']
+ bgl = ['un'] + gl + ['np']
+ egl = ['un'] + gl + ['np']
self.combobox_add_items("comboBox_begin_gl", bgl)
self.combobox_add_items("comboBox_end_gl", egl)
diff --git a/src/View/Geometry/Table.py b/src/View/Geometry/Table.py
index 26baa7fb..3c5db448 100644
--- a/src/View/Geometry/Table.py
+++ b/src/View/Geometry/Table.py
@@ -240,7 +240,19 @@ class GeometryReachTableModel(PamhyrTableModel):
self._undo.push(
MeshingCommand(
- self._data, mesher, data
+ self._data, mesher, data, "mesh"
+ )
+ )
+
+ self.layoutAboutToBeChanged.emit()
+ self.layoutChanged.emit()
+
+ def update_kp(self, mesher, data):
+ self.layoutAboutToBeChanged.emit()
+
+ self._undo.push(
+ MeshingCommand(
+ self._data, mesher, data, "update_kp"
)
)
diff --git a/src/View/Geometry/UndoCommand.py b/src/View/Geometry/UndoCommand.py
index e5d48885..f50299fc 100644
--- a/src/View/Geometry/UndoCommand.py
+++ b/src/View/Geometry/UndoCommand.py
@@ -222,12 +222,13 @@ class ImportCommand(QUndoCommand):
class MeshingCommand(QUndoCommand):
- def __init__(self, reach, mesher, data):
+ def __init__(self, reach, mesher, data, command):
QUndoCommand.__init__(self)
self._reach = reach
self._data = data
self._mesher = mesher
+ self._command = command
self._profiles = reach.profiles.copy()
self._profiles.reverse()
@@ -242,10 +243,16 @@ class MeshingCommand(QUndoCommand):
def redo(self):
if self._new_profiles is None:
- self._mesher.meshing(
- self._reach,
- **self._data
- )
+ if self._command == "update_kp":
+ self._mesher.update_kp(
+ self._reach,
+ **self._data
+ )
+ else:
+ self._mesher.meshing(
+ self._reach,
+ **self._data
+ )
self._new_profiles = self._reach.profiles.copy()
self._new_profiles.reverse()
diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py
index 302237a3..5e13a1dc 100644
--- a/src/View/Geometry/Window.py
+++ b/src/View/Geometry/Window.py
@@ -56,6 +56,7 @@ from View.Geometry.PlotXY import PlotXY
from View.Geometry.PlotAC import PlotAC
from View.Geometry.PlotKPZ import PlotKPZ
from View.Geometry.MeshingDialog import MeshingDialog
+from View.Geometry.UpdateKPDialog import UpdateKPDialog
from View.Geometry.Translate import GeometryTranslate
from View.Geometry.Profile.Window import ProfileWindow
@@ -321,10 +322,36 @@ class GeometryWindow(PamhyrWindow):
src_except=e
)
- pyqtSlot(bool)
+ def update_kp(self):
+ try:
+ dlg = UpdateKPDialog(
+ reach=self._reach,
+ trad=self._trad,
+ parent=self
+ )
+ if dlg.exec():
+ data = {
+ "origin": dlg.origin,
+ "directrices": [dlg.begin_dir, dlg.end_dir],
+ "origin_value": dlg.origin_value,
+ }
+ self._update_kp(data)
+ except Exception as e:
+ logger_exception(e)
+ return
- def changed_profile_slot(self, status):
- self.update_view1 = status
+ def _update_kp(self, data):
+ try:
+ mesher = MeshingWithMageMailleurTT()
+ self._table.update_kp(mesher, data)
+ except Exception as e:
+ logger_exception(e)
+ raise ExternFileMissingError(
+ module="mage",
+ filename="MailleurTT",
+ path=MeshingWithMageMailleurTT._path(),
+ src_except=e
+ )
def plot_xy(self):
self.tableView.model().blockSignals(True)
@@ -509,9 +536,6 @@ class GeometryWindow(PamhyrWindow):
self._table.move_down(row)
self.select_current_profile()
- def update_kp(self):
- pass
-
def purge(self):
self._table.purge()
self.update_redraw()
diff --git a/src/View/ui/MeshingOptions.ui b/src/View/ui/MeshingOptions.ui
index 01bd7a53..6ff87a52 100644
--- a/src/View/ui/MeshingOptions.ui
+++ b/src/View/ui/MeshingOptions.ui
@@ -6,8 +6,8 @@
0
0
- 608
- 342
+ 520
+ 341
@@ -108,78 +108,23 @@
- -
-
-
- Limits
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- First cross section
-
-
-
- -
-
-
- true
-
-
-
-
-
- -
-
-
-
-
-
- true
-
-
- Last cross section
-
-
-
- -
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
Distance computation
-
-
-
+
-
+
+
+ true
+
- Original section
+ Second guide-line
- -
-
-
- -
+
-
true
@@ -190,45 +135,69 @@
-
-
-
- true
-
-
-
- -
-
-
- true
-
-
- Second guide-line
-
-
-
- -
true
- -
-
+
-
+
true
-
- Takes
-
- -
-
-
- true
-
-
+
+
+
+ -
+
+
+ Limits
+
+
+
-
+
+
-
+
+
+ true
+
+
+ First cross section
+
+
+
+ -
+
+
+ true
+
+
+
+
+
+ -
+
+
-
+
+
+ true
+
+
+ Last cross section
+
+
+
+ -
+
+
+ true
+
+
+
+