diff --git a/qml/AppMenuBar.qml b/qml/AppMenuBar.qml
index c5126ed..cbd027f 100644
--- a/qml/AppMenuBar.qml
+++ b/qml/AppMenuBar.qml
@@ -18,6 +18,7 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
+import "js/objects.js" as Objects
MenuBar {
Menu {
@@ -59,6 +60,24 @@ MenuBar {
icon.name: 'editcopy'
}
}
+ Menu {
+ title: qsTr("&Create")
+ // Services repeater
+ Repeater {
+ model: Object.keys(Objects.types)
+
+ MenuItem {
+ text: modelData
+ visible: Objects.types[modelData].createable()
+ height: visible ? implicitHeight : 0
+ icon.source: './icons/'+modelData+'.svg' // Default to dark version
+ onTriggered: {
+ Objects.createNewRegisteredObject(modelData)
+ objectLists.update()
+ }
+ }
+ }
+ }
Menu {
title: qsTr("&Help")
Action { text: qsTr("&About") }
diff --git a/qml/Icon.qml b/qml/Icon.qml
new file mode 100644
index 0000000..a29159f
--- /dev/null
+++ b/qml/Icon.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.7
+import QtGraphicalEffects 1.0
+
+Item {
+ property color color: "#000000"
+ property alias source: img.source
+
+ Image {
+ id: img
+ height: parent.height
+ width: parent.width
+ smooth: true
+ visible: false
+ }
+ ColorOverlay {
+ anchors.fill: img
+ source: img
+ color: parent.color
+ }
+}
diff --git a/qml/LogGraph.qml b/qml/LogGraph.qml
index 742e9f6..7d94c75 100644
--- a/qml/LogGraph.qml
+++ b/qml/LogGraph.qml
@@ -38,7 +38,7 @@ ApplicationWindow {
Drawer {
id: sidebar
- width: 290
+ width: 300
height: parent.height
y: root.menuBar.height
readonly property bool inPortrait: root.width < root.height
@@ -60,30 +60,33 @@ ApplicationWindow {
width: parent.width
anchors.top: topSeparator.bottom
TabButton {
- text: qsTr("Settings")
+ text: qsTr("Objects")
}
TabButton {
- text: qsTr("Objects")
+ text: qsTr("Settings")
}
}
StackLayout {
- width: parent.width
- currentIndex: sidebarSelector.currentIndex
anchors.top: sidebarSelector.bottom
+ anchors.left: parent.left
+ anchors.topMargin: 5
+ anchors.leftMargin: 5
+ width: parent.width - 10
height: parent.height - sidebarSelector.height
+ currentIndex: sidebarSelector.currentIndex
z: -1
clip: true
-
- Settings {
- id: settings
- onChanged: drawCanvas.requestPaint()
- }
ObjectLists {
id: objectLists
onChanged: drawCanvas.requestPaint()
}
+
+ Settings {
+ id: settings
+ onChanged: drawCanvas.requestPaint()
+ }
}
}
@@ -152,13 +155,25 @@ ApplicationWindow {
})
})
// Refreshing sidebar
- Object.keys(objectLists.listViews).forEach(function(type){
- objectLists.listViews[type].model = Objects.currentObjects[type]
- })
- drawCanvas.requestPaint()
+ if(sidebarSelector.currentIndex == 0) {
+ // For some reason, if we load a file while the tab is on object,
+ // we get stuck in a Qt-side loop? Qt bug or sideeffect here, I don't know.
+ sidebarSelector.currentIndex = 1
+ objectLists.update()
+ delayRefreshTimer.start()
+ } else {
+ objectLists.update()
+ }
}
}
+ Timer {
+ id: delayRefreshTimer
+ repeat: false
+ interval: 1
+ onTriggered: sidebarSelector.currentIndex = 0
+ }
+
function copyDiagramToClipboard() {
var file = Helper.gettmpfile()
drawCanvas.save(file)
diff --git a/qml/ObjectLists.qml b/qml/ObjectLists.qml
index c5d1aff..d0cb167 100644
--- a/qml/ObjectLists.qml
+++ b/qml/ObjectLists.qml
@@ -277,17 +277,12 @@ ListView {
id: createBtn
text: modelData
width: createRow.width
- flat: false
+ visible: Objects.types[modelData].createable()
+ Component.onCompleted: console.log(modelData, visible, Objects)//, Objects.type[modelData])
+ height: visible ? implicitHeight : 0
+ icon.source: './icons/'+modelData+'.svg' // Default to dark version
- contentItem: Text {
-
- text: createBtn.text
- font.pixelSize: 20
- opacity: enabled ? 1.0 : 0.3
- color: sysPalette.windowText
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
+
onClicked: {
Objects.createNewRegisteredObject(modelData)
diff --git a/qml/icons/Function.svg b/qml/icons/Function.svg
new file mode 100644
index 0000000..502cc2c
--- /dev/null
+++ b/qml/icons/Function.svg
@@ -0,0 +1,71 @@
+
+
diff --git a/qml/icons/Gain Bode.svg b/qml/icons/Gain Bode.svg
new file mode 100644
index 0000000..9057757
--- /dev/null
+++ b/qml/icons/Gain Bode.svg
@@ -0,0 +1,93 @@
+
+
diff --git a/qml/icons/Point.svg b/qml/icons/Point.svg
new file mode 100644
index 0000000..093f939
--- /dev/null
+++ b/qml/icons/Point.svg
@@ -0,0 +1,74 @@
+
+
diff --git a/qml/js/objects.js b/qml/js/objects.js
index c381651..a56b911 100644
--- a/qml/js/objects.js
+++ b/qml/js/objects.js
@@ -151,7 +151,7 @@ class Point extends DrawableObject {
}
update() {
- if(currentObjects['Total gains Bode'] != undefined && currentObjects['Gain Bode'] != undefined) {
+ if(currentObjects['Somme gains Bode'] != undefined && currentObjects['Gain Bode'] != undefined) {
for(var i = 0; i < currentObjects['Gain Bode'].length; i++) {
console.log(currentObjects['Gain Bode'][i].ω_0.name)
if(currentObjects['Gain Bode'][i].ω_0.name == this.name) currentObjects['Gain Bode'][i].update()
@@ -229,8 +229,8 @@ class Function extends DrawableObject {
for(var px = pxprecision; px < canvas.canvasSize.width; px += pxprecision) {
var currentX = canvas.px2x(px)
var currentY = expr.evaluate(currentX)
- if(inDomain.includes(currentX) && inDomain.includes(previousX) &&
- outDomain.includes(currentY) && outDomain.includes(previousY) &&
+ if((inDomain.includes(currentX) || inDomain.includes(previousX)) &&
+ (outDomain.includes(currentY) || outDomain.includes(previousY)) &&
Math.abs(previousY-currentY)<100) { // 100 per 2px is a lot (probably inf to inf issue)
canvas.drawLine(ctx, canvas.x2px(previousX), canvas.y2px(previousY), canvas.x2px(currentX), canvas.y2px(currentY))
}
@@ -254,7 +254,7 @@ class GainBode extends DrawableObject {
constructor(name = null, visible = true, color = null, labelContent = 'name + value',
ω_0 = '', pass = 'high', gain = '20', labelPos = 'above', labelX = 1) {
if(name == null) name = getNewName('G', 'Gain Bode')
- if(name == 'G') name = 'G₀' // G is reserved for sum of BODE magnitues (Total Gains Bode).
+ if(name == 'G') name = 'G₀' // G is reserved for sum of BODE magnitues (Somme gains Bode).
super(name, visible, color, labelContent)
if(typeof ω_0 == "string") {
// Point name or create one
@@ -272,6 +272,7 @@ class GainBode extends DrawableObject {
this.gain = gain
this.labelPos = labelPos
this.labelX = labelX
+ this.update()
}
getReadableString() {
@@ -325,15 +326,18 @@ class GainBode extends DrawableObject {
}
update() {
- if(currentObjects['Total gains Bode'] != undefined) {
- currentObjects['Total gains Bode'][0].recalculateCache()
+ if(currentObjects['Somme gains Bode'] != undefined) {
+ currentObjects['Somme gains Bode'][0].recalculateCache()
+ } else {
+ createNewRegisteredObject('Somme gains Bode')
}
}
}
-class TotalGainsBode extends DrawableObject {
- static type(){return 'Total gains Bode'}
- static typeMultiple(){return 'Total gains Bode'}
+class SommeGainsBode extends DrawableObject {
+ static type(){return 'Somme gains Bode'}
+ static typeMultiple(){return 'Somme gains Bode'}
+ static createable() {return false}
static properties() {return {
'labelPos': ['above', 'below'],
'labelX': 'number'
@@ -349,11 +353,11 @@ class TotalGainsBode extends DrawableObject {
}
export() {
- return [this.name, this.visible, this.color.toString(), this.labelContent, labelPos = 'above', labelX = 1]
+ return [this.name, this.visible, this.color.toString(), this.labelContent, this.labelPos, this.labelX]
}
getReadableString() {
- return `${this.name}: ${getObjectsName('Gain Bode').join(' + ')}`
+ return `${this.name} = ${getObjectsName('Gain Bode').join(' + ')}`
}
recalculateCache() {
@@ -437,7 +441,7 @@ const types = {
'Point': Point,
'Function': Function,
'Gain Bode': GainBode,
- 'Total gains Bode': TotalGainsBode
+ 'Somme gains Bode': SommeGainsBode
}
var currentObjects = {}
@@ -465,11 +469,3 @@ function createNewRegisteredObject(objType) {
currentObjects[objType].push(newobj)
return newobj
}
-
-var points = [new Point()]
-var f = new Function();
-f.point = points[0]
-points[0].name = 'B'
-points[0].x = 2
-f.point.x = 4
-console.log(points[0].name, f.point.name, points[0].x, f.point.x)