mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
[GraphEditor] Clean-up: Harmonize syntax across all files
This commit is contained in:
parent
2bdf061d2e
commit
e9d80611c7
15 changed files with 341 additions and 375 deletions
|
@ -31,7 +31,7 @@ ListView {
|
|||
&& (object.isDefault && GraphEditorSettings.showDefaultAttributes || !object.isDefault && GraphEditorSettings.showModifiedAttributes)
|
||||
&& (object.isOutput && GraphEditorSettings.showOutputAttributes || !object.isOutput && GraphEditorSettings.showInputAttributes)
|
||||
&& (object.isLinkNested && GraphEditorSettings.showLinkAttributes || !object.isLink && GraphEditorSettings.showNotLinkAttributes))
|
||||
) && object.matchText(filterText)
|
||||
) && object.matchText(filterText)
|
||||
visible: active
|
||||
|
||||
sourceComponent: AttributeItemDelegate {
|
||||
|
|
|
@ -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)
|
||||
if (!editable)
|
||||
return
|
||||
switch(attribute.type)
|
||||
{
|
||||
case "IntParam":
|
||||
case "FloatParam":
|
||||
_reconstruction.setAttribute(root.attribute, Number(value))
|
||||
updateAttributeLabel()
|
||||
break;
|
||||
case "File":
|
||||
_reconstruction.setAttribute(root.attribute, value)
|
||||
break;
|
||||
default:
|
||||
_reconstruction.setAttribute(root.attribute, value.trim())
|
||||
updateAttributeLabel()
|
||||
break;
|
||||
switch (attribute.type) {
|
||||
case "IntParam":
|
||||
case "FloatParam":
|
||||
_reconstruction.setAttribute(root.attribute, Number(value))
|
||||
updateAttributeLabel()
|
||||
break
|
||||
case "File":
|
||||
_reconstruction.setAttribute(root.attribute, value)
|
||||
break
|
||||
default:
|
||||
_reconstruction.setAttribute(root.attribute, value.trim())
|
||||
updateAttributeLabel()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,24 +172,28 @@ RowLayout {
|
|||
Layout.fillWidth: true
|
||||
|
||||
sourceComponent: {
|
||||
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 "StringParam":
|
||||
if (attribute.desc.semantic === 'multiline')
|
||||
return textArea_component
|
||||
return textField_component
|
||||
case "ColorParam":
|
||||
return color_component
|
||||
default: return textField_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 "StringParam":
|
||||
if (attribute.desc.semantic === 'multiline')
|
||||
return textArea_component
|
||||
return textField_component
|
||||
case "ColorParam":
|
||||
return color_component
|
||||
default:
|
||||
return textField_component
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,16 +209,16 @@ RowLayout {
|
|||
root.forceActiveFocus()
|
||||
}
|
||||
Component.onDestruction: {
|
||||
if(activeFocus)
|
||||
if (activeFocus)
|
||||
setTextFieldAttribute(text)
|
||||
}
|
||||
DropArea {
|
||||
enabled: root.editable
|
||||
anchors.fill: parent
|
||||
onDropped: {
|
||||
if(drop.hasUrls)
|
||||
if (drop.hasUrls)
|
||||
setTextFieldAttribute(Filepath.urlToString(drop.urls[0]))
|
||||
else if(drop.hasText && drop.text != '')
|
||||
else if (drop.hasText && drop.text != '')
|
||||
setTextFieldAttribute(drop.text)
|
||||
}
|
||||
}
|
||||
|
@ -282,7 +285,7 @@ RowLayout {
|
|||
checked: node && node.color === "" ? false : true
|
||||
text: "Custom Color"
|
||||
onClicked: {
|
||||
if(checked) {
|
||||
if (checked) {
|
||||
_reconstruction.setAttribute(attribute, "#0000FF")
|
||||
} else {
|
||||
_reconstruction.setAttribute(attribute, "")
|
||||
|
@ -300,7 +303,7 @@ RowLayout {
|
|||
onEditingFinished: setTextFieldAttribute(text)
|
||||
onAccepted: setTextFieldAttribute(text)
|
||||
Component.onDestruction: {
|
||||
if(activeFocus)
|
||||
if (activeFocus)
|
||||
setTextFieldAttribute(text)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -407,7 +413,7 @@ RowLayout {
|
|||
ensureVisible(0)
|
||||
}
|
||||
Component.onDestruction: {
|
||||
if(activeFocus)
|
||||
if (activeFocus)
|
||||
setTextFieldAttribute(text)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
|
@ -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
|
||||
|
@ -491,7 +497,7 @@ RowLayout {
|
|||
|
||||
ScrollBar.vertical: ScrollBar { id: sb }
|
||||
|
||||
delegate: Loader{
|
||||
delegate: Loader {
|
||||
active: !objectsHideable
|
||||
|| ((object.isDefault && GraphEditorSettings.showDefaultAttributes || !object.isDefault && GraphEditorSettings.showModifiedAttributes)
|
||||
&& (object.isLinkNested && GraphEditorSettings.showLinkAttributes || !object.isLinkNested && GraphEditorSettings.showNotLinkAttributes))
|
||||
|
@ -505,14 +511,15 @@ 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
|
||||
obj.label.text = index
|
||||
obj.label.horizontalAlignment = Text.AlignHCenter
|
||||
obj.label.verticalAlignment = Text.AlignVCenter
|
||||
obj.doubleClicked.connect(function(attr) {root.doubleClicked(attr)})
|
||||
obj.doubleClicked.connect(function(attr) { root.doubleClicked(attr) })
|
||||
}
|
||||
ToolButton {
|
||||
enabled: root.editable
|
||||
|
@ -537,11 +544,12 @@ RowLayout {
|
|||
Component.onCompleted: {
|
||||
var cpt = Qt.createComponent("AttributeEditor.qml");
|
||||
var obj = cpt.createObject(groupItem,
|
||||
{'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 }),
|
||||
'filterText': Qt.binding(function() { return root.filterText }),
|
||||
{
|
||||
'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 }),
|
||||
'filterText': Qt.binding(function() { return root.filterText }),
|
||||
})
|
||||
obj.Layout.fillWidth = true;
|
||||
obj.attributeDoubleClicked.connect(function(attr) {root.doubleClicked(attr)})
|
||||
|
@ -565,7 +573,7 @@ RowLayout {
|
|||
onEditingFinished: setTextFieldAttribute(text)
|
||||
onAccepted: setTextFieldAttribute(text)
|
||||
Component.onDestruction: {
|
||||
if(activeFocus)
|
||||
if (activeFocus)
|
||||
setTextFieldAttribute(text)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -587,7 +595,7 @@ RowLayout {
|
|||
stepSize: 0.01
|
||||
snapMode: Slider.SnapAlways
|
||||
onPressedChanged: {
|
||||
if(!pressed)
|
||||
if (!pressed)
|
||||
_reconstruction.setAttribute(attribute, formattedValue)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ RowLayout {
|
|||
property bool displayOutputPinForInput: true
|
||||
|
||||
// position of the anchor for attaching and edge to this attribute pin
|
||||
readonly property point inputAnchorPos: Qt.point(inputAnchor.x + inputAnchor.width/2,
|
||||
inputAnchor.y + inputAnchor.height/2)
|
||||
readonly property point inputAnchorPos: Qt.point(inputAnchor.x + inputAnchor.width / 2,
|
||||
inputAnchor.y + inputAnchor.height / 2)
|
||||
|
||||
readonly property point outputAnchorPos: Qt.point(outputAnchor.x + outputAnchor.width/2,
|
||||
outputAnchor.y + outputAnchor.height/2)
|
||||
readonly property point outputAnchorPos: Qt.point(outputAnchor.x + outputAnchor.width / 2,
|
||||
outputAnchor.y + outputAnchor.height / 2)
|
||||
|
||||
readonly property bool isList: attribute && attribute.type === "ListAttribute"
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ RowLayout {
|
|||
|
||||
width: 8
|
||||
height: width
|
||||
radius: isList ? 0 : width/2
|
||||
radius: isList ? 0 : width / 2
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
border.color: Colors.sysPalette.mid
|
||||
border.color: Colors.sysPalette.mid
|
||||
color: Colors.sysPalette.base
|
||||
|
||||
Rectangle {
|
||||
|
@ -64,7 +64,7 @@ RowLayout {
|
|||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
color: {
|
||||
if(inputConnectMA.containsMouse || inputConnectMA.drag.active || (inputDropArea.containsDrag && inputDropArea.acceptableDrop))
|
||||
if (inputConnectMA.containsMouse || inputConnectMA.drag.active || (inputDropArea.containsDrag && inputDropArea.acceptableDrop))
|
||||
return Colors.sysPalette.highlight
|
||||
return Colors.sysPalette.text
|
||||
}
|
||||
|
@ -84,19 +84,17 @@ RowLayout {
|
|||
keys: [inputDragTarget.objectName]
|
||||
onEntered: {
|
||||
// Check if attributes are compatible to create a valid connection
|
||||
if( root.readOnly // cannot connect on a read-only attribute
|
||||
|| drag.source.objectName != inputDragTarget.objectName // not an edge connector
|
||||
|| drag.source.baseType !== inputDragTarget.baseType // not the same base type
|
||||
|| drag.source.nodeItem === inputDragTarget.nodeItem // connection between attributes of the same node
|
||||
|| (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)
|
||||
)
|
||||
{
|
||||
if (root.readOnly // cannot connect on a read-only attribute
|
||||
|| drag.source.objectName != inputDragTarget.objectName // not an edge connector
|
||||
|| drag.source.baseType !== inputDragTarget.baseType // not the same base type
|
||||
|| drag.source.nodeItem === inputDragTarget.nodeItem // connection between attributes of the same node
|
||||
|| (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
|
||||
|
@ -159,8 +157,8 @@ RowLayout {
|
|||
Edge {
|
||||
id: inputConnectEdge
|
||||
visible: false
|
||||
point1x: inputDragTarget.x + inputDragTarget.width/2
|
||||
point1y: inputDragTarget.y + inputDragTarget.height/2
|
||||
point1x: inputDragTarget.x + inputDragTarget.width / 2
|
||||
point1y: inputDragTarget.y + inputDragTarget.height / 2
|
||||
point2x: parent.width / 2
|
||||
point2y: parent.width / 2
|
||||
color: palette.highlight
|
||||
|
@ -214,7 +212,7 @@ RowLayout {
|
|||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
color: {
|
||||
if(outputConnectMA.containsMouse || outputConnectMA.drag.active || (outputDropArea.containsDrag && outputDropArea.acceptableDrop))
|
||||
if (outputConnectMA.containsMouse || outputConnectMA.drag.active || (outputDropArea.containsDrag && outputDropArea.acceptableDrop))
|
||||
return Colors.sysPalette.highlight
|
||||
return Colors.sysPalette.text
|
||||
}
|
||||
|
@ -234,18 +232,16 @@ RowLayout {
|
|||
keys: [outputDragTarget.objectName]
|
||||
onEntered: {
|
||||
// Check if attributes are compatible to create a valid connection
|
||||
if( drag.source.objectName != outputDragTarget.objectName // not an edge connector
|
||||
|| drag.source.baseType !== outputDragTarget.baseType // not the same base type
|
||||
|| drag.source.nodeItem === outputDragTarget.nodeItem // connection between attributes of the same node
|
||||
|| (!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
|
||||
)
|
||||
{
|
||||
if (drag.source.objectName != outputDragTarget.objectName // not an edge connector
|
||||
|| drag.source.baseType !== outputDragTarget.baseType // not the same base type
|
||||
|| drag.source.nodeItem === outputDragTarget.nodeItem // connection between attributes of the same node
|
||||
|| (!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
|
||||
|
@ -277,8 +273,8 @@ RowLayout {
|
|||
height: parent.height
|
||||
Drag.keys: [outputDragTarget.objectName]
|
||||
Drag.active: outputConnectMA.drag.active
|
||||
Drag.hotSpot.x: width*0.5
|
||||
Drag.hotSpot.y: height*0.5
|
||||
Drag.hotSpot.x: width * 0.5
|
||||
Drag.hotSpot.y: height * 0.5
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
@ -304,8 +300,8 @@ RowLayout {
|
|||
visible: false
|
||||
point1x: parent.width / 2
|
||||
point1y: parent.width / 2
|
||||
point2x: outputDragTarget.x + outputDragTarget.width/2
|
||||
point2y: outputDragTarget.y + outputDragTarget.height/2
|
||||
point2x: outputDragTarget.x + outputDragTarget.width / 2
|
||||
point2y: outputDragTarget.y + outputDragTarget.height / 2
|
||||
color: palette.highlight
|
||||
thickness: outputDragTarget.dropAccepted ? 2 : 1
|
||||
}
|
||||
|
@ -354,8 +350,8 @@ RowLayout {
|
|||
script: {
|
||||
// Add the right offset if the initial click is not exactly at the center of the connection circle.
|
||||
var pos = inputDragTarget.mapFromItem(inputConnectMA, inputConnectMA.mouseX, inputConnectMA.mouseY);
|
||||
inputDragTarget.x = pos.x - inputDragTarget.width/2;
|
||||
inputDragTarget.y = pos.y - inputDragTarget.height/2;
|
||||
inputDragTarget.x = pos.x - inputDragTarget.width / 2;
|
||||
inputDragTarget.y = pos.y - inputDragTarget.height / 2;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -374,11 +370,10 @@ RowLayout {
|
|||
StateChangeScript {
|
||||
script: {
|
||||
var pos = outputDragTarget.mapFromItem(outputConnectMA, outputConnectMA.mouseX, outputConnectMA.mouseY);
|
||||
outputDragTarget.x = pos.x - outputDragTarget.width/2;
|
||||
outputDragTarget.y = pos.y - outputDragTarget.height/2;
|
||||
outputDragTarget.x = pos.x - outputDragTarget.width / 2;
|
||||
outputDragTarget.y = pos.y - outputDragTarget.height / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ ColumnLayout {
|
|||
|
||||
onChunksChanged: {
|
||||
// When the list changes, ensure the current index is in the new range
|
||||
if(currentIndex >= chunks.count)
|
||||
if (currentIndex >= chunks.count)
|
||||
currentIndex = chunks.count-1
|
||||
}
|
||||
|
||||
|
@ -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 })
|
||||
|
@ -67,7 +66,7 @@ ColumnLayout {
|
|||
}
|
||||
highlight: Component {
|
||||
Rectangle {
|
||||
visible: true // !root.chunksSummary
|
||||
visible: true // !root.chunksSummary
|
||||
color: activePalette.highlight
|
||||
opacity: 0.3
|
||||
z: 2
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,8 @@ MessageDialog {
|
|||
// the number of CompatibilityNodes that can be upgraded
|
||||
readonly property int upgradableCount: {
|
||||
var count = 0
|
||||
for(var i=0; i<issueCount; ++i)
|
||||
{
|
||||
if(nodesModel.at(i).canUpgrade)
|
||||
for (var i = 0; i < issueCount; ++i) {
|
||||
if (nodesModel.at(i).canUpgrade)
|
||||
count++;
|
||||
}
|
||||
return 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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ Shape {
|
|||
strokeWidth: 1
|
||||
// final visual width of this path (never below 1)
|
||||
readonly property real visualWidth: Math.max(strokeWidth, 1)
|
||||
dashPattern: [6/visualWidth, 4/visualWidth]
|
||||
dashPattern: [6 / visualWidth, 4 / visualWidth]
|
||||
capStyle: ShapePath.RoundCap
|
||||
|
||||
PathCubic {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,19 +45,16 @@ Item {
|
|||
SystemPalette { id: activePalette }
|
||||
|
||||
/// Get node delegate for the given node object
|
||||
function nodeDelegate(node)
|
||||
{
|
||||
for(var i=0; i<nodeRepeater.count; ++i)
|
||||
{
|
||||
if(nodeRepeater.itemAt(i).node === node)
|
||||
function nodeDelegate(node) {
|
||||
for(var i = 0; i < nodeRepeater.count; ++i) {
|
||||
if (nodeRepeater.itemAt(i).node === node)
|
||||
return nodeRepeater.itemAt(i)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/// 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,14 +152,14 @@ Item {
|
|||
cursorShape: drag.target == draggable ? Qt.ClosedHandCursor : Qt.ArrowCursor
|
||||
|
||||
onWheel: {
|
||||
var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1/factor
|
||||
var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1 / factor
|
||||
var scale = draggable.scale * zoomFactor
|
||||
scale = Math.min(Math.max(minZoom, scale), maxZoom)
|
||||
if(draggable.scale == scale)
|
||||
if (draggable.scale == scale)
|
||||
return
|
||||
var point = mapToItem(draggable, wheel.x, wheel.y)
|
||||
draggable.x += (1-zoomFactor) * point.x * draggable.scale
|
||||
draggable.y += (1-zoomFactor) * point.y * draggable.scale
|
||||
draggable.x += (1 - zoomFactor) * point.x * draggable.scale
|
||||
draggable.y += (1 - zoomFactor) * point.y * draggable.scale
|
||||
draggable.scale = scale
|
||||
workspaceMoved()
|
||||
}
|
||||
|
@ -197,16 +185,15 @@ Item {
|
|||
workspaceClicked()
|
||||
}
|
||||
onPositionChanged: {
|
||||
if(drag.active)
|
||||
if (drag.active)
|
||||
workspaceMoved()
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -287,27 +271,27 @@ Item {
|
|||
// Hide items that does not match the filter text
|
||||
visible: modelData.toLowerCase().indexOf(searchBar.text.toLowerCase()) > -1
|
||||
// Reset menu currentIndex if highlighted items gets filtered out
|
||||
onVisibleChanged: if(highlighted) newNodeMenu.currentIndex = 0
|
||||
onVisibleChanged: if (highlighted) newNodeMenu.currentIndex = 0
|
||||
text: modelData
|
||||
// Forward key events to the search bar to continue typing seamlessly
|
||||
// even if this delegate took the activeFocus due to mouse hovering
|
||||
Keys.forwardTo: [searchBar.textField]
|
||||
Keys.onPressed: {
|
||||
event.accepted = false;
|
||||
switch(event.key) {
|
||||
switch (event.key) {
|
||||
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
|
||||
|
@ -339,7 +323,7 @@ Item {
|
|||
// Dynamically add the menu categories
|
||||
Instantiator {
|
||||
model: !(searchBar.text !== "") ? Object.keys(newNodeMenu.parseCategories()).sort() : undefined
|
||||
onObjectAdded: newNodeMenu.insertMenu(index+1, object ) // add sub-menu under the search bar
|
||||
onObjectAdded: newNodeMenu.insertMenu(index + 1, object ) // add sub-menu under the search bar
|
||||
onObjectRemoved: newNodeMenu.removeMenu(object)
|
||||
|
||||
delegate: Menu {
|
||||
|
@ -409,12 +393,10 @@ Item {
|
|||
onPressed: {
|
||||
const canEdit = !edge.dst.node.locked
|
||||
|
||||
if(event.button === Qt.RightButton)
|
||||
{
|
||||
if(canEdit && (event.modifiers & Qt.AltModifier)) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,35 +504,38 @@ Item {
|
|||
MenuItem {
|
||||
text: "Delete Data" + (deleteFollowingButton.hovered ? " From Here" : "" ) + "..."
|
||||
enabled: {
|
||||
if(!nodeMenu.currentNode)
|
||||
if (!nodeMenu.currentNode)
|
||||
return false
|
||||
// Check if the current node is locked (needed because it does not belong to its own duplicates list)
|
||||
if(nodeMenu.currentNode.locked)
|
||||
if (nodeMenu.currentNode.locked)
|
||||
return false
|
||||
// Check if at least one of the duplicate nodes is locked
|
||||
for(let i = 0; i < nodeMenu.currentNode.duplicates.count; ++i) {
|
||||
if(nodeMenu.currentNode.duplicates.at(i).locked)
|
||||
for (let i = 0; i < nodeMenu.currentNode.duplicates.count; ++i) {
|
||||
if (nodeMenu.currentNode.duplicates.at(i).locked)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -566,10 +557,10 @@ Item {
|
|||
standardButtons: Dialog.Yes | Dialog.Cancel
|
||||
|
||||
onAccepted: {
|
||||
if(deleteFollowing)
|
||||
uigraph.clearDataFrom(uigraph.selectedNodes);
|
||||
if (deleteFollowing)
|
||||
uigraph.clearDataFrom(uigraph.selectedNodes)
|
||||
else
|
||||
uigraph.clearData(uigraph.selectedNodes);
|
||||
uigraph.clearData(uigraph.selectedNodes)
|
||||
}
|
||||
onClosed: destroy()
|
||||
}
|
||||
|
@ -611,7 +602,7 @@ Item {
|
|||
return
|
||||
}
|
||||
} else if (mouse.modifiers & Qt.AltModifier) {
|
||||
if (!(mouse.modifiers & Qt.ControlModifier)){
|
||||
if (!(mouse.modifiers & Qt.ControlModifier)) {
|
||||
uigraph.clearNodeSelection()
|
||||
}
|
||||
uigraph.selectFollowing(node)
|
||||
|
@ -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,38 +830,34 @@ 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)
|
||||
// rescale to fit the bounding box in the view, zoom is limited to prevent huge text
|
||||
draggable.scale = Math.min(Math.min(root.width/bbox.width, root.height/bbox.height),maxZoom)
|
||||
draggable.scale = Math.min(Math.min(root.width / bbox.width, root.height / bbox.height),maxZoom)
|
||||
// recenter
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
for (var i = 0; i < root.graph.nodes.count; ++i) {
|
||||
var item = nodeRepeater.itemAt(i)
|
||||
bbox.x = Math.min(bbox.x, item.x)
|
||||
bbox.y = Math.min(bbox.y, item.y)
|
||||
bbox.width = Math.max(bbox.width, item.x+item.width)
|
||||
bbox.height = Math.max(bbox.height, item.y+item.height)
|
||||
bbox.width = Math.max(bbox.width, item.x + item.width)
|
||||
bbox.height = Math.max(bbox.height, item.y + item.height)
|
||||
}
|
||||
bbox.width -= bbox.x
|
||||
bbox.height -= bbox.y
|
||||
|
@ -882,10 +869,9 @@ Item {
|
|||
// compute bounding box
|
||||
var bbox = boundingBox()
|
||||
// rescale to fit the bounding box in the view, zoom is limited to prevent huge text
|
||||
draggable.scale = Math.min(Math.min(root.width/bbox.width, root.height/bbox.height),maxZoom)
|
||||
draggable.scale = Math.min(Math.min(root.width / bbox.width, root.height / bbox.height), maxZoom)
|
||||
// recenter
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -107,13 +107,13 @@ Item {
|
|||
// Used to generate list of node's label sharing the same uid
|
||||
function generateDuplicateList() {
|
||||
let str = "<b>Shares internal folder (data) with:</b>"
|
||||
for(let i = 0; i < node.duplicates.count; ++i) {
|
||||
if(i % 5 === 0)
|
||||
for (let i = 0; i < node.duplicates.count; ++i) {
|
||||
if (i % 5 === 0)
|
||||
str += "<br>"
|
||||
|
||||
const currentNode = node.duplicates.at(i)
|
||||
|
||||
if(i === node.duplicates.count - 1) {
|
||||
if (i === node.duplicates.count - 1) {
|
||||
str += currentNode.nameToLabel(currentNode.name)
|
||||
return str
|
||||
}
|
||||
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ ListView {
|
|||
id: chunkDelegate
|
||||
height: root.chunkHeight
|
||||
width: root.chunkWidth
|
||||
color: Colors.getChunkColor(object, {"NONE": root.defaultColor})
|
||||
color: Colors.getChunkColor(object, { "NONE": root.defaultColor })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,7 @@ Panel {
|
|||
hoverEnabled: true
|
||||
}
|
||||
|
||||
function getLongestChunkTime(chunks)
|
||||
{
|
||||
function getLongestChunkTime(chunks) {
|
||||
if (chunks.count <= 1)
|
||||
return 0
|
||||
|
||||
|
|
|
@ -47,49 +47,44 @@ FocusScope {
|
|||
|
||||
function readSourceFile() {
|
||||
// make sure we are trying to load a statistics file
|
||||
if(!Filepath.urlToString(source).endsWith("status"))
|
||||
return;
|
||||
if (!Filepath.urlToString(source).endsWith("status"))
|
||||
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) {
|
||||
// console.warn("StatusListModel: read valid file")
|
||||
if(lastModified === undefined || lastModified !== xhr.getResponseHeader('Last-Modified')) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,10 +79,10 @@ Item {
|
|||
}
|
||||
|
||||
function getPropertyWithDefault(prop, name, defaultValue) {
|
||||
if(prop.hasOwnProperty(name)) {
|
||||
return prop[name];
|
||||
if (prop.hasOwnProperty(name)) {
|
||||
return prop[name]
|
||||
}
|
||||
return defaultValue;
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
@ -94,33 +94,30 @@ Item {
|
|||
|
||||
function readSourceFile() {
|
||||
// make sure we are trying to load a statistics file
|
||||
if(!Filepath.urlToString(source).endsWith("statistics"))
|
||||
return;
|
||||
if (!Filepath.urlToString(source).endsWith("statistics"))
|
||||
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')) {
|
||||
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() {
|
||||
|
@ -151,7 +148,7 @@ Item {
|
|||
var category
|
||||
do {
|
||||
category = jsonObject.computer.curves["cpuUsage." + categoryCount]
|
||||
if(category !== undefined) {
|
||||
if (category !== undefined) {
|
||||
categories.push(category)
|
||||
categoryCount++
|
||||
}
|
||||
|
@ -164,17 +161,17 @@ Item {
|
|||
|
||||
root.nbReads = categories[0].length-1
|
||||
|
||||
for(var j = 0; j < nbCores; j++) {
|
||||
for (var j = 0; j < nbCores; j++) {
|
||||
var lineSerie = cpuChart.createSeries(ChartView.SeriesTypeLine, "CPU" + j, valueCpuX, valueCpuY)
|
||||
|
||||
if(categories[j].length === 1) {
|
||||
if (categories[j].length === 1) {
|
||||
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;
|
||||
for(var kk = 0; kk < displayLength; kk+=step) {
|
||||
var k = Math.floor(kk*step)
|
||||
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,35 +181,34 @@ 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;
|
||||
for(var l = 0; l < displayLengthA; l+=step) {
|
||||
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;
|
||||
for(var nn = 0; nn < displayLengthB; nn++) {
|
||||
var n = Math.floor(nn*stepB)
|
||||
for (var m = 0; m < categories.length; m++) {
|
||||
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]
|
||||
}
|
||||
}
|
||||
|
||||
for(var q = 0; q < average.length; q++) {
|
||||
for (var q = 0; q < average.length; q++) {
|
||||
average[q] = average[q] / (categories.length)
|
||||
|
||||
averageLine.append(q * root.deltaTime * stepA, average[q])
|
||||
}
|
||||
|
||||
averageLine.color = colors[colors.length-1]
|
||||
averageLine.color = colors[colors.length - 1]
|
||||
}
|
||||
|
||||
function hideOtherCpu(index) {
|
||||
for(var i = 0; i < cpuChart.count; i++) {
|
||||
cpuChart.series(i).visible = false;
|
||||
for (var i = 0; i < cpuChart.count; i++) {
|
||||
cpuChart.series(i).visible = false
|
||||
}
|
||||
cpuChart.series(index).visible = true;
|
||||
cpuChart.series(index).visible = true
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,10 +222,9 @@ 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++) {
|
||||
for (var i = 0; i < ram.length; i++) {
|
||||
maxRamPeak = Math.max(maxRamPeak, ram[i])
|
||||
}
|
||||
root.ramTotal = maxRamPeak
|
||||
|
@ -238,19 +233,19 @@ Item {
|
|||
|
||||
var ramSerie = ramChart.createSeries(ChartView.SeriesTypeLine, root.ramLabel + root.ramTotal + "GB", valueRamX, valueRamY)
|
||||
|
||||
if(ram.length === 1) {
|
||||
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,9 +264,9 @@ 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) {
|
||||
if (gpuUsedMemory.length === 1) {
|
||||
gpuUsedSerie.append(0, gpuUsed[0])
|
||||
gpuUsedSerie.append(1 * root.deltaTime, gpuUsed[0])
|
||||
|
||||
|
@ -282,9 +277,9 @@ 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;
|
||||
for(var ii = 0; ii < displayLength; ii+=step) {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,7 +378,7 @@ Item {
|
|||
id: cpuChart
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width/2
|
||||
Layout.preferredHeight: width / 2
|
||||
margins.top: 0
|
||||
margins.bottom: 0
|
||||
antialiasing: true
|
||||
|
@ -425,7 +417,6 @@ Item {
|
|||
shadesBorderColor: textColor
|
||||
labelsColor: textColor
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +433,7 @@ Item {
|
|||
margins.top: 0
|
||||
margins.bottom: 0
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width/2
|
||||
Layout.preferredHeight: width / 2
|
||||
antialiasing: true
|
||||
legend.color: textColor
|
||||
legend.labelColor: textColor
|
||||
|
@ -491,7 +482,6 @@ Item {
|
|||
|
||||
ColumnLayout {
|
||||
|
||||
|
||||
InteractiveChartView {
|
||||
id: gpuChart
|
||||
|
||||
|
@ -537,8 +527,6 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -150,8 +150,8 @@ Item {
|
|||
|
||||
function getNbFinishedChunks(chunks) {
|
||||
var nbSuccess = 0
|
||||
for(var i = 0; i < chunks.count; i++) {
|
||||
if(chunks.at(i).statusName === "SUCCESS") {
|
||||
for (var i = 0; i < chunks.count; i++) {
|
||||
if (chunks.at(i).statusName === "SUCCESS") {
|
||||
nbSuccess += 1
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ Item {
|
|||
}
|
||||
|
||||
Label {
|
||||
text: index+1
|
||||
text: index + 1
|
||||
Layout.preferredWidth: nbMetrics.width + 20
|
||||
Layout.preferredHeight: parent.height
|
||||
horizontalAlignment: Label.AlignHCenter
|
||||
|
@ -253,36 +253,36 @@ Item {
|
|||
Layout.minimumWidth: progressMetrics.width + 20
|
||||
Layout.preferredHeight: parent.height
|
||||
|
||||
ListView {
|
||||
id: chunkList
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
orientation: ListView.Horizontal
|
||||
model: object.chunks
|
||||
property var node: object
|
||||
ListView {
|
||||
id: chunkList
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
orientation: ListView.Horizontal
|
||||
model: object.chunks
|
||||
property var node: object
|
||||
|
||||
spacing: 3
|
||||
spacing: 3
|
||||
|
||||
delegate: Label {
|
||||
width: (ListView.view.width / ListView.view.model.count) -3
|
||||
height: ListView.view.height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
background: Rectangle {
|
||||
color: Colors.getChunkColor(object, {"NONE": bgColor})
|
||||
radius: 3
|
||||
border.width: 2
|
||||
border.color: chunkList.node === uigraph.selectedNode ? Colors.sysPalette.text : Colors.getChunkColor(object, {"NONE": bgColor})
|
||||
delegate: Label {
|
||||
width: (ListView.view.width / ListView.view.model.count) - 3
|
||||
height: ListView.view.height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
background: Rectangle {
|
||||
color: Colors.getChunkColor(object, {"NONE": bgColor})
|
||||
radius: 3
|
||||
border.width: 2
|
||||
border.color: chunkList.node === uigraph.selectedNode ? Colors.sysPalette.text : Colors.getChunkColor(object, {"NONE": bgColor})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onPressed: {
|
||||
selectNode(chunkList.node)
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onPressed: {
|
||||
selectNode(chunkList.node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue