mirror of https://gitlab.com/pamhyr/pamhyr2
debug Adis-TS
parent
f75a25d010
commit
2e2f054a4f
|
|
@ -177,5 +177,19 @@ class Pollutants(SQLSubModel):
|
|||
def is_define(self):
|
||||
return len(self._data) != 0
|
||||
|
||||
def new_from_data(self, data):
|
||||
|
||||
print("from_data before : ", data)
|
||||
try:
|
||||
new = [int(data[0])]
|
||||
new += [float(d) for d in data[1:-1]]
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
new = None
|
||||
|
||||
print("from_data after : ", new)
|
||||
|
||||
return new
|
||||
|
||||
def __len__(self):
|
||||
return len(self._data)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class Results(object):
|
|||
el.split("/")[-1][0:-4]
|
||||
for el in glob.glob(repertory_results + "/*.bin")
|
||||
]
|
||||
mylist.insert(0, mylist.pop(mylist.index("total_sediment")))
|
||||
|
||||
self._phys_var_list = ["C", "G", "M", "D", "L", "N", "R"]
|
||||
|
||||
|
|
|
|||
|
|
@ -181,13 +181,20 @@ class TableModel(PamhyrTableModel):
|
|||
)
|
||||
)
|
||||
elif self._headers[column] == "pol":
|
||||
pol = next(filter(lambda x: x.name == value,
|
||||
self._data._Pollutants.Pollutants_List))
|
||||
self._undo.push(
|
||||
SetPolCommand(
|
||||
self._lst, row, pol.id
|
||||
if value == self._trad["not_associated"]:
|
||||
self._undo.push(
|
||||
SetPolCommand(
|
||||
self._lst, row, None
|
||||
)
|
||||
)
|
||||
else:
|
||||
pol = next(filter(lambda x: x.name == value,
|
||||
self._data._Pollutants.Pollutants_List))
|
||||
self._undo.push(
|
||||
SetPolCommand(
|
||||
self._lst, row, pol.id
|
||||
)
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
logger.debug(traceback.format_exc())
|
||||
|
|
|
|||
|
|
@ -68,9 +68,8 @@ class SetPolCommand(QUndoCommand):
|
|||
|
||||
self._bcs = bcs
|
||||
self._index = index
|
||||
self._pollutant = pollutant
|
||||
self._old = self._bcs[self._index].pollutant
|
||||
self._new = self._pollutant
|
||||
self._new = pollutant
|
||||
|
||||
def undo(self):
|
||||
self._bcs[self._index].pollutant = self._old
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
|||
)
|
||||
|
||||
self._pollutants_lst = self._study._river._Pollutants
|
||||
|
||||
self._bcs = self._study.river.boundary_conditions_adists
|
||||
|
||||
self.setup_graph()
|
||||
|
|
@ -157,11 +156,7 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
|||
)
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(self._bcs) == 0 or len(rows) == 0:
|
||||
self._table.add(0)
|
||||
else:
|
||||
self._table.add(rows[0])
|
||||
self._table.add(len(self._bcs))
|
||||
|
||||
def delete(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue