Fixing tons of bugs.
All checks were successful
continuous-integration/drone/push Build is passing

1. Height of object list items should be adaptable to image's heights.
2. Fixed object positioning
3. Buttons of object rows are now vertically centered.
4. Fixing expr-eval not recognizing certain characters as part of the variable.
5. Fixing silent error when misentering variables preventing you from changing the expression again.
6. Fixing points in gains and phases having name-related issues.
7. (in the previous commit) Fixing invisible buttons at the end of the object row when not changing tabs.
This commit is contained in:
Adsooi 2022-10-18 02:55:15 +02:00
parent 9facc2389c
commit f76b601139
Signed by: Ad5001
GPG key ID: 7251B1AF90B960F9
7 changed files with 34 additions and 22 deletions

View file

@ -46,8 +46,9 @@ Item {
property var posPicker property var posPicker
property alias objVisible: objVisibilityCheckBox.checked property alias objVisible: objVisibilityCheckBox.checked
property int minHeight: 40
height: 40 height: objDescription.height
width: obj.typeList.width width: obj.typeList.width
CheckBox { CheckBox {
@ -74,17 +75,18 @@ Item {
id: objDescription id: objDescription
anchors.left: objVisibilityCheckBox.right anchors.left: objVisibilityCheckBox.right
anchors.right: deleteButton.left anchors.right: deleteButton.left
height: parent.height height: LatexJS.enabled ? Math.max(parent.minHeight, latexDescription.height+4) : parent.minHeight
verticalAlignment: TextInput.AlignVCenter verticalAlignment: TextInput.AlignVCenter
text: LatexJS.enabled ? "" : obj.getReadableString() text: LatexJS.enabled ? "" : obj.getReadableString()
font.pixelSize: 14 font.pixelSize: 14
Image { Image {
id: latexDescription
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
visible: LatexJS.enabled visible: LatexJS.enabled
property double depth: 2 property double depth: 2
property var ltxInfo: visible ? Latex.render(obj.getLatexLabel(), depth*parent.font.pixelSize, parent.color).split(",") : ["","0","0"] property var ltxInfo: visible ? Latex.render(obj.getLatexString(), depth*parent.font.pixelSize+4, parent.color).split(",") : ["","0","0"]
source: visible ? ltxInfo[0] : "" source: visible ? ltxInfo[0] : ""
width: parseInt(ltxInfo[1])/depth width: parseInt(ltxInfo[1])/depth
height: parseInt(ltxInfo[2])/depth height: parseInt(ltxInfo[2])/depth
@ -94,7 +96,7 @@ Item {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
objEditor.obj = Objects.currentObjects[obj.type][index] objEditor.obj = Objects.currentObjects[obj.type][index]
objEditor.obj.type = obj.type objEditor.objType = obj.type
objEditor.objIndex = index objEditor.objIndex = index
//objEditor.editingRow = objectRow //objEditor.editingRow = objectRow
objEditor.show() objEditor.show()
@ -108,7 +110,7 @@ Item {
height: width height: width
anchors.right: deleteButton.left anchors.right: deleteButton.left
anchors.rightMargin: 5 anchors.rightMargin: 5
anchors.topMargin: 5 anchors.verticalCenter: parent.verticalCenter
Setting.Icon { Setting.Icon {
id: icon id: icon
@ -127,6 +129,7 @@ Item {
ToolTip.text: qsTr("Set %1 %2 position").arg(obj.constructor.displayType()).arg(obj.name) ToolTip.text: qsTr("Set %1 %2 position").arg(obj.constructor.displayType()).arg(obj.name)
onClicked: { onClicked: {
console.log(obj.type, obj.name)
posPicker.objType = obj.type posPicker.objType = obj.type
posPicker.objName = obj.name posPicker.objName = obj.name
posPicker.pickX = hasXProp posPicker.pickX = hasXProp
@ -140,11 +143,11 @@ Item {
Button { Button {
id: deleteButton id: deleteButton
width: parent.height - 10 width: parent.minHeight - 10
height: width height: width
anchors.right: colorPickRect.left anchors.right: colorPickRect.left
anchors.rightMargin: 5 anchors.rightMargin: 5
anchors.topMargin: 5 anchors.verticalCenter: parent.verticalCenter
icon.name: 'delete' icon.name: 'delete'
icon.source: '../icons/common/delete.svg' icon.source: '../icons/common/delete.svg'
icon.color: sysPalette.buttonText icon.color: sysPalette.buttonText
@ -164,9 +167,9 @@ Item {
id: colorPickRect id: colorPickRect
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 5 anchors.rightMargin: 5
anchors.topMargin: 5 anchors.verticalCenter: parent.verticalCenter
color: obj.color color: obj.color
width: parent.height - 10 width: parent.minHeight - 10
height: width height: width
radius: Math.min(width, height) radius: Math.min(width, height)
border.width: 2 border.width: 2

View file

@ -49,7 +49,7 @@ Item {
//smooth: true //smooth: true
visible: false visible: false
sourceSize.width: width*2 sourceSize.width: width*2
sourceSize.height: sourceSize.width sourceSize.height: width*2
} }
ColorOverlay { ColorOverlay {
anchors.fill: img anchors.fill: img

View file

@ -165,7 +165,6 @@ Item {
"ₜ","¹","²","³","⁴","⁵","⁶", "ₜ","¹","²","³","⁴","⁵","⁶",
"⁷","⁸","⁹","⁰","₁","₂","₃", "⁷","⁸","⁹","⁰","₁","₂","₃",
"₄","₅","₆","₇","₈","₉","₀" "₄","₅","₆","₇","₈","₉","₀"
] ]
Repeater { Repeater {
model: parent.insertChars.length model: parent.insertChars.length

View file

@ -16,6 +16,19 @@ var IMEMBER = 'IMEMBER';
var IENDSTATEMENT = 'IENDSTATEMENT'; var IENDSTATEMENT = 'IENDSTATEMENT';
var IARRAY = 'IARRAY'; var IARRAY = 'IARRAY';
// Additional variable characters.
var ADDITIONAL_VARCHARS = [
"α","β","γ","δ","ε","ζ","η",
"π","θ","κ","λ","μ","ξ","ρ",
"ς","σ","τ","φ","χ","ψ","ω",
"Γ","Δ","Θ","Λ","Ξ","Π","Σ",
"Φ","Ψ","Ω","ₐ","ₑ","ₒ","ₓ",
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
"ₜ","¹","²","³","⁴","⁵","⁶",
"⁷","⁸","⁹","⁰","₁","₂","₃",
"₄","₅","₆","₇","₈","₉","₀"
]
function Instruction(type, value) { function Instruction(type, value) {
this.type = type; this.type = type;
this.value = (value !== undefined && value !== null) ? value : 0; this.value = (value !== undefined && value !== null) ? value : 0;
@ -707,7 +720,7 @@ TokenStream.prototype.isName = function () {
var hasLetter = false; var hasLetter = false;
for (; i < this.expression.length; i++) { for (; i < this.expression.length; i++) {
var c = this.expression.charAt(i); var c = this.expression.charAt(i);
if (c.toUpperCase() === c.toLowerCase()) { if (c.toUpperCase() === c.toLowerCase() && !ADDITIONAL_VARCHARS.includes(c)) {
if (i === this.pos && (c === '$' || c === '_')) { if (i === this.pos && (c === '$' || c === '_')) {
if (c === '_') { if (c === '_') {
hasLetter = true; hasLetter = true;

View file

@ -200,8 +200,10 @@ 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()) {
this.requires.push(C.currentObjectsByName[objName]) if(objName in C.currentObjectsByName) {
C.currentObjectsByName[objName].requiredBy.push(this) this.requires.push(C.currentObjectsByName[objName])
C.currentObjectsByName[objName].requiredBy.push(this)
}
} }
if(this[property].cached && this[property].requiredObjects().length > 0) if(this[property].cached && this[property].requiredObjects().length > 0)
// Recalculate // Recalculate

View file

@ -52,11 +52,9 @@ class GainBode extends Common.ExecutableObject {
om_0 = Objects.currentObjectsByName[om_0] om_0 = Objects.currentObjectsByName[om_0]
if(om_0 == null) { if(om_0 == null) {
// Create new point // Create new point
om_0 = Objects.createNewRegisteredObject('Point') om_0 = Objects.createNewRegisteredObject('Point', [Common.getNewName('ω'), true, this.color, 'name'])
om_0.name = Common.getNewName('ω')
om_0.labelContent = 'name'
om_0.color = this.color
HistoryLib.history.addToHistory(new HistoryLib.CreateNewObject(om_0.name, 'Point', om_0.export())) HistoryLib.history.addToHistory(new HistoryLib.CreateNewObject(om_0.name, 'Point', om_0.export()))
om_0.update()
labelPosition = 'below' labelPosition = 'below'
} }
om_0.requiredBy.push(this) om_0.requiredBy.push(this)

View file

@ -51,10 +51,7 @@ class PhaseBode extends Common.ExecutableObject {
om_0 = Objects.currentObjectsByName[om_0] om_0 = Objects.currentObjectsByName[om_0]
if(om_0 == null) { if(om_0 == null) {
// Create new point // Create new point
om_0 = Objects.createNewRegisteredObject('Point') om_0 = Objects.createNewRegisteredObject('Point', [Common.getNewName('ω'), this.color, 'name'])
om_0.name = Common.getNewName('ω')
om_0.color = this.color
om_0.labelContent = 'name'
om_0.labelPosition = this.phase.execute() >= 0 ? 'above' : 'below' om_0.labelPosition = this.phase.execute() >= 0 ? 'above' : 'below'
HistoryLib.history.addToHistory(new HistoryLib.CreateNewObject(om_0.name, 'Point', om_0.export())) HistoryLib.history.addToHistory(new HistoryLib.CreateNewObject(om_0.name, 'Point', om_0.export()))
labelPosition = 'below' labelPosition = 'below'