mirror of https://gitlab.com/pamhyr/pamhyr2
pamhyr: Add saved status in model.
parent
b786bb44e2
commit
d328806916
|
|
@ -5,9 +5,12 @@ from tools import trace, timer, old_pamhyr_date_to_timestamp
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
class BoundaryCondition(object):
|
class BoundaryCondition(object):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "",
|
||||||
|
status = None):
|
||||||
super(BoundaryCondition, self).__init__()
|
super(BoundaryCondition, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._type = ""
|
self._type = ""
|
||||||
self._node = None
|
self._node = None
|
||||||
|
|
@ -36,6 +39,7 @@ class BoundaryCondition(object):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bctype(self):
|
def bctype(self):
|
||||||
|
|
@ -48,6 +52,7 @@ class BoundaryCondition(object):
|
||||||
@node.setter
|
@node.setter
|
||||||
def node(self, node):
|
def node(self, node):
|
||||||
self._node = node
|
self._node = node
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def has_node(self):
|
def has_node(self):
|
||||||
return self._node is not None
|
return self._node is not None
|
||||||
|
|
@ -97,10 +102,12 @@ class BoundaryCondition(object):
|
||||||
def add(self, index:int):
|
def add(self, index:int):
|
||||||
value = (self._default_0, self._default_1)
|
value = (self._default_0, self._default_1)
|
||||||
self._data.insert(index, value)
|
self._data.insert(index, value)
|
||||||
|
self._status.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()
|
||||||
|
|
||||||
def delete_i(self, indexes):
|
def delete_i(self, indexes):
|
||||||
self._data = list(
|
self._data = list(
|
||||||
|
|
@ -112,6 +119,7 @@ class BoundaryCondition(object):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete(self, els):
|
def delete(self, els):
|
||||||
self._data = list(
|
self._data = list(
|
||||||
|
|
@ -120,12 +128,14 @@ class BoundaryCondition(object):
|
||||||
self.data
|
self.data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.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()
|
||||||
|
|
||||||
def get_i(self, index):
|
def get_i(self, index):
|
||||||
return self.data[index]
|
return self.data[index]
|
||||||
|
|
@ -141,6 +151,7 @@ class BoundaryCondition(object):
|
||||||
v = list(self._data[index])
|
v = list(self._data[index])
|
||||||
v[column] = self._types[column](value)
|
v[column] = self._types[column](value)
|
||||||
self._data[index] = tuple(v)
|
self._data[index] = tuple(v)
|
||||||
|
self._status.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)
|
||||||
|
|
@ -160,6 +171,7 @@ class BoundaryCondition(object):
|
||||||
for ind, v in self.data:
|
for ind, v in self.data:
|
||||||
new._set_i_c_v(ind, j, v[i])
|
new._set_i_c_v(ind, j, v[i])
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def move_up(self, index):
|
def move_up(self, index):
|
||||||
|
|
@ -167,9 +179,11 @@ class BoundaryCondition(object):
|
||||||
next = index - 1
|
next = index - 1
|
||||||
d = self._data
|
d = self._data
|
||||||
d[index], d[next] = d[next], d[index]
|
d[index], d[next] = d[next], d[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_down(self, index):
|
def move_down(self, index):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
prev = index + 1
|
prev = index + 1
|
||||||
d = self._data
|
d = self._data
|
||||||
d[index], d[prev] = d[prev], d[index]
|
d[index], d[prev] = d[prev], d[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,11 @@ from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||||
)
|
)
|
||||||
|
|
||||||
class BoundaryConditionList(object):
|
class BoundaryConditionList(object):
|
||||||
def __init__(self):
|
def __init__(self, status = None):
|
||||||
super(BoundaryConditionList, self).__init__()
|
super(BoundaryConditionList, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._tabs = {
|
self._tabs = {
|
||||||
"liquid" : [],
|
"liquid" : [],
|
||||||
"solid" : [],
|
"solid" : [],
|
||||||
|
|
@ -32,18 +34,22 @@ class BoundaryConditionList(object):
|
||||||
|
|
||||||
def set(self, lst, row, new):
|
def set(self, lst, row, new):
|
||||||
self._tabs[lst][row] = new
|
self._tabs[lst][row] = new
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def new(self, lst, index):
|
def new(self, lst, index):
|
||||||
n = NotDefined()
|
n = NotDefined()
|
||||||
self._tabs[lst].insert(index, n)
|
self._tabs[lst].insert(index, n)
|
||||||
|
self._status.modified()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def insert(self, lst, index, new):
|
def insert(self, lst, index, new):
|
||||||
self._tabs[lst].insert(index, new)
|
self._tabs[lst].insert(index, new)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete(self, lst, bcs):
|
def delete(self, lst, bcs):
|
||||||
for bc in bcs:
|
for bc in bcs:
|
||||||
self._tabs[lst].remove(bc)
|
self._tabs[lst].remove(bc)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete_i(self, lst, indexes):
|
def delete_i(self, lst, indexes):
|
||||||
bcs = list(
|
bcs = list(
|
||||||
|
|
@ -59,6 +65,7 @@ class BoundaryConditionList(object):
|
||||||
|
|
||||||
def sort(self, lst, reverse=False, key=None):
|
def sort(self, lst, reverse=False, key=None):
|
||||||
self._tabs[lst].sort(reverse=reverse, key=key)
|
self._tabs[lst].sort(reverse=reverse, key=key)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_up(self, lst, index):
|
def move_up(self, lst, index):
|
||||||
if index < len(self._tabs[lst]):
|
if index < len(self._tabs[lst]):
|
||||||
|
|
@ -66,6 +73,7 @@ class BoundaryConditionList(object):
|
||||||
|
|
||||||
l = self._tabs[lst]
|
l = self._tabs[lst]
|
||||||
l[index], l[next] = l[next], l[index]
|
l[index], l[next] = l[next], l[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_down(self, lst, index):
|
def move_down(self, lst, index):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
|
|
@ -73,6 +81,7 @@ class BoundaryConditionList(object):
|
||||||
|
|
||||||
l = self._tabs[lst]
|
l = self._tabs[lst]
|
||||||
l[index], l[prev] = l[prev], l[index]
|
l[index], l[prev] = l[prev], l[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
new = BoundaryConditionList()
|
new = BoundaryConditionList()
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||||
|
|
||||||
|
|
||||||
class NotDefined(BoundaryCondition):
|
class NotDefined(BoundaryCondition):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(NotDefined, self).__init__(name=name)
|
super(NotDefined, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "ND"
|
self._type = "ND"
|
||||||
self._header = ["x", "y"]
|
self._header = ["x", "y"]
|
||||||
|
|
@ -17,8 +17,8 @@ class NotDefined(BoundaryCondition):
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
class PonctualContribution(BoundaryCondition):
|
class PonctualContribution(BoundaryCondition):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(PonctualContribution, self).__init__(name=name)
|
super(PonctualContribution, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "PC"
|
self._type = "PC"
|
||||||
self._header = ["time", "debit"]
|
self._header = ["time", "debit"]
|
||||||
|
|
@ -29,8 +29,8 @@ class PonctualContribution(BoundaryCondition):
|
||||||
return ["liquid"]
|
return ["liquid"]
|
||||||
|
|
||||||
class TimeOverZ(BoundaryCondition):
|
class TimeOverZ(BoundaryCondition):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(TimeOverZ, self).__init__(name=name)
|
super(TimeOverZ, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "TZ"
|
self._type = "TZ"
|
||||||
self._header = ["time", "z"]
|
self._header = ["time", "z"]
|
||||||
|
|
@ -41,8 +41,8 @@ class TimeOverZ(BoundaryCondition):
|
||||||
return ["liquid"]
|
return ["liquid"]
|
||||||
|
|
||||||
class TimeOverDebit(BoundaryCondition):
|
class TimeOverDebit(BoundaryCondition):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(TimeOverDebit, self).__init__(name=name)
|
super(TimeOverDebit, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "TD"
|
self._type = "TD"
|
||||||
self._header = ["time", "debit"]
|
self._header = ["time", "debit"]
|
||||||
|
|
@ -53,8 +53,8 @@ class TimeOverDebit(BoundaryCondition):
|
||||||
return ["liquid"]
|
return ["liquid"]
|
||||||
|
|
||||||
class ZOverDebit(BoundaryCondition):
|
class ZOverDebit(BoundaryCondition):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(ZOverDebit, self).__init__(name=name)
|
super(ZOverDebit, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "ZD"
|
self._type = "ZD"
|
||||||
self._header = ["z", "debit"]
|
self._header = ["z", "debit"]
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
class Point(object):
|
class Point(object):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(Point, self).__init__()
|
super(Point, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -15,6 +17,7 @@ class Point(object):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def point_is_named(self):
|
def point_is_named(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ from Model.Geometry.Point import Point
|
||||||
|
|
||||||
class PointAC(Point):
|
class PointAC(Point):
|
||||||
def __init__(self, a:float = 0.0, c:float = 0.0,
|
def __init__(self, a:float = 0.0, c:float = 0.0,
|
||||||
name: str = ""):
|
name: str = "", status = None):
|
||||||
super(PointXY, self).__init__(name = name)
|
super(PointXY, self).__init__(name = name, status = status)
|
||||||
|
|
||||||
self._a = float(a)
|
self._a = float(a)
|
||||||
self._c = float(c)
|
self._c = float(c)
|
||||||
|
|
@ -22,6 +22,7 @@ class PointAC(Point):
|
||||||
@a.setter
|
@a.setter
|
||||||
def a(self, value):
|
def a(self, value):
|
||||||
self._a = float(value)
|
self._a = float(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def c(self):
|
def c(self):
|
||||||
|
|
@ -30,6 +31,7 @@ class PointAC(Point):
|
||||||
@c.setter
|
@c.setter
|
||||||
def c(self, value):
|
def c(self, value):
|
||||||
self._c = float(value)
|
self._c = float(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def dist(self, p2):
|
def dist(self, p2):
|
||||||
return PointAC.distance(self, p2)
|
return PointAC.distance(self, p2)
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ from Model.Geometry.Point import Point
|
||||||
|
|
||||||
class PointXYZ(Point):
|
class PointXYZ(Point):
|
||||||
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
|
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
|
||||||
name:str = ""):
|
name:str = "", status = None):
|
||||||
super(PointXYZ, self).__init__(name=name)
|
super(PointXYZ, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._x = float(x)
|
self._x = float(x)
|
||||||
self._y = float(y)
|
self._y = float(y)
|
||||||
|
|
@ -47,6 +47,7 @@ class PointXYZ(Point):
|
||||||
@x.setter
|
@x.setter
|
||||||
def x(self, value):
|
def x(self, value):
|
||||||
self._x = float(value)
|
self._x = float(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def y(self):
|
def y(self):
|
||||||
|
|
@ -55,6 +56,7 @@ class PointXYZ(Point):
|
||||||
@y.setter
|
@y.setter
|
||||||
def y(self, value):
|
def y(self, value):
|
||||||
self._y = float(value)
|
self._y = float(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def z(self):
|
def z(self):
|
||||||
|
|
@ -63,6 +65,7 @@ class PointXYZ(Point):
|
||||||
@z.setter
|
@z.setter
|
||||||
def z(self, value):
|
def z(self, value):
|
||||||
self._z = float(value)
|
self._z = float(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def is_nan(self):
|
def is_nan(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,12 @@ class Profile(object):
|
||||||
def __init__(self, num: int = 0,
|
def __init__(self, num: int = 0,
|
||||||
kp:float = 0.0, name:str = "",
|
kp:float = 0.0, name:str = "",
|
||||||
code1: int = 0, code2: int = 0,
|
code1: int = 0, code2: int = 0,
|
||||||
_type:str = "", reach = None):
|
_type:str = "", reach = None,
|
||||||
|
status = None):
|
||||||
super(Profile, self).__init__()
|
super(Profile, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._num = int(num)
|
self._num = int(num)
|
||||||
self._code1 = int(code1)
|
self._code1 = int(code1)
|
||||||
self._code2 = int(code2)
|
self._code2 = int(code2)
|
||||||
|
|
@ -46,6 +49,7 @@ class Profile(object):
|
||||||
@num.setter
|
@num.setter
|
||||||
def num(self, value: int):
|
def num(self, value: int):
|
||||||
self._num = int(value)
|
self._num = int(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code1(self):
|
def code1(self):
|
||||||
|
|
@ -58,6 +62,7 @@ class Profile(object):
|
||||||
@code1.setter
|
@code1.setter
|
||||||
def code1(self, value: int):
|
def code1(self, value: int):
|
||||||
self._code1 = int(value)
|
self._code1 = int(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code2(self):
|
def code2(self):
|
||||||
|
|
@ -70,6 +75,7 @@ class Profile(object):
|
||||||
@code2.setter
|
@code2.setter
|
||||||
def code2(self, value: int):
|
def code2(self, value: int):
|
||||||
self._code2 = int(value)
|
self._code2 = int(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nb_points(self):
|
def nb_points(self):
|
||||||
|
|
@ -86,6 +92,7 @@ class Profile(object):
|
||||||
@kp.setter
|
@kp.setter
|
||||||
def kp(self, value: float):
|
def kp(self, value: float):
|
||||||
self._kp = float(value)
|
self._kp = float(value)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
@ -98,6 +105,7 @@ class Profile(object):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, value: str):
|
def name(self, value: str):
|
||||||
self._name = value.strip()
|
self._name = value.strip()
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def profile_type(self):
|
def profile_type(self):
|
||||||
|
|
@ -110,6 +118,7 @@ class Profile(object):
|
||||||
@profile_type.setter
|
@profile_type.setter
|
||||||
def profile_type(self, value: str):
|
def profile_type(self, value: str):
|
||||||
self._profile_type = value
|
self._profile_type = value
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def point(self, i:int):
|
def point(self, i:int):
|
||||||
if i < len(self._points):
|
if i < len(self._points):
|
||||||
|
|
@ -138,6 +147,7 @@ class Profile(object):
|
||||||
Nothing.
|
Nothing.
|
||||||
"""
|
"""
|
||||||
self._points.insert(index, point)
|
self._points.insert(index, point)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
|
||||||
def delete(self, indexes: int):
|
def delete(self, indexes: int):
|
||||||
|
|
@ -165,6 +175,7 @@ class Profile(object):
|
||||||
self.points
|
self.points
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete_points(self, points):
|
def delete_points(self, points):
|
||||||
"""Delete some elements in profile list
|
"""Delete some elements in profile list
|
||||||
|
|
@ -181,6 +192,7 @@ class Profile(object):
|
||||||
self.points
|
self.points
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
# Move
|
# Move
|
||||||
|
|
||||||
|
|
@ -190,6 +202,7 @@ class Profile(object):
|
||||||
|
|
||||||
p = self._points
|
p = self._points
|
||||||
p[index], p[next] = p[next], p[index]
|
p[index], p[next] = p[next], p[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_down_point(self, index: int):
|
def move_down_point(self, index: int):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
|
|
@ -197,6 +210,7 @@ class Profile(object):
|
||||||
|
|
||||||
p = self._points
|
p = self._points
|
||||||
p[index], p[prev] = p[prev], p[index]
|
p[index], p[prev] = p[prev], p[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
# Sort
|
# Sort
|
||||||
|
|
||||||
|
|
@ -213,6 +227,7 @@ class Profile(object):
|
||||||
key=predicate,
|
key=predicate,
|
||||||
reverse=is_reversed
|
reverse=is_reversed
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def sort_with_indexes(self, indexes: list):
|
def sort_with_indexes(self, indexes: list):
|
||||||
|
|
@ -228,6 +243,7 @@ class Profile(object):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
# Abstract method, must be implemented for in non abstract class
|
# Abstract method, must be implemented for in non abstract class
|
||||||
def get_station(self):
|
def get_station(self):
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ class ProfileXYZ(Profile):
|
||||||
reach = None,
|
reach = None,
|
||||||
num = 0,
|
num = 0,
|
||||||
nb_point: int = 0,
|
nb_point: int = 0,
|
||||||
code1: int = 0, code2: int = 0):
|
code1: int = 0, code2: int = 0,
|
||||||
|
status = None):
|
||||||
"""ProfileXYZ constructor
|
"""ProfileXYZ constructor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -37,6 +38,7 @@ class ProfileXYZ(Profile):
|
||||||
code1 = code1, code2 = code2,
|
code1 = code1, code2 = code2,
|
||||||
_type = "XYZ",
|
_type = "XYZ",
|
||||||
reach = reach,
|
reach = reach,
|
||||||
|
status = status,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -101,8 +103,9 @@ class ProfileXYZ(Profile):
|
||||||
Nothing.
|
Nothing.
|
||||||
"""
|
"""
|
||||||
for point in list_points:
|
for point in list_points:
|
||||||
pt = PointXYZ(*point)
|
pt = PointXYZ(*point, status=self._status)
|
||||||
self._points.append(pt)
|
self._points.append(pt)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def get_point_i(self, index: int) -> PointXYZ:
|
def get_point_i(self, index: int) -> PointXYZ:
|
||||||
"""Get point at index.
|
"""Get point at index.
|
||||||
|
|
@ -124,8 +127,9 @@ class ProfileXYZ(Profile):
|
||||||
Returns:
|
Returns:
|
||||||
Nothing.
|
Nothing.
|
||||||
"""
|
"""
|
||||||
point_xyz = PointXYZ(0., 0., 0.)
|
point_xyz = PointXYZ(0., 0., 0., status=self._status)
|
||||||
self._points.append(point_xyz)
|
self._points.append(point_xyz)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def insert(self, index: int):
|
def insert(self, index: int):
|
||||||
"""Insert a new point at index.
|
"""Insert a new point at index.
|
||||||
|
|
@ -136,8 +140,9 @@ class ProfileXYZ(Profile):
|
||||||
Returns:
|
Returns:
|
||||||
The new point.
|
The new point.
|
||||||
"""
|
"""
|
||||||
point = PointXYZ(0., 0., 0.)
|
point = PointXYZ(0., 0., 0., status=self._status)
|
||||||
self._points.insert(index, point)
|
self._points.insert(index, point)
|
||||||
|
self._status.modified()
|
||||||
return point
|
return point
|
||||||
|
|
||||||
def filter_isnan(self, lst):
|
def filter_isnan(self, lst):
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||||
from Model.Except import FileFormatError, exception_message_box
|
from Model.Except import FileFormatError, exception_message_box
|
||||||
|
|
||||||
class Reach:
|
class Reach:
|
||||||
def __init__(self, parent=None):
|
def __init__(self, status=None, parent=None):
|
||||||
|
self._status = status
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self._profiles: List[Profile] = []
|
self._profiles: List[Profile] = []
|
||||||
|
|
||||||
|
|
@ -86,6 +87,8 @@ class Reach:
|
||||||
self._profiles.insert(index, profile)
|
self._profiles.insert(index, profile)
|
||||||
self._update_profile_numbers()
|
self._update_profile_numbers()
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
|
|
||||||
def insert_profile(self, index: int, profile: Profile):
|
def insert_profile(self, index: int, profile: Profile):
|
||||||
|
|
@ -99,6 +102,7 @@ class Reach:
|
||||||
"""
|
"""
|
||||||
self._profiles.insert(index, profile)
|
self._profiles.insert(index, profile)
|
||||||
self._update_profile_numbers()
|
self._update_profile_numbers()
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
|
||||||
def delete(self, indexes):
|
def delete(self, indexes):
|
||||||
|
|
@ -127,6 +131,7 @@ class Reach:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._update_profile_numbers()
|
self._update_profile_numbers()
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete_profiles(self, profiles):
|
def delete_profiles(self, profiles):
|
||||||
"""Delete some elements in profile list
|
"""Delete some elements in profile list
|
||||||
|
|
@ -144,6 +149,7 @@ class Reach:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._update_profile_numbers()
|
self._update_profile_numbers()
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
|
||||||
def move_up_profile(self, index: int):
|
def move_up_profile(self, index: int):
|
||||||
|
|
@ -152,6 +158,7 @@ class Reach:
|
||||||
|
|
||||||
p = self._profiles
|
p = self._profiles
|
||||||
p[index], p[next] = p[next], p[index]
|
p[index], p[next] = p[next], p[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_down_profile(self, index: int):
|
def move_down_profile(self, index: int):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
|
|
@ -159,6 +166,7 @@ class Reach:
|
||||||
|
|
||||||
p = self._profiles
|
p = self._profiles
|
||||||
p[index], p[prev] = p[prev], p[index]
|
p[index], p[prev] = p[prev], p[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def get_x(self):
|
def get_x(self):
|
||||||
return [profile.x() for profile in self.profiles]
|
return [profile.x() for profile in self.profiles]
|
||||||
|
|
@ -260,6 +268,7 @@ class Reach:
|
||||||
self._compute_guidelines_cache(guide_set, named_points,
|
self._compute_guidelines_cache(guide_set, named_points,
|
||||||
complete, incomplete)
|
complete, incomplete)
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
return (complete, incomplete)
|
return (complete, incomplete)
|
||||||
|
|
||||||
def _map_guidelines_points(self, func, full=False):
|
def _map_guidelines_points(self, func, full=False):
|
||||||
|
|
@ -306,6 +315,7 @@ class Reach:
|
||||||
key=lambda profile: profile.kp,
|
key=lambda profile: profile.kp,
|
||||||
reverse=is_reversed
|
reverse=is_reversed
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def sort_with_indexes(self, indexes: list):
|
def sort_with_indexes(self, indexes: list):
|
||||||
|
|
@ -321,6 +331,7 @@ class Reach:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
# Import/Export
|
# Import/Export
|
||||||
|
|
||||||
|
|
@ -352,6 +363,7 @@ class Reach:
|
||||||
self._profiles.append(prof)
|
self._profiles.append(prof)
|
||||||
self._update_profile_numbers()
|
self._update_profile_numbers()
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
print(e)
|
print(e)
|
||||||
exception_message_box(e)
|
exception_message_box(e)
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ from tools import trace, timer, old_pamhyr_date_to_timestamp
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
class LateralContribution(object):
|
class LateralContribution(object):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status = None):
|
||||||
super(LateralContribution, self).__init__()
|
super(LateralContribution, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._type = ""
|
self._type = ""
|
||||||
self._edge = None
|
self._edge = None
|
||||||
|
|
@ -36,6 +38,7 @@ class LateralContribution(object):
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lctype(self):
|
def lctype(self):
|
||||||
|
|
@ -48,6 +51,7 @@ class LateralContribution(object):
|
||||||
@edge.setter
|
@edge.setter
|
||||||
def edge(self, edge):
|
def edge(self, edge):
|
||||||
self._edge = edge
|
self._edge = edge
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def has_edge(self):
|
def has_edge(self):
|
||||||
return self._edge is not None
|
return self._edge is not None
|
||||||
|
|
@ -97,10 +101,12 @@ class LateralContribution(object):
|
||||||
def add(self, index:int):
|
def add(self, index:int):
|
||||||
value = (self._default_0, self._default_1)
|
value = (self._default_0, self._default_1)
|
||||||
self._data.insert(index, value)
|
self._data.insert(index, value)
|
||||||
|
self._status.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()
|
||||||
|
|
||||||
def delete_i(self, indexes):
|
def delete_i(self, indexes):
|
||||||
self._data = list(
|
self._data = list(
|
||||||
|
|
@ -112,6 +118,7 @@ class LateralContribution(object):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete(self, els):
|
def delete(self, els):
|
||||||
self._data = list(
|
self._data = list(
|
||||||
|
|
@ -120,12 +127,14 @@ class LateralContribution(object):
|
||||||
self.data
|
self.data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.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()
|
||||||
|
|
||||||
def get_i(self, index):
|
def get_i(self, index):
|
||||||
return self.data[index]
|
return self.data[index]
|
||||||
|
|
@ -141,6 +150,7 @@ class LateralContribution(object):
|
||||||
v = list(self._data[index])
|
v = list(self._data[index])
|
||||||
v[column] = self._types[column](value)
|
v[column] = self._types[column](value)
|
||||||
self._data[index] = tuple(v)
|
self._data[index] = tuple(v)
|
||||||
|
self._status.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)
|
||||||
|
|
@ -160,6 +170,7 @@ class LateralContribution(object):
|
||||||
for ind, v in self.data:
|
for ind, v in self.data:
|
||||||
new._set_i_c_v(ind, j, v[i])
|
new._set_i_c_v(ind, j, v[i])
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def move_up(self, index):
|
def move_up(self, index):
|
||||||
|
|
@ -167,9 +178,11 @@ class LateralContribution(object):
|
||||||
next = index - 1
|
next = index - 1
|
||||||
d = self._data
|
d = self._data
|
||||||
d[index], d[next] = d[next], d[index]
|
d[index], d[next] = d[next], d[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_down(self, index):
|
def move_down(self, index):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
prev = index + 1
|
prev = index + 1
|
||||||
d = self._data
|
d = self._data
|
||||||
d[index], d[prev] = d[prev], d[index]
|
d[index], d[prev] = d[prev], d[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,11 @@ from Model.LateralContribution.LateralContributionTypes import (
|
||||||
)
|
)
|
||||||
|
|
||||||
class LateralContributionList(object):
|
class LateralContributionList(object):
|
||||||
def __init__(self):
|
def __init__(self, status = None):
|
||||||
super(LateralContributionList, self).__init__()
|
super(LateralContributionList, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._tabs = {
|
self._tabs = {
|
||||||
"liquid" : [],
|
"liquid" : [],
|
||||||
"solid" : [],
|
"solid" : [],
|
||||||
|
|
@ -30,18 +32,22 @@ class LateralContributionList(object):
|
||||||
|
|
||||||
def set(self, lst, row, new):
|
def set(self, lst, row, new):
|
||||||
self._tabs[lst][row] = new
|
self._tabs[lst][row] = new
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def new(self, lst, index):
|
def new(self, lst, index):
|
||||||
n = NotDefined()
|
n = NotDefined()
|
||||||
self._tabs[lst].insert(index, n)
|
self._tabs[lst].insert(index, n)
|
||||||
|
self._status.modified()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def insert(self, lst, index, new):
|
def insert(self, lst, index, new):
|
||||||
self._tabs[lst].insert(index, new)
|
self._tabs[lst].insert(index, new)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete(self, lst, bcs):
|
def delete(self, lst, bcs):
|
||||||
for bc in bcs:
|
for bc in bcs:
|
||||||
self._tabs[lst].remove(bc)
|
self._tabs[lst].remove(bc)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def delete_i(self, lst, indexes):
|
def delete_i(self, lst, indexes):
|
||||||
bcs = list(
|
bcs = list(
|
||||||
|
|
@ -57,6 +63,7 @@ class LateralContributionList(object):
|
||||||
|
|
||||||
def sort(self, lst, reverse=False, key=None):
|
def sort(self, lst, reverse=False, key=None):
|
||||||
self._tabs[lst].sort(reverse=reverse, key=key)
|
self._tabs[lst].sort(reverse=reverse, key=key)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_up(self, lst, index):
|
def move_up(self, lst, index):
|
||||||
if index < len(self._tabs[lst]):
|
if index < len(self._tabs[lst]):
|
||||||
|
|
@ -64,6 +71,7 @@ class LateralContributionList(object):
|
||||||
|
|
||||||
l = self._tabs[lst]
|
l = self._tabs[lst]
|
||||||
l[index], l[next] = l[next], l[index]
|
l[index], l[next] = l[next], l[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def move_down(self, lst, index):
|
def move_down(self, lst, index):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
|
|
@ -71,6 +79,7 @@ class LateralContributionList(object):
|
||||||
|
|
||||||
l = self._tabs[lst]
|
l = self._tabs[lst]
|
||||||
l[index], l[prev] = l[prev], l[index]
|
l[index], l[prev] = l[prev], l[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
new = LateralContributionList()
|
new = LateralContributionList()
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ from Model.LateralContribution.LateralContribution import LateralContribution
|
||||||
|
|
||||||
|
|
||||||
class NotDefined(LateralContribution):
|
class NotDefined(LateralContribution):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status=None):
|
||||||
super(NotDefined, self).__init__(name=name)
|
super(NotDefined, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "ND"
|
self._type = "ND"
|
||||||
self._header = ["x", "y"]
|
self._header = ["x", "y"]
|
||||||
|
|
@ -17,8 +17,8 @@ class NotDefined(LateralContribution):
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
class LateralContrib(LateralContribution):
|
class LateralContrib(LateralContribution):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status=None):
|
||||||
super(LateralContrib, self).__init__(name=name)
|
super(LateralContrib, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "LC"
|
self._type = "LC"
|
||||||
self._header = ["time", "debit"]
|
self._header = ["time", "debit"]
|
||||||
|
|
@ -29,8 +29,8 @@ class LateralContrib(LateralContribution):
|
||||||
return ["liquid"]
|
return ["liquid"]
|
||||||
|
|
||||||
class Rain(LateralContribution):
|
class Rain(LateralContribution):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status=None):
|
||||||
super(Rain, self).__init__(name=name)
|
super(Rain, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "RA"
|
self._type = "RA"
|
||||||
self._header = ["time", "debit"]
|
self._header = ["time", "debit"]
|
||||||
|
|
@ -41,8 +41,8 @@ class Rain(LateralContribution):
|
||||||
return ["liquid"]
|
return ["liquid"]
|
||||||
|
|
||||||
class Evaporation(LateralContribution):
|
class Evaporation(LateralContribution):
|
||||||
def __init__(self, name:str = ""):
|
def __init__(self, name:str = "", status=None):
|
||||||
super(Evaporation, self).__init__(name=name)
|
super(Evaporation, self).__init__(name=name, status=status)
|
||||||
|
|
||||||
self._type = "EV"
|
self._type = "EV"
|
||||||
self._header = ["time", "debit"]
|
self._header = ["time", "debit"]
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ from Model.Network.Node import Node
|
||||||
class Edge(object):
|
class Edge(object):
|
||||||
def __init__(self, id:str, name:str,
|
def __init__(self, id:str, name:str,
|
||||||
node1:Node = None,
|
node1:Node = None,
|
||||||
node2:Node = None):
|
node2:Node = None,
|
||||||
|
status = None):
|
||||||
super(Edge, self).__init__()
|
super(Edge, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self.id = id
|
self.id = id
|
||||||
self._name = name if name != "" else f"{node1.name} -> {node2.name}"
|
self._name = name if name != "" else f"{node1.name} -> {node2.name}"
|
||||||
|
|
||||||
|
|
@ -44,6 +47,8 @@ class Edge(object):
|
||||||
elif name == "enable":
|
elif name == "enable":
|
||||||
self.enable = value
|
self.enable = value
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@ from Model.Network.Node import Node
|
||||||
from Model.Network.Edge import Edge
|
from Model.Network.Edge import Edge
|
||||||
|
|
||||||
class Graph(object):
|
class Graph(object):
|
||||||
def __init__(self):
|
def __init__(self, status = None):
|
||||||
super(Graph, self).__init__()
|
super(Graph, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self._node_ctor = Node
|
self._node_ctor = Node
|
||||||
self._edge_ctor = Edge
|
self._edge_ctor = Edge
|
||||||
|
|
||||||
|
|
@ -82,13 +84,16 @@ class Graph(object):
|
||||||
def _add_node(self, node):
|
def _add_node(self, node):
|
||||||
self._nodes.append(node)
|
self._nodes.append(node)
|
||||||
self._nodes_ids += 1
|
self._nodes_ids += 1
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def add_node(self, x:float = 0.0, y:float = 0.0):
|
def add_node(self, x:float = 0.0, y:float = 0.0):
|
||||||
node = self._node_ctor(
|
node = self._node_ctor(
|
||||||
self._nodes_ids,
|
self._nodes_ids,
|
||||||
f"Node {self._nodes_ids}",
|
f"Node {self._nodes_ids}",
|
||||||
x = x, y = y
|
x = x, y = y,
|
||||||
|
status = self._status
|
||||||
)
|
)
|
||||||
return self._add_node(node)
|
return self._add_node(node)
|
||||||
|
|
||||||
|
|
@ -101,10 +106,14 @@ class Graph(object):
|
||||||
|
|
||||||
self._edges.append(edge)
|
self._edges.append(edge)
|
||||||
self._edges_ids += 1
|
self._edges_ids += 1
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
return edge
|
return edge
|
||||||
|
|
||||||
def add_edge(self, n1:Node, n2:Node):
|
def add_edge(self, n1:Node, n2:Node):
|
||||||
edge = self._edge_ctor(self._edges_ids, "", n1, n2)
|
edge = self._edge_ctor(self._edges_ids,
|
||||||
|
"", n1, n2,
|
||||||
|
status = self._status)
|
||||||
return self._add_edge(edge)
|
return self._add_edge(edge)
|
||||||
|
|
||||||
def remove_node(self, node_name:str):
|
def remove_node(self, node_name:str):
|
||||||
|
|
@ -114,6 +123,7 @@ class Graph(object):
|
||||||
self._nodes
|
self._nodes
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def remove_edge(self, edge_name:str):
|
def remove_edge(self, edge_name:str):
|
||||||
self._edges = list(
|
self._edges = list(
|
||||||
|
|
@ -122,6 +132,7 @@ class Graph(object):
|
||||||
self._edges
|
self._edges
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
def is_upstream_node(self, node):
|
def is_upstream_node(self, node):
|
||||||
return reduce(
|
return reduce(
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,12 @@ from Model.Network.Point import Point
|
||||||
|
|
||||||
class Node(object):
|
class Node(object):
|
||||||
def __init__(self, id:str, name:str,
|
def __init__(self, id:str, name:str,
|
||||||
x:float = 0.0, y:float = 0.0):
|
x:float = 0.0, y:float = 0.0,
|
||||||
|
status = None):
|
||||||
super(Node, self).__init__()
|
super(Node, self).__init__()
|
||||||
|
|
||||||
|
self._status = status
|
||||||
|
|
||||||
self.id = id
|
self.id = id
|
||||||
self._name = name
|
self._name = name
|
||||||
self.pos = Point(x, y)
|
self.pos = Point(x, y)
|
||||||
|
|
@ -29,6 +32,8 @@ class Node(object):
|
||||||
elif name == "id":
|
elif name == "id":
|
||||||
self.id = value
|
self.id = value
|
||||||
|
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
@ -36,3 +41,4 @@ class Node(object):
|
||||||
def setPos(self, x, y):
|
def setPos(self, x, y):
|
||||||
self.pos.x = x
|
self.pos.x = x
|
||||||
self.pos.y = y
|
self.pos.y = y
|
||||||
|
self._status.modified()
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,12 @@ from Model.LateralContribution.LateralContributionList import LateralContributio
|
||||||
|
|
||||||
class RiverNode(Node):
|
class RiverNode(Node):
|
||||||
def __init__(self, id:str, name:str,
|
def __init__(self, id:str, name:str,
|
||||||
x:float, y:float):
|
x:float, y:float,
|
||||||
|
status = None):
|
||||||
super(RiverNode, self).__init__(
|
super(RiverNode, self).__init__(
|
||||||
id, name,
|
id, name,
|
||||||
x, y
|
x, y,
|
||||||
|
status = status
|
||||||
)
|
)
|
||||||
|
|
||||||
self._locker = None
|
self._locker = None
|
||||||
|
|
@ -33,10 +35,12 @@ class RiverNode(Node):
|
||||||
class RiverReach(Edge):
|
class RiverReach(Edge):
|
||||||
def __init__(self, id:str, name:str,
|
def __init__(self, id:str, name:str,
|
||||||
node1:RiverNode = None,
|
node1:RiverNode = None,
|
||||||
node2:RiverNode = None):
|
node2:RiverNode = None,
|
||||||
|
status = None):
|
||||||
super(RiverReach, self).__init__(
|
super(RiverReach, self).__init__(
|
||||||
id, name,
|
id, name,
|
||||||
node1, node2
|
node1, node2,
|
||||||
|
status = status
|
||||||
)
|
)
|
||||||
|
|
||||||
self._reach = Reach(self)
|
self._reach = Reach(self)
|
||||||
|
|
@ -47,16 +51,16 @@ class RiverReach(Edge):
|
||||||
|
|
||||||
|
|
||||||
class River(Graph):
|
class River(Graph):
|
||||||
def __init__(self):
|
def __init__(self, status=None):
|
||||||
super(River, self).__init__()
|
super(River, self).__init__(status=status)
|
||||||
|
|
||||||
# Replace Node and Edge ctor by custom ctor
|
# Replace Node and Edge ctor by custom ctor
|
||||||
self._node_ctor = RiverNode
|
self._node_ctor = RiverNode
|
||||||
self._edge_ctor = RiverReach
|
self._edge_ctor = RiverReach
|
||||||
|
|
||||||
self._current_reach = None
|
self._current_reach = None
|
||||||
self._boundary_condition = BoundaryConditionList()
|
self._boundary_condition = BoundaryConditionList(status=self._status)
|
||||||
self._lateral_contribution = LateralContributionList()
|
self._lateral_contribution = LateralContributionList(status=self._status)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def boundary_condition(self):
|
def boundary_condition(self):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
class SavedStatus(object):
|
||||||
|
def __init__(self):
|
||||||
|
super(SavedStatus, self).__init__()
|
||||||
|
self._saved = True
|
||||||
|
|
||||||
|
def is_saved(self):
|
||||||
|
return self._saved
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
print(" * save")
|
||||||
|
self._saved = True
|
||||||
|
|
||||||
|
def modified(self):
|
||||||
|
print(" * modified ...")
|
||||||
|
self._saved = False
|
||||||
|
|
@ -12,6 +12,6 @@ class Serializable():
|
||||||
me = pickle.load(in_file)
|
me = pickle.load(in_file)
|
||||||
return me
|
return me
|
||||||
|
|
||||||
def save(self):
|
def _save(self):
|
||||||
with open(self.filename, 'wb') as out_file:
|
with open(self.filename, 'wb') as out_file:
|
||||||
pickle.dump(self, out_file)
|
pickle.dump(self, out_file)
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,23 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from Model.Saved import SavedStatus
|
||||||
from Model.Serializable import Serializable
|
from Model.Serializable import Serializable
|
||||||
|
|
||||||
|
from Model.River import River
|
||||||
|
|
||||||
|
|
||||||
class Study(Serializable):
|
class Study(Serializable):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Serialization information
|
# Serialization information
|
||||||
super(Study, self).__init__("")
|
super(Study, self).__init__("")
|
||||||
self.filename = ""
|
self.filename = ""
|
||||||
|
|
||||||
|
self.status = SavedStatus()
|
||||||
|
|
||||||
# Study general information
|
# Study general information
|
||||||
self.name = ""
|
self._name = ""
|
||||||
self.description = ""
|
self.description = ""
|
||||||
# Time system
|
# Time system
|
||||||
self._time_system = "time"
|
self._time_system = "time"
|
||||||
|
|
@ -22,7 +29,25 @@ class Study(Serializable):
|
||||||
self.last_save_date = datetime.now()
|
self.last_save_date = datetime.now()
|
||||||
|
|
||||||
# Study data
|
# Study data
|
||||||
self.river = None
|
self.river = River(status=self.status)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_saved(self):
|
||||||
|
return self.status.is_saved()
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
self.last_save_date = datetime.now()
|
||||||
|
self.status.save()
|
||||||
|
self._save()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, name):
|
||||||
|
self._name = str(name)
|
||||||
|
self.status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def time_system(self):
|
def time_system(self):
|
||||||
|
|
@ -30,10 +55,12 @@ class Study(Serializable):
|
||||||
|
|
||||||
def use_time(self):
|
def use_time(self):
|
||||||
self._time_system = "time"
|
self._time_system = "time"
|
||||||
|
self.status.modified()
|
||||||
|
|
||||||
def use_date(self, date:datetime):
|
def use_date(self, date:datetime):
|
||||||
self._time_system = "date"
|
self._time_system = "date"
|
||||||
self._date = date
|
self._date = date
|
||||||
|
self.status.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def date(self):
|
def date(self):
|
||||||
|
|
@ -42,6 +69,7 @@ class Study(Serializable):
|
||||||
@date.setter
|
@date.setter
|
||||||
def date(self, timestamp):
|
def date(self, timestamp):
|
||||||
self._date = timestamp
|
self._date = timestamp
|
||||||
|
self.status.modified()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(cls):
|
def new(cls):
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
self.trans = QTranslator(self)
|
self.trans = QTranslator(self)
|
||||||
#self.ui.retranslateUi()
|
#self.ui.retranslateUi()
|
||||||
|
|
||||||
|
def set_title(self):
|
||||||
|
if self.model is not None:
|
||||||
|
self.setWindowTitle(f"PAMHYR - {self.model.name}")
|
||||||
|
else:
|
||||||
|
self.setWindowTitle("PAMHYR")
|
||||||
|
|
||||||
def enable_actions(self, action:str, enable:bool):
|
def enable_actions(self, action:str, enable:bool):
|
||||||
"""Enable of disable an action componant
|
"""Enable of disable an action componant
|
||||||
|
|
||||||
|
|
@ -155,10 +161,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
def set_model(self, model):
|
def set_model(self, model):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.update_enable_action()
|
self.update_enable_action()
|
||||||
|
self.set_title()
|
||||||
|
|
||||||
def close_model(self):
|
def close_model(self):
|
||||||
self.model = None
|
self.model = None
|
||||||
self.update_enable_action()
|
self.update_enable_action()
|
||||||
|
self.set_title()
|
||||||
|
|
||||||
def update_enable_action(self):
|
def update_enable_action(self):
|
||||||
"""Update status of action componante
|
"""Update status of action componante
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,6 @@ class NetworkWindow(ASubMainWindow):
|
||||||
self.ui.setWindowTitle(title)
|
self.ui.setWindowTitle(title)
|
||||||
|
|
||||||
self.model = model
|
self.model = model
|
||||||
if self.model.river is None:
|
|
||||||
self.graph = River()
|
|
||||||
self.model.river = self.graph
|
|
||||||
else:
|
|
||||||
self.graph = self.model.river
|
self.graph = self.model.river
|
||||||
|
|
||||||
# Graph Widget
|
# Graph Widget
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue