mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
13 Commits
fb8b5aa77f
...
48d6728e1e
| Author | SHA1 | Date |
|---|---|---|
|
|
48d6728e1e | |
|
|
c51c06e6ec | |
|
|
a425c9a6ac | |
|
|
e79ae8ebf5 | |
|
|
e3020d15ba | |
|
|
83e0ecbdc7 | |
|
|
3087023caa | |
|
|
7e080767da | |
|
|
44c3a91d72 | |
|
|
26dc7d8761 | |
|
|
e573fa4197 | |
|
|
7aa0cf4361 | |
|
|
c3faf45f75 |
|
|
@ -514,42 +514,6 @@ class BoundaryCondition(SQLSubModel):
|
|||
self._sigma = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def d50(self):
|
||||
return self._d50
|
||||
|
||||
@d50.setter
|
||||
def d50(self, value):
|
||||
self._d50 = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def sigma(self):
|
||||
return self._sigma
|
||||
|
||||
@sigma.setter
|
||||
def sigma(self, value):
|
||||
self._sigma = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def d50(self):
|
||||
return self._d50
|
||||
|
||||
@d50.setter
|
||||
def d50(self, value):
|
||||
self._d50 = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def sigma(self):
|
||||
return self._sigma
|
||||
|
||||
@sigma.setter
|
||||
def sigma(self, value):
|
||||
self._sigma = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def header(self):
|
||||
return self._header.copy()
|
||||
|
|
|
|||
|
|
@ -70,9 +70,8 @@ class Data(SQLSubModel):
|
|||
def _db_update(cls, execute, version, data=None):
|
||||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 7:
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
@ -250,7 +249,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
created = False
|
||||
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 7:
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ class D90AdisTS(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 6:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ class D90AdisTSSpec(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == 0 and minor < 1:
|
||||
if int(release) < 6:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
@ -95,8 +95,10 @@ class D90AdisTSSpec(SQLSubModel):
|
|||
|
||||
execute(
|
||||
f"INSERT INTO {table_new}_tmp " +
|
||||
"(pamhyr_id, name, d90, enabled, scenario) " +
|
||||
"SELECT pamhyr_id, name, d90, enabled, scenario " +
|
||||
"(pamhyr_id, d90_default, name, reach, " +
|
||||
" start_rk, end_rk, d90, enabled, scenario) " +
|
||||
"SELECT pamhyr_id, d90_default, name, reach, " +
|
||||
" start_rk, end_rk, d90, enabled, scenario " +
|
||||
f"FROM {table}"
|
||||
)
|
||||
|
||||
|
|
@ -109,7 +111,7 @@ class D90AdisTSSpec(SQLSubModel):
|
|||
def _db_update_to_0_2_0_set_d90_pid(cls, execute, data):
|
||||
pid_d90 = data["id2pid"]["d90_adists"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, d90 FROM d90_adists_spec"
|
||||
f"SELECT pamhyr_id, d90_default FROM d90_adists_spec"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
|
|
@ -121,8 +123,8 @@ class D90AdisTSSpec(SQLSubModel):
|
|||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE d90_adists_spec" +
|
||||
f"SET d90 = {pid_d90[d90_id]} " +
|
||||
f"UPDATE d90_adists_spec " +
|
||||
f"SET d90_default = {pid_d90[d90_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ class DIFAdisTS(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 6:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ class DIFAdisTSSpec(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == 0 and minor < 1:
|
||||
if int(release) < 6:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 6:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == 0 and minor < 1:
|
||||
if int(release) < 6:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ class Data(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 7:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
@ -243,8 +243,8 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 7:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ class OutputRKAdists(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 7:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
|
|||
|
|
@ -34,18 +34,6 @@ from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import (
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
# Types de polluants: indice -> nom du type
|
||||
POLLUTANT_TYPES = {
|
||||
0: "Soluté",
|
||||
1: "Particules sphériques",
|
||||
2: "Galets lisses",
|
||||
3: "Sable naturel",
|
||||
4: "Sable concassé",
|
||||
5: "Cylindres longs",
|
||||
6: "Limon, particules cohésives",
|
||||
7: "Flocs"
|
||||
}
|
||||
|
||||
|
||||
class PollutantCharacteristics(SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
|
@ -152,8 +140,8 @@ class PollutantCharacteristics(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 7:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
|
|
@ -344,19 +332,21 @@ class Pollutants(SQLSubModel):
|
|||
|
||||
@data.setter
|
||||
def data(self, data):
|
||||
self._data = [PollutantCharacteristics(type=int(data[0]),
|
||||
diametre=float(data[1]),
|
||||
rho=float(data[2]),
|
||||
porosity=float(data[3]),
|
||||
cdc_riv=float(data[4]),
|
||||
cdc_cas=float(data[5]),
|
||||
apd=float(data[6]),
|
||||
ac=float(data[7]),
|
||||
bc=float(data[8]),
|
||||
pollutant=self,
|
||||
status=self._status
|
||||
)
|
||||
]
|
||||
self._data = [
|
||||
PollutantCharacteristics(
|
||||
type=int(data[0]),
|
||||
diametre=float(data[1]),
|
||||
rho=float(data[2]),
|
||||
porosity=float(data[3]),
|
||||
cdc_riv=float(data[4]),
|
||||
cdc_cas=float(data[5]),
|
||||
apd=float(data[6]),
|
||||
ac=float(data[7]),
|
||||
bc=float(data[8]),
|
||||
pollutant=self,
|
||||
status=self._status
|
||||
)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
|
|
@ -364,6 +354,7 @@ class Pollutants(SQLSubModel):
|
|||
CREATE TABLE pollutants{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
name TEXT NOT NULL,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
{Scenario.create_db_add_scenario_fk()}
|
||||
|
|
@ -380,14 +371,22 @@ class Pollutants(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
created = False
|
||||
|
||||
if major == "0" and int(minor) <= 1:
|
||||
if int(release) < 7:
|
||||
if major == "0" and minor == "0":
|
||||
if int(release) < 11:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
|
||||
if major == "0" and int(minor) < 2:
|
||||
if not created:
|
||||
cls._db_update_to_0_2_0(execute, data)
|
||||
|
||||
if major == "0" and minor == "2":
|
||||
if int(release) < 5:
|
||||
execute(f"ALTER TABLE pollutants " +
|
||||
f"ADD COLUMN enabled BOOLEAN NOT NULL DEFAULT TRUE")
|
||||
|
||||
# cls._db_update_to_0_2_5(execute, data)
|
||||
# # created = True
|
||||
|
||||
if not created:
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
|
@ -426,7 +425,7 @@ class Pollutants(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, deleted, name, scenario FROM pollutants " +
|
||||
"SELECT pamhyr_id, deleted, enabled, name, scenario FROM pollutants " +
|
||||
f"WHERE scenario = {scenario.id} " +
|
||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||
)
|
||||
|
|
@ -437,6 +436,7 @@ class Pollutants(SQLSubModel):
|
|||
|
||||
pid = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
enabled = (next(it) == 1)
|
||||
name = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
||||
|
|
@ -447,6 +447,8 @@ class Pollutants(SQLSubModel):
|
|||
)
|
||||
if deleted:
|
||||
new_pollutant.set_as_deleted()
|
||||
if not enabled:
|
||||
new_pollutant.enabled = False
|
||||
|
||||
data["pollutant"] = new_pollutant
|
||||
new_pollutant._data = PollutantCharacteristics._db_load(
|
||||
|
|
@ -488,9 +490,10 @@ class Pollutants(SQLSubModel):
|
|||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"pollutants(pamhyr_id, deleted, name, scenario) " +
|
||||
"pollutants(pamhyr_id, deleted, enabled, name, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||
f"{self._db_format(self._enabled)}, " +
|
||||
f"'{self._db_format(self._name)}', " +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ logger = logging.getLogger()
|
|||
|
||||
|
||||
class Study(SQLModel):
|
||||
_version = "0.2.4"
|
||||
_version = "0.2.5"
|
||||
|
||||
_sub_classes = [
|
||||
Scenario,
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ from View.Pollutants.Edit.UndoCommand import (
|
|||
SetDataCommand, PasteCommand,
|
||||
)
|
||||
|
||||
from Model.Pollutants.Pollutants import POLLUTANT_TYPES
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
|
@ -51,17 +49,20 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
def __init__(self, type_dict=None, trad=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
self._type_dict = type_dict if type_dict else POLLUTANT_TYPES
|
||||
# self._type_dict = type_dict if type_dict else POLLUTANT_TYPES
|
||||
self._trad = trad
|
||||
self.editor = None
|
||||
|
||||
self._type = {}
|
||||
if self._trad is not None:
|
||||
self._type = self._trad.get_dict("type")
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
self.editor = QComboBox(parent)
|
||||
|
||||
# Ajouter les items du dictionnaire
|
||||
for key in sorted(self._type_dict.keys()):
|
||||
display_text = self._type_dict[key]
|
||||
self.editor.addItem(display_text, userData=key)
|
||||
for key, value in self._type.items():
|
||||
self.editor.addItem(value, key)
|
||||
|
||||
self.editor.currentTextChanged.connect(self.currentItemChanged)
|
||||
return self.editor
|
||||
|
|
@ -96,6 +97,23 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def __init__(self, trad=None, **kwargs):
|
||||
self._trad = trad
|
||||
self._types = {}
|
||||
if self._trad is not None:
|
||||
self._types = self._trad.get_dict("types")
|
||||
|
||||
super(TableModel, self).__init__(trad=trad, **kwargs)
|
||||
|
||||
def is_same_data(self, index, value):
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if self._headers[column] == "type":
|
||||
return int(self._data.data[row][column]) == int(value)
|
||||
|
||||
return super(TableModel, self).is_same_data(index, value)
|
||||
|
||||
def data(self, index, role):
|
||||
if role == Qt.TextAlignmentRole:
|
||||
return Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
|
@ -113,7 +131,7 @@ class TableModel(PamhyrTableModel):
|
|||
|
||||
# Si c'est la colonne "type", convertir l'indice en string
|
||||
if self._headers[column] == "type":
|
||||
return POLLUTANT_TYPES.get(int(value), str(value))
|
||||
value = self._trad.get_dict("type").get(value, "")
|
||||
|
||||
return value
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,18 @@ from View.Pollutants.Translate import PollutantsTranslate
|
|||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
# Types de polluants: indice -> nom du type
|
||||
POLLUTANT_TYPES = {
|
||||
0: "Solutes",
|
||||
1: "Spherical particles",
|
||||
2: "Smooth pebbles",
|
||||
3: "Natural sand",
|
||||
4: "Crushed sand",
|
||||
5: "Elongated cylinders",
|
||||
6: "Silts, cohesive particles",
|
||||
7: "Flocs"
|
||||
}
|
||||
|
||||
|
||||
class EditPollutantTranslate(PollutantsTranslate):
|
||||
def __init__(self):
|
||||
|
|
@ -44,3 +56,14 @@ class EditPollutantTranslate(PollutantsTranslate):
|
|||
"ac": self._dict["unit_ac"],
|
||||
"bc": self._dict["unit_bc"],
|
||||
}
|
||||
|
||||
self._sub_dict["type"] = {
|
||||
0: _translate("Pollutants", "Solutes"),
|
||||
1: _translate("Pollutants", "Spherical particles"),
|
||||
2: _translate("Pollutants", "Smooth pebbles"),
|
||||
3: _translate("Pollutants", "Natural sand"),
|
||||
4: _translate("Pollutants", "Crushed sand"),
|
||||
5: _translate("Pollutants", "Elongated cylinders"),
|
||||
6: _translate("Pollutants", "Silts, cohesive particles"),
|
||||
7: _translate("Pollutants", "Flocs"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ class EditPolluantWindow(PamhyrWindow):
|
|||
editable_headers=editable_headers,
|
||||
delegates={"type": self._delegate_type},
|
||||
data=self._data,
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study.time_system
|
||||
)
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class TableModel(PamhyrTableModel):
|
|||
def enabled(self, row, enabled, parent=QModelIndex()):
|
||||
self._undo.push(
|
||||
SetEnabledCommand(
|
||||
self._data._Pollutants, row, enabled
|
||||
self._lst, row, enabled
|
||||
)
|
||||
)
|
||||
self.layoutChanged.emit()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import tempfile
|
|||
import os
|
||||
|
||||
from queue import Queue
|
||||
from tools import trace, timer
|
||||
from tools import trace, timer, logger_exception
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog, PamhyrWindow
|
||||
|
||||
|
|
@ -81,25 +81,31 @@ class SolverLogFileWindow(PamhyrWindow):
|
|||
self.open_on_editor)
|
||||
|
||||
def setup_text(self):
|
||||
with open(self._file_name, "r") as f:
|
||||
for line in f:
|
||||
line = line.rstrip()
|
||||
self.find(QTextEdit, "textEdit").append(line)
|
||||
try:
|
||||
with open(self._file_name, "r") as f:
|
||||
for line in f:
|
||||
line = line.rstrip()
|
||||
self.find(QTextEdit, "textEdit").append(line)
|
||||
except Exception as e:
|
||||
logger_exception(e)
|
||||
|
||||
def revert(self):
|
||||
self.find(QTextEdit, "textEdit").clear()
|
||||
self.setup_text()
|
||||
|
||||
def open_on_editor(self):
|
||||
p = QProcess(self)
|
||||
try:
|
||||
p = QProcess(self)
|
||||
|
||||
cmd = self._config.editor
|
||||
cmd = cmd.replace("@file", self._file_name)
|
||||
cmd = self._config.editor
|
||||
cmd = cmd.replace("@file", self._file_name)
|
||||
|
||||
cmd = cmd.split()
|
||||
exe = cmd[0]
|
||||
args = cmd[1:]
|
||||
cmd = cmd.split()
|
||||
exe = cmd[0]
|
||||
args = cmd[1:]
|
||||
|
||||
p.start(
|
||||
exe, args,
|
||||
)
|
||||
p.start(
|
||||
exe, args,
|
||||
)
|
||||
except Exception as e:
|
||||
logger_exception(e)
|
||||
|
|
|
|||
553
src/lang/fr.ts
553
src/lang/fr.ts
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue