Compare commits
4 commits
b8d312bb23
...
f76b601139
Author | SHA1 | Date | |
---|---|---|---|
f76b601139 | |||
9facc2389c | |||
15fd660e0c | |||
dfdd576296 |
11 changed files with 237 additions and 159 deletions
|
@ -21,14 +21,13 @@ import QtQuick.Dialogs 1.3 as D
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||||
import "../js/objects.js" as Objects
|
import "../js/objects.js" as Objects
|
||||||
import "../js/historylib.js" as HistoryLib
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmltype ObjectLists
|
\qmltype ObjectLists
|
||||||
\inqmlmodule eu.ad5001.LogarithmPlotter
|
\inqmlmodule eu.ad5001.LogarithmPlotter
|
||||||
\brief Tab of the drawer that allows the user to manage the objects.
|
\brief Tab of the drawer that allows the user to manage the objects.
|
||||||
|
|
||||||
This item allows the user to syntheticly see all objects, while giving the user the ability
|
This item allows the user to synthetically see all objects, while giving the user the ability
|
||||||
to show, hide, delete, change the location and color, as well as opening the editor dialog
|
to show, hide, delete, change the location and color, as well as opening the editor dialog
|
||||||
for each object.
|
for each object.
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ ScrollView {
|
||||||
ListView {
|
ListView {
|
||||||
id: objectsListView
|
id: objectsListView
|
||||||
model: Object.keys(Objects.types)
|
model: Object.keys(Objects.types)
|
||||||
width: implicitWidth //objectListList.width - (implicitHeight > objectListList.parent.height ? 20 : 0)
|
//width: implicitWidth //objectListList.width - (implicitHeight > objectListList.parent.height ? 20 : 0)
|
||||||
implicitHeight: contentItem.childrenRect.height + footer.height + 10
|
implicitHeight: contentItem.childrenRect.height + footer.height + 10
|
||||||
|
|
||||||
delegate: ListView {
|
delegate: ListView {
|
||||||
|
@ -89,146 +88,18 @@ ScrollView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Item {
|
delegate: ObjectRow {
|
||||||
id: controlRow
|
id: controlRow
|
||||||
property var obj: Objects.currentObjects[objType][index]
|
|
||||||
property alias objVisible: objVisibilityCheckBox.checked
|
|
||||||
height: 40
|
|
||||||
width: objTypeList.width
|
width: objTypeList.width
|
||||||
|
obj: Objects.currentObjects[objType][index]
|
||||||
|
posPicker: positionPicker
|
||||||
|
|
||||||
|
onChanged: {
|
||||||
|
//obj = Objects.currentObjects[objType][index]
|
||||||
|
objectListList.update()
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: objTypeList.editingRows.push(controlRow)
|
Component.onCompleted: objTypeList.editingRows.push(controlRow)
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: objVisibilityCheckBox
|
|
||||||
checked: Objects.currentObjects[objType][index].visible
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: 5
|
|
||||||
onClicked: {
|
|
||||||
history.addToHistory(new HistoryLib.EditedVisibility(
|
|
||||||
Objects.currentObjects[objType][index].name, objType, this.checked
|
|
||||||
))
|
|
||||||
Objects.currentObjects[objType][index].visible = this.checked
|
|
||||||
objectListList.changed()
|
|
||||||
controlRow.obj = Objects.currentObjects[objType][index]
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolTip.visible: hovered
|
|
||||||
ToolTip.text: checked ?
|
|
||||||
qsTr("Hide %1 %2").arg(Objects.types[objType].displayType()).arg(obj.name) :
|
|
||||||
qsTr("Show %1 %2").arg(Objects.types[objType].displayType()).arg(obj.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: objDescription
|
|
||||||
anchors.left: objVisibilityCheckBox.right
|
|
||||||
anchors.right: deleteButton.left
|
|
||||||
height: parent.height
|
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
|
||||||
text: obj.getReadableString()
|
|
||||||
font.pixelSize: 14
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
objEditor.obj = Objects.currentObjects[objType][index]
|
|
||||||
objEditor.objType = objType
|
|
||||||
objEditor.objIndex = index
|
|
||||||
//objEditor.editingRow = controlRow
|
|
||||||
objEditor.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
id: pointerButton
|
|
||||||
width: parent.height - 10
|
|
||||||
height: width
|
|
||||||
anchors.right: deleteButton.left
|
|
||||||
anchors.rightMargin: 5
|
|
||||||
anchors.topMargin: 5
|
|
||||||
|
|
||||||
Setting.Icon {
|
|
||||||
id: icon
|
|
||||||
width: 18
|
|
||||||
height: 18
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
color: sysPalette.windowText
|
|
||||||
source: '../icons/common/position.svg'
|
|
||||||
}
|
|
||||||
|
|
||||||
property bool hasXProp: Objects.types[objType].properties().hasOwnProperty('x')
|
|
||||||
property bool hasYProp: Objects.types[objType].properties().hasOwnProperty('y')
|
|
||||||
visible: hasXProp || hasYProp
|
|
||||||
ToolTip.visible: hovered
|
|
||||||
ToolTip.text: qsTr("Set %1 %2 position").arg(Objects.types[objType].displayType()).arg(obj.name)
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
positionPicker.objType = objType
|
|
||||||
positionPicker.objName = obj.name
|
|
||||||
positionPicker.pickX = hasXProp
|
|
||||||
positionPicker.pickY = hasYProp
|
|
||||||
positionPicker.propertyX = 'x'
|
|
||||||
positionPicker.propertyY = 'y'
|
|
||||||
positionPicker.visible = true
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
id: deleteButton
|
|
||||||
width: parent.height - 10
|
|
||||||
height: width
|
|
||||||
anchors.right: colorPickRect.left
|
|
||||||
anchors.rightMargin: 5
|
|
||||||
anchors.topMargin: 5
|
|
||||||
icon.name: 'delete'
|
|
||||||
icon.source: '../icons/common/delete.svg'
|
|
||||||
icon.color: sysPalette.buttonText
|
|
||||||
ToolTip.visible: hovered
|
|
||||||
ToolTip.text: qsTr("Delete %1 %2").arg(Objects.types[objType].displayType()).arg(obj.name)
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
history.addToHistory(new HistoryLib.DeleteObject(
|
|
||||||
obj.name, objType, obj.export()
|
|
||||||
))
|
|
||||||
Objects.deleteObject(obj.name)
|
|
||||||
objectListList.update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: colorPickRect
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: 5
|
|
||||||
anchors.topMargin: 5
|
|
||||||
color: obj.color
|
|
||||||
width: parent.height - 10
|
|
||||||
height: width
|
|
||||||
radius: Math.min(width, height)
|
|
||||||
border.width: 2
|
|
||||||
border.color: sysPalette.windowText
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: pickColor.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
D.ColorDialog {
|
|
||||||
id: pickColor
|
|
||||||
color: obj.color
|
|
||||||
title: qsTr("Pick new color for %1 %2").arg(Objects.types[objType].displayType()).arg(obj.name)
|
|
||||||
onAccepted: {
|
|
||||||
history.addToHistory(new HistoryLib.ColorChanged(
|
|
||||||
obj.name, objType, obj.color, color.toString()
|
|
||||||
))
|
|
||||||
obj.color = color.toString()
|
|
||||||
controlRow.obj = Objects.currentObjects[objType][index]
|
|
||||||
objectListList.update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,196 @@
|
||||||
|
/**
|
||||||
|
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
|
||||||
|
* Copyright (C) 2022 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.12
|
||||||
|
import QtQuick.Dialogs 1.3 as D
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||||
|
import "../js/objects.js" as Objects
|
||||||
|
import "../js/historylib.js" as HistoryLib
|
||||||
|
import "../js/math/latex.js" as LatexJS
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmltype ObjectRow
|
||||||
|
\inqmlmodule eu.ad5001.LogarithmPlotter
|
||||||
|
\brief Row describing an object.
|
||||||
|
|
||||||
|
This item allows the user to see, control, and modify a graph object.
|
||||||
|
It includes the visibility checkbox, the description label (optionally latex if enabled),
|
||||||
|
the reposition and delete buttons, and the color picker.
|
||||||
|
|
||||||
|
|
||||||
|
\sa LogarithmPlotter, ObjectCreationGrid, ObjectLists
|
||||||
|
*/
|
||||||
|
Item {
|
||||||
|
id: objectRow
|
||||||
|
|
||||||
|
signal changed()
|
||||||
|
|
||||||
|
property var obj
|
||||||
|
property var posPicker
|
||||||
|
|
||||||
|
property alias objVisible: objVisibilityCheckBox.checked
|
||||||
|
property int minHeight: 40
|
||||||
|
|
||||||
|
height: objDescription.height
|
||||||
|
width: obj.typeList.width
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: objVisibilityCheckBox
|
||||||
|
checked: obj.visible
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
onClicked: {
|
||||||
|
history.addToHistory(new HistoryLib.EditedVisibility(
|
||||||
|
obj.name, obj.type, this.checked
|
||||||
|
))
|
||||||
|
obj.visible = this.checked
|
||||||
|
changed()
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: checked ?
|
||||||
|
qsTr("Hide %1 %2").arg(obj.constructor.displayType()).arg(obj.name) :
|
||||||
|
qsTr("Show %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: objDescription
|
||||||
|
anchors.left: objVisibilityCheckBox.right
|
||||||
|
anchors.right: deleteButton.left
|
||||||
|
height: LatexJS.enabled ? Math.max(parent.minHeight, latexDescription.height+4) : parent.minHeight
|
||||||
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
|
text: LatexJS.enabled ? "" : obj.getReadableString()
|
||||||
|
font.pixelSize: 14
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: latexDescription
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: parent.left
|
||||||
|
visible: LatexJS.enabled
|
||||||
|
property double depth: 2
|
||||||
|
property var ltxInfo: visible ? Latex.render(obj.getLatexString(), depth*parent.font.pixelSize+4, parent.color).split(",") : ["","0","0"]
|
||||||
|
source: visible ? ltxInfo[0] : ""
|
||||||
|
width: parseInt(ltxInfo[1])/depth
|
||||||
|
height: parseInt(ltxInfo[2])/depth
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
objEditor.obj = Objects.currentObjects[obj.type][index]
|
||||||
|
objEditor.objType = obj.type
|
||||||
|
objEditor.objIndex = index
|
||||||
|
//objEditor.editingRow = objectRow
|
||||||
|
objEditor.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: pointerButton
|
||||||
|
width: parent.height - 10
|
||||||
|
height: width
|
||||||
|
anchors.right: deleteButton.left
|
||||||
|
anchors.rightMargin: 5
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
Setting.Icon {
|
||||||
|
id: icon
|
||||||
|
width: 18
|
||||||
|
height: 18
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
color: sysPalette.windowText
|
||||||
|
source: '../icons/common/position.svg'
|
||||||
|
}
|
||||||
|
|
||||||
|
property bool hasXProp: obj.constructor.properties().hasOwnProperty('x')
|
||||||
|
property bool hasYProp: obj.constructor.properties().hasOwnProperty('y')
|
||||||
|
visible: hasXProp || hasYProp
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: qsTr("Set %1 %2 position").arg(obj.constructor.displayType()).arg(obj.name)
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
console.log(obj.type, obj.name)
|
||||||
|
posPicker.objType = obj.type
|
||||||
|
posPicker.objName = obj.name
|
||||||
|
posPicker.pickX = hasXProp
|
||||||
|
posPicker.pickY = hasYProp
|
||||||
|
posPicker.propertyX = 'x'
|
||||||
|
posPicker.propertyY = 'y'
|
||||||
|
posPicker.visible = true
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: deleteButton
|
||||||
|
width: parent.minHeight - 10
|
||||||
|
height: width
|
||||||
|
anchors.right: colorPickRect.left
|
||||||
|
anchors.rightMargin: 5
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
icon.name: 'delete'
|
||||||
|
icon.source: '../icons/common/delete.svg'
|
||||||
|
icon.color: sysPalette.buttonText
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: qsTr("Delete %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
history.addToHistory(new HistoryLib.DeleteObject(
|
||||||
|
obj.name, obj.type, obj.export()
|
||||||
|
))
|
||||||
|
Objects.deleteObject(obj.name)
|
||||||
|
changed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: colorPickRect
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 5
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
color: obj.color
|
||||||
|
width: parent.minHeight - 10
|
||||||
|
height: width
|
||||||
|
radius: Math.min(width, height)
|
||||||
|
border.width: 2
|
||||||
|
border.color: sysPalette.windowText
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: pickColor.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
D.ColorDialog {
|
||||||
|
id: pickColor
|
||||||
|
color: obj.color
|
||||||
|
title: qsTr("Pick new color for %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
|
||||||
|
onAccepted: {
|
||||||
|
history.addToHistory(new HistoryLib.ColorChanged(
|
||||||
|
obj.name, obj.type, obj.color, color.toString()
|
||||||
|
))
|
||||||
|
obj.color = color.toString()
|
||||||
|
changed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,5 +2,5 @@ module eu.ad5001.LogarithmPlotter.ObjectLists
|
||||||
|
|
||||||
ObjectLists 1.0 ObjectLists.qml
|
ObjectLists 1.0 ObjectLists.qml
|
||||||
ObjectCreationGrid 1.0 ObjectCreationGrid.qml
|
ObjectCreationGrid 1.0 ObjectCreationGrid.qml
|
||||||
|
ObjectRow 1.0 ObjectRow.qml
|
||||||
EditorDialog 1.0 EditorDialog.qml
|
EditorDialog 1.0 EditorDialog.qml
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
//smooth: true
|
//smooth: true
|
||||||
visible: false
|
visible: false
|
||||||
sourceSize.height: sourceSize.width
|
sourceSize.width: width*2
|
||||||
|
sourceSize.height: width*2
|
||||||
}
|
}
|
||||||
ColorOverlay {
|
ColorOverlay {
|
||||||
anchors.fill: img
|
anchors.fill: img
|
||||||
|
|
|
@ -165,7 +165,6 @@ Item {
|
||||||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||||
"₄","₅","₆","₇","₈","₉","₀"
|
"₄","₅","₆","₇","₈","₉","₀"
|
||||||
|
|
||||||
]
|
]
|
||||||
Repeater {
|
Repeater {
|
||||||
model: parent.insertChars.length
|
model: parent.insertChars.length
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -116,7 +116,7 @@ class EditedProperty extends C.Action {
|
||||||
.arg(this.targetPropertyReadable)
|
.arg(this.targetPropertyReadable)
|
||||||
.arg('<b style="font-size: 15px;"> ' + this.targetName + ' </b>')
|
.arg('<b style="font-size: 15px;"> ' + this.targetName + ' </b>')
|
||||||
.arg('<tt style="background: rgba(128,128,128,0.1);"> '+this.prev+' </tt>')
|
.arg('<tt style="background: rgba(128,128,128,0.1);"> '+this.prev+' </tt>')
|
||||||
.arg('<tt style="background: rgba(128,128,128,0.1);"> '+this.next+'</tt>')
|
.arg('<tt style="background: rgba(128,128,128,0.1);"> '+this.next+' </tt>')
|
||||||
// .arg('<b style="font-size: 15px;">' + Objects.types[this.targetType].displayType())
|
// .arg('<b style="font-size: 15px;">' + Objects.types[this.targetType].displayType())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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'
|
||||||
|
|
|
@ -79,11 +79,11 @@ class Latex(QObject):
|
||||||
@Property(bool)
|
@Property(bool)
|
||||||
def latexSupported(self):
|
def latexSupported(self):
|
||||||
return LATEX_PATH is not None and DVIPNG_PATH is not None
|
return LATEX_PATH is not None and DVIPNG_PATH is not None
|
||||||
|
|
||||||
@Slot(str, float, QColor, result=str)
|
@Slot(str, float, QColor, result=str)
|
||||||
def render(self, latex_markup: str, font_size: float, color: QColor = True) -> str:
|
def render(self, latex_markup: str, font_size: float, color: QColor) -> str:
|
||||||
"""
|
"""
|
||||||
Renders a latex string into a png file.
|
Prepares and renders a latex string into a png file.
|
||||||
"""
|
"""
|
||||||
markup_hash = hash(latex_markup)
|
markup_hash = hash(latex_markup)
|
||||||
export_path = path.join(self.tempdir.name, f'{markup_hash}_{font_size}_{color.rgb()}')
|
export_path = path.join(self.tempdir.name, f'{markup_hash}_{font_size}_{color.rgb()}')
|
||||||
|
@ -100,7 +100,7 @@ class Latex(QObject):
|
||||||
self.convert_dvi_to_png(latex_path, export_path, font_size, color)
|
self.convert_dvi_to_png(latex_path, export_path, font_size, color)
|
||||||
except Exception as e: # One of the processes failed. A message will be sent every time.
|
except Exception as e: # One of the processes failed. A message will be sent every time.
|
||||||
raise e
|
raise e
|
||||||
img = QImage(export_path + ".png");
|
img = QImage(export_path);
|
||||||
# Small hack, not very optimized since we load the image twice, but you can't pass a QImage to QML and expect it to be loaded
|
# Small hack, not very optimized since we load the image twice, but you can't pass a QImage to QML and expect it to be loaded
|
||||||
return f'{export_path}.png,{img.width()},{img.height()}'
|
return f'{export_path}.png,{img.width()},{img.height()}'
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class Latex(QObject):
|
||||||
for i in [".tex", ".aux", ".log"]:
|
for i in [".tex", ".aux", ".log"]:
|
||||||
remove(export_path + i)
|
remove(export_path + i)
|
||||||
|
|
||||||
|
"""
|
||||||
@Slot(str, float, QColor, result=str)
|
@Slot(str, float, QColor, result=str)
|
||||||
def render_legacy(self, latexstring, font_size, color = True):
|
def render_legacy(self, latexstring, font_size, color = True):
|
||||||
exprpath = path.join(self.tempdir.name, f'{hash(latexstring)}_{font_size}_{color.rgb()}.png')
|
exprpath = path.join(self.tempdir.name, f'{hash(latexstring)}_{font_size}_{color.rgb()}.png')
|
||||||
|
@ -190,3 +190,4 @@ class Latex(QObject):
|
||||||
img = QImage(exprpath);
|
img = QImage(exprpath);
|
||||||
# Small hack, not very optimized since we load the image twice, but you can't pass a QImage to QML and expect it to be loaded
|
# Small hack, not very optimized since we load the image twice, but you can't pass a QImage to QML and expect it to be loaded
|
||||||
return f'{exprpath},{img.width()},{img.height()}'
|
return f'{exprpath},{img.width()},{img.height()}'
|
||||||
|
"""
|
||||||
|
|
Loading…
Reference in a new issue