mirror of https://gitlab.com/pamhyr/pamhyr2
HS: Add to scenarios.
parent
9ec21d815d
commit
60ee889794
|
|
@ -216,7 +216,9 @@ class AddFile(SQLSubModel):
|
||||||
"additional_files(pamhyr_id, enabled, deleted, " +
|
"additional_files(pamhyr_id, enabled, deleted, " +
|
||||||
"name, path, text, scenario) " +
|
"name, path, text, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self._pamhyr_id}, {self._enabled}, {self.is_deleted()}, " +
|
f"{self._pamhyr_id}, " +
|
||||||
|
f"{self._db_format(self._enabled)}, " +
|
||||||
|
f"{self._db_format(self.is_deleted())}, " +
|
||||||
f"'{self._db_format(self._name)}', " +
|
f"'{self._db_format(self._name)}', " +
|
||||||
f"'{self._db_format(self._path)}', " +
|
f"'{self._db_format(self._path)}', " +
|
||||||
f"'{self._db_format(self._text)}', " +
|
f"'{self._db_format(self._text)}', " +
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,13 @@ class BasicHS(SQLSubModel):
|
||||||
_sub_classes = [
|
_sub_classes = [
|
||||||
BHSValue,
|
BHSValue,
|
||||||
]
|
]
|
||||||
_id_cnt = 0
|
|
||||||
|
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(BasicHS, self).__init__(id)
|
super(BasicHS, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
self._status = status
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._type = ""
|
self._type = ""
|
||||||
|
|
@ -53,6 +53,7 @@ class BasicHS(SQLSubModel):
|
||||||
execute(f"""
|
execute(f"""
|
||||||
CREATE TABLE hydraulic_structures_basic{ext} (
|
CREATE TABLE hydraulic_structures_basic{ext} (
|
||||||
{cls.create_db_add_pamhyr_id()},
|
{cls.create_db_add_pamhyr_id()},
|
||||||
|
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
enabled BOOLEAN NOT NULL,
|
enabled BOOLEAN NOT NULL,
|
||||||
|
|
@ -79,6 +80,13 @@ class BasicHS(SQLSubModel):
|
||||||
else:
|
else:
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
|
if major == "0" and minor == "1":
|
||||||
|
if release < 2:
|
||||||
|
execute(
|
||||||
|
"ALTER TABLE hydraulic_structures_basic " +
|
||||||
|
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||||
|
)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -135,28 +143,39 @@ class BasicHS(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
status = data["status"]
|
||||||
|
scenario = data["scenario"]
|
||||||
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
|
if scenario is None:
|
||||||
|
return []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, name, type, enabled, hs " +
|
"SELECT pamhyr_id, deleted, name, type, enabled, hs, scenario " +
|
||||||
"FROM hydraulic_structures_basic " +
|
"FROM hydraulic_structures_basic " +
|
||||||
f"WHERE hs = {data['hs_id']} "
|
f"WHERE hs = {data['hs_id']} " +
|
||||||
|
f"AND scenario = {scenario.id} " +
|
||||||
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in table:
|
for row in table:
|
||||||
it = iter(row)
|
it = iter(row)
|
||||||
|
|
||||||
bhs_pid = next(it)
|
bhs_pid = next(it)
|
||||||
|
deleted = (next(it) == 1)
|
||||||
name = next(it)
|
name = next(it)
|
||||||
type = next(it)
|
type = next(it)
|
||||||
enabled = (next(it) == 1)
|
enabled = (next(it) == 1)
|
||||||
hs_id = next(it)
|
hs_id = next(it)
|
||||||
|
owner_scenario = next(it)
|
||||||
|
|
||||||
ctor = cls._get_ctor_from_type(type)
|
ctor = cls._get_ctor_from_type(type)
|
||||||
bhs = ctor(
|
bhs = ctor(
|
||||||
id=bhs_pid,
|
id=bhs_pid, name=name,
|
||||||
name=name,
|
status=status, owner_scenario=owner_scenario
|
||||||
status=data['status']
|
|
||||||
)
|
)
|
||||||
|
if deleted:
|
||||||
|
bhs.set_as_deleted()
|
||||||
|
|
||||||
bhs.enabled = enabled
|
bhs.enabled = enabled
|
||||||
|
|
||||||
|
|
@ -164,31 +183,45 @@ class BasicHS(SQLSubModel):
|
||||||
bhs._data = BHSValue._db_load(
|
bhs._data = BHSValue._db_load(
|
||||||
execute, data
|
execute, data
|
||||||
)
|
)
|
||||||
|
print(f"{bhs_pid} : {deleted}")
|
||||||
|
if deleted:
|
||||||
|
bhs.set_as_deleted()
|
||||||
|
|
||||||
new.append(bhs)
|
new.append(bhs)
|
||||||
|
loaded.add(bhs_pid)
|
||||||
|
|
||||||
|
data["scenario"] = scenario.parent
|
||||||
|
new += cls._db_load(execute, data)
|
||||||
|
data["scenario"] = scenario
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
|
if not self.must_be_saved():
|
||||||
|
return True
|
||||||
|
|
||||||
hs_id = data['hs_id']
|
hs_id = data['hs_id']
|
||||||
|
|
||||||
sql = (
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"hydraulic_structures_basic(pamhyr_id, name, type, enabled, hs) " +
|
"hydraulic_structures_basic(pamhyr_id, deleted, " +
|
||||||
|
"name, type, enabled, hs, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.pamhyr_id}, " +
|
f"{self.pamhyr_id}, " +
|
||||||
|
f"{self._db_format(self.is_deleted())}, " +
|
||||||
f"'{self._db_format(self._name)}', " +
|
f"'{self._db_format(self._name)}', " +
|
||||||
f"'{self._db_format(self._type)}', " +
|
f"'{self._db_format(self._type)}', " +
|
||||||
f"{self._db_format(self.enabled)}, " +
|
f"{self._db_format(self.enabled)}, " +
|
||||||
f"{hs_id} " +
|
f"{hs_id}, " +
|
||||||
|
f"{self._status.scenario_id}"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
execute(sql)
|
|
||||||
|
|
||||||
data['bhs_id'] = self.pamhyr_id
|
data['bhs_id'] = self.pamhyr_id
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM hydraulic_structures_basic_value " +
|
"DELETE FROM hydraulic_structures_basic_value " +
|
||||||
f"WHERE bhs = {self.pamhyr_id}"
|
f"WHERE bhs = {self.pamhyr_id} " +
|
||||||
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for values in self._data:
|
for values in self._data:
|
||||||
|
|
@ -209,7 +242,7 @@ class BasicHS(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 type(self):
|
def type(self):
|
||||||
|
|
@ -218,7 +251,7 @@ class BasicHS(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 enabled(self):
|
def enabled(self):
|
||||||
|
|
@ -227,7 +260,7 @@ class BasicHS(SQLSubModel):
|
||||||
@enabled.setter
|
@enabled.setter
|
||||||
def enabled(self, enabled):
|
def enabled(self, enabled):
|
||||||
self._enabled = enabled
|
self._enabled = enabled
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parameters(self):
|
def parameters(self):
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,11 @@ from Model.HydraulicStructures.Basic.Value import (
|
||||||
|
|
||||||
class NotDefined(BasicHS):
|
class NotDefined(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(NotDefined, self).__init__(
|
super(NotDefined, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "ND"
|
self._type = "ND"
|
||||||
|
|
@ -39,10 +40,11 @@ class NotDefined(BasicHS):
|
||||||
|
|
||||||
class DischargeWeir(BasicHS):
|
class DischargeWeir(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(DischargeWeir, self).__init__(
|
super(DischargeWeir, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "S1"
|
self._type = "S1"
|
||||||
|
|
@ -55,10 +57,11 @@ class DischargeWeir(BasicHS):
|
||||||
|
|
||||||
class TrapezoidalWeir(BasicHS):
|
class TrapezoidalWeir(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(TrapezoidalWeir, self).__init__(
|
super(TrapezoidalWeir, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "S2"
|
self._type = "S2"
|
||||||
|
|
@ -73,10 +76,11 @@ class TrapezoidalWeir(BasicHS):
|
||||||
|
|
||||||
class TriangularWeir(BasicHS):
|
class TriangularWeir(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(TriangularWeir, self).__init__(
|
super(TriangularWeir, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "S3"
|
self._type = "S3"
|
||||||
|
|
@ -90,10 +94,11 @@ class TriangularWeir(BasicHS):
|
||||||
|
|
||||||
class RectangularOrifice(BasicHS):
|
class RectangularOrifice(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(RectangularOrifice, self).__init__(
|
super(RectangularOrifice, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "OR"
|
self._type = "OR"
|
||||||
|
|
@ -110,10 +115,11 @@ class RectangularOrifice(BasicHS):
|
||||||
|
|
||||||
class CircularOrifice(BasicHS):
|
class CircularOrifice(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(CircularOrifice, self).__init__(
|
super(CircularOrifice, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "OC"
|
self._type = "OC"
|
||||||
|
|
@ -127,10 +133,11 @@ class CircularOrifice(BasicHS):
|
||||||
|
|
||||||
class VaultedOrifice(BasicHS):
|
class VaultedOrifice(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(VaultedOrifice, self).__init__(
|
super(VaultedOrifice, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "OV"
|
self._type = "OV"
|
||||||
|
|
@ -145,10 +152,11 @@ class VaultedOrifice(BasicHS):
|
||||||
|
|
||||||
class RectangularGate(BasicHS):
|
class RectangularGate(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(RectangularGate, self).__init__(
|
super(RectangularGate, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "V1"
|
self._type = "V1"
|
||||||
|
|
@ -163,10 +171,11 @@ class RectangularGate(BasicHS):
|
||||||
|
|
||||||
class SimplifiedRectangularGate(BasicHS):
|
class SimplifiedRectangularGate(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(SimplifiedRectangularGate, self).__init__(
|
super(SimplifiedRectangularGate, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "V2"
|
self._type = "V2"
|
||||||
|
|
@ -181,10 +190,11 @@ class SimplifiedRectangularGate(BasicHS):
|
||||||
|
|
||||||
class Borda(BasicHS):
|
class Borda(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(Borda, self).__init__(
|
super(Borda, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "BO"
|
self._type = "BO"
|
||||||
|
|
@ -197,10 +207,11 @@ class Borda(BasicHS):
|
||||||
|
|
||||||
class CheckValve(BasicHS):
|
class CheckValve(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(CheckValve, self).__init__(
|
super(CheckValve, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "CV"
|
self._type = "CV"
|
||||||
|
|
@ -217,10 +228,11 @@ class CheckValve(BasicHS):
|
||||||
|
|
||||||
class UserDefined(BasicHS):
|
class UserDefined(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(UserDefined, self).__init__(
|
super(UserDefined, self).__init__(
|
||||||
id=id, name=name,
|
id=id, name=name,
|
||||||
status=status
|
status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "UD"
|
self._type = "UD"
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,11 @@ class BHSValue(SQLSubModel):
|
||||||
|
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
type=float, value=0.0,
|
type=float, value=0.0,
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(BHSValue, self).__init__(id)
|
super(BHSValue, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
self._status = status
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._type = type
|
self._type = type
|
||||||
|
|
@ -132,12 +133,20 @@ class BHSValue(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
status = data["status"]
|
||||||
|
scenario = data["scenario"]
|
||||||
|
loaded = data['loaded_pid']
|
||||||
bhs_id = data["bhs_id"]
|
bhs_id = data["bhs_id"]
|
||||||
|
|
||||||
|
if scenario is None:
|
||||||
|
return []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, name, type, value " +
|
"SELECT pamhyr_id, name, type, value, scenario " +
|
||||||
"FROM hydraulic_structures_basic_value " +
|
"FROM hydraulic_structures_basic_value " +
|
||||||
f"WHERE bhs = '{bhs_id}'"
|
f"WHERE bhs = '{bhs_id}' " +
|
||||||
|
f"AND scenario = {scenario.id} " +
|
||||||
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in table:
|
for row in table:
|
||||||
|
|
@ -147,14 +156,20 @@ class BHSValue(SQLSubModel):
|
||||||
name = next(it)
|
name = next(it)
|
||||||
type = cls._str_to_type(next(it))
|
type = cls._str_to_type(next(it))
|
||||||
value = next(it)
|
value = next(it)
|
||||||
|
owner_scenario = next(it)
|
||||||
|
|
||||||
val = cls(
|
val = cls(
|
||||||
id=pid, name=name,
|
id=pid, name=name,
|
||||||
type=type, value=value,
|
type=type, value=value,
|
||||||
status=data['status']
|
status=status, owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
||||||
new.append(val)
|
new.append(val)
|
||||||
|
loaded.add(pid)
|
||||||
|
|
||||||
|
data["scenario"] = scenario.parent
|
||||||
|
new += cls._db_load(execute, data)
|
||||||
|
data["scenario"] = scenario
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
@ -164,13 +179,14 @@ class BHSValue(SQLSubModel):
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"hydraulic_structures_basic_value" +
|
"hydraulic_structures_basic_value" +
|
||||||
"(pamhyr_id, name, type, value, bhs) " +
|
"(pamhyr_id, name, type, value, bhs, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self._pamhyr_id}, " +
|
f"{self._pamhyr_id}, " +
|
||||||
f"'{self._db_format(self._name)}', " +
|
f"'{self._db_format(self._name)}', " +
|
||||||
f"'{self._db_format(self._type_to_str(self._type))}', " +
|
f"'{self._db_format(self._type_to_str(self._type))}', " +
|
||||||
f"'{self._db_format(self._value)}', " +
|
f"'{self._db_format(self._value)}', " +
|
||||||
f"{bhs_id}" +
|
f"{bhs_id}, " +
|
||||||
|
f"{self._status.scenario_id}"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -191,4 +207,4 @@ class BHSValue(SQLSubModel):
|
||||||
@value.setter
|
@value.setter
|
||||||
def value(self, value):
|
def value(self, value):
|
||||||
self._value = self._type(value)
|
self._value = self._type(value)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ class HydraulicStructure(SQLSubModel):
|
||||||
_sub_classes = [
|
_sub_classes = [
|
||||||
BasicHS,
|
BasicHS,
|
||||||
]
|
]
|
||||||
_id_cnt = 0
|
|
||||||
|
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
status=None, owner_scenario=-1):
|
||||||
super(HydraulicStructure, self).__init__(id)
|
super(HydraulicStructure, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
self._status = status
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._input_section = None
|
self._input_section = None
|
||||||
|
|
@ -58,6 +58,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
execute(f"""
|
execute(f"""
|
||||||
CREATE TABLE hydraulic_structures{ext} (
|
CREATE TABLE hydraulic_structures{ext} (
|
||||||
{cls.create_db_add_pamhyr_id()},
|
{cls.create_db_add_pamhyr_id()},
|
||||||
|
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
enabled BOOLEAN NOT NULL,
|
enabled BOOLEAN NOT NULL,
|
||||||
input_reach INTEGER,
|
input_reach INTEGER,
|
||||||
|
|
@ -84,9 +85,9 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update(cls, execute, version, data=None):
|
def _db_update(cls, execute, version, data=None):
|
||||||
major, minor, release = version.strip().split(".")
|
major, minor, release = version.strip().split(".")
|
||||||
if major == minor == "0":
|
rl = int(release)
|
||||||
rl = int(release)
|
|
||||||
|
|
||||||
|
if major == minor == "0":
|
||||||
if rl < 6:
|
if rl < 6:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
return True
|
return True
|
||||||
|
|
@ -103,9 +104,16 @@ class HydraulicStructure(SQLSubModel):
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
if major == "0" and minor == "1":
|
if major == "0" and minor == "1":
|
||||||
if int(release) < 1:
|
if rl < 1:
|
||||||
cls._db_update_to_0_1_1(execute, data)
|
cls._db_update_to_0_1_1(execute, data)
|
||||||
|
|
||||||
|
if rl < 2:
|
||||||
|
execute(
|
||||||
|
"ALTER TABLE hydraulic_structures " +
|
||||||
|
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -181,70 +189,97 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
status = data["status"]
|
||||||
|
scenario = data["scenario"]
|
||||||
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
|
if scenario is None:
|
||||||
|
return []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, name, enabled, " +
|
"SELECT pamhyr_id, deleted, name, enabled, " +
|
||||||
"input_section, output_section, " +
|
"input_section, output_section, " +
|
||||||
"input_reach, output_reach " +
|
"input_reach, output_reach, scenario " +
|
||||||
"FROM hydraulic_structures"
|
"FROM hydraulic_structures " +
|
||||||
|
f"WHERE scenario = {scenario.id} " +
|
||||||
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in table:
|
for row in table:
|
||||||
it = iter(row)
|
new.append(cls._db_load_new(execute, data, row))
|
||||||
|
|
||||||
hs_id = next(it)
|
data["scenario"] = scenario.parent
|
||||||
name = next(it)
|
new += cls._db_load(execute, data)
|
||||||
enabled = (next(it) == 1)
|
data["scenario"] = scenario
|
||||||
input_section_id = next(it)
|
|
||||||
input_section_id = (
|
|
||||||
-1 if input_section_id is None else input_section_id
|
|
||||||
)
|
|
||||||
output_section_id = next(it)
|
|
||||||
output_section_id = (
|
|
||||||
-1 if output_section_id is None else output_section_id
|
|
||||||
)
|
|
||||||
input_reach_id = next(it)
|
|
||||||
output_reach_id = next(it)
|
|
||||||
|
|
||||||
hs = cls(
|
|
||||||
id=hs_id, name=name, status=data['status']
|
|
||||||
)
|
|
||||||
|
|
||||||
hs.enabled = enabled
|
|
||||||
hs.input_reach, hs.output_reach = reduce(
|
|
||||||
lambda acc, n: (
|
|
||||||
n if n.pamhyr_id == input_reach_id else acc[0],
|
|
||||||
n if n.pamhyr_id == output_reach_id else acc[1]
|
|
||||||
),
|
|
||||||
data["edges"],
|
|
||||||
[None, None]
|
|
||||||
)
|
|
||||||
sections = []
|
|
||||||
if hs.input_reach is not None:
|
|
||||||
sections += hs.input_reach.reach.profiles
|
|
||||||
if hs.output_reach is not None:
|
|
||||||
sections += hs.output_reach.reach.profiles
|
|
||||||
|
|
||||||
hs.input_section, hs.output_section = reduce(
|
|
||||||
lambda acc, s: (
|
|
||||||
s if s.pamhyr_id == input_section_id else acc[0],
|
|
||||||
s if s.pamhyr_id == output_section_id else acc[1]
|
|
||||||
),
|
|
||||||
sections,
|
|
||||||
[None, None]
|
|
||||||
)
|
|
||||||
|
|
||||||
data['hs_id'] = hs_id
|
|
||||||
hs._data = BasicHS._db_load(execute, data)
|
|
||||||
|
|
||||||
new.append(hs)
|
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_load_new(cls, execute, data, row):
|
||||||
|
it = iter(row)
|
||||||
|
status = data["status"]
|
||||||
|
scenario = data["scenario"]
|
||||||
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
|
hs_id = next(it)
|
||||||
|
deleted = (next(it) == 1)
|
||||||
|
name = next(it)
|
||||||
|
enabled = (next(it) == 1)
|
||||||
|
input_section_id = next(it)
|
||||||
|
input_section_id = (
|
||||||
|
-1 if input_section_id is None else input_section_id
|
||||||
|
)
|
||||||
|
output_section_id = next(it)
|
||||||
|
output_section_id = (
|
||||||
|
-1 if output_section_id is None else output_section_id
|
||||||
|
)
|
||||||
|
input_reach_id = next(it)
|
||||||
|
output_reach_id = next(it)
|
||||||
|
owner_scenario = next(it)
|
||||||
|
|
||||||
|
hs = cls(
|
||||||
|
id=hs_id, name=name, status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
if deleted:
|
||||||
|
new.set_as_deleted()
|
||||||
|
|
||||||
|
hs.enabled = enabled
|
||||||
|
hs.input_reach, hs.output_reach = reduce(
|
||||||
|
lambda acc, n: (
|
||||||
|
n if n.pamhyr_id == input_reach_id else acc[0],
|
||||||
|
n if n.pamhyr_id == output_reach_id else acc[1]
|
||||||
|
),
|
||||||
|
data["edges"],
|
||||||
|
[None, None]
|
||||||
|
)
|
||||||
|
sections = []
|
||||||
|
if hs.input_reach is not None:
|
||||||
|
sections += hs.input_reach.reach.profiles
|
||||||
|
if hs.output_reach is not None:
|
||||||
|
sections += hs.output_reach.reach.profiles
|
||||||
|
|
||||||
|
hs.input_section, hs.output_section = reduce(
|
||||||
|
lambda acc, s: (
|
||||||
|
s if s.pamhyr_id == input_section_id else acc[0],
|
||||||
|
s if s.pamhyr_id == output_section_id else acc[1]
|
||||||
|
),
|
||||||
|
sections,
|
||||||
|
[None, None]
|
||||||
|
)
|
||||||
|
|
||||||
|
loaded.add(hs_id)
|
||||||
|
|
||||||
|
data['hs_id'] = hs_id
|
||||||
|
hs._data = BasicHS._db_load(execute, data)
|
||||||
|
|
||||||
|
return hs
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM hydraulic_structures " +
|
"DELETE FROM hydraulic_structures " +
|
||||||
f"WHERE pamhyr_id = {self.pamhyr_id}"
|
f"WHERE pamhyr_id = {self.pamhyr_id} " +
|
||||||
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
input_reach_id = -1
|
input_reach_id = -1
|
||||||
|
|
@ -266,21 +301,27 @@ class HydraulicStructure(SQLSubModel):
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"hydraulic_structures(" +
|
"hydraulic_structures(" +
|
||||||
" pamhyr_id, name, enabled, input_section, output_section, " +
|
" pamhyr_id, deleted, name, enabled, " +
|
||||||
" input_reach, output_reach" +
|
" input_section, output_section, " +
|
||||||
|
" input_reach, output_reach, " +
|
||||||
|
" scenario" +
|
||||||
") " +
|
") " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.pamhyr_id}, '{self._db_format(self._name)}', " +
|
f"{self.pamhyr_id}, " +
|
||||||
|
f"{self._db_format(self.is_deleted())}, " +
|
||||||
|
f"'{self._db_format(self._name)}', " +
|
||||||
f"{self._db_format(self.enabled)}, " +
|
f"{self._db_format(self.enabled)}, " +
|
||||||
f"{input_section}, {output_section}, " +
|
f"{input_section}, {output_section}, " +
|
||||||
f"{input_reach_id}, {output_reach_id}" +
|
f"{input_reach_id}, {output_reach_id}, " +
|
||||||
|
f"{self._status.scenario_id}"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
data['hs_id'] = self.pamhyr_id
|
data['hs_id'] = self.pamhyr_id
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM hydraulic_structures_basic " +
|
"DELETE FROM hydraulic_structures_basic " +
|
||||||
f"WHERE hs = {self.pamhyr_id}"
|
f"WHERE hs = {self.pamhyr_id} " +
|
||||||
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for basic in self._data:
|
for basic in self._data:
|
||||||
|
|
@ -289,7 +330,16 @@ class HydraulicStructure(SQLSubModel):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self._data)
|
return len(self.lst)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lst(self):
|
||||||
|
return list(
|
||||||
|
filter(
|
||||||
|
lambda bhs: not bhs.is_deleted(),
|
||||||
|
self._data,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
@ -301,7 +351,7 @@ class HydraulicStructure(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 input_rk(self):
|
def input_rk(self):
|
||||||
|
|
@ -322,7 +372,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@input_section.setter
|
@input_section.setter
|
||||||
def input_section(self, input_section):
|
def input_section(self, input_section):
|
||||||
self._input_section = input_section
|
self._input_section = input_section
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def output_section(self):
|
def output_section(self):
|
||||||
|
|
@ -331,7 +381,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@output_section.setter
|
@output_section.setter
|
||||||
def output_section(self, output_section):
|
def output_section(self, output_section):
|
||||||
self._output_section = output_section
|
self._output_section = output_section
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
|
|
@ -340,7 +390,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@enabled.setter
|
@enabled.setter
|
||||||
def enabled(self, enabled):
|
def enabled(self, enabled):
|
||||||
self._enabled = enabled
|
self._enabled = enabled
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def input_reach(self):
|
def input_reach(self):
|
||||||
|
|
@ -349,7 +399,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@input_reach.setter
|
@input_reach.setter
|
||||||
def input_reach(self, input_reach):
|
def input_reach(self, input_reach):
|
||||||
self._input_reach = input_reach
|
self._input_reach = input_reach
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def output_reach(self):
|
def output_reach(self):
|
||||||
|
|
@ -358,26 +408,31 @@ class HydraulicStructure(SQLSubModel):
|
||||||
@output_reach.setter
|
@output_reach.setter
|
||||||
def output_reach(self, output_reach):
|
def output_reach(self, output_reach):
|
||||||
self._output_reach = output_reach
|
self._output_reach = output_reach
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def basic_structures(self):
|
def basic_structures(self):
|
||||||
return self._data.copy()
|
return self.lst.copy()
|
||||||
|
|
||||||
def basic_structure(self, index: int):
|
def basic_structure(self, index: int):
|
||||||
return self._data[index]
|
return self.lst[index]
|
||||||
|
|
||||||
def add(self, index: int):
|
def add(self, index: int):
|
||||||
value = NotDefined(status=self._status)
|
value = NotDefined(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: BasicHS):
|
def insert(self, index: int, value: BasicHS):
|
||||||
self._data.insert(index, value)
|
if value in self._data:
|
||||||
self._status.modified()
|
value.set_as_not_deleted()
|
||||||
|
else:
|
||||||
|
self._data.insert(index, value)
|
||||||
|
|
||||||
def delete_i(self, indexes):
|
self.modified()
|
||||||
|
|
||||||
|
def hard_delete_i(self, indexes):
|
||||||
self._data = list(
|
self._data = list(
|
||||||
map(
|
map(
|
||||||
lambda e: e[1],
|
lambda e: e[1],
|
||||||
|
|
@ -387,20 +442,30 @@ class HydraulicStructure(SQLSubModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
def delete(self, els):
|
def delete_i(self, indexes):
|
||||||
self._data = list(
|
list(
|
||||||
filter(
|
map(
|
||||||
lambda e: e not in els,
|
lambda e: e[1].set_as_deleted(),
|
||||||
self._data
|
filter(
|
||||||
|
lambda e: e[0] in indexes,
|
||||||
|
enumerate(self.lst)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
|
|
||||||
|
def delete(self, els):
|
||||||
|
for el in els:
|
||||||
|
el.set_as_deleted()
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from Model.Tools.PamhyrList import PamhyrModelList
|
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||||
from Model.HydraulicStructures.HydraulicStructures import HydraulicStructure
|
from Model.HydraulicStructures.HydraulicStructures import HydraulicStructure
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,10 +42,10 @@ class HydraulicStructureList(PamhyrModelList):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute("DELETE FROM hydraulic_structures")
|
execute(
|
||||||
|
"DELETE FROM hydraulic_structures " +
|
||||||
if data is None:
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
data = {}
|
)
|
||||||
|
|
||||||
for hs in self._lst:
|
for hs in self._lst:
|
||||||
hs._db_save(execute, data=data)
|
hs._db_save(execute, data=data)
|
||||||
|
|
@ -53,9 +53,12 @@ class HydraulicStructureList(PamhyrModelList):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def new(self, lst, index):
|
def new(self, lst, index):
|
||||||
n = HydraulicStructure(status=self._status)
|
n = HydraulicStructure(
|
||||||
|
status=self._status,
|
||||||
|
owner_scenario=self._status.scenario_id
|
||||||
|
)
|
||||||
self._lst.insert(index, n)
|
self._lst.insert(index, n)
|
||||||
self._status.modified()
|
self.modified()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ from Model.Scenario import Scenario
|
||||||
|
|
||||||
|
|
||||||
class Stricklers(SQLSubModel):
|
class Stricklers(SQLSubModel):
|
||||||
_id_cnt = 0
|
|
||||||
_sub_classes = []
|
_sub_classes = []
|
||||||
|
|
||||||
def __init__(self, id: int = -1,
|
def __init__(self, id: int = -1,
|
||||||
|
|
@ -33,9 +32,9 @@ class Stricklers(SQLSubModel):
|
||||||
medium: float = 15.0,
|
medium: float = 15.0,
|
||||||
status=None, owner_scenario=-1):
|
status=None, owner_scenario=-1):
|
||||||
super(Stricklers, self).__init__(
|
super(Stricklers, self).__init__(
|
||||||
id=id, owner_scenario=owner_scenario
|
id=id, status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
self._status = status
|
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._comment = comment
|
self._comment = comment
|
||||||
|
|
@ -111,7 +110,6 @@ class Stricklers(SQLSubModel):
|
||||||
"FROM stricklers " +
|
"FROM stricklers " +
|
||||||
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))})"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if table is None:
|
if table is None:
|
||||||
|
|
@ -129,9 +127,7 @@ class Stricklers(SQLSubModel):
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
|
|
||||||
new = cls(
|
new = cls(
|
||||||
id=pid,
|
id=pid, name=name, comment=comment,
|
||||||
name=name,
|
|
||||||
comment=comment,
|
|
||||||
minor=minor, medium=medium,
|
minor=minor, medium=medium,
|
||||||
status=status, owner_scenario=owner_scenario
|
status=status, owner_scenario=owner_scenario
|
||||||
)
|
)
|
||||||
|
|
@ -157,7 +153,7 @@ class Stricklers(SQLSubModel):
|
||||||
"name, comment, minor, medium, scenario) " +
|
"name, comment, minor, medium, scenario) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.pamhyr_id}, " +
|
f"{self.pamhyr_id}, " +
|
||||||
f"{self.is_deleted()}, " +
|
f"{self._db_format(self.is_deleted())}, " +
|
||||||
f"'{self._db_format(self.name)}', " +
|
f"'{self._db_format(self.name)}', " +
|
||||||
f"'{self._db_format(self.comment)}', " +
|
f"'{self._db_format(self.comment)}', " +
|
||||||
f"{float(self.minor)}, {float(self.medium)}, " +
|
f"{float(self.minor)}, {float(self.medium)}, " +
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,14 @@ class SetTypeCommand(QUndoCommand):
|
||||||
self._type = new_type
|
self._type = new_type
|
||||||
self._old = self._hs.basic_structure(self._index)
|
self._old = self._hs.basic_structure(self._index)
|
||||||
self._new = self._hs.basic_structure(self._index)\
|
self._new = self._hs.basic_structure(self._index)\
|
||||||
.convert(self._type)
|
.convert(self._type)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._hs.delete_i([self._index])
|
self._hs.hard_delete_i([self._index])
|
||||||
self._hs.insert(self._index, self._old)
|
self._hs.insert(self._index, self._old)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._hs.delete_i([self._index])
|
self._hs.hard_delete_i([self._index])
|
||||||
self._hs.insert(self._index, self._new)
|
self._hs.insert(self._index, self._new)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,20 +50,22 @@ class SetReachCommand(QUndoCommand):
|
||||||
|
|
||||||
self._h_s_lst = h_s_lst
|
self._h_s_lst = h_s_lst
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._h_s_lst.get(self._index).input_reach
|
self._old = self._h_s_lst.get(self._index)\
|
||||||
|
.input_reach
|
||||||
self._new = reach
|
self._new = reach
|
||||||
self._old_rk = self._h_s_lst.get(self._index).input_rk
|
self._old_section = self._h_s_lst.get(self._index)\
|
||||||
self._new_rk = None
|
.input_section
|
||||||
|
self._new_section = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
i = self._h_s_lst.get(self._index)
|
i = self._h_s_lst.get(self._index)
|
||||||
i.input_reach = self._old
|
i.input_reach = self._old
|
||||||
i.input_rk = self._old_rk
|
i.input_section = self._old_section
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
i = self._h_s_lst.get(self._index)
|
i = self._h_s_lst.get(self._index)
|
||||||
i.input_reach = self._new
|
i.input_reach = self._new
|
||||||
i.input_rk = self._new_rk
|
i.input_section = self._new_section
|
||||||
|
|
||||||
|
|
||||||
class SetSectionCommand(QUndoCommand):
|
class SetSectionCommand(QUndoCommand):
|
||||||
|
|
@ -114,7 +116,7 @@ class AddCommand(QUndoCommand):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._h_s_lst.new(self._h_s_lst, self._index)
|
self._new = self._h_s_lst.new(self._h_s_lst, self._index)
|
||||||
else:
|
else:
|
||||||
self._h_s_lst.insert(self._index, self._new)
|
self._h_s_lst.undelete([self._new])
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
|
|
@ -127,12 +129,11 @@ class DelCommand(QUndoCommand):
|
||||||
|
|
||||||
self._h_s = []
|
self._h_s = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._h_s.append((row, self._h_s_lst.get(row)))
|
self._h_s.append(self._h_s_lst.get(row))
|
||||||
self._h_s.sort()
|
self._h_s.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
for row, el in self._h_s:
|
self._h_s_lst.undelete(self._h_s)
|
||||||
self._h_s_lst.insert(row, el)
|
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._h_s_lst.delete_i(self._rows)
|
self._h_s_lst.delete_i(self._rows)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,9 @@ def display_timers():
|
||||||
)
|
)
|
||||||
|
|
||||||
for func, time, calls in lst:
|
for func, time, calls in lst:
|
||||||
|
if time <= 0.000001:
|
||||||
|
continue
|
||||||
|
|
||||||
name = (f"{logger_color_blue()}{func.__module__}" +
|
name = (f"{logger_color_blue()}{func.__module__}" +
|
||||||
f"{logger_color_reset()}" +
|
f"{logger_color_reset()}" +
|
||||||
f".{logger_color_green()}" +
|
f".{logger_color_green()}" +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue