X Axis step & NLog set (all [1...9]*10^n)
This commit is contained in:
parent
ef87b8362c
commit
8aa6ac7e88
6 changed files with 58 additions and 8 deletions
17
qml/Icon.qml
17
qml/Icon.qml
|
@ -1,3 +1,20 @@
|
|||
/**
|
||||
* Logarithm Graph Creator - Create graphs with logarithm scales.
|
||||
* Copyright (C) 2020 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 2.7
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ ApplicationWindow {
|
|||
xlabel: settings.xaxislabel
|
||||
ylabel: settings.yaxislabel
|
||||
yaxisstep: settings.yaxisstep
|
||||
xaxisstep: settings.xaxisstep
|
||||
logscalex: settings.logscalex
|
||||
|
||||
onPaint: {
|
||||
|
@ -125,9 +126,11 @@ ApplicationWindow {
|
|||
"yzoom": settings.yzoom,
|
||||
"xmin": settings.xmin,
|
||||
"ymax": settings.ymax,
|
||||
"xaxisstep": settings.xaxisstep,
|
||||
"yaxisstep": settings.yaxisstep,
|
||||
"xaxislabel": settings.xaxislabel,
|
||||
"yaxislabel": settings.yaxislabel,
|
||||
"logscalex": settings.logscalex,
|
||||
"width": root.width,
|
||||
"height": root.height,
|
||||
"objects": objs,
|
||||
|
@ -142,9 +145,11 @@ ApplicationWindow {
|
|||
settings.yzoom = data["yzoom"]
|
||||
settings.xmin = data["xmin"]
|
||||
settings.ymax = data["ymax"]
|
||||
settings.xaxisstep = data["xaxisstep"]
|
||||
settings.yaxisstep = data["yaxisstep"]
|
||||
settings.xaxislabel = data["xaxislabel"]
|
||||
settings.yaxislabel = data["yaxislabel"]
|
||||
settings.logscalex = data["logscalex"]
|
||||
root.height = data["height"]
|
||||
root.width = data["width"]
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ Canvas {
|
|||
property double ymax: 0
|
||||
property int xzoom: 10
|
||||
property int yzoom: 10
|
||||
property string yaxisstep: "3"
|
||||
property string xaxisstep: "4"
|
||||
property string yaxisstep: "4"
|
||||
property string xlabel: ""
|
||||
property string ylabel: ""
|
||||
property int maxgradx: 8
|
||||
|
@ -42,6 +43,9 @@ Canvas {
|
|||
property var yaxisstepExpr: (new MathLib.Expression(`x*(${yaxisstep})`))
|
||||
property double yaxisstep1: yaxisstepExpr.execute(1)
|
||||
property int drawMaxY: Math.ceil(Math.max(Math.abs(ymax), Math.abs(px2y(canvasSize.height)))/yaxisstep1)
|
||||
property var xaxisstepExpr: (new MathLib.Expression(`x*(${xaxisstep})`))
|
||||
property double xaxisstep1: xaxisstepExpr.execute(1)
|
||||
property int drawMaxX: Math.ceil(Math.max(Math.abs(xmin), Math.abs(px2x(canvasSize.width)))/xaxisstep1)
|
||||
|
||||
|
||||
onPaint: {
|
||||
|
@ -79,10 +83,9 @@ Canvas {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for(var x = 0; x < 40*maxgradx; x+=1) {
|
||||
// TODO: Fill screen based
|
||||
drawXLine(ctx, x*yaxisstep1)
|
||||
drawXLine(ctx, -x*yaxisstep1)
|
||||
for(var x = 0; x < drawMaxX; x+=1) {
|
||||
drawXLine(ctx, x*xaxisstep1)
|
||||
drawXLine(ctx, -x*xaxisstep1)
|
||||
}
|
||||
}
|
||||
for(var y = 0; y < drawMaxY; y+=1) {
|
||||
|
|
|
@ -34,6 +34,7 @@ Column {
|
|||
property int yzoom: 10
|
||||
property double xmin: 5/10
|
||||
property double ymax: 25
|
||||
property string xaxisstep: "4"
|
||||
property string yaxisstep: "4"
|
||||
property string xaxislabel: ""
|
||||
property string yaxislabel: ""
|
||||
|
@ -113,7 +114,6 @@ Column {
|
|||
TextSetting {
|
||||
id: yAxisStep
|
||||
height: 30
|
||||
//isInt: true
|
||||
label: "Y Axis Step"
|
||||
width: settings.settingWidth
|
||||
defValue: settings.yaxisstep
|
||||
|
@ -123,6 +123,19 @@ Column {
|
|||
}
|
||||
}
|
||||
|
||||
TextSetting {
|
||||
id: xAxisStep
|
||||
height: 30
|
||||
label: "X Axis Step"
|
||||
width: settings.settingWidth
|
||||
defValue: settings.xaxisstep
|
||||
visible: !settings.logscalex
|
||||
onChanged: function(newValue) {
|
||||
settings.xaxisstep = newValue
|
||||
settings.changed()
|
||||
}
|
||||
}
|
||||
|
||||
ComboBoxSetting {
|
||||
id: xAxisLabel
|
||||
height: 30
|
||||
|
|
|
@ -132,6 +132,10 @@ class Domain {
|
|||
case "ℤ⁺":
|
||||
return Domain.N
|
||||
break;
|
||||
case "NLOG":
|
||||
case "ℕˡᵒᵍ":
|
||||
return Domain.NLog
|
||||
break;
|
||||
case "NE":
|
||||
case "NP":
|
||||
case "N*":
|
||||
|
@ -536,7 +540,16 @@ Domain.ZM = new SpecialDomain('ℤ⁻', x => x%1==0 && x <= 0,
|
|||
Domain.ZME = new SpecialDomain('ℤ⁻*', x => x%1==0 && x < 0,
|
||||
x => Math.min(Math.floor(x)+1, -1),
|
||||
x => Math.min(Math.ceil(x)-1, -1))
|
||||
|
||||
Domain.NLog = new SpecialDomain('ℕˡᵒᵍ',
|
||||
x => x/Math.pow(10, x.toString().length-1) % 1 == 0 && x > 0,
|
||||
function(x) {
|
||||
var x10pow = Math.pow(10, x.toString().length-1)
|
||||
return Math.max(1, (Math.floor(x/x10pow)+1)*x10pow)
|
||||
},
|
||||
function(x) {
|
||||
var x10pow = Math.pow(10, x.toString().length-1)
|
||||
return Math.max(1, (Math.ceil(x/x10pow)-1)*x10pow)
|
||||
})
|
||||
|
||||
var refedDomains = []
|
||||
|
||||
|
|
|
@ -282,7 +282,6 @@ class Function extends ExecutableObject {
|
|||
var previousY;
|
||||
var draw = function(currentX) {
|
||||
}
|
||||
console.log('Drawing', inDomain, inDomain instanceof MathLib.SpecialDomain)
|
||||
if(inDomain instanceof MathLib.SpecialDomain && inDomain.moveSupported) {
|
||||
previousX = inDomain.previous(previousX)
|
||||
if(previousX === null) previousX = inDomain.next(canvas.px2x(0))
|
||||
|
|
Loading…
Reference in a new issue