Compare commits

..

No commits in common. "6abbbe5e61518ab5158c7135140c4f087222a4ab" and "d6dee6a2be4b92aa5e0520e20ab3a6dcbb5893ce" have entirely different histories.

6 changed files with 40 additions and 93 deletions

View file

@ -18,7 +18,6 @@
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
@ -44,11 +43,6 @@ 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']
@ -129,15 +123,15 @@ Repeater {
} }
Native.MessageDialog { // D.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()
} // }
} // }
} }
} }
@ -261,68 +255,29 @@ Repeater {
} }
delegate: Component { delegate: Component {
Row { Loader {
//height: customPropComment.height + customPropText.height + customPropCheckBox.height + customPropCombo.height + customPropListDict.height
width: dlgProperties.width width: dlgProperties.width
spacing: 5 property string propertyName: modelData[0]
property var propertyType: modelData[1]
property string propertyLabel: qsTranslate('prop',propertyName)
property string propertyIcon: Utils.camelCase2readable(propertyName)
Loader { sourceComponent: {
id: propertyEditor if(propertyName.startsWith('comment'))
width: dlgProperties.width - pointerButton.width return commentComponent
property string propertyName: modelData[0] else if(propertyType == 'boolean')
property var propertyType: modelData[1] return checkboxComponent
property string propertyLabel: qsTranslate('prop',propertyName) else if(paramTypeIn(propertyType, ['Expression']))
property string propertyIcon: Utils.camelCase2readable(propertyName) return expressionEditorComponent
else if(paramTypeIn(propertyType, textTypes))
sourceComponent: { return textEditorComponent
if(propertyName.startsWith('comment')) else if(paramTypeIn(propertyType, comboBoxTypes))
return commentComponent return comboBoxComponent
else if(propertyType == 'boolean') else if(paramTypeIn(propertyType, listTypes))
return checkboxComponent return listDictEditorComponent
else if(paramTypeIn(propertyType, ['Expression'])) else
return expressionEditorComponent return {}
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,11 +55,6 @@ 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
@ -148,7 +143,6 @@ 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,8 +116,6 @@ 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: function() { onEditingFinished: {
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.isVisible(keys[0],this.probabilities[keys[0]].replace(/,/g, '.'))) { if(canvas.visible(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.isVisible(keys[0],0)) { if(canvas.visible(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.isVisible(idx,currentY) || canvas.isVisible(keys[i+1],currentY)) { if(canvas.visible(idx,currentY) || canvas.visible(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.isVisible(idx,currentY)) { if(canvas.visible(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.isVisible(keys[i+1],currentY)) { if(canvas.visible(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.isVisible(keys[keys.length-1],currentY+parseFloat(this.probabilities[keys[keys.length-1]]))) { if(canvas.visible(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