mirror of https://gitlab.com/pamhyr/pamhyr2
Interpolated profiles: modify an interpolated profile, or something relative to it in the model, will no longer considerate this profile as an interpolated one
parent
e0bc481ae2
commit
e064c1aee5
|
|
@ -55,8 +55,11 @@ class Point(SQLSubModel):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
changed = self._name != name
|
||||
self._name = name
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
def is_named(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -329,8 +329,11 @@ class PointXYZ(Point):
|
|||
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
changed = self._x != float(value)
|
||||
self._x = float(value)
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
@property
|
||||
def y(self):
|
||||
|
|
@ -338,8 +341,11 @@ class PointXYZ(Point):
|
|||
|
||||
@y.setter
|
||||
def y(self, value):
|
||||
changed = self._y != float(value)
|
||||
self._y = float(value)
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
@property
|
||||
def z(self):
|
||||
|
|
@ -347,8 +353,11 @@ class PointXYZ(Point):
|
|||
|
||||
@z.setter
|
||||
def z(self, value):
|
||||
changed = self._z != float(value)
|
||||
self._z = float(value)
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
def shift(self, x, y, z):
|
||||
self.x += x
|
||||
|
|
|
|||
|
|
@ -160,8 +160,13 @@ class Profile(object):
|
|||
|
||||
@rk.setter
|
||||
def rk(self, value: float):
|
||||
self._rk = float(value)
|
||||
self.modified()
|
||||
value = float(value)
|
||||
changed = value != self._rk
|
||||
self._rk = value
|
||||
if changed:
|
||||
self.content_modified()
|
||||
else:
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
@ -173,8 +178,13 @@ class Profile(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, value: str):
|
||||
self._name = value.strip()
|
||||
self.modified()
|
||||
value = value.strip()
|
||||
changed = value != self._name
|
||||
self._name = value
|
||||
if changed:
|
||||
self.content_modified()
|
||||
else:
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def sl(self):
|
||||
|
|
@ -217,6 +227,12 @@ class Profile(object):
|
|||
return [point for point in self.points
|
||||
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):
|
||||
"""Insert point at index.
|
||||
|
||||
|
|
@ -232,7 +248,7 @@ class Profile(object):
|
|||
else:
|
||||
self._points.insert(index, point)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def delete_i(self, indexes: list):
|
||||
list(
|
||||
|
|
@ -245,7 +261,7 @@ class Profile(object):
|
|||
)
|
||||
)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def delete_points(self, points):
|
||||
"""Delete some elements in profile list
|
||||
|
|
@ -262,7 +278,7 @@ class Profile(object):
|
|||
points
|
||||
)
|
||||
)
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
# Move
|
||||
|
||||
|
|
@ -272,7 +288,7 @@ class Profile(object):
|
|||
|
||||
p = self._points
|
||||
p[index], p[next] = p[next], p[index]
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def move_down_point(self, index: int):
|
||||
if index >= 0:
|
||||
|
|
@ -280,7 +296,7 @@ class Profile(object):
|
|||
|
||||
p = self._points
|
||||
p[index], p[prev] = p[prev], p[index]
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
# Sort
|
||||
|
||||
|
|
@ -297,7 +313,7 @@ class Profile(object):
|
|||
key=predicate,
|
||||
reverse=is_reversed
|
||||
)
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
@timer
|
||||
def sort_with_indexes(self, indexes: list):
|
||||
|
|
@ -313,12 +329,12 @@ class Profile(object):
|
|||
)
|
||||
)
|
||||
)
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
@timer
|
||||
def reverse(self):
|
||||
self._points.reverse()
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
# Sediment Layers
|
||||
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
)
|
||||
self._points.append(pt)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def get_point_i(self, index: int) -> PointXYZ:
|
||||
"""Get point at index.
|
||||
|
|
@ -624,7 +624,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
)
|
||||
self.points.append(point_xyz)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def insert(self, index: int):
|
||||
"""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)
|
||||
self._points.insert(index, point)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
return point
|
||||
|
||||
|
|
@ -1172,8 +1172,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
interpolated=self.interpolated)
|
||||
|
||||
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
|
||||
|
||||
def purge_aligned_points(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue