Geometry: Add scenario support.

This commit is contained in:
Pierre-Antoine Rouby committed 2024-09-20 16:10:00 +02:00
1 parent 02c6430ed2
commit 4199eb6ac5
6 files changed
+133 -114

No files matched your search

+38 -28
View File
@@ -32,10 +32,11 @@ class Profile(object):
rk: float = 0.0, name: str = "",
code1: int = 0, code2: int = 0,
_type: str = "", reach=None,
status=None):
super(Profile, self).__init__(id)
self._status = status
status=None, owner_scenario=-1):
super(Profile, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._num = int(num)
self._code1 = int(code1)
@@ -64,7 +65,12 @@ class Profile(object):
if not isinstance(self._points, list):
self._points = self._get_points_list()
return self._points
return list(
filter(
lambda p: not p.is_deleted(),
self._points
)
)
def point(self, index):
return self.points[index]
@@ -84,7 +90,7 @@ class Profile(object):
@num.setter
def num(self, value: int):
self._num = int(value)
self._status.modified()
self.modified()
@property
def code1(self):
@@ -97,7 +103,7 @@ class Profile(object):
@code1.setter
def code1(self, value: int):
self._code1 = int(value)
self._status.modified()
self.modified()
@property
def code2(self):
@@ -110,7 +116,7 @@ class Profile(object):
@code2.setter
def code2(self, value: int):
self._code2 = int(value)
self._status.modified()
self.modified()
@property
def nb_points(self):
@@ -127,7 +133,7 @@ class Profile(object):
@rk.setter
def rk(self, value: float):
self._rk = float(value)
self._status.modified()
self.modified()
@property
def name(self):
@@ -140,7 +146,7 @@ class Profile(object):
@name.setter
def name(self, value: str):
self._name = value.strip()
self._status.modified()
self.modified()
@property
def sl(self):
@@ -153,7 +159,7 @@ class Profile(object):
@sl.setter
def sl(self, value):
self._sl = value
self._status.modified()
self.modified()
@property
def profile_type(self):
@@ -166,7 +172,7 @@ class Profile(object):
@profile_type.setter
def profile_type(self, value: str):
self._profile_type = value
self._status.modified()
self.modified()
def point(self, i: int):
if i < len(self.points):
@@ -193,21 +199,25 @@ class Profile(object):
Returns:
Nothing.
"""
self.points.insert(index, point)
self._status.modified()
if point in self._points:
point.set_as_not_deleted()
else:
self.points.insert(index, point)
self.modified()
def delete_i(self, indexes: list):
self._points = list(
list(
map(
lambda e: e[1],
lambda e: e[1].set_as_deleted(),
filter(
lambda e: e[0] not in indexes,
lambda e: e[0] in indexes,
enumerate(self.points)
)
)
)
self._status.modified()
self.modified()
def delete_points(self, points):
"""Delete some elements in profile list
@@ -218,13 +228,13 @@ class Profile(object):
Returns:
Nothing.
"""
self._points = list(
filter(
lambda p: p not in points,
self.points
list(
map(
lambda p: p.set_as_deleted(),
points
)
)
self._status.modified()
self.modified()
# Move
@@ -234,7 +244,7 @@ class Profile(object):
p = self.points
p[index], p[next] = p[next], p[index]
self._status.modified()
self.modified()
def move_down_point(self, index: int):
if index >= 0:
@@ -242,7 +252,7 @@ class Profile(object):
p = self.points
p[index], p[prev] = p[prev], p[index]
self._status.modified()
self.modified()
# Sort
@@ -259,7 +269,7 @@ class Profile(object):
key=predicate,
reverse=is_reversed
)
self._status.modified()
self.modified()
@timer
def sort_with_indexes(self, indexes: list):
@@ -275,12 +285,12 @@ class Profile(object):
)
)
)
self._status.modified()
self.modified()
@timer
def reverse(self):
self._points.reverse()
self._status.modified()
self.modified()
# Sediment Layers