mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Fix profile copy/paste.
parent
2a1c8c1e57
commit
f4d3f2b28f
|
|
@ -273,6 +273,22 @@ class PointXYZ(Point):
|
|||
|
||||
return point
|
||||
|
||||
def copy(self):
|
||||
new_p = PointXYZ(
|
||||
id=-1,
|
||||
name=self.name,
|
||||
x=self.x, y=self.y, z=self.z,
|
||||
profile=self.profile,
|
||||
status=self._status
|
||||
)
|
||||
if self.is_deleted():
|
||||
new_p.set_as_deleted()
|
||||
|
||||
new_p._sl = self.sl
|
||||
|
||||
new_p.modified()
|
||||
return new_p
|
||||
|
||||
def __repr__(self):
|
||||
return f"({self._x}, {self._y}, {self._z}, {self._name})"
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ class Profile(object):
|
|||
if point in self._points:
|
||||
point.set_as_not_deleted()
|
||||
else:
|
||||
self.points.insert(index, point)
|
||||
self._points.insert(index, point)
|
||||
|
||||
self.modified()
|
||||
|
||||
|
|
|
|||
|
|
@ -369,6 +369,27 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
|
||||
return profile
|
||||
|
||||
def copy(self):
|
||||
new_p = ProfileXYZ(
|
||||
id=-1,
|
||||
name=self.name,
|
||||
rk=self.rk,
|
||||
reach=self.reach,
|
||||
status=self._status
|
||||
)
|
||||
if self.is_deleted():
|
||||
new_p.set_as_deleted()
|
||||
|
||||
new_p._sl = self.sl
|
||||
|
||||
for point in self._points:
|
||||
p = point.copy()
|
||||
print(p)
|
||||
new_p._points.append(p)
|
||||
|
||||
new_p.modified()
|
||||
return new_p
|
||||
|
||||
def point_from_data(self, header, data):
|
||||
def float_format(s: str):
|
||||
return float(
|
||||
|
|
|
|||
|
|
@ -241,7 +241,6 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def reverse(self):
|
||||
|
||||
self._undo.push(
|
||||
ReverseCommand(
|
||||
self._data
|
||||
|
|
@ -259,15 +258,16 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
points = list(
|
||||
map(
|
||||
lambda d: self._data.point_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.point_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
self._data, row, points
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -294,13 +294,13 @@ class ProfileWindow(PamhyrWindow):
|
|||
rows = table.selectionModel().selectedRows()
|
||||
|
||||
data = []
|
||||
data.append(["x", "y", "z", "name"])
|
||||
data.append(["name", "x", "y", "z"])
|
||||
|
||||
for row in rows:
|
||||
point = self._profile.point(row.row())
|
||||
data.append(
|
||||
[
|
||||
point.x, point.y, point.z, point.name
|
||||
point.name, point.x, point.y, point.z
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class PasteCommand(QUndoCommand):
|
|||
self._row = row
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: deepcopy(p),
|
||||
lambda p: p.copy(),
|
||||
profiles
|
||||
)
|
||||
)
|
||||
|
|
@ -180,7 +180,7 @@ class DuplicateCommand(QUndoCommand):
|
|||
self._rows = rows
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: deepcopy(p),
|
||||
lambda p: p.copy(),
|
||||
profiles
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue