mirror of https://gitlab.com/pamhyr/pamhyr2
work 5
parent
b56b8099ab
commit
a633e4bccf
|
|
@ -35,21 +35,22 @@ class OutputKpAdists(SQLSubModel):
|
||||||
_id_cnt = 0
|
_id_cnt = 0
|
||||||
|
|
||||||
def __init__(self, id: int = -1, reach = None, kp = None, title: str = "", status=None):
|
def __init__(self, id: int = -1, reach = None, kp = None, title: str = "", status=None):
|
||||||
super(LateralContribution, self).__init__()
|
super(OutputKpAdists, self).__init__()
|
||||||
|
|
||||||
self._status = status
|
self._status = status
|
||||||
|
|
||||||
if id == -1:
|
if id == -1:
|
||||||
self.id = LateralContribution._id_cnt
|
self.id = OutputKpAdists._id_cnt
|
||||||
else:
|
else:
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
||||||
self._reach = reach
|
self._reach = reach
|
||||||
self._kp = kp
|
self._kp = kp
|
||||||
self._title = str(title)
|
self._title = str(title)
|
||||||
|
self._enabled = True
|
||||||
|
|
||||||
LateralContribution._id_cnt = max(
|
OutputKpAdists._id_cnt = max(
|
||||||
LateralContribution._id_cnt + 1, self.id)
|
OutputKpAdists._id_cnt + 1, self.id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def reach(self):
|
def reach(self):
|
||||||
|
|
@ -110,19 +111,20 @@ class OutputKpAdists(SQLSubModel):
|
||||||
f"FROM OutputKpAdists"
|
f"FROM OutputKpAdists"
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in table:
|
if table is not None:
|
||||||
id = row[0]
|
for row in table:
|
||||||
id_reach = row[1]
|
id = row[0]
|
||||||
id_kp = row[2]
|
id_reach = row[1]
|
||||||
title = row[3]
|
id_kp = row[2]
|
||||||
|
title = row[3]
|
||||||
|
|
||||||
new_output = cls(
|
new_output = cls(
|
||||||
id=id, reach=id_reach,
|
id=id, reach=id_reach,
|
||||||
kp=id_kp, title=title,
|
kp=id_kp, title=title,
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
|
|
||||||
new.append(new_output)
|
new.append(new_output)
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
@ -141,6 +143,16 @@ class OutputKpAdists(SQLSubModel):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def enabled(self):
|
||||||
|
return self._enabled
|
||||||
|
|
||||||
|
@enabled.setter
|
||||||
|
def enabled(self, enabled):
|
||||||
|
self._enabled = enabled
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ class OutputKpAdistsList(PamhyrModelList):
|
||||||
def OutputKp_List(self):
|
def OutputKp_List(self):
|
||||||
return self.lst
|
return self.lst
|
||||||
|
|
||||||
def new(self, index):
|
def new(self, lst, index):
|
||||||
n = OutputKpAdists(status=self._status)
|
n = OutputKpAdists(status=self._status)
|
||||||
self.insert(index, n)
|
self._lst.insert(index, n)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
return n
|
return n
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,6 @@ class AdisTS(CommandLineSolver):
|
||||||
("adists_timestep_csv", "60"),
|
("adists_timestep_csv", "60"),
|
||||||
("adists_timestep_mage", "60"),
|
("adists_timestep_mage", "60"),
|
||||||
("adists_initial_concentration", "60"),
|
("adists_initial_concentration", "60"),
|
||||||
("adists_output_points_csv", ""),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
return lst
|
return lst
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ from PyQt5.QtWidgets import (
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
||||||
from View.HydraulicStructures.PlotAC import PlotAC
|
|
||||||
|
|
||||||
from View.HydraulicStructures.BasicHydraulicStructures.Table import (
|
from View.HydraulicStructures.BasicHydraulicStructures.Table import (
|
||||||
ComboBoxDelegate, TableModel, ParametersTableModel,
|
ComboBoxDelegate, TableModel, ParametersTableModel,
|
||||||
)
|
)
|
||||||
|
|
@ -78,7 +76,6 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_checkbox()
|
self.setup_checkbox()
|
||||||
self.setup_plot()
|
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
@ -139,37 +136,6 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
|
||||||
self._checkbox = self.find(QCheckBox, f"checkBox")
|
self._checkbox = self.find(QCheckBox, f"checkBox")
|
||||||
self._set_checkbox_state()
|
self._set_checkbox_state()
|
||||||
|
|
||||||
def setup_plot(self):
|
|
||||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
|
||||||
self.canvas.setObjectName("canvas")
|
|
||||||
self.toolbar = PamhyrPlotToolbar(
|
|
||||||
self.canvas, self
|
|
||||||
)
|
|
||||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
|
||||||
self.plot_layout.addWidget(self.toolbar)
|
|
||||||
self.plot_layout.addWidget(self.canvas)
|
|
||||||
|
|
||||||
reach = self._hs.input_reach
|
|
||||||
profile_kp = self._hs.input_kp
|
|
||||||
if profile_kp is not None:
|
|
||||||
profiles = reach.reach.get_profiles_from_kp(float(profile_kp))
|
|
||||||
else:
|
|
||||||
profiles = None
|
|
||||||
if profiles is not None:
|
|
||||||
profile = profiles[0]
|
|
||||||
else:
|
|
||||||
profile = None
|
|
||||||
|
|
||||||
self.plot_ac = PlotAC(
|
|
||||||
canvas=self.canvas,
|
|
||||||
river=self._study.river,
|
|
||||||
reach=self._hs.input_reach,
|
|
||||||
profile=profile,
|
|
||||||
trad=self._trad,
|
|
||||||
toolbar=self.toolbar
|
|
||||||
)
|
|
||||||
self.plot_ac.draw()
|
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
||||||
|
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
# PlotAC.py -- Pamhyr
|
|
||||||
# Copyright (C) 2023-2024 INRAE
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from tools import timer
|
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
|
||||||
from matplotlib import pyplot as plt
|
|
||||||
|
|
||||||
|
|
||||||
class PlotAC(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
river=None, reach=None, profile=None,
|
|
||||||
parent=None):
|
|
||||||
super(PlotAC, self).__init__(
|
|
||||||
canvas=canvas,
|
|
||||||
trad=trad,
|
|
||||||
data=river,
|
|
||||||
toolbar=toolbar,
|
|
||||||
parent=parent
|
|
||||||
)
|
|
||||||
|
|
||||||
self._current_reach = reach
|
|
||||||
self._current_profile = profile
|
|
||||||
|
|
||||||
self.label_x = self._trad["x"]
|
|
||||||
self.label_y = self._trad["unit_elevation"]
|
|
||||||
|
|
||||||
self._isometric_axis = False
|
|
||||||
|
|
||||||
self._auto_relim_update = True
|
|
||||||
self._autoscale_update = True
|
|
||||||
|
|
||||||
@property
|
|
||||||
def river(self):
|
|
||||||
return self.data
|
|
||||||
|
|
||||||
@river.setter
|
|
||||||
def river(self, river):
|
|
||||||
self.data = river
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def draw(self):
|
|
||||||
self.init_axes()
|
|
||||||
|
|
||||||
if self.data is None:
|
|
||||||
self.line_kp = None
|
|
||||||
return
|
|
||||||
|
|
||||||
if self._current_reach is None:
|
|
||||||
self.line_kp = None
|
|
||||||
return
|
|
||||||
|
|
||||||
self.draw_data()
|
|
||||||
|
|
||||||
self.idle()
|
|
||||||
self._init = True
|
|
||||||
|
|
||||||
def draw_data(self):
|
|
||||||
reach = self._current_reach
|
|
||||||
|
|
||||||
if self._current_profile is None:
|
|
||||||
self.line_kp = None
|
|
||||||
else:
|
|
||||||
profile = self._current_profile
|
|
||||||
x = profile.get_station()
|
|
||||||
z = profile.z()
|
|
||||||
|
|
||||||
self.line_kp, = self.canvas.axes.plot(
|
|
||||||
x, z,
|
|
||||||
color=self.color_plot_river_bottom,
|
|
||||||
**self.plot_default_kargs
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_reach(self, reach):
|
|
||||||
self._current_reach = reach
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def set_profile(self, profile):
|
|
||||||
self._current_profile = profile
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
if self.line_kp is None:
|
|
||||||
self.draw()
|
|
||||||
return
|
|
||||||
|
|
||||||
if self._current_reach is None or self._current_profile is None:
|
|
||||||
self.update_clear()
|
|
||||||
else:
|
|
||||||
self.update_data()
|
|
||||||
|
|
||||||
self.update_idle()
|
|
||||||
|
|
||||||
def update_data(self):
|
|
||||||
profile = self._current_profile
|
|
||||||
x = profile.get_station()
|
|
||||||
z = profile.z()
|
|
||||||
|
|
||||||
self.line_kp.set_data(x, z)
|
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
self.update_clear()
|
|
||||||
|
|
||||||
def update_clear(self):
|
|
||||||
if self.line_kp is not None:
|
|
||||||
self.line_kp.set_data([], [])
|
|
||||||
|
|
@ -1,165 +0,0 @@
|
||||||
# PlotKPC.py -- Pamhyr
|
|
||||||
# Copyright (C) 2023-2024 INRAE
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from tools import timer
|
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
QCoreApplication
|
|
||||||
)
|
|
||||||
|
|
||||||
from matplotlib.collections import LineCollection
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
|
|
||||||
class PlotKPC(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
river=None, reach=None, profile=None,
|
|
||||||
parent=None):
|
|
||||||
super(PlotKPC, self).__init__(
|
|
||||||
canvas=canvas,
|
|
||||||
trad=trad,
|
|
||||||
data=river,
|
|
||||||
toolbar=toolbar,
|
|
||||||
parent=parent
|
|
||||||
)
|
|
||||||
|
|
||||||
self._current_reach = reach
|
|
||||||
self._current_profile = profile
|
|
||||||
|
|
||||||
self.label_x = self._trad["unit_kp"]
|
|
||||||
self.label_y = self._trad["unit_elevation"]
|
|
||||||
|
|
||||||
self._isometric_axis = False
|
|
||||||
|
|
||||||
self._auto_relim_update = True
|
|
||||||
self._autoscale_update = True
|
|
||||||
|
|
||||||
@property
|
|
||||||
def river(self):
|
|
||||||
return self.data
|
|
||||||
|
|
||||||
@river.setter
|
|
||||||
def river(self, river):
|
|
||||||
self.data = river
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def draw(self, highlight=None):
|
|
||||||
self.init_axes()
|
|
||||||
|
|
||||||
if self.data is None:
|
|
||||||
self.profile = None
|
|
||||||
self.line_kp_zmin_zmax = None
|
|
||||||
self.line_kp_zmin = None
|
|
||||||
return
|
|
||||||
|
|
||||||
if self._current_reach is None:
|
|
||||||
self.profile = None
|
|
||||||
self.line_kp_zmin_zmax = None
|
|
||||||
self.line_kp_zmin = None
|
|
||||||
return
|
|
||||||
|
|
||||||
self.draw_data()
|
|
||||||
self.draw_current()
|
|
||||||
|
|
||||||
self.idle()
|
|
||||||
self._init = True
|
|
||||||
|
|
||||||
def draw_data(self):
|
|
||||||
reach = self._current_reach
|
|
||||||
|
|
||||||
kp = reach.reach.get_kp()
|
|
||||||
z_min = reach.reach.get_z_min()
|
|
||||||
z_max = reach.reach.get_z_max()
|
|
||||||
|
|
||||||
self.line_kp_zmin, = self.canvas.axes.plot(
|
|
||||||
kp, z_min,
|
|
||||||
color=self.color_plot_river_bottom,
|
|
||||||
lw=1.
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(kp) != 0:
|
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
|
||||||
x=kp,
|
|
||||||
ymin=z_min, ymax=z_max,
|
|
||||||
color=self.color_plot,
|
|
||||||
lw=1.
|
|
||||||
)
|
|
||||||
|
|
||||||
def draw_current(self):
|
|
||||||
if self._current_profile is None:
|
|
||||||
self.profile = None
|
|
||||||
else:
|
|
||||||
kp = [self._current_profile.kp,
|
|
||||||
self._current_profile.kp]
|
|
||||||
min_max = [self._current_profile.z_min(),
|
|
||||||
self._current_profile.z_max()]
|
|
||||||
|
|
||||||
self.profile = self.canvas.axes.plot(
|
|
||||||
kp, min_max,
|
|
||||||
color=self.color_plot_current,
|
|
||||||
lw=1.
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_reach(self, reach):
|
|
||||||
self._current_reach = reach
|
|
||||||
self._current_profile = None
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def set_profile(self, profile):
|
|
||||||
self._current_profile = profile
|
|
||||||
self.update_current_profile()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
self.draw()
|
|
||||||
|
|
||||||
def update_current_profile(self):
|
|
||||||
reach = self._current_reach
|
|
||||||
kp = reach.reach.get_kp()
|
|
||||||
z_min = reach.reach.get_z_min()
|
|
||||||
z_max = reach.reach.get_z_max()
|
|
||||||
|
|
||||||
if self.profile is None:
|
|
||||||
self.draw()
|
|
||||||
else:
|
|
||||||
self.profile.set_data(
|
|
||||||
[self._current_profile.kp, self._current_profile.kp],
|
|
||||||
[self._current_profile.z_min(), self._current_profile.z_max()],
|
|
||||||
)
|
|
||||||
|
|
||||||
self.update_idle()
|
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
if self.profile is not None:
|
|
||||||
self.profile[0].set_data([], [])
|
|
||||||
|
|
||||||
if self.line_kp_zmin_zmax is not None:
|
|
||||||
self.line_kp_zmin_zmax.remove()
|
|
||||||
self.line_kp_zmin_zmax = None
|
|
||||||
|
|
||||||
if self.line_kp_zmin is not None:
|
|
||||||
self.line_kp_zmin.set_data([], [])
|
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
|
|
||||||
def clear_profile(self):
|
|
||||||
if self.profile is not None:
|
|
||||||
self.profile.set_data([], [])
|
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
|
||||||
|
|
@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
|
||||||
|
|
||||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
|
||||||
from View.HydraulicStructures.UndoCommand import (
|
from View.OutputKpAdisTS.UndoCommand import (
|
||||||
SetNameCommand, SetReachCommand, SetKpCommand,
|
SetNameCommand, SetReachCommand, SetKpCommand,
|
||||||
SetEnabledCommand, AddCommand, DelCommand,
|
SetEnabledCommand, AddCommand, DelCommand,
|
||||||
)
|
)
|
||||||
|
|
@ -59,9 +59,9 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
||||||
val = []
|
val = []
|
||||||
if self._mode == "kp":
|
if self._mode == "kp":
|
||||||
reach = self._data.hydraulic_structures\
|
reach = self._data.Output_kp_adists\
|
||||||
.get(index.row())\
|
.get(index.row())\
|
||||||
.input_reach
|
.reach
|
||||||
if reach is not None:
|
if reach is not None:
|
||||||
val = list(
|
val = list(
|
||||||
map(
|
map(
|
||||||
|
|
@ -107,7 +107,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = self._data._hydraulic_structures
|
self._lst = self._data._Output_kp_adists
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def rowCount(self, parent):
|
||||||
return len(self._lst)
|
return len(self._lst)
|
||||||
|
|
@ -119,15 +119,15 @@ class TableModel(PamhyrTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "title":
|
||||||
return self._lst.get(row).name
|
return self._lst.get(row).title
|
||||||
elif self._headers[column] == "reach":
|
elif self._headers[column] == "reach":
|
||||||
n = self._lst.get(row).input_reach
|
n = self._lst.get(row).reach
|
||||||
if n is None:
|
if n is None:
|
||||||
return self._trad['not_associated']
|
return self._trad['not_associated']
|
||||||
return n.name
|
return n.name
|
||||||
elif self._headers[column] == "kp":
|
elif self._headers[column] == "kp":
|
||||||
n = self._lst.get(row).input_kp
|
n = self._lst.get(row).kp
|
||||||
if n is None:
|
if n is None:
|
||||||
return self._trad['not_associated']
|
return self._trad['not_associated']
|
||||||
return n
|
return n
|
||||||
|
|
@ -143,7 +143,7 @@ class TableModel(PamhyrTableModel):
|
||||||
na = self._trad['not_associated']
|
na = self._trad['not_associated']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "title":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
self._lst, row, value
|
self._lst, row, value
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class OutputKpAdisTSTranslate(MainTranslate):
|
||||||
self._dict["x"] = _translate("OutputKpAdisTS", "X (m)")
|
self._dict["x"] = _translate("OutputKpAdisTS", "X (m)")
|
||||||
|
|
||||||
self._sub_dict["table_headers"] = {
|
self._sub_dict["table_headers"] = {
|
||||||
"name": self._dict["name"],
|
"title": self._dict["title"],
|
||||||
"reach": self._dict["reach"],
|
"reach": self._dict["reach"],
|
||||||
"kp": self._dict["unit_kp"],
|
"kp": self._dict["unit_kp"],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,131 +29,131 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class SetNameCommand(QUndoCommand):
|
class SetNameCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, index, new_value):
|
def __init__(self, outputkp_lst, index, new_value):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._h_s_lst.get(self._index).name
|
self._old = self._outputkp_lst.get(self._index).name
|
||||||
self._new = str(new_value)
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._h_s_lst.get(self._index).name = self._old
|
self._outputkp_lst.get(self._index).name = self._old
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._h_s_lst.get(self._index).name = self._new
|
self._outputkp_lst.get(self._index).name = self._new
|
||||||
|
|
||||||
|
|
||||||
class SetReachCommand(QUndoCommand):
|
class SetReachCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, index, reach):
|
def __init__(self, outputkp_lst, index, reach):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._h_s_lst.get(self._index).input_reach
|
self._old = self._outputkp_lst.get(self._index).input_reach
|
||||||
self._new = reach
|
self._new = reach
|
||||||
self._old_kp = self._h_s_lst.get(self._index).input_kp
|
self._old_kp = self._outputkp_lst.get(self._index).input_kp
|
||||||
self._new_kp = None
|
self._new_kp = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
i = self._h_s_lst.get(self._index)
|
i = self._outputkp_lst.get(self._index)
|
||||||
i.input_reach = self._old
|
i.input_reach = self._old
|
||||||
i.input_kp = self._old_kp
|
i.input_kp = self._old_kp
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
i = self._h_s_lst.get(self._index)
|
i = self._outputkp_lst.get(self._index)
|
||||||
i.input_reach = self._new
|
i.input_reach = self._new
|
||||||
i.input_kp = self._new_kp
|
i.input_kp = self._new_kp
|
||||||
|
|
||||||
|
|
||||||
class SetKpCommand(QUndoCommand):
|
class SetKpCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, index, kp):
|
def __init__(self, outputkp_lst, index, kp):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._h_s_lst.get(self._index).input_kp
|
self._old = self._outputkp_lst.get(self._index).input_kp
|
||||||
self._new = kp
|
self._new = kp
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._h_s_lst.get(self._index).input_kp = self._old
|
self._outputkp_lst.get(self._index).input_kp = self._old
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._h_s_lst.get(self._index).input_kp = self._new
|
self._outputkp_lst.get(self._index).input_kp = self._new
|
||||||
|
|
||||||
|
|
||||||
class SetEnabledCommand(QUndoCommand):
|
class SetEnabledCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, index, enabled):
|
def __init__(self, outputkp_lst, index, enabled):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = not enabled
|
self._old = not enabled
|
||||||
self._new = enabled
|
self._new = enabled
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._h_s_lst.get(self._index).enabled = self._old
|
self._outputkp_lst.get(self._index).enabled = self._old
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._h_s_lst.get(self._index).enabled = self._new
|
self._outputkp_lst.get(self._index).enabled = self._new
|
||||||
|
|
||||||
|
|
||||||
class AddCommand(QUndoCommand):
|
class AddCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, index):
|
def __init__(self, outputkp_lst, index):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
|
|
||||||
self._index = index
|
self._index = index
|
||||||
self._new = None
|
self._new = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._h_s_lst.delete_i([self._index])
|
self._outputkp_lst.delete_i([self._index])
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._h_s_lst.new(self._h_s_lst, self._index)
|
self._new = self._outputkp_lst.new(self._outputkp_lst, self._index)
|
||||||
else:
|
else:
|
||||||
self._h_s_lst.insert(self._index, self._new)
|
self._outputkp_lst.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, rows):
|
def __init__(self, outputkp_lst, rows):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
|
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
|
|
||||||
self._h_s = []
|
self._outputkp = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._h_s.append((row, self._h_s_lst.get(row)))
|
self._outputkp.append((row, self._outputkp_lst.get(row)))
|
||||||
self._h_s.sort()
|
self._outputkp.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
for row, el in self._h_s:
|
for row, el in self._outputkp:
|
||||||
self._h_s_lst.insert(row, el)
|
self._outputkp_lst.insert(row, el)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._h_s_lst.delete_i(self._rows)
|
self._outputkp_lst.delete_i(self._rows)
|
||||||
|
|
||||||
|
|
||||||
class PasteCommand(QUndoCommand):
|
class PasteCommand(QUndoCommand):
|
||||||
def __init__(self, h_s_lst, row, h_s):
|
def __init__(self, outputkp_lst, row, outputkp):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._outputkp_lst = outputkp_lst
|
||||||
|
|
||||||
self._row = row
|
self._row = row
|
||||||
self._h_s = deepcopy(h_s)
|
self._outputkp = deepcopy(outputkp)
|
||||||
self._h_s.reverse()
|
self._outputkp.reverse()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._h_s_lst.delete_i(
|
self._outputkp_lst.delete_i(
|
||||||
self._tab,
|
self._tab,
|
||||||
range(self._row, self._row + len(self._h_s))
|
range(self._row, self._row + len(self._outputkp))
|
||||||
)
|
)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
for r in self._h_s:
|
for r in self._outputkp:
|
||||||
self._h_s_lst.insert(self._row, r)
|
self._outputkp_lst.insert(self._row, r)
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,6 @@ from PyQt5.QtWidgets import (
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
||||||
from View.OutputKpAdisTS.PlotAC import PlotAC
|
|
||||||
from View.OutputKpAdisTS.PlotKPC import PlotKPC
|
|
||||||
|
|
||||||
from View.OutputKpAdisTS.Table import (
|
from View.OutputKpAdisTS.Table import (
|
||||||
TableModel, ComboBoxDelegate
|
TableModel, ComboBoxDelegate
|
||||||
)
|
)
|
||||||
|
|
@ -71,14 +68,13 @@ class OutputKpAdisTSWindow(PamhyrWindow):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self._hs_lst = self._study.river._hydraulic_structures
|
self._outputkp_lst = self._study.river._Output_kp_adists
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
#self.setup_checkbox()
|
self.setup_checkbox()
|
||||||
#self.setup_plots()
|
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
#self.update()
|
self.update()
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
self._table = None
|
self._table = None
|
||||||
|
|
@ -100,7 +96,7 @@ class OutputKpAdisTSWindow(PamhyrWindow):
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
table_view=table,
|
table_view=table,
|
||||||
table_headers=self._trad.get_dict("table_headers"),
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
editable_headers=["name", "reach", "kp"],
|
editable_headers=["title", "reach", "kp"],
|
||||||
delegates={
|
delegates={
|
||||||
"reach": self._delegate_reach,
|
"reach": self._delegate_reach,
|
||||||
"kp": self._delegate_kp,
|
"kp": self._delegate_kp,
|
||||||
|
|
@ -125,45 +121,6 @@ class OutputKpAdisTSWindow(PamhyrWindow):
|
||||||
self._checkbox = self.find(QCheckBox, f"checkBox")
|
self._checkbox = self.find(QCheckBox, f"checkBox")
|
||||||
self._set_checkbox_state()
|
self._set_checkbox_state()
|
||||||
|
|
||||||
def setup_plots(self):
|
|
||||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
|
||||||
self.canvas.setObjectName("canvas")
|
|
||||||
self.toolbar = PamhyrPlotToolbar(
|
|
||||||
self.canvas, self
|
|
||||||
)
|
|
||||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
|
||||||
self.plot_layout.addWidget(self.toolbar)
|
|
||||||
self.plot_layout.addWidget(self.canvas)
|
|
||||||
|
|
||||||
self.plot_kpc = PlotKPC(
|
|
||||||
canvas=self.canvas,
|
|
||||||
river=self._study.river,
|
|
||||||
reach=None,
|
|
||||||
profile=None,
|
|
||||||
trad=self._trad,
|
|
||||||
toolbar=self.toolbar
|
|
||||||
)
|
|
||||||
self.plot_kpc.draw()
|
|
||||||
|
|
||||||
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
|
|
||||||
self.canvas_2.setObjectName("canvas_2")
|
|
||||||
self.toolbar_2 = PamhyrPlotToolbar(
|
|
||||||
self.canvas_2, self
|
|
||||||
)
|
|
||||||
self.plot_layout_2 = self.find(QVBoxLayout, "verticalLayout_2")
|
|
||||||
self.plot_layout_2.addWidget(self.toolbar_2)
|
|
||||||
self.plot_layout_2.addWidget(self.canvas_2)
|
|
||||||
|
|
||||||
self.plot_ac = PlotAC(
|
|
||||||
canvas=self.canvas_2,
|
|
||||||
river=self._study.river,
|
|
||||||
reach=None,
|
|
||||||
profile=None,
|
|
||||||
trad=self._trad,
|
|
||||||
toolbar=self.toolbar_2
|
|
||||||
)
|
|
||||||
self.plot_ac.draw()
|
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
self.find(QAction, "action_delete").triggered.connect(self.delete)
|
||||||
|
|
@ -210,7 +167,7 @@ class OutputKpAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
if len(self._hs_lst) == 0 or len(rows) == 0:
|
if len(self._outputkp_lst) == 0 or len(rows) == 0:
|
||||||
self._table.add(0)
|
self._table.add(0)
|
||||||
else:
|
else:
|
||||||
self._table.add(rows[0])
|
self._table.add(rows[0])
|
||||||
|
|
@ -237,7 +194,7 @@ class OutputKpAdisTSWindow(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._hs_lst.get(row)
|
data = self._outputkp_lst.get(row)
|
||||||
|
|
||||||
if self.sub_window_exists(
|
if self.sub_window_exists(
|
||||||
BasicHydraulicStructuresWindow,
|
BasicHydraulicStructuresWindow,
|
||||||
|
|
@ -259,7 +216,7 @@ class OutputKpAdisTSWindow(PamhyrWindow):
|
||||||
self._checkbox.setChecked(True)
|
self._checkbox.setChecked(True)
|
||||||
else:
|
else:
|
||||||
self._checkbox.setEnabled(True)
|
self._checkbox.setEnabled(True)
|
||||||
self._checkbox.setChecked(self._hs_lst.get(row).enabled)
|
self._checkbox.setChecked(self._outputkp_lst.get(row).enabled)
|
||||||
|
|
||||||
def _set_structure_state(self):
|
def _set_structure_state(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
|
|
@ -273,43 +230,3 @@ class OutputKpAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self._set_checkbox_state()
|
self._set_checkbox_state()
|
||||||
self._update_clear_plot()
|
|
||||||
|
|
||||||
def _update_clear_plot(self):
|
|
||||||
rows = self.index_selected_rows()
|
|
||||||
|
|
||||||
if len(rows) == 0 or len(self._hs_lst) == 0:
|
|
||||||
self._update_clear_all()
|
|
||||||
return
|
|
||||||
|
|
||||||
reach = self._hs_lst.get(rows[0]).input_reach
|
|
||||||
if reach is not None:
|
|
||||||
self.plot_kpc.set_reach(reach)
|
|
||||||
self.plot_ac.set_reach(reach)
|
|
||||||
|
|
||||||
profile_kp = self._hs_lst.get(rows[0]).input_kp
|
|
||||||
if profile_kp is not None:
|
|
||||||
profiles = reach.reach\
|
|
||||||
.get_profiles_from_kp(
|
|
||||||
float(profile_kp)
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(profiles) != 0 and profiles is not None:
|
|
||||||
profile = profiles[0]
|
|
||||||
|
|
||||||
self.plot_kpc.set_profile(profile)
|
|
||||||
self.plot_ac.set_profile(profile)
|
|
||||||
else:
|
|
||||||
self._update_clear_profile()
|
|
||||||
else:
|
|
||||||
self._update_clear_profile()
|
|
||||||
else:
|
|
||||||
self._update_clear_all()
|
|
||||||
|
|
||||||
def _update_clear_all(self):
|
|
||||||
self.plot_kpc.clear()
|
|
||||||
self.plot_ac.clear()
|
|
||||||
|
|
||||||
def _update_clear_profile(self):
|
|
||||||
self.plot_ac.clear()
|
|
||||||
self.plot_kpc.clear_profile()
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class CommonWordTranslate(PamhyrTranslate):
|
||||||
super(CommonWordTranslate, self).__init__()
|
super(CommonWordTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["name"] = _translate("CommonWord", "Name")
|
self._dict["name"] = _translate("CommonWord", "Name")
|
||||||
|
self._dict["title"] = _translate("CommonWord", "Title")
|
||||||
self._dict["type"] = _translate("CommonWord", "Type")
|
self._dict["type"] = _translate("CommonWord", "Type")
|
||||||
self._dict["value"] = _translate("CommonWord", "Value")
|
self._dict["value"] = _translate("CommonWord", "Value")
|
||||||
self._dict["comment"] = _translate("CommonWord", "Comment")
|
self._dict["comment"] = _translate("CommonWord", "Comment")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue