mirror of https://gitlab.com/pamhyr/pamhyr2
debug IC import
parent
6c8a2013d9
commit
0569425df1
|
|
@ -38,7 +38,7 @@ from View.Tools.PamhyrTable import PamhyrTableModel
|
|||
from View.InitialConditions.UndoCommand import (
|
||||
SetCommand, AddCommand, DelCommand,
|
||||
SortCommand, MoveCommand, InsertCommand,
|
||||
DuplicateCommand, GenerateCommand,
|
||||
DuplicateCommand, GenerateCommand, ReplaceDataCommand,
|
||||
)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
|
@ -267,8 +267,8 @@ class InitialConditionTableModel(PamhyrTableModel):
|
|||
)
|
||||
|
||||
self._undo.push(
|
||||
InsertCommand(
|
||||
self._lst, index,
|
||||
ReplaceDataCommand(
|
||||
self._lst,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._lst.new_from_data(*d),
|
||||
|
|
|
|||
|
|
@ -198,3 +198,25 @@ class GenerateCommand(QUndoCommand):
|
|||
self._param[1],
|
||||
self._option,
|
||||
self._param[2])
|
||||
|
||||
|
||||
class ReplaceDataCommand(QUndoCommand):
|
||||
def __init__(self, ics, new_data):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._ics = ics
|
||||
self._copy = self._ics.data
|
||||
self._new_data = new_data
|
||||
self._rows = list(range(len(ics.data)))
|
||||
self._new_rows = list(range(len(new_data)))
|
||||
|
||||
def undo(self):
|
||||
self._ics.delete_i(self._new_rows)
|
||||
for row, el in enumerate(self._copy):
|
||||
self._ics.insert(row, el)
|
||||
|
||||
def redo(self):
|
||||
self._ics.delete_i(self._rows)
|
||||
for row, el in enumerate(self._new_data):
|
||||
self._ics.insert(row, el)
|
||||
|
||||
|
|
|
|||
|
|
@ -276,11 +276,14 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||
.replace(".BIN", "")
|
||||
|
||||
def reading():
|
||||
self._tmp_results = solver.results(
|
||||
self._study,
|
||||
os.path.dirname(file_name),
|
||||
name=name
|
||||
)
|
||||
try:
|
||||
self._tmp_results = solver.results(
|
||||
self._study,
|
||||
os.path.dirname(file_name),
|
||||
name=name
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
dlg = ReadingResultsDialog(
|
||||
reading_fn=reading,
|
||||
|
|
|
|||
Loading…
Reference in New Issue