Compare commits
3 commits
016a21ecb4
...
9239eac78a
Author | SHA1 | Date | |
---|---|---|---|
9239eac78a | |||
35ce1c4824 | |||
75e70903f1 |
13 changed files with 136 additions and 19 deletions
|
@ -1046,6 +1046,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Ausdruck analysiert: %3</translation>
|
Ausdruck analysiert: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1066,6 +1074,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Ausdruck analysiert: %3</translation>
|
Ausdruck analysiert: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1046,6 +1046,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Evaluated expression: %3</translation>
|
Evaluated expression: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1066,6 +1074,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Evaluated expression: %3</translation>
|
Evaluated expression: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -991,6 +991,14 @@ These settings can be changed at any time from the "Settings" menu.</s
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1008,6 +1016,11 @@ Evaluated expression: %3</source>
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1055,6 +1055,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Formule analysée : %3</translation>
|
Formule analysée : %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1075,6 +1083,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Formule analysée : %3</translation>
|
Formule analysée : %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1046,6 +1046,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Kiértékelt kifejezés: %3</translation>
|
Kiértékelt kifejezés: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1066,6 +1074,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Kiértékelt kifejezés: %3</translation>
|
Kiértékelt kifejezés: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1043,6 +1043,14 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.</tr
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1060,6 +1068,11 @@ Evaluated expression: %3</source>
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -991,6 +991,14 @@ These settings can be changed at any time from the "Settings" menu.</s
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1008,6 +1016,11 @@ Evaluated expression: %3</source>
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Qt.labs.platform as Native
|
||||||
import "js/objects.js" as Objects
|
import "js/objects.js" as Objects
|
||||||
import "js/utils.js" as Utils
|
import "js/utils.js" as Utils
|
||||||
import "js/mathlib.js" as MathLib
|
import "js/mathlib.js" as MathLib
|
||||||
|
@ -170,6 +171,16 @@ Canvas {
|
||||||
|
|
||||||
Component.onCompleted: imageLoaders = {}
|
Component.onCompleted: imageLoaders = {}
|
||||||
|
|
||||||
|
Native.MessageDialog {
|
||||||
|
id: drawingErrorDialog
|
||||||
|
title: qsTranslate("expression", "LogarithmPlotter - Drawing error")
|
||||||
|
text: ""
|
||||||
|
function showDialog(objType, objName, error) {
|
||||||
|
text = qsTranslate("error", "Error while attempting to draw %1 %2:\n%3\n\nUndoing last change.").arg(objType).arg(objName).arg(error)
|
||||||
|
open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onPaint: function(rect) {
|
onPaint: function(rect) {
|
||||||
//console.log('Redrawing')
|
//console.log('Redrawing')
|
||||||
if(rect.width == canvas.width) { // Redraw full canvas
|
if(rect.width == canvas.width) { // Redraw full canvas
|
||||||
|
@ -183,7 +194,14 @@ Canvas {
|
||||||
for(var obj of Objects.currentObjects[objType]){
|
for(var obj of Objects.currentObjects[objType]){
|
||||||
ctx.strokeStyle = obj.color
|
ctx.strokeStyle = obj.color
|
||||||
ctx.fillStyle = obj.color
|
ctx.fillStyle = obj.color
|
||||||
if(obj.visible) obj.draw(canvas, ctx)
|
if(obj.visible)
|
||||||
|
try {
|
||||||
|
obj.draw(canvas, ctx)
|
||||||
|
} catch(e) {
|
||||||
|
// Drawing throws an error. Generally, it's due to a new modification (or the opening of a file)
|
||||||
|
drawingErrorDialog.showDialog(objType, obj.name, e.message)
|
||||||
|
history.undo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.lineWidth = 1
|
ctx.lineWidth = 1
|
||||||
|
|
|
@ -84,11 +84,12 @@ ListView {
|
||||||
Text {
|
Text {
|
||||||
leftPadding: 5
|
leftPadding: 5
|
||||||
text: listFiltered.category
|
text: listFiltered.category
|
||||||
|
color: sysPalette.windowText
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: 1
|
height: 1
|
||||||
color: 'black'
|
color: 'gray'
|
||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,10 @@ function evaluate(tokens, expr, values) {
|
||||||
nstack.push(f.apply(undefined, args));
|
nstack.push(f.apply(undefined, args));
|
||||||
} else if(f.execute) {
|
} else if(f.execute) {
|
||||||
// Objects & expressions execution
|
// Objects & expressions execution
|
||||||
nstack.push(f.execute.apply(f, args));
|
if(args.length >= 1)
|
||||||
|
nstack.push(f.execute.apply(f, args));
|
||||||
|
else
|
||||||
|
throw new Error(qsTranslate('error', 'In order to be executed, object %1 must have at least one argument.').arg(f))
|
||||||
} else {
|
} else {
|
||||||
throw new Error(qsTranslate('error', '%1 cannot be executed.').arg(f));
|
throw new Error(qsTranslate('error', '%1 cannot be executed.').arg(f));
|
||||||
}
|
}
|
||||||
|
@ -1614,16 +1617,20 @@ function arrayIndex(array, index) {
|
||||||
function max(array) {
|
function max(array) {
|
||||||
if (arguments.length === 1 && Array.isArray(array)) {
|
if (arguments.length === 1 && Array.isArray(array)) {
|
||||||
return Math.max.apply(Math, array);
|
return Math.max.apply(Math, array);
|
||||||
} else {
|
} else if(arguments.length >= 1) {
|
||||||
return Math.max.apply(Math, arguments);
|
return Math.max.apply(Math, arguments);
|
||||||
|
} else {
|
||||||
|
throw new EvalError(qsTranslate('error', 'Function %1 must have at least one argument.').arg('max'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function min(array) {
|
function min(array) {
|
||||||
if (arguments.length === 1 && Array.isArray(array)) {
|
if (arguments.length === 1 && Array.isArray(array)) {
|
||||||
return Math.min.apply(Math, array);
|
return Math.min.apply(Math, array);
|
||||||
} else {
|
} else if(arguments.length >= 1) {
|
||||||
return Math.min.apply(Math, arguments);
|
return Math.min.apply(Math, arguments);
|
||||||
|
} else {
|
||||||
|
throw new EvalError(qsTranslate('error', 'Function %1 must have at least one argument.').arg('min'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class InputExpression {
|
||||||
if(!this.atEnd() && this.peek() == char) {
|
if(!this.atEnd() && this.peek() == char) {
|
||||||
this.position++;
|
this.position++;
|
||||||
} else {
|
} else {
|
||||||
this.raise("Unexpected character " + peek() + ". Expected character " + char);
|
this.raise("Unexpected character " + this.peek() + ". Expected character " + char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,16 +216,16 @@ function simplifyExpression(str) {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
// Simple simplifications
|
// Simple simplifications
|
||||||
[/(\s|^|\()0(\.0+)? \* (\([^)(]+\))/g, '$10'],
|
// [/(\s|^|\()0(\.0+)? \* (\([^)(]+\))/g, '$10'],
|
||||||
[/(\s|^|\()0(\.0+)? \* ([^)(+-]+)/g, '$10'],
|
// [/(\s|^|\()0(\.0+)? \* ([^)(+-]+)/g, '$10'],
|
||||||
[/(\([^)(]\)) \* 0(\.0+)?(\s|$|\))/g, '0$3'],
|
// [/(\([^)(]\)) \* 0(\.0+)?(\s|$|\))/g, '0$3'],
|
||||||
[/([^)(+-]) \* 0(\.0+)?(\s|$|\))/g, '0$3'],
|
// [/([^)(+-]) \* 0(\.0+)?(\s|$|\))/g, '0$3'],
|
||||||
[/(\s|^|\()1(\.0+)? (\*|\/) /g, '$1'],
|
// [/(\s|^|\()1(\.0+)? (\*|\/) /g, '$1'],
|
||||||
[/(\s|^|\()0(\.0+)? (\+|\-) /g, '$1'],
|
// [/(\s|^|\()0(\.0+)? (\+|\-) /g, '$1'],
|
||||||
[/ (\*|\/) 1(\.0+)?(\s|$|\))/g, '$3'],
|
// [/ (\*|\/) 1(\.0+)?(\s|$|\))/g, '$3'],
|
||||||
[/ (\+|\-) 0(\.0+)?(\s|$|\))/g, '$3'],
|
// [/ (\+|\-) 0(\.0+)?(\s|$|\))/g, '$3'],
|
||||||
[/(^| |\() /g, '$1'],
|
// [/(^| |\() /g, '$1'],
|
||||||
[/ ($|\))/g, '$1'],
|
// [/ ($|\))/g, '$1'],
|
||||||
]
|
]
|
||||||
|
|
||||||
// Replacements
|
// Replacements
|
||||||
|
@ -271,7 +271,7 @@ function makeExpressionReadable(str) {
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
|
|
||||||
str = simplifyExpression(str)
|
// str = simplifyExpression(str)
|
||||||
// Replacements
|
// Replacements
|
||||||
for(var replacement of replacements)
|
for(var replacement of replacements)
|
||||||
while(replacement[0].test(str))
|
while(replacement[0].test(str))
|
||||||
|
|
Loading…
Reference in a new issue