Labels for bode gains, fixing bugs
This commit is contained in:
parent
37c9772e94
commit
8673c89c15
5 changed files with 61 additions and 37 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,6 +15,7 @@ build
|
||||||
docs/html
|
docs/html
|
||||||
.directory
|
.directory
|
||||||
loggraph.kdev4
|
loggraph.kdev4
|
||||||
|
*.json
|
||||||
.kdev4
|
.kdev4
|
||||||
AccountFree.pro
|
AccountFree.pro
|
||||||
AccountFree.pro.user
|
AccountFree.pro.user
|
||||||
|
|
|
@ -72,6 +72,8 @@ ApplicationWindow {
|
||||||
currentIndex: sidebarSelector.currentIndex
|
currentIndex: sidebarSelector.currentIndex
|
||||||
anchors.top: sidebarSelector.bottom
|
anchors.top: sidebarSelector.bottom
|
||||||
height: parent.height - sidebarSelector.height
|
height: parent.height - sidebarSelector.height
|
||||||
|
z: -1
|
||||||
|
clip: true
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: settings
|
id: settings
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
import "js/utils.js" as Utils
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
id: settings
|
id: settings
|
||||||
|
@ -133,7 +134,7 @@ Grid {
|
||||||
width: settings.settingWidth
|
width: settings.settingWidth
|
||||||
defValue: settings.xaxislabel
|
defValue: settings.xaxislabel
|
||||||
onChanged: function(newValue) {
|
onChanged: function(newValue) {
|
||||||
settings.xaxislabel = newValue
|
settings.xaxislabel = Utils.parseName(newValue, false)
|
||||||
settings.changed()
|
settings.changed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +146,7 @@ Grid {
|
||||||
width: settings.settingWidth
|
width: settings.settingWidth
|
||||||
defValue: settings.yaxislabel
|
defValue: settings.yaxislabel
|
||||||
onChanged: function(newValue) {
|
onChanged: function(newValue) {
|
||||||
settings.yaxislabel = newValue
|
settings.yaxislabel = Utils.parseName(newValue, false)
|
||||||
settings.changed()
|
settings.changed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ class DrawableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
getRandomColor() {
|
getRandomColor() {
|
||||||
var x = '0123456789ABCDEF';
|
var x = '0123456789'; // Removing ABCDEF for less flashy colors.
|
||||||
var color = '#';
|
var color = '#';
|
||||||
for (var i = 0; i < 6; i++) {
|
for (var i = 0; i < 6; i++) {
|
||||||
color += x[Math.floor(Math.random() * 16)];
|
color += x[Math.floor(Math.random() * 10)];
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ class GainBode extends DrawableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
getReadableString() {
|
getReadableString() {
|
||||||
return `${this.name}: ${this.pass}-pass, ω₀=${this.ω_0.x}, ${this.gain.toString(true)} dB/dec.`
|
return `${this.name}: ${this.pass}-pass; ω₀ = ${this.ω_0.x}\n ${' '.repeat(this.name.length)}${this.gain.toString(true)} dB/dec.`
|
||||||
}
|
}
|
||||||
|
|
||||||
export() {
|
export() {
|
||||||
|
@ -282,6 +282,26 @@ class GainBode extends DrawableObject {
|
||||||
inDrawDom = MathLib.parseDomain(`]${this.ω_0.x};+inf[`)
|
inDrawDom = MathLib.parseDomain(`]${this.ω_0.x};+inf[`)
|
||||||
}
|
}
|
||||||
Function.drawFunction(canvas, ctx, dbfn, inDrawDom, MathLib.Domain.R)
|
Function.drawFunction(canvas, ctx, dbfn, inDrawDom, MathLib.Domain.R)
|
||||||
|
|
||||||
|
// Label
|
||||||
|
var text = this.getLabel()
|
||||||
|
ctx.font = "14px sans-serif"
|
||||||
|
var textSize = canvas.measureText(ctx, text)
|
||||||
|
var posX = canvas.x2px(this.labelX)
|
||||||
|
var posY
|
||||||
|
if((this.pass == 'high' && this.labelX < this.ω_0.x) || (this.pass == 'low' && this.labelX > this.ω_0.x)) {
|
||||||
|
posY = canvas.y2px(dbfn.evaluate(this.labelX))
|
||||||
|
} else {
|
||||||
|
posY = base[1]
|
||||||
|
}
|
||||||
|
switch(this.labelPos) {
|
||||||
|
case 'above':
|
||||||
|
canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY-textSize.height)
|
||||||
|
break;
|
||||||
|
case 'below':
|
||||||
|
canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY+textSize.height)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,39 +147,39 @@ function makeExpressionReadable(str) {
|
||||||
function parseName(str, removeUnallowed = true) {
|
function parseName(str, removeUnallowed = true) {
|
||||||
var replacements = [
|
var replacements = [
|
||||||
// Greek letters
|
// Greek letters
|
||||||
[/(\s|^)al(pha)?[^a-z]/g, 'α'],
|
[/([^a-z]|^)al(pha)?([^a-z]|$)/g, '$1α$3'],
|
||||||
[/(\s|^)be(ta)?[^a-z]/g, 'β'],
|
[/([^a-z]|^)be(ta)?([^a-z]|$)/g, '$1β$3'],
|
||||||
[/(\s|^)ga(mma)?[^a-z]/g, 'γ'],
|
[/([^a-z]|^)ga(mma)?([^a-z]|$)/g, '$1γ$3'],
|
||||||
[/(\s|^)de(lta)?[^a-z]/g, 'δ'],
|
[/([^a-z]|^)de(lta)?([^a-z]|$)/g, '$1δ$3'],
|
||||||
[/(\s|^)ep(silon)?[^a-z]/g, 'ε'],
|
[/([^a-z]|^)ep(silon)?([^a-z]|$)/g, '$1ε$3'],
|
||||||
[/(\s|^)ze(ta)?[^a-z]/g, 'ζ'],
|
[/([^a-z]|^)ze(ta)?([^a-z]|$)/g, '$1ζ$3'],
|
||||||
[/(\s|^)et(a)?[^a-z]/g, 'η'],
|
[/([^a-z]|^)et(a)?([^a-z]|$)/g, '$1η$3'],
|
||||||
[/(\s|^)th(eta)?[^a-z]/g, 'θ'],
|
[/([^a-z]|^)th(eta)?([^a-z]|$)/g, '$1θ$3'],
|
||||||
[/(\s|^)io(ta)?[^a-z]/g, 'ι'],
|
[/([^a-z]|^)io(ta)?([^a-z]|$)/g, '$1ι$3'],
|
||||||
[/(\s|^)ka(ppa)[^a-z]?/g, 'κ'],
|
[/([^a-z]|^)ka(ppa)([^a-z]|$)?/g, '$1κ$3'],
|
||||||
[/(\s|^)la(mbda)?[^a-z]/g, 'λ'],
|
[/([^a-z]|^)la(mbda)?([^a-z]|$)/g, '$1λ$3'],
|
||||||
[/(\s|^)mu[^a-z]/g, 'μ'],
|
[/([^a-z]|^)mu([^a-z]|$)/g, '$1μ$2'],
|
||||||
[/(\s|^)nu[^a-z]/g, 'ν'],
|
[/([^a-z]|^)nu([^a-z]|$)/g, '$1ν$2'],
|
||||||
[/(\s|^)xi[^a-z]/g, 'ξ'],
|
[/([^a-z]|^)xi([^a-z]|$)/g, '$1ξ$2'],
|
||||||
[/(\s|^)rh(o)?[^a-z]/g, 'ρ'],
|
[/([^a-z]|^)rh(o)?([^a-z]|$)/g, '$1ρ$3'],
|
||||||
[/(\s|^)si(gma)?[^a-z]/g, 'σ'],
|
[/([^a-z]|^)si(gma)?([^a-z]|$)/g, '$1σ$3'],
|
||||||
[/(\s|^)ta(u)?[^a-z]/g, 'τ'],
|
[/([^a-z]|^)ta(u)?([^a-z]|$)/g, '$1τ$3'],
|
||||||
[/(\s|^)up(silon)?[^a-z]/g, 'υ'],
|
[/([^a-z]|^)up(silon)?([^a-z]|$)/g, '$1υ$3'],
|
||||||
[/(\s|^)ph(i)?[^a-z]/g, 'φ'],
|
[/([^a-z]|^)ph(i)?([^a-z]|$)/g, '$1φ$3'],
|
||||||
[/(\s|^)ch(i)?[^a-z]/g, 'χ'],
|
[/([^a-z]|^)ch(i)?([^a-z]|$)/g, '$1χ$3'],
|
||||||
[/(\s|^)ps(i)?[^a-z]/g, 'ψ'],
|
[/([^a-z]|^)ps(i)?([^a-z]|$)/g, '$1ψ$3'],
|
||||||
[/(\s|^)om(ega)?[^a-z]/g, 'ω'],
|
[/([^a-z]|^)om(ega)?([^a-z]|$)/g, '$1ω$3'],
|
||||||
// Capital greek letters
|
// Capital greek letters
|
||||||
[/(\s|^)gga(mma)?[^a-z]/g, 'Γ'],
|
[/([^a-z]|^)gga(mma)?([^a-z]|$)/g, '$1Γ$3'],
|
||||||
[/(\s|^)gde(lta)?[^a-z]/g, 'Δ'],
|
[/([^a-z]|^)gde(lta)?([^a-z]|$)/g, '$1Δ$3'],
|
||||||
[/(\s|^)gth(eta)?[^a-z]/g, 'Θ'],
|
[/([^a-z]|^)gth(eta)?([^a-z]|$)/g, '$1Θ$3'],
|
||||||
[/(\s|^)gla(mbda)?[^a-z]/g, 'Λ'],
|
[/([^a-z]|^)gla(mbda)?([^a-z]|$)/g, '$1Λ$3'],
|
||||||
[/(\s|^)gxi[^a-z]/g, 'Ξ'],
|
[/([^a-z]|^)gxi([^a-z]|$)/g, '$1Ξ$2'],
|
||||||
[/(\s|^)gpi[^a-z]/g, 'Π'],
|
[/([^a-z]|^)gpi([^a-z]|$)/g, '$1Π$2'],
|
||||||
[/(\s|^)gsi(gma)[^a-z]?/g, 'Σ'],
|
[/([^a-z]|^)gsi(gma)([^a-z]|$)?/g, '$1Σ$3'],
|
||||||
[/(\s|^)gph(i)?[^a-z]/g, 'Φ'],
|
[/([^a-z]|^)gph(i)?([^a-z]|$)/g, '$1Φ$3'],
|
||||||
[/(\s|^)gps(i)?[^a-z]/g, 'Ψ'],
|
[/([^a-z]|^)gps(i)?([^a-z]|$)/g, '$1Ψ$3'],
|
||||||
[/(\s|^)gom(ega)?[^a-z]/g, 'Ω'],
|
[/([^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) }],
|
||||||
|
|
Loading…
Reference in a new issue