From c35d8e4e8c91744edb40ed561aa2cb2eac478ffe Mon Sep 17 00:00:00 2001 From: Matthieu BAUMANN Date: Wed, 26 Apr 2023 11:35:20 +0200 Subject: [PATCH] shorten table name in measurement table --- examples/al-obscore.html | 8 ++- examples/datalink.xml | 34 ++++----- src/core/Cargo.toml | 4 +- src/core/al-core/Cargo.toml | 2 +- src/core/src/app.rs | 9 ++- src/core/src/renderable/image/mod.rs | 10 ++- .../src/renderable/image/subdivide_texture.rs | 71 ++++++++++--------- src/js/DefaultActionsForContextMenu.js | 6 +- src/js/MeasurementTable.js | 8 +++ src/js/View.js | 6 +- src/js/vo/VOTable.js | 11 ++- 11 files changed, 102 insertions(+), 67 deletions(-) diff --git a/examples/al-obscore.html b/examples/al-obscore.html index caf6aa8d..33665984 100644 --- a/examples/al-obscore.html +++ b/examples/al-obscore.html @@ -13,11 +13,13 @@ A.init.then(() => { aladin = A.aladin('#aladin-lite-div', {target: '14 18 16.868 +56 44 29.37', fov: 5, showContextMenu: true}); - const catalog = A.catalogFromURL('./ObsCore_003.xml', {onClick: 'showTable'}); - //const catalog = A.catalogFromURL('https://vo.astron.nl/tap/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.obscore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+214.92068%2C+56.81529%2C+3.03%29%29+%3D+1+', {onClick: 'showTable'}); -// const catalog = A.catalogFromURL('http://archive.eso.org/tap_obs/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.ObsCore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+83.82184%2C+-5.38635%2C+0.14798%29%29+%3D+1+AND+obs_collection+%3D+%27MUSE%27+', {onClick: 'showTable'}); + //const c1 = A.catalogFromURL('./ObsCore_003.xml', {onClick: 'showTable'}); + const catalog = A.catalogFromURL('https://vo.astron.nl/tap/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.obscore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+214.92068%2C+56.81529%2C+3.03%29%29+%3D+1+', {onClick: 'showTable'}); + //const c2 = A.catalogFromURL('http://archive.eso.org/tap_obs/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.ObsCore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+83.82184%2C+-5.38635%2C+0.14798%29%29+%3D+1+AND+obs_collection+%3D+%27MUSE%27+', {onClick: 'showTable'}); aladin.addCatalog(catalog); + //aladin.addCatalog(c2); + }); diff --git a/examples/datalink.xml b/examples/datalink.xml index 9435a366..26b09662 100644 --- a/examples/datalink.xml +++ b/examples/datalink.xml @@ -18,8 +18,8 @@ ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 https://vo.astron.nl/getproduct/APERTIF_DR1/200110007_AP_B037/HI_image_cube3.fits - a - a + + #this The full dataset image/fits @@ -29,8 +29,8 @@ ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 https://alasky.cds.unistra.fr/hips-cube-services/compute/hips:httpsalasky.cds.unistra.fr;SKA-demo;hips;APERTIF;HiPS_APERTIF_cube_NGC5585-cubic-tiles%7Cexpr:s0_1211 - a - a + + #derived Moment zero map of the cube (in HiPS format) application/hips @@ -40,8 +40,8 @@ ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 https://alasky.cds.unistra.fr/hips-cube-services/compute/hips:httpsalasky.cds.unistra.fr;SKA-demo;hips;APERTIF;HiPS_APERTIF_cube_NGC5585-cubic-tiles%7Cexpr:s345_410-(s0_1211;24) - a - a + + #derived HI Line map derived from the cube (in HiPS format) application/hips @@ -51,8 +51,8 @@ ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 https://alasky.cds.unistra.fr/hips-cube-services/color/hips:httpsalasky.cds.unistra.fr;SKA-demo;hips;APERTIF;HiPS_APERTIF_cube_NGC5585%7Cblue:345-365%7Cgreen:365-385%7Cred:385-405 - a - a + + #derived velocity variation color map derived from the cube (in HiPS format) application/hips @@ -61,36 +61,36 @@ ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 - a + soda-HiPS - a + #cutout SODA-HiPS cutout of moment zero map of ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 image/fits 0 - a + ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 - a + soda-sync - a + #cutout SODA-sync cutout of ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 image/fits 0 - a + ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 - a + soda-async - a + #cutout SODA-async cutout of ivo://SKA/SrcNet/APERTIF_DR1/200110007_AP_B037/HI_image_cube3 image/fits 0 - a + diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index be4cc439..27cbd075 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -30,7 +30,7 @@ serde = { version = "^1.0.59", features = ["derive"] } serde_json = "1.0" serde-wasm-bindgen = "0.4" console_error_panic_hook = "0.1.7" -fitsrs = "0.2.6" +fitsrs = "0.2.7" enum_dispatch = "0.3.8" wasm-bindgen = "0.2.79" wasm-streams = "0.3.0" @@ -42,6 +42,7 @@ mapproj = "0.3.0" wcs = "0.2.4" colorgrad = "0.6.2" image-decoder = { package = "image", version = "0.24.2", default-features = false, features = ["jpeg", "png"] } +#votable = { git = "https://github.com/cds-astro/cds-votable-rust", branch = "main" } votable = "0.2.0" [features] @@ -88,6 +89,7 @@ features = [ 'WebGlUniformLocation', 'WebGlTexture', 'WebGlActiveInfo', + 'Headers', 'Window', 'Request', diff --git a/src/core/al-core/Cargo.toml b/src/core/al-core/Cargo.toml index 83d2f939..b1b2c374 100644 --- a/src/core/al-core/Cargo.toml +++ b/src/core/al-core/Cargo.toml @@ -9,7 +9,7 @@ js-sys = "0.3.47" cgmath = "*" jpeg-decoder = "0.3.0" png = "0.17.6" -fitsrs = "0.2.6" +fitsrs = "0.2.7" al-api = { path = "../al-api" } serde = { version = "^1.0.59", features = ["derive"] } serde_json = "1.0" diff --git a/src/core/src/app.rs b/src/core/src/app.rs index 9802f745..a8a00cec 100644 --- a/src/core/src/app.rs +++ b/src/core/src/app.rs @@ -894,9 +894,16 @@ impl App { use crate::renderable::image::Image; use futures::TryStreamExt; use futures::future::Either; + use web_sys::{Request, RequestInit, RequestMode, Headers}; + + let mut opts = RequestInit::new(); + opts.method("GET"); + opts.mode(RequestMode::Cors); let window = window().unwrap(); - let resp_value = JsFuture::from(window.fetch_with_str(&url)) + let request = Request::new_with_str_and_init(&url, &opts)?; + + let resp_value = JsFuture::from(window.fetch_with_request(&request)) .await?; let resp: Response = resp_value.dyn_into()?; diff --git a/src/core/src/renderable/image/mod.rs b/src/core/src/renderable/image/mod.rs index 73e683b8..e46c687b 100644 --- a/src/core/src/renderable/image/mod.rs +++ b/src/core/src/renderable/image/mod.rs @@ -98,6 +98,8 @@ impl Image { // Load the fits file let header = hdu.get_header(); + al_core::log(&format!("header: {:?}", header)); + let naxis = header.get_xtension().get_naxis(); if naxis == 0 { @@ -129,7 +131,7 @@ impl Image { let data = hdu.get_data_mut(); - let (textures, channel, cuts) = match data { + let (textures, channel, mut cuts) = match data { stream::Data::U8(data) => { let reader = data .map_ok(|v| { @@ -221,7 +223,7 @@ impl Image { v[0].to_le_bytes() }) .into_async_read(); - + //al_core::log(&format!("{:?}", )) let (textures, samples) = subdivide_texture::build::(gl, w, h, reader, max_tex_size).await?; let mut samples = samples @@ -314,6 +316,10 @@ impl Image { vao }; + // apply bscale to the cuts + cuts.start = cuts.start * scale + offset; + cuts.end = cuts.end * scale + offset; + let gl = gl.clone(); // Compute the fov diff --git a/src/core/src/renderable/image/subdivide_texture.rs b/src/core/src/renderable/image/subdivide_texture.rs index d2dfee27..f6c41c9f 100644 --- a/src/core/src/renderable/image/subdivide_texture.rs +++ b/src/core/src/renderable/image/subdivide_texture.rs @@ -30,6 +30,8 @@ where let mut pixels_written = 0; let num_pixels = width * height; + al_core::log(&format!("pixels written {:?}, num pixels {:?}", pixels_written, num_pixels)); + let step_x_cut = (width / 50) as usize; let step_y_cut = (height / 50) as usize; @@ -55,48 +57,49 @@ where }; let num_bytes_to_read = (num_pixels_to_read as usize) * std::mem::size_of::<::Item>(); - reader.read_exact(&mut buf[..num_bytes_to_read]) - .await - .map_err(|_| JsValue::from_str("Read some bytes error"))?; + al_core::log(&format!("max tex size {:?} written {:?}, {:?}", max_tex_size, pixels_written, num_pixels)); + if let Ok(()) = reader.read_exact(&mut buf[..num_bytes_to_read]).await { + // Tell where the data must go inside the texture + let off_y_px = id_ty * max_tex_size; - // Tell where the data must go inside the texture - let off_y_px = id_ty * max_tex_size; + let dy = (pixels_written / width) - off_y_px; + let view = unsafe { + let slice = std::slice::from_raw_parts( + buf[..num_bytes_to_read].as_ptr() as *const ::Item, + num_pixels_to_read as usize + ); - let dy = (pixels_written / width) - off_y_px; - let view = unsafe { - let slice = std::slice::from_raw_parts( - buf[..num_bytes_to_read].as_ptr() as *const ::Item, - num_pixels_to_read as usize - ); + // fill the samples buffer + if (pixels_written / width) % (step_cut as u64) == 0 { + // We are in a good line + let xmin = pixels_written % width; - // fill the samples buffer - if (pixels_written / width) % (step_cut as u64) == 0 { - // We are in a good line - let xmin = pixels_written % width; - - for i in (0..width).step_by(step_cut) { - if (xmin..(xmin + num_pixels_to_read)).contains(&i) { - let j = (i - xmin) as usize; - - samples.push(slice[j]); + for i in (0..width).step_by(step_cut) { + if (xmin..(xmin + num_pixels_to_read)).contains(&i) { + let j = (i - xmin) as usize; + + samples.push(slice[j]); + } } } - } - F::view(slice) - }; + F::view(slice) + }; - (&mut tex_chunks[id_t as usize]) - .bind() - .tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_array_buffer_view( - 0, - dy as i32, - num_pixels_to_read as i32, - 1, - Some(view.as_ref()) - ); + (&mut tex_chunks[id_t as usize]) + .bind() + .tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_array_buffer_view( + 0, + dy as i32, + num_pixels_to_read as i32, + 1, + Some(view.as_ref()) + ); - pixels_written += num_pixels_to_read; + pixels_written += num_pixels_to_read; + } else { + pixels_written = num_pixels; + } } Ok((tex_chunks, samples)) diff --git a/src/js/DefaultActionsForContextMenu.js b/src/js/DefaultActionsForContextMenu.js index 86a2c7bf..ca43e8f1 100644 --- a/src/js/DefaultActionsForContextMenu.js +++ b/src/js/DefaultActionsForContextMenu.js @@ -138,13 +138,13 @@ export let DefaultActionsForContextMenu = (function () { window.open(hips2fitsUrl, '_blank'); } }, - /* { label: "Select sources", action(o) { - aladinInstance.select(); + const a = aladinInstance; + + a.select(); } }, - */ ] } diff --git a/src/js/MeasurementTable.js b/src/js/MeasurementTable.js index 05026547..e90f8704 100644 --- a/src/js/MeasurementTable.js +++ b/src/js/MeasurementTable.js @@ -226,7 +226,15 @@ export let MeasurementTable = (function() { let self = this; this.tables.forEach(function(table, index) { let tabButtonElement = document.createElement("button"); + tabButtonElement.setAttribute('title', table["name"]) + tabButtonElement.innerText = table["name"]; + tabButtonElement.style.overflow = 'hidden'; + tabButtonElement.style.textOverflow = 'ellipsis'; + tabButtonElement.style.whiteSpace = 'nowrap'; + tabButtonElement.style.maxWidth = '20%'; + + tabButtonElement tabButtonElement.addEventListener( 'click', diff --git a/src/js/View.js b/src/js/View.js index 22389f7f..809ab67a 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -652,8 +652,6 @@ export let View = (function () { return; // when in TOOL_SIMBAD_POINTER mode, we do not call the listeners } - - // popup to show ? var objs = view.closestObjects(xymouse.x, xymouse.y, 5); if (!wasDragging && objs) { @@ -674,6 +672,9 @@ export let View = (function () { if (view.lastClickedObject) { view.lastClickedObject.actionOtherObjectClicked && view.lastClickedObject.actionOtherObjectClicked(); } + } + + if (o.actionClicked) { o.actionClicked(); } @@ -681,7 +682,6 @@ export let View = (function () { var objClickedFunction = view.aladin.callbacksByEventName['objectClicked']; (typeof objClickedFunction === 'function') && objClickedFunction(o); } else { - if (!wasDragging) { // Deselect objects if any view.deselectObjects(); diff --git a/src/js/vo/VOTable.js b/src/js/vo/VOTable.js index 87742c7f..d7d59695 100644 --- a/src/js/vo/VOTable.js +++ b/src/js/vo/VOTable.js @@ -56,22 +56,29 @@ export let VOTable = (function() { let tables = resource.get("tables") if (tables) { tables.forEach((table) => { + console.log(table.get("elems")) + let fields = table.get("elems") + .filter((elem) => { + const elemType = elem["elem_type"] || elem.get("elem_type") + return elemType === "Field"; + }) .map((field) => { // convert a map into a javascript object return Object.fromEntries(field); }) - + try { fields = ObsCore.parseFields(fields); + fields.subtype = "ObsCore"; + console.log("obscore") } catch(e) { // It is not an ObsCore table fields = Catalog.parseFields(fields, raField, decField); } let data = table.get("data"); - if (data) { let rows = data.get("rows");