Better installation, fixing bugs, allowing commas instead of dots for repartition floats
This commit is contained in:
parent
08dd31ddbc
commit
0060b8aca6
8 changed files with 57 additions and 29 deletions
9
linux/install_local.sh
Normal file
9
linux/install_local.sh
Normal file
|
@ -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
|
|
@ -5,6 +5,7 @@ Name=Logarithm Plotter
|
||||||
Comment=Plotter to make BODE diagrams, sequences and repartition functions.
|
Comment=Plotter to make BODE diagrams, sequences and repartition functions.
|
||||||
Exec=/usr/bin/python3 /home/ad5001/Apps/LogarithmPlotter/run.py %F
|
Exec=/usr/bin/python3 /home/ad5001/Apps/LogarithmPlotter/run.py %F
|
||||||
Icon=/home/ad5001/Apps/LogarithmPlotter/logplotter.svg
|
Icon=/home/ad5001/Apps/LogarithmPlotter/logplotter.svg
|
||||||
|
MimeType=application/x-logarithm-plotter;
|
||||||
Terminal=false
|
Terminal=false
|
||||||
StartupNotify=false
|
StartupNotify=false
|
||||||
Categories=Graphics;Science;Math;
|
Categories=Graphics;Science;Math;
|
|
@ -21,7 +21,7 @@
|
||||||
inkscape:collect="always"
|
inkscape:collect="always"
|
||||||
id="linearGradient909">
|
id="linearGradient909">
|
||||||
<stop
|
<stop
|
||||||
style="stop-color:#dddddf;stop-opacity:1;"
|
style="stop-color:#d0d0df;stop-opacity:1"
|
||||||
offset="0"
|
offset="0"
|
||||||
id="stop905" />
|
id="stop905" />
|
||||||
<stop
|
<stop
|
||||||
|
@ -46,9 +46,9 @@
|
||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="11.2"
|
inkscape:zoom="63.356767"
|
||||||
inkscape:cx="20.998067"
|
inkscape:cx="21.069815"
|
||||||
inkscape:cy="1.6486949"
|
inkscape:cy="8.4702325"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
inkscape:document-rotation="0"
|
inkscape:document-rotation="0"
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<dc:format>image/svg+xml</dc:format>
|
<dc:format>image/svg+xml</dc:format>
|
||||||
<dc:type
|
<dc:type
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
<dc:title></dc:title>
|
<dc:title />
|
||||||
</cc:Work>
|
</cc:Work>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
<path
|
<path
|
||||||
id="rect902"
|
id="rect902"
|
||||||
style="fill:url(#linearGradient911);fill-opacity:1;stroke:none;stroke-width:0.6579;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
style="fill:url(#linearGradient911);fill-opacity:1;stroke:none;stroke-width:0.6579;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
d="m 17,6 h 2.65 v 2 0 z"
|
d="m 17,6 h 2.65 v 2.5 0 z"
|
||||||
sodipodi:nodetypes="ccccc" />
|
sodipodi:nodetypes="ccccc" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
10
linux/x-logarithm-plotter.xml
Normal file
10
linux/x-logarithm-plotter.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-logarithm-plotter">
|
||||||
|
<!--Created automatically by update-mime-database. DO NOT EDIT!-->
|
||||||
|
<comment>Logarithm Plot/Graph</comment>
|
||||||
|
<icon name="/home/ad5001/Apps/LogarithmPlotter/logplotterfile.svg"/>
|
||||||
|
<glob-deleteall/>
|
||||||
|
<glob pattern="*.json"/>
|
||||||
|
<glob pattern="*.lgg"/>
|
||||||
|
<glob pattern="*.lgp"/>
|
||||||
|
</mime-type>
|
|
@ -52,7 +52,7 @@ ApplicationWindow {
|
||||||
id: topSeparator
|
id: topSeparator
|
||||||
color: sysPaletteIn.dark
|
color: sysPaletteIn.dark
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 2
|
height: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
TabBar {
|
TabBar {
|
||||||
|
@ -143,6 +143,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
function loadDiagram(filename) {
|
function loadDiagram(filename) {
|
||||||
var data = JSON.parse(Helper.load(filename))
|
var data = JSON.parse(Helper.load(filename))
|
||||||
|
var error = "";
|
||||||
if(Object.keys(data).includes("type") && data["type"] == "logplotv1") {
|
if(Object.keys(data).includes("type") && data["type"] == "logplotv1") {
|
||||||
settings.saveFilename = filename
|
settings.saveFilename = filename
|
||||||
settings.xzoom = data["xzoom"]
|
settings.xzoom = data["xzoom"]
|
||||||
|
@ -159,16 +160,20 @@ ApplicationWindow {
|
||||||
|
|
||||||
Objects.currentObjects = {}
|
Objects.currentObjects = {}
|
||||||
for(var objType in data['objects']) {
|
for(var objType in data['objects']) {
|
||||||
Objects.currentObjects[objType] = []
|
if(Object.keys(Objects.types).indexOf(objType) > -1) {
|
||||||
for(var objData of data['objects'][objType]) {
|
Objects.currentObjects[objType] = []
|
||||||
var obj = new Objects.types[objType](...objData)
|
for(var objData of data['objects'][objType]) {
|
||||||
Objects.currentObjects[objType].push(obj)
|
var obj = new Objects.types[objType](...objData)
|
||||||
|
Objects.currentObjects[objType].push(obj)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error += "Unknown object type: " +objType + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Refreshing sidebar
|
// Refreshing sidebar
|
||||||
if(sidebarSelector.currentIndex == 0) {
|
if(sidebarSelector.currentIndex == 0) {
|
||||||
// For some reason, if we load a file while the tab is on object,
|
// 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
|
sidebarSelector.currentIndex = 1
|
||||||
objectLists.update()
|
objectLists.update()
|
||||||
delayRefreshTimer.start()
|
delayRefreshTimer.start()
|
||||||
|
@ -176,6 +181,9 @@ ApplicationWindow {
|
||||||
objectLists.update()
|
objectLists.update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(error != "") {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
viewBox="0 0 24.0 24.0"
|
viewBox="0 0 24.0 24.0"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="SVGRoot"
|
id="SVGRoot"
|
||||||
sodipodi:docname="Repartition function.svg"
|
sodipodi:docname="Repartition.svg"
|
||||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
|
||||||
<defs
|
<defs
|
||||||
id="defs835" />
|
id="defs835" />
|
||||||
<sodipodi:namedview
|
<sodipodi:namedview
|
||||||
|
@ -24,8 +24,8 @@
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="31.678384"
|
inkscape:zoom="31.678384"
|
||||||
inkscape:cx="10.734927"
|
inkscape:cx="4.7687136"
|
||||||
inkscape:cy="13.020605"
|
inkscape:cy="12.95747"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
inkscape:document-rotation="0"
|
inkscape:document-rotation="0"
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<dc:format>image/svg+xml</dc:format>
|
<dc:format>image/svg+xml</dc:format>
|
||||||
<dc:type
|
<dc:type
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
<dc:title></dc:title>
|
<dc:title />
|
||||||
</cc:Work>
|
</cc:Work>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
x="5"
|
x="5"
|
||||||
y="11" />
|
y="11" />
|
||||||
<path
|
<path
|
||||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.755908;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.75;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
id="path1416"
|
id="path1416"
|
||||||
sodipodi:type="arc"
|
sodipodi:type="arc"
|
||||||
sodipodi:cx="22.049"
|
sodipodi:cx="22.049"
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.5 KiB |
|
@ -1137,13 +1137,13 @@ class Sequence extends ExecutableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RepartitionFunction extends ExecutableObject {
|
class RepartitionFunction extends ExecutableObject {
|
||||||
static type(){return 'Repartition function'}
|
static type(){return 'Repartition'}
|
||||||
static typeMultiple(){return 'Repartition functions'}
|
static typeMultiple(){return 'Repartitions'}
|
||||||
static properties() {return {
|
static properties() {return {
|
||||||
'beginIncluded': 'Boolean',
|
'beginIncluded': 'Boolean',
|
||||||
'drawLineEnds': 'Boolean',
|
'drawLineEnds': 'Boolean',
|
||||||
'comment1': 'Note: Specify the properties for each potential result.',
|
'comment1': 'Note: Specify the properties for each potential result.',
|
||||||
'probabilities': new P.Dictionary('string', 'float', /^-?[\d.]+$/, /^-?[\d\.]+$/, 'P({name} = ', ') = '),
|
'probabilities': new P.Dictionary('string', 'float', /^-?[\d.,]+$/, /^-?[\d\.,]+$/, 'P({name} = ', ') = '),
|
||||||
'labelPosition': new P.Enum('above', 'below', 'left', 'right', 'above-left', 'above-right', 'below-left', 'below-right'),
|
'labelPosition': new P.Enum('above', 'below', 'left', 'right', 'above-left', 'above-right', 'below-left', 'below-right'),
|
||||||
'labelX': 'number'
|
'labelX': 'number'
|
||||||
}}
|
}}
|
||||||
|
@ -1174,7 +1174,7 @@ class RepartitionFunction extends ExecutableObject {
|
||||||
execute(x = 1) {
|
execute(x = 1) {
|
||||||
var ret = 0;
|
var ret = 0;
|
||||||
Object.keys(this.probabilities).sort((a,b) => a-b).forEach(idx => {
|
Object.keys(this.probabilities).sort((a,b) => a-b).forEach(idx => {
|
||||||
if(x >= idx) ret += parseFloat(this.probabilities[idx])
|
if(x >= idx) ret += parseFloat(this.probabilities[idx].replace(/,/g, '.'))
|
||||||
})
|
})
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
@ -1200,7 +1200,7 @@ class RepartitionFunction extends ExecutableObject {
|
||||||
var currentY = 0;
|
var currentY = 0;
|
||||||
var keys = Object.keys(this.probabilities).map(idx => parseInt(idx)).sort((a,b) => a-b)
|
var keys = Object.keys(this.probabilities).map(idx => parseInt(idx)).sort((a,b) => a-b)
|
||||||
console.log("Keys", keys)
|
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,
|
canvas.drawLine(ctx,
|
||||||
0,
|
0,
|
||||||
canvas.y2px(0),
|
canvas.y2px(0),
|
||||||
|
@ -1215,7 +1215,7 @@ class RepartitionFunction extends ExecutableObject {
|
||||||
}
|
}
|
||||||
for(var i = 0; i < keys.length-1; i++) {
|
for(var i = 0; i < keys.length-1; i++) {
|
||||||
var idx = keys[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)) {
|
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))
|
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,
|
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]]))) {
|
if(canvas.visible(keys[keys.length-1],currentY+parseFloat(this.probabilities[keys[keys.length-1]]))) {
|
||||||
canvas.drawLine(ctx,
|
canvas.drawLine(ctx,
|
||||||
Math.max(0,canvas.x2px(keys[keys.length-1])),
|
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.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.beginPath();
|
||||||
ctx.arc(
|
ctx.arc(
|
||||||
canvas.x2px(keys[keys.length-1]),
|
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);
|
4, 0, 2 * Math.PI);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
@ -1295,7 +1295,7 @@ const types = {
|
||||||
'Somme phases Bode': SommePhasesBode,
|
'Somme phases Bode': SommePhasesBode,
|
||||||
'X Cursor': CursorX,
|
'X Cursor': CursorX,
|
||||||
'Sequence': Sequence,
|
'Sequence': Sequence,
|
||||||
'Repartition function': RepartitionFunction,
|
'Repartition': RepartitionFunction,
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentObjects = {}
|
var currentObjects = {}
|
||||||
|
|
2
run.py
2
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")))
|
engine.load(os.path.realpath(os.path.join(os.getcwd(), "qml", "LogGraph.qml")))
|
||||||
|
|
||||||
os.chdir(pwd)
|
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])
|
print(argv[-1])
|
||||||
engine.rootObjects()[0].loadDiagram(argv[-1])
|
engine.rootObjects()[0].loadDiagram(argv[-1])
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
Loading…
Reference in a new issue