From a663dc482ce111582606fefb270c8adc4bbfd4a8 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Wed, 7 Feb 2024 17:09:50 +0100
Subject: [PATCH] Meshing: Add lplan and linear to meching options.

---
 src/Meshing/Mage.py              | 16 ++++++++++++----
 src/View/Geometry/Table.py       |  4 ++--
 src/View/Geometry/UndoCommand.py |  6 +++---
 src/View/Geometry/Window.py      | 16 ++++++++++------
 src/View/ui/MeshingOptions.ui    |  4 ++--
 5 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/src/Meshing/Mage.py b/src/Meshing/Mage.py
index e306bc9f..73684ad8 100644
--- a/src/Meshing/Mage.py
+++ b/src/Meshing/Mage.py
@@ -65,6 +65,10 @@ class MeshingWithMage(AMeshingTool):
             )
         )
 
+    @classmethod
+    def _path(cls):
+        return cls._exe_path()
+
     def _init_c_init_bief_from_geo_file(self):
         self._c_init_bief_from_geo_file = getattr(
             self._bief_lib, 'c_init_bief_from_geo_file'
@@ -278,6 +282,10 @@ class MeshingWithMageMailleurTT(AMeshingTool):
             )
         )
 
+    @classmethod
+    def _path(cls):
+        return cls._exe_path()
+
     ###########
     # Meshing #
     ###########
@@ -288,7 +296,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
                 directrices=['un', 'np'],
                 lplan: bool = False,
                 lm: int = 3,
-                lineaire: bool = False):
+                linear: bool = False):
         if reach is None or len(reach.profiles) == 0:
             return reach
 
@@ -301,14 +309,14 @@ class MeshingWithMageMailleurTT(AMeshingTool):
             proc.setWorkingDirectory(tmp)
 
             lplan = 1 if lplan else 0
-            lineaire = 1 if lineaire else 0
+            linear = 1 if linear else 0
 
             logger.info(
                 f"! mailleurTT {st_file} {m_file} " +
                 f"{str(step)} " +
                 f"{limites[0]} {limites[1]} " +
                 f"{directrices[0]} {directrices[1]} " +
-                f"{lplan} {lm} {lineaire}"
+                f"{lplan} {lm} {linear}"
             )
             proc.start(
                 self._exe_path(),
@@ -318,7 +326,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
                         st_file, m_file, step,
                         limites[0], limites[1],
                         directrices[0], directrices[1],
-                        lplan, lm, lineaire
+                        lplan, lm, linear
                     ]
                 ))
             )
diff --git a/src/View/Geometry/Table.py b/src/View/Geometry/Table.py
index cdad1671..e22d49d2 100644
--- a/src/View/Geometry/Table.py
+++ b/src/View/Geometry/Table.py
@@ -235,12 +235,12 @@ class GeometryReachTableModel(PamhyrTableModel):
         self.layoutAboutToBeChanged.emit()
         self.layoutChanged.emit()
 
-    def meshing(self, mesher, step):
+    def meshing(self, mesher, data):
         self.layoutAboutToBeChanged.emit()
 
         self._undo.push(
             MeshingCommand(
-                self._data, mesher, step
+                self._data, mesher, data
             )
         )
 
diff --git a/src/View/Geometry/UndoCommand.py b/src/View/Geometry/UndoCommand.py
index aafd2b50..335841c3 100644
--- a/src/View/Geometry/UndoCommand.py
+++ b/src/View/Geometry/UndoCommand.py
@@ -217,11 +217,11 @@ class ImportCommand(QUndoCommand):
 
 
 class MeshingCommand(QUndoCommand):
-    def __init__(self, reach, mesher, step):
+    def __init__(self, reach, mesher, data):
         QUndoCommand.__init__(self)
 
         self._reach = reach
-        self._step = step
+        self._data = data
         self._mesher = mesher
 
         self._profiles = reach.profiles.copy()
@@ -239,7 +239,7 @@ class MeshingCommand(QUndoCommand):
         if self._new_profiles is None:
             self._mesher.meshing(
                 self._reach,
-                step=self._step
+                **self._data
             )
 
             self._new_profiles = self._reach.profiles.copy()
diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py
index 7c35818e..94a3b3c4 100644
--- a/src/View/Geometry/Window.py
+++ b/src/View/Geometry/Window.py
@@ -263,21 +263,25 @@ class GeometryWindow(PamhyrWindow):
         try:
             dlg = MeshingDialog(parent=self)
             if dlg.exec():
-                step = dlg.space_step
-                self._edit_meshing(step)
+                data = {
+                    "step": dlg.space_step,
+                    "lplan": dlg.lplan,
+                    "linear": dlg.linear,
+                }
+                self._edit_meshing(data)
         except Exception as e:
             return
 
-    def _edit_meshing(self, step):
+    def _edit_meshing(self, data):
         try:
             mesher = MeshingWithMageMailleurTT()
-            self._table.meshing(mesher, step)
+            self._table.meshing(mesher, data)
         except Exception as e:
             logger_exception(e)
             raise ExternFileMissingError(
                 module="mage",
-                filename="libbief",
-                path=MeshingWithMage._lib_path(),
+                filename="MailleurTT",
+                path=MeshingWithMageMailleurTT._path(),
                 src_except=e
             )
 
diff --git a/src/View/ui/MeshingOptions.ui b/src/View/ui/MeshingOptions.ui
index 315a171e..1ad0514b 100644
--- a/src/View/ui/MeshingOptions.ui
+++ b/src/View/ui/MeshingOptions.ui
@@ -170,7 +170,7 @@
    <item row="4" column="0">
     <widget class="QCheckBox" name="checkBox_lplan">
      <property name="enabled">
-      <bool>false</bool>
+      <bool>true</bool>
      </property>
      <property name="text">
       <string>Lplan</string>
@@ -180,7 +180,7 @@
    <item row="5" column="0">
     <widget class="QCheckBox" name="checkBox_linear">
      <property name="enabled">
-      <bool>false</bool>
+      <bool>true</bool>
      </property>
      <property name="text">
       <string>Linear</string>
-- 
GitLab