mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
[ui] Improve sequence display
- allows multiple "*" in the files search expression - fix a bug if we only provide a folder - keep the current frame if the frame range has not changed
This commit is contained in:
parent
53679485a9
commit
15c1ce16b5
2 changed files with 41 additions and 41 deletions
|
@ -147,23 +147,19 @@ class FilepathHelper(QObject):
|
|||
extension = ".*"
|
||||
return [self.basename(f) for f in glob.glob(os.path.join(folderPath, f"*{extension}")) if os.path.isfile(f)]
|
||||
|
||||
@Slot(str, result="QVariantList")
|
||||
def resolveSequence(self, path):
|
||||
@Slot(str, bool, result="QVariantList")
|
||||
def resolveSequence(self, path, includesSeqMissingFiles):
|
||||
"""
|
||||
Get id of each file in the sequence.
|
||||
"""
|
||||
# use of pyseq to get the sequences
|
||||
seq = pyseq.get_sequences(self.asStr(path))
|
||||
seqs = pyseq.get_sequences(self.asStr(path))
|
||||
|
||||
ids = [[s.start(), s.end()] for s in seq]
|
||||
frameRanges = [[seq.start(), seq.end()] for seq in seqs]
|
||||
|
||||
folder = self.dirname(path)
|
||||
|
||||
missingFiles = [s.missing() for s in seq]
|
||||
|
||||
# create the resolved path for each sequence and if a frame is missing add a empty string
|
||||
resolved = [[os.path.join(folder, s.head() + str(s.format("%p") % frame) + s.tail()) if frame not in missingFiles[seq.index(s)]
|
||||
else "" for frame in range(ids[seq.index(s)][0], ids[seq.index(s)][1] + 1)] if s.frames()
|
||||
else os.path.join(folder, s.head())
|
||||
for s in seq]
|
||||
return ids, resolved
|
||||
# create the resolved path for each sequence
|
||||
if includesSeqMissingFiles:
|
||||
resolved = [[seq.format("%D%h%p%t") % frameNumber for frameNumber in range(seq.start(), seq.end() + 1)] for seq in seqs]
|
||||
else:
|
||||
resolved = [[fileItem.path for fileItem in seq] for seq in seqs]
|
||||
return frameRanges, resolved
|
||||
|
|
|
@ -251,52 +251,56 @@ FocusScope {
|
|||
function buildOrderedSequence(pathTemplate) {
|
||||
// Resolve the path template on the sequence of viewpoints
|
||||
// ordered by path
|
||||
let outputFiles = []
|
||||
|
||||
let objs = []
|
||||
|
||||
if (displayedNode && displayedNode.hasSequenceOutput && displayedAttr &&
|
||||
(displayedAttr.desc.semantic === "imageList" || displayedAttr.desc.semantic === "sequence")) {
|
||||
let sequence = Filepath.resolveSequence(pathTemplate)
|
||||
let ids = sequence[0]
|
||||
let resolved = sequence[1]
|
||||
if (displayedNode && displayedNode.hasSequenceOutput && displayedAttr) {
|
||||
|
||||
// reset current frame to 0 if it is imageList but not sequence
|
||||
if (displayedAttr.desc.semantic === "imageList") {
|
||||
let includesSeqMissingFiles = false // list only the existing files
|
||||
let [_, filesSeqs] = Filepath.resolveSequence(pathTemplate, includesSeqMissingFiles)
|
||||
// concat in one array all sequences in resolved
|
||||
resolved = [].concat.apply([], resolved)
|
||||
frameRange.min = 0
|
||||
frameRange.max = resolved.length - 1
|
||||
currentFrame = 0
|
||||
outputFiles = [].concat.apply([], filesSeqs)
|
||||
let newFrameRange = [0, outputFiles.length - 1]
|
||||
|
||||
if(frameRange.min != newFrameRange[0] || frameRange.max != newFrameRange[1]) {
|
||||
frameRange.min = newFrameRange[0]
|
||||
frameRange.max = newFrameRange[1]
|
||||
// Change the current frame, only if the frame range is different
|
||||
currentFrame = frameRange.min
|
||||
}
|
||||
|
||||
enableSequencePlayerAction.checked = true
|
||||
}
|
||||
|
||||
if (displayedAttr.desc.semantic === "sequence") {
|
||||
// if there is several sequences, take the first one, else take the only one
|
||||
if (typeof resolved[0] === "object")
|
||||
resolved = resolved[0]
|
||||
ids = ids[0]
|
||||
frameRange.min = ids[0]
|
||||
frameRange.max = ids[ids.length - 1]
|
||||
currentFrame = frameRange.min
|
||||
let includesSeqMissingFiles = true
|
||||
let [frameRanges, filesSeqs] = Filepath.resolveSequence(pathTemplate, includesSeqMissingFiles)
|
||||
let newFrameRange = [0, 0]
|
||||
if (filesSeqs.length > 0) {
|
||||
// if there is one or several sequences, take the first one
|
||||
outputFiles = filesSeqs[0]
|
||||
newFrameRange = frameRanges[0]
|
||||
}
|
||||
|
||||
|
||||
enableSequencePlayerAction.checked = true
|
||||
}
|
||||
|
||||
enableSequencePlayerAction.checked = true
|
||||
|
||||
return resolved
|
||||
} else {
|
||||
let objs = []
|
||||
for (let i = 0; i < _reconstruction.viewpoints.count; i++) {
|
||||
objs.push(_reconstruction.viewpoints.at(i))
|
||||
}
|
||||
objs.sort((a, b) => { return a.childAttribute("path").value < b.childAttribute("path").value ? -1 : 1; })
|
||||
let seq = [];
|
||||
|
||||
for (let i = 0; i < objs.length; i++) {
|
||||
seq.push(Filepath.resolve(pathTemplate, objs[i]))
|
||||
outputFiles.push(Filepath.resolve(pathTemplate, objs[i]))
|
||||
}
|
||||
|
||||
frameRange.min = 0
|
||||
frameRange.max = seq.length - 1
|
||||
|
||||
return seq
|
||||
frameRange.max = outputFiles.length - 1
|
||||
}
|
||||
return outputFiles
|
||||
}
|
||||
|
||||
function getSequence() {
|
||||
|
|
Loading…
Add table
Reference in a new issue