Display/Hide scales (not saved yet)

This commit is contained in:
Adsooi 2021-01-26 18:36:21 +01:00
parent 6d1c3d5450
commit 018ad08348
3 changed files with 50 additions and 20 deletions

View file

@ -107,6 +107,8 @@ ApplicationWindow {
yaxisstep: settings.yaxisstep
xaxisstep: settings.xaxisstep
logscalex: settings.logscalex
showxgrad: settings.showxgrad
showygrad: settings.showygrad
onPaint: {
var ctx = getContext("2d");

View file

@ -39,6 +39,8 @@ Canvas {
property string ylabel: ""
property int maxgradx: 8
property bool logscalex: false
property bool showxgrad: false
property bool showygrad: false
property var yaxisstepExpr: (new MathLib.Expression(`x*(${yaxisstep})`))
property double yaxisstep1: yaxisstepExpr.execute(1)
@ -121,6 +123,7 @@ Canvas {
ctx.font = "12px sans-serif"
var txtMinus = ctx.measureText('-').width
if(showxgrad) {
if(logscalex) {
for(var xpow = -maxgradx; xpow <= maxgradx; xpow+=1) {
var textSize = ctx.measureText("10"+Utils.textsup(xpow)).width
@ -136,6 +139,8 @@ Canvas {
drawVisibleText(ctx, '-'+txtX, x2px(-drawX)-4, axisxpx+6+textSize)
}
}
}
if(showygrad) {
for(var y = 0; y < drawMaxY; y += 1) {
var drawY = y*yaxisstep1
var txtY = yaxisstepExpr.simplify(y)
@ -144,6 +149,7 @@ Canvas {
if(y != 0)
drawVisibleText(ctx, '-'+txtY, axisypx-6-textSize-txtMinus, y2px(-drawY)+4)
}
}
ctx.fillStyle = "#FFFFFF"
}

View file

@ -40,6 +40,8 @@ Column {
property string yaxislabel: ""
property bool logscalex: true
property string saveFilename: ""
property bool showxgrad: true
property bool showygrad: true
FileDialog {
id: fdiag
@ -199,6 +201,26 @@ Column {
}
}
CheckBox {
id: showXGrad
checked: settings.showxgrad
text: 'Show X graduation'
onClicked: {
settings.showxgrad = checked
settings.changed()
}
}
CheckBox {
id: showYGrad
checked: settings.showygrad
text: 'Show Y graduation'
onClicked: {
settings.showygrad = checked
settings.changed()
}
}
Button {
id: copyToClipboard
height: 30