From 27ff27fd9ce835d65f78162a06225f925a03aa62 Mon Sep 17 00:00:00 2001 From: Matthieu BAUMANN Date: Fri, 28 Oct 2022 17:08:23 +0200 Subject: [PATCH 1/4] zooming heuristic for touchpad and detection --- src/js/Aladin.js | 4 +-- src/js/View.js | 79 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/src/js/Aladin.js b/src/js/Aladin.js index 27b58890..8cff564b 100644 --- a/src/js/Aladin.js +++ b/src/js/Aladin.js @@ -1044,11 +1044,11 @@ export let Aladin = (function () { // @api Aladin.prototype.increaseZoom = function () { - this.view.increaseZoom(); + this.view.increaseZoom(0.01); }; Aladin.prototype.decreaseZoom = function () { - this.view.decreaseZoom(); + this.view.decreaseZoom(0.01); }; // @api diff --git a/src/js/View.js b/src/js/View.js index 6d1e8fd8..e71bb741 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -780,7 +780,13 @@ export let View = (function () { // disable text selection on IE $(view.aladinDiv).onselectstart = function () { return false; } - + var eventCount = 0; + var eventCountStart; + var isTouchPad; + var firstZoomDone = false; + var scrolling = false; + var oldTime = 0; + var newTime = 0; $(view.catalogCanvas).on('wheel', function (event) { event.preventDefault(); event.stopPropagation(); @@ -788,13 +794,6 @@ export let View = (function () { if (view.rightClick) { return; } - //var xymouse = view.imageCanvas.relMouseCoords(event); - - /*if(view.aladin.webglAPI.posOnUi()) { - return; - }*/ - //var xymouse = view.imageCanvas.relMouseCoords(event); - //var level = view.zoomLevel; var delta = event.deltaY; // this seems to happen in context of Jupyter notebook --> we have to invert the direction of scroll @@ -802,20 +801,58 @@ export let View = (function () { if (event.hasOwnProperty('originalEvent')) { delta = -event.originalEvent.deltaY; } - /*if (delta>0) { - level += 1; - //zoom + + // See https://stackoverflow.com/questions/10744645/detect-touchpad-vs-mouse-in-javascript + // for detecting the use of a touchpad + var isTouchPadDefined = isTouchPad || typeof isTouchPad !== "undefined"; + if (!isTouchPadDefined) { + if (eventCount === 0) { + eventCountStart = new Date().getTime(); + } + + eventCount++; + + if (new Date().getTime() - eventCountStart > 100) { + if (eventCount > 5) { + isTouchPad = true; + } else { + isTouchPad = false; + } + isTouchPadDefined = true; + } } - else { - level -= 1; - //unzoom - }*/ + // The value of the field of view is determined // inside the backend - if (delta > 0.0) { - view.increaseZoom(); + + const triggerZoom = (amount) => { + if (delta > 0.0) { + view.increaseZoom(amount); + } else { + view.decreaseZoom(amount); + } + }; + if (!isTouchPadDefined) { + if (!firstZoomDone) { + // zoom for the first time + triggerZoom(0.003); + + firstZoomDone = true; + } } else { - view.decreaseZoom(); + if (isTouchPad) { + // touchpad + newTime = new Date().getTime(); + + if ( newTime - oldTime > 20 ) { + triggerZoom(0.003); + + oldTime = new Date().getTime(); + } + } else { + // mouse + triggerZoom(0.007); + } } if (!view.debounceProgCatOnZoom) { @@ -1312,10 +1349,9 @@ export let View = (function () { this.updateFovDiv(); }; - View.prototype.increaseZoom = function () { + View.prototype.increaseZoom = function (amount) { const si = 500000.0; const alpha = 40.0; - const amount = 0.005; let initialAccDelta = this.pinchZoomParameters.initialAccDelta + amount; let new_fov = si / Math.pow(initialAccDelta, alpha); @@ -1328,10 +1364,9 @@ export let View = (function () { this.setZoom(new_fov); } - View.prototype.decreaseZoom = function () { + View.prototype.decreaseZoom = function (amount) { const si = 500000.0; const alpha = 40.0; - const amount = 0.005; let initialAccDelta = this.pinchZoomParameters.initialAccDelta - amount; From 18ceda57c80d6b2e80b117849fa01b23633c08fd Mon Sep 17 00:00:00 2001 From: Matthieu BAUMANN Date: Fri, 28 Oct 2022 17:33:43 +0200 Subject: [PATCH 2/4] set default background color to blue --- src/js/gui/Stack.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/js/gui/Stack.js b/src/js/gui/Stack.js index bccf3a0f..8d253a8e 100644 --- a/src/js/gui/Stack.js +++ b/src/js/gui/Stack.js @@ -98,6 +98,11 @@ export class Stack { let fontColorInput = $(''); layerBox.append(fontColorInput); + // Set a default background color + const defaultBackgroundClr = '#6699ff'; + fontColorInput.val(defaultBackgroundClr); + self.view.aladin.webglAPI.setFontColor(Color.hexToRgb(defaultBackgroundClr)); + let updateFontColor = function () { let rgb = Color.hexToRgb(fontColorInput.val()); self.view.aladin.webglAPI.setFontColor(rgb); From 4e33ea1b6bac7ab8cf5d632526a45756f36ff60e Mon Sep 17 00:00:00 2001 From: Matthieu BAUMANN Date: Sat, 29 Oct 2022 01:42:12 +0200 Subject: [PATCH 3/4] set rotation + tan change --- deploy.sh | 8 ++++---- src/core/src/line.rs | 2 +- src/core/src/math/projection.rs | 8 ++++---- src/js/Aladin.js | 4 ++++ src/js/View.js | 7 +++++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/deploy.sh b/deploy.sh index 6fe0b8d2..83423a3f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,8 +4,8 @@ DATEUPLOAD="$(date '+%Y-%m-%d')" ssh $USER_ALADIN@aladin 'sg hips -c "mkdir -p $HOME/al-tmp && rm -rf $HOME/al-tmp/*"' scp dist/* $USER_ALADIN@aladin:~/al-tmp -ssh $USER_ALADIN@aladin 'sg hips -c "rm -rf /home/thomas.boch/AladinLite/www/api/v3/27-10-2022 && -mkdir -p /home/thomas.boch/AladinLite/www/api/v3/27-10-2022 && -cp $HOME/al-tmp/* /home/thomas.boch/AladinLite/www/api/v3/27-10-2022 && +ssh $USER_ALADIN@aladin 'sg hips -c "rm -rf /home/thomas.boch/AladinLite/www/api/v3/28-10-2022 && +mkdir -p /home/thomas.boch/AladinLite/www/api/v3/28-10-2022 && +cp $HOME/al-tmp/* /home/thomas.boch/AladinLite/www/api/v3/28-10-2022 && rm -rf /home/thomas.boch/AladinLite/www/api/v3/latest && -ln -s /home/thomas.boch/AladinLite/www/api/v3/27-10-2022 /home/thomas.boch/AladinLite/www/api/v3/latest"' +ln -s /home/thomas.boch/AladinLite/www/api/v3/28-10-2022 /home/thomas.boch/AladinLite/www/api/v3/latest"' diff --git a/src/core/src/line.rs b/src/core/src/line.rs index 729a2536..8d1d7fd7 100644 --- a/src/core/src/line.rs +++ b/src/core/src/line.rs @@ -60,7 +60,7 @@ pub fn project_along_longitudes_and_latitudes( } use crate::ArcDeg; use crate::LonLatT; -const MAX_ANGLE_BEFORE_SUBDIVISION: Angle = Angle(0.20943951023); // 12 degrees +const MAX_ANGLE_BEFORE_SUBDIVISION: Angle = Angle(0.10943951023); // 12 degrees const MAX_ITERATION: usize = 3; pub fn subdivide_along_longitude_and_latitudes( vertices: &mut Vec>, diff --git a/src/core/src/math/projection.rs b/src/core/src/math/projection.rs index ec22a5fb..f037da98 100644 --- a/src/core/src/math/projection.rs +++ b/src/core/src/math/projection.rs @@ -817,8 +817,8 @@ impl Projection for Gnomonic { //if pos_clip_space.x * pos_clip_space.x + pos_clip_space.y * pos_clip_space.y >= 1.0 { // None //} else { - let x_2d = pos_clip_space.x * PI; - let y_2d = pos_clip_space.y * PI; + let x_2d = pos_clip_space.x; + let y_2d = pos_clip_space.y; let r = x_2d * x_2d + y_2d * y_2d; let z = 1.0 / (1.0 + r).sqrt(); @@ -850,8 +850,8 @@ impl Projection for Gnomonic { fn world_to_clip_space_unchecked(&self, pos_world_space: &Vector4) -> Vector2 { let z = pos_world_space.z.abs(); Vector2::new( - (-pos_world_space.x / z) / std::f64::consts::PI, - (pos_world_space.y / z) / std::f64::consts::PI, + -pos_world_space.x / z, + pos_world_space.y / z, ) } } diff --git a/src/js/Aladin.js b/src/js/Aladin.js index 8cff564b..a3f88115 100644 --- a/src/js/Aladin.js +++ b/src/js/Aladin.js @@ -1051,6 +1051,10 @@ export let Aladin = (function () { this.view.decreaseZoom(0.01); }; + Aladin.prototype.setRotation = function(rotation) { + this.view.setRotation(rotation); + } + // @api // Set the current layer that is targeted // Rightclicking for changing the cuts is done the targeted layer diff --git a/src/js/View.js b/src/js/View.js index e71bb741..db79146d 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -787,6 +787,7 @@ export let View = (function () { var scrolling = false; var oldTime = 0; var newTime = 0; + var scrolling; $(view.catalogCanvas).on('wheel', function (event) { event.preventDefault(); event.stopPropagation(); @@ -863,8 +864,6 @@ export let View = (function () { }, 300); } view.debounceProgCatOnZoom(); - //view.setZoomLevel(level); - //view.refreshProgressiveCats(); return false; }); @@ -1384,6 +1383,10 @@ export let View = (function () { this.setZoom(new_fov); } + View.prototype.setRotation = function(rotation) { + this.aladin.webglAPI.setRotationAroundCenter(rotation); + } + View.prototype.setGridConfig = function (gridCfg) { this.aladin.webglAPI.setGridConfig(gridCfg); From fd86576f731d7f48ba3fc40f5646282458513fcd Mon Sep 17 00:00:00 2001 From: Matthieu BAUMANN Date: Sat, 29 Oct 2022 01:43:59 +0200 Subject: [PATCH 4/4] add script showing a big zoom from panstaars to jwst on stephan's quintet --- examples/al-adass2022.html | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/al-adass2022.html diff --git a/examples/al-adass2022.html b/examples/al-adass2022.html new file mode 100644 index 00000000..052e0bf0 --- /dev/null +++ b/examples/al-adass2022.html @@ -0,0 +1,62 @@ + + + + + + + + + + + +
+ +
+ + + + + +