Icons! + fixing bugs & removing debug
This commit is contained in:
parent
971882e075
commit
b8431749a3
8 changed files with 327 additions and 44 deletions
|
@ -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") }
|
||||
|
|
20
qml/Icon.qml
Normal file
20
qml/Icon.qml
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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,28 +60,31 @@ 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
|
||||
ObjectLists {
|
||||
id: objectLists
|
||||
onChanged: drawCanvas.requestPaint()
|
||||
}
|
||||
|
||||
ObjectLists {
|
||||
id: objectLists
|
||||
Settings {
|
||||
id: settings
|
||||
onChanged: drawCanvas.requestPaint()
|
||||
}
|
||||
}
|
||||
|
@ -152,12 +155,24 @@ 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()
|
||||
|
|
|
@ -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)
|
||||
|
|
71
qml/icons/Function.svg
Normal file
71
qml/icons/Function.svg
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24.0px"
|
||||
height="24.0px"
|
||||
viewBox="0 0 24.0 24.0"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
sodipodi:docname="Function.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<defs
|
||||
id="defs3359" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="15.839192"
|
||||
inkscape:cx="25.331188"
|
||||
inkscape:cy="8.0958853"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3929" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata3362">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:17.1281px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.98816"
|
||||
x="-0.045739319"
|
||||
y="18.130817"
|
||||
id="text3942"
|
||||
transform="scale(0.98816009,1.0119818)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3940"
|
||||
x="-0.045739319"
|
||||
y="18.130817"
|
||||
style="font-size:17.1281px;stroke-width:0.98816">f(x)</tspan></text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
93
qml/icons/Gain Bode.svg
Normal file
93
qml/icons/Gain Bode.svg
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24.0px"
|
||||
height="24.0px"
|
||||
viewBox="0 0 24.0 24.0"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
sodipodi:docname="Gain Bode.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<defs
|
||||
id="defs1469" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="22.4"
|
||||
inkscape:cx="22.985246"
|
||||
inkscape:cy="9.8906279"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2039" />
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2058" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata1472">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
id="path1414"
|
||||
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0"
|
||||
d="m 15.979376,17.120606 a 3.5,3.5 0 0 1 -3.06333,3.854578 3.5,3.5 0 0 1 -3.8866522,-3.022533 3.5,3.5 0 0 1 2.9814002,-3.918293 3.5,3.5 0 0 1 3.9495,2.939936" />
|
||||
<rect
|
||||
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:14.257;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0"
|
||||
id="rect835"
|
||||
width="14"
|
||||
height="2"
|
||||
x="0"
|
||||
y="16.5" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:17.3333px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
|
||||
x="-0.12666447"
|
||||
y="12.134649"
|
||||
id="text839"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan837"
|
||||
x="-0.12666447"
|
||||
y="12.134649"
|
||||
style="font-size:17.3333px">ω</tspan></text>
|
||||
<rect
|
||||
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:19.0663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0"
|
||||
id="rect835-3"
|
||||
width="25.038315"
|
||||
height="2"
|
||||
x="-10.440239"
|
||||
y="19.284609"
|
||||
ry="0"
|
||||
transform="rotate(-60)" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
74
qml/icons/Point.svg
Normal file
74
qml/icons/Point.svg
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24.0px"
|
||||
height="24.0px"
|
||||
viewBox="0 0 24.0 24.0"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
sodipodi:docname="Point.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<defs
|
||||
id="defs1469" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="22.4"
|
||||
inkscape:cx="23.448337"
|
||||
inkscape:cy="8.0833333"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2039" />
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2058" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata1472">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
id="path1414"
|
||||
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0"
|
||||
d="M 10.019082,18.146312 A 3.5,3.5 0 0 1 6.955752,22.00089 3.5,3.5 0 0 1 3.0690998,18.978357 3.5,3.5 0 0 1 6.0505,15.060064 3.5,3.5 0 0 1 10,18" />
|
||||
<g
|
||||
aria-label="A"
|
||||
id="text2054"
|
||||
style="font-style:normal;font-weight:normal;font-size:17.3333px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none">
|
||||
<path
|
||||
d="m 18.990651,13.942643 h 1.73333 L 16.910655,1.9999997 H 14.830659 L 11,13.942643 h 1.663996 l 0.901332,-2.998661 h 4.523991 z M 13.963994,9.6093183 15.83599,3.3693304 17.690653,9.6093183 Z"
|
||||
id="path3356" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue