Skip to content

Commit

Permalink
fix hover color on catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatthieu3 committed Oct 25, 2024
1 parent ce735ab commit 73e970c
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 38 deletions.
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
4 changes: 2 additions & 2 deletions examples/al-hips-cube.html
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
15 changes: 9 additions & 6 deletions src/core/src/renderable/hips/d3/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub struct HiPS3DBuffer {
textures: HashMap<HEALPixCell, HpxTexture3D>,

config: HiPSConfig,
num_root_textures_available: u8,

available_tiles_during_frame: bool,

Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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> {
Expand Down
8 changes: 6 additions & 2 deletions src/core/src/renderable/hips/d3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,19 @@ 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
.iter()
.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
Expand Down
13 changes: 10 additions & 3 deletions src/core/src/renderable/hips/d3/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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> {
Expand Down
34 changes: 18 additions & 16 deletions src/js/A.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,49 +570,51 @@ 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) {
Catalog.parseVOTable(
url,
processVOTable,
errorCallback,
catalog.maxNbSources,
c.maxNbSources,
useProxy,
catalog.raField, catalog.decField
c.raField, c.decField
);
} else {
Catalog.parseVOTable(
Expand All @@ -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;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/js/Catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/js/Footprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ 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);
}
// Selection and hover color are catalog options
s.setSelectionColor(catalog.selectionColor);
s.setHoverColor(catalog.hoverColor);
}
}*/
}
};

Expand Down
4 changes: 1 addition & 3 deletions src/js/gui/Box/HiPSBrowserBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ export class HiPSBrowserBox extends Box {
searchDropdown.removeClass('aladin-valid')
searchDropdown.removeClass('aladin-not-valid')
},
change(e) {
_parseHiPS(e)
},
},
});

Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 2 additions & 0 deletions src/js/shapes/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 73e970c

Please sign in to comment.