diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py index 26bb246874412d1e716eefa1a02072c8212f3298..afd6b23b1c241960e4377c99b29c7e82dad2639d 100644 --- a/src/Model/Geometry/Reach.py +++ b/src/Model/Geometry/Reach.py @@ -79,13 +79,15 @@ class Reach: index: The position of the new profile. Returns: - Nothing. + The new profile. """ profile = ProfileXYZ(reach=self) self._profiles.insert(index, profile) self._update_profile_numbers() + return profile + def insert_profile(self, index: int, profile: Profile): """Insert new profile in list diff --git a/src/View/Geometry/ReachUndoCommand.py b/src/View/Geometry/ReachUndoCommand.py index 62e992034a424738aa63e1e010b1c63fe2fd2c17..2171e0bc61957ec197a9f6925e802f96372c880e 100644 --- a/src/View/Geometry/ReachUndoCommand.py +++ b/src/View/Geometry/ReachUndoCommand.py @@ -40,12 +40,16 @@ class AddCommand(QUndoCommand): self._reach = reach self._index = index + self._profile = None def undo(self): - self._reach.delete(self._index) + self._reach.delete_profiles([self._profile]) def redo(self): - self._reach.insert(self._index) + if self._profile is None: + self._profile = self._reach.insert(self._index) + else: + self._reach.insert_profile(self._index, self._profile) class DelCommand(QUndoCommand): def __init__(self, reach, rows):