fix hover color on catalogs

This commit is contained in:
Matthieu Baumann
2024-10-25 17:23:36 +02:00
committed by Matthieu Baumann
parent e85945947a
commit 5562d74c0b
10 changed files with 55 additions and 38 deletions

View File

@@ -13,7 +13,7 @@
// Start up Aladin Lite // 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}); 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]}); var overlay = A.graphicOverlay({color: '#ee2345', lineWidth: 3, lineDash: [2, 2]});
aladin.addOverlay(overlay); /*aladin.addOverlay(overlay);
overlay.addFootprints([ 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.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([[83.62807, 22.06330], [83.58397, 22.02280], [83.62792, 22.02258]]),
@@ -21,7 +21,7 @@
]); ]);
overlay.add(A.circle(83.66067, 22.03081, 0.04, {color: 'cyan'})); // radius in degrees 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 overlay.add(A.vector(83.66067, 22.03081, 0.04, {color: 'cyan'})); // radius in degrees
*/
aladin.on("footprintClicked", (footprint, xyMouseCoords) => { aladin.on("footprintClicked", (footprint, xyMouseCoords) => {
console.log("footprint clicked catched: ", footprint, "mouse coords xy: ", xyMouseCoords.x, xyMouseCoords.y); console.log("footprint clicked catched: ", footprint, "mouse coords xy: ", xyMouseCoords.x, xyMouseCoords.y);
}) })
@@ -35,7 +35,7 @@
console.log("Object hovered stopped: ", object, "mouse coords xy: ", xyMouseCoords.x, xyMouseCoords.y); 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); aladin.addCatalog(cat);
}); });
</script> </script>

View File

