Compare commits

..

2 commits

3 changed files with 24 additions and 9 deletions

View file

@ -124,7 +124,7 @@ Canvas {
\qmlproperty int LogGraphCanvas::maxgradx \qmlproperty int LogGraphCanvas::maxgradx
Max power of the logarithmic scaled on the x axis in logarithmic mode. Max power of the logarithmic scaled on the x axis in logarithmic mode.
*/ */
property int maxgradx: 20 property int maxgradx: 90
/*! /*!
\qmlproperty var LogGraphCanvas::imageLoaders \qmlproperty var LogGraphCanvas::imageLoaders

View file

@ -94,9 +94,13 @@ Item {
property int positionChangeTimer: 0 property int positionChangeTimer: 0
function updatePosition(deltaX, deltaY) { function updatePosition(deltaX, deltaY) {
settingsInstance.xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX)) const unauthorized = [NaN, Infinity, -Infinity]
settingsInstance.ymax += deltaY/canvas.yzoom const xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
settingsInstance.ymax = settingsInstance.ymax.toFixed(4) const ymax = settingsInstance.ymax + deltaY/canvas.yzoom
if(!unauthorized.includes(xmin))
settingsInstance.xmin = xmin
if(!unauthorized.includes(ymax))
settingsInstance.ymax = ymax.toFixed(4)
settingsInstance.changed() settingsInstance.changed()
parent.positionChanged(deltaX, deltaY) parent.positionChanged(deltaX, deltaY)
@ -140,12 +144,15 @@ Item {
} }
let newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(0) let newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(0)
let newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(0) let newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(0)
if(newXZoom == settingsInstance.xzoom) // No change, allow more precision. // Check if we need to have more precision
if(newXZoom < 10)
newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(4) newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(4)
if(newYZoom == settingsInstance.yzoom) // No change, allow more precision. if(newYZoom < 10)
newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(4) newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(4)
settingsInstance.xzoom = newXZoom if(newXZoom > 0.5)
settingsInstance.yzoom = newYZoom settingsInstance.xzoom = newXZoom
if(newYZoom > 0.5)
settingsInstance.yzoom = newYZoom
settingsInstance.changed() settingsInstance.changed()
} }
} }

View file

@ -139,7 +139,15 @@ class CanvasAPI extends Module {
* Max power of the logarithmic scaled on the x axis in logarithmic mode. * Max power of the logarithmic scaled on the x axis in logarithmic mode.
* @returns {number} * @returns {number}
*/ */
get maxgradx() { return this._canvas.maxgradx } get maxgradx() {
return Math.min(
309, // 10e309 = Infinity (beyond this land be dragons)
Math.max(
Math.ceil(Math.abs(Math.log10(this.xmin))),
Math.ceil(Math.abs(Math.log10(this.px2x(this.width))))
)
)
}
// //
// Methods to draw the canvas // Methods to draw the canvas