File extension for plotter, with icon for it.

This commit is contained in:
Adsooi 2021-03-09 11:14:12 +01:00
parent faffd67e28
commit 08dd31ddbc
5 changed files with 140 additions and 6 deletions

10
logplotter.desktop Normal file
View file

@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Type=Application
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
Terminal=false
StartupNotify=false
Categories=Graphics;Science;Math;

123
logplotterfile.svg Normal file
View file

@ -0,0 +1,123 @@
<?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:xlink="http://www.w3.org/1999/xlink"
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="logplotterfile.svg"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
<defs
id="defs10">
<linearGradient
inkscape:collect="always"
id="linearGradient909">
<stop
style="stop-color:#dddddf;stop-opacity:1;"
offset="0"
id="stop905" />
<stop
style="stop-color:#dddddf;stop-opacity:0;"
offset="1"
id="stop907" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient909"
id="linearGradient911"
x1="19"
y1="6"
x2="19"
y2="9"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.2"
inkscape:cx="20.998067"
inkscape:cy="1.6486949"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true">
<inkscape:grid
type="xygrid"
id="grid19" />
</sodipodi:namedview>
<metadata
id="metadata13">
<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="rect26"
style="fill:#ffffff;fill-opacity:1;stroke:#aaaaaf;stroke-width:0.7;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 4,2 h 13 l 3,3.8181818 V 23 H 4 Z"
sodipodi:nodetypes="cccccc" />
<g
id="g870"
transform="translate(-4.5,-1)">
<rect
style="fill:#000000;fill-rule:evenodd;stroke-width:9.65201;stroke-opacity:0"
id="rect1410"
width="11"
height="1"
x="11"
y="17" />
<rect
style="fill:#000000;fill-rule:evenodd;stroke-width:9.65208;stroke-opacity:0"
id="rect1412"
width="1"
height="11"
x="15"
y="8" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.975312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1529"
sodipodi:type="arc"
sodipodi:cx="11"
sodipodi:cy="8"
sodipodi:rx="10.012342"
sodipodi:ry="9.0123415"
sodipodi:start="0"
sodipodi:end="1.5707963"
sodipodi:arc-type="arc"
sodipodi:open="true"
d="M 21.012342,8 A 10.012342,9.0123415 0 0 1 11,17.012341" />
</g>
<path
id="rect899"
style="fill:#aaaaaf;fill-opacity:1;stroke:none;stroke-width:0.7;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 17,2 3,4 v 0 h -3 z"
sodipodi:nodetypes="ccccc" />
<path
id="rect902"
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"
sodipodi:nodetypes="ccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -24,7 +24,7 @@ D.FileDialog {
property bool exportMode: false property bool exportMode: false
title: exportMode ? "Export Logarithmic Graph file" : "Import Logarithmic Graph file" title: exportMode ? "Export Logarithmic Graph file" : "Import Logarithmic Graph file"
nameFilters: ["Logarithmic Graph JSON Data (*.json)", "All files (*)"] nameFilters: ["Logarithmic Graph JSON Data (*.lgg)", "Old Logarithmic Graph JSON Data (*.json)", "All files (*)"]
folder: shortcuts.documents folder: shortcuts.documents
selectExisting: !exportMode selectExisting: !exportMode

View file

@ -29,7 +29,7 @@ ApplicationWindow {
width: 1000 width: 1000
height: 500 height: 500
color: sysPalette.window color: sysPalette.window
title: "Logarithmic Plotter " + (settings.saveFilename != "" ? " - " + settings.saveFilename.split('/')[0] : "") title: "Logarithmic Plotter " + (settings.saveFilename != "" ? " - " + settings.saveFilename.split('/')[settings.saveFilename.split('/').length -1] : "")
SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active } SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active }
SystemPalette { id: sysPaletteIn; colorGroup: SystemPalette.Disabled } SystemPalette { id: sysPaletteIn; colorGroup: SystemPalette.Disabled }
@ -116,6 +116,7 @@ ApplicationWindow {
} }
function saveDiagram(filename) { function saveDiagram(filename) {
settings.saveFilename = filename
var objs = {} var objs = {}
for(var objType in Objects.currentObjects){ for(var objType in Objects.currentObjects){
objs[objType] = [] objs[objType] = []
@ -143,6 +144,7 @@ ApplicationWindow {
function loadDiagram(filename) { function loadDiagram(filename) {
var data = JSON.parse(Helper.load(filename)) var data = JSON.parse(Helper.load(filename))
if(Object.keys(data).includes("type") && data["type"] == "logplotv1") { if(Object.keys(data).includes("type") && data["type"] == "logplotv1") {
settings.saveFilename = filename
settings.xzoom = data["xzoom"] settings.xzoom = data["xzoom"]
settings.yzoom = data["yzoom"] settings.yzoom = data["yzoom"]
settings.xmin = data["xmin"] settings.xmin = data["xmin"]

View file

@ -1167,14 +1167,14 @@ class RepartitionFunction extends ExecutableObject {
getReadableString() { getReadableString() {
var keys = Object.keys(this.probabilities).sort(); var keys = Object.keys(this.probabilities).sort((a,b) => a-b);
return `F_${this.name}(x) = P(${this.name} ≤ x)\n` + keys.map(idx => `P(${this.name}=${idx})=${this.probabilities[idx]}`).join("; ") return `F_${this.name}(x) = P(${this.name} ≤ x)\n` + keys.map(idx => `P(${this.name}=${idx})=${this.probabilities[idx]}`).join("; ")
} }
execute(x = 1) { execute(x = 1) {
var ret = 0; var ret = 0;
Object.keys(this.probabilities).sort().forEach(idx => { Object.keys(this.probabilities).sort((a,b) => a-b).forEach(idx => {
if(x >= idx) ret += this.probabilities[idx] if(x >= idx) ret += parseFloat(this.probabilities[idx])
}) })
return ret return ret
} }
@ -1236,7 +1236,6 @@ class RepartitionFunction extends ExecutableObject {
} }
} }
} }
console.log("Checking end", canvas.visible(keys[keys.length-1],currentY+parseFloat(this.probabilities[keys[keys.length-1]])), canvas.y2px(currentY+parseFloat(this.probabilities[keys[keys.length-1]])))
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])),