Skip to content

Commit

Permalink
[ui] sequence player: support output attribute sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
mugulmd committed Jul 3, 2023
1 parent c4f806f commit d852dc1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
4 changes: 2 additions & 2 deletions meshroom/ui/qml/Viewer/SequencePlayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ FloatingPane {
let objs = []
for (let i = 0; i < vps.count; i++) {
objs.push({
viewId: m.viewpoints.at(i).childAttribute("viewId").value,
filename: Filepath.basename(m.viewpoints.at(i).childAttribute("path").value)
viewId: vps.at(i).childAttribute("viewId").value,
filename: Filepath.basename(vps.at(i).childAttribute("path").value)
});
}
objs.sort((a, b) => { return a.filename < b.filename ? -1 : 1; });
Expand Down
40 changes: 37 additions & 3 deletions meshroom/ui/qml/Viewer/Viewer2D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ FocusScope {
"<VIEW_ID>": vp.childAttribute("viewId").value,
"<INTRINSIC_ID>": vp.childAttribute("intrinsicId").value,
"<POSE_ID>": vp.childAttribute("poseId").value,
"<PATH>": vp.childAttribute("path").value,
"<FILENAME>": Filepath.removeExtension(Filepath.basename(vp.childAttribute("path").value)),
};

Expand All @@ -258,7 +259,7 @@ FocusScope {
}

if (_reconstruction) {
let vp = getViewpoint(_reconstruction.selectedViewId);
let vp = getViewpoint(_reconstruction.pickedViewId);
let attr = getAttributeByName(displayedNode, outputAttribute.name);
let path = attr ? attr.value : "";
let resolved = vp ? resolve(path, vp) : "";
Expand All @@ -268,6 +269,39 @@ FocusScope {
return undefined;
}

function buildOrderedSequence(path_template) {
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(resolve(path_template, objs[i]));
}

return seq;
}

function getSequence() {
if (useExternal) {
return [];
}

if (_reconstruction && (!displayedNode || outputAttribute.name == "gallery")) {
return buildOrderedSequence("<PATH>");
}

if (_reconstruction) {
let attr = getAttributeByName(displayedNode, outputAttribute.name);
let path_template = attr ? attr.value : "";
return buildOrderedSequence(path_template);
}

return [];
}

onDisplayedNodeChanged: {
if (!displayedNode) {
root.source = "";
Expand Down Expand Up @@ -440,8 +474,8 @@ FocusScope {
'canBeHovered': false,
'idView': Qt.binding(function() { return (_reconstruction ? _reconstruction.selectedViewId : -1); }),
'cropFisheye': false,
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? _reconstruction.allImagePaths() : []); }),
'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction && (!displayedNode || outputAttribute.name == "gallery"); })
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? getSequence() : []); }),
'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction; })
})
} else {
// Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14
Expand Down

0 comments on commit d852dc1

Please sign in to comment.