@@ -30,8 +30,8 @@
} }
); );
hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/CALIFA/V500DR2/"); //hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/GALFAHI/GALFAHI-Narrow-DR2/");
aladin.setImageLayer(hips) //aladin.setImageLayer(hips)
/*let id; /*let id;
aladin.on("zoomChanged", () => { aladin.on("zoomChanged", () => {

View File

@@ -20,7 +20,6 @@ pub struct HiPS3DBuffer {
textures: HashMap<HEALPixCell, HpxTexture3D>, textures: HashMap<HEALPixCell, HpxTexture3D>,
config: HiPSConfig, config: HiPSConfig,
num_root_textures_available: u8,
available_tiles_during_frame: bool, available_tiles_during_frame: bool,
@@ -31,14 +30,12 @@ impl HiPS3DBuffer {
pub fn new(gl: &WebGlContext, config: HiPSConfig) -> Result<Self, JsValue> { pub fn new(gl: &WebGlContext, config: HiPSConfig) -> Result<Self, JsValue> {
let textures = HashMap::new(); let textures = HashMap::new();
let num_root_textures_available = 0;
let available_tiles_during_frame = false; let available_tiles_during_frame = false;
let gl = gl.clone(); let gl = gl.clone();
Ok(Self { Ok(Self {
config, config,
num_root_textures_available,
textures, textures,
available_tiles_during_frame, available_tiles_during_frame,
gl, gl,
@@ -135,14 +132,12 @@ impl HpxTileBuffer for HiPS3DBuffer {
fn new(gl: &WebGlContext, config: HiPSConfig) -> Result<Self, JsValue> { fn new(gl: &WebGlContext, config: HiPSConfig) -> Result<Self, JsValue> {
let textures = HashMap::new(); let textures = HashMap::new();
let num_root_textures_available = 0;
let available_tiles_during_frame = false; let available_tiles_during_frame = false;
let gl = gl.clone(); let gl = gl.clone();
Ok(Self { Ok(Self {
config, config,
num_root_textures_available,
textures, textures,
available_tiles_during_frame, available_tiles_during_frame,
gl, gl,
@@ -158,7 +153,15 @@ impl HpxTileBuffer for HiPS3DBuffer {
} }
fn set_image_ext(&mut self, gl: &WebGlContext, ext: ImageExt) -> Result<(), JsValue> { fn set_image_ext(&mut self, gl: &WebGlContext, ext: ImageExt) -> Result<(), JsValue> {
todo!(); self.config.set_image_ext(ext)?;
let channel = self.config.get_format().get_channel();
self.textures.clear();
//self.ready = false;
self.available_tiles_during_frame = true;
Ok(())
} }
fn read_pixel(&self, pos: &LonLatT<f64>, camera: &CameraViewPort) -> Result<JsValue, JsValue> { fn read_pixel(&self, pos: &LonLatT<f64>, camera: &CameraViewPort) -> Result<JsValue, JsValue> {

View File

@@ -580,7 +580,7 @@ impl HiPS3D {
// * there are new available tiles for the GPU // * there are new available tiles for the GPU
let mut off_idx = 0; let mut off_idx = 0;
let shader = get_raster_shader(cmap, &self.gl, shaders, &hips_cfg)?.bind(&self.gl); let shader = get_raster_shader(cmap, &self.gl, shaders, &hips_cfg)?;
for (slice_idx, (cell, num_indices)) in self for (slice_idx, (cell, num_indices)) in self
.slice_indices .slice_indices
@@ -588,7 +588,11 @@ impl HiPS3D {
.zip(self.cells.iter().zip(self.num_indices.iter())) .zip(self.cells.iter().zip(self.num_indices.iter()))
{ {
blend_cfg.enable(&self.gl, || { blend_cfg.enable(&self.gl, || {
shader // Bind the shader at each draw of a cell to not exceed the max number of tex image units bindable
// to a shader. It is 32 in my case
let shaderbound = shader.bind(&self.gl);
shaderbound
.attach_uniform( .attach_uniform(
"tex", "tex",
self.buffer self.buffer

View File

@@ -147,7 +147,14 @@ impl HpxTexture3D {
} }
} }
Err(i) => { Err(i) => {
match (self.block_indices.get(i - 1), self.block_indices.get(i)) { let prev_block = if i > 0 {
self.block_indices.get(i - 1)
} else {
None
};
let cur_block = self.block_indices.get(i);
match (prev_block, cur_block) {
(Some(b_idx_1), Some(b_idx_2)) => { (Some(b_idx_1), Some(b_idx_2)) => {
let b1 = self.blocks[*b_idx_1]; let b1 = self.blocks[*b_idx_1];
let b2 = self.blocks[*b_idx_2]; let b2 = self.blocks[*b_idx_2];
@@ -184,9 +191,9 @@ impl HpxTexture3D {
} }
pub fn get_3d_block_from_slice(&self, slice: u16) -> Option<&Texture3D> { pub fn get_3d_block_from_slice(&self, slice: u16) -> Option<&Texture3D> {
let block_idx = slice >> 5; let block_idx = (slice >> 5) as usize;
self.textures[block_idx as usize].as_ref() self.textures[block_idx].as_ref()
} }
pub fn extract_2d_slice_texture(&self, slice: u16) -> Option<HpxTexture2D> { pub fn extract_2d_slice_texture(&self, slice: u16) -> Option<HpxTexture2D> {

View File

@@ -570,39 +570,41 @@ A.catalog = function (options) {
*/ */
A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) { A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) {
options.url = url; options.url = url;
var catalog = A.catalog(options); var c = A.catalog(options);
const processVOTable = function (table) { const processVOTable = function (table) {
let {sources, fields} = table; let {sources, fields} = table;
catalog.setFields(fields); c.setFields(fields);
catalog.addSources(sources); c.addSources(sources);
const s_regionFieldFound = Array.from(Object.keys(fields)).find((f) => f.toLowerCase() === 's_region'); const s_regionFieldFound = Array.from(Object.keys(fields)).find((f) => f.toLowerCase() === 's_region');
if (s_regionFieldFound && typeof catalog.shape !== 'function') { if (s_regionFieldFound && typeof c.shape !== 'function') {
// set the shape // set the shape
catalog.setShape((s) => { c.setShape((s) => {
if (!s.data.s_region) if (!s.data.s_region)
return; return;
const shapes = A.footprintsFromSTCS(s.data.s_region, options) const shapes = A.footprintsFromSTCS(s.data.s_region, options)
let fp = new Footprint(shapes, s); let fp = new Footprint(shapes, s);
fp.setColor(catalog.color); fp.setColor(c.color);
fp.setHoverColor(c.hoverColor);
fp.setSelectionColor(c.selectionColor);
return fp; return fp;
}) })
} }
if (successCallback) { if (successCallback) {
successCallback(catalog); successCallback(c);
} }
if (sources.length === 0) { if (sources.length === 0) {
console.warn(catalog.name + ' has no sources!') console.warn(c.name + ' has no sources!')
} }
// Even if the votable is not a proper ObsCore one, try to see if specific columns are given // Even if the votable is not a proper ObsCore one, try to see if specific columns are given
// e.g. access_format and access_url // e.g. access_format and access_url
//ObsCore.handleActions(catalog); //ObsCore.handleActions(c);
}; };
if (useProxy !== undefined) { if (useProxy !== undefined) {
@@ -610,9 +612,9 @@ A.catalogFromURL = function (url, options, successCallback, errorCallback, usePr
url, url,
processVOTable, processVOTable,
errorCallback, errorCallback,
catalog.maxNbSources, c.maxNbSources,
useProxy, useProxy,
catalog.raField, catalog.decField c.raField, c.decField
); );
} else { } else {
Catalog.parseVOTable( Catalog.parseVOTable(
@@ -623,18 +625,18 @@ A.catalogFromURL = function (url, options, successCallback, errorCallback, usePr
url, url,
processVOTable, processVOTable,
errorCallback, errorCallback,
catalog.maxNbSources, c.maxNbSources,
true, true,
catalog.raField, catalog.decField c.raField, c.decField
); );
}, },
catalog.maxNbSources, c.maxNbSources,
false, false,
catalog.raField, catalog.decField c.raField, c.decField
); );
} }
return catalog; return c;
}; };
/** /**

View File

@@ -116,6 +116,7 @@ export let Catalog = (function () {
this.filterFn = options.filter || undefined; // TODO: do the same for catalog this.filterFn = options.filter || undefined; // TODO: do the same for catalog
this.selectionColor = options.selectionColor || "#00ff00"; this.selectionColor = options.selectionColor || "#00ff00";
this.hoverColor = options.hoverColor || this.color; this.hoverColor = options.hoverColor || this.color;
this.displayLabel = options.displayLabel || false; this.displayLabel = options.displayLabel || false;
this.labelColor = options.labelColor || this.color; this.labelColor = options.labelColor || this.color;
this.labelFont = options.labelFont || "10px sans-serif"; this.labelFont = options.labelFont || "10px sans-serif";
@@ -499,7 +500,7 @@ export let Catalog = (function () {
options = options || {}; options = options || {};
this.color = options.color || this.color || Color.getNextColor(); this.color = options.color || this.color || Color.getNextColor();
this.selectionColor = options.selectionColor || this.selectionColor || Color.getNextColor(); this.selectionColor = options.selectionColor || this.selectionColor || Color.getNextColor();
this.hoverColor = options.hoverColor || this.color; this.hoverColor = options.hoverColor || this.hoverColor || this.color;
this.sourceSize = options.sourceSize || this.sourceSize || 6; this.sourceSize = options.sourceSize || this.sourceSize || 6;
this.shape = options.shape || this.shape || "square"; this.shape = options.shape || this.shape || "square";
this.onClick = options.onClick || this.onClick; this.onClick = options.onClick || this.onClick;

View File

@@ -70,7 +70,7 @@ export let Footprint= (function() {
if (this.source) { if (this.source) {
this.source.setCatalog(catalog); this.source.setCatalog(catalog);
for (var s of this.shapes) { /*for (var s of this.shapes) {
if (!s.color) { if (!s.color) {
s.setColor(catalog.color); s.setColor(catalog.color);
} }
@@ -78,7 +78,7 @@ export let Footprint= (function() {
// Selection and hover color are catalog options // Selection and hover color are catalog options
s.setSelectionColor(catalog.selectionColor); s.setSelectionColor(catalog.selectionColor);
s.setHoverColor(catalog.hoverColor); s.setHoverColor(catalog.hoverColor);
} }*/
} }
}; };

View File

@@ -116,9 +116,6 @@ export class HiPSBrowserBox extends Box {
searchDropdown.removeClass('aladin-valid') searchDropdown.removeClass('aladin-valid')
searchDropdown.removeClass('aladin-not-valid') searchDropdown.removeClass('aladin-not-valid')
}, },
change(e) {
_parseHiPS(e)
},
}, },
}); });
@@ -277,6 +274,7 @@ export class HiPSBrowserBox extends Box {
} }
_addHiPS(id) { _addHiPS(id) {
console.log("add hips", id)
let self = this; let self = this;
let hips = A.imageHiPS(id, { let hips = A.imageHiPS(id, {
successCallback: (hips) => { successCallback: (hips) => {

View File

@@ -236,6 +236,8 @@ export let Polyline = (function() {
if (!color || this.hoverColor == color) { if (!color || this.hoverColor == color) {
return; return;
} }
console.log(color)
this.hoverColor = color; this.hoverColor = color;
if (this.overlay) { if (this.overlay) {
this.overlay.reportChange(); this.overlay.reportChange();