Compare commits

...

2 Commits

Author SHA1 Message Date
Matthieu Baumann
5c70d0211c fix clippy 2025-08-28 16:13:04 +02:00
Matthieu Baumann
e66ddc557e Fix wrong coordinates frame 2025-08-28 15:57:46 +02:00
7 changed files with 67 additions and 46 deletions

View File

@@ -71,7 +71,7 @@ impl Texture3D {
self.gl.generate_mipmap(WebGlRenderingCtx::TEXTURE_3D);
}
pub fn bind(&self) -> Texture3DBound {
pub fn bind(&self) -> Texture3DBound<'_> {
self.gl
.bind_texture(WebGlRenderingCtx::TEXTURE_3D, self.texture.as_ref());

View File

@@ -70,7 +70,7 @@ impl Texture2DArray {
self.gl.generate_mipmap(WebGlRenderingCtx::TEXTURE_2D_ARRAY);
}
pub fn bind(&self) -> Texture2DArrayBound {
pub fn bind(&self) -> Texture2DArrayBound<'_> {
self.gl
.bind_texture(WebGlRenderingCtx::TEXTURE_2D_ARRAY, self.texture.as_ref());

View File

@@ -295,7 +295,7 @@ impl Texture2D {
self
}
pub fn bind(&self) -> Texture2DBound {
pub fn bind(&self) -> Texture2DBound<'_> {
self.gl
.bind_texture(WebGlRenderingCtx::TEXTURE_2D, self.texture.as_ref());

View File

@@ -3126,7 +3126,7 @@ aladin.displayFITS(
);
}
if (executeDefaultSuccessAction === true) {
self.wasm.setCenter(meta.ra, meta.dec);
self.gotoRaDec(meta.ra, meta.dec);
self.setFoV(meta.fov);
}

View File

@@ -213,7 +213,7 @@ export let View = (function () {
this.fov = this.options.fov || 180.0
// Target position settings
this.viewCenter = { lon, lat }; // position of center of view
this.viewCenter = { ra: lon, dec: lat }; // position of center of view always in ICRS
// Coo frame setting
const cooFrame = CooFrameEnum.fromString(this.options.cooFrame, CooFrameEnum.ICRS);
@@ -2022,9 +2022,17 @@ export let View = (function () {
};
View.prototype.updateCenter = function() {
const [ra, dec] = this.wasm.getCenter();
this.viewCenter.lon = ra;
this.viewCenter.lat = dec;
// Center position in the frame of the view
const [lon, lat] = this.wasm.getCenter();
// ICRS conversion
let [ra, dec] = this.wasm.viewToICRSCooSys(lon, lat);
if (ra < 0) {
ra = ra + 360.0
}
this.viewCenter = {ra, dec};
}
View.prototype.showHealpixGrid = function (show) {
@@ -2069,11 +2077,10 @@ export let View = (function () {
return;
}
this.viewCenter.lon = ra;
this.viewCenter.lat = dec;
this.viewCenter = {ra, dec};
// Put a javascript code here to do some animation
this.wasm.setCenter(this.viewCenter.lon, this.viewCenter.lat);
this.wasm.setCenter(this.viewCenter.ra, this.viewCenter.dec);
ALEvent.POSITION_CHANGED.dispatchedTo(this.aladin.aladinDiv, this.viewCenter);

View File

@@ -47,6 +47,7 @@ export class ALEvent {
static UPDATE_CMAP_LIST = new ALEvent("AL:cmap.updated");
// Gives the center position in ICRS
static POSITION_CHANGED = new ALEvent("AL:position.changed");
static ZOOM_CHANGED = new ALEvent("AL:zoom.changed");

View File

@@ -41,6 +41,16 @@ import { ActionButton } from "./Widgets/ActionButton.js";
import { Input } from "./Widgets/Input.js";
import { Utils } from "../Utils.ts";
function radec2Lonlat(radec, frame) {
// convert to the view frame
let lonlat = radec;
if (frame === "GAL") {
lonlat = CooConversion.ICRSToGalactic(radec)
}
return lonlat
}
export class Location extends DOMElement {
// constructor
constructor(aladin) {
@@ -141,20 +151,15 @@ export class Location extends DOMElement {
ALEvent.CANVAS_EVENT.listenedBy(aladin.aladinDiv, function (e) {
let param = e.detail;
if (param.type === 'mouseout') {
let radec = aladin.getRaDec();
// convert to the view frame
let lonlat = radec;
if (aladin.getFrame() === "GAL") {
lonlat = CooConversion.ICRSToGalactic(radec)
}
let frame = aladin.getFrame();
if (param.type === 'mouseout') {
let [ra, dec] = aladin.getRaDec();
let [lon, lat] = lonlat;
//self.field.el.blur()
self.update({
lon, lat,
frame: aladin.view.cooFrame,
isViewCenter: true,
ra, dec,
frame,
center: true,
}, aladin);
}
@@ -170,39 +175,46 @@ export class Location extends DOMElement {
self.update({
mouseX: param.xy.x,
mouseY: param.xy.y,
frame: aladin.view.cooFrame,
isViewCenter: false,
frame,
center: false,
}, aladin);
}
});
ALEvent.POSITION_CHANGED.listenedBy(aladin.aladinDiv, function (e) {
// center position in ICRS
let {ra, dec} = e.detail;
let frame = aladin.getFrame();
self.update({
lon: e.detail.lon,
lat: e.detail.lat,
isViewCenter: true,
frame: aladin.view.cooFrame
ra,
dec,
center: true,
frame
}, aladin);
});
ALEvent.FRAME_CHANGED.listenedBy(aladin.aladinDiv, function (e) {
let [lon, lat] = aladin.getRaDec();
let [ra, dec] = aladin.getRaDec();
let frame = aladin.getFrame();
self.update({
lon, lat,
isViewCenter: true,
frame: e.detail.cooFrame
ra, dec,
center: true,
frame
}, aladin);
});
this.aladin = aladin;
let [lon, lat] = aladin.getRaDec();
let [ra, dec] = aladin.getRaDec();
let frame = aladin.getFrame();
this.update({
lon, lat,
isViewCenter: true,
frame: aladin.view.cooFrame
ra,
dec,
frame,
center: true
}, aladin)
};
@@ -210,6 +222,7 @@ export class Location extends DOMElement {
update(options, aladin) {
let self = this;
// lon and lat must be given in cooFrame
const updateFromLonLatFunc = (lon, lat, cooFrame) => {
var coo = new Coo(lon, lat, Location.prec);
if (cooFrame == CooFrameEnum.ICRS) {
@@ -224,21 +237,21 @@ export class Location extends DOMElement {
self.field.removeClass('aladin-not-valid');
self.field.removeClass('aladin-valid');
self.field.element().style.color = options.isViewCenter ? 'var(--aladin-color)' : 'white';
//self.field.el.blur()
self.field.element().style.color = options.center ? 'var(--aladin-color)' : 'white';
};
if (options.lon && options.lat) {
updateFromLonLatFunc(options.lon, options.lat, options.frame, true);
if (options.ra && options.dec) {
let [lon, lat] = radec2Lonlat([options.ra, options.dec], options.frame)
updateFromLonLatFunc(lon, lat, options.frame);
} else if (options.mouseX && options.mouseY) {
try {
let radec = aladin.pix2world(options.mouseX, options.mouseY); // This is given in the frame of the view
if (radec) {
if (radec[0] < 0) {
radec = [radec[0] + 360.0, radec[1]];
let lonlat = aladin.pix2world(options.mouseX, options.mouseY); // This is given in the frame of the view
if (lonlat) {
if (lonlat[0] < 0) {
lonlat = [lonlat[0] + 360.0, lonlat[1]];
}
updateFromLonLatFunc(radec[0], radec[1], options.frame, false);
updateFromLonLatFunc(lonlat[0], lonlat[1], options.frame);
}
} catch(e) {}
}