mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "d6f7755d12b8cdb1075e63826872eec3afef940e" and "0701531d3725db893d47c3dabfbde29b4b835c69" have entirely different histories.
d6f7755d12
...
0701531d37
|
|
@ -312,21 +312,19 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
status = data['status']
|
status = data['status']
|
||||||
nodes = data['nodes']
|
nodes = data['nodes']
|
||||||
scenario = data["scenario"]
|
scenario = data["scenario"]
|
||||||
pollutant = data.get("pollutant")
|
pollutant = data["pollutant"]
|
||||||
loaded = data['loaded_pid']
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
if scenario is None:
|
if scenario is None:
|
||||||
return new
|
return new
|
||||||
|
|
||||||
sql = (
|
table = execute(
|
||||||
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario "
|
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario " +
|
||||||
"FROM boundary_condition_adists " +
|
"FROM boundary_condition_adists " +
|
||||||
f"WHERE scenario = {scenario.id} "
|
f"WHERE scenario = {scenario.id} " +
|
||||||
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
|
||||||
|
f"AND pollutant = {pollutant.id} "
|
||||||
)
|
)
|
||||||
if pollutant is not None:
|
|
||||||
sql += f"AND pollutant = {pollutant.id} "
|
|
||||||
|
|
||||||
table = execute(sql)
|
|
||||||
|
|
||||||
if table is not None:
|
if table is not None:
|
||||||
for row in table:
|
for row in table:
|
||||||
|
|
@ -351,7 +349,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
bc.type = bc_type
|
bc.type = bc_type
|
||||||
|
|
||||||
bc.node = None
|
bc.node = None
|
||||||
if node != -1:
|
if row[3] != -1:
|
||||||
tmp = next(
|
tmp = next(
|
||||||
filter(
|
filter(
|
||||||
lambda n: n.id == node, nodes
|
lambda n: n.id == node, nodes
|
||||||
|
|
@ -515,10 +513,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
return (new_0, new_1)
|
return (new_0, new_1)
|
||||||
|
|
||||||
def add(self, index: int):
|
def add(self, index: int):
|
||||||
value = Data(
|
value = (self._default_0, self._default_1)
|
||||||
self._default_0, self._default_1,
|
|
||||||
status=self._status
|
|
||||||
)
|
|
||||||
self._data.insert(index, value)
|
self._data.insert(index, value)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
return value
|
return value
|
||||||
|
|
@ -559,9 +554,9 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
def _set_i_c_v(self, index, column, value):
|
def _set_i_c_v(self, index, column, value):
|
||||||
v = self._data[index]
|
v = list(self._data[index])
|
||||||
v[column] = self._types[column](value)
|
v[column] = self._types[column](value)
|
||||||
self._data[index] = v
|
self._data[index] = tuple(v)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
|
|
||||||
def set_i_0(self, index: int, value):
|
def set_i_0(self, index: int, value):
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,9 @@ class BoundaryConditionsAdisTSList(PamhyrModelList):
|
||||||
if data is None:
|
if data is None:
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
previous_pollutant = data.get("pollutant")
|
new._lst = BoundaryConditionAdisTS._db_load(
|
||||||
data.pop("pollutant", None)
|
execute, data
|
||||||
|
)
|
||||||
new._lst = BoundaryConditionAdisTS._db_load(execute, data)
|
|
||||||
|
|
||||||
if previous_pollutant is not None:
|
|
||||||
data["pollutant"] = previous_pollutant
|
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,9 @@ class AddCommand(QUndoCommand):
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._data.add(self._index)
|
self._new = self._data.insert(self._index, (
|
||||||
|
self._data._types[0](0), self._data._types[1](0.0)
|
||||||
|
))
|
||||||
else:
|
else:
|
||||||
self._data.insert(self._index, self._new)
|
self._data.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,25 +121,9 @@ class TableModel(PamhyrTableModel):
|
||||||
super(TableModel, self).__init__(trad=trad, **kwargs)
|
super(TableModel, self).__init__(trad=trad, **kwargs)
|
||||||
|
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = list(
|
self._lst = self._pollutant_bc_list.boundary_conditions_adists
|
||||||
filter(
|
|
||||||
lambda bc: bc.pollutant == self._pollutant,
|
|
||||||
self._bc_list.lst
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def get(self, row):
|
def rowCount(self, parent):
|
||||||
if row < 0 or row >= len(self._lst):
|
|
||||||
return None
|
|
||||||
return self._lst[row]
|
|
||||||
|
|
||||||
def _global_row(self, row):
|
|
||||||
bc = self.get(row)
|
|
||||||
if bc is None:
|
|
||||||
return None
|
|
||||||
return self._bc_list.index(bc)
|
|
||||||
|
|
||||||
def rowCount(self, parent=QModelIndex()):
|
|
||||||
return len(self._lst)
|
return len(self._lst)
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
|
|
@ -175,21 +159,15 @@ class TableModel(PamhyrTableModel):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._headers[column] == "type":
|
if self._headers[column] == "type":
|
||||||
global_row = self._global_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetTypeCommand(
|
SetTypeCommand(
|
||||||
self._bc_list, global_row, value
|
self._bc_list, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "node":
|
elif self._headers[column] == "node":
|
||||||
global_row = self._global_row(row)
|
|
||||||
node = next(
|
|
||||||
filter(lambda n: n.name == value, self._data.nodes()),
|
|
||||||
None
|
|
||||||
)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNodeCommand(
|
SetNodeCommand(
|
||||||
self._bc_list, global_row, node
|
self._bc_list, row, self._data.node(value)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -201,39 +179,33 @@ class TableModel(PamhyrTableModel):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
row = len(self._lst)
|
self.beginInsertRows(parent, row, row - 1)
|
||||||
self.beginInsertRows(parent, row, row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._pollutant, self._bc_list, len(self._bc_list)
|
self._pollutant, self._bc_list, row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._setup_lst()
|
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
|
|
||||||
global_rows = list(
|
|
||||||
map(self._global_row, rows)
|
|
||||||
)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._bc_list, global_rows
|
self._bc_list, rows
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._setup_lst()
|
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._undo.undo()
|
self._undo.undo()
|
||||||
self._setup_lst()
|
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._undo.redo()
|
self._undo.redo()
|
||||||
self._setup_lst()
|
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class SetNodeCommand(QUndoCommand):
|
||||||
self._bcs = bcs
|
self._bcs = bcs
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._bcs.get(self._index).node
|
self._old = self._bcs.get(self._index).node
|
||||||
self._new = node.id if node is not None else None
|
self._new = node.id
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._bcs.get(self._index).node = self._old
|
self._bcs.get(self._index).node = self._old
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
)
|
)
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
self._table.add(self._table.rowCount())
|
self._table.add(len(self._data.boundary_conditions_adists))
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
|
|
@ -183,7 +183,7 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
def edit(self):
|
def edit(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
data = self._table.get(row)
|
data = self._bcs.get(row)
|
||||||
|
|
||||||
if data.node is None:
|
if data.node is None:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class PlotRKZ(PlotRKC):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
def onpick(self, event):
|
def onpick(self, event):
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class PlotStricklers(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self, highlight=None):
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
self.label_x = self._trad["transverse_abscissa"]
|
self.label_x = self._trad["transverse_abscissa"]
|
||||||
self.label_y = self._trad["unit_elevation"]
|
self.label_y = self._trad["unit_elevation"]
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def river(self):
|
def river(self):
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.anotate_lst = []
|
self.anotate_lst = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class PlotDRK(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self, highlight=None):
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class PlotDischarge(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -925,9 +925,6 @@ class GraphWidget(QGraphicsView):
|
||||||
self.scale(scaleFactor, scaleFactor)
|
self.scale(scaleFactor, scaleFactor)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if self._only_display or self.graph._status.is_read_only():
|
|
||||||
return
|
|
||||||
|
|
||||||
pos = self.mapToScene(event.pos())
|
pos = self.mapToScene(event.pos())
|
||||||
self.clicked = True
|
self.clicked = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class PlotXY(PamhyrPlot):
|
||||||
self._isometric_axis = True
|
self._isometric_axis = True
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = False
|
self._autoscale_update = True
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue