Geometry: Make meshing method to undo command.

setup.py
Pierre-Antoine Rouby 2023-12-20 14:36:41 +01:00
parent eb65ce4c1b
commit 655982e908
3 changed files with 47 additions and 5 deletions

View File

@ -221,3 +221,15 @@ class GeometryReachTableModel(PamhyrTableModel):
self.layoutAboutToBeChanged.emit()
self.layoutChanged.emit()
def meshing(self, mesher, step):
self.layoutAboutToBeChanged.emit()
self._undo.push(
MeshingCommand(
self._data, mesher, step
)
)
self.layoutAboutToBeChanged.emit()
self.layoutChanged.emit()

View File

@ -25,6 +25,8 @@ from PyQt5.QtWidgets import (
from Model.Geometry import Reach
from Meshing.Mage import MeshingWithMage
class SetDataCommand(QUndoCommand):
def __init__(self, reach, index, old_value, new_value):
@ -187,3 +189,35 @@ class DuplicateCommand(QUndoCommand):
def redo(self):
for profile in self._profiles:
self._reach.insert_profile(self._rows[0], profile)
class MeshingCommand(QUndoCommand):
def __init__(self, reach, mesher, step):
QUndoCommand.__init__(self)
self._reach = reach
self._step = step
self._mesher = mesher
self._profiles = reach.profiles.copy()
self._profiles.reverse()
self._new_profiles = None
def undo(self):
self._reach.purge()
for profile in self._profiles:
self._reach.insert_profile(0, profile)
def redo(self):
if self._new_profiles is None:
self._mesher.meshing(self._reach)
self._new_profiles = self._reach.profiles.copy()
self._new_profiles.reverse()
else:
self._reach.purge()
for profile in self._new_profiles:
self._reach.insert_profile(0, profile)

View File

@ -247,12 +247,8 @@ class GeometryWindow(PamhyrWindow):
self.tableView.model().blockSignals(False)
def edit_meshing(self):
self.tableView.model().blockSignals(True)
mesher = MeshingWithMage()
mesher.meshing(self._reach)
self.tableView.model().blockSignals(False)
self._tablemodel.meshing(mesher, -1)
self.update_profile_windows()
self.plot_xy()