mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pamhyr: Add just-in-time database geometry loading.
This commit is contained in:
1 parent
a603c3a63f
commit
ab9ebc6400
9 files changed
+140
-77
No files matched your search
@@ -57,18 +57,34 @@ class Profile(object):
|
||||
self._profile_type = _type
|
||||
|
||||
def __len__(self):
|
||||
return len(self._points)
|
||||
return len(self.points)
|
||||
|
||||
@property
|
||||
def number_points(self):
|
||||
return len(self._points)
|
||||
return len(self.points)
|
||||
|
||||
def _get_points_list(self):
|
||||
# Points list generator is type (int, Point) with the first
|
||||
# element the index of the Point in list
|
||||
return list(
|
||||
map(
|
||||
lambda p: p[1],
|
||||
sorted(
|
||||
self._points,
|
||||
key = lambda p: p[0]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def points(self):
|
||||
return self._points.copy()
|
||||
if not isinstance(self._points, list):
|
||||
self._points = self._get_points_list()
|
||||
|
||||
return self._points
|
||||
|
||||
def point(self, index):
|
||||
return self._points[index]
|
||||
return self.points[index]
|
||||
|
||||
@property
|
||||
def reach(self):
|
||||
@@ -115,7 +131,7 @@ class Profile(object):
|
||||
|
||||
@property
|
||||
def nb_points(self):
|
||||
return len(self._points)
|
||||
return len(self.points)
|
||||
|
||||
@property
|
||||
def kp(self):
|
||||
@@ -170,8 +186,8 @@ class Profile(object):
|
||||
self._status.modified()
|
||||
|
||||
def point(self, i:int):
|
||||
if i < len(self._points):
|
||||
return self._points[i]
|
||||
if i < len(self.points):
|
||||
return self.points[i]
|
||||
|
||||
return None
|
||||
|
||||
@@ -181,7 +197,7 @@ class Profile(object):
|
||||
Returns:
|
||||
The list of named point
|
||||
"""
|
||||
return [point for point in self._points
|
||||
return [point for point in self.points
|
||||
if point.point_is_named()]
|
||||
|
||||
|
||||
@@ -195,7 +211,7 @@ class Profile(object):
|
||||
Returns:
|
||||
Nothing.
|
||||
"""
|
||||
self._points.insert(index, point)
|
||||
self.points.insert(index, point)
|
||||
self._status.modified()
|
||||
|
||||
|
||||
@@ -218,7 +234,7 @@ class Profile(object):
|
||||
)
|
||||
)
|
||||
|
||||
self._points = list(
|
||||
self.points = list(
|
||||
filter(
|
||||
lambda p: p not in points,
|
||||
self.points
|
||||
@@ -235,7 +251,7 @@ class Profile(object):
|
||||
Returns:
|
||||
Nothing.
|
||||
"""
|
||||
self._points = list(
|
||||
self.points = list(
|
||||
filter(
|
||||
lambda p: p not in points,
|
||||
self.points
|
||||
@@ -246,10 +262,10 @@ class Profile(object):
|
||||
# Move
|
||||
|
||||
def move_up_point(self, index: int):
|
||||
if index < len(self._points):
|
||||
if index < len(self.points):
|
||||
next = index - 1
|
||||
|
||||
p = self._points
|
||||
p = self.points
|
||||
p[index], p[next] = p[next], p[index]
|
||||
self._status.modified()
|
||||
|
||||
@@ -257,7 +273,7 @@ class Profile(object):
|
||||
if index >= 0:
|
||||
prev = index + 1
|
||||
|
||||
p = self._points
|
||||
p = self.points
|
||||
p[index], p[prev] = p[prev], p[index]
|
||||
self._status.modified()
|
||||
|
||||
@@ -271,8 +287,8 @@ class Profile(object):
|
||||
elif column == 'z':
|
||||
predicate = lambda p: p.z
|
||||
|
||||
self._points = sorted(
|
||||
self._points,
|
||||
self.points = sorted(
|
||||
self.points,
|
||||
key=predicate,
|
||||
reverse=is_reversed
|
||||
)
|
||||
@@ -280,10 +296,10 @@ class Profile(object):
|
||||
|
||||
@timer
|
||||
def sort_with_indexes(self, indexes: list):
|
||||
if len(self._points) != len(indexes):
|
||||
if len(self.points) != len(indexes):
|
||||
logger.critical("Indexes list do not correspond to point list")
|
||||
|
||||
self._points = list(
|
||||
self.points = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
sorted(
|
||||
|
||||
Reference in new issue
Block a user