[ui] basic sequence player: control selected viewId with a slider

This commit is contained in:
mugulmd 2023-02-09 00:27:27 -08:00 committed by Loïc Vital
parent 6c135e14b9
commit d9264473e4
2 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,45 @@
import QtQuick 2.11
import QtQuick.Controls 2.0
Slider {
function sequence(vps) {
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)
});
}
objs.sort((a, b) => { return a.filename < b.filename ? -1 : 1; });
let viewIds = [];
for (let i = 0; i < objs.length; i++) {
viewIds.push(objs[i].viewId);
}
return viewIds;
}
QtObject {
id: m
property var currentCameraInit: _reconstruction && _reconstruction.cameraInit ? _reconstruction.cameraInit : undefined
property var viewpoints: currentCameraInit ? currentCameraInit.attribute('viewpoints').value : undefined
property var sortedViewIds: viewpoints ? sequence(viewpoints) : []
}
stepSize: 1
snapMode: Slider.SnapAlways
live: true
from: 0
to: Math.max(m.sortedViewIds.length, 1)
onValueChanged: {
let idx = Math.floor(value);
if (_reconstruction && idx >= 0 && idx < m.sortedViewIds.length - 1) {
_reconstruction.selectedViewId = m.sortedViewIds[idx];
}
}
}

View file

@ -1296,6 +1296,10 @@ FocusScope {
}
}
FloatingPane {
SequencePlayer {}
}
}
}
}