From 5cef8e23fa8ba6cb38dfef4399f516da4ddc55c6 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Wed, 24 May 2023 03:17:21 +0200 Subject: [PATCH] Fixing several issues with repartition + Underscores being automatically removed from the name the moment it's edited. + Fixing issue with function name change. --- .../LogarithmPlotter/ObjectLists/Editor/Dialog.qml | 1 + .../ad5001/LogarithmPlotter/Setting/TextSetting.qml | 3 ++- .../ad5001/LogarithmPlotter/js/objs/repartition.js | 12 ++++++------ .../qml/eu/ad5001/LogarithmPlotter/js/utils.js | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml index f869177..6cdc6a4 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/ObjectLists/Editor/Dialog.qml @@ -106,6 +106,7 @@ Popup.BaseDialog { value: objEditor.obj.name onChanged: function(newValue) { let newName = Utils.parseName(newValue) + console.log(newValue, newName) if(newName != '' && objEditor.obj.name != newName) { if(newName in Objects.currentObjectsByName) { invalidNameDialog.showDialog(newName) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml index 2c6ea9a..6e8ff1d 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/TextSetting.qml @@ -119,12 +119,13 @@ Item { focus: true text: control.defValue selectByMouse: true - onEditingFinished: { + onEditingFinished: function() { if(insertButton.focus || insertPopup.focus) return var value = text if(control.isInt) value = Math.max(control.min,parseInt(value).toString()=="NaN"?control.min:parseInt(value)) if(control.isDouble) value = Math.max(control.min,parseFloat(value).toString()=="NaN"?control.min:parseFloat(value)) if(value != "" && value.toString() != defValue) { + console.log(value, value.toString()) control.changed(value) defValue = value.toString() } diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js index 7a98b56..c8a30a5 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js @@ -96,14 +96,14 @@ class RepartitionFunction extends Common.ExecutableObject { draw(canvas, ctx) { var currentY = 0; var keys = Object.keys(this.probabilities).map(idx => parseInt(idx)).sort((a,b) => a-b) - if(canvas.visible(keys[0],this.probabilities[keys[0]].replace(/,/g, '.'))) { + if(canvas.isVisible(keys[0],this.probabilities[keys[0]].replace(/,/g, '.'))) { canvas.drawLine(ctx, 0, canvas.y2px(0), canvas.x2px(keys[0]), canvas.y2px(0) ) - if(canvas.visible(keys[0],0)) { + if(canvas.isVisible(keys[0],0)) { ctx.beginPath(); ctx.arc(canvas.x2px(keys[0])+4,canvas.y2px(0), 4, Math.PI / 2, 3 * Math.PI / 2); ctx.stroke(); @@ -112,26 +112,26 @@ class RepartitionFunction extends Common.ExecutableObject { for(var i = 0; i < keys.length-1; i++) { var idx = keys[i]; currentY += parseFloat(this.probabilities[idx].replace(/,/g, '.')); - if(canvas.visible(idx,currentY) || canvas.visible(keys[i+1],currentY)) { + if(canvas.isVisible(idx,currentY) || canvas.isVisible(keys[i+1],currentY)) { canvas.drawLine(ctx, Math.max(0,canvas.x2px(idx)), canvas.y2px(currentY), Math.min(canvas.canvasSize.width,canvas.x2px(keys[i+1])), canvas.y2px(currentY) ) - if(canvas.visible(idx,currentY)) { + if(canvas.isVisible(idx,currentY)) { ctx.beginPath(); ctx.arc(canvas.x2px(idx),canvas.y2px(currentY), 4, 0, 2 * Math.PI); ctx.fill(); } - if(canvas.visible(keys[i+1],currentY)) { + if(canvas.isVisible(keys[i+1],currentY)) { ctx.beginPath(); ctx.arc(canvas.x2px(keys[i+1])+4,canvas.y2px(currentY), 4, Math.PI / 2, 3 * Math.PI / 2); ctx.stroke(); } } } - if(canvas.visible(keys[keys.length-1],currentY+parseFloat(this.probabilities[keys[keys.length-1]]))) { + if(canvas.isVisible(keys[keys.length-1],currentY+parseFloat(this.probabilities[keys[keys.length-1]]))) { canvas.drawLine(ctx, Math.max(0,canvas.x2px(keys[keys.length-1])), canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]].replace(/,/g, '.'))), diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js index 466fc9f..ee53afa 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js @@ -316,8 +316,8 @@ function parseName(str, removeUnallowed = true) { [/([^a-z]|^)gps(i)?([^a-z]|$)/g, '$1Ψ$3'], [/([^a-z]|^)gom(ega)?([^a-z]|$)/g, '$1Ω$3'], // Underscores - [/_\(([^_]+)\)/g, function(match, p1) { return textsub(p1) }], - [/_([^" ]+)/g, function(match, p1) { return textsub(p1) }], + // [/_\(([^_]+)\)/g, function(match, p1) { return textsub(p1) }], + // [/_([^" ]+)/g, function(match, p1) { return textsub(p1) }], // Array elements [/\[([^\]\[]+)\]/g, function(match, p1) { return textsub(p1) }], // Removing