Skip to content

Commit

Permalink
rename ImageHiPS in HiPS, factorize Image/HiPS, zoom for trackpad ref…
Browse files Browse the repository at this point in the history
…ined
  • Loading branch information
bmatthieu3 committed Sep 10, 2024
1 parent 5fd6bed commit 186e634
Show file tree
Hide file tree
Showing 42 changed files with 1,585 additions and 2,474 deletions.
2 changes: 1 addition & 1 deletion examples/al-aas225.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let aladin;
A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', { fov:0.15, target: 'Arp 240', showReticle: false, fullScreen: true });
aladin.setBaseImageLayer(aladin.newImageSurvey('P/SDSS9/g', {colormap: "rainbow", stretch: "Linear"}));
aladin.setBaseImageLayer(aladin.newImageSurvey('P/SDSS9/g', {colormap: "eosb", stretch: "linear"}));

var simbad = A.catalog({name: 'Simbad', sourceSize: 16, color: '#4050F0'});
aladin.addCatalog(simbad);
Expand Down
2 changes: 1 addition & 1 deletion examples/al-adass2022.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import A from '../src/js/A.js';
let aladin;
A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', {survey: ["P/PanSTARRS/DR1/color-i-r-g"], showReticle: false, projection: "AIT", cooFrame: 'icrs', target: "stephan's quintet", fov: 1000, showGotoControl: false, showFrame: false, fullScreen: true, showLayersControl: true, showCooGrid: true, showCooGridControl: false});
aladin = A.aladin('#aladin-lite-div', {survey: "P/PanSTARRS/DR1/color-z-zg-g", showReticle: false, projection: "AIT", cooFrame: 'icrs', target: "stephan's quintet", fov: 1000, showGotoControl: false, showFrame: false, fullScreen: true, showLayersControl: true, showCooGrid: true, showCooGridControl: false});

const chft = aladin.createImageSurvey('CFHT', "CFHT deep view of NGC7331 and Stephan's quintet u+g+r", "https://cds.unistra.fr/~derriere/PR_HiPS/2022_Duc/", null, null, {imgFormat: 'png'});
const nircamJWST = aladin.createImageSurvey('Nircam', "Stephans Quintet NIRCam+MIRI", "http://alasky.cds.unistra.fr/JWST/CDS_P_JWST_Stephans-Quintet_NIRCam+MIRI/", null, null, {imgFormat: 'png', colormap: "viridis"});
Expand Down
8 changes: 4 additions & 4 deletions examples/al-additive-blend.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
hscGreenSurvey.setColormap("green", { stretch: "asinh" });
hscGreenSurvey.setCuts(-0.2186, 5.30322);

const HSCRedSurvey = aladin.newImageSurvey('CDS/P/HSC/DR2/deep/r', {imgFormat: 'fits', colormap: "red", minCut: 0.34228, maxCut: 2.75785, additive: true, stretch: "asinh"});
const HSCBlueSurvey = aladin.newImageSurvey('CDS/P/HSC/DR2/deep/z', {imgFormat: 'fits', colormap: "blue", minCut: -0.01218, maxCut: 2.27397, additive: true, stretch: "asinh"});
const HSCRedSurvey = aladin.newImageSurvey('P/HSC/DR2/deep/r', {imgFormat: 'fits', colormap: "red", minCut: 0.34228, maxCut: 2.75785, additive: true, stretch: "asinh"});
const HSCBlueSurvey = aladin.newImageSurvey('P/HSC/DR2/deep/z', {imgFormat: 'fits', colormap: "blue", minCut: -0.01218, maxCut: 2.27397, additive: true, stretch: "asinh"});

aladin.setOverlayImageLayer('CDS/P/HSC/DR2/deep/r', 'hsc red layer');
aladin.setOverlayImageLayer('CDS/P/HSC/DR2/deep/z', 'hsc blue layer');
aladin.setOverlayImageLayer('P/HSC/DR2/deep/r', 'hsc red layer');
aladin.setOverlayImageLayer('P/HSC/DR2/deep/z', 'hsc blue layer');
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion examples/al-artifact.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</head>
<body>

<div id="aladin-lite-div" style="width: 1024px; height: 100%;"></div>
<div id="aladin-lite-div" style="width: 1024px; height: 256px;"></div>

