mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Make meshing method to undo command.
parent
eb65ce4c1b
commit
655982e908
|
|
@ -221,3 +221,15 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.layoutChanged.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()
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ from PyQt5.QtWidgets import (
|
||||||
|
|
||||||
from Model.Geometry import Reach
|
from Model.Geometry import Reach
|
||||||
|
|
||||||
|
from Meshing.Mage import MeshingWithMage
|
||||||
|
|
||||||
|
|
||||||
class SetDataCommand(QUndoCommand):
|
class SetDataCommand(QUndoCommand):
|
||||||
def __init__(self, reach, index, old_value, new_value):
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
|
@ -187,3 +189,35 @@ class DuplicateCommand(QUndoCommand):
|
||||||
def redo(self):
|
def redo(self):
|
||||||
for profile in self._profiles:
|
for profile in self._profiles:
|
||||||
self._reach.insert_profile(self._rows[0], profile)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -247,12 +247,8 @@ class GeometryWindow(PamhyrWindow):
|
||||||
self.tableView.model().blockSignals(False)
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
def edit_meshing(self):
|
def edit_meshing(self):
|
||||||
self.tableView.model().blockSignals(True)
|
|
||||||
|
|
||||||
mesher = MeshingWithMage()
|
mesher = MeshingWithMage()
|
||||||
mesher.meshing(self._reach)
|
self._tablemodel.meshing(mesher, -1)
|
||||||
|
|
||||||
self.tableView.model().blockSignals(False)
|
|
||||||
|
|
||||||
self.update_profile_windows()
|
self.update_profile_windows()
|
||||||
self.plot_xy()
|
self.plot_xy()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue