mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "2db1f4c7f7267e35e9b2d6a41e3f051f604cae75" and "51dd6d27c51a1f42a72566eb2d5e0160792f65d9" have entirely different histories.
2db1f4c7f7
...
51dd6d27c5
|
|
@ -329,8 +329,7 @@ class BoundaryCondition(SQLSubModel):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, deleted, name, type, node, d50, sigma, " +
|
"SELECT pamhyr_id, deleted, name, type, node, d50, sigma, scenario " +
|
||||||
"scenario " +
|
|
||||||
"FROM boundary_condition " +
|
"FROM boundary_condition " +
|
||||||
f"WHERE tab = '{tab}' " +
|
f"WHERE tab = '{tab}' " +
|
||||||
f"AND scenario = {scenario.id} " +
|
f"AND scenario = {scenario.id} " +
|
||||||
|
|
@ -356,14 +355,11 @@ class BoundaryCondition(SQLSubModel):
|
||||||
status=data['status'],
|
status=data['status'],
|
||||||
owner_scenario=owner_scenario
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
if deleted:
|
if deleted:
|
||||||
bc.set_as_deleted()
|
bc.set_as_deleted()
|
||||||
|
if t=="SL":
|
||||||
if t == "SL":
|
|
||||||
bc.d50 = d50
|
bc.d50 = d50
|
||||||
bc.sigma = sigma
|
bc.sigma = sigma
|
||||||
|
|
||||||
bc.node = None
|
bc.node = None
|
||||||
if node != -1:
|
if node != -1:
|
||||||
bc.node = next(filter(lambda n: n.id == node, nodes), None)
|
bc.node = next(filter(lambda n: n.id == node, nodes), None)
|
||||||
|
|
|
||||||
|
|
@ -302,8 +302,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
|
|
||||||
if pol_id not in pid_pol:
|
if pol_id not in pid_pol:
|
||||||
# ⚠️ cas important : probablement déjà migré
|
# ⚠️ cas important : probablement déjà migré
|
||||||
print(f"[WARN] pol_id {pol_id} not in pid_pol " +
|
print(f"[WARN] pol_id {pol_id} not in pid_pol → probably already migrated")
|
||||||
f"→ probably already migrated")
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
|
|
|
||||||
|
|
@ -132,13 +132,11 @@ class Data(SQLSubModel):
|
||||||
if scenario is None:
|
if scenario is None:
|
||||||
return new
|
return new
|
||||||
|
|
||||||
lca = data["lca"]
|
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, deleted, data0, data1 " +
|
"SELECT pamhyr_id, deleted, data0, data1 " +
|
||||||
"FROM lateral_contribution_data_adists " +
|
"FROM lateral_contribution_data_adists " +
|
||||||
f"WHERE scenario = {scenario.id} " +
|
f"WHERE scenario = {scenario.id} " +
|
||||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
||||||
f"AND lca = '{lca.id}'"
|
f"AND lca = '{lca.id}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -374,12 +372,12 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"lateral_contribution_adists(pamhyr_id, deleted, " +
|
"lateral_contribution_adists(pamhyr_id, deleted," +
|
||||||
"pollutant, reach, begin_rk, end_rk, scenario) " +
|
"pollutant, reach, begin_rk, end_rk, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||||
f"{self._pollutant}, {self.reach}, " +
|
f"{self._pollutant}, {self.reach}, " +
|
||||||
f"{self._begin_rk}, {self._end_rk}, " +
|
f"{self._begin_rk}, {self._end_rk}" +
|
||||||
f"{self._status.scenario_id}" +
|
f"{self._status.scenario_id}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@ from tools import (
|
||||||
from Model.Tools.PamhyrDB import SQLSubModel
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
from Model.Scenario import Scenario
|
from Model.Scenario import Scenario
|
||||||
from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import (
|
from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import BoundaryConditionAdisTS
|
||||||
BoundaryConditionAdisTS,
|
|
||||||
)
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
@ -425,11 +423,8 @@ class Pollutants(SQLSubModel):
|
||||||
execute, data=data
|
execute, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
new_pollutant._boundary_conditions_adists = (
|
new_pollutant._boundary_conditions_adists = BoundaryConditionAdisTS._db_load(
|
||||||
BoundaryConditionAdisTS._db_load(
|
execute, data=data
|
||||||
execute,
|
|
||||||
data=data
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
loaded.add(pid)
|
loaded.add(pid)
|
||||||
|
|
|
||||||
|
|
@ -313,8 +313,7 @@ class SQLSubModel(PamhyrID):
|
||||||
|
|
||||||
if node_id not in nodes:
|
if node_id not in nodes:
|
||||||
# ⚠️ cas important : probablement déjà migré
|
# ⚠️ cas important : probablement déjà migré
|
||||||
print(f"[WARN] node_id {node_id} not in nodes " +
|
print(f"[WARN] node_id {node_id} not in nodes → probably already migrated")
|
||||||
f"→ probably already migrated")
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def __init__(self, bc_list=None, pollutant_bc_list=None,
|
def __init__(self, bc_list=None, pollutant_bc_list=None, trad=None, **kwargs):
|
||||||
trad=None, **kwargs):
|
|
||||||
self._trad = trad
|
self._trad = trad
|
||||||
self._bc_list = bc_list
|
self._bc_list = bc_list
|
||||||
self._pollutant = pollutant_bc_list.id
|
self._pollutant = pollutant_bc_list.id
|
||||||
|
|
|
||||||
|
|
@ -58,18 +58,17 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "BoundaryConditionsAdisTS"
|
_pamhyr_ui = "BoundaryConditionsAdisTS"
|
||||||
_pamhyr_name = "Boundary conditions AdisTS"
|
_pamhyr_name = "Boundary conditions AdisTS"
|
||||||
|
|
||||||
def __init__(self, data=None, pollutant_id=None, study=None,
|
def __init__(self, data=None, pollutant_id=None, study=None, config=None, parent=None):
|
||||||
config=None, parent=None):
|
|
||||||
self._data = data
|
self._data = data
|
||||||
self._pollutant_id = pollutant_id
|
self._pollutant_id = pollutant_id
|
||||||
trad = BCAdisTSTranslate()
|
|
||||||
|
|
||||||
|
_pollutants_lst = study._river._Pollutants.Pollutants_List
|
||||||
self._pollutant_name = next(
|
self._pollutant_name = next(
|
||||||
(x.name for x in study._river._Pollutants.Pollutants_List
|
(x.name for x in _pollutants_lst if x.id == self._pollutant_id),
|
||||||
if x.id == self._pollutant_id),
|
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
trad = BCAdisTSTranslate()
|
||||||
name = (
|
name = (
|
||||||
trad[self._pamhyr_name] +
|
trad[self._pamhyr_name] +
|
||||||
" - " + study.name +
|
" - " + study.name +
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class D90TableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = list(
|
self._lst = list(
|
||||||
filter(
|
filter(
|
||||||
lambda d90: d90._deleted is False,
|
lambda d90: d90._deleted == False,
|
||||||
self._data._data
|
self._data._data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ from View.Tools.PamhyrWindow import PamhyrDialog
|
||||||
from PyQt5.QtWidgets import QDoubleSpinBox
|
from PyQt5.QtWidgets import QDoubleSpinBox
|
||||||
from View.Tools.FlexibleDoubleSpinBox import FlexibleDoubleSpinBox
|
from View.Tools.FlexibleDoubleSpinBox import FlexibleDoubleSpinBox
|
||||||
|
|
||||||
|
|
||||||
class ShiftDialog(PamhyrDialog):
|
class ShiftDialog(PamhyrDialog):
|
||||||
_pamhyr_ui = "GeometryReachShift"
|
_pamhyr_ui = "GeometryReachShift"
|
||||||
_pamhyr_name = "Shift"
|
_pamhyr_name = "Shift"
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,3 @@ class GeometryTranslate(MainTranslate):
|
||||||
self._dict["Shift"] = _translate(
|
self._dict["Shift"] = _translate(
|
||||||
"Geometry", "Shift"
|
"Geometry", "Shift"
|
||||||
)
|
)
|
||||||
self._dict["warning"] = _translate(
|
|
||||||
"Geometry", "Warning"
|
|
||||||
)
|
|
||||||
self._dict["format_not_exportable"] = _translate(
|
|
||||||
"Geometry", "The format of the file is not exportable."
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -691,13 +691,7 @@ class GeometryWindow(PamhyrWindow):
|
||||||
if suffix == ".st" or suffix == ".ST":
|
if suffix == ".st" or suffix == ".ST":
|
||||||
self._export_to_file_st(filename[:-3])
|
self._export_to_file_st(filename[:-3])
|
||||||
else:
|
else:
|
||||||
# Warning popup when the format is not exportable
|
# TODO : prévenir l'utilisateur que le format n'est pas exportable
|
||||||
win = QtWidgets.QMessageBox()
|
|
||||||
win.setIcon(QtWidgets.QMessageBox.Warning)
|
|
||||||
win.setWindowTitle(self._trad["warning"])
|
|
||||||
win.setText(self._trad["format_not_exportable"])
|
|
||||||
win.exec()
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self._export_to_file_st(filename)
|
self._export_to_file_st(filename)
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = list(
|
self._lst = list(
|
||||||
filter(
|
filter(
|
||||||
lambda ica: ica._deleted is False,
|
lambda ica: ica._deleted == False,
|
||||||
self._data._data
|
self._data._data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -68,22 +68,15 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "InitialConditionsAdisTS"
|
_pamhyr_ui = "InitialConditionsAdisTS"
|
||||||
_pamhyr_name = "Initial condition AdisTS"
|
_pamhyr_name = "Initial condition AdisTS"
|
||||||
|
|
||||||
def __init__(self, data=None, pollutant_id=None, study=None,
|
def __init__(self, data=None, study=None, config=None, parent=None):
|
||||||
config=None, parent=None):
|
|
||||||
self._data = []
|
self._data = []
|
||||||
self._data.append(data)
|
self._data.append(data)
|
||||||
self._pollutant_id = pollutant_id
|
|
||||||
trad = IcAdisTSTranslate()
|
trad = IcAdisTSTranslate()
|
||||||
|
|
||||||
self._pollutant_name = next(
|
|
||||||
(x.name for x in study._river._Pollutants.Pollutants_List
|
|
||||||
if x.id == self._pollutant_id),
|
|
||||||
None
|
|
||||||
)
|
|
||||||
name = (
|
name = (
|
||||||
trad[self._pamhyr_name] +
|
trad[self._pamhyr_name] +
|
||||||
" - " + study.name +
|
" - " + study.name +
|
||||||
" - " + self._pollutant_name
|
" - " + self._data[0].name
|
||||||
)
|
)
|
||||||
|
|
||||||
super(InitialConditionsAdisTSWindow, self).__init__(
|
super(InitialConditionsAdisTSWindow, self).__init__(
|
||||||
|
|
|
||||||
|
|
@ -116,22 +116,10 @@ class TableModel(PamhyrTableModel):
|
||||||
self._pollutant = pollutant
|
self._pollutant = pollutant
|
||||||
|
|
||||||
super(TableModel, self).__init__(trad=trad, **kwargs)
|
super(TableModel, self).__init__(trad=trad, **kwargs)
|
||||||
self._setup_lst()
|
|
||||||
|
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
if self._lcs_list is not None:
|
self._lst = self._data.lateral_contributions_adists.lst
|
||||||
self._lcs_pol_list = [
|
self._tab = self._opt_data
|
||||||
lcs for lcs in self._lcs_list.lst
|
|
||||||
if lcs.pollutant == self._pollutant
|
|
||||||
]
|
|
||||||
|
|
||||||
self._lst = list(
|
|
||||||
filter(
|
|
||||||
lambda x: x._deleted is False,
|
|
||||||
self._lcs_pol_list
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# self._tab = self._opt_data
|
|
||||||
self._long_types = self._trad.get_dict("long_types")
|
self._long_types = self._trad.get_dict("long_types")
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def rowCount(self, parent):
|
||||||
|
|
@ -202,43 +190,17 @@ class TableModel(PamhyrTableModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
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._lcs_list, global_rows
|
self._lst, rows
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._setup_lst()
|
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def undo(self):
|
|
||||||
self._undo.undo()
|
|
||||||
self._setup_lst()
|
|
||||||
self.layoutChanged.emit()
|
|
||||||
|
|
||||||
def redo(self):
|
|
||||||
self._undo.redo()
|
|
||||||
self._setup_lst()
|
|
||||||
self.layoutChanged.emit()
|
|
||||||
|
|
||||||
def get(self, row):
|
|
||||||
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._lcs_list.index(bc)
|
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,13 @@ class AddCommand(QUndoCommand):
|
||||||
self._new = None
|
self._new = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._lcs.delete_i(self._index)
|
del self._lcs[self._index]
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._lcs.new(self._index, self._pollutant)
|
self._new = self._lcs.new(self._index, self._pollutant)
|
||||||
else:
|
else:
|
||||||
self._lcs.insert(self._index, self._new)
|
self._lcs_lst.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
|
|
@ -107,14 +107,15 @@ class DelCommand(QUndoCommand):
|
||||||
self._lcs = lcs
|
self._lcs = lcs
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
|
|
||||||
self._lc = []
|
self._bc = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._lc.append((row, self._lcs.get(row)))
|
self._bc.append((row, self._lcs[row]))
|
||||||
self._lc.sort()
|
self._bc.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
for row, el in self._lc:
|
for row, el in self._bc:
|
||||||
self._lcs.insert(row, el)
|
self._lcs.insert(row, el)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._lcs.delete_i(self._rows)
|
for row in self._rows:
|
||||||
|
del self._lcs[row]
|
||||||
|
|
|
||||||
|
|
@ -57,24 +57,11 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "LateralContributionsAdisTS"
|
_pamhyr_ui = "LateralContributionsAdisTS"
|
||||||
_pamhyr_name = "Lateral contribution AdisTS"
|
_pamhyr_name = "Lateral contribution AdisTS"
|
||||||
|
|
||||||
def __init__(self, data=None, study=None, pollutant_id=None,
|
def __init__(self, study=None, pollutant=None, config=None, parent=None):
|
||||||
config=None, parent=None):
|
|
||||||
self._pollutant = pollutant_id
|
|
||||||
self._study = study
|
|
||||||
self._data = data
|
|
||||||
trad = LCTranslate()
|
trad = LCTranslate()
|
||||||
|
name = trad[self._pamhyr_name] + " - " + study.name
|
||||||
|
|
||||||
self._pollutant_name = next(
|
self._pollutant = pollutant
|
||||||
(x.name for x in study._river._Pollutants.Pollutants_List
|
|
||||||
if x.id == self._pollutant),
|
|
||||||
None
|
|
||||||
)
|
|
||||||
|
|
||||||
name = (
|
|
||||||
trad[self._pamhyr_name] +
|
|
||||||
" - " + study.name +
|
|
||||||
" - " + self._pollutant_name
|
|
||||||
)
|
|
||||||
|
|
||||||
super(LateralContributionAdisTSWindow, self).__init__(
|
super(LateralContributionAdisTSWindow, self).__init__(
|
||||||
title=name,
|
title=name,
|
||||||
|
|
@ -123,7 +110,7 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
data=self._study.river,
|
data=self._study.river,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
# opt_data="liquid",
|
opt_data="liquid",
|
||||||
pollutant=self._pollutant,
|
pollutant=self._pollutant,
|
||||||
lcs_list=self._lcs,
|
lcs_list=self._lcs,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -217,8 +217,7 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
initial = InitialConditionsAdisTSWindow(
|
initial = InitialConditionsAdisTSWindow(
|
||||||
study=self._study,
|
study=self._study,
|
||||||
parent=self,
|
parent=self,
|
||||||
data=ics_adists,
|
data=ics_adists
|
||||||
pollutant_id=pollutant_id
|
|
||||||
)
|
)
|
||||||
initial.show()
|
initial.show()
|
||||||
|
|
||||||
|
|
@ -230,8 +229,7 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
for row in rows:
|
for row in rows:
|
||||||
pollutant_id = self._pollutants_lst.get(row).id
|
pollutant_id = self._pollutants_lst.get(row).id
|
||||||
|
|
||||||
river = self._study.river
|
bclist = self._study.river.boundary_conditions_adists.BCs_AdisTS_List
|
||||||
bclist = river.boundary_conditions_adists.BCs_AdisTS_List
|
|
||||||
bcs_adists = [
|
bcs_adists = [
|
||||||
x for x in bclist
|
x for x in bclist
|
||||||
if x.pollutant == pollutant_id
|
if x.pollutant == pollutant_id
|
||||||
|
|
@ -258,9 +256,6 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
|
|
||||||
pollutant_id = self._pollutants_lst.get(rows[0]).id
|
pollutant_id = self._pollutants_lst.get(rows[0]).id
|
||||||
|
|
||||||
lclist = self._study.river.lateral_contributions_adists.Lat_Cont_List
|
|
||||||
lcs_adists = [x for x in lclist if x.pollutant == pollutant_id]
|
|
||||||
|
|
||||||
if self.sub_window_exists(
|
if self.sub_window_exists(
|
||||||
LateralContributionAdisTSWindow,
|
LateralContributionAdisTSWindow,
|
||||||
data=[self._study, pollutant_id, None]
|
data=[self._study, pollutant_id, None]
|
||||||
|
|
@ -269,9 +264,8 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
|
|
||||||
lateral = LateralContributionAdisTSWindow(
|
lateral = LateralContributionAdisTSWindow(
|
||||||
study=self._study,
|
study=self._study,
|
||||||
parent=self,
|
pollutant=pollutant_id,
|
||||||
data=lcs_adists,
|
parent=self
|
||||||
pollutant_id=pollutant_id,
|
|
||||||
)
|
)
|
||||||
lateral.show()
|
lateral.show()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue