mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-01-18 15:57:45 -08:00
stable version
This commit is contained in:
@@ -55,7 +55,7 @@ pub struct CameraViewPort {
|
||||
|
||||
// A reference to the WebGL2 context
|
||||
gl: WebGl2Context,
|
||||
pub system: CooSystem,
|
||||
system: CooSystem,
|
||||
}
|
||||
use crate::coo_conversion::CooSystem;
|
||||
use crate::WebGl2Context;
|
||||
@@ -283,6 +283,11 @@ impl CameraViewPort {
|
||||
self.vertices._type()
|
||||
}
|
||||
|
||||
pub fn set_coo_system<P: Projection>(&mut self, system: CooSystem) {
|
||||
self.system = system;
|
||||
self.vertices.set_rotation::<P>(&self.w2m, self.aperture, &self.system);
|
||||
}
|
||||
|
||||
// Accessors
|
||||
pub fn get_rotation(&self) -> &Rotation<f64> {
|
||||
&self.w2m_rot
|
||||
@@ -351,6 +356,10 @@ impl CameraViewPort {
|
||||
pub fn get_time_of_last_move(&self) -> Time {
|
||||
self.time_last_move
|
||||
}
|
||||
|
||||
pub fn get_system(&self) -> &CooSystem {
|
||||
&self.system
|
||||
}
|
||||
}
|
||||
use cgmath::Matrix;
|
||||
use crate::coo_conversion::CooBaseFloat;
|
||||
@@ -371,14 +380,14 @@ impl CameraViewPort {
|
||||
|
||||
// 2. rotate the matrix on his axis
|
||||
/*let w2m_rot = Rotation::from_axis_angle(
|
||||
&self.get_center().truncate(),
|
||||
crate::renderable::angle::ArcDeg(45.0).into()
|
||||
&self.get_center().truncate().normalize(),
|
||||
crate::renderable::angle::ArcDeg(48.0).into()
|
||||
) * self.w2m_rot;
|
||||
|
||||
self.w2m = (&w2m_rot).into();
|
||||
self.m2w = self.w2m.transpose();
|
||||
self.update_center::<P>();
|
||||
self.time_last_move = Time::now();*/
|
||||
self.m2w = self.w2m.transpose();*/
|
||||
//self.update_center::<P>();
|
||||
//self.time_last_move = Time::now();
|
||||
}
|
||||
|
||||
fn update_center<P: Projection>(&mut self) {
|
||||
|
||||
@@ -710,9 +710,10 @@ impl App {
|
||||
self.request_redraw = true;
|
||||
}
|
||||
|
||||
pub fn set_coo_system(&mut self, coo_system: CooSystem) {
|
||||
pub fn set_coo_system<P: Projection>(&mut self, coo_system: CooSystem) {
|
||||
self.system = coo_system;
|
||||
self.camera.system = coo_system;
|
||||
self.camera.set_coo_system::<P>(coo_system);
|
||||
self.surveys.set_coo_system::<P>(false, &self.camera, &mut self.shaders, &self.resources, &self.system);
|
||||
}
|
||||
|
||||
pub fn world_to_screen<P: Projection>(
|
||||
@@ -1267,6 +1268,18 @@ impl ProjectionType {
|
||||
ProjectionType::Mercator => app.enable_grid::<Mercator>(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn set_coo_system(&mut self, app: &mut App, system: CooSystem) {
|
||||
match self {
|
||||
ProjectionType::Aitoff => app.set_coo_system::<Aitoff>(system),
|
||||
ProjectionType::MollWeide => app.set_coo_system::<Mollweide>(system),
|
||||
ProjectionType::Ortho => app.set_coo_system::<Orthographic>(system),
|
||||
ProjectionType::Arc => app.set_coo_system::<AzimuthalEquidistant>(system),
|
||||
ProjectionType::Gnomonic => app.set_coo_system::<Gnomonic>(system),
|
||||
ProjectionType::Mercator => app.set_coo_system::<Mercator>(system),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn hide_grid_labels(&mut self, app: &mut App) {
|
||||
app.hide_grid_labels();
|
||||
}
|
||||
@@ -1545,7 +1558,7 @@ impl WebClient {
|
||||
}
|
||||
#[wasm_bindgen(js_name = setCooSystem)]
|
||||
pub fn set_coo_system(&mut self, coo_system: CooSystem) -> Result<(), JsValue> {
|
||||
self.app.set_coo_system(coo_system);
|
||||
self.projection.set_coo_system(&mut self.app, coo_system);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -323,7 +323,6 @@ impl ProjetedGrid {
|
||||
let size_screen = &camera.get_screen_size();
|
||||
self.ctx2d
|
||||
.clear_rect(0.0, 0.0, size_screen.x as f64, size_screen.y as f64);
|
||||
crate::log("redraw grid labels");
|
||||
|
||||
let text_height = Label::size(camera);
|
||||
self.ctx2d
|
||||
@@ -429,7 +428,7 @@ fn subdivide<P: Projection>(
|
||||
camera: &CameraViewPort,
|
||||
) {
|
||||
// Convert to cartesian
|
||||
let system = &camera.system;
|
||||
let system = camera.get_system();
|
||||
let a: Vector4<f64> = system.to_icrs_j2000::<f64>() * math::radec_to_xyzw(Angle(lonlat[0].0), Angle(lonlat[0].1));
|
||||
let b: Vector4<f64> = system.to_icrs_j2000::<f64>() * math::radec_to_xyzw(Angle(lonlat[1].0), Angle(lonlat[1].1));
|
||||
let c: Vector4<f64> = system.to_icrs_j2000::<f64>() * math::radec_to_xyzw(Angle(lonlat[2].0), Angle(lonlat[2].1));
|
||||
@@ -615,7 +614,7 @@ impl Label {
|
||||
sp: Option<&Vector2<f64>>,
|
||||
ctx2d: &CanvasRenderingContext2d,
|
||||
) -> Option<Self> {
|
||||
let system = &camera.system;
|
||||
let system = camera.get_system();
|
||||
|
||||
let LonLatT(_, lat) = &(system.to_gal::<f64>() * camera.get_center()).lonlat();
|
||||
// Do not plot meridian labels when the center of fov
|
||||
@@ -707,7 +706,7 @@ impl Label {
|
||||
ctx2d: &CanvasRenderingContext2d,
|
||||
) -> Option<Self> {
|
||||
let mut d = Vector3::new(-m1.z, 0.0, m1.x).normalize();
|
||||
let system = &camera.system;
|
||||
let system = camera.get_system();
|
||||
let center = (system.to_gal::<f64>() * camera.get_center()).truncate();
|
||||
if center.dot(d) < 0.0 {
|
||||
d = -d;
|
||||
@@ -768,11 +767,11 @@ impl Label {
|
||||
let allsky = dx < 2.0;
|
||||
|
||||
let ss = camera.get_screen_size();
|
||||
let size_not_allsky = ((ss.y.max(ss.x) as f64) * 0.02).min(13.0);
|
||||
let size_not_allsky = ((ss.y.max(ss.x) as f64) * 0.1).min(13.0);
|
||||
|
||||
if allsky {
|
||||
let dw = dx / 2.0; // [0..1]
|
||||
dw * size_not_allsky
|
||||
(dw * size_not_allsky).max(10.0)
|
||||
} else {
|
||||
size_not_allsky
|
||||
}
|
||||
@@ -967,7 +966,7 @@ fn lines<P: Projection>(
|
||||
ctx2d: &CanvasRenderingContext2d,
|
||||
) -> Vec<GridLine> {
|
||||
// Get the screen position of the nearest pole
|
||||
let system = &camera.system;
|
||||
let system = camera.get_system();
|
||||
let fov = camera.get_field_of_view();
|
||||
let sp = if fov.contains_pole() {
|
||||
if fov.contains_north_pole(camera) {
|
||||
|
||||
@@ -1122,6 +1122,18 @@ impl ImageSurveys {
|
||||
self.raytracer = RayTracer::new::<P>(&self.gl, camera, shaders, rs, system);
|
||||
}
|
||||
|
||||
pub fn set_coo_system<P: Projection>(
|
||||
&mut self,
|
||||
_reversed: bool,
|
||||
camera: &CameraViewPort,
|
||||
shaders: &mut ShaderManager,
|
||||
rs: &Resources,
|
||||
system: &CooSystem,
|
||||
) {
|
||||
// Recompute the raytracer
|
||||
self.raytracer = RayTracer::new::<P>(&self.gl, camera, shaders, rs, system);
|
||||
}
|
||||
|
||||
pub fn set_overlay_opacity(&mut self, opacity: f32) {
|
||||
self.opacity = opacity;
|
||||
}
|
||||
@@ -1311,7 +1323,6 @@ impl ImageSurveys {
|
||||
} else {
|
||||
let (_, layer) = &self.layers.iter().next().unwrap();
|
||||
let name = &layer.name_most_precised_survey;
|
||||
crate::log(name);
|
||||
Some(
|
||||
self.surveys.get(name)
|
||||
.unwrap()
|
||||
|
||||
@@ -29,6 +29,7 @@ fn create_vertices_array<P: Projection>(
|
||||
P::clip_to_world_space(&pos_clip_space, camera.is_reversed_longitude()).unwrap()
|
||||
);*/
|
||||
let pos_world_space = P::clip_to_world_space(&pos_clip_space, camera.is_reversed_longitude()).unwrap();
|
||||
//let pos_world_space = system.to_icrs_j2000() * pos_world_space;
|
||||
let lonlat = pos_world_space.lonlat();
|
||||
|
||||
// Cast all the double into float
|
||||
|
||||
@@ -56,7 +56,7 @@ impl FieldOfViewType {
|
||||
// We do an approx saying allsky fovs intersect all meridian
|
||||
// but this is not true for example for the orthographic projection
|
||||
// Some meridians may not be visible
|
||||
let system = &camera.system;
|
||||
let system = camera.get_system();
|
||||
let center = (system.to_gal::<f64>() * camera.get_center()).lonlat();
|
||||
let lon: Rad<f64> = lon.into();
|
||||
let pos: Vector3<f64> = LonLatT::new(lon.into(), center.lat()).vector();
|
||||
@@ -73,7 +73,7 @@ impl FieldOfViewType {
|
||||
) -> Option<Vector3<f64>> {
|
||||
match self {
|
||||
FieldOfViewType::Allsky(_) => {
|
||||
let system = &camera.system;
|
||||
let system = camera.get_system();
|
||||
|
||||
let center = (system.to_gal::<f64>() * camera.get_center()).lonlat();
|
||||
let lat: Rad<f64> = lat.into();
|
||||
|
||||
@@ -393,7 +393,7 @@ export let MOC = (function() {
|
||||
ra = corners[2*k];
|
||||
dec = corners[2*k + 1];
|
||||
// need for frame transformation ?
|
||||
if (surveyFrame && surveyFrame.system != viewFrame.system) {
|
||||
/*if (surveyFrame && surveyFrame.system != viewFrame.system) {
|
||||
if (surveyFrame.system == CooFrameEnum.SYSTEMS.J2000) {
|
||||
var radec = CooConversion.J2000ToGalactic([ra, dec]);
|
||||
lon = radec[0];
|
||||
@@ -408,7 +408,9 @@ export let MOC = (function() {
|
||||
else {
|
||||
lon = ra;
|
||||
lat = dec;
|
||||
}
|
||||
}*/
|
||||
lon = ra;
|
||||
lat = dec;
|
||||
|
||||
//cornersXY[k] = projection.project(lon, lat);
|
||||
cornersXYView[k] = view.aladin.webglAPI.worldToScreen(lon, lat);
|
||||
|
||||
@@ -1329,7 +1329,7 @@ export let View = (function() {
|
||||
dec: pos_world[1]
|
||||
};
|
||||
var lonlat = [];
|
||||
if (frameSurvey && frameSurvey.system != this.cooFrame.system) {
|
||||
/*if (frameSurvey && frameSurvey.system != this.cooFrame.system) {
|
||||
if (frameSurvey.system==CooFrameEnum.SYSTEMS.J2000) {
|
||||
lonlat = CooConversion.GalacticToJ2000([radec.ra, radec.dec]);
|
||||
}
|
||||
@@ -1339,7 +1339,8 @@ export let View = (function() {
|
||||
}
|
||||
else {
|
||||
lonlat = [radec.ra, radec.dec];
|
||||
}
|
||||
}*/
|
||||
lonlat = [radec.ra, radec.dec];
|
||||
spatialVector.set(lonlat[0], lonlat[1]);
|
||||
|
||||
var radius = this.fov*0.5*this.ratio;
|
||||
|
||||
Reference in New Issue
Block a user