mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
merge master
This commit is contained in:
commit
c3d732b426
106 files changed
+61703
-430
No files matched your search
@@ -55,7 +55,7 @@ class AboutWindow(PamhyrDialog):
|
||||
|
||||
label = self.get_label_text("label_version")
|
||||
label = label.replace("@version", version)
|
||||
label = label.replace("@codename", "(Tahiti)")
|
||||
label = label.replace("@codename", "(Adis-TS)")
|
||||
self.set_label_text("label_version", label)
|
||||
|
||||
# Authors
|
||||
|
||||
@@ -88,13 +88,13 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
self.setup_connections()
|
||||
|
||||
def setup_table(self):
|
||||
table_headers = self._trad.get_dict("table_headers")
|
||||
if self._data.type == "Concentration":
|
||||
self._data.header = ["time", "concentration"]
|
||||
else:
|
||||
self._data.header = ["time", "rate"]
|
||||
self._data.header = ["time", "mass"]
|
||||
|
||||
headers = {}
|
||||
table_headers = self._trad.get_dict("table_headers")
|
||||
for h in self._data.header:
|
||||
headers[h] = table_headers[h]
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ class BCETranslate(BCTranslate):
|
||||
super(BCETranslate, self).__init__()
|
||||
|
||||
self._dict["Edit Boundary Conditions AdisTS"] = _translate(
|
||||
"BoundaryConditionAdisTS", "Edit boundary conditions AdisTS"
|
||||
"BoundaryConditionsAdisTS", "Edit boundary conditions AdisTS"
|
||||
)
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"time": self._dict["time"],
|
||||
"date": self._dict["date"],
|
||||
"rate": _translate("BoundaryConditionAdisTS", "Rate"),
|
||||
"concentration": _translate("BoundaryConditionAdisTS",
|
||||
"mass": _translate("BoundaryConditionsAdisTS", "Mass"),
|
||||
"concentration": _translate("BoundaryConditionsAdisTS",
|
||||
"Concentration"),
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
if self._mode == "type":
|
||||
lst = [self._trad["not_associated"], "Concentration", "Rate"]
|
||||
lst = [self._trad["not_associated"], "Concentration", "Mass"]
|
||||
self.editor.addItems(
|
||||
lst
|
||||
)
|
||||
@@ -146,8 +146,7 @@ class TableModel(PamhyrTableModel):
|
||||
n = data[row].node
|
||||
if n is None:
|
||||
return self._trad["not_associated"]
|
||||
tmp = next(filter(lambda x: x.id == n, self._data._nodes),
|
||||
None)
|
||||
tmp = next(filter(lambda x: x.id == n, self._data._nodes), None)
|
||||
if tmp is not None:
|
||||
return tmp.name
|
||||
else:
|
||||
@@ -156,7 +155,14 @@ class TableModel(PamhyrTableModel):
|
||||
n = data[row].pollutant
|
||||
if n is None or n == "not_associated" or n == "":
|
||||
return self._trad["not_associated"]
|
||||
return self._data._Pollutants.Pollutants_List[n].name
|
||||
tmp = next(filter(lambda x: x.id == n,
|
||||
self._data._Pollutants.Pollutants_List
|
||||
),
|
||||
None)
|
||||
if tmp is not None:
|
||||
return tmp.name
|
||||
else:
|
||||
return self._trad["not_associated"]
|
||||
|
||||
return QVariant()
|
||||
|
||||
@@ -181,13 +187,21 @@ 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()
|
||||
|
||||
@@ -187,7 +187,6 @@ class DIFTableModel(PamhyrTableModel):
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "reach":
|
||||
print(self._river.edge(value).id)
|
||||
self._undo.push(
|
||||
SetCommandSpec(
|
||||
self._lst,
|
||||
|
||||
@@ -287,9 +287,7 @@ class DIFAdisTSWindow(PamhyrWindow):
|
||||
self._table_spec.add(rows[0])
|
||||
|
||||
def delete(self):
|
||||
print("del")
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
print("len 0")
|
||||
return
|
||||
self._table_spec.delete(rows)
|
||||
@@ -66,11 +66,9 @@ class Plot(PamhyrPlot):
|
||||
self._isometric_axis = False
|
||||
|
||||
self.hl_points = []
|
||||
self.highlight = (
|
||||
[], # Points list to highlight
|
||||
None # Hydrolic values (z, wet_area,
|
||||
# wet_preimeter, water_width)
|
||||
)
|
||||
self.highlight = None # (z, wet_area, wet_preimeter, water_width)
|
||||
self._colors = []
|
||||
|
||||
self._onpickevent = None
|
||||
self._rect_select = RectangleSelector(
|
||||
ax=self.canvas.axes,
|
||||
@@ -87,36 +85,25 @@ class Plot(PamhyrPlot):
|
||||
# we need to do that to prevent conflicst
|
||||
# between onpick and rect_select_callback
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
points, hyd = self.highlight
|
||||
if self._onpickevent is not None:
|
||||
ind, point = self._closest_point(self._onpickevent)
|
||||
if modifiers == Qt.ControlModifier:
|
||||
rows = self._parent.index_selected_rows()
|
||||
if ind in rows:
|
||||
rows.remove(ind)
|
||||
del (points[ind])
|
||||
self.highlight = (points, hyd)
|
||||
self._select_in_table(rows)
|
||||
else:
|
||||
self.highlight = (points+[point], hyd)
|
||||
self._select_in_table(rows+[ind])
|
||||
elif modifiers == Qt.ShiftModifier:
|
||||
rows = self._parent.index_selected_rows()
|
||||
if len(rows) > 0:
|
||||
i1 = min(rows[0], rows[-1], ind)
|
||||
i2 = max(rows[0], rows[-1], ind)
|
||||
p = [
|
||||
[self.data.points[i].x, self.data.points[i].y]
|
||||
for i in range(i1, i2)
|
||||
]
|
||||
else:
|
||||
i1 = ind
|
||||
i2 = ind
|
||||
p = [point]
|
||||
self.highlight = (p, hyd)
|
||||
self._select_range_in_table(i1, i2)
|
||||
else:
|
||||
self.highlight = ([point], hyd)
|
||||
self._select_in_table([ind])
|
||||
|
||||
self._onpickevent = None
|
||||
@@ -142,41 +129,26 @@ class Plot(PamhyrPlot):
|
||||
if event.button.value == 1:
|
||||
return
|
||||
|
||||
points, _ = self.highlight
|
||||
|
||||
z = self._get_z_from_click(event)
|
||||
if z < self.data.z_min() or event.button.value == 2:
|
||||
self.highlight = (points, None)
|
||||
self.update()
|
||||
self.highlight = None
|
||||
self.draw_highligth()
|
||||
self.update_idle()
|
||||
return
|
||||
|
||||
a, p, w = self._compute_hydraulics(z)
|
||||
|
||||
logger.debug(f"{z, a, p, w}")
|
||||
|
||||
self.highlight = (points, (z, a, p, w))
|
||||
self.highlight = (z, a, p, w)
|
||||
|
||||
self.update()
|
||||
self.draw_highligth()
|
||||
self.update_idle()
|
||||
return
|
||||
|
||||
def select_points_from_indices(self, indices):
|
||||
data = self.data
|
||||
_, hyd = self.highlight
|
||||
|
||||
points = list(
|
||||
map(
|
||||
lambda e: e[1],
|
||||
filter(
|
||||
lambda e: e[0] in indices,
|
||||
enumerate(
|
||||
zip(data.get_station(), data.z())
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.highlight = (points, hyd)
|
||||
self.update()
|
||||
self.draw_highligth()
|
||||
# self.update()
|
||||
|
||||
def _select_in_table(self, ind):
|
||||
if self._table is not None:
|
||||
@@ -224,11 +196,6 @@ class Plot(PamhyrPlot):
|
||||
|
||||
x = event.artist.get_xdata()
|
||||
y = event.artist.get_ydata()
|
||||
|
||||
# points = filter(
|
||||
# lambda e: e[0] in points_ind,
|
||||
# enumerate(zip(x, y))
|
||||
# )
|
||||
points = enumerate(zip(x, y))
|
||||
|
||||
mx = event.mouseevent.xdata
|
||||
@@ -250,7 +217,7 @@ class Plot(PamhyrPlot):
|
||||
|
||||
def rect_select_callback(self, eclick, erelease):
|
||||
|
||||
points, hyd = self.highlight
|
||||
hyd = self.highlight
|
||||
x1, y1 = eclick.xdata, eclick.ydata
|
||||
x2, y2 = erelease.xdata, erelease.ydata
|
||||
|
||||
@@ -268,14 +235,13 @@ class Plot(PamhyrPlot):
|
||||
if all(i in rows for i in inds):
|
||||
for ind in sorted(inds, reverse=True):
|
||||
rows.remove(ind)
|
||||
del (points[ind])
|
||||
self.highlight = (points, hyd)
|
||||
self.highlight = hyd
|
||||
self._select_in_table(rows)
|
||||
else:
|
||||
self.highlight = (points+points2, hyd)
|
||||
self.highlight = hyd
|
||||
self._select_in_table(rows+inds)
|
||||
else:
|
||||
self.highlight = (points2, hyd)
|
||||
self.highlight = hyd
|
||||
self._select_in_table(inds)
|
||||
return
|
||||
|
||||
@@ -319,13 +285,16 @@ class Plot(PamhyrPlot):
|
||||
picker=10
|
||||
)
|
||||
|
||||
self.draw_annotation(x, y)
|
||||
self.draw_annotation()
|
||||
self.highlight = None
|
||||
self.draw_highligth()
|
||||
|
||||
self.idle()
|
||||
|
||||
def draw_annotation(self, x, y):
|
||||
def draw_annotation(self):
|
||||
gl = map(lambda p: p.name, self.data.points)
|
||||
x = self.data.get_station()
|
||||
y = self.data.z()
|
||||
|
||||
# Add label on graph
|
||||
self.annotation = []
|
||||
@@ -363,16 +332,18 @@ class Plot(PamhyrPlot):
|
||||
self.canvas.figure.patch.set_facecolor('white')
|
||||
|
||||
def draw_highligth(self):
|
||||
points, hyd = self.highlight
|
||||
hyd = self.highlight
|
||||
for p in self.hl_points:
|
||||
p[0].set_data([], [])
|
||||
|
||||
self.hl_points = []
|
||||
x = self.data.get_station()
|
||||
y = self.data.z()
|
||||
|
||||
for x, y in points:
|
||||
for i in self._parent.index_selected_rows():
|
||||
self.hl_points.append(
|
||||
self.canvas.axes.plot(
|
||||
x, y,
|
||||
x[i], y[i],
|
||||
color=self.color_plot_highlight,
|
||||
lw=1.5, markersize=7, marker='+',
|
||||
)
|
||||
@@ -383,8 +354,9 @@ class Plot(PamhyrPlot):
|
||||
else:
|
||||
if self._z_note is not None:
|
||||
self._z_note.set_visible(False)
|
||||
self._z_line[0].set_visible(False)
|
||||
self._z_line.set_visible(False)
|
||||
self._z_fill_between.set_visible(False)
|
||||
self.idle()
|
||||
|
||||
def draw_highligth_z_line(self, z, a, p, w):
|
||||
text = (
|
||||
@@ -396,40 +368,37 @@ class Plot(PamhyrPlot):
|
||||
|
||||
x = self.data.get_station()
|
||||
xlim = (x[0], x[-1])
|
||||
ylim = self.canvas.axes.get_ylim()
|
||||
pos = (
|
||||
xlim[0] + (abs(xlim[0] - xlim[1]) * 0.05),
|
||||
z + 0.8
|
||||
z + + (abs(ylim[0] - ylim[1]) * 0.08)
|
||||
)
|
||||
y = self.data.z()
|
||||
|
||||
if self._z_note is None:
|
||||
self.draw_highligth_z_line_fill(x, y, z)
|
||||
if self._z_note is not None:
|
||||
self._z_note.remove()
|
||||
if self._z_line is not None:
|
||||
self._z_line.remove()
|
||||
self.draw_highligth_z_line_fill(x, y, z)
|
||||
|
||||
self._z_line = self.canvas.axes.plot(
|
||||
xlim, [z, z],
|
||||
color=self.color_plot_river_water
|
||||
)
|
||||
self._z_line[0].set_visible(True)
|
||||
self._z_line, = self.canvas.axes.plot(
|
||||
xlim, [z, z],
|
||||
color=self.color_plot_river_water
|
||||
)
|
||||
self._z_line.set_visible(True)
|
||||
self._z_fill_between.set_visible(True)
|
||||
|
||||
self._z_note = self.canvas.axes.annotate(
|
||||
text, pos,
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top',
|
||||
annotation_clip=True,
|
||||
color=self.color_plot_river_water,
|
||||
fontsize=9,
|
||||
fontweight='bold',
|
||||
alpha=0.7
|
||||
)
|
||||
self._z_note.set_visible(True)
|
||||
else:
|
||||
self.draw_highligth_z_line_fill(x, y, z)
|
||||
|
||||
self._z_line[0].set_data(xlim, [z, z])
|
||||
self._z_note.set_position(pos)
|
||||
self._z_note.set_text(text)
|
||||
self._z_line[0].set_visible(True)
|
||||
self._z_note.set_visible(True)
|
||||
self._z_note = self.canvas.axes.annotate(
|
||||
text, pos,
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top',
|
||||
annotation_clip=True,
|
||||
color=self.color_plot_river_water,
|
||||
fontsize=9,
|
||||
fontweight='bold',
|
||||
alpha=0.7
|
||||
)
|
||||
self._z_note.set_visible(True)
|
||||
|
||||
def draw_highligth_z_line_fill(self, x, y, z):
|
||||
if self._z_fill_between is not None:
|
||||
@@ -444,6 +413,6 @@ class Plot(PamhyrPlot):
|
||||
|
||||
@timer
|
||||
def update(self):
|
||||
self.draw_highligth()
|
||||
self.draw()
|
||||
|
||||
self.update_idle()
|
||||
@@ -42,9 +42,11 @@ class SetXCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).x = self._old
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).x = self._new
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class SetYCommand(SetDataCommand):
|
||||
@@ -54,9 +56,11 @@ class SetYCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).y = self._old
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).y = self._new
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class SetZCommand(SetDataCommand):
|
||||
@@ -66,9 +70,11 @@ class SetZCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).z = self._old
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).z = self._new
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class SetNameCommand(SetDataCommand):
|
||||
@@ -94,12 +100,14 @@ class AddCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.delete_i([self._index])
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
if self._point is None:
|
||||
self._point = self._profile.insert(self._index)
|
||||
else:
|
||||
self._profile.insert_point(self._index, self._point)
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
@@ -117,9 +125,11 @@ class DelCommand(QUndoCommand):
|
||||
def undo(self):
|
||||
for row, point in self._points:
|
||||
self._profile.insert_point(row, point)
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.delete_i(self._rows)
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
@@ -143,9 +153,11 @@ class SortCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.sort_with_indexes(self._indexes)
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.sort(self._column, self._reverse)
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class MoveCommand(QUndoCommand):
|
||||
@@ -161,12 +173,14 @@ class MoveCommand(QUndoCommand):
|
||||
self._profile.move_up_point(self._i)
|
||||
else:
|
||||
self._profile.move_down_point(self._i)
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
if self._up:
|
||||
self._profile.move_up_point(self._i)
|
||||
else:
|
||||
self._profile.move_down_point(self._i)
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class ReverseCommand(QUndoCommand):
|
||||
@@ -177,9 +191,11 @@ class ReverseCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.reverse()
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.reverse()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class PurgeCommand(QUndoCommand):
|
||||
@@ -192,9 +208,11 @@ class PurgeCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile._points = self._old.copy()
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.purge(self._np_purge)
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class PasteCommand(QUndoCommand):
|
||||
@@ -210,7 +228,9 @@ class PasteCommand(QUndoCommand):
|
||||
def undo(self):
|
||||
for ind in range(len(self._points)):
|
||||
self._profile.delete_i([self._row])
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
for point in self._points:
|
||||
self._profile.insert_point(self._row, point)
|
||||
self._profile.modified()
|
||||
@@ -63,7 +63,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
reach_id = self._ic_spec_lst[index.row()].reach
|
||||
|
||||
reach = next(filter(lambda edge: edge.id == reach_id,
|
||||
self._data.edges()))
|
||||
self._data.edges()), None)
|
||||
|
||||
if reach_id is not None:
|
||||
val = list(
|
||||
|
||||
@@ -28,7 +28,7 @@ class LCTranslate(MainTranslate):
|
||||
super(LCTranslate, self).__init__()
|
||||
|
||||
self._dict["Lateral contribution AdisTS"] = _translate(
|
||||
"LateralContribution1adisTS", "Lateral contribution AdisTS"
|
||||
"LateralContributionAdisTS", "Lateral contribution AdisTS"
|
||||
)
|
||||
|
||||
self._sub_dict["long_types"] = {
|
||||
|
||||
@@ -194,10 +194,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
title = "(dbg) " if self.conf.debug else ""
|
||||
|
||||
if self._study is not None:
|
||||
title += f"Pamhyr2 (Tahiti 🌴) - {self._study.name}"
|
||||
title += f"Pamhyr2 - {self._study.name}"
|
||||
self.setWindowTitle(title)
|
||||
else:
|
||||
title += "Pamhyr2 (Tahiti 🌴)"
|
||||
title += "Pamhyr2"
|
||||
self.setWindowTitle(title)
|
||||
|
||||
def setup_tab(self):
|
||||
|
||||
@@ -90,17 +90,14 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(d),
|
||||
data
|
||||
)
|
||||
)
|
||||
self._undo.push(PasteCommand(self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(d),
|
||||
data
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
@@ -35,7 +35,7 @@ class EditPollutantTranslate(PollutantsTranslate):
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"type": self._dict["type"],
|
||||
"diametre": self._dict["unit_area"],
|
||||
"diameter": self._dict["unit_diameter"],
|
||||
"rho": self._dict["unit_rho"],
|
||||
"porosity": self._dict["unit_porosity"],
|
||||
"cdc_riv": self._dict["unit_cdc_riv"],
|
||||
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -101,7 +101,9 @@ class DelCommand(QUndoCommand):
|
||||
|
||||
for row in rows:
|
||||
self._pollutants.append((row, self._pollutants_lst.get(row)))
|
||||
self._inc_pollutants.append((row, self._inc_pollutants_lst))
|
||||
self._inc_pollutants.append(
|
||||
(row, self._inc_pollutants_lst.get(row))
|
||||
)
|
||||
self._pollutants.sort()
|
||||
self._inc_pollutants.sort()
|
||||
|
||||
|
||||
@@ -154,11 +154,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 +177,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,12 +198,15 @@ 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
|
||||
|
||||
iclist = self._study.river.ic_adists.Initial_Conditions_List
|
||||
ics_adists = next(filter(lambda x: x.pollutant == pollutant_id,
|
||||
self._study.river.ic_adists.lst))
|
||||
iclist))
|
||||
|
||||
if self.sub_window_exists(
|
||||
InitialConditionsAdisTSWindow,
|
||||
@@ -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,
|
||||
|
||||
@@ -66,7 +66,7 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog):
|
||||
self._envelop = []
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_x")
|
||||
self._envelop = QCheckBox(
|
||||
"envelop",
|
||||
self._trad["envelop"],
|
||||
parent=self
|
||||
)
|
||||
layout.addWidget(self._envelop)
|
||||
|
||||
@@ -188,6 +188,12 @@ class CustomPlot(PamhyrPlot):
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
v = list(
|
||||
map(
|
||||
lambda p: p.get_ts_key(self._timestamp, "V"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
shift = 0
|
||||
compt = 0
|
||||
@@ -328,14 +334,6 @@ class CustomPlot(PamhyrPlot):
|
||||
if "velocity" in self._y:
|
||||
|
||||
ax = self._axes[unit["velocity"]]
|
||||
v = list(
|
||||
map(
|
||||
lambda p: p.geometry.speed(
|
||||
p.get_ts_key(self._timestamp, "Q"),
|
||||
p.get_ts_key(self._timestamp, "Z")),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
line = ax.plot(
|
||||
rk, v, lw=1.,
|
||||
@@ -345,12 +343,10 @@ class CustomPlot(PamhyrPlot):
|
||||
|
||||
if self._envelop:
|
||||
|
||||
velocities = list(map(
|
||||
lambda p: list(map(
|
||||
lambda q, z:
|
||||
p.geometry.speed(q, z),
|
||||
p.get_key("Q"), p.get_key("Z")
|
||||
)), reach.profiles
|
||||
velocities = list(
|
||||
map(
|
||||
lambda p: p.get_key("V"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
@@ -441,9 +437,7 @@ class CustomPlot(PamhyrPlot):
|
||||
fr = list(
|
||||
map(
|
||||
lambda p:
|
||||
p.geometry.speed(
|
||||
p.get_ts_key(self._timestamp, "Q"),
|
||||
p.get_ts_key(self._timestamp, "Z")) /
|
||||
p.get_ts_key(self._timestamp, "V") /
|
||||
sqrt(9.81 * (
|
||||
p.geometry.wet_area(
|
||||
p.get_ts_key(self._timestamp, "Z")) /
|
||||
@@ -507,6 +501,12 @@ class CustomPlot(PamhyrPlot):
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
v = list(
|
||||
map(
|
||||
lambda p: p.get_ts_key(self._timestamp, "V"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
if "bed_elevation" in self._y:
|
||||
self.lines["bed_elevation"][0].set_ydata(z_min)
|
||||
|
||||
@@ -525,15 +525,7 @@ class CustomPlot(PamhyrPlot):
|
||||
self.lines["discharge"][0].set_ydata(q)
|
||||
|
||||
if "velocity" in self._y:
|
||||
v = list(
|
||||
map(
|
||||
lambda p: p.geometry.speed(
|
||||
p.get_ts_key(self._timestamp, "Q"),
|
||||
p.get_ts_key(self._timestamp, "Z")),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
self.lines["discharge"][0].set_ydata(v)
|
||||
self.lines["velocity"][0].set_ydata(v)
|
||||
|
||||
if "depth" in self._y:
|
||||
d = list(
|
||||
@@ -559,9 +551,7 @@ class CustomPlot(PamhyrPlot):
|
||||
fr = list(
|
||||
map(
|
||||
lambda p:
|
||||
p.geometry.speed(
|
||||
p.get_ts_key(self._timestamp, "Q"),
|
||||
p.get_ts_key(self._timestamp, "Z")) /
|
||||
p.get_ts_key(self._timestamp, "V") /
|
||||
sqrt(9.81 * (
|
||||
p.geometry.wet_area(
|
||||
p.get_ts_key(self._timestamp, "Z")) /
|
||||
@@ -643,6 +633,7 @@ class CustomPlot(PamhyrPlot):
|
||||
|
||||
q = profile.get_key("Q")
|
||||
z = profile.get_key("Z")
|
||||
v = profile.get_key("V")
|
||||
z_min = profile.geometry.z_min()
|
||||
if reach.has_sediment():
|
||||
ts_z_min = self.get_ts_zmin(self._profile)
|
||||
@@ -694,12 +685,6 @@ class CustomPlot(PamhyrPlot):
|
||||
if "velocity" in self._y:
|
||||
|
||||
ax = self._axes[unit["velocity"]]
|
||||
v = list(
|
||||
map(
|
||||
lambda q, z: profile.geometry.speed(q, z),
|
||||
q, z
|
||||
)
|
||||
)
|
||||
|
||||
line = ax.plot(
|
||||
ts, v, lw=1.,
|
||||
@@ -737,12 +722,12 @@ class CustomPlot(PamhyrPlot):
|
||||
|
||||
ax = self._axes[unit["froude"]]
|
||||
d = list(
|
||||
map(lambda z, q:
|
||||
profile.geometry.speed(q, z) /
|
||||
map(lambda z, v:
|
||||
v /
|
||||
sqrt(9.81 * (
|
||||
profile.geometry.wet_area(z) /
|
||||
profile.geometry.wet_width(z))
|
||||
), z, q)
|
||||
), z, v)
|
||||
)
|
||||
|
||||
line = ax.plot(
|
||||
@@ -783,6 +768,7 @@ class CustomPlot(PamhyrPlot):
|
||||
|
||||
q = profile.get_key("Q")
|
||||
z = profile.get_key("Z")
|
||||
v = profile.get_key("V")
|
||||
if reach.has_sediment():
|
||||
ts_z_min = self.get_ts_zmin(self._profile)
|
||||
else:
|
||||
@@ -811,12 +797,6 @@ class CustomPlot(PamhyrPlot):
|
||||
self.lines["discharge"][0].set_ydata(q)
|
||||
|
||||
if "velocity" in self._y:
|
||||
v = list(
|
||||
map(
|
||||
lambda q, z: profile.geometry.speed(q, z),
|
||||
q, z
|
||||
)
|
||||
)
|
||||
self.lines["velocity"][0].set_ydata(v)
|
||||
|
||||
if "depth" in self._y:
|
||||
@@ -833,12 +813,12 @@ class CustomPlot(PamhyrPlot):
|
||||
|
||||
if "froude" in self._y:
|
||||
d = list(
|
||||
map(lambda z, q:
|
||||
profile.geometry.speed(q, z) /
|
||||
map(lambda z, v:
|
||||
v /
|
||||
sqrt(9.81 * (
|
||||
profile.geometry.wet_area(z) /
|
||||
profile.geometry.wet_width(z))
|
||||
), z, q)
|
||||
), z, v)
|
||||
)
|
||||
self.lines["froude"][0].set_ydata(d)
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class TableModel(PamhyrTableModel):
|
||||
elif self._headers[column] == "velocity":
|
||||
q = self._lst[row].get_ts_key(self._timestamp, "Q")
|
||||
z = self._lst[row].get_ts_key(self._timestamp, "Z")
|
||||
v = self._lst[row].geometry.speed(q, z)
|
||||
v = self._lst[row].get_ts_key(self._timestamp, "V")
|
||||
return f"{v:.4f}"
|
||||
elif self._headers[column] == "width":
|
||||
z = self._lst[row].get_ts_key(self._timestamp, "Z")
|
||||
@@ -126,7 +126,7 @@ class TableModel(PamhyrTableModel):
|
||||
elif self._headers[column] == "froude":
|
||||
q = self._lst[row].get_ts_key(self._timestamp, "Q")
|
||||
z = self._lst[row].get_ts_key(self._timestamp, "Z")
|
||||
v = self._lst[row].geometry.speed(q, z)
|
||||
v = self._lst[row].get_ts_key(self._timestamp, "V")
|
||||
a = self._lst[row].geometry.wet_area(z)
|
||||
b = self._lst[row].geometry.wet_width(z)
|
||||
if b == 0.0 or a == 0.0:
|
||||
|
||||
+10
-22
@@ -781,21 +781,16 @@ class ResultsWindow(PamhyrWindow):
|
||||
if "velocity" in y:
|
||||
my_dict[dict_y["velocity"]] = list(
|
||||
map(
|
||||
lambda p: p.geometry.speed(
|
||||
p.get_ts_key(timestamp, "Q"),
|
||||
p.get_ts_key(timestamp, "Z")),
|
||||
lambda p: p.get_ts_key(timestamp, "V"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
if envelop:
|
||||
velocities = list(map(
|
||||
lambda p: list(map(
|
||||
lambda q, z:
|
||||
p.geometry.speed(q, z),
|
||||
p.get_key("Q"), p.get_key("Z")
|
||||
)), reach.profiles
|
||||
lambda p: p.get_key("V"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["min_velocity"]] = [min(v) for v in velocities]
|
||||
my_dict[dict_y["max_velocity"]] = [max(v) for v in velocities]
|
||||
|
||||
@@ -835,9 +830,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
my_dict[dict_y["froude"]] = list(
|
||||
map(
|
||||
lambda p:
|
||||
p.geometry.speed(
|
||||
p.get_ts_key(timestamp, "Q"),
|
||||
p.get_ts_key(timestamp, "Z")) /
|
||||
p.get_ts_key(timestamp, "V") /
|
||||
sqrt(9.81 * (
|
||||
p.geometry.wet_area(
|
||||
p.get_ts_key(timestamp, "Z")) /
|
||||
@@ -869,6 +862,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
my_dict[dict_x["time"]] = ts
|
||||
z = profile.get_key("Z")
|
||||
q = profile.get_key("Q")
|
||||
v = profile.get_key("V")
|
||||
if "bed_elevation" in y:
|
||||
my_dict[dict_y["bed_elevation"]] = [
|
||||
profile.geometry.z_min()] * len(ts)
|
||||
@@ -877,12 +871,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
if "water_elevation" in y:
|
||||
my_dict[dict_y["water_elevation"]] = z
|
||||
if "velocity" in y:
|
||||
my_dict[dict_y["velocity"]] = list(
|
||||
map(
|
||||
lambda q, z: profile.geometry.speed(q, z),
|
||||
q, z
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["velocity"]] = v
|
||||
if "depth" in y:
|
||||
my_dict[dict_y["depth"]] = list(
|
||||
map(lambda z: profile.geometry.max_water_depth(z), z)
|
||||
@@ -893,12 +882,11 @@ class ResultsWindow(PamhyrWindow):
|
||||
)
|
||||
if "froude" in y:
|
||||
my_dict[dict_y["froude"]] = list(
|
||||
map(lambda z, q:
|
||||
profile.geometry.speed(q, z) /
|
||||
sqrt(9.81 * (
|
||||
map(lambda z, v:
|
||||
v / sqrt(9.81 * (
|
||||
profile.geometry.wet_area(z) /
|
||||
profile.geometry.wet_width(z))
|
||||
), z, q)
|
||||
), z, v)
|
||||
)
|
||||
if "wet_area" in y:
|
||||
my_dict[dict_y["wet_area"]] = list(
|
||||
|
||||
@@ -78,6 +78,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||
parent=None):
|
||||
self._solver = solver
|
||||
self._results = results
|
||||
self.pollutant_label = ["None"]
|
||||
|
||||
pollutants_headers = self._results.pollutants_list.copy()
|
||||
|
||||
@@ -374,17 +375,14 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||
# Pollutant
|
||||
table = self.find(QTableView, f"tableView_pollutants")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
pollutant = self._results.pollutants_list[0]
|
||||
else:
|
||||
pollutant = self._results.pollutants_list[indexes[0].row()]
|
||||
if len(indexes) != 0:
|
||||
self.pollutant_label = [
|
||||
self._results.pollutants_list[i.row()+1] for i in indexes
|
||||
]
|
||||
|
||||
#return (f"Reach: {reach.name} | " +
|
||||
#f"Profile: {pname} | " +
|
||||
#f"Pollutant: {pollutant}")
|
||||
return (f"{self._trad['reach']}: {reach.name} | " +
|
||||
f"{self._trad['cross_section']}: {pname} | " +
|
||||
f"Pollutant: {pollutant} | " +
|
||||
f"Pollutant: {', '.join(self.pollutant_label)} | " +
|
||||
f"{self._trad['unit_time_s']} : {fts} ({ts} sec)")
|
||||
|
||||
def setup_statusbar(self):
|
||||
@@ -404,6 +402,8 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||
"action_export": self.export,
|
||||
}
|
||||
|
||||
self.find(QAction, "action_add").setEnabled(False)
|
||||
|
||||
for action in actions:
|
||||
self.find(QAction, action).triggered.connect(
|
||||
actions[action]
|
||||
|
||||
@@ -42,6 +42,8 @@ class ResultsTranslate(MainTranslate):
|
||||
self._dict['day'] = _translate("Results", "day")
|
||||
self._dict['days'] = _translate("Results", "days")
|
||||
|
||||
self._dict['envelop'] = _translate("Results", "envelop")
|
||||
|
||||
self._dict['x'] = _translate("Results", "X (m)")
|
||||
|
||||
self._dict['label_bottom'] = _translate("Results", "Bottom")
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Copyright © 2022-2024 INRAE</string>
|
||||
<string>Copyright © 2022-2025 INRAE</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in new issue
Block a user