From ba02aa7098324996ec877a3caa3108d7c1537675 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 19 Apr 2019 16:56:55 -0700 Subject: [PATCH] making luci2 better --- .../utilities/lib/jet/qml/TaskPropView.qml | 12 ++- .../utilities/render/debugCulling.js | 2 +- scripts/developer/utilities/render/luci.js | 85 ++---------------- scripts/developer/utilities/render/luci.qml | 25 ++++++ .../render/{culling.qml => luci/Culling.qml} | 21 +++-- .../developer/utilities/render/luci/Page.js | 90 +++++++++++++++++++ .../developer/utilities/render/luci/qmldir | 3 +- scripts/developer/utilities/render/luci2.js | 87 ++++++++++++++++-- .../utilities/render/materialInspector.js | 8 +- 9 files changed, 236 insertions(+), 97 deletions(-) rename scripts/developer/utilities/render/{culling.qml => luci/Culling.qml} (86%) create mode 100644 scripts/developer/utilities/render/luci/Page.js diff --git a/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml b/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml index 0587352b4e..165edcf2e1 100644 --- a/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml +++ b/scripts/developer/utilities/lib/jet/qml/TaskPropView.qml @@ -31,7 +31,15 @@ Prop.PropGroup { property var showProps: true property var showSubs: true property var jobEnabled: rootConfig.getConfig(jobPath).enabled - property var jobCpuTime: rootConfig.getConfig(jobPath).cpuRunTime.toPrecision(3) + property var jobCpuTime: pullCpuTime() + + function pullCpuTime() { + if (jobEnabled) { + return rootConfig.getConfig(jobPath).cpuRunTime.toPrecision(3); + } else { + return '.' + } + } property var toggleJobActivation: function() { console.log("the button has been pressed and jobEnabled is " + jobEnabled ) @@ -52,7 +60,7 @@ Prop.PropGroup { } Prop.PropLabel { id: cpuTime - visible: root.jobEnabled + visible: false // root.jobEnabled width: 50 text: jobCpuTime horizontalAlignment: Text.AlignLeft diff --git a/scripts/developer/utilities/render/debugCulling.js b/scripts/developer/utilities/render/debugCulling.js index 788c7cb4a0..e7c68fd717 100644 --- a/scripts/developer/utilities/render/debugCulling.js +++ b/scripts/developer/utilities/render/debugCulling.js @@ -10,7 +10,7 @@ // // Set up the qml ui -var qml = Script.resolvePath('culling.qml'); +var qml = Script.resolvePath('luci/Culling.qml'); var window = new OverlayWindow({ title: 'Render Draws', source: qml, diff --git a/scripts/developer/utilities/render/luci.js b/scripts/developer/utilities/render/luci.js index bae5c4646d..fd84f55e65 100644 --- a/scripts/developer/utilities/render/luci.js +++ b/scripts/developer/utilities/render/luci.js @@ -10,10 +10,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + + (function() { var AppUi = Script.require('appUi'); var MaterialInspector = Script.require('./materialInspector.js'); + var Page = Script.require('./luci/Page.js'); var moveDebugCursor = false; var onMousePressEvent = function (e) { @@ -43,83 +46,12 @@ Render.getConfig("RenderMainView").getConfig("DebugDeferredBuffer").size = { x: nx, y: ny, z: 1.0, w: 1.0 }; } - function Page(title, qmlurl, width, height, handleWindowFunc) { - this.title = title; - this.qml = qmlurl; - this.width = width; - this.height = height; - this.handleWindowFunc = handleWindowFunc; - this.window; - - print("Page: New Page:" + JSON.stringify(this)); - } - - Page.prototype.killView = function () { - print("Page: Kill window for page:" + JSON.stringify(this)); - if (this.window) { - print("Page: Kill window for page:" + this.title); - //this.window.closed.disconnect(function () { - // this.killView(); - //}); - this.window.close(); - this.window = false; - } - }; - - Page.prototype.createView = function () { - var that = this; - if (!this.window) { - print("Page: New window for page:" + this.title); - this.window = Desktop.createWindow(Script.resolvePath(this.qml), { - title: this.title, - presentationMode: Desktop.PresentationMode.NATIVE, - size: {x: this.width, y: this.height} - }); - this.handleWindowFunc(this.window); - this.window.closed.connect(function () { - that.killView(); - this.handleWindowFunc(undefined); - }); - } - }; - - - var Pages = function () { - this._pages = {}; - }; - - Pages.prototype.addPage = function (command, title, qmlurl, width, height, handleWindowFunc) { - if (handleWindowFunc === undefined) { - // Workaround for bad linter - handleWindowFunc = function(window){}; - } - this._pages[command] = new Page(title, qmlurl, width, height, handleWindowFunc); - }; - - Pages.prototype.open = function (command) { - print("Pages: command = " + command); - if (!this._pages[command]) { - print("Pages: unknown command = " + command); - return; - } - this._pages[command].createView(); - }; - - Pages.prototype.clear = function () { - for (var p in this._pages) { - print("Pages: kill page: " + p); - this._pages[p].killView(); - delete this._pages[p]; - } - this._pages = {}; - }; var pages = new Pages(); - pages.addPage('openEngineView', 'Render Engine', 'engineInspector.qml', 300, 400); - pages.addPage('openEngineLODView', 'Render LOD', 'lod.qml', 300, 400); - pages.addPage('openCullInspectorView', 'Cull Inspector', 'culling.qml', 300, 400); - pages.addPage('openMaterialInspectorView', 'Material Inspector', 'materialInspector.qml', 300, 400, MaterialInspector.setWindow); + pages.addPage('openEngineLODView', 'Render LOD', '../lod.qml', 300, 400); + pages.addPage('openCullInspectorView', 'Cull Inspector', '../luci/Culling.qml', 300, 400); + pages.addPage('openMaterialInspectorView', 'Material Inspector', '../materialInspector.qml', 300, 400, MaterialInspector.setWindow); function fromQml(message) { if (pages.open(message.method)) { @@ -132,7 +64,7 @@ ui = new AppUi({ buttonName: "LUCI", home: Script.resolvePath("deferredLighting.qml"), - additionalAppScreens: Script.resolvePath("engineInspector.qml"), + additionalAppScreens : Script.resolvePath("engineInspector.qml"), onMessage: fromQml, normalButton: Script.resolvePath("../../../system/assets/images/luci-i.svg"), activeButton: Script.resolvePath("../../../system/assets/images/luci-a.svg") @@ -144,8 +76,5 @@ Controller.mouseReleaseEvent.disconnect(onMouseReleaseEvent); Controller.mouseMoveEvent.disconnect(onMouseMoveEvent); pages.clear(); - // killEngineInspectorView(); - // killCullInspectorView(); - // killEngineLODWindow(); }); }()); diff --git a/scripts/developer/utilities/render/luci.qml b/scripts/developer/utilities/render/luci.qml index 6ceee9a8d0..a904ec52fc 100644 --- a/scripts/developer/utilities/render/luci.qml +++ b/scripts/developer/utilities/render/luci.qml @@ -62,6 +62,31 @@ Rectangle { Antialiasing {} } } + Prop.PropFolderPanel { + label: "Culling" + panelFrameData: Component { + Culling {} + } + } + Prop.PropFolderPanel { + label: "Tools" + panelFrameData: Component { + Row { + HifiControls.Button { + text: "LOD" + onClicked: { + sendToScript({method: "openEngineLODView"}); + } + } + HifiControls.Button { + text: "Material" + onClicked: { + sendToScript({method: "openMaterialInspectorView"}); + } + } + } + } + } Jet.TaskPropView { id: "le" jobPath: "" diff --git a/scripts/developer/utilities/render/culling.qml b/scripts/developer/utilities/render/luci/Culling.qml similarity index 86% rename from scripts/developer/utilities/render/culling.qml rename to scripts/developer/utilities/render/luci/Culling.qml index 801cb5b573..d881ddf7a6 100644 --- a/scripts/developer/utilities/render/culling.qml +++ b/scripts/developer/utilities/render/luci/Culling.qml @@ -9,11 +9,16 @@ // import QtQuick 2.5 import QtQuick.Controls 1.4 -import "configSlider" + +import "../../lib/prop" as Prop Column { id: root spacing: 8 + + anchors.left: parent.left; + anchors.right: parent.right; + property var sceneOctree: Render.getConfig("RenderMainView.DrawSceneOctree"); property var itemSelection: Render.getConfig("RenderMainView.DrawItemSelection"); @@ -36,6 +41,10 @@ Column { GroupBox { title: "Culling" + + anchors.left: parent.left; + anchors.right: parent.right; + Row { spacing: 8 Column { @@ -91,6 +100,7 @@ Column { } } } + } GroupBox { @@ -103,13 +113,14 @@ Column { anchors.right: parent.right; Repeater { model: [ "Opaque:RenderMainView.DrawOpaqueDeferred", "Transparent:RenderMainView.DrawTransparentDeferred", "Light:RenderMainView.DrawLight", - "Opaque Overlays:RenderMainView.DrawOverlay3DOpaque", "Transparent Overlays:RenderMainView.DrawOverlay3DTransparent" ] - ConfigSlider { + "Opaque InFront:RenderMainView.DrawInFrontOpaque", "Transparent InFront:RenderMainView.DrawInFrontTransparent", + "Opaque HUD:RenderMainView.DrawHUDOpaque", "Transparent HUD:RenderMainView.DrawHUDTransparent" ] + Prop.PropScalar { label: qsTr(modelData.split(":")[0]) integral: true - config: Render.getConfig(modelData.split(":")[1]) + object: Render.getConfig(modelData.split(":")[1]) property: "maxDrawn" - max: config.numDrawn + max: object.numDrawn min: -1 } } diff --git a/scripts/developer/utilities/render/luci/Page.js b/scripts/developer/utilities/render/luci/Page.js new file mode 100644 index 0000000000..06c9704abf --- /dev/null +++ b/scripts/developer/utilities/render/luci/Page.js @@ -0,0 +1,90 @@ +// +// Page.js +// +// Sam Gateau, created on 4/19/2019 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +"use strict"; + +(function() { +function Page(title, qmlurl, width, height, onViewCreated, onViewClosed) { + this.title = title; + this.qml = qmlurl; + this.width = width; + this.height = height; + this.onViewCreated = onViewCreated; + this.onViewClosed = onViewClosed; + + this.window; + + print("Page: New Page:" + JSON.stringify(this)); +} + +Page.prototype.killView = function () { + print("Page: Kill window for page:" + JSON.stringify(this)); + if (this.window) { + print("Page: Kill window for page:" + this.title); + //this.window.closed.disconnect(function () { + // this.killView(); + //}); + this.window.close(); + this.window = false; + } +}; + +Page.prototype.createView = function () { + var that = this; + if (!this.window) { + print("Page: New window for page:" + this.title); + this.window = Desktop.createWindow(Script.resolvePath(this.qml), { + title: this.title, + presentationMode: Desktop.PresentationMode.NATIVE, + size: {x: this.width, y: this.height} + }); + this.onViewCreated(this.window); + this.window.closed.connect(function () { + that.killView(); + that.onViewClosed(); + }); + } +}; + + +Pages = function () { + this._pages = {}; +}; + +Pages.prototype.addPage = function (command, title, qmlurl, width, height, onViewCreated, onViewClosed) { + if (onViewCreated === undefined) { + // Workaround for bad linter + onViewCreated = function(window) {}; + } + if (onViewClosed === undefined) { + // Workaround for bad linter + onViewClosed = function() {}; + } + this._pages[command] = new Page(title, qmlurl, width, height, onViewCreated, onViewClosed); +}; + +Pages.prototype.open = function (command) { + print("Pages: command = " + command); + if (!this._pages[command]) { + print("Pages: unknown command = " + command); + return; + } + this._pages[command].createView(); +}; + +Pages.prototype.clear = function () { + for (var p in this._pages) { + print("Pages: kill page: " + p); + this._pages[p].killView(); + delete this._pages[p]; + } + this._pages = {}; +}; + +}()); diff --git a/scripts/developer/utilities/render/luci/qmldir b/scripts/developer/utilities/render/luci/qmldir index c88dfee714..7a7d6a8ca6 100644 --- a/scripts/developer/utilities/render/luci/qmldir +++ b/scripts/developer/utilities/render/luci/qmldir @@ -3,4 +3,5 @@ ShadingModel 1.0 ShadingModel.qml ToneMapping 1.0 ToneMapping.qml BoundingBoxes 1.0 BoundingBoxes.qml Framebuffer 1.0 Framebuffer.qml -Antialiasing 1.0 Antialiasing.qml \ No newline at end of file +Antialiasing 1.0 Antialiasing.qml +Culling 1.0 Culling.qml \ No newline at end of file diff --git a/scripts/developer/utilities/render/luci2.js b/scripts/developer/utilities/render/luci2.js index d6bb005795..a34cf88415 100644 --- a/scripts/developer/utilities/render/luci2.js +++ b/scripts/developer/utilities/render/luci2.js @@ -1,10 +1,83 @@ + + +var MaterialInspector = Script.require('./materialInspector.js'); +var Page = Script.require('./luci/Page.js'); + + function openView() { - // Set up the qml ui - var window = Desktop.createWindow(Script.resolvePath('luci.qml'), { - title: this.title, - presentationMode: Desktop.PresentationMode.NATIVE, - size: {x: 300, y: 400} - }); //window.closed.connect(function() { Script.stop(); }); + + + var pages = new Pages(); + function fromQml(message) { + if (pages.open(message.method)) { + return; + } + } + + var luciWindow + function openLuciWindow(window) { + if (luciWindow !== undefined) { + activeWindow.fromQml.disconnect(fromQml); + } + if (window !== undefined) { + window.fromQml.connect(fromQml); + } + luciWindow = window; + + + var moveDebugCursor = false; + var onMousePressEvent = function (e) { + if (e.isMiddleButton) { + moveDebugCursor = true; + setDebugCursor(e.x, e.y); + } + }; + Controller.mousePressEvent.connect(onMousePressEvent); + + var onMouseReleaseEvent = function () { + moveDebugCursor = false; + }; + Controller.mouseReleaseEvent.connect(onMouseReleaseEvent); + + var onMouseMoveEvent = function (e) { + if (moveDebugCursor) { + setDebugCursor(e.x, e.y); + } + }; + Controller.mouseMoveEvent.connect(onMouseMoveEvent); + + function setDebugCursor(x, y) { + var nx = 2.0 * (x / Window.innerWidth) - 1.0; + var ny = 1.0 - 2.0 * ((y) / (Window.innerHeight)); + + Render.getConfig("RenderMainView").getConfig("DebugDeferredBuffer").size = { x: nx, y: ny, z: 1.0, w: 1.0 }; + } + + } + + function closeLuciWindow() { + if (luciWindow !== undefined) { + activeWindow.fromQml.disconnect(fromQml); + } + luciWindow = {}; + + Controller.mousePressEvent.disconnect(onMousePressEvent); + Controller.mouseReleaseEvent.disconnect(onMouseReleaseEvent); + Controller.mouseMoveEvent.disconnect(onMouseMoveEvent); + pages.clear(); + } + + pages.addPage('Luci', 'Luci', '../luci.qml', 300, 420, openLuciWindow, closeLuciWindow); + pages.addPage('openEngineLODView', 'Render LOD', '../lod.qml', 300, 400); + pages.addPage('openMaterialInspectorView', 'Material Inspector', '../materialInspector.qml', 300, 400, MaterialInspector.setWindow, MaterialInspector.setWindow); + + pages.open('Luci'); + + + return pages; } -openView(); \ No newline at end of file + + +openView(); + diff --git a/scripts/developer/utilities/render/materialInspector.js b/scripts/developer/utilities/render/materialInspector.js index 76e5da5cd0..98d9f769fb 100644 --- a/scripts/developer/utilities/render/materialInspector.js +++ b/scripts/developer/utilities/render/materialInspector.js @@ -109,7 +109,9 @@ function mouseReleaseEvent(event) { } function killWindow() { - setWindow(undefined); + activeWindow = undefined; + + // setWindow(undefined); } function toQml(message) { @@ -138,14 +140,14 @@ function setSelectedObject(id, type) { function setWindow(window) { if (activeWindow !== undefined) { setSelectedObject(Uuid.NULL, ""); - activeWindow.closed.disconnect(killWindow); + // activeWindow.closed.disconnect(killWindow); activeWindow.fromQml.disconnect(fromQml); Controller.mousePressEvent.disconnect(mousePressEvent); Controller.mouseReleaseEvent.disconnect(mouseReleaseEvent); activeWindow.close(); } if (window !== undefined) { - window.closed.connect(killWindow); + // window.closed.connect(killWindow); window.fromQml.connect(fromQml); Controller.mousePressEvent.connect(mousePressEvent); Controller.mouseReleaseEvent.connect(mouseReleaseEvent);