mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 06:32:57 +02:00
Regfining
This commit is contained in:
parent
e8bd424697
commit
3a910489c8
4 changed files with 217 additions and 31 deletions
|
@ -123,7 +123,7 @@ public:
|
|||
|
||||
// Running Time measurement
|
||||
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
|
||||
void setCPURunTime(const std::chrono::nanoseconds& runtime) { _msCPURunTime = std::chrono::duration<double, std::milli>(runtime).count(); emit newStats(); }
|
||||
void setCPURunTime(const std::chrono::nanoseconds& runtime) { _msCPURunTime = std::chrono::duration<double, std::milli>(runtime).count(); /* emit newStats();*/ }
|
||||
double getCPURunTime() const { return _msCPURunTime; }
|
||||
|
||||
// Describe the node graph data connections of the associated Job/Task
|
||||
|
@ -230,7 +230,8 @@ public:
|
|||
auto tokens = path.split('.', QString::SkipEmptyParts);
|
||||
|
||||
if (tokens.empty()) {
|
||||
tokens.push_back(QString());
|
||||
return dynamic_cast<typename T::Config*>(const_cast<TaskConfig*> (root));
|
||||
// tokens.push_back(QString());
|
||||
} else {
|
||||
while (tokens.size() > 1) {
|
||||
auto name = tokens.front();
|
||||
|
|
|
@ -27,27 +27,32 @@ Rectangle {
|
|||
property var jobsTree
|
||||
property var jobsArray
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!jobsTree) { jobsTree = new Array(); }
|
||||
if (!jobsArray) { jobsArray = new Array(); }
|
||||
|
||||
var tfunctor = Jet.job_tree_model_array_functor(jobsTree, function(node) {
|
||||
var job = { "fullpath": (node.path + "." + node.name), "cpuT": 0.0, "depth": node.level }
|
||||
var job = { "fullpath": (node.path + "." + node.name), "cpuT": 0.0, "depth": node.level, "name": node.name }
|
||||
jobsArray.push(job)
|
||||
})
|
||||
Jet.task_traverseTree(rootConfig, tfunctor);
|
||||
|
||||
for (var j = 0; j <jobsArray.length; j++) {
|
||||
jobsArray[j].cpuT = Render.getConfig(jobsArray[j].fullpath).cpuRunTime
|
||||
print("job" + j + ": " + jobsArray[j].cpuT)
|
||||
// print("job" + j + ": " + jobsArray[j].cpuT)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Component.onDestruction: {
|
||||
myCanvasTimer.stop();
|
||||
console.log("stopping timer!!!!");
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 500; running: true; repeat: true
|
||||
id: myCanvasTimer
|
||||
interval: 100; running: true; repeat: true
|
||||
onTriggered: pullFreshValues()
|
||||
}
|
||||
|
||||
|
@ -58,16 +63,78 @@ Rectangle {
|
|||
}
|
||||
mycanvas.requestPaint()
|
||||
}
|
||||
|
||||
|
||||
property var frameScale : 10
|
||||
Row {
|
||||
id: myHeaderRow
|
||||
anchors.top:parent.top
|
||||
anchors.left:parent.left
|
||||
anchors.right:parent.right
|
||||
|
||||
|
||||
HifiControls.Button {
|
||||
id: myTimerPlayPause
|
||||
text: (myCanvasTimer.running ? "||" : "|>")
|
||||
height: 24
|
||||
width: 24
|
||||
onClicked: {
|
||||
print("list of highlight styles")
|
||||
myCanvasTimer.running = !myCanvasTimer.running
|
||||
}
|
||||
}
|
||||
}
|
||||
Canvas {
|
||||
id: mycanvas
|
||||
anchors.fill:parent
|
||||
anchors.top:myHeaderRow.bottom
|
||||
anchors.bottom:parent.bottom
|
||||
anchors.left:parent.left
|
||||
anchors.right:parent.right
|
||||
|
||||
onPaint: {
|
||||
print("mycanvasOnPaint " + jobsArray.length)
|
||||
var lineHeight = 12;
|
||||
var frameWidth = width;
|
||||
property var frameDuration: 10
|
||||
property var frameViewBegin: 0
|
||||
property var frameViewRange: width
|
||||
|
||||
|
||||
function reset() {
|
||||
frameViewBegin = 0
|
||||
frameViewRange = width
|
||||
}
|
||||
|
||||
function checkView() {
|
||||
if (frameViewBegin > width * 0.9) {
|
||||
frameViewBegin = width * 0.9
|
||||
} else if (frameViewBegin + frameViewRange < width * 0.1) {
|
||||
frameViewBegin = width * 0.1 -frameViewRange
|
||||
}
|
||||
}
|
||||
|
||||
function drag(deltaX) {
|
||||
frameViewBegin -= deltaX
|
||||
checkView()
|
||||
}
|
||||
|
||||
function pivotScale(pivotX, deltaX) {
|
||||
var newRange = frameViewRange + 2 * deltaX
|
||||
if (newRange <= 1) {
|
||||
newRange = 2;
|
||||
}
|
||||
frameViewBegin = pivotX - frameViewRange * (pivotX - frameViewBegin) / newRange
|
||||
frameViewRange = newRange
|
||||
print( "pivot= " + pivotX + " deltaX= " + (deltaX))
|
||||
checkView()
|
||||
}
|
||||
|
||||
|
||||
onPaint: {
|
||||
// print("mycanvasOnPaint " + jobsArray.length)
|
||||
var lineHeight = 12;
|
||||
|
||||
function getXFromTime(t) {
|
||||
return (t / mycanvas.frameDuration) * mycanvas.frameViewRange - (mycanvas.frameViewBegin)
|
||||
}
|
||||
function getWFromDuration(d) {
|
||||
return (d / mycanvas.frameDuration) * mycanvas.frameViewRange
|
||||
}
|
||||
function displayBackground(ctx) {
|
||||
ctx.fillStyle = Qt.rgba(0, 0, 0, root.backgroundOpacity);
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
@ -80,15 +147,34 @@ Rectangle {
|
|||
ctx.lineTo(width, lineHeight + 1);
|
||||
ctx.moveTo(0, height);
|
||||
ctx.lineTo(width, height);
|
||||
|
||||
var x0 = getXFromTime(0)
|
||||
ctx.moveTo(x0, 0);
|
||||
ctx.lineTo(x0, height);
|
||||
|
||||
x0 = getXFromTime(5)
|
||||
ctx.moveTo(x0, 0);
|
||||
ctx.lineTo(x0, height);
|
||||
|
||||
x0 = getXFromTime(10)
|
||||
ctx.moveTo(x0, 0);
|
||||
ctx.lineTo(x0, height);
|
||||
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
function drawJob(ctx, depth, index, duration, timeOffset, timeScale) {
|
||||
function drawJob(ctx, depth, index, duration, timeOffset) {
|
||||
//print(root.jobsArray[index].cpuT)
|
||||
// ctx.fillStyle = Qt.rgba(255, 255, 0, root.backgroundOpacity);
|
||||
ctx.fillStyle = ( depth % 2 ? ( index % 2 ? "blue" : "yellow") : ( index % 2 ? "green" : "red"))
|
||||
ctx.fillRect(timeOffset * timeScale, lineHeight * depth, duration * timeScale, lineHeight * 0.6);
|
||||
|
||||
ctx.fillRect(getXFromTime(timeOffset), lineHeight * 2 * depth,getWFromDuration(duration), lineHeight);
|
||||
|
||||
if (depth,getWFromDuration(duration) >= width * 0.1) {
|
||||
ctx.fillStyle = "grey";
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText( root.jobsArray[index].name, getXFromTime(timeOffset + duration * 0.5), lineHeight * 2 * depth);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var ctx = getContext("2d");
|
||||
|
@ -97,26 +183,22 @@ Rectangle {
|
|||
|
||||
displayBackground(ctx);
|
||||
if (jobsArray.length > 0) {
|
||||
|
||||
mycanvas.frameDuration = Math.max(jobsArray[0].cpuT, 1)
|
||||
var rangeStack =new Array()
|
||||
var frameDuration = Math.max(jobsArray[0].cpuT, 1)
|
||||
rangeStack.push( { "b": 0.0, "e": frameDuration } )
|
||||
var timeScale = width * 0.9 / frameDuration;
|
||||
|
||||
drawJob(ctx, 0, 0, jobsArray[0].cpuT, 0, timeScale)
|
||||
rangeStack.push( { "b": 0.0, "e": mycanvas.frameDuration } )
|
||||
|
||||
drawJob(ctx, 0, 0, jobsArray[0].cpuT, 0)
|
||||
|
||||
for (var i = 1; i <jobsArray.length; i++) {
|
||||
//for (var i = 1; i <20; i++) {
|
||||
var lastDepth = rangeStack.length - 1;
|
||||
var depth = jobsArray[i].depth;
|
||||
var timeOffset = 0.0
|
||||
var duration = jobsArray[i].cpuT;
|
||||
if (depth < 4) {
|
||||
|
||||
if (depth > lastDepth) {
|
||||
timeOffset = rangeStack[lastDepth].b
|
||||
while(rangeStack.length <= depth) {
|
||||
rangeStack.push( { "b": timeOffset, "e": duration } )
|
||||
rangeStack.push( { "b": timeOffset, "e": timeOffset + duration } )
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -130,12 +212,54 @@ Rectangle {
|
|||
rangeStack[depth].b = timeOffset
|
||||
rangeStack[depth].e = timeOffset + duration
|
||||
}
|
||||
|
||||
print("j " + i + " depth " + depth + " lastDepth " + lastDepth + " off " + timeOffset + " dur " + duration)
|
||||
drawJob(ctx, depth, i, duration, timeOffset, timeScale)
|
||||
if (duration > 0.0) {
|
||||
drawJob(ctx, depth, i, duration, timeOffset)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: hitbox
|
||||
anchors.fill: mycanvas
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
|
||||
property var pivotX
|
||||
property var dragPos
|
||||
onPressed: {
|
||||
dragPos = { "x":mouse.x, "y":mouse.y }
|
||||
pivotX = mouse.x
|
||||
}
|
||||
onPositionChanged: {
|
||||
if (dragPos !== undefined) {
|
||||
var delta = mouse.x - dragPos.x
|
||||
|
||||
if (mouse.buttons & Qt.LeftButton) {
|
||||
mycanvas.drag(delta)
|
||||
}
|
||||
|
||||
if (mouse.buttons & Qt.RightButton) {
|
||||
mycanvas.pivotScale(pivotX, delta)
|
||||
}
|
||||
|
||||
dragPos.x = mouse.x
|
||||
dragPos.y = mouse.y
|
||||
mycanvas.requestPaint()
|
||||
}
|
||||
}
|
||||
onReleased: {
|
||||
dragPos = undefined
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
mycanvas.pivotScale(wheel.x, mycanvas.frameViewRange * 0.02 * (wheel.angleDelta.y / 120.0))
|
||||
mycanvas.requestPaint()
|
||||
}
|
||||
|
||||
onDoubleClicked: {
|
||||
mycanvas.reset()
|
||||
mycanvas.requestPaint()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
function openEngineTaskView() {
|
||||
/*function openEngineTaskView() {
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('engineInspector.qml');
|
||||
var window = new OverlayWindow({
|
||||
|
@ -10,6 +10,62 @@
|
|||
window.setPosition(200, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
||||
}
|
||||
openEngineTaskView();
|
||||
openEngineTaskView();*/
|
||||
|
||||
(function() {
|
||||
var TABLET_BUTTON_NAME = "Render Engine";
|
||||
var QMLAPP_URL = Script.resolvePath("./engineInspector.qml");
|
||||
var ICON_URL = Script.resolvePath("../../../system/assets/images/lod-i.svg");
|
||||
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/lod-a.svg");
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
text: TABLET_BUTTON_NAME,
|
||||
icon: ICON_URL,
|
||||
activeIcon: ACTIVE_ICON_URL
|
||||
});
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
killWindow()
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.removeButton(button);
|
||||
});
|
||||
|
||||
button.clicked.connect(onClicked);
|
||||
|
||||
var onScreen = false;
|
||||
var window;
|
||||
|
||||
function onClicked() {
|
||||
if (onScreen) {
|
||||
killWindow()
|
||||
} else {
|
||||
createWindow()
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
var qml = Script.resolvePath(QMLAPP_URL);
|
||||
window = new OverlayWindow({
|
||||
title: 'Render Engine',
|
||||
source: qml,
|
||||
width: 500,
|
||||
height: 100
|
||||
});
|
||||
window.setPosition(200, 50);
|
||||
window.closed.connect(killWindow);
|
||||
onScreen = true
|
||||
button.editProperties({isActive: true});
|
||||
}
|
||||
|
||||
function killWindow() {
|
||||
if (window !== undefined) {
|
||||
window.closed.disconnect(killWindow);
|
||||
window.close()
|
||||
window = undefined
|
||||
}
|
||||
onScreen = false
|
||||
button.editProperties({isActive: false})
|
||||
}
|
||||
}());
|
||||
|
|
@ -23,9 +23,14 @@ Item {
|
|||
|
||||
property var mainViewTask: Render.getConfig("RenderMainView")
|
||||
|
||||
//Jet.TaskListView {
|
||||
|
||||
Jet.TaskTimeFrameView {
|
||||
rootConfig: Render
|
||||
anchors.fill: render
|
||||
}
|
||||
/* Jet.TaskListView {
|
||||
rootConfig: Render
|
||||
anchors.fill: render
|
||||
} */
|
||||
|
||||
}
|
Loading…
Reference in a new issue