mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-15 17:21:56 +02:00
[ui] WorkspaceView: open images in the 2D Viewer from the Graph/NodeEditor
Double click on a node or an attribute with an image file to display it in the 2D viewer.
This commit is contained in:
parent
bc1eb83d92
commit
dbcfce7c90
3 changed files with 53 additions and 5 deletions
|
@ -78,3 +78,14 @@ class FilepathHelper(QObject):
|
||||||
def normpath(self, path):
|
def normpath(self, path):
|
||||||
""" Returns native normalized path """
|
""" Returns native normalized path """
|
||||||
return os.path.normpath(self.asStr(path))
|
return os.path.normpath(self.asStr(path))
|
||||||
|
|
||||||
|
@Slot(str, result=str)
|
||||||
|
@Slot(QUrl, result=str)
|
||||||
|
def globFirst(self, path):
|
||||||
|
""" Returns the first from a list of paths matching a pathname pattern. """
|
||||||
|
import glob
|
||||||
|
fileList = glob.glob(self.asStr(path))
|
||||||
|
fileList.sort()
|
||||||
|
if fileList:
|
||||||
|
return fileList[0]
|
||||||
|
return ""
|
||||||
|
|
|
@ -23,7 +23,7 @@ Item {
|
||||||
readonly property variant cameraInits: _reconstruction.cameraInits
|
readonly property variant cameraInits: _reconstruction.cameraInits
|
||||||
property bool readOnly: false
|
property bool readOnly: false
|
||||||
readonly property Viewer3D viewer3D: viewer3D
|
readonly property Viewer3D viewer3D: viewer3D
|
||||||
|
readonly property Viewer2D viewer2D: viewer2D
|
||||||
|
|
||||||
implicitWidth: 300
|
implicitWidth: 300
|
||||||
implicitHeight: 400
|
implicitHeight: 400
|
||||||
|
|
|
@ -531,6 +531,28 @@ ApplicationWindow {
|
||||||
viewer3D.solo(attribute);
|
viewer3D.solo(attribute);
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
function viewIn2D(attribute) {
|
||||||
|
var imageExts = ['.exr', '.jpg', '.tif', '.png'];
|
||||||
|
var ext = Filepath.extension(attribute.value);
|
||||||
|
if(imageExts.indexOf(ext) == -1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(attribute.value.includes('*'))
|
||||||
|
{
|
||||||
|
// For now, the viewer only supports a single image.
|
||||||
|
var firstFile = Filepath.globFirst(attribute.value)
|
||||||
|
viewer2D.source = Filepath.stringToUrl(firstFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
viewer2D.source = Filepath.stringToUrl(attribute.value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,10 +620,16 @@ ApplicationWindow {
|
||||||
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.isOutput
|
if(attr.isOutput)
|
||||||
&& workspaceView.viewIn3D(attr, mouse))
|
|
||||||
{
|
{
|
||||||
break;
|
if(workspaceView.viewIn2D(attr))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(workspaceView.viewIn3D(attr, mouse))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,7 +643,16 @@ ApplicationWindow {
|
||||||
node: _reconstruction.selectedNode
|
node: _reconstruction.selectedNode
|
||||||
// Make NodeEditor readOnly when computing
|
// Make NodeEditor readOnly when computing
|
||||||
readOnly: graphLocked
|
readOnly: graphLocked
|
||||||
onAttributeDoubleClicked: workspaceView.viewIn3D(attribute, mouse)
|
onAttributeDoubleClicked: {
|
||||||
|
if(workspaceView.viewIn2D(attribute))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(workspaceView.viewIn3D(attribute, mouse))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
onUpgradeRequest: {
|
onUpgradeRequest: {
|
||||||
var n = _reconstruction.upgradeNode(node);
|
var n = _reconstruction.upgradeNode(node);
|
||||||
_reconstruction.selectedNode = n;
|
_reconstruction.selectedNode = n;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue