[ui] Sync Viewer3D according to updateSelectedViewpoint

This commit is contained in:
Aurore LAFAURIE 2024-04-04 15:55:41 +02:00 committed by Candice Bentéjac
parent ca4f7f13e5
commit 5afb9cb2c8
2 changed files with 28 additions and 1 deletions

View file

@ -29,6 +29,9 @@ FloatingPane {
_reconstruction.selectedViewId = sortedViewIds[m.frame];
} else {
_reconstruction.pickedViewId = sortedViewIds[m.frame];
if (m.sync3DSelected) {
_reconstruction.updateSelectedViewpoint(_reconstruction.pickedViewId);
}
}
}
}
@ -41,6 +44,7 @@ FloatingPane {
property int frame: 0
property bool syncSelected: true
property bool sync3DSelected: false
property bool playing: false
property bool repeat: false
property real fps: 24
@ -271,6 +275,19 @@ FloatingPane {
}
}
}
MaterialToolButton {
id: sync3DButton
checkable: true
checked: false
text: MaterialIcons.sync_alt
ToolTip.text: "Sync 3D Viewer and Sequence Player"
onCheckedChanged: {
m.sync3DSelected = checked;
}
}
}
TextMetrics {

View file

@ -1115,12 +1115,21 @@ class Reconstruction(UIGraph):
# Reconstruction has ownership of Viewpoint object - destroy it when not needed anymore
self._selectedViewpoint.deleteLater()
self._selectedViewpoint = ViewpointWrapper(viewpointAttribute, self) if viewpointAttribute else None
self.selectedViewpointChanged.emit()
def setPickedViewId(self, viewId):
if viewId == self._pickedViewId:
return
self._pickedViewId = viewId
self.pickedViewIdChanged.emit()
@Slot(str)
def updateSelectedViewpoint(self, viewId):
""" Update the currently set viewpoint if the provided view ID corresponds to one. """
vp = None
if self.viewpoints:
vp = next((v for v in self.viewpoints if str(v.viewId.value) == viewId), None)
self._setSelectedViewpoint(vp)
def reconstructedCamerasCount(self):
""" Get the number of reconstructed cameras in the current context. """
@ -1166,7 +1175,8 @@ class Reconstruction(UIGraph):
selectedViewIdChanged = Signal()
selectedViewId = Property(str, lambda self: self._selectedViewId, setSelectedViewId, notify=selectedViewIdChanged)
selectedViewpoint = Property(ViewpointWrapper, lambda self: self._selectedViewpoint, notify=selectedViewIdChanged)
selectedViewpointChanged = Signal()
selectedViewpoint = Property(ViewpointWrapper, lambda self: self._selectedViewpoint, notify=selectedViewpointChanged)
pickedViewIdChanged = Signal()
pickedViewId = Property(str, lambda self: self._pickedViewId, setPickedViewId, notify=pickedViewIdChanged)