mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
add purge in profile and geometry
This commit is contained in:
1 parent
5164891928
commit
5790bdfe82
12 files changed
+217
-28
No files matched your search
@@ -250,6 +250,26 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||
self.endMoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def purge(self):
|
||||
|
||||
self._undo.push(
|
||||
PurgeCommand(
|
||||
self._data, 24
|
||||
)
|
||||
)
|
||||
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def reverse(self):
|
||||
|
||||
self._undo.push(
|
||||
ReverseCommand(
|
||||
self._data
|
||||
)
|
||||
)
|
||||
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def paste(self, row, header, data):
|
||||
if row > self._data.number_points:
|
||||
return
|
||||
|
||||
@@ -169,6 +169,34 @@ class MoveCommand(QUndoCommand):
|
||||
self._profile.move_down_point(self._i)
|
||||
|
||||
|
||||
class ReverseCommand(QUndoCommand):
|
||||
def __init__(self, profile):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._profile = profile
|
||||
|
||||
def undo(self):
|
||||
self._profile.reverse()
|
||||
|
||||
def redo(self):
|
||||
self._profile.reverse()
|
||||
|
||||
|
||||
class PurgeCommand(QUndoCommand):
|
||||
def __init__(self, profile, np_purge):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._profile = profile
|
||||
self._old = self._profile.points.copy()
|
||||
self._np_purge = np_purge
|
||||
|
||||
def undo(self):
|
||||
self._profile._points = self._old.copy()
|
||||
|
||||
def redo(self):
|
||||
self._profile.purge(self._np_purge)
|
||||
|
||||
|
||||
class PasteCommand(QUndoCommand):
|
||||
def __init__(self, profile, row, points):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -125,6 +125,8 @@ class ProfileWindow(PamhyrWindow):
|
||||
"action_down": self.move_down,
|
||||
"action_add": self.add,
|
||||
"action_delete": self.delete,
|
||||
"action_purge": self.purge,
|
||||
"action_reverse": self.reverse,
|
||||
}
|
||||
|
||||
for action in actions:
|
||||
@@ -137,6 +139,12 @@ class ProfileWindow(PamhyrWindow):
|
||||
self.update_plot()
|
||||
self._propagate_update(key=Modules.GEOMETRY)
|
||||
|
||||
def _update(self, redraw=False, propagate=True):
|
||||
if redraw:
|
||||
self.update_plot()
|
||||
if propagate:
|
||||
self._propagate_update(key=Modules.GEOMETRY)
|
||||
|
||||
def update_plot(self):
|
||||
self._tablemodel.blockSignals(True)
|
||||
|
||||
@@ -145,6 +153,14 @@ class ProfileWindow(PamhyrWindow):
|
||||
|
||||
self._tablemodel.blockSignals(False)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.GEOMETRY not in key:
|
||||
return
|
||||
|
||||
print("=====TOTO=====")
|
||||
self._tablemodel.layoutChanged.emit()
|
||||
self._update(redraw=True, propagate=False)
|
||||
|
||||
def index_selected_row(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
rows = table.selectionModel()\
|
||||
@@ -221,6 +237,14 @@ class ProfileWindow(PamhyrWindow):
|
||||
|
||||
self.update()
|
||||
|
||||
def purge(self):
|
||||
self._tablemodel.purge()
|
||||
self.update()
|
||||
|
||||
def reverse(self):
|
||||
self._tablemodel.reverse()
|
||||
self.update()
|
||||
|
||||
def _copy(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
rows = table.selectionModel().selectedRows()
|
||||
|
||||
@@ -246,3 +246,12 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def purge(self):
|
||||
|
||||
self._undo.push(
|
||||
PurgeCommand(
|
||||
self._data, 24
|
||||
)
|
||||
)
|
||||
self.layoutChanged.emit()
|
||||
@@ -249,3 +249,23 @@ class MeshingCommand(QUndoCommand):
|
||||
|
||||
for profile in self._new_profiles:
|
||||
self._reach.insert_profile(0, profile)
|
||||
|
||||
|
||||
class PurgeCommand(QUndoCommand):
|
||||
def __init__(self, reach, np_purge):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._reach = reach
|
||||
self._np_purge = np_purge
|
||||
|
||||
self._old = []
|
||||
for profile in self._reach.profiles:
|
||||
self._old.append(profile.points.copy())
|
||||
|
||||
def undo(self):
|
||||
for i in range(self._reach.number_profiles):
|
||||
self._reach.profiles[i]._points = self._old[i].copy()
|
||||
|
||||
def redo(self):
|
||||
for profile in self._reach._profiles:
|
||||
profile.purge(self._np_purge)
|
||||
@@ -188,6 +188,8 @@ class GeometryWindow(PamhyrWindow):
|
||||
"action_delete": self.delete,
|
||||
"action_edit": self.edit_profile,
|
||||
"action_meshing": self.edit_meshing,
|
||||
"action_update_kp": self.update_kp,
|
||||
"action_purge": self.purge,
|
||||
}
|
||||
|
||||
for action in actions:
|
||||
@@ -227,7 +229,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._propagate_update(key=Modules.GEOMETRY)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.NETWORK not in key:
|
||||
if Modules.NETWORK not in key and Modules.GEOMETRY not in key:
|
||||
return
|
||||
|
||||
self._update(propagate=False)
|
||||
@@ -505,6 +507,13 @@ 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()
|
||||
|
||||
def duplicate(self):
|
||||
rows = [
|
||||
row.row() for row in
|
||||
|
||||
Reference in new issue
Block a user