[ui] display output 3D files when double clicking on a node

* iterate over output attributes to find an "obj" file
* make default material brighter
This commit is contained in:
Yann Lanthony 2018-01-05 12:13:15 +01:00
parent 76ec5a1913
commit b8f61bf033
6 changed files with 42 additions and 10 deletions

View file

@ -22,6 +22,7 @@ Item {
// signals // signals
signal workspaceMoved() signal workspaceMoved()
signal workspaceClicked() signal workspaceClicked()
signal nodeDoubleClicked(var node)
clip: true clip: true
@ -221,6 +222,7 @@ Item {
onAttributePinCreated: registerAttributePin(attribute, pin) onAttributePinCreated: registerAttributePin(attribute, pin)
onPressed: draggable.selectNode(nodeDelegate) onPressed: draggable.selectNode(nodeDelegate)
onDoubleClicked: root.nodeDoubleClicked(node)
Keys.onDeletePressed: uigraph.removeNode(node) Keys.onDeletePressed: uigraph.removeNode(node)

View file

@ -11,6 +11,7 @@ Item {
property color shadowColor: "black" property color shadowColor: "black"
signal pressed(var mouse) signal pressed(var mouse)
signal doubleClicked(var mouse)
signal attributePinCreated(var attribute, var pin) signal attributePinCreated(var attribute, var pin)
implicitHeight: body.height implicitHeight: body.height
@ -27,6 +28,8 @@ Item {
root.pressed(mouse) root.pressed(mouse)
} }
onDoubleClicked: root.doubleClicked(mouse)
Menu { Menu {
id: nodeMenu id: nodeMenu
MenuItem { MenuItem {

View file

@ -16,10 +16,10 @@ Entity {
property bool showTextures: true property bool showTextures: true
property string diffuseMap: "" property string diffuseMap: ""
property color ambient: "#999999" property color ambient: "#AAA"
property real shininess property real shininess
property color specular property color specular
property color diffuseColor: "#AA9999" property color diffuseColor: "#AAA"
property alias object: instantiator.object property alias object: instantiator.object
NodeInstantiator { NodeInstantiator {

View file

@ -74,15 +74,24 @@ FocusScope {
// unparent previous material // unparent previous material
// and exclude it from the entity components // and exclude it from the entity components
comp.parent = null comp.parent = null
continue; // skip original component and continue
} }
else
comps.push(comp) // make default material brighter
if(comp.toString().indexOf("QPhongMaterial") > -1) {
comp.diffuse = "#AAA"
comp.ambient = "#AAA"
}
comps.push(comp)
} }
entity.components = comps entity.components = comps
mats.forEach(function(m){ mats.forEach(function(m){
// create a material switcher for each material definition // create a material switcher for each material definition
var matSwitcher = materialSwitcherComponent.createObject(entity, m) var matSwitcher = materialSwitcherComponent.createObject(entity, m)
// bind textures checkbox to texture switch property // trigger showTextures update by inverting it
// and re-bind textures checkbox to texture switch property
// (this double update ensure the texture display is correct)
matSwitcher.showTextures = !matSwitcher.showTextures
matSwitcher.showTextures = Qt.binding(function(){ return texturesCheckBox.checked }) matSwitcher.showTextures = Qt.binding(function(){ return texturesCheckBox.checked })
}) })
}) })

View file

@ -26,6 +26,12 @@ Item {
onMeshFileChanged: viewer3D.clear() onMeshFileChanged: viewer3D.clear()
// Load a 3D media file in the 3D viewer
function load3DMedia(filepath)
{
viewer3D.source = filepath
}
SystemPalette { id: palette } SystemPalette { id: palette }
Controls1.SplitView { Controls1.SplitView {

View file

@ -7,6 +7,7 @@ import QtQml.Models 2.2
import Qt.labs.platform 1.0 as Platform import Qt.labs.platform 1.0 as Platform
import GraphEditor 1.0 import GraphEditor 1.0
import MaterialIcons 2.2 import MaterialIcons 2.2
import "filepath.js" as Filepath
ApplicationWindow { ApplicationWindow {
id: _window id: _window
@ -322,7 +323,7 @@ ApplicationWindow {
} }
WorkspaceView { WorkspaceView {
id: imageGallery id: workspaceView
reconstruction: _reconstruction reconstruction: _reconstruction
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
@ -339,19 +340,30 @@ ApplicationWindow {
orientation: Qt.Horizontal orientation: Qt.Horizontal
anchors.fill: parent anchors.fill: parent
ColumnLayout { Item {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: 10 Layout.margins: 10
GraphEditor { GraphEditor {
id: graphEditor id: graphEditor
Layout.fillHeight: true anchors.fill: parent
Layout.fillWidth: true
uigraph: _reconstruction uigraph: _reconstruction
nodeTypesModel: _nodeTypes nodeTypesModel: _nodeTypes
readOnly: _reconstruction.computing readOnly: _reconstruction.computing
onNodeDoubleClicked: {
for(var i=0; i < node.attributes.count; ++i)
{
var attr = node.attributes.at(i)
if(attr.isOutput
&& attr.desc.type === "File"
&& Filepath.extension(attr.value) === ".obj")
{
workspaceView.load3DMedia(attr.value)
break // only load first model found
}
}
}
} }
} }
Item { Item {
implicitHeight: Math.round(parent.height * 0.2) implicitHeight: Math.round(parent.height * 0.2)