Compare commits
No commits in common. "32db56304bfbbfe9b61cf74282a36d4f2a0eeab0" and "6116ffe4e7370f5867e6d2f23fb8832d314edcfe" have entirely different histories.
32db56304b
...
6116ffe4e7
14 changed files with 98 additions and 373 deletions
|
@ -249,11 +249,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
// Importing objects
|
// Importing objects
|
||||||
Objects.currentObjects = {}
|
Objects.currentObjects = {}
|
||||||
Object.keys(Objects.currentObjectsByName).forEach(key => {
|
Objects.currentObjectsByName = {}
|
||||||
delete Objects.currentObjectsByName[key];
|
|
||||||
// Required to keep the same reference for the copy of the object used in expression variable detection.
|
|
||||||
// Another way would be to change the reference as well, but I feel like the code would be less clean.
|
|
||||||
})
|
|
||||||
for(let objType in data['objects']) {
|
for(let objType in data['objects']) {
|
||||||
if(Object.keys(Objects.types).indexOf(objType) > -1) {
|
if(Object.keys(Objects.types).indexOf(objType) > -1) {
|
||||||
Objects.currentObjects[objType] = []
|
Objects.currentObjects[objType] = []
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
import QtQuick.Dialogs 1.3 as D
|
||||||
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/objs/common.js" as ObjectsCommons
|
||||||
import "../../js/historylib.js" as HistoryLib
|
import "../../js/historylib.js" as HistoryLib
|
||||||
import "../../js/utils.js" as Utils
|
import "../../js/utils.js" as Utils
|
||||||
import "../../js/mathlib.js" as MathLib
|
import "../../js/mathlib.js" as MathLib
|
||||||
|
@ -44,7 +46,7 @@ Repeater {
|
||||||
*/
|
*/
|
||||||
property var obj
|
property var obj
|
||||||
|
|
||||||
readonly property var textTypes: ['Domain', 'string', 'number']
|
readonly property var textTypes: ['Expression', 'Domain', 'string', 'number']
|
||||||
readonly property var comboBoxTypes: ['ObjectType', 'Enum']
|
readonly property var comboBoxTypes: ['ObjectType', 'Enum']
|
||||||
readonly property var listTypes: ['List', 'Dict']
|
readonly property var listTypes: ['List', 'Dict']
|
||||||
|
|
||||||
|
@ -64,43 +66,48 @@ Repeater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
|
||||||
id: expressionEditorComponent
|
|
||||||
|
|
||||||
// Setting for expressions
|
|
||||||
Setting.ExpressionEditor {
|
|
||||||
height: 30
|
|
||||||
label: propertyLabel
|
|
||||||
icon: `settings/custom/${propertyIcon}.svg`
|
|
||||||
defValue: Utils.simplifyExpression(obj[propertyName].toEditableString())
|
|
||||||
self: obj.name
|
|
||||||
onChanged: function(newExpr) {
|
|
||||||
if(obj[propertyName].toString() != newExpr.toString()) {
|
|
||||||
history.addToHistory(new HistoryLib.EditedProperty(
|
|
||||||
obj.name, objType, propertyName,
|
|
||||||
obj[propertyName], newExpr
|
|
||||||
))
|
|
||||||
obj[propertyName] = newExpr
|
|
||||||
root.changed()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: textEditorComponent
|
id: textEditorComponent
|
||||||
|
|
||||||
// Setting for text & number settings as well as domains
|
// Setting for text & number settings as well as domains & expressions
|
||||||
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'
|
||||||
defValue: obj[propertyName] == null ? '' : obj[propertyName].toString()
|
defValue: {
|
||||||
|
switch(propertyType) {
|
||||||
|
case 'Expression':
|
||||||
|
return Utils.simplifyExpression(obj[propertyName].toEditableString())
|
||||||
|
break
|
||||||
|
case 'string':
|
||||||
|
return obj[propertyName]
|
||||||
|
break
|
||||||
|
case 'Domain':
|
||||||
|
case 'number':
|
||||||
|
default:
|
||||||
|
return obj[propertyName].toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
onChanged: function(newValue) {
|
onChanged: function(newValue) {
|
||||||
try {
|
try {
|
||||||
var newValueParsed = {
|
var newValueParsed = {
|
||||||
|
'Expression': () => {
|
||||||
|
let expr = new MathLib.Expression(newValue)
|
||||||
|
// Check if the expression is valid, throws error otherwise.
|
||||||
|
if(!expr.allRequirementsFullfilled()) {
|
||||||
|
let undefVars = expr.undefinedVariables()
|
||||||
|
console.log(JSON.stringify(undefVars), undefVars.join(', '))
|
||||||
|
if(undefVars.length > 1)
|
||||||
|
throw new Error(qsTranslate('error', 'No object found with names %1.').arg(undefVars.join(', ')))
|
||||||
|
else
|
||||||
|
throw new Error(qsTranslate('error', 'No object found with name %1.').arg(undefVars.join(', ')))
|
||||||
|
}
|
||||||
|
if(expr.requiredObjects().includes(obj.name))
|
||||||
|
throw new Error(qsTranslate('error', 'Object cannot be dependent on itself.'))
|
||||||
|
// TODO: Check for recursive dependencies.
|
||||||
|
return expr
|
||||||
|
},
|
||||||
'Domain': () => MathLib.parseDomain(newValue),
|
'Domain': () => MathLib.parseDomain(newValue),
|
||||||
'string': () => newValue,
|
'string': () => newValue,
|
||||||
'number': () => parseFloat(newValue)
|
'number': () => parseFloat(newValue)
|
||||||
|
@ -122,15 +129,15 @@ Repeater {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// D.MessageDialog {
|
D.MessageDialog {
|
||||||
// id: parsingErrorDialog
|
id: parsingErrorDialog
|
||||||
// title: qsTranslate("expression", "LogarithmPlotter - Parsing error")
|
title: qsTr("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 = qsTr("Error while parsing expression for property %1:\n%2\n\nEvaluated expression: %3").arg(propName).arg(error).arg(propValue)
|
||||||
// open()
|
open()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,12 +150,7 @@ Repeater {
|
||||||
text: propertyLabel
|
text: propertyLabel
|
||||||
//icon: `settings/custom/${propertyIcon}.svg`
|
//icon: `settings/custom/${propertyIcon}.svg`
|
||||||
|
|
||||||
checked: {
|
checked: obj[propertyName]
|
||||||
//if(obj[propertyName] == null) {
|
|
||||||
// return false
|
|
||||||
//}
|
|
||||||
return obj[propertyName]
|
|
||||||
}
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
history.addToHistory(new HistoryLib.EditedProperty(
|
history.addToHistory(new HistoryLib.EditedProperty(
|
||||||
obj.name, objType, propertyName,
|
obj.name, objType, propertyName,
|
||||||
|
@ -267,8 +269,6 @@ Repeater {
|
||||||
return commentComponent
|
return commentComponent
|
||||||
else if(propertyType == 'boolean')
|
else if(propertyType == 'boolean')
|
||||||
return checkboxComponent
|
return checkboxComponent
|
||||||
else if(propertyType == 'Expression')
|
|
||||||
return expressionEditorComponent
|
|
||||||
else if(paramTypeIn(propertyType, textTypes))
|
else if(paramTypeIn(propertyType, textTypes))
|
||||||
return textEditorComponent
|
return textEditorComponent
|
||||||
else if(paramTypeIn(propertyType, comboBoxTypes))
|
else if(paramTypeIn(propertyType, comboBoxTypes))
|
||||||
|
|
|
@ -96,7 +96,7 @@ ScrollView {
|
||||||
posPicker: positionPicker
|
posPicker: positionPicker
|
||||||
|
|
||||||
onChanged: {
|
onChanged: {
|
||||||
obj = Objects.currentObjects[objType][index]
|
//obj = Objects.currentObjects[objType][index]
|
||||||
objectListList.update()
|
objectListList.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,10 @@ Item {
|
||||||
ToolTip.text: qsTr("Delete %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
|
ToolTip.text: qsTr("Delete %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
deleteRecursively(obj)
|
history.addToHistory(new HistoryLib.DeleteObject(
|
||||||
|
obj.name, obj.type, obj.export()
|
||||||
|
))
|
||||||
|
Objects.deleteObject(obj.name)
|
||||||
changed()
|
changed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,18 +207,4 @@ Item {
|
||||||
changed()
|
changed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmlmethod void ObjectRow::deleteRecursively(var object)
|
|
||||||
Deletes an object and it's dependencies recursively.
|
|
||||||
*/
|
|
||||||
function deleteRecursively(object) {
|
|
||||||
for(let toRemove of object.requiredBy)
|
|
||||||
deleteRecursively(toRemove)
|
|
||||||
object.requiredBy = []
|
|
||||||
history.addToHistory(new HistoryLib.DeleteObject(
|
|
||||||
object.name, object.type, object.export()
|
|
||||||
))
|
|
||||||
Objects.deleteObject(object.name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
/**
|
|
||||||
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
|
|
||||||
* Copyright (C) 2022 Ad5001
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick.Controls 2.12
|
|
||||||
import QtQuick 2.12
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmltype InsertCharacter
|
|
||||||
\inqmlmodule eu.ad5001.LogarithmPlotter.Setting
|
|
||||||
\brief Popup to insert special character.
|
|
||||||
|
|
||||||
\sa TextSetting, ExpressionEditor
|
|
||||||
*/
|
|
||||||
Popup {
|
|
||||||
id: insertPopup
|
|
||||||
|
|
||||||
signal selected(string character)
|
|
||||||
|
|
||||||
width: 280
|
|
||||||
height: insertGrid.insertChars.length/insertGrid.columns*(width/insertGrid.columns)
|
|
||||||
modal: true
|
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
||||||
|
|
||||||
Grid {
|
|
||||||
id: insertGrid
|
|
||||||
width: parent.width
|
|
||||||
columns: 7
|
|
||||||
|
|
||||||
property var insertChars: [
|
|
||||||
"α","β","γ","δ","ε","ζ","η",
|
|
||||||
"π","θ","κ","λ","μ","ξ","ρ",
|
|
||||||
"ς","σ","τ","φ","χ","ψ","ω",
|
|
||||||
"Γ","Δ","Θ","Λ","Ξ","Π","Σ",
|
|
||||||
"Φ","Ψ","Ω","ₐ","ₑ","ₒ","ₓ",
|
|
||||||
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
|
|
||||||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
|
||||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
|
||||||
"₄","₅","₆","₇","₈","₉","₀"
|
|
||||||
]
|
|
||||||
Repeater {
|
|
||||||
model: parent.insertChars.length
|
|
||||||
|
|
||||||
Button {
|
|
||||||
id: insertBtn
|
|
||||||
width: insertGrid.width/insertGrid.columns
|
|
||||||
height: width
|
|
||||||
text: insertGrid.insertChars[modelData]
|
|
||||||
flat: text == " "
|
|
||||||
font.pixelSize: 18
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
selected(text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,4 +6,3 @@ FileDialog 1.0 FileDialog.qml
|
||||||
GreetScreen 1.0 GreetScreen.qml
|
GreetScreen 1.0 GreetScreen.qml
|
||||||
Changelog 1.0 Changelog.qml
|
Changelog 1.0 Changelog.qml
|
||||||
ThanksTo 1.0 ThanksTo.qml
|
ThanksTo 1.0 ThanksTo.qml
|
||||||
InsertCharacter 1.0 InsertCharacter.qml
|
|
||||||
|
|
|
@ -1,214 +0,0 @@
|
||||||
/**
|
|
||||||
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
|
|
||||||
* Copyright (C) 2022 Ad5001
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick.Controls 2.12
|
|
||||||
import QtQuick 2.12
|
|
||||||
import QtQuick.Dialogs 1.3 as D
|
|
||||||
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
|
|
||||||
import "../js/mathlib.js" as MathLib
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmltype ExpressionEditor
|
|
||||||
\inqmlmodule eu.ad5001.LogarithmPlotter.Setting
|
|
||||||
\brief Setting to edit strings and numbers.
|
|
||||||
|
|
||||||
\sa EditorDialog, Settings, Icon
|
|
||||||
*/
|
|
||||||
Item {
|
|
||||||
id: control
|
|
||||||
height: 30
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmlsignal ExpressionEditor::changed(var newValue)
|
|
||||||
|
|
||||||
Emitted when the value of the expression has been changed.
|
|
||||||
The corresponding handler is \c onChanged.
|
|
||||||
*/
|
|
||||||
signal changed(var newValue)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::defValue
|
|
||||||
Default editable expression value of the editor.
|
|
||||||
*/
|
|
||||||
property string defValue
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::value
|
|
||||||
Value of the editor.
|
|
||||||
*/
|
|
||||||
property alias value: editor.text
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::self
|
|
||||||
Object or context of the expression to be edited.
|
|
||||||
Used to prevent circular dependency.
|
|
||||||
*/
|
|
||||||
property string self: ""
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::placeholderText
|
|
||||||
Value of the editor.
|
|
||||||
*/
|
|
||||||
property alias placeholderText: editor.placeholderText
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::label
|
|
||||||
Label of the editor.
|
|
||||||
*/
|
|
||||||
property string label
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::icon
|
|
||||||
Icon path of the editor.
|
|
||||||
*/
|
|
||||||
property string icon: ""
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmlproperty string ExpressionEditor::openAndCloseMatches
|
|
||||||
Characters that when pressed, should be immediately followed up by their closing character.
|
|
||||||
*/
|
|
||||||
readonly property var openAndCloseMatches: {
|
|
||||||
"(": ")",
|
|
||||||
"[": "]",
|
|
||||||
"'": "'",
|
|
||||||
'"': '"'
|
|
||||||
}
|
|
||||||
|
|
||||||
Icon {
|
|
||||||
id: iconLabel
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.topMargin: icon == "" ? 0 : 3
|
|
||||||
source: control.visible && icon != "" ? "../icons/" + control.icon : ""
|
|
||||||
width: height
|
|
||||||
height: icon == "" || !visible ? 0 : 24
|
|
||||||
color: sysPalette.windowText
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: labelItem
|
|
||||||
anchors.left: iconLabel.right
|
|
||||||
anchors.leftMargin: icon == "" ? 0 : 5
|
|
||||||
height: parent.height
|
|
||||||
anchors.top: parent.top
|
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
|
||||||
//color: sysPalette.windowText
|
|
||||||
text: visible ? qsTranslate("control", "%1: ").arg(control.label) : ""
|
|
||||||
visible: control.label != ""
|
|
||||||
}
|
|
||||||
|
|
||||||
D.MessageDialog {
|
|
||||||
id: parsingErrorDialog
|
|
||||||
title: qsTranslate("expression", "LogarithmPlotter - Parsing error")
|
|
||||||
text: ""
|
|
||||||
function showDialog(propName, propValue, error) {
|
|
||||||
text = qsTranslate("expression", "Error while parsing expression for property %1:\n%2\n\nEvaluated expression: %3").arg(propName).arg(error).arg(propValue)
|
|
||||||
open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: editor
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: labelItem.right
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
width: control.width - (labelItem.visible ? labelItem.width + 5 : 0) - iconLabel.width - 5
|
|
||||||
height: parent.height
|
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
|
||||||
horizontalAlignment: control.label == "" ? TextInput.AlignLeft : TextInput.AlignHCenter
|
|
||||||
text: control.defValue
|
|
||||||
color: sysPalette.windowText
|
|
||||||
focus: true
|
|
||||||
selectByMouse: true
|
|
||||||
|
|
||||||
Keys.priority: Keys.BeforeItem // Required for knowing which key the user presses.
|
|
||||||
|
|
||||||
onEditingFinished: {
|
|
||||||
if(insertButton.focus || insertPopup.focus) return
|
|
||||||
let value = text
|
|
||||||
if(value != "" && value.toString() != defValue) {
|
|
||||||
let expr = parse(value)
|
|
||||||
if(expr != null) {
|
|
||||||
control.changed(expr)
|
|
||||||
defValue = expr.toEditableString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onPressed: function(event) {
|
|
||||||
if(event.text in openAndCloseMatches) {
|
|
||||||
let start = selectionStart
|
|
||||||
insert(selectionStart, event.text)
|
|
||||||
insert(selectionEnd, openAndCloseMatches[event.text])
|
|
||||||
cursorPosition = start+1
|
|
||||||
event.accepted = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
id: insertButton
|
|
||||||
text: "α"
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: 5
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
width: 20
|
|
||||||
height: width
|
|
||||||
onClicked: {
|
|
||||||
insertPopup.open()
|
|
||||||
insertPopup.focus = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Popup.InsertCharacter {
|
|
||||||
id: insertPopup
|
|
||||||
|
|
||||||
x: Math.round((parent.width - width) / 2)
|
|
||||||
y: Math.round((parent.height - height) / 2)
|
|
||||||
|
|
||||||
onSelected: function(c) {
|
|
||||||
editor.insert(editor.cursorPosition, c)
|
|
||||||
insertPopup.close()
|
|
||||||
editor.focus = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\qmlmethod var ExpressionEditor::parse(string newExpression)
|
|
||||||
Parses the \c newExpression as an expression, checks for errors, shows them if any.
|
|
||||||
Returns the parsed expression if possible, null otherwise..
|
|
||||||
*/
|
|
||||||
function parse(newExpression) {
|
|
||||||
let expr = null
|
|
||||||
try {
|
|
||||||
expr = new MathLib.Expression(value.toString())
|
|
||||||
// Check if the expression is valid, throws error otherwise.
|
|
||||||
if(!expr.allRequirementsFullfilled()) {
|
|
||||||
let undefVars = expr.undefinedVariables()
|
|
||||||
console.log(JSON.stringify(undefVars), undefVars.join(', '))
|
|
||||||
if(undefVars.length > 1)
|
|
||||||
throw new Error(qsTranslate('error', 'No object found with names %1.').arg(undefVars.join(', ')))
|
|
||||||
else
|
|
||||||
throw new Error(qsTranslate('error', 'No object found with name %1.').arg(undefVars.join(', ')))
|
|
||||||
}
|
|
||||||
if(expr.requiredObjects().includes(control.self))
|
|
||||||
throw new Error(qsTranslate('error', 'Object cannot be dependent on itself.'))
|
|
||||||
// TODO: Check for recursive dependencies.
|
|
||||||
} catch(e) {
|
|
||||||
// Error in expression
|
|
||||||
parsingErrorDialog.showDialog(propertyName, newExpression, e.message)
|
|
||||||
}
|
|
||||||
return expr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmltype TextSetting
|
\qmltype TextSetting
|
||||||
|
@ -120,7 +119,6 @@ Item {
|
||||||
text: control.defValue
|
text: control.defValue
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
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))
|
||||||
if(control.isDouble) value = Math.max(control.min,parseFloat(value).toString()=="NaN"?control.min:parseFloat(value))
|
if(control.isDouble) value = Math.max(control.min,parseFloat(value).toString()=="NaN"?control.min:parseFloat(value))
|
||||||
|
@ -132,7 +130,6 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: insertButton
|
|
||||||
text: "α"
|
text: "α"
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 5
|
anchors.rightMargin: 5
|
||||||
|
@ -140,22 +137,53 @@ Item {
|
||||||
width: 20
|
width: 20
|
||||||
height: width
|
height: width
|
||||||
visible: !isInt && !isDouble
|
visible: !isInt && !isDouble
|
||||||
onClicked: {
|
onClicked: insertPopup.open()
|
||||||
insertPopup.open()
|
|
||||||
insertPopup.focus = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Popup.InsertCharacter {
|
Popup {
|
||||||
id: insertPopup
|
id: insertPopup
|
||||||
|
|
||||||
x: Math.round((parent.width - width) / 2)
|
x: Math.round((parent.width - width) / 2)
|
||||||
y: Math.round((parent.height - height) / 2)
|
y: Math.round((parent.height - height) / 2)
|
||||||
|
width: 280
|
||||||
|
height: insertGrid.insertChars.length/insertGrid.columns*(width/insertGrid.columns)
|
||||||
|
modal: true
|
||||||
|
focus: true
|
||||||
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
||||||
|
|
||||||
onSelected: function(c) {
|
Grid {
|
||||||
input.insert(input.cursorPosition, c)
|
id: insertGrid
|
||||||
insertPopup.close()
|
width: parent.width
|
||||||
input.focus = true
|
columns: 7
|
||||||
|
|
||||||
|
property var insertChars: [
|
||||||
|
"α","β","γ","δ","ε","ζ","η",
|
||||||
|
"π","θ","κ","λ","μ","ξ","ρ",
|
||||||
|
"ς","σ","τ","φ","χ","ψ","ω",
|
||||||
|
"Γ","Δ","Θ","Λ","Ξ","Π","Σ",
|
||||||
|
"Φ","Ψ","Ω","ₐ","ₑ","ₒ","ₓ",
|
||||||
|
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
|
||||||
|
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||||
|
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||||
|
"₄","₅","₆","₇","₈","₉","₀"
|
||||||
|
]
|
||||||
|
Repeater {
|
||||||
|
model: parent.insertChars.length
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: insertBtn
|
||||||
|
width: insertGrid.width/insertGrid.columns
|
||||||
|
height: width
|
||||||
|
text: insertGrid.insertChars[modelData]
|
||||||
|
flat: text == " "
|
||||||
|
font.pixelSize: 18
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
input.insert(input.cursorPosition, insertGrid.insertChars[modelData])
|
||||||
|
insertPopup.close()
|
||||||
|
input.focus = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,4 @@ ComboBoxSetting 1.0 ComboBoxSetting.qml
|
||||||
Icon 1.0 Icon.qml
|
Icon 1.0 Icon.qml
|
||||||
ListSetting 1.0 ListSetting.qml
|
ListSetting 1.0 ListSetting.qml
|
||||||
TextSetting 1.0 TextSetting.qml
|
TextSetting 1.0 TextSetting.qml
|
||||||
ExpressionEditor 1.0 ExpressionEditor.qml
|
|
||||||
|
|
|
@ -1836,9 +1836,9 @@ var optionNameMap = {
|
||||||
'not': 'logical',
|
'not': 'logical',
|
||||||
'?': 'conditional',
|
'?': 'conditional',
|
||||||
':': 'conditional',
|
':': 'conditional',
|
||||||
//'=': 'assignment', // Disable assignment
|
'=': 'assignment',
|
||||||
'[': 'array',
|
'[': 'array',
|
||||||
//'()=': 'fndef' // Diable function definition
|
'()=': 'fndef'
|
||||||
};
|
};
|
||||||
|
|
||||||
function getOptionName(op) {
|
function getOptionName(op) {
|
||||||
|
|
|
@ -45,7 +45,6 @@ class CreateNewObject extends C.Action {
|
||||||
|
|
||||||
redo() {
|
redo() {
|
||||||
Objects.createNewRegisteredObject(this.targetType, this.targetProperties)
|
Objects.createNewRegisteredObject(this.targetType, this.targetProperties)
|
||||||
Objects.currentObjectsByName[this.targetName].update()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export() {
|
export() {
|
||||||
|
|
|
@ -46,9 +46,9 @@ function deleteObject(objName) {
|
||||||
* @param {string} objName - Current name of the object.
|
* @param {string} objName - Current name of the object.
|
||||||
*/
|
*/
|
||||||
let obj = currentObjectsByName[objName]
|
let obj = currentObjectsByName[objName]
|
||||||
|
delete currentObjectsByName[objName]
|
||||||
currentObjects[obj.type].splice(currentObjects[obj.type].indexOf(obj),1)
|
currentObjects[obj.type].splice(currentObjects[obj.type].indexOf(obj),1)
|
||||||
obj.delete()
|
obj.delete()
|
||||||
delete currentObjectsByName[objName]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getObjectsName(objType) {
|
function getObjectsName(objType) {
|
||||||
|
|
|
@ -200,7 +200,7 @@ class DrawableObject {
|
||||||
if(properties[property] == 'Expression' && this[property] != null) {
|
if(properties[property] == 'Expression' && this[property] != null) {
|
||||||
// Expressions with dependencies
|
// Expressions with dependencies
|
||||||
for(let objName of this[property].requiredObjects()) {
|
for(let objName of this[property].requiredObjects()) {
|
||||||
if(objName in C.currentObjectsByName && !this.requires.includes(C.currentObjectsByName[objName])) {
|
if(objName in C.currentObjectsByName) {
|
||||||
this.requires.push(C.currentObjectsByName[objName])
|
this.requires.push(C.currentObjectsByName[objName])
|
||||||
C.currentObjectsByName[objName].requiredBy.push(this)
|
C.currentObjectsByName[objName].requiredBy.push(this)
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ class DrawableObject {
|
||||||
* Callback method when the object is about to get deleted.
|
* Callback method when the object is about to get deleted.
|
||||||
*/
|
*/
|
||||||
delete() {
|
delete() {
|
||||||
for(let toRemove of this.requiredBy) { // Normally, there should be none here, but better leave nothing just in case.
|
for(let toRemove of this.requiredBy) {
|
||||||
Objects.deleteObject(toRemove.name)
|
Objects.deleteObject(toRemove.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Text extends Common.DrawableObject {
|
||||||
x = 1, y = 0, labelPosition = 'center', text = 'New text', disableLatex = false) {
|
x = 1, y = 0, labelPosition = 'center', text = 'New text', disableLatex = false) {
|
||||||
if(name == null) name = Common.getNewName('t')
|
if(name == null) name = Common.getNewName('t')
|
||||||
super(name, visible, color, labelContent)
|
super(name, visible, color, labelContent)
|
||||||
this.type = 'Text'
|
this.type = 'Point'
|
||||||
if(typeof x == 'number' || typeof x == 'string') x = new MathLib.Expression(x.toString())
|
if(typeof x == 'number' || typeof x == 'string') x = new MathLib.Expression(x.toString())
|
||||||
this.x = x
|
this.x = x
|
||||||
if(typeof y == 'number' || typeof y == 'string') y = new MathLib.Expression(y.toString())
|
if(typeof y == 'number' || typeof y == 'string') y = new MathLib.Expression(y.toString())
|
||||||
|
|
Loading…
Reference in a new issue