mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
[ui] Reconstruction: maintain CameraInit node and expose Viewpoints model
* keep an internal reference to the "main" CameraInit node an update it according to graph modification * expose viewpoints model as a property * TODO: handle multiple CameraInit nodes
This commit is contained in:
parent
4bcd55fe46
commit
c06e2f110a
1 changed files with 30 additions and 6 deletions
|
@ -16,6 +16,7 @@ class Reconstruction(UIGraph):
|
||||||
def __init__(self, graphFilepath='', parent=None):
|
def __init__(self, graphFilepath='', parent=None):
|
||||||
super(Reconstruction, self).__init__(graphFilepath, parent)
|
super(Reconstruction, self).__init__(graphFilepath, parent)
|
||||||
self._buildIntrinsicsThread = None
|
self._buildIntrinsicsThread = None
|
||||||
|
self._cameraInit = None
|
||||||
self._endChunk = None
|
self._endChunk = None
|
||||||
self._meshFile = ''
|
self._meshFile = ''
|
||||||
self.intrinsicsBuilt.connect(self.onIntrinsicsAvailable)
|
self.intrinsicsBuilt.connect(self.onIntrinsicsAvailable)
|
||||||
|
@ -34,7 +35,7 @@ class Reconstruction(UIGraph):
|
||||||
""" React to the change of the internal graph. """
|
""" React to the change of the internal graph. """
|
||||||
self._endChunk = None
|
self._endChunk = None
|
||||||
self.setMeshFile('')
|
self.setMeshFile('')
|
||||||
|
self.updateCameraInit()
|
||||||
if not self._graph:
|
if not self._graph:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ class Reconstruction(UIGraph):
|
||||||
self.updateMeshFile()
|
self.updateMeshFile()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._endChunk = None
|
self._endChunk = None
|
||||||
|
# TODO: listen specifically for cameraInit creation/deletion
|
||||||
|
self._graph.nodes.countChanged.connect(self.updateCameraInit)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def runAsync(func, args=(), kwargs=None):
|
def runAsync(func, args=(), kwargs=None):
|
||||||
|
@ -53,6 +56,27 @@ class Reconstruction(UIGraph):
|
||||||
thread.start()
|
thread.start()
|
||||||
return thread
|
return thread
|
||||||
|
|
||||||
|
def getViewpoints(self):
|
||||||
|
""" Return the Viewpoints model. """
|
||||||
|
# TODO: handle multiple Viewpoints models
|
||||||
|
return self._cameraInit.viewpoints.value if self._cameraInit else None
|
||||||
|
|
||||||
|
def updateCameraInit(self):
|
||||||
|
""" Update internal CameraInit node (Viewpoints model owner) based on graph content. """
|
||||||
|
# TODO: handle multiple CameraInit nodes
|
||||||
|
if self._cameraInit in self._graph.nodes:
|
||||||
|
return
|
||||||
|
cameraInits = self._graph.findNodeCandidates("CameraInit")
|
||||||
|
self.setCameraInit(cameraInits[0] if cameraInits else None)
|
||||||
|
|
||||||
|
def setCameraInit(self, cameraInit):
|
||||||
|
""" Set the internal CameraInit node. """
|
||||||
|
# TODO: handle multiple CameraInit nodes
|
||||||
|
if self._cameraInit == cameraInit:
|
||||||
|
return
|
||||||
|
self._cameraInit = cameraInit
|
||||||
|
self.viewpointsChanged.emit()
|
||||||
|
|
||||||
def updateMeshFile(self):
|
def updateMeshFile(self):
|
||||||
if self._endChunk and self._endChunk.status.status == graph.Status.SUCCESS:
|
if self._endChunk and self._endChunk.status.status == graph.Status.SUCCESS:
|
||||||
self.setMeshFile(self._endChunk.node.outputMesh.value)
|
self.setMeshFile(self._endChunk.node.outputMesh.value)
|
||||||
|
@ -95,9 +119,8 @@ class Reconstruction(UIGraph):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.buildingIntrinsicsChanged.emit()
|
self.buildingIntrinsicsChanged.emit()
|
||||||
cameraInit = self._graph.findNode("CameraInit")
|
|
||||||
# Retrieve the list of updated viewpoints and intrinsics
|
# Retrieve the list of updated viewpoints and intrinsics
|
||||||
views, intrinsics = cameraInit.nodeDesc.buildIntrinsics(cameraInit, additionalViews)
|
views, intrinsics = self._cameraInit.nodeDesc.buildIntrinsics(self._cameraInit, additionalViews)
|
||||||
self.intrinsicsBuilt.emit(views, intrinsics)
|
self.intrinsicsBuilt.emit(views, intrinsics)
|
||||||
return views, intrinsics
|
return views, intrinsics
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -107,15 +130,16 @@ class Reconstruction(UIGraph):
|
||||||
|
|
||||||
def onIntrinsicsAvailable(self, views, intrinsics):
|
def onIntrinsicsAvailable(self, views, intrinsics):
|
||||||
""" Update CameraInit with given views and intrinsics. """
|
""" Update CameraInit with given views and intrinsics. """
|
||||||
cameraInit = self._graph.findNode("CameraInit")
|
|
||||||
with self.groupedGraphModification("Add Images"):
|
with self.groupedGraphModification("Add Images"):
|
||||||
self.setAttribute(cameraInit.viewpoints, views)
|
self.setAttribute(self._cameraInit.viewpoints, views)
|
||||||
self.setAttribute(cameraInit.intrinsics, intrinsics)
|
self.setAttribute(self._cameraInit.intrinsics, intrinsics)
|
||||||
|
|
||||||
def isBuildingIntrinsics(self):
|
def isBuildingIntrinsics(self):
|
||||||
""" Whether intrinsics are being built """
|
""" Whether intrinsics are being built """
|
||||||
return self._buildIntrinsicsThread and self._buildIntrinsicsThread.isAlive()
|
return self._buildIntrinsicsThread and self._buildIntrinsicsThread.isAlive()
|
||||||
|
|
||||||
|
viewpointsChanged = Signal()
|
||||||
|
viewpoints = Property(QObject, getViewpoints, notify=viewpointsChanged)
|
||||||
intrinsicsBuilt = Signal(list, list)
|
intrinsicsBuilt = Signal(list, list)
|
||||||
buildingIntrinsicsChanged = Signal()
|
buildingIntrinsicsChanged = Signal()
|
||||||
buildingIntrinsics = Property(bool, isBuildingIntrinsics, notify=buildingIntrinsicsChanged)
|
buildingIntrinsics = Property(bool, isBuildingIntrinsics, notify=buildingIntrinsicsChanged)
|
||||||
|
|
Loading…
Add table
Reference in a new issue