debug Adis-TS

This commit is contained in:
Theophile Terraz committed 2025-01-16 14:16:24 +01:00
1 parent f75a25d010
commit 2e2f054a4f
10 files changed
+68 -57

No files matched your search

+1 -4
View File
@@ -90,9 +90,7 @@ class TableModel(PamhyrTableModel):
self.layoutAboutToBeChanged.emit()
self._undo.push(
PasteCommand(
self._data, row,
self._undo.push(PasteCommand(self._data, row,
list(
map(
lambda d: self._data.new_from_data(d),
@@ -102,5 +100,4 @@ class TableModel(PamhyrTableModel):
)
)
self.layoutAboutToBeChanged.emit()
self.layoutChanged.emit()
+24 -25
View File
@@ -31,36 +31,35 @@ logger = logging.getLogger()
class SetDataCommand(QUndoCommand):
def __init__(self, data, index, column, new_value):
QUndoCommand.__init__(self)
self._data = data
self._index = index
self._column = column
self._old = self._data.data[self._index][self._column]
self._new = new_value
def undo(self):
self._data.data[self._index][self._column] = self._old
def redo(self):
self._data.data[self._index][self._column] = self._new
class PasteCommand(QUndoCommand):
def __init__(self, data, row, hs):
def __init__(self, data, row, column, new_value):
QUndoCommand.__init__(self)
self._data = data
self._row = row
self._h = hs
self._h.reverse()
self._column = column
self._old = self._data.data[self._row][self._column]
self._new = new_value
def undo(self):
self._data.delete_i(
range(self._row, self._row + len(self._h))
)
self._data.data[self._row][self._column] = self._old
def redo(self):
for h in self._h:
self._data.insert(self._row, h)
self._data.data[self._row][self._column] = self._new
class PasteCommand(QUndoCommand):
def __init__(self, data, row, new_data):
QUndoCommand.__init__(self)
self._data = data
self._row = row
self._new = [n for n in new_data[row]]
self._old = [o for o in self._data.data[row]]
def undo(self):
for i in range(9):
self._data.data[self._row][i] = self._old[i]
def redo(self):
for i in range(9):
self._data.data[self._row][i] = self._new[i]
+1 -1
View File
@@ -129,7 +129,7 @@ class EditPolluantWindow(PamhyrWindow):
def _paste(self):
header, data = self.parseClipboardTable()
logger.debug(f"paste: h:{header}, d:{data}")
logger.debug(f"paste: header:{header}, data:{data}")
if len(data) == 0:
return
+1 -1
View File
@@ -103,7 +103,7 @@ class TableModel(PamhyrTableModel):
self._undo.push(
DelCommand(
self._lst, rows, self._data.initial_conditions_adists
self._lst, rows, self._data.ic_adists
)
)
+11 -12
View File
@@ -105,6 +105,7 @@ class PollutantsWindow(PamhyrWindow):
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_delete").setEnabled(False)
self.find(QAction, "action_delete").triggered.connect(self.delete)
self.find(QAction, "action_edit").triggered.connect(self.edit)
self.find(QAction, "action_initial_conditions"
@@ -154,11 +155,7 @@ class PollutantsWindow(PamhyrWindow):
)
def add(self):
rows = self.index_selected_rows()
if len(self._pollutants_lst) == 0 or len(rows) == 0:
self._table.add(0)
else:
self._table.add(rows[-1])
self._table.add(len(self._pollutants_lst))
def delete(self):
rows = self.index_selected_rows()
@@ -181,6 +178,9 @@ class PollutantsWindow(PamhyrWindow):
def edit(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
for row in rows:
data = self._pollutants_lst.get(row)
@@ -199,6 +199,8 @@ class PollutantsWindow(PamhyrWindow):
def initial_conditions(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
for row in rows:
pollutant_id = self._pollutants_lst.get(row).id
@@ -219,11 +221,7 @@ class PollutantsWindow(PamhyrWindow):
)
initial.show()
def boundary_conditions(self, tab=0):
rows = self.index_selected_rows()
for row in rows:
pollutant_id = self._pollutants_lst.get(row).id
def boundary_conditions(self):
if self.sub_window_exists(
BoundaryConditionAdisTSWindow,
@@ -242,9 +240,10 @@ class PollutantsWindow(PamhyrWindow):
def lateral_contrib(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
for row in rows:
pollutant_id = self._pollutants_lst.get(row).id
pollutant_id = self._pollutants_lst.get(rows[0]).id
if self.sub_window_exists(
LateralContributionAdisTSWindow,