DetailPage: guardie port undefined, log init/refresh, Z0 tratteggiata manuale (no setLineDash Qt5.6)
This commit is contained in:
+49
-32
@@ -27,6 +27,11 @@ Page {
|
||||
function init() {
|
||||
nearPort = null
|
||||
nearKm = 0
|
||||
console.log("[tide] DetailPage.init custom:", custom, "port:", port ? port[0] : "UNDEFINED")
|
||||
if (!port) {
|
||||
console.log("[tide] DetailPage.init: port undefined, niente da caricare")
|
||||
return
|
||||
}
|
||||
if (custom && port.length > 5 && port[5] !== "") {
|
||||
var np = Tides.nearestPort(port[2], port[3])
|
||||
if (np.port !== null) {
|
||||
@@ -38,36 +43,44 @@ Page {
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
if (!port) return
|
||||
// eventi
|
||||
eventsModel.clear()
|
||||
var ex = Tides.extrema(port, new Date(), days)
|
||||
var n = Math.min(ex.length, 6)
|
||||
for (var i = 0; i < n; i++) {
|
||||
eventsModel.append({
|
||||
kind: ex[i].kind,
|
||||
date: Tides.fmtDate(ex[i].t),
|
||||
time: Tides.fmtHM(ex[i].t),
|
||||
height: Tides.fmtH(ex[i].h, unit)
|
||||
})
|
||||
if (!port) {
|
||||
console.log("[tide] refresh: port UNDEFINED")
|
||||
return
|
||||
}
|
||||
// astro
|
||||
var mp = Tides.moonPhase(new Date())
|
||||
moonLabel.text = mp.icon + " " + moonNames[mp.idx] + " (" + qsTr("age %1 d").arg(mp.age.toFixed(1)) + ")"
|
||||
var st = Tides.sunTimes(port[2], new Date())
|
||||
sunLabel.text = Tides.fmtHM(new Date(0, 0, 0, st.rise, 0)) + " / " + Tides.fmtHM(new Date(0, 0, 0, st.set, 0)) + " " + qsTr("(solar time)")
|
||||
rangeLabel.text = "±" + ((port[4][1][0] + port[4][2][0]) * 2).toFixed(2) + " m"
|
||||
// info curva
|
||||
var f = port[5] || ""
|
||||
if (f.indexOf("near:") === 0) {
|
||||
var p = f.split(":")
|
||||
curveInfo.text = qsTr("Constants of the port of %1 (distance %2°)").arg(p[1]).arg(p[2])
|
||||
} else if (f === "synth") {
|
||||
curveInfo.text = qsTr("Estimated constants from lat/lon (synthetic model)")
|
||||
} else {
|
||||
curveInfo.text = qsTr("Z₀ %1 m · 7 harmonic constituents").arg(port[4][0].toFixed(2))
|
||||
console.log("[tide] refresh:", port[0], "days:", days, "unit:", unit)
|
||||
try {
|
||||
// eventi
|
||||
eventsModel.clear()
|
||||
var ex = Tides.extrema(port, new Date(), days)
|
||||
var n = Math.min(ex.length, 6)
|
||||
for (var i = 0; i < n; i++) {
|
||||
eventsModel.append({
|
||||
kind: ex[i].kind,
|
||||
date: Tides.fmtDate(ex[i].t),
|
||||
time: Tides.fmtHM(ex[i].t),
|
||||
height: Tides.fmtH(ex[i].h, unit)
|
||||
})
|
||||
}
|
||||
// astro
|
||||
var mp = Tides.moonPhase(new Date())
|
||||
moonLabel.text = mp.icon + " " + moonNames[mp.idx] + " (" + qsTr("age %1 d").arg(mp.age.toFixed(1)) + ")"
|
||||
var st = Tides.sunTimes(port[2], new Date())
|
||||
sunLabel.text = Tides.fmtHM(new Date(0, 0, 0, st.rise, 0)) + " / " + Tides.fmtHM(new Date(0, 0, 0, st.set, 0)) + " " + qsTr("(solar time)")
|
||||
rangeLabel.text = "±" + ((port[4][1][0] + port[4][2][0]) * 2).toFixed(2) + " m"
|
||||
// info curva
|
||||
var f = port[5] || ""
|
||||
if (f.indexOf("near:") === 0) {
|
||||
var p = f.split(":")
|
||||
curveInfo.text = qsTr("Constants of the port of %1 (distance %2°)").arg(p[1]).arg(p[2])
|
||||
} else if (f === "synth") {
|
||||
curveInfo.text = qsTr("Estimated constants from lat/lon (synthetic model)")
|
||||
} else {
|
||||
curveInfo.text = qsTr("Z₀ %1 m · 7 harmonic constituents").arg(port[4][0].toFixed(2))
|
||||
}
|
||||
cv.requestPaint()
|
||||
} catch (e) {
|
||||
console.log("[tide] refresh error:", e)
|
||||
}
|
||||
cv.requestPaint()
|
||||
}
|
||||
|
||||
property var moonNames: [
|
||||
@@ -300,11 +313,15 @@ Page {
|
||||
ctx.fillText((d.getHours() < 10 ? "0" : "") + d.getHours() + ":00", x + 3, h - 3)
|
||||
}
|
||||
|
||||
// Z0 tratteggiata
|
||||
ctx.setLineDash([4, 4])
|
||||
// Z0 tratteggiata (disegno manuale: setLineDash non garantito su Qt 5.6)
|
||||
ctx.strokeStyle = Theme.rgba(Theme.secondaryColor, 0.6)
|
||||
ctx.beginPath(); ctx.moveTo(pad, Y(port[4][0])); ctx.lineTo(w - pad, Y(port[4][0])); ctx.stroke()
|
||||
ctx.setLineDash([])
|
||||
var zy = Y(port[4][0])
|
||||
for (var zx = pad; zx < w - pad; zx += 10) {
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(zx, zy)
|
||||
ctx.lineTo(Math.min(zx + 5, w - pad), zy)
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
// curva
|
||||
ctx.strokeStyle = Theme.highlightColor
|
||||
|
||||
Reference in New Issue
Block a user