Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HiPS cube support #204

Merged
merged 7 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/al-footprints.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
// Start up Aladin Lite
aladin = A.aladin('#aladin-lite-div', {survey: "CDS/P/DSS2/color", target: 'M 1', fov: 0.2, showContextMenu: true, fullScreen: true});
var overlay = A.graphicOverlay({color: '#ee2345', lineWidth: 3, lineDash: [2, 2]});
aladin.addOverlay(overlay);
/*aladin.addOverlay(overlay);
overlay.addFootprints([
A.polygon([[83.64287, 22.01713], [83.59872, 22.01692], [83.59852, 21.97629], [83.64295, 21.97629]], {hoverColor: 'green'}),
A.polygon([[83.62807, 22.06330], [83.58397, 22.02280], [83.62792, 22.02258]]),
A.polygon([[8.62807, 220.06330], [83.58397, 10.02280], [150.62792, 87.02258]])
]);
overlay.add(A.circle(83.66067, 22.03081, 0.04, {color: 'cyan'})); // radius in degrees
overlay.add(A.vector(83.66067, 22.03081, 0.04, {color: 'cyan'})); // radius in degrees

*/
aladin.on("footprintClicked", (footprint, xyMouseCoords) => {
console.log("footprint clicked catched: ", footprint, "mouse coords xy: ", xyMouseCoords.x, xyMouseCoords.y);
})
Expand All @@ -35,7 +35,7 @@
console.log("Object hovered stopped: ", object, "mouse coords xy: ", xyMouseCoords.x, xyMouseCoords.y);
})

const cat = A.catalogFromVizieR('B/assocdata/obscore', 'M 1', 10, {onClick: 'showTable', hoverColor: 'purple', limit: 10000});
const cat = A.catalogFromVizieR('B/assocdata/obscore', 'M 1', 10, {onClick: 'showTable', selectionColor: "orange", hoverColor: 'red', limit: 10000});
aladin.addCatalog(cat);
});
</script>
Expand Down
52 changes: 52 additions & 0 deletions examples/al-hips-cube.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
</head>
<body>


<div id="aladin-lite-div" style="width: 768px; height: 512px"></div>
<script>let aladin; let hips;</script>
<script type="module">
import A from '../src/js/A.js';
A.init.then(() => {
aladin = A.aladin(
'#aladin-lite-div',
{
showSimbadPointerControl: true,
projection: 'AIT', // set a projection
fov: 360, // initial field of view in degrees
target: '169.58868 +45.74914', // initial target
cooFrame: 'icrs', // set galactic frame
reticleColor: '#ff89ff', // change reticle color
reticleSize: 64, // change reticle size
showContextMenu: true,
showFrame: true,
showZoomControl:true,
showSettingsControl:true,
showCooGrid: true,
fullScreen: true,
samp: true,
}
);

//hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/GALFAHI/GALFAHI-Narrow-DR2/");
//aladin.setImageLayer(hips)

/*let id;
aladin.on("zoomChanged", () => {
if (id)
clearTimeout(id);
id = setTimeout(() => {
console.log("wheel stopped, new cone search here")
}, 500);
})*/
});
</script>
<style>
.aladin-cat-browser-box {
width: 600px;
}
</style>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/al-save-colormap.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

aladin.setImageLayer(survey2);

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


aladin.addColormap('mycmap', ["lightblue", "red", "violet", "lightgreen"])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"homepage": "https://aladin.u-strasbg.fr/",
"name": "aladin-lite",
"type": "module",
"version": "3.5.1-beta",
"version": "3.6.0-beta",
"description": "An astronomical HiPS visualizer in the browser",
"author": "Thomas Boch and Matthieu Baumann",
"license": "GPL-3",
Expand Down
6 changes: 2 additions & 4 deletions src/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ optional = true

[dependencies.healpix]
package = "cdshealpix"
git = "https://github.com/cds-astro/cds-healpix-rust"
branch = "master"
version = "0.7.0"

[dependencies.moclib]
package = "moc"
git = "https://github.com/cds-astro/cds-moc-rust"
branch = "main"
version = "0.17.0"

