This commit is contained in:
Theophile Terraz committed 2024-05-13 16:02:36 +02:00
commit 9d0168a9ee
28 files changed
+456 -139

No files matched your search

+1 -1
View File
@@ -129,7 +129,7 @@ class PlotAC(PamhyrPlot):
if txt.strip() in self.complete_gl:
color = self.color_complete_gl[
lcomplete.index(txt)
lcomplete.index(txt) % len(self.color_complete_gl)
]
else:
color = self.color_incomplete_gl[
+3 -1
View File
@@ -167,7 +167,9 @@ class PlotKPZ(PamhyrPlot):
self.line_kp_zgl.append(
self.canvas.axes.plot(
kp, z, lw=1., color=self.colors[ind]
kp, z, lw=1.,
color=self.colors[ind % len(self.colors)],
linestyle=self.linestyle[ind // len(self.colors)]
)
)
ind += 1
+2 -1
View File
@@ -130,7 +130,8 @@ class PlotXY(PamhyrPlot):
self.line_gl = []
for x, y in zip(x_complete, y_complete):
line = self.canvas.axes.plot(
x, y, color=self.colors[ind]
x, y, color=self.colors[ind % len(self.colors)],
linestyle=self.linestyle[ind // len(self.colors)]
)
self.line_gl.append(line)
ind += 1
+20
View File
@@ -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
+28
View File
@@ -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)
+24
View File
@@ -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:
@@ -146,6 +148,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)
@@ -153,6 +161,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()\
@@ -238,6 +254,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()
+9
View File
@@ -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()
+20
View File
@@ -254,3 +254,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)
+10 -1
View File
@@ -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)
@@ -507,6 +509,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