[ui] Create empty graph and handle new Camera Init or KeyFrameSelection

This commit is contained in:
Aurore LAFAURIE 2024-07-31 16:22:22 +02:00
parent 1038806ccd
commit 78fb0114e4
2 changed files with 29 additions and 16 deletions

View file

@ -253,6 +253,8 @@ class GraphLayout(QObject):
startX (int): start position x coordinate
startY (int): start position y coordinate
"""
if not self.graph.nodes:
return
fromIndex = self.graph.nodes.indexOf(fromNode) if fromNode else 0
toIndex = self.graph.nodes.indexOf(toNode) if toNode else self.graph.nodes.count - 1
@ -439,9 +441,12 @@ class UIGraph(QObject):
@Slot(str, result=bool)
def loadGraph(self, filepath, setupProjectFile=True, publishOutputs=False):
g = Graph('')
status = True
if filepath:
status = g.load(filepath, setupProjectFile, importProject=False, publishOutputs=publishOutputs)
if not os.path.exists(g.cacheDir):
os.mkdir(g.cacheDir)
g.fileDateVersion = os.path.getmtime(filepath)
self.setGraph(g)
return status

View file

@ -509,10 +509,8 @@ class Reconstruction(UIGraph):
@Slot()
@Slot(str)
def new(self, pipeline=None):
p = pipeline if pipeline != None else self._defaultPipeline
if not p:
return
""" Create a new pipeline. """
p = pipeline if pipeline != None else self._defaultPipeline
# Lower the input and the dictionary keys to make sure that all input types can be found:
# - correct pipeline name but the case does not match (e.g. panoramaHDR instead of panoramaHdr)
# - lowercase pipeline name given through the "New Pipeline" menu
@ -537,7 +535,6 @@ class Reconstruction(UIGraph):
"Open it with the corresponding version of Meshroom to recover your data."
))
self.graph.fileDateVersion = os.path.getmtime(filepath)
return status
except FileNotFoundError as e:
self.error.emit(
@ -769,6 +766,13 @@ class Reconstruction(UIGraph):
"""
if filesByType["images"]:
if cameraInit is None:
if not self._cameraInits:
if isinstance(position, QPoint):
p = Position(position.x(), position.y())
else:
p = position
cameraInit = self.addNewNode("CameraInit", position=p)
else:
boundingBox = self.layout.boundingBox()
if not position:
p = Position(boundingBox[0], boundingBox[1] + boundingBox[3])
@ -779,8 +783,12 @@ class Reconstruction(UIGraph):
cameraInit = self.addNewNode("CameraInit", position=p)
self._workerThreads.apply_async(func=self.importImagesSync, args=(filesByType["images"], cameraInit,))
if filesByType["videos"]:
if self.nodes:
boundingBox = self.layout.boundingBox()
keyframeNode = self.addNewNode("KeyframeSelection", position=Position(boundingBox[0], boundingBox[1] + boundingBox[3]))
p = Position(boundingBox[0], boundingBox[1] + boundingBox[3])
else:
p = position
keyframeNode = self.addNewNode("KeyframeSelection", position=p)
keyframeNode.inputPaths.value = filesByType["videos"]
if len(filesByType["videos"]) == 1:
newVideoNodeMessage = "New node '{}' added for the input video.".format(keyframeNode.getLabel())