diff --git a/linux/install_local.sh b/linux/install_local.sh
new file mode 100644
index 0000000..4f6b58c
--- /dev/null
+++ b/linux/install_local.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+APPROOT="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+mkdir -p ~/.local/share/applications
+sed "s+/home/ad5001/Apps/LogarithmPlotter/+$APPROOT+g" "$APPROOT/linux/logplotter.desktop" > ~/.local/share/applications/logplotter.desktop
+sed "s+/home/ad5001/Apps/LogarithmPlotter/+$APPROOT+g" "$APPROOT/linux/x-logarithm-plotter.xml" > ~/.local/share/mime/x-logarithm-plotter.xml
+mkdir -p ~/.local/share/icons/hicolor/scalable/mimetypes
+cp "$APPROOT/linux/logplotterfile.svg" ~/.local/share/icons/hicolor/scalable/mimetypes/application-x-logarithm-plotter.svg
+update-mime-database ~/.local/share/mime/
+update-icon-caches ~/.local/share/icons/hicolor
diff --git a/logplotter.desktop b/linux/logplotter.desktop
similarity index 88%
rename from logplotter.desktop
rename to linux/logplotter.desktop
index aae6f6f..8da90f2 100644
--- a/logplotter.desktop
+++ b/linux/logplotter.desktop
@@ -5,6 +5,7 @@ Name=Logarithm Plotter
Comment=Plotter to make BODE diagrams, sequences and repartition functions.
Exec=/usr/bin/python3 /home/ad5001/Apps/LogarithmPlotter/run.py %F
Icon=/home/ad5001/Apps/LogarithmPlotter/logplotter.svg
+MimeType=application/x-logarithm-plotter;
Terminal=false
StartupNotify=false
Categories=Graphics;Science;Math;
diff --git a/logplotterfile.svg b/linux/logplotterfile.svg
similarity index 94%
rename from logplotterfile.svg
rename to linux/logplotterfile.svg
index 03cd1ce..6ac1ec3 100644
--- a/logplotterfile.svg
+++ b/linux/logplotterfile.svg
@@ -21,7 +21,7 @@
inkscape:collect="always"
id="linearGradient909">
image/svg+xml
-
+
@@ -117,7 +117,7 @@
diff --git a/linux/x-logarithm-plotter.xml b/linux/x-logarithm-plotter.xml
new file mode 100644
index 0000000..d235081
--- /dev/null
+++ b/linux/x-logarithm-plotter.xml
@@ -0,0 +1,10 @@
+
+
+
+ Logarithm Plot/Graph
+
+
+
+
+
+
diff --git a/qml/LogGraph.qml b/qml/LogGraph.qml
index d6d3ba5..2dff24f 100644
--- a/qml/LogGraph.qml
+++ b/qml/LogGraph.qml
@@ -52,7 +52,7 @@ ApplicationWindow {
id: topSeparator
color: sysPaletteIn.dark
width: parent.width
- height: 2
+ height: 0
}
TabBar {
@@ -143,6 +143,7 @@ ApplicationWindow {
function loadDiagram(filename) {
var data = JSON.parse(Helper.load(filename))
+ var error = "";
if(Object.keys(data).includes("type") && data["type"] == "logplotv1") {
settings.saveFilename = filename
settings.xzoom = data["xzoom"]
@@ -159,16 +160,20 @@ ApplicationWindow {
Objects.currentObjects = {}
for(var objType in data['objects']) {
- Objects.currentObjects[objType] = []
- for(var objData of data['objects'][objType]) {
- var obj = new Objects.types[objType](...objData)
- Objects.currentObjects[objType].push(obj)
+ if(Object.keys(Objects.types).indexOf(objType) > -1) {
+ Objects.currentObjects[objType] = []
+ for(var objData of data['objects'][objType]) {
+ var obj = new Objects.types[objType](...objData)
+ Objects.currentObjects[objType].push(obj)
+ }
+ } else {
+ error += "Unknown object type: " +objType + "\n";
}
}
// Refreshing sidebar
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.
+ // we get stuck in a Qt-side loop? Qt bug or side-effect here, I don't know.
sidebarSelector.currentIndex = 1
objectLists.update()
delayRefreshTimer.start()
@@ -176,6 +181,9 @@ ApplicationWindow {
objectLists.update()
}
}
+ if(error != "") {
+
+ }
}
Timer {
diff --git a/qml/icons/Repartition function.svg b/qml/icons/Repartition.svg
similarity index 89%
rename from qml/icons/Repartition function.svg
rename to qml/icons/Repartition.svg
index 2bb420a..f48e75c 100644
--- a/qml/icons/Repartition function.svg
+++ b/qml/icons/Repartition.svg
@@ -12,8 +12,8 @@
viewBox="0 0 24.0 24.0"
version="1.1"
id="SVGRoot"
- sodipodi:docname="Repartition function.svg"
- inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
+ sodipodi:docname="Repartition.svg"
+ inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
image/svg+xml
-
+
@@ -69,7 +69,7 @@
x="5"
y="11" />
a-b).forEach(idx => {
- if(x >= idx) ret += parseFloat(this.probabilities[idx])
+ if(x >= idx) ret += parseFloat(this.probabilities[idx].replace(/,/g, '.'))
})
return ret
}
@@ -1200,7 +1200,7 @@ class RepartitionFunction extends ExecutableObject {
var currentY = 0;
var keys = Object.keys(this.probabilities).map(idx => parseInt(idx)).sort((a,b) => a-b)
console.log("Keys", keys)
- if(canvas.visible(keys[0],this.probabilities[keys[0]])) {
+ if(canvas.visible(keys[0],this.probabilities[keys[0]].replace(/,/g, '.'))) {
canvas.drawLine(ctx,
0,
canvas.y2px(0),
@@ -1215,7 +1215,7 @@ class RepartitionFunction extends ExecutableObject {
}
for(var i = 0; i < keys.length-1; i++) {
var idx = keys[i];
- currentY += parseFloat(this.probabilities[idx]);
+ currentY += parseFloat(this.probabilities[idx].replace(/,/g, '.'));
if(canvas.visible(idx,currentY) || canvas.visible(keys[i+1],currentY)) {
console.log("Drawing", idx, Math.max(0,canvas.x2px(idx)), canvas.y2px(currentY), Math.min(canvas.canvasSize.width,canvas.x2px(keys[i+1])), canvas.y2px(currentY))
canvas.drawLine(ctx,
@@ -1239,14 +1239,14 @@ class RepartitionFunction extends ExecutableObject {
if(canvas.visible(keys[keys.length-1],currentY+parseFloat(this.probabilities[keys[keys.length-1]]))) {
canvas.drawLine(ctx,
Math.max(0,canvas.x2px(keys[keys.length-1])),
- canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]])),
+ canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]].replace(/,/g, '.'))),
canvas.canvasSize.width,
- canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]]))
+ canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]].replace(/,/g, '.')))
)
ctx.beginPath();
ctx.arc(
canvas.x2px(keys[keys.length-1]),
- canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]])),
+ canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]].replace(/,/g, '.'))),
4, 0, 2 * Math.PI);
ctx.fill();
}
@@ -1295,7 +1295,7 @@ const types = {
'Somme phases Bode': SommePhasesBode,
'X Cursor': CursorX,
'Sequence': Sequence,
- 'Repartition function': RepartitionFunction,
+ 'Repartition': RepartitionFunction,
}
var currentObjects = {}
diff --git a/run.py b/run.py
index 59552bf..0b6be20 100644
--- a/run.py
+++ b/run.py
@@ -93,7 +93,7 @@ engine.addImportPath(os.path.realpath(os.path.join(os.getcwd(), "qml")))
engine.load(os.path.realpath(os.path.join(os.getcwd(), "qml", "LogGraph.qml")))
os.chdir(pwd)
-if len(argv) > 0 and os.path.exists(argv[-1]) and argv[-1].split('.')[-1] == 'json':
+if len(argv) > 0 and os.path.exists(argv[-1]) and argv[-1].split('.')[-1] in ['json', 'lgg']:
print(argv[-1])
engine.rootObjects()[0].loadDiagram(argv[-1])
os.chdir(os.path.dirname(os.path.realpath(__file__)))