Compare commits

...

2 commits

Author SHA1 Message Date
6abbbe5e61
Adding picker for properties (x,y,labelX)
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-24 03:51:42 +02:00
5cef8e23fa
Fixing several issues with repartition
+ Underscores being automatically removed from the name the moment it's edited.
+ Fixing issue with function name change.
2023-05-24 03:17:21 +02:00
6 changed files with 93 additions and 40 deletions

View file

@ -18,6 +18,7 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../../js/objects.js" as Objects import "../../js/objects.js" as Objects
import "../../js/historylib.js" as HistoryLib import "../../js/historylib.js" as HistoryLib
@ -43,6 +44,11 @@ Repeater {
Object whose properties to list and edit. Object whose properties to list and edit.
*/ */
property var obj property var obj
/*!
\qmlproperty var CustomPropertyList::positionPicker
Reference to the global PositionPicker QML object.
*/
property var positionPicker
readonly property var textTypes: ['Domain', 'string', 'number'] readonly property var textTypes: ['Domain', 'string', 'number']
readonly property var comboBoxTypes: ['ObjectType', 'Enum'] readonly property var comboBoxTypes: ['ObjectType', 'Enum']
@ -94,7 +100,7 @@ Repeater {
// Setting for text & number settings as well as domains // Setting for text & number settings as well as domains
Setting.TextSetting { Setting.TextSetting {
height: 30 height: 30
label: propertyLabel label: propertyLabel
icon: `settings/custom/${propertyIcon}.svg` icon: `settings/custom/${propertyIcon}.svg`
isDouble: propertyType == 'number' isDouble: propertyType == 'number'
@ -123,15 +129,15 @@ Repeater {
} }
// D.MessageDialog { Native.MessageDialog {
// id: parsingErrorDialog id: parsingErrorDialog
// title: qsTranslate("expression", "LogarithmPlotter - Parsing error") title: qsTranslate("expression", "LogarithmPlotter - Parsing error")
// text: "" text: ""
// function showDialog(propName, propValue, error) { function showDialog(propName, propValue, error) {
// text = qsTranslate("error", "Error while parsing expression for property %1:\n%2\n\nEvaluated expression: %3").arg(propName).arg(error).arg(propValue) text = qsTranslate("error", "Error while parsing expression for property %1:\n%2\n\nEvaluated expression: %3").arg(propName).arg(error).arg(propValue)
// open() open()
// } }
// } }
} }
} }
@ -255,29 +261,68 @@ Repeater {
} }
delegate: Component { delegate: Component {
Loader { Row {
//height: customPropComment.height + customPropText.height + customPropCheckBox.height + customPropCombo.height + customPropListDict.height
width: dlgProperties.width width: dlgProperties.width
property string propertyName: modelData[0] spacing: 5
property var propertyType: modelData[1]
property string propertyLabel: qsTranslate('prop',propertyName)
property string propertyIcon: Utils.camelCase2readable(propertyName)
sourceComponent: { Loader {
if(propertyName.startsWith('comment')) id: propertyEditor
return commentComponent width: dlgProperties.width - pointerButton.width
else if(propertyType == 'boolean') property string propertyName: modelData[0]
return checkboxComponent property var propertyType: modelData[1]
else if(paramTypeIn(propertyType, ['Expression'])) property string propertyLabel: qsTranslate('prop',propertyName)
return expressionEditorComponent property string propertyIcon: Utils.camelCase2readable(propertyName)
else if(paramTypeIn(propertyType, textTypes))
return textEditorComponent sourceComponent: {
else if(paramTypeIn(propertyType, comboBoxTypes)) if(propertyName.startsWith('comment'))
return comboBoxComponent return commentComponent
else if(paramTypeIn(propertyType, listTypes)) else if(propertyType == 'boolean')
return listDictEditorComponent return checkboxComponent
else else if(paramTypeIn(propertyType, ['Expression']))
return {} return expressionEditorComponent
else if(paramTypeIn(propertyType, textTypes))
return textEditorComponent
else if(paramTypeIn(propertyType, comboBoxTypes))
return comboBoxComponent
else if(paramTypeIn(propertyType, listTypes))
return listDictEditorComponent
else
return {}
}
}
Button {
id: pointerButton
height: parent.height
width: visible ? height : 0
anchors.verticalCenter: parent.verticalCenter
property bool isXProp: ['labelX', 'x'].includes(propertyEditor.propertyName)
property bool isYProp: ['y'].includes(propertyEditor.propertyName)
visible: isXProp || isYProp
ToolTip.visible: hovered
ToolTip.text: qsTr("Pick on graph")
Setting.Icon {
id: icon
width: 18
height: 18
anchors.centerIn: parent
color: sysPalette.windowText
source: '../icons/common/position.svg'
}
onClicked: {
positionPicker.objType = objType
positionPicker.objName = obj.name
positionPicker.pickX = isXProp
positionPicker.pickY = isYProp
positionPicker.propertyX = propertyEditor.propertyName
positionPicker.propertyY = propertyEditor.propertyName
positionPicker.visible = true
objEditor.close()
}
} }
} }
} }

View file

@ -55,6 +55,11 @@ Popup.BaseDialog {
Instance of the object being edited. Instance of the object being edited.
*/ */
property var obj: Objects.currentObjects[objType][objIndex] property var obj: Objects.currentObjects[objType][objIndex]
/*!
\qmlproperty var EditorDialog::posPicker
Reference to the global PositionPicker QML object.
*/
property var posPicker
title: "LogarithmPlotter" title: "LogarithmPlotter"
width: 350 width: 350
@ -143,6 +148,7 @@ Popup.BaseDialog {
CustomPropertyList { CustomPropertyList {
id: dlgCustomProperties id: dlgCustomProperties
obj: objEditor.obj obj: objEditor.obj
positionPicker: posPicker
onChanged: { onChanged: {
obj.update() obj.update()

View file

@ -116,6 +116,8 @@ ScrollView {
// Object editor // Object editor
Editor.Dialog { Editor.Dialog {
id: objEditor id: objEditor
posPicker: positionPicker
} }
/*! /*!

View file

@ -119,7 +119,7 @@ Item {
focus: true focus: true
text: control.defValue text: control.defValue
selectByMouse: true selectByMouse: true
onEditingFinished: { onEditingFinished: function() {
if(insertButton.focus || insertPopup.focus) return if(insertButton.focus || insertPopup.focus) return
var value = text var value = text
if(control.isInt) value = Math.max(control.min,parseInt(value).toString()=="NaN"?control.min:parseInt(value)) if(control.isInt) value = Math.max(control.min,parseInt(value).toString()=="NaN"?control.min:parseInt(value))

View file

@ -96,14 +96,14 @@ class RepartitionFunction extends Common.ExecutableObject {
draw(canvas, ctx) { draw(canvas, ctx) {
var currentY = 0; var currentY = 0;
var keys = Object.keys(this.probabilities).map(idx => parseInt(idx)).sort((a,b) => a-b) 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, canvas.drawLine(ctx,
0, 0,
canvas.y2px(0), canvas.y2px(0),
canvas.x2px(keys[0]), canvas.x2px(keys[0]),
canvas.y2px(0) canvas.y2px(0)
) )
if(canvas.visible(keys[0],0)) { if(canvas.isVisible(keys[0],0)) {
ctx.beginPath(); ctx.beginPath();
ctx.arc(canvas.x2px(keys[0])+4,canvas.y2px(0), 4, Math.PI / 2, 3 * Math.PI / 2); ctx.arc(canvas.x2px(keys[0])+4,canvas.y2px(0), 4, Math.PI / 2, 3 * Math.PI / 2);
ctx.stroke(); ctx.stroke();
@ -112,26 +112,26 @@ class RepartitionFunction extends Common.ExecutableObject {
for(var i = 0; i < keys.length-1; i++) { for(var i = 0; i < keys.length-1; i++) {
var idx = keys[i]; var idx = keys[i];
currentY += parseFloat(this.probabilities[idx].replace(/,/g, '.')); 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, canvas.drawLine(ctx,
Math.max(0,canvas.x2px(idx)), Math.max(0,canvas.x2px(idx)),
canvas.y2px(currentY), canvas.y2px(currentY),
Math.min(canvas.canvasSize.width,canvas.x2px(keys[i+1])), Math.min(canvas.canvasSize.width,canvas.x2px(keys[i+1])),
canvas.y2px(currentY) canvas.y2px(currentY)
) )
if(canvas.visible(idx,currentY)) { if(canvas.isVisible(idx,currentY)) {
ctx.beginPath(); ctx.beginPath();
ctx.arc(canvas.x2px(idx),canvas.y2px(currentY), 4, 0, 2 * Math.PI); ctx.arc(canvas.x2px(idx),canvas.y2px(currentY), 4, 0, 2 * Math.PI);
ctx.fill(); ctx.fill();
} }
if(canvas.visible(keys[i+1],currentY)) { if(canvas.isVisible(keys[i+1],currentY)) {
ctx.beginPath(); ctx.beginPath();
ctx.arc(canvas.x2px(keys[i+1])+4,canvas.y2px(currentY), 4, Math.PI / 2, 3 * Math.PI / 2); ctx.arc(canvas.x2px(keys[i+1])+4,canvas.y2px(currentY), 4, Math.PI / 2, 3 * Math.PI / 2);
ctx.stroke(); 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, canvas.drawLine(ctx,
Math.max(0,canvas.x2px(keys[keys.length-1])), Math.max(0,canvas.x2px(keys[keys.length-1])),
canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]].replace(/,/g, '.'))), canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]].replace(/,/g, '.'))),

View file

@ -316,8 +316,8 @@ function parseName(str, removeUnallowed = true) {
[/([^a-z]|^)gps(i)?([^a-z]|$)/g, '$1Ψ$3'], [/([^a-z]|^)gps(i)?([^a-z]|$)/g, '$1Ψ$3'],
[/([^a-z]|^)gom(ega)?([^a-z]|$)/g, '$1Ω$3'], [/([^a-z]|^)gom(ega)?([^a-z]|$)/g, '$1Ω$3'],
// Underscores // 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 // Array elements
[/\[([^\]\[]+)\]/g, function(match, p1) { return textsub(p1) }], [/\[([^\]\[]+)\]/g, function(match, p1) { return textsub(p1) }],
// Removing // Removing