<script type="module">
import A from '../src/js/A.js';
Expand Down
4 changes: 2 additions & 2 deletions examples/al-event-listeners.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import A from '../src/js/A.js';
A.init.then(() => {
var aladin = A.aladin('#aladin-lite-div', {showContextMenu: true, target: '05 37 58 +08 17 35', fov: 12, backgroundColor: 'rgb(120, 0, 0)'});
var cat = A.catalog({sourceSize: 20, onClick: 'showTable'});
var cat = A.catalog({sourceSize: 20, onClick: (s) => {console.log("kjk", s)}});
aladin.addCatalog(cat);
cat.addSources([A.source(83.784490, 9.934156, {name: 'Meissa'}), A.source(88.792939, 7.407064, {name: 'Betelgeuse'}), A.source(81.282764, 6.349703, {name: 'Bellatrix'})]);
var msg;

// define function triggered when a source is hovered
aladin.on('click', function(e) {
console.log(e)
Expand Down
2 changes: 1 addition & 1 deletion examples/al-init-custom-options.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
);

aladin.removeHiPSFromFavorites('CDS/P/allWISE/color')
//aladin.removeHiPSFromFavorites('CDS/P/allWISE/color')
});
</script>
<style>
Expand Down
6 changes: 6 additions & 0 deletions examples/al-mars.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
landingSites.addSources([A.marker(-225.71, 47.64, {popupTitle: 'Viking 2', popupDesc: 'Landing date: September 3, 1976 22:37:50'})]);
landingSites.addSources([A.marker(175.472636, -14.5684, {popupTitle: 'Spirit', popupDesc: 'Landing date: January 4, 2004, 04:35 UTC '})]);
landingSites.addSources([A.marker(137.4417, -4.5895, {popupTitle: 'Curiosity', popupDesc: 'Landing date: August 6, 2012, 05:17 UTC '})])

var cat = A.catalog({name: "Temp", sourceSize: 18, onClick: 'showPopup'});
aladin.addCatalog(cat);
cat.addSources(A.source(105.69239256, -8.45235969, {a: 1, b: 2, c:3}));
cat.addSources(A.source(105.70779763, -8.31350997, {a: 4, b: 5, c:6}));
cat.addSources(A.source(105.74242906, -8.34776709, {a: 7, b: 8, c:9}));
});
</script>
</body>
Expand Down
4 changes: 0 additions & 4 deletions examples/al-polyline.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
var overlay = A.graphicOverlay({lineWidth: 2});
aladin.addOverlay(overlay);
overlay.add(A.polyline([ [2.29452158, 59.14978110], [10.12683778, 56.53733116], [14.1772154, 60.7167403], [21.45396446, 60.23528403], [28.59885697, 63.67010079] ], {color: 'green'}));

aladin.select('rect', (s) => {
console.log(s)
})
});
</script>
</body>
Expand Down
5 changes: 4 additions & 1 deletion examples/al-save-colormap.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@

aladin.setImageLayer(survey2);

aladin.removeHiPSFromFavorites(survey3);
/*setTimeout(() => {
aladin.removeHiPSFromFavorites(survey3)
}, 10000);*/


aladin.addColormap('mycmap', ["lightblue", "red", "violet", "lightgreen"])
});
Expand Down
3 changes: 1 addition & 2 deletions examples/al-v2VSv3.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ <h1>Trifid interactive map</h1>

<script type="text/javascript" src="./../dist/aladin.umd.cjs" charset="utf-8"></script>


<!-- Aladin Lite V3 JS code -->
<!-- Creation of Aladin Lite instance with initial parameters -->
<script type="text/javascript">
//import A from '../src/js/A.js';

let aladin;
A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', {survey: "https://alasky.cds.unistra.fr/AllWISE/RGB-W4-W2-W1/", fov:1.5, target: "14 03 12.583 +54 20 55.5", });
aladin = A.aladin('#aladin-lite-div', {fov:1.5, target: "14 03 12.583 +54 20 55.5", });
});
</script>
</body>
Expand Down
103 changes: 38 additions & 65 deletions src/core/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use crate::{
tile_fetcher::TileFetcherQueue,
time::DeltaTime,
};
use al_core::log::console_log;
use std::sync::{Arc, Mutex};
use wcs::WCS;

use wasm_bindgen::prelude::*;
Expand Down Expand Up @@ -53,7 +55,7 @@ pub struct App {
shaders: ShaderManager,
pub camera: CameraViewPort,

downloader: Downloader,
downloader: Rc<RefCell<Downloader>>,
tile_fetcher: TileFetcherQueue,
layers: Layers,

Expand Down Expand Up @@ -146,7 +148,7 @@ impl App {
//gl.enable(WebGl2RenderingContext::CULL_FACE);

// The tile buffer responsible for the tile requests
let downloader = Downloader::new();
let downloader = Rc::new(RefCell::new(Downloader::new()));

let camera = CameraViewPort::new(&gl, CooSystem::ICRS, &projection);
let screen_size = &camera.get_screen_size();
Expand Down Expand Up @@ -266,6 +268,7 @@ impl App {
if self.camera.get_texture_depth() == 0
&& self
.downloader
.borrow()
.is_queried(&query::Allsky::new(survey.get_config()).id)
{
// do not ask for tiles if we download the allsky
Expand All @@ -285,10 +288,12 @@ impl App {
if let Some(tiles_iter) = survey.look_for_new_tiles(&mut self.camera, &self.projection)
{
for tile_cell in tiles_iter.into_iter() {
self.tile_fetcher.append(
query::Tile::new(&tile_cell, creator_did.clone(), root_url.clone(), format),
&mut self.downloader,
);
self.tile_fetcher.append(query::Tile::new(
&tile_cell,
creator_did.clone(),
root_url.clone(),
format,
));

// check if we are starting aladin lite or not.
// If so we want to retrieve only the tiles in the view and access them
Expand All @@ -314,10 +319,12 @@ impl App {
// Request for ancestor
for ancestor in ancestors {
if !survey.update_priority_tile(&ancestor) {
self.tile_fetcher.append(
query::Tile::new(&ancestor, creator_did.clone(), root_url.clone(), format),
&mut self.downloader,
);
self.tile_fetcher.append(query::Tile::new(
&ancestor,
creator_did.clone(),
root_url.clone(),
format,
));
}
}
}
Expand Down Expand Up @@ -489,12 +496,6 @@ impl App {
self.catalog_loaded
}

/*pub(crate) fn is_ready(&self) -> Result<bool, JsValue> {
let res = self.layers.is_ready();
Ok(res)
}*/

pub(crate) fn get_moc(&self, cfg: &al_api::moc::MOC) -> Option<&HEALPixCoverage> {
self.moc.get_hpx_coverage(cfg)
}
Expand Down Expand Up @@ -594,7 +595,7 @@ impl App {
/*let is_there_new_available_tiles = self
.downloader
.get_resolved_tiles(/*&available_tiles, */&mut self.surveys);*/
let rscs_received = self.downloader.get_received_resources();
let rscs_received = self.downloader.borrow_mut().get_received_resources();

let _num_tile_handled = 0;
let _tile_copied = false;
Expand All @@ -621,7 +622,7 @@ impl App {
//let is_tile_root = tile.cell().depth() == delta_depth;
//let _depth = tile.cell().depth();
// do not perform tex_sub costly GPU calls while the camera is zooming
if included_or_near_coverage {
if tile.cell().is_root() || included_or_near_coverage {
let is_missing = tile.missing();
/*self.tile_fetcher.notify_tile(
&tile,
Expand Down Expand Up @@ -721,7 +722,6 @@ impl App {
// The allsky image is missing so we donwload all the tiles contained into
// the 0's cell
let cfg = survey.get_config();
let _delta_depth = cfg.delta_depth();
for texture_cell in crate::healpix::cell::ALLSKY_HPX_CELLS_D0 {
for cell in texture_cell.get_tile_cells(cfg.delta_depth()) {
let query = query::Tile::new(
Expand All @@ -730,8 +730,7 @@ impl App {
cfg.get_root_url().to_string(),
cfg.get_format(),
);
self.tile_fetcher
.append_base_tile(query, &mut self.downloader);
self.tile_fetcher.append_base_tile(query);
}
}
} else {
Expand Down Expand Up @@ -772,27 +771,20 @@ impl App {
}
}

// We fetch when we does not move
/*let has_not_moved_recently =
(Time::now() - self.camera.get_time_of_last_move()) > DeltaTime(100.0);
if has_not_moved_recently && self.inertia.is_none() {
// Triggers the fetching of new queued tiles
self.tile_fetcher.notify(&mut self.downloader);
}*/

// If there is inertia, we do not fetch any new tiles
if self.inertia.is_none() {
let has_not_moved_recently =
(Time::now() - self.camera.get_time_of_last_move()) > DeltaTime(100.0);

/*let dt = if has_not_moved_recently {
None
} else {
Some(DeltaTime::from_millis(700.0))
};*/
if has_not_moved_recently {
self.tile_fetcher.notify(&mut self.downloader, None);
}
// Tiles are fetched if:
let fetch_tiles = self.inertia.is_none() &&
// * the user is not zooming
!self.camera.has_zoomed() &&
// * no inertia action is in progress
(
// * the user is not panning the view
!self.dragging ||
// * or the user is but did not move for at least 100ms
(self.dragging && Time::now() - self.camera.get_time_of_last_move() >= DeltaTime(100.0))
);

if fetch_tiles {
self.tile_fetcher.notify(self.downloader.clone(), None);
}
}

Expand All @@ -811,21 +803,6 @@ impl App {
// - there is at least one tile in its blending phase
let blending_anim_occuring =
(Time::now() - self.time_start_blending) < BLENDING_ANIM_DURATION;
/*let start_fading = self.layers.values_hips().any(|hips| {
if let Some(start_time) = hips.get_ready_time() {
Time::now() - *start_time < BLENDING_ANIM_DURATION
} else {
false
}
});*/

// Finally update the camera that reset the flag camera changed
//if has_camera_moved {
// Catalogues update
/*if let Some(view) = self.layers.get_view() {
self.manager.update(&self.camera, view);
}*/
//}

// Check for async retrieval
if let Ok(img) = self.img_recv.try_recv() {
Expand Down Expand Up @@ -1012,7 +989,7 @@ impl App {
self.layers
.add_image_hips(&self.gl, hips_cfg, &mut self.camera, &self.projection)?;
self.tile_fetcher
.launch_starting_hips_requests(hips, &mut self.downloader);
.launch_starting_hips_requests(hips, self.downloader.clone());

// Once its added, request the tiles in the view (unless the viewer is at depth 0)
self.request_for_new_tiles = true;
Expand Down Expand Up @@ -1318,7 +1295,7 @@ impl App {

// Relaunch the base tiles for the survey to be ready with the new url
self.tile_fetcher
.launch_starting_hips_requests(hips, &mut self.downloader);
.launch_starting_hips_requests(hips, self.downloader.clone());

// Once its added, request the tiles in the view (unless the viewer is at depth 0)
self.request_for_new_tiles = true;
Expand Down Expand Up @@ -1507,7 +1484,7 @@ impl App {
}
}

pub(crate) fn press_left_button_mouse(&mut self, _sx: f32, _sy: f32) {
pub(crate) fn press_left_button_mouse(&mut self) {
self.dist_dragging = 0.0;
self.time_start_dragging = Time::now();
self.dragging = true;
Expand All @@ -1517,11 +1494,10 @@ impl App {
self.out_of_fov = false;
}

pub(crate) fn release_left_button_mouse(&mut self, sx: f32, sy: f32) {
pub(crate) fn release_left_button_mouse(&mut self) {
self.request_for_new_tiles = true;

self.dragging = false;
let _cur_mouse_pos = [sx, sy];

// Check whether the center has moved
// between the pressing and releasing
Expand Down Expand Up @@ -1632,9 +1608,6 @@ impl App {
self.prev_cam_position = self.camera.get_center().truncate();
self.camera.apply_rotation(&(-axis), d, &self.projection);

/* 2. Or just set the center to the current position */
//self.set_center(&cur_pos.lonlat());

self.request_for_new_tiles = true;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/camera/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ use wasm_bindgen::JsCast;

const MAX_DPI_LIMIT: f32 = 3.0;
use crate::math;
use crate::time::Time;
use crate::time::{DeltaTime, Time};
use crate::Abort;
use crate::ArcDeg;
impl CameraViewPort {
Expand Down
2 changes: 0 additions & 2 deletions src/core/src/downloader/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ where
};

let _ = wasm_bindgen_futures::future_to_promise(fut);

log!("launch promises");
}

Self {
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/downloader/request/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use al_core::image::html::HTMLImage;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen_futures::JsFuture;
use web_sys::{HtmlImageElement, RequestInit, RequestMode, Response};
use web_sys::{RequestInit, RequestMode, Response};
impl From<query::Tile> for TileRequest {
// Create a tile request associated to a HiPS
fn from(query: query::Tile) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/healpix/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl HEALPixCell {
}

#[inline(always)]
pub fn is_root(&self, _delta_depth_to_texture: u8) -> bool {
pub fn is_root(&self) -> bool {
self.depth() == 0
}

Expand Down
Loading

0 comments on commit 186e634

Please sign in to comment.