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
|
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):
|
def __repr__(self):
|
||||||
return f"({self._x}, {self._y}, {self._z}, {self._name})"
|
return f"({self._x}, {self._y}, {self._z}, {self._name})"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ class Profile(object):
|
||||||
if point in self._points:
|
if point in self._points:
|
||||||
point.set_as_not_deleted()
|
point.set_as_not_deleted()
|
||||||
else:
|
else:
|
||||||
self.points.insert(index, point)
|
self._points.insert(index, point)
|
||||||
|
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,27 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
|
|
||||||
return profile
|
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 point_from_data(self, header, data):
|
||||||
def float_format(s: str):
|
def float_format(s: str):
|
||||||
return float(
|
return float(
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,6 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def reverse(self):
|
def reverse(self):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
ReverseCommand(
|
ReverseCommand(
|
||||||
self._data
|
self._data
|
||||||
|
|
@ -259,15 +258,16 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
|
|
||||||
|
points = list(
|
||||||
|
map(
|
||||||
|
lambda d: self._data.point_from_data(header, d),
|
||||||
|
data
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
PasteCommand(
|
PasteCommand(
|
||||||
self._data, row,
|
self._data, row, points
|
||||||
list(
|
|
||||||
map(
|
|
||||||
lambda d: self._data.point_from_data(header, d),
|
|
||||||
data
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,13 +294,13 @@ class ProfileWindow(PamhyrWindow):
|
||||||
rows = table.selectionModel().selectedRows()
|
rows = table.selectionModel().selectedRows()
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
data.append(["x", "y", "z", "name"])
|
data.append(["name", "x", "y", "z"])
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
point = self._profile.point(row.row())
|
point = self._profile.point(row.row())
|
||||||
data.append(
|
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._row = row
|
||||||
self._profiles = list(
|
self._profiles = list(
|
||||||
map(
|
map(
|
||||||
lambda p: deepcopy(p),
|
lambda p: p.copy(),
|
||||||
profiles
|
profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -180,7 +180,7 @@ class DuplicateCommand(QUndoCommand):
|
||||||
self._rows = rows
|
self._rows = rows
|
||||||
self._profiles = list(
|
self._profiles = list(
|
||||||
map(
|
map(
|
||||||
lambda p: deepcopy(p),
|
lambda p: p.copy(),
|
||||||
profiles
|
profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue