[GraphEditor] Clean-up: Harmonize syntax across all files

This commit is contained in:
Candice Bentéjac 2023-10-17 15:42:14 +02:00
parent 2bdf061d2e
commit e9d80611c7
15 changed files with 341 additions and 375 deletions

View file

@ -25,8 +25,7 @@ RowLayout {
spacing: 2
function updateAttributeLabel()
{
function updateAttributeLabel() {
background.color = attribute.validValue ? Qt.darker(palette.window, 1.1) : Qt.darker(Colors.red, 1.5)
if (attribute.desc) {
@ -40,7 +39,10 @@ RowLayout {
}
Pane {
background: Rectangle { id: background; color: object.validValue ? Qt.darker(parent.palette.window, 1.1) : Qt.darker(Colors.red, 1.5) }
background: Rectangle {
id: background
color: object.validValue ? Qt.darker(parent.palette.window, 1.1) : Qt.darker(Colors.red, 1.5)
}
padding: 0
Layout.preferredWidth: labelWidth || implicitWidth
Layout.fillHeight: true
@ -128,8 +130,7 @@ RowLayout {
onClicked: {
forceActiveFocus()
if(mouse.button == Qt.RightButton)
{
if (mouse.button == Qt.RightButton) {
var menu = menuComp.createObject(parameterLabel)
menu.parent = parameterLabel
menu.popup()
@ -147,25 +148,23 @@ RowLayout {
}
}
function setTextFieldAttribute(value)
{
function setTextFieldAttribute(value) {
// editingFinished called even when TextField is readonly
if (!editable)
return
switch(attribute.type)
{
switch (attribute.type) {
case "IntParam":
case "FloatParam":
_reconstruction.setAttribute(root.attribute, Number(value))
updateAttributeLabel()
break;
break
case "File":
_reconstruction.setAttribute(root.attribute, value)
break;
break
default:
_reconstruction.setAttribute(root.attribute, value.trim())
updateAttributeLabel()
break;
break
}
}
@ -173,24 +172,28 @@ RowLayout {
Layout.fillWidth: true
sourceComponent: {
switch(attribute.type)
{
case "ChoiceParam": return attribute.desc.exclusive ? comboBox_component : multiChoice_component
switch (attribute.type) {
case "ChoiceParam":
return attribute.desc.exclusive ? comboBox_component : multiChoice_component
case "IntParam": return slider_component
case "FloatParam":
if (attribute.desc.semantic === 'color/hue')
return color_hue_component
return slider_component
case "BoolParam": return checkbox_component
case "ListAttribute": return listAttribute_component
case "GroupAttribute": return groupAttribute_component
case "BoolParam":
return checkbox_component
case "ListAttribute":
return listAttribute_component
case "GroupAttribute":
return groupAttribute_component
case "StringParam":
if (attribute.desc.semantic === 'multiline')
return textArea_component
return textField_component
case "ColorParam":
return color_component
default: return textField_component
default:
return textField_component
}
}
@ -366,8 +369,11 @@ RowLayout {
checked: attribute.value.indexOf(modelData) >= 0
onToggled: {
var t = attribute.value
if(!checked) { t.splice(t.indexOf(modelData), 1) } // remove element
else { t.push(modelData) } // add element
if (!checked) {
t.splice(t.indexOf(modelData), 1) // remove element
} else {
t.push(modelData) // add element
}
_reconstruction.setAttribute(attribute, t)
}
}
@ -397,7 +403,7 @@ RowLayout {
// When the value change keep the text align to the left to be able to read the most important part
// of the number. When we are editing (item is in focus), the content should follow the editing.
autoScroll: activeFocus
validator: attribute.type == "FloatParam" ? doubleValidator : intValidator
validator: attribute.type === "FloatParam" ? doubleValidator : intValidator
onEditingFinished: setTextFieldAttribute(text)
onAccepted: {
setTextFieldAttribute(text)
@ -482,7 +488,7 @@ RowLayout {
ListView {
id: lv
model: listAttribute_layout.expanded ? attribute.value : undefined
visible: model != undefined && count > 0
visible: model !== undefined && count > 0
implicitHeight: Math.min(contentHeight, 300)
Layout.fillWidth: true
Layout.margins: 4
@ -505,7 +511,8 @@ RowLayout {
Component.onCompleted: {
var cpt = Qt.createComponent("AttributeItemDelegate.qml")
var obj = cpt.createObject(item,
{'attribute': Qt.binding(function() { return item.childAttrib }),
{
'attribute': Qt.binding(function() { return item.childAttrib }),
'readOnly': Qt.binding(function() { return !root.editable })
})
obj.Layout.fillWidth = true
@ -537,7 +544,8 @@ RowLayout {
Component.onCompleted: {
var cpt = Qt.createComponent("AttributeEditor.qml");
var obj = cpt.createObject(groupItem,
{'model': Qt.binding(function() { return attribute.value }),
{
'model': Qt.binding(function() { return attribute.value }),
'readOnly': Qt.binding(function() { return root.readOnly }),
'labelWidth': 100, // reduce label width for children (space gain)
'objectsHideable': Qt.binding(function() { return root.objectsHideable }),
@ -575,9 +583,9 @@ RowLayout {
color: Qt.hsla(slider.pressed ? slider.formattedValue : attribute.value, 1, 0.5, 1)
}
Slider {
id: slider
Layout.fillWidth: true
id: slider
readonly property int stepDecimalCount: 2
readonly property real formattedValue: value.toFixed(stepDecimalCount)
enabled: root.editable

View file

@ -39,8 +39,8 @@ RowLayout {
Repeater {
id: childrenRepeater
model: isList && !attribute.isLink ? attribute.value : 0
onItemAdded: {childPinCreated(item.childAttribute, item)}
onItemRemoved: {childPinDeleted(item.childAttribute, item)}
onItemAdded: childPinCreated(item.childAttribute, item)
onItemRemoved: childPinDeleted(item.childAttribute, item)
delegate: Item {
property var childAttribute: object
}
@ -91,12 +91,10 @@ RowLayout {
|| (drag.source.isList && !inputDragTarget.isList) // connection between a list and a simple attribute
|| (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children
|| drag.source.connectorType === "input" // refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin)
)
{
) {
// Refuse attributes connection
drag.accepted = false
}
else if (inputDragTarget.attribute.isLink) { // already connected attribute
} else if (inputDragTarget.attribute.isLink) { // already connected attribute
root.edgeAboutToBeRemoved(inputDragTarget.attribute)
}
inputDropArea.acceptableDrop = drag.accepted
@ -240,12 +238,10 @@ RowLayout {
|| (!drag.source.isList && outputDragTarget.isList) // connection between a list and a simple attribute
|| (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children
|| drag.source.connectorType === "output" // refuse to connect an output pin on another one
)
{
) {
// Refuse attributes connection
drag.accepted = false
}
else if (drag.source.attribute.isLink) { // already connected attribute
} else if (drag.source.attribute.isLink) { // already connected attribute
root.edgeAboutToBeRemoved(drag.source.attribute)
}
outputDropArea.acceptableDrop = drag.accepted
@ -380,5 +376,4 @@ RowLayout {
}
}
]
}

View file

@ -39,8 +39,7 @@ ColumnLayout {
focus: true
currentIndex: root.currentIndex
onCurrentIndexChanged: {
if(chunksLV.currentIndex !== root.currentIndex)
{
if (chunksLV.currentIndex !== root.currentIndex) {
// When the list is resized, the currentIndex is reset to 0.
// So here we force it to keep the binding.
chunksLV.currentIndex = Qt.binding(function() { return root.currentIndex })

View file

@ -23,7 +23,6 @@ Loader {
property Component iconDelegate: Component {
Label {
text: MaterialIcons.warning
font.family: MaterialIcons.fontFamily
font.pointSize: 12
@ -74,6 +73,5 @@ Loader {
}
}
}
}
}

View file

@ -20,8 +20,7 @@ MessageDialog {
// the number of CompatibilityNodes that can be upgraded
readonly property int upgradableCount: {
var count = 0
for(var i=0; i<issueCount; ++i)
{
for (var i = 0; i < issueCount; ++i) {
if (nodesModel.at(i).canUpgrade)
count++;
}
@ -34,8 +33,7 @@ MessageDialog {
t += '-------------------------\n'
t += "Node | Issue | Upgradable\n"
t += '-------------------------\n'
for(var i=0; i<issueCount; ++i)
{
for (var i = 0; i < issueCount; ++i) {
var n = nodesModel.at(i)
t += n.nodeType + " | " + n.issueDetails + " | " + n.canUpgrade + "\n"
}
@ -108,7 +106,6 @@ MessageDialog {
font.bold: true
}
}
}
Label {
@ -126,11 +123,9 @@ MessageDialog {
}
onAccepted: {
if(upgradableCount)
{
if (upgradableCount) {
uigraph.upgradeAllNodes()
upgradeDone()
}
}
}

View file

@ -53,8 +53,10 @@ Shape {
property real ctrlPtDist: 30
x: root.endX
y: root.endY
relativeControl1X: ctrlPtDist; relativeControl1Y: 0
control2X: x - ctrlPtDist; control2Y: y
relativeControl1X: ctrlPtDist
relativeControl1Y: 0
control2X: x - ctrlPtDist
control2Y: y
}
}

View file

@ -45,10 +45,8 @@ Item {
SystemPalette { id: activePalette }
/// Get node delegate for the given node object
function nodeDelegate(node)
{
for(var i=0; i<nodeRepeater.count; ++i)
{
function nodeDelegate(node) {
for(var i = 0; i < nodeRepeater.count; ++i) {
if (nodeRepeater.itemAt(i).node === node)
return nodeRepeater.itemAt(i)
}
@ -56,8 +54,7 @@ Item {
}
/// Select node delegate
function selectNode(node)
{
function selectNode(node) {
uigraph.selectedNode = node
if (node !== null) {
uigraph.appendSelection(node)
@ -79,8 +76,7 @@ Item {
}
/// Copy node content to clipboard
function copyNodes()
{
function copyNodes() {
var nodeContent = uigraph.getSelectedNodesContent()
if (nodeContent !== '') {
Clipboard.clear()
@ -89,8 +85,7 @@ Item {
}
/// Paste content of clipboard to graph editor and create new node if valid
function pasteNodes()
{
function pasteNodes() {
var finalPosition = undefined
var centerPosition = false
if (mouseArea.containsMouse) {
@ -115,37 +110,30 @@ Item {
}
/// Get the coordinates of the point at the center of the GraphEditor
function getCenterPosition()
{
function getCenterPosition() {
return mapToItem(draggable, mouseArea.width / 2, mouseArea.height / 2)
}
Keys.onPressed: {
if (event.key === Qt.Key_F) {
fit();
}
else if (event.key === Qt.Key_Delete) {
fit()
} else if (event.key === Qt.Key_Delete) {
if (event.modifiers === Qt.AltModifier) {
uigraph.removeNodesFrom(uigraph.selectedNodes);
uigraph.removeNodesFrom(uigraph.selectedNodes)
} else {
uigraph.removeNodes(uigraph.selectedNodes)
}
else {
uigraph.removeNodes(uigraph.selectedNodes);
}
}
else if (event.key === Qt.Key_D) {
duplicateNode(event.modifiers === Qt.AltModifier);
}
else if (event.key === Qt.Key_C && event.modifiers === Qt.ControlModifier) {
copyNodes();
}
else if (event.key === Qt.Key_V && event.modifiers === Qt.ControlModifier) {
pasteNodes();
}
else if (event.key === Qt.Key_Tab) {
event.accepted = true;
} else if (event.key === Qt.Key_D) {
duplicateNode(event.modifiers === Qt.AltModifier)
} else if (event.key === Qt.Key_C && event.modifiers === Qt.ControlModifier) {
copyNodes()
} else if (event.key === Qt.Key_V && event.modifiers === Qt.ControlModifier) {
pasteNodes()
} else if (event.key === Qt.Key_Tab) {
event.accepted = true
if (mouseArea.containsMouse) {
newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouseArea.mouseX, mouseArea.mouseY);
newNodeMenu.popup();
newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouseArea.mouseX, mouseArea.mouseY)
newNodeMenu.popup()
}
}
}
@ -202,11 +190,10 @@ Item {
}
onClicked: {
if(mouse.button == Qt.RightButton)
{
if (mouse.button == Qt.RightButton) {
// store mouse click position in 'draggable' coordinates as new node spawn position
newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouse.x, mouse.y);
newNodeMenu.popup();
newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouse.x, mouse.y)
newNodeMenu.popup()
}
}
@ -217,8 +204,7 @@ Item {
property point spawnPosition
property variant menuKeys: Object.keys(root.nodeTypesModel).concat(Object.values(MeshroomApp.pipelineTemplateNames))
function createNode(nodeType)
{
function createNode(nodeType) {
uigraph.clearNodeSelection() // Ensures that only the created node / imported pipeline will be selected
// "nodeType" might be a pipeline (artificially added in the "Pipelines" category) instead of a node
@ -231,8 +217,7 @@ Item {
close()
}
function importPipeline(pipeline)
{
function importPipeline(pipeline) {
if (MeshroomApp.pipelineTemplateNames.includes(pipeline)) {
var url = MeshroomApp.pipelineTemplateFiles[MeshroomApp.pipelineTemplateNames.indexOf(pipeline)]["path"]
var nodes = uigraph.importProject(Filepath.stringToUrl(url), spawnPosition)
@ -243,21 +228,20 @@ Item {
return false
}
function parseCategories()
{
function parseCategories() {
// Organize nodes based on their category
// {"category1": ["node1", "node2"], "category2": ["node3", "node4"]}
let categories = {};
for (const [name, data] of Object.entries(root.nodeTypesModel)) {
let category = data["category"];
if (categories[category] === undefined) {
categories[category] = [];
categories[category] = []
}
categories[category].push(name)
}
// Add a "Pipelines" category, filled with the list of templates to create pipelines from the menu
categories["Pipelines"] = MeshroomApp.pipelineTemplateNames;
categories["Pipelines"] = MeshroomApp.pipelineTemplateNames
return categories
}
@ -298,16 +282,16 @@ Item {
case Qt.Key_Return:
case Qt.Key_Enter:
// create node on validation (Enter/Return keys)
newNodeMenu.createNode(modelData);
event.accepted = true;
break;
newNodeMenu.createNode(modelData)
event.accepted = true
break
case Qt.Key_Up:
case Qt.Key_Down:
case Qt.Key_Left:
case Qt.Key_Right:
break; // ignore if arrow key was pressed to let the menu be controlled
break // ignore if arrow key was pressed to let the menu be controlled
default:
searchBar.forceActiveFocus();
searchBar.forceActiveFocus()
}
}
// Create node on mouse click
@ -409,12 +393,10 @@ Item {
onPressed: {
const canEdit = !edge.dst.node.locked
if(event.button === Qt.RightButton)
{
if (event.button === Qt.RightButton) {
if (canEdit && (event.modifiers & Qt.AltModifier)) {
uigraph.removeEdge(edge)
}
else {
} else {
edgeMenu.currentEdge = edge
edgeMenu.popup()
}
@ -478,8 +460,8 @@ Item {
ToolTip.text: "Copy selection to the clipboard and immediately paste it"
ToolTip.visible: hovered
onTriggered: {
copyNodes();
pasteNodes();
copyNodes()
pasteNodes()
}
}
MenuItem {
@ -489,11 +471,14 @@ Item {
MaterialToolButton {
id: duplicateFollowingButton
height: parent.height
anchors { right: parent.right; rightMargin: parent.padding }
anchors {
right: parent.right
rightMargin: parent.padding
}
text: MaterialIcons.fast_forward
onClicked: {
duplicateNode(true);
nodeMenu.close();
duplicateNode(true)
nodeMenu.close()
}
}
}
@ -504,11 +489,14 @@ Item {
MaterialToolButton {
id: removeFollowingButton
height: parent.height
anchors { right: parent.right; rightMargin: parent.padding }
anchors {
right: parent.right
rightMargin: parent.padding
}
text: MaterialIcons.fast_forward
onClicked: {
uigraph.removeNodesFrom(uigraph.selectedNodes);
nodeMenu.close();
uigraph.removeNodesFrom(uigraph.selectedNodes)
nodeMenu.close()
}
}
}
@ -530,21 +518,24 @@ Item {
}
function showConfirmationDialog(deleteFollowing) {
uigraph.forceNodesStatusUpdate();
uigraph.forceNodesStatusUpdate()
var obj = deleteDataDialog.createObject(root,
{
"node": nodeMenu.currentNode,
"deleteFollowing": deleteFollowing
});
})
obj.open()
nodeMenu.close();
nodeMenu.close()
}
onTriggered: showConfirmationDialog(false)
MaterialToolButton {
id: deleteFollowingButton
anchors { right: parent.right; rightMargin: parent.padding }
anchors {
right: parent.right
rightMargin: parent.padding
}
height: parent.height
text: MaterialIcons.fast_forward
onClicked: parent.showConfirmationDialog(true)
@ -567,9 +558,9 @@ Item {
onAccepted: {
if (deleteFollowing)
uigraph.clearDataFrom(uigraph.selectedNodes);
uigraph.clearDataFrom(uigraph.selectedNodes)
else
uigraph.clearData(uigraph.selectedNodes);
uigraph.clearData(uigraph.selectedNodes)
}
onClosed: destroy()
}
@ -796,10 +787,10 @@ Item {
padding: 0
enabled: graphSearchBar.text !== ""
onClicked: {
navigation.currentIndex--;
navigation.currentIndex--
if (navigation.currentIndex === -1)
navigation.currentIndex = filteredNodes.count - 1;
navigation.nextItem();
navigation.currentIndex = filteredNodes.count - 1
navigation.nextItem()
}
}
@ -808,10 +799,10 @@ Item {
padding: 0
enabled: graphSearchBar.text !== ""
onClicked: {
navigation.currentIndex++;
navigation.currentIndex++
if (navigation.currentIndex === filteredNodes.count)
navigation.currentIndex = 0;
navigation.nextItem();
navigation.currentIndex = 0
navigation.nextItem()
}
}
@ -839,8 +830,7 @@ Item {
}
}
function nextItem()
{
function nextItem() {
// compute bounding box
var node = nodeRepeater.itemAt(filteredNodes.itemAt(navigation.currentIndex).index_)
var bbox = Qt.rect(node.x, node.y, node.width, node.height)
@ -852,17 +842,14 @@ Item {
}
}
function registerAttributePin(attribute, pin)
{
function registerAttributePin(attribute, pin) {
root._attributeToDelegate[attribute] = pin
}
function unregisterAttributePin(attribute, pin)
{
function unregisterAttributePin(attribute, pin) {
delete root._attributeToDelegate[attribute]
}
function boundingBox()
{
function boundingBox() {
var first = nodeRepeater.itemAt(0)
var bbox = Qt.rect(first.x, first.y, first.x + first.width, first.y + first.height)
for (var i = 0; i < root.graph.nodes.count; ++i) {
@ -887,5 +874,4 @@ Item {
draggable.x = bbox.x * draggable.scale * -1 + (root.width - bbox.width * draggable.scale) * 0.5
draggable.y = bbox.y * draggable.scale * -1 + (root.height - bbox.height * draggable.scale) * 0.5
}
}

View file

@ -138,9 +138,8 @@ Item {
onEntered: root.entered()
onExited: root.exited()
drag.onActiveChanged: {
if(!drag.active)
{
root.moved(Qt.point(root.x, root.y));
if (!drag.active) {
root.moved(Qt.point(root.x, root.y))
}
}
@ -244,15 +243,23 @@ Item {
palette.text: Colors.sysPalette.text
ToolTip.text: toolTipText
onPressed: { offsetReleased.running = false; toolTipText = visible ? generateDuplicateList() : "" }
onReleased: { toolTipText = "" ; offsetReleased.running = true }
onPressed: {
offsetReleased.running = false
toolTipText = visible ? generateDuplicateList() : ""
}
onReleased: {
toolTipText = ""
offsetReleased.running = true
}
onCanceled: released()
// Used for a better user experience with the button
// Avoid to change the text too quickly
Timer {
id: offsetReleased
interval: 750; running: false; repeat: false
interval: 750
running: false
repeat: false
onTriggered: parent.toolTipText = visible ? parent.baseText : ""
}
}
@ -521,4 +528,3 @@ Item {
}
}
}

View file

@ -72,8 +72,7 @@ Panel {
hoverEnabled: true
}
function getLongestChunkTime(chunks)
{
function getLongestChunkTime(chunks) {
if (chunks.count <= 1)
return 0

View file

@ -48,10 +48,10 @@ FocusScope {
function readSourceFile() {
// make sure we are trying to load a statistics file
if (!Filepath.urlToString(source).endsWith("status"))
return;
return
var xhr = new XMLHttpRequest;
xhr.open("GET", source);
var xhr = new XMLHttpRequest
xhr.open("GET", source)
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
@ -59,37 +59,32 @@ FocusScope {
if (lastModified === undefined || lastModified !== xhr.getResponseHeader('Last-Modified')) {
lastModified = xhr.getResponseHeader('Last-Modified')
try {
var jsonObject = JSON.parse(xhr.responseText);
var jsonObject = JSON.parse(xhr.responseText)
var entries = [];
var entries = []
// prepare data to populate the ListModel from the input json object
for(var key in jsonObject)
{
var entry = {};
entry["key"] = key;
entry["value"] = String(jsonObject[key]);
entries.push(entry);
for (var key in jsonObject) {
var entry = {}
entry["key"] = key
entry["value"] = String(jsonObject[key])
entries.push(entry)
}
// reset the model with prepared data (limit to one update event)
statusListModel.clear();
statusListModel.append(entries);
}
catch(exc)
{
statusListModel.clear()
statusListModel.append(entries)
} catch(exc) {
// console.warn("StatusListModel: failed to read file")
lastModified = undefined;
statusListModel.clear();
lastModified = undefined
statusListModel.clear()
}
}
}
else
{
} else {
// console.warn("StatusListModel: invalid file")
lastModified = undefined;
statusListModel.clear();
lastModified = undefined
statusListModel.clear()
}
};
xhr.send();
}
xhr.send()
}
}

View file

@ -80,9 +80,9 @@ Item {
function getPropertyWithDefault(prop, name, defaultValue) {
if (prop.hasOwnProperty(name)) {
return prop[name];
return prop[name]
}
return defaultValue;
return defaultValue
}
Timer {
@ -95,32 +95,29 @@ Item {
function readSourceFile() {
// make sure we are trying to load a statistics file
if (!Filepath.urlToString(source).endsWith("statistics"))
return;
return
var xhr = new XMLHttpRequest;
xhr.open("GET", source);
var xhr = new XMLHttpRequest
xhr.open("GET", source)
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {
if (sourceModified === undefined || sourceModified < xhr.getResponseHeader('Last-Modified')) {
try {
root.jsonObject = JSON.parse(xhr.responseText);
}
catch(exc)
{
root.jsonObject = JSON.parse(xhr.responseText)
} catch(exc) {
console.warning("Failed to parse statistics file: " + source)
root.jsonObject = {};
return;
root.jsonObject = {}
return
}
resetCharts();
resetCharts()
sourceModified = xhr.getResponseHeader('Last-Modified')
root.createCharts();
reloadTimer.restart();
root.createCharts()
reloadTimer.restart()
}
}
};
xhr.send();
}
xhr.send()
}
function resetCharts() {
@ -171,8 +168,8 @@ Item {
lineSerie.append(0, categories[j][0])
lineSerie.append(root.deltaTime, categories[j][0])
} else {
var displayLength = Math.min(maxDisplayLength, categories[j].length);
var step = categories[j].length / displayLength;
var displayLength = Math.min(maxDisplayLength, categories[j].length)
var step = categories[j].length / displayLength
for (var kk = 0; kk < displayLength; kk += step) {
var k = Math.floor(kk * step)
lineSerie.append(k * root.deltaTime, categories[j][k])
@ -184,15 +181,15 @@ Item {
var averageLine = cpuChart.createSeries(ChartView.SeriesTypeLine, "AVERAGE", valueCpuX, valueCpuY)
var average = []
var displayLengthA = Math.min(maxDisplayLength, categories[0].length);
var stepA = categories[0].length / displayLengthA;
var displayLengthA = Math.min(maxDisplayLength, categories[0].length)
var stepA = categories[0].length / displayLengthA
for (var l = 0; l < displayLengthA; l += step) {
average.push(0)
}
for (var m = 0; m < categories.length; m++) {
var displayLengthB = Math.min(maxDisplayLength, categories[m].length);
var stepB = categories[0].length / displayLengthB;
var displayLengthB = Math.min(maxDisplayLength, categories[m].length)
var stepB = categories[0].length / displayLengthB
for (var nn = 0; nn < displayLengthB; nn++) {
var n = Math.floor(nn * stepB)
average[nn] += categories[m][n]
@ -201,7 +198,6 @@ Item {
for (var q = 0; q < average.length; q++) {
average[q] = average[q] / (categories.length)
averageLine.append(q * root.deltaTime * stepA, average[q])
}
@ -210,9 +206,9 @@ Item {
function hideOtherCpu(index) {
for (var i = 0; i < cpuChart.count; i++) {
cpuChart.series(i).visible = false;
cpuChart.series(i).visible = false
}
cpuChart.series(index).visible = true;
cpuChart.series(index).visible = true
}
@ -226,8 +222,7 @@ Item {
root.ramTotal = getPropertyWithDefault(jsonObject.computer, 'ramTotal', -1)
root.ramLabel = "RAM: "
if(root.ramTotal <= 0)
{
if (root.ramTotal <= 0) {
var maxRamPeak = 0
for (var i = 0; i < ram.length; i++) {
maxRamPeak = Math.max(maxRamPeak, ram[i])
@ -240,17 +235,17 @@ Item {
if (ram.length === 1) {
// Create 2 entries if we have only one input value to create a segment that can be display
ramSerie.append(0, ram[0]);
ramSerie.append(root.deltaTime, ram[0]);
ramSerie.append(0, ram[0])
ramSerie.append(root.deltaTime, ram[0])
} else {
var displayLength = Math.min(maxDisplayLength, ram.length);
var step = ram.length / displayLength;
var displayLength = Math.min(maxDisplayLength, ram.length)
var step = ram.length / displayLength
for(var ii = 0; ii < displayLength; ii++) {
var i = Math.floor(ii*step);
ramSerie.append(i * root.deltaTime, ram[i]);
var i = Math.floor(ii * step)
ramSerie.append(i * root.deltaTime, ram[i])
}
}
ramSerie.color = colors[10];
ramSerie.color = colors[10]
}
/**************************
@ -269,7 +264,7 @@ Item {
var gpuUsedMemorySerie = gpuChart.createSeries(ChartView.SeriesTypeLine, "Memory", valueGpuX, valueGpuY)
var gpuTemperatureSerie = gpuChart.createSeries(ChartView.SeriesTypeLine, "Temperature", valueGpuX, valueGpuY)
var gpuMemoryRatio = root.gpuTotalMemory > 0 ? (100 / root.gpuTotalMemory) : 1;
var gpuMemoryRatio = root.gpuTotalMemory > 0 ? (100 / root.gpuTotalMemory) : 1
if (gpuUsedMemory.length === 1) {
gpuUsedSerie.append(0, gpuUsed[0])
@ -282,8 +277,8 @@ Item {
gpuTemperatureSerie.append(1 * root.deltaTime, gpuTemperature[0])
root.gpuMaxAxis = Math.max(gpuMaxAxis, gpuTemperature[0])
} else {
var displayLength = Math.min(maxDisplayLength, gpuUsedMemory.length);
var step = gpuUsedMemory.length / displayLength;
var displayLength = Math.min(maxDisplayLength, gpuUsedMemory.length)
var step = gpuUsedMemory.length / displayLength
for (var ii = 0; ii < displayLength; ii += step) {
var i = Math.floor(ii*step)
gpuUsedSerie.append(i * root.deltaTime, gpuUsed[i])
@ -356,7 +351,6 @@ Item {
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
ChartViewCheckBox {
id: allCPU
text: "ALL"
@ -365,9 +359,8 @@ Item {
leftPadding: 0
onClicked: {
var _checked = checked;
for(var i = 0; i < cpuChart.count; ++i)
{
cpuChart.series(i).visible = _checked;
for (var i = 0; i < cpuChart.count; ++i) {
cpuChart.series(i).visible = _checked
}
}
}
@ -378,7 +371,6 @@ Item {
Layout.fillHeight: true
chartView: cpuChart
}
}
}
@ -425,7 +417,6 @@ Item {
shadesBorderColor: textColor
labelsColor: textColor
}
}
}
@ -491,7 +482,6 @@ Item {
ColumnLayout {
InteractiveChartView {
id: gpuChart
@ -537,8 +527,6 @@ Item {
}
}
}
}
}
}

View file

@ -12,21 +12,16 @@ var statusColorsExternOverrides = {
"SUBMITTED": "#2196F3"
}
function getChunkColor(chunk, overrides)
{
if(overrides && chunk.statusName in overrides)
{
function getChunkColor(chunk, overrides) {
if (overrides && chunk.statusName in overrides) {
return overrides[chunk.statusName]
}
else if(chunk.execModeName === "EXTERN"
&& chunk.statusName in statusColorsExternOverrides)
{
} else if(chunk.execModeName === "EXTERN"
&& chunk.statusName in statusColorsExternOverrides) {
return statusColorsExternOverrides[chunk.statusName]
}
else if(chunk.statusName in statusColors)
{
} else if(chunk.statusName in statusColors) {
return statusColors[chunk.statusName]
}
console.warn("Unknown status : " + chunk.status)
return "magenta"
}