[dependencies.serde]
version = "^1.0.183"
Expand Down
6 changes: 6 additions & 0 deletions src/core/al-api/src/hips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct HiPSProperties {
hips_initial_fov: Option<f64>,
hips_initial_ra: Option<f64>,
hips_initial_dec: Option<f64>,
hips_cube_depth: Option<u32>,

// Parametrable by the user
#[allow(unused)]
Expand Down Expand Up @@ -78,6 +79,11 @@ impl HiPSProperties {
self.min_order
}

#[inline(always)]
pub fn get_cube_depth(&self) -> Option<u32> {
self.hips_cube_depth
}

#[inline(always)]
pub fn get_bitpix(&self) -> Option<i32> {
self.bitpix
Expand Down
13 changes: 4 additions & 9 deletions src/core/al-core/src/image/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@ where
}
}
}
use crate::texture::Texture2DArray;
use crate::texture::Tex3D;
use wasm_bindgen::JsValue;
impl<F> Image for Bitmap<F>
where
F: ImageFormat + Clone,
{
fn tex_sub_image_3d(
fn insert_into_3d_texture<T: Tex3D>(
&self,
textures: &Texture2DArray,
textures: &T,
offset: &Vector3<i32>,
) -> Result<(), JsValue> {
textures.bind().tex_sub_image_3d_with_image_bitmap(
offset.z,
offset.x,
offset.y,
&self.image,
);
textures.tex_sub_image_3d_with_image_bitmap(offset.x, offset.y, offset.z, &self.image);

Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/al-core/src/image/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ where

use crate::image::format::ImageFormat;
use crate::image::Image;
use crate::texture::Texture2DArray;
use crate::texture::Tex3D;
use cgmath::Vector3;
use wasm_bindgen::JsValue;
impl<F> Image for Canvas<F>
where
F: ImageFormat,
{
fn tex_sub_image_3d(
fn insert_into_3d_texture<T: Tex3D>(
&self,
// The texture array
textures: &Texture2DArray,
textures: &T,
// An offset to write the image in the texture array
offset: &Vector3<i32>,
) -> Result<(), JsValue> {
textures.bind().tex_sub_image_3d_with_html_canvas_element(
offset.z,
textures.tex_sub_image_3d_with_html_canvas_element(
offset.x,
offset.y,
offset.z,
&self.canvas,
);

Expand Down
27 changes: 15 additions & 12 deletions src/core/al-core/src/image/fits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,58 +116,61 @@ impl<'a> Fits<'a> {
}
}*/

use crate::image::Image;
use crate::Texture2DArray;
use crate::{image::Image, texture::Tex3D};
impl Image for Fits<'_> {
fn tex_sub_image_3d(
fn insert_into_3d_texture<T: Tex3D>(
&self,
// The texture array
textures: &Texture2DArray,
textures: &T,
// An offset to write the image in the texture array
offset: &Vector3<i32>,
) -> Result<(), JsValue> {
match &self.data {
Data::U8(data) => {
let view = unsafe { R8UI::view(&data) };
textures.bind().tex_sub_image_3d_with_opt_array_buffer_view(
offset.z,
textures.tex_sub_image_3d_with_opt_array_buffer_view(
offset.x,
offset.y,
offset.z,
self.size.x,
self.size.y,
1,
Some(view.as_ref()),
);
}
Data::I16(data) => {
let view = unsafe { R16I::view(&data) };
textures.bind().tex_sub_image_3d_with_opt_array_buffer_view(
offset.z,
textures.tex_sub_image_3d_with_opt_array_buffer_view(
offset.x,
offset.y,
offset.z,
self.size.x,
self.size.y,
1,
Some(view.as_ref()),
);
}
Data::I32(data) => {
let view = unsafe { R32I::view(&data) };
textures.bind().tex_sub_image_3d_with_opt_array_buffer_view(
offset.z,
textures.tex_sub_image_3d_with_opt_array_buffer_view(
offset.x,
offset.y,
offset.z,
self.size.x,
self.size.y,
1,
Some(view.as_ref()),
);
}
Data::F32(data) => {
let view = unsafe { R32F::view(&data) };
textures.bind().tex_sub_image_3d_with_opt_array_buffer_view(
offset.z,
textures.tex_sub_image_3d_with_opt_array_buffer_view(
offset.x,
offset.y,
offset.z,
self.size.x,
self.size.y,
1,
Some(view.as_ref()),
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/al-core/src/image/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ where

use crate::image::format::ImageFormat;
use crate::image::Image;
use crate::texture::Texture2DArray;
use crate::texture::{Tex3D, Texture2DArray};
use cgmath::Vector3;
use wasm_bindgen::JsValue;
impl<F> Image for HTMLImage<F>
where
F: ImageFormat,
{
fn tex_sub_image_3d(
fn insert_into_3d_texture<T: Tex3D>(
&self,
// The texture array
textures: &Texture2DArray,
textures: &T,
// An offset to write the image in the texture array
offset: &Vector3<i32>,
) -> Result<(), JsValue> {
textures.bind().tex_sub_image_3d_with_html_image_element(
offset.z,
textures.tex_sub_image_3d_with_html_image_element(
offset.x,
offset.y,
offset.z,
&self.image,
);

Expand Down
Loading
Loading