mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-02 10:52:03 +02:00
[ui] save after drag&drop: meshroom scenes detected as separated type of file
In FilesByType, new attribute meshroomScene allowing to detected separately the meshroom scenes from the other types of file.
This commit is contained in:
parent
58e9bafa45
commit
b74cada8ef
4 changed files with 30 additions and 21 deletions
|
@ -69,6 +69,7 @@ videoExtensions = (
|
|||
'.mxf',
|
||||
)
|
||||
panoramaInfoExtensions = ('.xml')
|
||||
meshroomSceneExtensions = ('.mg')
|
||||
|
||||
|
||||
def hasExtension(filepath, extensions):
|
||||
|
@ -81,15 +82,17 @@ class FilesByType:
|
|||
self.images = []
|
||||
self.videos = []
|
||||
self.panoramaInfo = []
|
||||
self.meshroomScene = []
|
||||
self.other = []
|
||||
|
||||
def __bool__(self):
|
||||
return self.images or self.videos or self.panoramaInfo
|
||||
return self.images or self.videos or self.panoramaInfo or self.meshroomScene
|
||||
|
||||
def extend(self, other):
|
||||
self.images.extend(other.images)
|
||||
self.videos.extend(other.videos)
|
||||
self.panoramaInfo.extend(other.panoramaInfo)
|
||||
self.meshroomScene.extend(other.meshroomScene)
|
||||
self.other.extend(other.other)
|
||||
|
||||
def addFile(self, file):
|
||||
|
@ -99,6 +102,8 @@ class FilesByType:
|
|||
self.videos.append(file)
|
||||
elif hasExtension(file, panoramaInfoExtensions):
|
||||
self.panoramaInfo.append(file)
|
||||
elif hasExtension(file, meshroomSceneExtensions):
|
||||
self.meshroomScene.append(file)
|
||||
else:
|
||||
self.other.append(file)
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ Item {
|
|||
onAllViewpointsCleared: { reconstruction.removeAllImages(); reconstruction.selectedViewId = "-1" }
|
||||
onFilesDropped: {
|
||||
var filesByType = _reconstruction.getFilesByTypeFromDrop(drop.urls)
|
||||
if (filesByType["other"].length > 0) {
|
||||
if (filesByType["meshroomScene"].length == 1) {
|
||||
ensureSaved(function() {
|
||||
reconstruction.handleFilesUrl(filesByType, augmentSfm ? null : cameraInit)
|
||||
})
|
||||
|
|
|
@ -1188,7 +1188,7 @@ ApplicationWindow {
|
|||
}
|
||||
onFilesDropped: {
|
||||
var filesByType = _reconstruction.getFilesByTypeFromDrop(drop.urls)
|
||||
if (filesByType["other"].length > 0) {
|
||||
if (filesByType["meshroomScene"].length == 1) {
|
||||
ensureSaved(function() {
|
||||
_reconstruction.handleFilesUrl(filesByType, null, mousePosition)
|
||||
})
|
||||
|
|
|
@ -785,24 +785,28 @@ class Reconstruction(UIGraph):
|
|||
"",
|
||||
))
|
||||
|
||||
if not filesByType["images"] and not filesByType["videos"] and not filesByType["panoramaInfo"]:
|
||||
if filesByType["other"]:
|
||||
singleMgFile = False
|
||||
if len(filesByType["other"]) == 1:
|
||||
url = filesByType["other"][0]
|
||||
ext = os.path.splitext(url)[1]
|
||||
if ext == '.mg':
|
||||
self.loadUrl(url)
|
||||
singleMgFile = True
|
||||
if not singleMgFile:
|
||||
extensions = set([os.path.splitext(url)[1] for url in filesByType["other"]])
|
||||
self.error.emit(
|
||||
Message(
|
||||
"No Recognized Input File",
|
||||
"No recognized input file in the {} dropped files".format(len(filesByType["other"])),
|
||||
"Unknown file extensions: " + ', '.join(extensions)
|
||||
)
|
||||
if filesByType["meshroomScene"]:
|
||||
if len(filesByType["meshroomScene"]) > 1:
|
||||
self.error.emit(
|
||||
Message(
|
||||
"Too much Meshroom Scenes",
|
||||
"You should only import 1 .mg file"
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.loadUrl(filesByType["meshroomScene"][0])
|
||||
|
||||
|
||||
if not filesByType["images"] and not filesByType["videos"] and not filesByType["panoramaInfo"] and not filesByType["meshroomScene"]:
|
||||
if filesByType["other"]:
|
||||
extensions = set([os.path.splitext(url)[1] for url in filesByType["other"]])
|
||||
self.error.emit(
|
||||
Message(
|
||||
"No Recognized Input File",
|
||||
"No recognized input file in the {} dropped files".format(len(filesByType["other"])),
|
||||
"Unknown file extensions: " + ', '.join(extensions)
|
||||
)
|
||||
)
|
||||
|
||||
@Slot("QList<QUrl>", result="QVariantMap")
|
||||
def getFilesByTypeFromDrop(self, urls):
|
||||
|
@ -822,7 +826,7 @@ class Reconstruction(UIGraph):
|
|||
filesByType.extend(multiview.findFilesByTypeInFolder(localFile))
|
||||
else:
|
||||
filesByType.addFile(localFile)
|
||||
return {"images": filesByType.images, "videos": filesByType.videos, "panoramaInfo":filesByType.panoramaInfo, "other":filesByType.other}
|
||||
return {"images": filesByType.images, "videos": filesByType.videos, "panoramaInfo": filesByType.panoramaInfo, "meshroomScene": filesByType.meshroomScene, "other": filesByType.other}
|
||||
|
||||
def importImagesFromFolder(self, path, recursive=False):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue