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
|
@ -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 {
|
||||
|
|
|
@ -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)">
|
||||
<defs
|
||||
id="defs835" />
|
||||
<sodipodi:namedview
|
||||
|
@ -24,8 +24,8 @@
|
|||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="31.678384"
|
||||
inkscape:cx="10.734927"
|
||||
inkscape:cy="13.020605"
|
||||
inkscape:cx="4.7687136"
|
||||
inkscape:cy="12.95747"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
|
@ -47,7 +47,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
@ -69,7 +69,7 @@
|
|||
x="5"
|
||||
y="11" />
|
||||
<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"
|
||||
sodipodi:type="arc"
|
||||
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 {
|
||||
static type(){return 'Repartition function'}
|
||||
static typeMultiple(){return 'Repartition functions'}
|
||||
static type(){return 'Repartition'}
|
||||
static typeMultiple(){return 'Repartitions'}
|
||||
static properties() {return {
|
||||
'beginIncluded': 'Boolean',
|
||||
'drawLineEnds': 'Boolean',
|
||||
'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'),
|
||||
'labelX': 'number'
|
||||
}}
|
||||
|
@ -1174,7 +1174,7 @@ class RepartitionFunction extends ExecutableObject {
|
|||
execute(x = 1) {
|
||||
var ret = 0;
|
||||
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
|
||||
}
|
||||
|
@ -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 = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue