mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pamhyr: Add saved status in model.
This commit is contained in:
1 parent
b786bb44e2
commit
d328806916
21 files changed
+215
-54
No files matched your search
@@ -5,9 +5,12 @@ from tools import trace, timer, old_pamhyr_date_to_timestamp
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
class BoundaryCondition(object):
|
||||
def __init__(self, name:str = ""):
|
||||
def __init__(self, name:str = "",
|
||||
status = None):
|
||||
super(BoundaryCondition, self).__init__()
|
||||
|
||||
self._status = status
|
||||
|
||||
self._name = name
|
||||
self._type = ""
|
||||
self._node = None
|
||||
@@ -36,6 +39,7 @@ class BoundaryCondition(object):
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
self._status.modified()
|
||||
|
||||
@property
|
||||
def bctype(self):
|
||||
@@ -48,6 +52,7 @@ class BoundaryCondition(object):
|
||||
@node.setter
|
||||
def node(self, node):
|
||||
self._node = node
|
||||
self._status.modified()
|
||||
|
||||
def has_node(self):
|
||||
return self._node is not None
|
||||
@@ -97,10 +102,12 @@ class BoundaryCondition(object):
|
||||
def add(self, index:int):
|
||||
value = (self._default_0, self._default_1)
|
||||
self._data.insert(index, value)
|
||||
self._status.modified()
|
||||
return value
|
||||
|
||||
def insert(self, index:int, value):
|
||||
self._data.insert(index, value)
|
||||
self._status.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
self._data = list(
|
||||
@@ -112,6 +119,7 @@ class BoundaryCondition(object):
|
||||
)
|
||||
)
|
||||
)
|
||||
self._status.modified()
|
||||
|
||||
def delete(self, els):
|
||||
self._data = list(
|
||||
@@ -120,12 +128,14 @@ class BoundaryCondition(object):
|
||||
self.data
|
||||
)
|
||||
)
|
||||
self._status.modified()
|
||||
|
||||
def sort(self, _reverse=False, key=None):
|
||||
if key is None:
|
||||
self._data.sort(reverse=_reverse)
|
||||
else:
|
||||
self._data.sort(reverse=_reverse, key=key)
|
||||
self._status.modified()
|
||||
|
||||
def get_i(self, index):
|
||||
return self.data[index]
|
||||
@@ -141,6 +151,7 @@ class BoundaryCondition(object):
|
||||
v = list(self._data[index])
|
||||
v[column] = self._types[column](value)
|
||||
self._data[index] = tuple(v)
|
||||
self._status.modified()
|
||||
|
||||
def set_i_0(self, index:int, value):
|
||||
self._set_i_c_v(index, 0, value)
|
||||
@@ -160,6 +171,7 @@ class BoundaryCondition(object):
|
||||
for ind, v in self.data:
|
||||
new._set_i_c_v(ind, j, v[i])
|
||||
|
||||
self._status.modified()
|
||||
return new
|
||||
|
||||
def move_up(self, index):
|
||||
@@ -167,9 +179,11 @@ class BoundaryCondition(object):
|
||||
next = index - 1
|
||||
d = self._data
|
||||
d[index], d[next] = d[next], d[index]
|
||||
self._status.modified()
|
||||
|
||||
def move_down(self, index):
|
||||
if index >= 0:
|
||||
prev = index + 1
|
||||
d = self._data
|
||||
d[index], d[prev] = d[prev], d[index]
|
||||
self._status.modified()
|
||||
@@ -12,9 +12,11 @@ from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
)
|
||||
|
||||
class BoundaryConditionList(object):
|
||||
def __init__(self):
|
||||
def __init__(self, status = None):
|
||||
super(BoundaryConditionList, self).__init__()
|
||||
|
||||
self._status = status
|
||||
|
||||
self._tabs = {
|
||||
"liquid" : [],
|
||||
"solid" : [],
|
||||
@@ -32,18 +34,22 @@ class BoundaryConditionList(object):
|
||||
|
||||
def set(self, lst, row, new):
|
||||
self._tabs[lst][row] = new
|
||||
self._status.modified()
|
||||
|
||||
def new(self, lst, index):
|
||||
n = NotDefined()
|
||||
self._tabs[lst].insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
|
||||
def insert(self, lst, index, new):
|
||||
self._tabs[lst].insert(index, new)
|
||||
self._status.modified()
|
||||
|
||||
def delete(self, lst, bcs):
|
||||
for bc in bcs:
|
||||
self._tabs[lst].remove(bc)
|
||||
self._status.modified()
|
||||
|
||||
def delete_i(self, lst, indexes):
|
||||
bcs = list(
|
||||
@@ -59,6 +65,7 @@ class BoundaryConditionList(object):
|
||||
|
||||
def sort(self, lst, reverse=False, key=None):
|
||||
self._tabs[lst].sort(reverse=reverse, key=key)
|
||||
self._status.modified()
|
||||
|
||||
def move_up(self, lst, index):
|
||||
if index < len(self._tabs[lst]):
|
||||
@@ -66,6 +73,7 @@ class BoundaryConditionList(object):
|
||||
|
||||
l = self._tabs[lst]
|
||||
l[index], l[next] = l[next], l[index]
|
||||
self._status.modified()
|
||||
|
||||
def move_down(self, lst, index):
|
||||
if index >= 0:
|
||||
@@ -73,6 +81,7 @@ class BoundaryConditionList(object):
|
||||
|
||||
l = self._tabs[lst]
|
||||
l[index], l[prev] = l[prev], l[index]
|
||||
self._status.modified()
|
||||
|
||||
def __copy__(self):
|
||||
new = BoundaryConditionList()
|
||||
|
||||
@@ -6,8 +6,8 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
|
||||
|
||||
class NotDefined(BoundaryCondition):
|
||||
def __init__(self, name:str = ""):
|
||||
super(NotDefined, self).__init__(name=name)
|
||||
def __init__(self, name:str = "", status = None):
|
||||
super(NotDefined, self).__init__(name=name, status=status)
|
||||
|
||||
self._type = "ND"
|
||||
self._header = ["x", "y"]
|
||||
@@ -17,8 +17,8 @@ class NotDefined(BoundaryCondition):
|
||||
return 0.0
|
||||
|
||||
class PonctualContribution(BoundaryCondition):
|
||||
def __init__(self, name:str = ""):
|
||||
super(PonctualContribution, self).__init__(name=name)
|
||||
def __init__(self, name:str = "", status = None):
|
||||
super(PonctualContribution, self).__init__(name=name, status=status)
|
||||
|
||||
self._type = "PC"
|
||||
self._header = ["time", "debit"]
|
||||
@@ -29,8 +29,8 @@ class PonctualContribution(BoundaryCondition):
|
||||
return ["liquid"]
|
||||
|
||||
class TimeOverZ(BoundaryCondition):
|
||||
def __init__(self, name:str = ""):
|
||||
super(TimeOverZ, self).__init__(name=name)
|
||||
def __init__(self, name:str = "", status = None):
|
||||
super(TimeOverZ, self).__init__(name=name, status=status)
|
||||
|
||||
self._type = "TZ"
|
||||
self._header = ["time", "z"]
|
||||
@@ -41,8 +41,8 @@ class TimeOverZ(BoundaryCondition):
|
||||
return ["liquid"]
|
||||
|
||||
class TimeOverDebit(BoundaryCondition):
|
||||
def __init__(self, name:str = ""):
|
||||
super(TimeOverDebit, self).__init__(name=name)
|
||||
def __init__(self, name:str = "", status = None):
|
||||
super(TimeOverDebit, self).__init__(name=name, status=status)
|
||||
|
||||
self._type = "TD"
|
||||
self._header = ["time", "debit"]
|
||||
@@ -53,8 +53,8 @@ class TimeOverDebit(BoundaryCondition):
|
||||
return ["liquid"]
|
||||
|
||||
class ZOverDebit(BoundaryCondition):
|
||||
def __init__(self, name:str = ""):
|
||||
super(ZOverDebit, self).__init__(name=name)
|
||||
def __init__(self, name:str = "", status = None):
|
||||
super(ZOverDebit, self).__init__(name=name, status=status)
|
||||
|
||||
self._type = "ZD"
|
||||
self._header = ["z", "debit"]
|
||||
|
||||
Reference in new issue
Block a user