mirror of https://gitlab.com/pamhyr/pamhyr2
Merge branch 'scenarios' of gitlab.com:pamhyr/pamhyr2 into scenarios
commit
b6a6d54a22
|
|
@ -157,12 +157,12 @@
|
||||||
%%
|
%%
|
||||||
|
|
||||||
%% FIXME: Delete me for the first realease
|
%% FIXME: Delete me for the first realease
|
||||||
\usepackage{draftwatermark}
|
%% \usepackage{draftwatermark}
|
||||||
\SetWatermarkLightness{0.8}
|
%% \SetWatermarkLightness{0.8}
|
||||||
\SetWatermarkAngle{25}
|
%% \SetWatermarkAngle{25}
|
||||||
\SetWatermarkScale{3}
|
%% \SetWatermarkScale{3}
|
||||||
\SetWatermarkFontSize{1cm}
|
%% \SetWatermarkFontSize{1cm}
|
||||||
\SetWatermarkText{Work in progress}
|
%% \SetWatermarkText{Work in progress}
|
||||||
|
|
||||||
%% Icons
|
%% Icons
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,8 @@ class BoundaryCondition(SQLSubModel):
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
tab TEXT NOT NULL,
|
tab TEXT NOT NULL,
|
||||||
node INTEGER,
|
node INTEGER,
|
||||||
|
d50 REAL DEFAULT 0.002,
|
||||||
|
sigma REAL DEFAULT 1,
|
||||||
{Scenario.create_db_add_scenario()},
|
{Scenario.create_db_add_scenario()},
|
||||||
{Scenario.create_db_add_scenario_fk()},
|
{Scenario.create_db_add_scenario_fk()},
|
||||||
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id),
|
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id),
|
||||||
|
|
@ -258,6 +260,17 @@ class BoundaryCondition(SQLSubModel):
|
||||||
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if major == "0" and int(minor) <= 2:
|
||||||
|
if int(release) < 4:
|
||||||
|
execute(
|
||||||
|
"ALTER TABLE boundary_condition " +
|
||||||
|
"ADD COLUMN d50 REAL DEFAULT 0.002"
|
||||||
|
)
|
||||||
|
execute(
|
||||||
|
"ALTER TABLE boundary_condition " +
|
||||||
|
"ADD COLUMN sigma REAL DEFAULT 1"
|
||||||
|
)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -316,7 +329,8 @@ class BoundaryCondition(SQLSubModel):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, deleted, name, type, node, scenario " +
|
"SELECT pamhyr_id, deleted, name, type, node, d50, sigma, " +
|
||||||
|
"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} " +
|
||||||
|
|
@ -331,6 +345,8 @@ class BoundaryCondition(SQLSubModel):
|
||||||
name = next(it)
|
name = next(it)
|
||||||
t = next(it)
|
t = next(it)
|
||||||
node = next(it)
|
node = next(it)
|
||||||
|
d50 = next(it)
|
||||||
|
sigma = next(it)
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
|
|
||||||
ctor = cls._get_ctor_from_type(t)
|
ctor = cls._get_ctor_from_type(t)
|
||||||
|
|
@ -340,9 +356,14 @@ 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":
|
||||||
|
bc.d50 = d50
|
||||||
|
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)
|
||||||
|
|
@ -375,15 +396,22 @@ class BoundaryCondition(SQLSubModel):
|
||||||
if self._node is not None:
|
if self._node is not None:
|
||||||
node = self._node.id
|
node = self._node.id
|
||||||
|
|
||||||
|
d50 = 0.002
|
||||||
|
sigma = 1
|
||||||
|
if self._type == "SL":
|
||||||
|
d50 = self._d50
|
||||||
|
sigma = self._sigma
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"boundary_condition(" +
|
"boundary_condition(" +
|
||||||
"pamhyr_id, deleted, name, type, tab, node, scenario" +
|
"pamhyr_id, deleted, name, type, tab, node, d50, sigma, scenario" +
|
||||||
") " +
|
") " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self._pamhyr_id}, {self._db_format(self.is_deleted())}, " +
|
f"{self._pamhyr_id}, {self._db_format(self.is_deleted())}, " +
|
||||||
f"'{self._db_format(self._name)}', " +
|
f"'{self._db_format(self._name)}', " +
|
||||||
f"'{self._db_format(self._type)}', '{tab}', {node}, " +
|
f"'{self._db_format(self._type)}', '{tab}', {node}, " +
|
||||||
|
f"{d50}, {sigma}, " +
|
||||||
f"{self._status.scenario_id}" +
|
f"{self._status.scenario_id}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
@ -468,6 +496,60 @@ class BoundaryCondition(SQLSubModel):
|
||||||
def has_node(self):
|
def has_node(self):
|
||||||
return self._node is not None
|
return self._node is not None
|
||||||
|
|
||||||
|
@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 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
|
@property
|
||||||
def header(self):
|
def header(self):
|
||||||
return self._header.copy()
|
return self._header.copy()
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ class Data(SQLSubModel):
|
||||||
"SELECT pamhyr_id, deleted, data0, data1, scenario FROM " +
|
"SELECT pamhyr_id, deleted, data0, data1, scenario FROM " +
|
||||||
"boundary_condition_data_adists " +
|
"boundary_condition_data_adists " +
|
||||||
f"WHERE bca = {bca.id} " +
|
f"WHERE bca = {bca.id} " +
|
||||||
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
|
||||||
f"AND scenario = {scenario.id}"
|
f"AND scenario = {scenario.id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -300,6 +301,12 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
if pol_id == -1:
|
if pol_id == -1:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if pol_id not in pid_pol:
|
||||||
|
# ⚠️ cas important : probablement déjà migré
|
||||||
|
print(f"[WARN] pol_id {pol_id} not in pid_pol " +
|
||||||
|
f"→ probably already migrated")
|
||||||
|
continue
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"UPDATE boundary_condition_adists " +
|
f"UPDATE boundary_condition_adists " +
|
||||||
f"SET pollutant = {pid_pol[pol_id]} " +
|
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||||
|
|
@ -312,17 +319,21 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
status = data['status']
|
status = data['status']
|
||||||
nodes = data['nodes']
|
nodes = data['nodes']
|
||||||
scenario = data["scenario"]
|
scenario = data["scenario"]
|
||||||
|
pollutant = data.get("pollutant")
|
||||||
loaded = data['loaded_pid']
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
if scenario is None:
|
if scenario is None:
|
||||||
return new
|
return new
|
||||||
|
|
||||||
table = execute(
|
sql = (
|
||||||
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario " +
|
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario "
|
||||||
"FROM boundary_condition_adists " +
|
"FROM boundary_condition_adists " +
|
||||||
f"WHERE scenario = {scenario.id} " +
|
f"WHERE scenario = {scenario.id} "
|
||||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
|
||||||
)
|
)
|
||||||
|
if pollutant is not None:
|
||||||
|
sql += f"AND pollutant = {pollutant.id} "
|
||||||
|
|
||||||
|
table = execute(sql)
|
||||||
|
|
||||||
if table is not None:
|
if table is not None:
|
||||||
for row in table:
|
for row in table:
|
||||||
|
|
@ -347,7 +358,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
bc.type = bc_type
|
bc.type = bc_type
|
||||||
|
|
||||||
bc.node = None
|
bc.node = None
|
||||||
if row[3] != -1:
|
if node != -1:
|
||||||
tmp = next(
|
tmp = next(
|
||||||
filter(
|
filter(
|
||||||
lambda n: n.id == node, nodes
|
lambda n: n.id == node, nodes
|
||||||
|
|
@ -451,7 +462,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
@node.setter
|
@node.setter
|
||||||
def node(self, node):
|
def node(self, node):
|
||||||
self._node = node
|
self._node = node
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def header(self):
|
def header(self):
|
||||||
|
|
@ -460,7 +471,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
@header.setter
|
@header.setter
|
||||||
def header(self, header):
|
def header(self, header):
|
||||||
self._header = header
|
self._header = header
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pollutant(self):
|
def pollutant(self):
|
||||||
|
|
@ -469,7 +480,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
@pollutant.setter
|
@pollutant.setter
|
||||||
def pollutant(self, pollutant):
|
def pollutant(self, pollutant):
|
||||||
self._pollutant = pollutant
|
self._pollutant = pollutant
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
|
|
@ -478,7 +489,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
@type.setter
|
@type.setter
|
||||||
def type(self, type):
|
def type(self, type):
|
||||||
self._type = type
|
self._type = type
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
|
@ -511,14 +522,17 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
return (new_0, new_1)
|
return (new_0, new_1)
|
||||||
|
|
||||||
def add(self, index: int):
|
def add(self, index: int):
|
||||||
value = (self._default_0, self._default_1)
|
value = Data(
|
||||||
|
self._default_0, self._default_1,
|
||||||
|
status=self._status
|
||||||
|
)
|
||||||
self._data.insert(index, value)
|
self._data.insert(index, value)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def insert(self, index: int, value):
|
def insert(self, index: int, value):
|
||||||
self._data.insert(index, value)
|
self._data.insert(index, value)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def delete_i(self, indexes):
|
def delete_i(self, indexes):
|
||||||
self._data = list(
|
self._data = list(
|
||||||
|
|
@ -530,14 +544,14 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def sort(self, _reverse=False, key=None):
|
def sort(self, _reverse=False, key=None):
|
||||||
if key is None:
|
if key is None:
|
||||||
self._data.sort(reverse=_reverse)
|
self._data.sort(reverse=_reverse)
|
||||||
else:
|
else:
|
||||||
self._data.sort(reverse=_reverse, key=key)
|
self._data.sort(reverse=_reverse, key=key)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def index(self, bc):
|
def index(self, bc):
|
||||||
self._data.index(bc)
|
self._data.index(bc)
|
||||||
|
|
@ -552,10 +566,10 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
def _set_i_c_v(self, index, column, value):
|
def _set_i_c_v(self, index, column, value):
|
||||||
v = list(self._data[index])
|
v = self._data[index]
|
||||||
v[column] = self._types[column](value)
|
v[column] = self._types[column](value)
|
||||||
self._data[index] = tuple(v)
|
self._data[index] = v
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def set_i_0(self, index: int, value):
|
def set_i_0(self, index: int, value):
|
||||||
self._set_i_c_v(index, 0, value)
|
self._set_i_c_v(index, 0, value)
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,13 @@ class BoundaryConditionsAdisTSList(PamhyrModelList):
|
||||||
if data is None:
|
if data is None:
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
new._lst = BoundaryConditionAdisTS._db_load(
|
previous_pollutant = data.get("pollutant")
|
||||||
execute, data
|
data.pop("pollutant", None)
|
||||||
)
|
|
||||||
|
new._lst = BoundaryConditionAdisTS._db_load(execute, data)
|
||||||
|
|
||||||
|
if previous_pollutant is not None:
|
||||||
|
data["pollutant"] = previous_pollutant
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ class D90AdisTSSpec(SQLSubModel):
|
||||||
owner_scenario=owner_scenario
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
if deleted:
|
if deleted:
|
||||||
new_spec.is_deleted()
|
new_spec.set_as_deleted()
|
||||||
|
|
||||||
new_spec.reach = reach
|
new_spec.reach = reach
|
||||||
new_spec.start_rk = start_rk
|
new_spec.start_rk = start_rk
|
||||||
|
|
@ -196,12 +196,12 @@ class D90AdisTSSpec(SQLSubModel):
|
||||||
"d90_default, name, reach, " +
|
"d90_default, name, reach, " +
|
||||||
"start_rk, end_rk, d90, enabled, scenario) " +
|
"start_rk, end_rk, d90, enabled, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, {self._db_format(self.is_deleted())}" +
|
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||||
f"{d90_default}, " +
|
f"{d90_default}, " +
|
||||||
f"'{self._db_format(self._name_section)}', " +
|
f"'{self._db_format(self._name_section)}', " +
|
||||||
f"{self._reach}, " +
|
f"{self._reach}, " +
|
||||||
f"{self._start_rk}, {self._end_rk}, " +
|
f"{self._start_rk}, {self._end_rk}, " +
|
||||||
f"{self._d90}, {self._enabled}" +
|
f"{self._d90}, {self._enabled}, " +
|
||||||
f"{self._status.scenario_id}" +
|
f"{self._status.scenario_id}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pollutant(self):
|
def pollutant(self):
|
||||||
|
|
@ -276,7 +276,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@pollutant.setter
|
@pollutant.setter
|
||||||
def pollutant(self, pollutant):
|
def pollutant(self, pollutant):
|
||||||
self._pollutant = pollutant
|
self._pollutant = pollutant
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def concentration(self):
|
def concentration(self):
|
||||||
|
|
@ -285,7 +285,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@concentration.setter
|
@concentration.setter
|
||||||
def concentration(self, concentration):
|
def concentration(self, concentration):
|
||||||
self._concentration = concentration
|
self._concentration = concentration
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def eg(self):
|
def eg(self):
|
||||||
|
|
@ -294,7 +294,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@eg.setter
|
@eg.setter
|
||||||
def eg(self, eg):
|
def eg(self, eg):
|
||||||
self._eg = eg
|
self._eg = eg
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def em(self):
|
def em(self):
|
||||||
|
|
@ -303,7 +303,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@em.setter
|
@em.setter
|
||||||
def em(self, em):
|
def em(self, em):
|
||||||
self._em = em
|
self._em = em
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ed(self):
|
def ed(self):
|
||||||
|
|
@ -312,7 +312,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@ed.setter
|
@ed.setter
|
||||||
def ed(self, ed):
|
def ed(self, ed):
|
||||||
self._ed = ed
|
self._ed = ed
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
|
|
@ -321,28 +321,45 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@enabled.setter
|
@enabled.setter
|
||||||
def enabled(self, enabled):
|
def enabled(self, enabled):
|
||||||
self._enabled = enabled
|
self._enabled = enabled
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def new(self, index):
|
def new(self, index):
|
||||||
n = ICAdisTSSpec(status=self._status)
|
n = ICAdisTSSpec(status=self._status)
|
||||||
self._data.insert(index, n)
|
self._data.insert(index, n)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def delete(self, data):
|
def delete(self, data):
|
||||||
self._data = list(
|
list(
|
||||||
filter(
|
map(
|
||||||
lambda x: x not in data,
|
lambda x: x.set_as_deleted(),
|
||||||
self._data
|
data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def delete_i(self, indexes):
|
def delete_i(self, indexes):
|
||||||
for ind in indexes:
|
list(
|
||||||
del self._data[ind]
|
map(
|
||||||
self._status.modified()
|
lambda e: e[1].set_as_deleted(),
|
||||||
|
filter(
|
||||||
|
lambda e: e[0] in indexes,
|
||||||
|
enumerate(self._data)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.modified()
|
||||||
|
|
||||||
def insert(self, index, data):
|
def insert(self, index, data):
|
||||||
self._data.insert(index, data)
|
if data in self._data:
|
||||||
self._status.modified()
|
self.undelete([data])
|
||||||
|
else:
|
||||||
|
self._data.insert(index, data)
|
||||||
|
|
||||||
|
self.modified()
|
||||||
|
|
||||||
|
def undelete(self, lst):
|
||||||
|
for x in lst:
|
||||||
|
x.set_as_not_deleted()
|
||||||
|
|
||||||
|
self.modified()
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class ICAdisTSSpec(SQLSubModel):
|
||||||
_sub_classes = []
|
_sub_classes = []
|
||||||
|
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=None):
|
||||||
super(ICAdisTSSpec, self).__init__()
|
super(ICAdisTSSpec, self).__init__()
|
||||||
|
|
||||||
self._status = status
|
self._status = status
|
||||||
|
|
@ -194,7 +194,7 @@ class ICAdisTSSpec(SQLSubModel):
|
||||||
new_spec.rate = rate
|
new_spec.rate = rate
|
||||||
new_spec.enabled = enabled
|
new_spec.enabled = enabled
|
||||||
|
|
||||||
loaded.add(pid)
|
# loaded.add(pid)
|
||||||
new.append(new_spec)
|
new.append(new_spec)
|
||||||
|
|
||||||
data["scenario"] = scenario.parent
|
data["scenario"] = scenario.parent
|
||||||
|
|
@ -211,7 +211,7 @@ class ICAdisTSSpec(SQLSubModel):
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"initial_conditions_adists_spec(id, deleted, " +
|
"initial_conditions_adists_spec(pamhyr_id, deleted, " +
|
||||||
"ic_default, name, reach, " +
|
"ic_default, name, reach, " +
|
||||||
"start_rk, end_rk, concentration, eg, em, ed, rate, " +
|
"start_rk, end_rk, concentration, eg, em, ed, rate, " +
|
||||||
"enabled, scenario) " +
|
"enabled, scenario) " +
|
||||||
|
|
|
||||||
|
|
@ -132,11 +132,13 @@ 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, scenario " +
|
||||||
"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}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -150,16 +152,16 @@ class Data(SQLSubModel):
|
||||||
data1 = next(it)
|
data1 = next(it)
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
|
|
||||||
data = cls(
|
lc = cls(
|
||||||
data0, data1,
|
data0, data1,
|
||||||
id=pid, status=status,
|
id=pid, status=status,
|
||||||
owner_scenario=owner_scenario
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
if deleted:
|
if deleted:
|
||||||
data.set_as_deleted()
|
lc.set_as_deleted()
|
||||||
|
|
||||||
loaded.add(pid)
|
loaded.add(pid)
|
||||||
new.append(data)
|
new.append(lc)
|
||||||
|
|
||||||
data["scenario"] = scenario.parent
|
data["scenario"] = scenario.parent
|
||||||
new += cls._db_load(execute, data)
|
new += cls._db_load(execute, data)
|
||||||
|
|
@ -175,7 +177,7 @@ class Data(SQLSubModel):
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"lateral_contribution_adists(pamhyr_id, deleted," +
|
"lateral_contribution_data_adists(pamhyr_id, deleted," +
|
||||||
"data0, data1, lca, scenario) " +
|
"data0, data1, lca, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||||
|
|
@ -372,16 +374,18 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"lateral_contribution_adists(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}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data["lca"] = self
|
||||||
|
|
||||||
ind = 0
|
ind = 0
|
||||||
for d in self._data:
|
for d in self._data:
|
||||||
data["ind"] = ind
|
data["ind"] = ind
|
||||||
|
|
@ -471,3 +475,57 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
def end_rk(self, end_rk):
|
def end_rk(self, end_rk):
|
||||||
self._end_rk = end_rk
|
self._end_rk = end_rk
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _default_0(self):
|
||||||
|
return self._types[0](0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _default_1(self):
|
||||||
|
return self._types[1](0.0)
|
||||||
|
|
||||||
|
def add(self, index: int):
|
||||||
|
value = Data(self._default_0, self._default_1, status=self._status)
|
||||||
|
self._data.insert(index, value)
|
||||||
|
self.modified()
|
||||||
|
return value
|
||||||
|
|
||||||
|
def insert(self, index: int, data: Data):
|
||||||
|
self._data.insert(index, data)
|
||||||
|
self.modified()
|
||||||
|
|
||||||
|
def delete_i(self, indexes):
|
||||||
|
self._data = list(
|
||||||
|
map(
|
||||||
|
lambda e: e[1],
|
||||||
|
filter(
|
||||||
|
lambda e: e[0] not in indexes,
|
||||||
|
enumerate(self.data)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.modified()
|
||||||
|
|
||||||
|
def index(self, bc):
|
||||||
|
self._data.index(bc)
|
||||||
|
|
||||||
|
def get_i(self, index: int):
|
||||||
|
return self._data[index]
|
||||||
|
|
||||||
|
def get_range(self, _range):
|
||||||
|
lst = []
|
||||||
|
for r in _range:
|
||||||
|
lst.append(r)
|
||||||
|
return lst
|
||||||
|
|
||||||
|
def _set_i_c_v(self, index: int, column: int, value):
|
||||||
|
v = self._data[index]
|
||||||
|
v[column] = self._types[column](value)
|
||||||
|
self._data[index] = v
|
||||||
|
self.modified()
|
||||||
|
|
||||||
|
def set_i_0(self, index: int, value):
|
||||||
|
self._set_i_c_v(index, 0, value)
|
||||||
|
|
||||||
|
def set_i_1(self, index: int, value):
|
||||||
|
self._set_i_c_v(index, 1, value)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ 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 (
|
||||||
|
BoundaryConditionAdisTS,
|
||||||
|
)
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
@ -275,7 +278,8 @@ class PollutantCharacteristics(SQLSubModel):
|
||||||
|
|
||||||
|
|
||||||
class Pollutants(SQLSubModel):
|
class Pollutants(SQLSubModel):
|
||||||
_sub_classes = [PollutantCharacteristics]
|
_sub_classes = [PollutantCharacteristics,
|
||||||
|
BoundaryConditionAdisTS]
|
||||||
|
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None, owner_scenario=-1):
|
status=None, owner_scenario=-1):
|
||||||
|
|
@ -293,6 +297,11 @@ class Pollutants(SQLSubModel):
|
||||||
self._enabled = True
|
self._enabled = True
|
||||||
|
|
||||||
self._data = []
|
self._data = []
|
||||||
|
self._boundary_conditions_adists = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boundary_conditions_adists(self):
|
||||||
|
return self._boundary_conditions_adists
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
@ -415,6 +424,17 @@ class Pollutants(SQLSubModel):
|
||||||
new_pollutant._data = PollutantCharacteristics._db_load(
|
new_pollutant._data = PollutantCharacteristics._db_load(
|
||||||
execute, data=data
|
execute, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
new_pollutant._boundary_conditions_adists = BoundaryConditionAdisTS._db_load(
|
||||||
|
execute, data=data
|
||||||
|
)
|
||||||
|
|
||||||
|
new_pollutant._boundary_conditions_adists = (
|
||||||
|
BoundaryConditionAdisTS._db_load(
|
||||||
|
execute,
|
||||||
|
data=data
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
loaded.add(pid)
|
loaded.add(pid)
|
||||||
new.append(new_pollutant)
|
new.append(new_pollutant)
|
||||||
|
|
@ -455,6 +475,9 @@ class Pollutants(SQLSubModel):
|
||||||
for d in self._data:
|
for d in self._data:
|
||||||
ok &= d._db_save(execute, data)
|
ok &= d._db_save(execute, data)
|
||||||
|
|
||||||
|
for bc in self._boundary_conditions_adists:
|
||||||
|
ok &= bc._db_save(execute, data)
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def _data_traversal(self,
|
def _data_traversal(self,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class Study(SQLModel):
|
class Study(SQLModel):
|
||||||
_version = "0.2.3"
|
_version = "0.2.4"
|
||||||
|
|
||||||
_sub_classes = [
|
_sub_classes = [
|
||||||
Scenario,
|
Scenario,
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,12 @@ class SQLSubModel(PamhyrID):
|
||||||
if node_id == -1:
|
if node_id == -1:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if node_id not in nodes:
|
||||||
|
# ⚠️ cas important : probablement déjà migré
|
||||||
|
print(f"[WARN] node_id {node_id} not in nodes " +
|
||||||
|
f"→ probably already migrated")
|
||||||
|
continue
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"UPDATE {table} " +
|
f"UPDATE {table} " +
|
||||||
f"SET node = {nodes[node_id]} " +
|
f"SET node = {nodes[node_id]} " +
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,7 @@ class AddCommand(QUndoCommand):
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._data.insert(self._index, (
|
self._new = self._data.add(self._index)
|
||||||
self._data._types[0](0), self._data._types[1](0.0)
|
|
||||||
))
|
|
||||||
else:
|
else:
|
||||||
self._data.insert(self._index, self._new)
|
self._data.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,16 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||||
|
|
||||||
name = trad[self._pamhyr_name]
|
name = trad[self._pamhyr_name]
|
||||||
|
|
||||||
|
if self._data is not None:
|
||||||
|
n = self._data.node
|
||||||
|
node_name = next(filter(
|
||||||
|
lambda x: x.id == n, study.river._nodes
|
||||||
|
)).name
|
||||||
|
name += (
|
||||||
|
f" - {study.name} " +
|
||||||
|
f"({node_name})"
|
||||||
|
)
|
||||||
|
|
||||||
super(EditBoundaryConditionWindow, self).__init__(
|
super(EditBoundaryConditionWindow, self).__init__(
|
||||||
title=name,
|
title=name,
|
||||||
study=study,
|
study=study,
|
||||||
|
|
@ -71,16 +81,6 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._data is not None:
|
|
||||||
n = self._data.node
|
|
||||||
node_name = next(filter(
|
|
||||||
lambda x: x.id == n, self._study.river._nodes
|
|
||||||
)).name
|
|
||||||
name += (
|
|
||||||
f" - {study.name} " +
|
|
||||||
f"({node_name})"
|
|
||||||
)
|
|
||||||
|
|
||||||
self._hash_data.append(data)
|
self._hash_data.append(data)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
|
|
|
||||||
|
|
@ -112,18 +112,37 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def __init__(self, pollutant=None, bc_list=None, trad=None, **kwargs):
|
def __init__(self, bc_list=None, pollutant_bc_list=None,
|
||||||
|
trad=None, **kwargs):
|
||||||
self._trad = trad
|
self._trad = trad
|
||||||
self._bc_list = bc_list
|
self._bc_list = bc_list
|
||||||
self._pollutant = pollutant
|
self._pollutant = pollutant_bc_list.id
|
||||||
|
|
||||||
super(TableModel, self).__init__(trad=trad, **kwargs)
|
super(TableModel, self).__init__(trad=trad, **kwargs)
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def _setup_lst(self):
|
||||||
return len(self._bc_list)
|
self._lst = list(
|
||||||
|
filter(
|
||||||
|
lambda bc: bc.pollutant == self._pollutant,
|
||||||
|
self._bc_list.lst
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
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._bc_list.index(bc)
|
||||||
|
|
||||||
|
def rowCount(self, parent=QModelIndex()):
|
||||||
|
return len(self._lst)
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
|
|
||||||
if role != Qt.ItemDataRole.DisplayRole:
|
if role != Qt.ItemDataRole.DisplayRole:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
|
|
@ -131,12 +150,12 @@ class TableModel(PamhyrTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "type":
|
if self._headers[column] == "type":
|
||||||
n = self._bc_list.get(row).type
|
n = self._lst[row].type
|
||||||
if n is None or n == "":
|
if n is None or n == "":
|
||||||
return self._trad["not_associated"]
|
return self._trad["not_associated"]
|
||||||
return n
|
return n
|
||||||
elif self._headers[column] == "node":
|
elif self._headers[column] == "node":
|
||||||
n = self._bc_list.get(row).node
|
n = self._lst[row].node
|
||||||
if n is None:
|
if n is None:
|
||||||
return self._trad["not_associated"]
|
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)
|
||||||
|
|
@ -144,18 +163,6 @@ class TableModel(PamhyrTableModel):
|
||||||
return tmp.name
|
return tmp.name
|
||||||
else:
|
else:
|
||||||
return self._trad["not_associated"]
|
return self._trad["not_associated"]
|
||||||
elif self._headers[column] == "pol":
|
|
||||||
n = self._bc_list.get(row).pollutant
|
|
||||||
if n is None or n == "not_associated" or n == "":
|
|
||||||
return self._trad["not_associated"]
|
|
||||||
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()
|
return QVariant()
|
||||||
|
|
||||||
|
|
@ -168,33 +175,24 @@ class TableModel(PamhyrTableModel):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._headers[column] == "type":
|
if self._headers[column] == "type":
|
||||||
|
global_row = self._global_row(row)
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetTypeCommand(
|
SetTypeCommand(
|
||||||
self._bc_list, row, value
|
self._bc_list, global_row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "node":
|
elif self._headers[column] == "node":
|
||||||
|
global_row = self._global_row(row)
|
||||||
|
node = next(
|
||||||
|
filter(lambda n: n.name == value, self._data.nodes()),
|
||||||
|
None
|
||||||
|
)
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNodeCommand(
|
SetNodeCommand(
|
||||||
self._bc_list, row, self._data.node(value)
|
self._bc_list, global_row, node
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "pol":
|
|
||||||
if value == self._trad["not_associated"]:
|
|
||||||
self._undo.push(
|
|
||||||
SetPolCommand(
|
|
||||||
self._bc_list, row, None
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
pol = next(filter(lambda x: x.name == value,
|
|
||||||
self._data._Pollutants.Pollutants_List)
|
|
||||||
)
|
|
||||||
self._undo.push(
|
|
||||||
SetPolCommand(
|
|
||||||
self._bc_list, row, pol.id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
|
|
@ -203,33 +201,44 @@ class TableModel(PamhyrTableModel):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
self.beginInsertRows(parent, row, row - 1)
|
row = len(self._lst)
|
||||||
|
self.beginInsertRows(parent, row, row)
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._pollutant, self._bc_list, row
|
self._pollutant, self._bc_list, len(self._bc_list)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
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])
|
||||||
|
|
||||||
|
row_by_bc = {
|
||||||
|
id(bc): row for row, bc in enumerate(self._bc_list._lst)
|
||||||
|
}
|
||||||
|
global_rows = [
|
||||||
|
row_by_bc[id(self._lst[row])]
|
||||||
|
for row in rows
|
||||||
|
if 0 <= row < len(self._lst)
|
||||||
|
]
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._bc_list, rows
|
self._bc_list, global_rows
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._setup_lst()
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._undo.undo()
|
self._undo.undo()
|
||||||
|
self._setup_lst()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._undo.redo()
|
self._undo.redo()
|
||||||
|
self._setup_lst()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class SetNodeCommand(QUndoCommand):
|
||||||
self._bcs = bcs
|
self._bcs = bcs
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._bcs.get(self._index).node
|
self._old = self._bcs.get(self._index).node
|
||||||
self._new = node.id
|
self._new = node.id if node is not None else None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._bcs.get(self._index).node = self._old
|
self._bcs.get(self._index).node = self._old
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,22 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "BoundaryConditionsAdisTS"
|
_pamhyr_ui = "BoundaryConditionsAdisTS"
|
||||||
_pamhyr_name = "Boundary conditions AdisTS"
|
_pamhyr_name = "Boundary conditions AdisTS"
|
||||||
|
|
||||||
def __init__(self, study=None, config=None, parent=None):
|
def __init__(self, data=None, pollutant_id=None, study=None,
|
||||||
|
config=None, parent=None):
|
||||||
|
self._data = data
|
||||||
|
self._pollutant_id = pollutant_id
|
||||||
trad = BCAdisTSTranslate()
|
trad = BCAdisTSTranslate()
|
||||||
|
|
||||||
|
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
|
||||||
)
|
)
|
||||||
|
|
||||||
super(BoundaryConditionAdisTSWindow, self).__init__(
|
super(BoundaryConditionAdisTSWindow, self).__init__(
|
||||||
|
|
@ -73,7 +84,6 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self._pollutants_lst = self._study._river._Pollutants
|
|
||||||
self._bcs = self._study.river.boundary_conditions_adists
|
self._bcs = self._study.river.boundary_conditions_adists
|
||||||
|
|
||||||
self.setup_graph()
|
self.setup_graph()
|
||||||
|
|
@ -95,12 +105,6 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
mode="node",
|
mode="node",
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
self._delegate_pol = ComboBoxDelegate(
|
|
||||||
trad=self._trad,
|
|
||||||
data=self._study.river,
|
|
||||||
mode="pol",
|
|
||||||
parent=self
|
|
||||||
)
|
|
||||||
|
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
|
|
@ -110,10 +114,10 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
delegates={
|
delegates={
|
||||||
"type": self._delegate_type,
|
"type": self._delegate_type,
|
||||||
"node": self._delegate_node,
|
"node": self._delegate_node,
|
||||||
"pol": self._delegate_pol,
|
|
||||||
},
|
},
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
bc_list=self._study.river.boundary_conditions_adists,
|
bc_list=self._study.river.boundary_conditions_adists,
|
||||||
|
pollutant_bc_list=self._data,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
data=self._study.river
|
data=self._study.river
|
||||||
)
|
)
|
||||||
|
|
@ -156,7 +160,7 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
)
|
)
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
self._table.add(len(self._bcs))
|
self._table.add(self._table.rowCount())
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
|
|
@ -180,7 +184,7 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
|
||||||
def edit(self):
|
def edit(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
data = self._bcs.get(row)
|
data = self._table.get(row)
|
||||||
|
|
||||||
if data.node is None:
|
if data.node is None:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,4 @@ class BCAdisTSTranslate(MainTranslate):
|
||||||
self._sub_dict["table_headers"] = {
|
self._sub_dict["table_headers"] = {
|
||||||
"type": self._dict["type"],
|
"type": self._dict["type"],
|
||||||
"node": _translate("BoundaryCondition", "Node"),
|
"node": _translate("BoundaryCondition", "Node"),
|
||||||
"pol": _translate("BoundaryCondition", "Pollutant")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,21 +46,21 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class ComboBoxDelegate(QItemDelegate):
|
class ComboBoxDelegate(QItemDelegate):
|
||||||
def __init__(self, data=None, ic_spec_lst=None,
|
def __init__(self, data=None, d90_spec_lst=None,
|
||||||
trad=None, parent=None, mode="reaches"):
|
trad=None, parent=None, mode="reaches"):
|
||||||
super(ComboBoxDelegate, self).__init__(parent)
|
super(ComboBoxDelegate, self).__init__(parent)
|
||||||
|
|
||||||
self._data = data
|
self._data = data
|
||||||
self._mode = mode
|
self._mode = mode
|
||||||
self._trad = trad
|
self._trad = trad
|
||||||
self._ic_spec_lst = ic_spec_lst
|
self._d90_spec_lst = d90_spec_lst
|
||||||
|
|
||||||
def createEditor(self, parent, option, index):
|
def createEditor(self, parent, option, index):
|
||||||
self.editor = QComboBox(parent)
|
self.editor = QComboBox(parent)
|
||||||
|
|
||||||
val = []
|
val = []
|
||||||
if self._mode == "rk":
|
if self._mode == "rk":
|
||||||
reach_id = self._ic_spec_lst[index.row()].reach
|
reach_id = self._d90_spec_lst[index.row()].reach
|
||||||
|
|
||||||
reach = next(filter(
|
reach = next(filter(
|
||||||
lambda edge: edge.id == reach_id, self._data.edges()
|
lambda edge: edge.id == reach_id, self._data.edges()
|
||||||
|
|
@ -118,7 +118,12 @@ class D90TableModel(PamhyrTableModel):
|
||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = self._data._data
|
self._lst = list(
|
||||||
|
filter(
|
||||||
|
lambda d90: d90._deleted is False,
|
||||||
|
self._data._data
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def rowCount(self, parent):
|
||||||
return len(self._lst)
|
return len(self._lst)
|
||||||
|
|
@ -197,18 +202,25 @@ class D90TableModel(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])
|
||||||
|
|
||||||
|
data_rows = {
|
||||||
|
id(d90): i for i, d90 in enumerate(self._data._data)
|
||||||
|
}
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data, self._lst, rows
|
self._data,
|
||||||
|
self._data._data,
|
||||||
|
[data_rows[id(self._lst[row])] for row in rows]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._setup_lst()
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,11 +112,11 @@ class SetCommandSpec(QUndoCommand):
|
||||||
|
|
||||||
|
|
||||||
class AddCommand(QUndoCommand):
|
class AddCommand(QUndoCommand):
|
||||||
def __init__(self, data, ics_spec, index):
|
def __init__(self, data, d90_spec, index):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._data = data
|
self._data = data
|
||||||
self._ics_spec = ics_spec
|
self._d90_spec = d90_spec
|
||||||
self._index = index
|
self._index = index
|
||||||
self._new = None
|
self._new = None
|
||||||
|
|
||||||
|
|
@ -131,21 +131,20 @@ class AddCommand(QUndoCommand):
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
def __init__(self, data, ics_spec, rows):
|
def __init__(self, data, d90_spec, rows):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._data = data
|
self._data = data
|
||||||
self._ics_spec = ics_spec
|
self._d90_spec = d90_spec
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
# self._data = data
|
|
||||||
|
|
||||||
self._ic = []
|
self._d90 = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._ic.append((row, self._ics_spec[row]))
|
self._d90.append((row, self._d90_spec[row]))
|
||||||
self._ic.sort()
|
self._d90.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
for row, el in self._ic:
|
for row, el in self._d90:
|
||||||
self._data.insert(row, el)
|
self._data.insert(row, el)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
|
|
|
||||||
|
|
@ -138,14 +138,14 @@ class D90AdisTSWindow(PamhyrWindow):
|
||||||
self._delegate_reach = ComboBoxDelegate(
|
self._delegate_reach = ComboBoxDelegate(
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
data=self._study.river,
|
data=self._study.river,
|
||||||
ic_spec_lst=self._data[0]._data,
|
d90_spec_lst=self._data[0]._data,
|
||||||
parent=self,
|
parent=self,
|
||||||
mode="reaches"
|
mode="reaches"
|
||||||
)
|
)
|
||||||
self._delegate_rk = ComboBoxDelegate(
|
self._delegate_rk = ComboBoxDelegate(
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
data=self._study.river,
|
data=self._study.river,
|
||||||
ic_spec_lst=self._data[0]._data,
|
d90_spec_lst=self._data[0]._data,
|
||||||
parent=self,
|
parent=self,
|
||||||
mode="rk"
|
mode="rk"
|
||||||
)
|
)
|
||||||
|
|
@ -227,15 +227,15 @@ class D90AdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
table = list(
|
table = list(
|
||||||
map(
|
map(
|
||||||
lambda eic: list(
|
lambda ed90: list(
|
||||||
map(
|
map(
|
||||||
lambda k: eic[1][k],
|
lambda k: ed90[1][k],
|
||||||
["rk", "discharge", "elevation"]
|
["rk", "discharge", "elevation"]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
filter(
|
filter(
|
||||||
lambda eic: eic[0] in rows,
|
lambda ed90: ed90[0] in rows,
|
||||||
enumerate(self._ics.lst())
|
enumerate(self._d90.lst())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class PlotRKZ(PlotRKC):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
def onpick(self, event):
|
def onpick(self, event):
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class PlotStricklers(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self, highlight=None):
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
self.label_x = self._trad["transverse_abscissa"]
|
self.label_x = self._trad["transverse_abscissa"]
|
||||||
self.label_y = self._trad["unit_elevation"]
|
self.label_y = self._trad["unit_elevation"]
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||||
|
from PyQt5.QtWidgets import QDoubleSpinBox
|
||||||
|
from View.Tools.FlexibleDoubleSpinBox import FlexibleDoubleSpinBox
|
||||||
|
from PyQt5.QtWidgets import QDoubleSpinBox
|
||||||
|
from View.Tools.FlexibleDoubleSpinBox import FlexibleDoubleSpinBox
|
||||||
|
|
||||||
|
|
||||||
class ShiftDialog(PamhyrDialog):
|
class ShiftDialog(PamhyrDialog):
|
||||||
|
|
@ -31,8 +35,36 @@ class ShiftDialog(PamhyrDialog):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._replace_spinboxes()
|
||||||
self._init_default_values()
|
self._init_default_values()
|
||||||
|
|
||||||
|
def _replace_spinboxes(self):
|
||||||
|
for name in ["doubleSpinBox_X", "doubleSpinBox_Y", "doubleSpinBox_Z"]:
|
||||||
|
old = self.find(QDoubleSpinBox, name)
|
||||||
|
|
||||||
|
if old is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
new = FlexibleDoubleSpinBox(old.parent())
|
||||||
|
new.setObjectName(old.objectName())
|
||||||
|
|
||||||
|
# Copier propriétés utiles
|
||||||
|
new.setDecimals(old.decimals())
|
||||||
|
new.setMinimum(old.minimum())
|
||||||
|
new.setMaximum(old.maximum())
|
||||||
|
new.setSingleStep(old.singleStep())
|
||||||
|
new.setValue(old.value())
|
||||||
|
new.setGeometry(old.geometry())
|
||||||
|
|
||||||
|
# Remplacement dans layout si présent
|
||||||
|
layout = old.parent().layout()
|
||||||
|
if layout is not None:
|
||||||
|
layout.replaceWidget(old, new)
|
||||||
|
|
||||||
|
old.hide()
|
||||||
|
old.setParent(None)
|
||||||
|
old.deleteLater()
|
||||||
|
|
||||||
def _init_default_values(self):
|
def _init_default_values(self):
|
||||||
self._dx = 0.0
|
self._dx = 0.0
|
||||||
self._dy = 0.0
|
self._dy = 0.0
|
||||||
|
|
|
||||||
|
|
@ -91,3 +91,9 @@ 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."
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from pathlib import Path
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
@ -685,10 +686,24 @@ class GeometryWindow(PamhyrWindow):
|
||||||
)
|
)
|
||||||
|
|
||||||
if filename != '' and filename is not None:
|
if filename != '' and filename is not None:
|
||||||
self._export_to_file_st(filename)
|
suffix = Path(filename).suffix
|
||||||
|
if suffix != "":
|
||||||
|
if suffix == ".st" or suffix == ".ST":
|
||||||
|
self._export_to_file_st(filename[:-3])
|
||||||
|
else:
|
||||||
|
# Warning popup when the format is not exportable
|
||||||
|
win = QtWidgets.QMessageBox()
|
||||||
|
win.setIcon(QtWidgets.QMessageBox.Warning)
|
||||||
|
win.setWindowTitle(self._trad["warning"])
|
||||||
|
win.setText(self._trad["format_not_exportable"])
|
||||||
|
win.exec()
|
||||||
|
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self._export_to_file_st(filename)
|
||||||
|
|
||||||
def _export_to_file_st(self, filename):
|
def _export_to_file_st(self, filename):
|
||||||
with open(filename, "w+") as f:
|
with open(filename+".st", "w+") as f:
|
||||||
f.write("# Exported from Pamhyr2\n")
|
f.write("# Exported from Pamhyr2\n")
|
||||||
self._export_to_file_st_reach(f, self._reach)
|
self._export_to_file_st_reach(f, self._reach)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def river(self):
|
def river(self):
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.anotate_lst = []
|
self.anotate_lst = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class PlotDRK(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self, highlight=None):
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class PlotDischarge(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,12 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = self._data._data
|
self._lst = list(
|
||||||
|
filter(
|
||||||
|
lambda ica: ica._deleted is False,
|
||||||
|
self._data._data
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def rowCount(self, parent):
|
def rowCount(self, parent):
|
||||||
return len(self._lst)
|
return len(self._lst)
|
||||||
|
|
@ -216,18 +221,25 @@ class InitialConditionTableModel(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])
|
||||||
|
|
||||||
|
data_rows = {
|
||||||
|
id(ica): i for i, ica in enumerate(self._data._data)
|
||||||
|
}
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data, self._lst, rows
|
self._data,
|
||||||
|
self._data._data,
|
||||||
|
[data_rows[id(self._lst[row])] for row in rows]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._setup_lst()
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,6 @@ class DelCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._ics_spec = ics_spec
|
self._ics_spec = ics_spec
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
# self._data = data
|
|
||||||
|
|
||||||
self._ic = []
|
self._ic = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
|
|
||||||
|
|
@ -68,15 +68,22 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "InitialConditionsAdisTS"
|
_pamhyr_ui = "InitialConditionsAdisTS"
|
||||||
_pamhyr_name = "Initial condition AdisTS"
|
_pamhyr_name = "Initial condition AdisTS"
|
||||||
|
|
||||||
def __init__(self, data=None, study=None, config=None, parent=None):
|
def __init__(self, data=None, pollutant_id=None, study=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._data[0].name
|
" - " + self._pollutant_name
|
||||||
)
|
)
|
||||||
|
|
||||||
super(InitialConditionsAdisTSWindow, self).__init__(
|
super(InitialConditionsAdisTSWindow, self).__init__(
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
def custom_ticks(self):
|
def custom_ticks(self):
|
||||||
if self.data.header[0] != "time":
|
if self.data.header[0] != "time":
|
||||||
|
|
|
||||||
|
|
@ -34,29 +34,14 @@ class SetDataCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._index = index
|
self._index = index
|
||||||
self._column = column
|
self._column = column
|
||||||
self._old = self._data._data[self._index][self._column]
|
self._old = self._data.get_i(self._index)[self._column]
|
||||||
_type = self._data._types[self._column]
|
self._new = new_value
|
||||||
self._new = _type(new_value)
|
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
if self._column == 0:
|
self._data._set_i_c_v(self._index, self._column, self._old)
|
||||||
self._data._data[self._index] = (
|
|
||||||
self._old, self._data._data[self._index][1]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self._data._data[self._index] = (
|
|
||||||
self._data._data[self._index][0], self._old
|
|
||||||
)
|
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._column == 0:
|
self._data._set_i_c_v(self._index, self._column, self._new)
|
||||||
self._data._data[self._index] = (
|
|
||||||
self._new, self._data._data[self._index][1]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self._data._data[self._index] = (
|
|
||||||
self._data._data[self._index][0], self._new
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AddCommand(QUndoCommand):
|
class AddCommand(QUndoCommand):
|
||||||
|
|
@ -72,11 +57,7 @@ class AddCommand(QUndoCommand):
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._data._data.insert(
|
self._new = self._data.add(self._index)
|
||||||
self._index, (
|
|
||||||
self._data._types[0](0), self._data._types[1](0.0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self._data._data.insert(self._index, self._new)
|
self._data._data.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,14 +50,38 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "EditLateralContributionAdisTS"
|
_pamhyr_ui = "EditLateralContributionAdisTS"
|
||||||
_pamhyr_name = "Edit lateral contribution AdisTS"
|
_pamhyr_name = "Edit lateral contribution AdisTS"
|
||||||
|
|
||||||
def __init__(self, data=None,
|
def __init__(self, data=None, study=None, config=None, parent=None):
|
||||||
study=None, config=None,
|
|
||||||
parent=None):
|
|
||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
trad = LCETranslate()
|
trad = LCETranslate()
|
||||||
|
|
||||||
name = trad[self._pamhyr_name]
|
name = trad[self._pamhyr_name]
|
||||||
|
|
||||||
|
if self._data is not None:
|
||||||
|
if self._data.reach is not None:
|
||||||
|
reach_name = next(filter(
|
||||||
|
lambda reach: reach.id == self._data.reach,
|
||||||
|
study.river.reachs()
|
||||||
|
)).name
|
||||||
|
else:
|
||||||
|
reach_name = trad['not_associated']
|
||||||
|
|
||||||
|
if self._data.begin_rk is not None:
|
||||||
|
begin_rk = self._data.begin_rk
|
||||||
|
else:
|
||||||
|
begin_rk = trad['not_associated']
|
||||||
|
|
||||||
|
if self._data.end_rk is not None:
|
||||||
|
end_rk = self._data.end_rk
|
||||||
|
else:
|
||||||
|
end_rk = trad['not_associated']
|
||||||
|
|
||||||
|
name += (
|
||||||
|
f" - {study.name} - " +
|
||||||
|
f"{reach_name} - " +
|
||||||
|
f"({begin_rk} - " +
|
||||||
|
f"{end_rk})"
|
||||||
|
)
|
||||||
|
|
||||||
super(EditLateralContributionAdisTSWindow, self).__init__(
|
super(EditLateralContributionAdisTSWindow, self).__init__(
|
||||||
title=name,
|
title=name,
|
||||||
study=study,
|
study=study,
|
||||||
|
|
@ -66,20 +90,6 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._data is not None:
|
|
||||||
if self._data.edge is not None:
|
|
||||||
edge_name = next(filter(
|
|
||||||
lambda edge: edge.id == self._data.edge,
|
|
||||||
self._study.river.edges()
|
|
||||||
)).name
|
|
||||||
else:
|
|
||||||
edge_name = trad['not_associated']
|
|
||||||
|
|
||||||
name += (
|
|
||||||
f"{study.name} - " +
|
|
||||||
f"{edge_name})"
|
|
||||||
)
|
|
||||||
|
|
||||||
self._hash_data.append(data)
|
self._hash_data.append(data)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,22 @@ 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):
|
||||||
self._lst = self._data.lateral_contributions_adists.lst
|
if self._lcs_list is not None:
|
||||||
self._tab = self._opt_data
|
self._lcs_pol_list = [
|
||||||
|
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):
|
||||||
|
|
@ -190,17 +202,37 @@ 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])
|
||||||
|
|
||||||
|
row_by_lc = {
|
||||||
|
id(lc): row for row, lc in enumerate(self._lcs_list._lst)
|
||||||
|
}
|
||||||
|
global_rows = [
|
||||||
|
row_by_lc[id(self._lst[row])]
|
||||||
|
for row in rows
|
||||||
|
if 0 <= row < len(self._lst)
|
||||||
|
]
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._lst, rows
|
self._lcs_list, global_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()
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,13 @@ class AddCommand(QUndoCommand):
|
||||||
self._new = None
|
self._new = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
del self._lcs[self._index]
|
self._lcs.delete_i(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_lst.insert(self._index, self._new)
|
self._lcs.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
|
|
@ -107,15 +107,14 @@ class DelCommand(QUndoCommand):
|
||||||
self._lcs = lcs
|
self._lcs = lcs
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
|
|
||||||
self._bc = []
|
self._lc = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._bc.append((row, self._lcs[row]))
|
self._lc.append((row, self._lcs._lst[row]))
|
||||||
self._bc.sort()
|
self._lc.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
for row, el in self._bc:
|
for row, el in self._lc:
|
||||||
self._lcs.insert(row, el)
|
self._lcs.insert(row, el)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
for row in self._rows:
|
self._lcs.delete_i(self._rows)
|
||||||
del self._lcs[row]
|
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,24 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "LateralContributionsAdisTS"
|
_pamhyr_ui = "LateralContributionsAdisTS"
|
||||||
_pamhyr_name = "Lateral contribution AdisTS"
|
_pamhyr_name = "Lateral contribution AdisTS"
|
||||||
|
|
||||||
def __init__(self, study=None, pollutant=None, config=None, parent=None):
|
def __init__(self, data=None, study=None, pollutant_id=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 = pollutant
|
self._pollutant_name = next(
|
||||||
|
(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,
|
||||||
|
|
@ -110,7 +123,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,
|
||||||
)
|
)
|
||||||
|
|
@ -237,6 +250,9 @@ class LateralContributionAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
def edit(self):
|
def edit(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
|
if not rows:
|
||||||
|
return
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
data = self._lcs.lst[row]
|
data = self._lcs.lst[row]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -901,7 +901,18 @@ class GraphWidget(QGraphicsView):
|
||||||
painter.drawRect(sceneRect)
|
painter.drawRect(sceneRect)
|
||||||
|
|
||||||
def wheelEvent(self, event):
|
def wheelEvent(self, event):
|
||||||
self.scaleView(math.pow(2.0, -event.angleDelta().y() / 240.0))
|
factor = math.pow(2.0, event.angleDelta().y() / 240.0)
|
||||||
|
|
||||||
|
old_pos = self.mapToScene(event.pos())
|
||||||
|
|
||||||
|
self.scaleView(factor)
|
||||||
|
|
||||||
|
new_pos = self.mapToScene(event.pos())
|
||||||
|
|
||||||
|
delta = old_pos - new_pos
|
||||||
|
|
||||||
|
# Compensation pour garder le point sous la souris fixe
|
||||||
|
self.translate(delta.x(), delta.y())
|
||||||
|
|
||||||
def scaleView(self, scaleFactor):
|
def scaleView(self, scaleFactor):
|
||||||
factor = self.transform().scale(
|
factor = self.transform().scale(
|
||||||
|
|
@ -914,6 +925,9 @@ class GraphWidget(QGraphicsView):
|
||||||
self.scale(scaleFactor, scaleFactor)
|
self.scale(scaleFactor, scaleFactor)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
|
if self._only_display or self.graph._status.is_read_only():
|
||||||
|
return
|
||||||
|
|
||||||
pos = self.mapToScene(event.pos())
|
pos = self.mapToScene(event.pos())
|
||||||
self.clicked = True
|
self.clicked = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class PlotXY(PamhyrPlot):
|
||||||
self._isometric_axis = True
|
self._isometric_axis = True
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -217,26 +217,39 @@ 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()
|
||||||
|
|
||||||
def boundary_conditions(self):
|
def boundary_conditions(self):
|
||||||
|
rows = self.index_selected_rows()
|
||||||
if self.sub_window_exists(
|
if len(rows) == 0:
|
||||||
BoundaryConditionAdisTSWindow,
|
|
||||||
data=[self._study, None]
|
|
||||||
):
|
|
||||||
bound = self.get_sub_window(
|
|
||||||
BoundaryConditionAdisTSWindow,
|
|
||||||
data=[self._study, None]
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
bound = BoundaryConditionAdisTSWindow(
|
for row in rows:
|
||||||
study=self._study, parent=self
|
pollutant_id = self._pollutants_lst.get(row).id
|
||||||
)
|
|
||||||
bound.show()
|
river = self._study.river
|
||||||
|
bclist = river.boundary_conditions_adists.BCs_AdisTS_List
|
||||||
|
bcs_adists = [
|
||||||
|
x for x in bclist
|
||||||
|
if x.pollutant == pollutant_id
|
||||||
|
]
|
||||||
|
self._data = self._study.river.Pollutants.get(row)
|
||||||
|
if self.sub_window_exists(
|
||||||
|
BoundaryConditionAdisTSWindow,
|
||||||
|
data=[self._study, None, bcs_adists]
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
bound = BoundaryConditionAdisTSWindow(
|
||||||
|
study=self._study,
|
||||||
|
parent=self,
|
||||||
|
data=self._data,
|
||||||
|
pollutant_id=pollutant_id
|
||||||
|
)
|
||||||
|
bound.show()
|
||||||
|
|
||||||
def lateral_contrib(self):
|
def lateral_contrib(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
|
|
@ -245,6 +258,9 @@ 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]
|
||||||
|
|
@ -253,8 +269,9 @@ class PollutantsWindow(PamhyrWindow):
|
||||||
|
|
||||||
lateral = LateralContributionAdisTSWindow(
|
lateral = LateralContributionAdisTSWindow(
|
||||||
study=self._study,
|
study=self._study,
|
||||||
pollutant=pollutant_id,
|
parent=self,
|
||||||
parent=self
|
data=lcs_adists,
|
||||||
|
pollutant_id=pollutant_id,
|
||||||
)
|
)
|
||||||
lateral.show()
|
lateral.show()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class Plot(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class PlotAC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
|
|
|
||||||
|
|
@ -701,7 +701,8 @@ class ResultsWindow(PamhyrWindow):
|
||||||
logger.info("TODO: paste")
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
def _undo(self):
|
def _undo(self):
|
||||||
self._table.undo()
|
logger.info("TODO: undo")
|
||||||
|
# self._table.undo()
|
||||||
|
|
||||||
def _redo(self):
|
def _redo(self):
|
||||||
self._table.redo()
|
self._table.redo()
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,18 @@ class GraphWidget(QGraphicsView):
|
||||||
painter.drawRect(sceneRect)
|
painter.drawRect(sceneRect)
|
||||||
|
|
||||||
def wheelEvent(self, event):
|
def wheelEvent(self, event):
|
||||||
self.scaleView(math.pow(2.0, -event.angleDelta().y() / 240.0))
|
factor = math.pow(2.0, event.angleDelta().y() / 240.0)
|
||||||
|
|
||||||
|
old_pos = self.mapToScene(event.pos())
|
||||||
|
|
||||||
|
self.scaleView(factor)
|
||||||
|
|
||||||
|
new_pos = self.mapToScene(event.pos())
|
||||||
|
|
||||||
|
delta = old_pos - new_pos
|
||||||
|
|
||||||
|
# Compensation pour garder le point sous la souris fixe
|
||||||
|
self.translate(delta.x(), delta.y())
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
key = event.key()
|
key = event.key()
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class Plot(PamhyrPlot):
|
||||||
|
|
||||||
self._auto_relim = False
|
self._auto_relim = False
|
||||||
self._auto_relim_update = False
|
self._auto_relim_update = False
|
||||||
self._autoscale_update = True
|
self._autoscale_update = False
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
# PamhyrWindow.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2025 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 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import QDoubleSpinBox
|
||||||
|
|
||||||
|
|
||||||
|
class FlexibleDoubleSpinBox(QDoubleSpinBox):
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
if event.text() == ".":
|
||||||
|
# Simule une virgule à la place du point
|
||||||
|
event = type(event)(
|
||||||
|
event.type(),
|
||||||
|
event.key(),
|
||||||
|
event.modifiers(),
|
||||||
|
","
|
||||||
|
)
|
||||||
|
|
||||||
|
super().keyPressEvent(event)
|
||||||
|
|
@ -222,10 +222,11 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
||||||
filters.append(new)
|
filters.append(new)
|
||||||
filters = ';;'.join(filters)
|
filters = ';;'.join(filters)
|
||||||
|
|
||||||
file_name, _ = qt_compat._getSaveFileName(
|
file_name, _ = QtWidgets.QFileDialog.getSaveFileName(
|
||||||
self.canvas.parent(),
|
self.canvas.parent(),
|
||||||
_translate("MainWindow_reach", "Select destination file"),
|
_translate("MainWindow_reach", "Select destination file"),
|
||||||
start, filters,
|
start,
|
||||||
|
filters,
|
||||||
selected_filter
|
selected_filter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue