Interpolated profiles: modify an interpolated profile, or something relative to it in the model, will no longer considerate this profile as an interpolated one

dev_dylan
Dylan Jeannin 2026-09-10 19:17:23 +02:00
parent e0bc481ae2
commit e064c1aee5
4 changed files with 45 additions and 16 deletions

View File

@ -55,8 +55,11 @@ class Point(SQLSubModel):
@name.setter @name.setter
def name(self, name): def name(self, name):
changed = self._name != name
self._name = name self._name = name
self.modified() self.modified()
if changed and self._profile is not None:
self._profile.content_modified()
def is_named(self): def is_named(self):
""" """

View File

@ -329,8 +329,11 @@ class PointXYZ(Point):
@x.setter @x.setter
def x(self, value): def x(self, value):
changed = self._x != float(value)
self._x = float(value) self._x = float(value)
self.modified() self.modified()
if changed and self._profile is not None:
self._profile.content_modified()
@property @property
def y(self): def y(self):
@ -338,8 +341,11 @@ class PointXYZ(Point):
@y.setter @y.setter
def y(self, value): def y(self, value):
changed = self._y != float(value)
self._y = float(value) self._y = float(value)
self.modified() self.modified()
if changed and self._profile is not None:
self._profile.content_modified()
@property @property
def z(self): def z(self):
@ -347,8 +353,11 @@ class PointXYZ(Point):
@z.setter @z.setter
def z(self, value): def z(self, value):
changed = self._z != float(value)
self._z = float(value) self._z = float(value)
self.modified() self.modified()
if changed and self._profile is not None:
self._profile.content_modified()
def shift(self, x, y, z): def shift(self, x, y, z):
self.x += x self.x += x

View File

@ -160,7 +160,12 @@ class Profile(object):
@rk.setter @rk.setter
def rk(self, value: float): def rk(self, value: float):
self._rk = float(value) value = float(value)
changed = value != self._rk
self._rk = value
if changed:
self.content_modified()
else:
self.modified() self.modified()
@property @property
@ -173,7 +178,12 @@ class Profile(object):
@name.setter @name.setter
def name(self, value: str): def name(self, value: str):
self._name = value.strip() value = value.strip()
changed = value != self._name
self._name = value
if changed:
self.content_modified()
else:
self.modified() self.modified()
@property @property
@ -217,6 +227,12 @@ class Profile(object):
return [point for point in self.points return [point for point in self.points
if point.is_named()] if point.is_named()]
def content_modified(self):
"""An edited profile is no longer an interpolation result."""
if hasattr(self, "_interpolated"):
self._interpolated = False
self.modified()
def insert_point(self, index: int, point: Point): def insert_point(self, index: int, point: Point):
"""Insert point at index. """Insert point at index.
@ -232,7 +248,7 @@ class Profile(object):
else: else:
self._points.insert(index, point) self._points.insert(index, point)
self.modified() self.content_modified()
def delete_i(self, indexes: list): def delete_i(self, indexes: list):
list( list(
@ -245,7 +261,7 @@ class Profile(object):
) )
) )
self.modified() self.content_modified()
def delete_points(self, points): def delete_points(self, points):
"""Delete some elements in profile list """Delete some elements in profile list
@ -262,7 +278,7 @@ class Profile(object):
points points
) )
) )
self.modified() self.content_modified()
# Move # Move
@ -272,7 +288,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.modified() self.content_modified()
def move_down_point(self, index: int): def move_down_point(self, index: int):
if index >= 0: if index >= 0:
@ -280,7 +296,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.modified() self.content_modified()
# Sort # Sort
@ -297,7 +313,7 @@ class Profile(object):
key=predicate, key=predicate,
reverse=is_reversed reverse=is_reversed
) )
self.modified() self.content_modified()
@timer @timer
def sort_with_indexes(self, indexes: list): def sort_with_indexes(self, indexes: list):
@ -313,12 +329,12 @@ class Profile(object):
) )
) )
) )
self.modified() self.content_modified()
@timer @timer
def reverse(self): def reverse(self):
self._points.reverse() self._points.reverse()
self.modified() self.content_modified()
# Sediment Layers # Sediment Layers

View File

@ -559,7 +559,7 @@ class ProfileXYZ(Profile, SQLSubModel):
) )
self._points.append(pt) self._points.append(pt)
self.modified() self.content_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.
@ -624,7 +624,7 @@ class ProfileXYZ(Profile, SQLSubModel):
) )
self.points.append(point_xyz) self.points.append(point_xyz)
self.modified() self.content_modified()
def insert(self, index: int): def insert(self, index: int):
"""Insert a new point at index. """Insert a new point at index.
@ -643,7 +643,7 @@ class ProfileXYZ(Profile, SQLSubModel):
point = PointXYZ(x=x, y=y, z=z, profile=self, status=self._status) point = PointXYZ(x=x, y=y, z=z, profile=self, status=self._status)
self._points.insert(index, point) self._points.insert(index, point)
self.modified() self.content_modified()
return point return point
@ -1172,8 +1172,9 @@ class ProfileXYZ(Profile, SQLSubModel):
interpolated=self.interpolated) interpolated=self.interpolated)
for i, k in enumerate(self.points): for i, k in enumerate(self.points):
p.insert_point(i, k.copy()) p.insert_point(i, k.cloned_for(p))
p._interpolated = self.interpolated
return p return p
def purge_aligned_points(self): def purge_aligned_points(self):