mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-30 09:26:32 +02:00
[ui] add new patterns to load images in viewer2D
This commit is contained in:
parent
2f36b2a8bb
commit
731440eaa1
2 changed files with 30 additions and 11 deletions
|
@ -49,6 +49,12 @@ class FilepathHelper(QObject):
|
||||||
""" Returns the extension (.ext) of a pathname """
|
""" Returns the extension (.ext) of a pathname """
|
||||||
return os.path.splitext(self.asStr(path))[-1]
|
return os.path.splitext(self.asStr(path))[-1]
|
||||||
|
|
||||||
|
@Slot(str, result=str)
|
||||||
|
@Slot(QUrl, result=str)
|
||||||
|
def removeExtension(self, path):
|
||||||
|
""" Returns the pathname without its extension (.ext)"""
|
||||||
|
return os.path.splitext(self.asStr(path))[0]
|
||||||
|
|
||||||
@Slot(str, result=bool)
|
@Slot(str, result=bool)
|
||||||
@Slot(QUrl, result=bool)
|
@Slot(QUrl, result=bool)
|
||||||
def isFile(self, path):
|
def isFile(self, path):
|
||||||
|
|
|
@ -219,37 +219,50 @@ FocusScope {
|
||||||
return sourceExternal;
|
return sourceExternal;
|
||||||
}
|
}
|
||||||
if (_reconstruction && (!displayedNode || outputAttribute.name == "gallery")) {
|
if (_reconstruction && (!displayedNode || outputAttribute.name == "gallery")) {
|
||||||
return getViewpointPath(_reconstruction.selectedViewId);
|
return Filepath.stringToUrl(getViewpointAttribute("path",_reconstruction.selectedViewId));
|
||||||
}
|
}
|
||||||
return getFileAttributePath(displayedNode, outputAttribute.name, _reconstruction ? _reconstruction.selectedViewId : -1);
|
|
||||||
|
var viewId = -1;
|
||||||
|
var intrinsicId = -1;
|
||||||
|
var fileName = "";
|
||||||
|
if (_reconstruction) {
|
||||||
|
viewId = _reconstruction.selectedViewId;
|
||||||
|
intrinsicId = getViewpointAttribute("intrinsicId", viewId);
|
||||||
|
fileName = Filepath.removeExtension(Filepath.basename(getViewpointAttribute("path",viewId)));
|
||||||
|
}
|
||||||
|
var patterns = {"<VIEW_ID>": viewId,"<INTRINSIC_ID>": intrinsicId, "<FILENAME>": fileName}
|
||||||
|
return getFileAttributePath(displayedNode, outputAttribute.name,patterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileAttributePath(node, attrName, viewId) {
|
function getFileAttributePath(node, attrName, patterns) {
|
||||||
// get output attribute with matching name
|
// get output attribute with matching name
|
||||||
// and parse its value to get the image filepath
|
// and parse with the patterns present in the patterns dict
|
||||||
if (!node)
|
if (!node)
|
||||||
return "";
|
return "";
|
||||||
for (var i = 0; i < node.attributes.count; i++) {
|
for (var i = 0; i < node.attributes.count; i++) {
|
||||||
var attr = node.attributes.at(i);
|
var attr = node.attributes.at(i);
|
||||||
if (attr.name == attrName) {
|
if (attr.name == attrName) {
|
||||||
let pattern = String(attr.value).replace("<VIEW_ID>", viewId);
|
let path = String(attr.value)
|
||||||
let path = Filepath.globFirst(pattern);
|
for (var key in patterns) {
|
||||||
|
if (patterns.hasOwnProperty(key)) {
|
||||||
|
path = path.replace(key, patterns[key])
|
||||||
|
}
|
||||||
|
}
|
||||||
return Filepath.stringToUrl(path);
|
return Filepath.stringToUrl(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewpointPath(viewId) {
|
function getViewpointAttribute(attributeName, viewId) {
|
||||||
// get viewpoint from cameraInit with matching id
|
// get viewpoint from cameraInit with matching id and return the attribute corresponding to the attributeName
|
||||||
// and get its image filepath
|
|
||||||
for (var i = 0; i < _reconstruction.viewpoints.count; i++) {
|
for (var i = 0; i < _reconstruction.viewpoints.count; i++) {
|
||||||
var vp = _reconstruction.viewpoints.at(i);
|
var vp = _reconstruction.viewpoints.at(i);
|
||||||
if (vp.childAttribute("viewId").value == viewId) {
|
if (vp.childAttribute("viewId").value == viewId) {
|
||||||
return Filepath.stringToUrl(vp.childAttribute("path").value);
|
return vp.childAttribute(attributeName).value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewpointMetadata(viewId) {
|
function getViewpointMetadata(viewId) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue