[ui] make Nodes moves undoable

Handle nodes move and auto-layout on Python side by using GraphLayout and MoveNodeCommand.

* Node QML component relies on underlying core.Node object's position
* MoveNodeCommand is called after a Node has been dragged
* partial/full auto-layout for specific graph operations (Duplication, Augmentation...) are now part of those operations
* serialized position in node data allows to properly restore nodes coordinates on undo/redo
* remove all layout/node moving code from QML
This commit is contained in:
Yann Lanthony 2018-07-26 22:37:01 +02:00
parent 830173047c
commit f415745a4a
8 changed files with 75 additions and 124 deletions

View file

@ -305,10 +305,17 @@ class Reconstruction(UIGraph):
if len(self._cameraInits[0].viewpoints) == 0:
return self._cameraInit, sfm
with self.groupedGraphModification("SfM Augmentation"):
sfm, mvs = multiview.sfmAugmentation(self, self.lastSfmNode(), withMVS=withMVS)
# enable updates between duplication and layout to get correct depths during layout
with self.groupedGraphModification("SfM Augmentation", disableUpdates=False):
# disable graph updates when adding augmentation branch
with self.groupedGraphModification("Augmentation", disableUpdates=True):
sfm, mvs = multiview.sfmAugmentation(self, self.lastSfmNode(), withMVS=withMVS)
first, last = sfm[0], mvs[-1] if mvs else sfm[-1]
# use graph current bounding box height to spawn the augmentation branch
bb = self.layout.boundingBox()
self.layout.autoLayout(first, last, bb[0], bb[3] + self._layout.gridSpacing)
self.sfmAugmented.emit(sfm[0], mvs[-1] if mvs else sfm[-1])
self.sfmAugmented.emit(first, last)
return sfm[0], sfm[-1]
def allImagePaths(self):