mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 07:40:26 -08:00
fix hover color on catalogs
This commit is contained in:
committed by
Matthieu Baumann
parent
e85945947a
commit
5562d74c0b
@@ -13,7 +13,7 @@
|
||||
// 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]]),
|
||||
@@ -21,7 +21,7 @@
|
||||
]);
|
||||
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);
|
||||
})
|
||||
@@ -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>
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
}
|
||||
);
|
||||
|
||||
hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/CALIFA/V500DR2/");
|
||||
aladin.setImageLayer(hips)
|
||||
//hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/GALFAHI/GALFAHI-Narrow-DR2/");
|
||||
//aladin.setImageLayer(hips)
|
||||
|
||||
/*let id;
|
||||
aladin.on("zoomChanged", () => {
|
||||
|
||||
@@ -20,7 +20,6 @@ pub struct HiPS3DBuffer {
|
||||
textures: HashMap<HEALPixCell, HpxTexture3D>,
|
||||
|
||||
config: HiPSConfig,
|
||||
num_root_textures_available: u8,
|
||||
|
||||
available_tiles_during_frame: bool,
|
||||
|
||||
@@ -31,14 +30,12 @@ impl HiPS3DBuffer {
|
||||
pub fn new(gl: &WebGlContext, config: HiPSConfig) -> Result<Self, JsValue> {
|
||||
let textures = HashMap::new();
|
||||
|
||||
let num_root_textures_available = 0;
|
||||
let available_tiles_during_frame = false;
|
||||
|
||||
let gl = gl.clone();
|
||||
Ok(Self {
|
||||
config,
|
||||
|
||||
num_root_textures_available,
|
||||
textures,
|
||||
available_tiles_during_frame,
|
||||
gl,
|
||||
@@ -135,14 +132,12 @@ impl HpxTileBuffer for HiPS3DBuffer {
|
||||
fn new(gl: &WebGlContext, config: HiPSConfig) -> Result<Self, JsValue> {
|
||||
let textures = HashMap::new();
|
||||
|
||||
let num_root_textures_available = 0;
|
||||
let available_tiles_during_frame = false;
|
||||
|
||||
let gl = gl.clone();
|
||||
Ok(Self {
|
||||
config,
|
||||
|
||||
num_root_textures_available,
|
||||
textures,
|
||||
available_tiles_during_frame,
|
||||
gl,
|
||||
@@ -158,7 +153,15 @@ impl HpxTileBuffer for HiPS3DBuffer {
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
@@ -580,7 +580,7 @@ impl HiPS3D {
|
||||
// * there are new available tiles for the GPU
|
||||
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
|
||||
.slice_indices
|
||||
@@ -588,7 +588,11 @@ impl HiPS3D {
|
||||
.zip(self.cells.iter().zip(self.num_indices.iter()))
|
||||
{
|
||||
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(
|
||||
"tex",
|
||||
self.buffer
|
||||
|
||||
@@ -147,7 +147,14 @@ impl HpxTexture3D {
|
||||
}
|
||||
}
|
||||
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)) => {
|
||||
let b1 = self.blocks[*b_idx_1];
|
||||
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> {
|
||||
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> {
|
||||
|
||||
34
src/js/A.js
34
src/js/A.js
@@ -570,39 +570,41 @@ A.catalog = function (options) {
|
||||
*/
|
||||
A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) {
|
||||
options.url = url;
|
||||
var catalog = A.catalog(options);
|
||||
var c = A.catalog(options);
|
||||
const processVOTable = function (table) {
|
||||
let {sources, fields} = table;
|
||||
catalog.setFields(fields);
|
||||
catalog.addSources(sources);
|
||||
c.setFields(fields);
|
||||
c.addSources(sources);
|
||||
|
||||
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
|
||||
catalog.setShape((s) => {
|
||||
c.setShape((s) => {
|
||||
if (!s.data.s_region)
|
||||
return;
|
||||
|
||||
const shapes = A.footprintsFromSTCS(s.data.s_region, options)
|
||||
let fp = new Footprint(shapes, s);
|
||||
fp.setColor(catalog.color);
|
||||
fp.setColor(c.color);
|
||||
fp.setHoverColor(c.hoverColor);
|
||||
fp.setSelectionColor(c.selectionColor);
|
||||
|
||||
return fp;
|
||||
})
|
||||
}
|
||||
|
||||
if (successCallback) {
|
||||
successCallback(catalog);
|
||||
successCallback(c);
|
||||
}
|
||||
|
||||
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
|
||||
// e.g. access_format and access_url
|
||||
//ObsCore.handleActions(catalog);
|
||||
//ObsCore.handleActions(c);
|
||||
};
|
||||
|
||||
if (useProxy !== undefined) {
|
||||
@@ -610,9 +612,9 @@ A.catalogFromURL = function (url, options, successCallback, errorCallback, usePr
|
||||
url,
|
||||
processVOTable,
|
||||
errorCallback,
|
||||
catalog.maxNbSources,
|
||||
c.maxNbSources,
|
||||
useProxy,
|
||||
catalog.raField, catalog.decField
|
||||
c.raField, c.decField
|
||||
);
|
||||
} else {
|
||||
Catalog.parseVOTable(
|
||||
@@ -623,18 +625,18 @@ A.catalogFromURL = function (url, options, successCallback, errorCallback, usePr
|
||||
url,
|
||||
processVOTable,
|
||||
errorCallback,
|
||||
catalog.maxNbSources,
|
||||
c.maxNbSources,
|
||||
true,
|
||||
catalog.raField, catalog.decField
|
||||
c.raField, c.decField
|
||||
);
|
||||
},
|
||||
catalog.maxNbSources,
|
||||
c.maxNbSources,
|
||||
false,
|
||||
catalog.raField, catalog.decField
|
||||
c.raField, c.decField
|
||||
);
|
||||
}
|
||||
|
||||
return catalog;
|
||||
return c;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -116,6 +116,7 @@ export let Catalog = (function () {
|
||||
this.filterFn = options.filter || undefined; // TODO: do the same for catalog
|
||||
this.selectionColor = options.selectionColor || "#00ff00";
|
||||
this.hoverColor = options.hoverColor || this.color;
|
||||
|
||||
this.displayLabel = options.displayLabel || false;
|
||||
this.labelColor = options.labelColor || this.color;
|
||||
this.labelFont = options.labelFont || "10px sans-serif";
|
||||
@@ -499,7 +500,7 @@ export let Catalog = (function () {
|
||||
options = options || {};
|
||||
this.color = options.color || this.color || 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.shape = options.shape || this.shape || "square";
|
||||
this.onClick = options.onClick || this.onClick;
|
||||
|
||||
@@ -70,7 +70,7 @@ export let Footprint= (function() {
|
||||
if (this.source) {
|
||||
this.source.setCatalog(catalog);
|
||||
|
||||
for (var s of this.shapes) {
|
||||
/*for (var s of this.shapes) {
|
||||
if (!s.color) {
|
||||
s.setColor(catalog.color);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export let Footprint= (function() {
|
||||
// Selection and hover color are catalog options
|
||||
s.setSelectionColor(catalog.selectionColor);
|
||||
s.setHoverColor(catalog.hoverColor);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -116,9 +116,6 @@ export class HiPSBrowserBox extends Box {
|
||||
searchDropdown.removeClass('aladin-valid')
|
||||
searchDropdown.removeClass('aladin-not-valid')
|
||||
},
|
||||
change(e) {
|
||||
_parseHiPS(e)
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -277,6 +274,7 @@ export class HiPSBrowserBox extends Box {
|
||||
}
|
||||
|
||||
_addHiPS(id) {
|
||||
console.log("add hips", id)
|
||||
let self = this;
|
||||
let hips = A.imageHiPS(id, {
|
||||
successCallback: (hips) => {
|
||||
|
||||
@@ -236,6 +236,8 @@ export let Polyline = (function() {
|
||||
if (!color || this.hoverColor == color) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(color)
|
||||
this.hoverColor = color;
|
||||
if (this.overlay) {
|
||||
this.overlay.reportChange();
|
||||
|
||||
Reference in New Issue
Block a user