mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-01-16 23:12:30 -08:00
add al-ui workspace and al-task-exec
This commit is contained in:
@@ -7,6 +7,8 @@ edition = "2018"
|
||||
[workspace]
|
||||
members = [
|
||||
"al-core",
|
||||
"al-task-exec",
|
||||
"al-ui"
|
||||
]
|
||||
|
||||
[lib]
|
||||
@@ -24,16 +26,18 @@ serde = { version = "^1.0.59", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_derive = "^1.0.59"
|
||||
num = "*"
|
||||
task-async-executor = { path = "./lib/task-async-executor" }
|
||||
fitsrs = { package = "fitsrs", git = 'https://github.com/cds-astro/fitsrs', branch = 'master' }
|
||||
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
|
||||
num-traits = "0.2.14"
|
||||
img_pixel = { package = "image", version = "0.23.14" }
|
||||
al-core = { path = "./al-core" }
|
||||
egui = "*"
|
||||
epi = "*"
|
||||
egui_web = "*"
|
||||
|
||||
al-core = { path = "./al-core" }
|
||||
al-ui = { path = "./al-ui" }
|
||||
al-task-exec = { path = "./al-task-exec" }
|
||||
|
||||
|
||||
[dependencies.wasm-bindgen]
|
||||
version = "0.2.70"
|
||||
|
||||
@@ -2,6 +2,8 @@ mod object;
|
||||
pub mod shader;
|
||||
pub mod texture;
|
||||
pub mod webgl_ctx;
|
||||
#[macro_use]
|
||||
pub mod log;
|
||||
|
||||
pub use texture::format;
|
||||
pub use texture::image;
|
||||
|
||||
@@ -24,9 +24,10 @@ pub fn console_error(s: impl Into<JsValue>) {
|
||||
web_sys::console::error_1(&s.into());
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
// The pattern for a single `eval`
|
||||
($($arg:tt)*) => {
|
||||
$( self::log(&format!("{:?}", $arg)); )*
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "task-async-executor"
|
||||
name = "al-task-exec"
|
||||
version = "0.1.0"
|
||||
authors = ["Matthieu Baumann <matthieu.baumann@astro.unistra.fr>"]
|
||||
edition = "2018"
|
||||
83
src/core/al-ui/Cargo.toml
Normal file
83
src/core/al-ui/Cargo.toml
Normal file
@@ -0,0 +1,83 @@
|
||||
[package]
|
||||
name = "al-ui"
|
||||
version = "0.1.0"
|
||||
authors = ["baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
console_error_panic_hook = "0.1.6"
|
||||
futures = "0.3.12"
|
||||
js-sys = "0.3.47"
|
||||
wasm-bindgen-futures = "0.4.20"
|
||||
cgmath = "*"
|
||||
itertools-num = "0.1.3"
|
||||
healpix = { package = "cdshealpix", git = 'https://github.com/cds-astro/cds-healpix-rust', branch = 'master' }
|
||||
serde = { version = "^1.0.59", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_derive = "^1.0.59"
|
||||
num = "*"
|
||||
fitsrs = { package = "fitsrs", git = 'https://github.com/cds-astro/fitsrs', branch = 'master' }
|
||||
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
|
||||
num-traits = "0.2.14"
|
||||
img_pixel = { package = "image", version = "0.23.14" }
|
||||
egui = "*"
|
||||
epi = "*"
|
||||
egui_web = "*"
|
||||
al-core = { path = "../al-core" }
|
||||
|
||||
|
||||
[dependencies.wasm-bindgen]
|
||||
version = "0.2.70"
|
||||
features = ["serde-serialize"]
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.47"
|
||||
features = [
|
||||
'console',
|
||||
'Document',
|
||||
'Element',
|
||||
'HtmlCollection',
|
||||
'HtmlElement',
|
||||
'HtmlImageElement',
|
||||
'HtmlCanvasElement',
|
||||
'MouseEvent',
|
||||
'WheelEvent',
|
||||
'EventTarget',
|
||||
'WebGlBuffer',
|
||||
'WebGlVertexArrayObject',
|
||||
'WebGl2RenderingContext',
|
||||
'WebGlContextAttributes',
|
||||
'WebGlFramebuffer',
|
||||
'WebGlProgram',
|
||||
'WebGlShader',
|
||||
'WebGlUniformLocation',
|
||||
'WebGlTexture',
|
||||
'Window',
|
||||
'Headers',
|
||||
'Request',
|
||||
'RequestInit',
|
||||
'RequestMode',
|
||||
'Response',
|
||||
'XmlHttpRequest',
|
||||
'XmlHttpRequestEventTarget',
|
||||
'XmlHttpRequestResponseType',
|
||||
'PerformanceTiming',
|
||||
'Performance',
|
||||
'CanvasRenderingContext2d',
|
||||
'TextMetrics',
|
||||
'ImageData',
|
||||
'Storage',
|
||||
'WebGlActiveInfo',
|
||||
'GpuRenderBundleEncoder'
|
||||
]
|
||||
|
||||
[profile.dev]
|
||||
lto = true
|
||||
opt-level = 3
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
opt-level = 3
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = true
|
||||
@@ -14,16 +14,17 @@
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(clippy::all, missing_crate_level_docs, rust_2018_idioms)]
|
||||
|
||||
use crate::ui::Gui;
|
||||
use wasm_bindgen::{prelude::*};
|
||||
|
||||
|
||||
use egui::mutex::Mutex;
|
||||
pub use wasm_bindgen;
|
||||
pub use web_sys;
|
||||
use crate::Gui;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use al_core::log::*;
|
||||
|
||||
static AGENT_ID: &str = "egui_text_agent";
|
||||
|
||||
@@ -546,7 +547,6 @@ pub fn install_document_events(runner_ref: &GuiRef) -> Result<(), JsValue> {
|
||||
// keydown
|
||||
let runner_ref = runner_ref.clone();
|
||||
let closure = Closure::wrap(Box::new(move |event: web_sys::KeyboardEvent| {
|
||||
log!("key event");
|
||||
if event.is_composing() || event.key_code() == 229 {
|
||||
// https://www.fxsitecompat.dev/en-CA/docs/2018/keydown-and-keyup-events-are-now-fired-during-ime-composition/
|
||||
return;
|
||||
@@ -818,7 +818,6 @@ pub fn install_text_agent(runner_ref: &GuiRef) -> Result<(), JsValue> {
|
||||
body.append_child(&input)?;
|
||||
Ok(())
|
||||
}
|
||||
use crate::log::*;
|
||||
pub fn install_canvas_events(runner_ref: &GuiRef) -> Result<(), JsValue> {
|
||||
use wasm_bindgen::JsCast;
|
||||
let runner_ref = runner_ref.clone();
|
||||
@@ -2,6 +2,8 @@ mod painter;
|
||||
use painter::WebGl2Painter;
|
||||
|
||||
mod input;
|
||||
use input::*;
|
||||
pub use input::GuiRef;
|
||||
|
||||
use egui;
|
||||
use egui_web::Painter;
|
||||
@@ -52,9 +54,7 @@ pub struct Gui {
|
||||
pub aladin_lite_div: String,
|
||||
}
|
||||
|
||||
use crate::log::log;
|
||||
pub use crate::ui::input::GuiRef;
|
||||
use crate::ui::input::*;
|
||||
use al_core::log::*;
|
||||
use al_core::WebGl2Context;
|
||||
impl Gui {
|
||||
pub fn new(aladin_lite_div: &str, gl: &WebGl2Context) -> Result<GuiRef, JsValue> {
|
||||
@@ -11,8 +11,7 @@ use {
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::log::*;
|
||||
use crate::shader::{ShaderId, ShaderManager};
|
||||
use al_core::log::*;
|
||||
use al_core::{shader::Shader, VecData, VertexArrayObject};
|
||||
use cgmath::Vector2;
|
||||
use egui::{
|
||||
@@ -107,8 +106,8 @@ impl WebGl2Painter {
|
||||
gl.tex_parameteri(Gl::TEXTURE_2D, Gl::TEXTURE_MAG_FILTER, Gl::LINEAR as i32);*/
|
||||
let shader = Shader::new(
|
||||
&gl,
|
||||
include_str!("shaders/main_vertex_100es.glsl"),
|
||||
include_str!("shaders/main_fragment_100es.glsl"),
|
||||
include_str!("../shaders/main_vertex_100es.glsl"),
|
||||
include_str!("../shaders/main_fragment_100es.glsl"),
|
||||
)?;
|
||||
|
||||
/*let mut vao = VertexArrayObject::new(&gl);
|
||||
@@ -156,8 +155,8 @@ impl WebGl2Painter {
|
||||
})*/
|
||||
let shader = Shader::new(
|
||||
&gl,
|
||||
include_str!("shaders/main_vertex_100es.glsl"),
|
||||
include_str!("shaders/main_fragment_100es.glsl"),
|
||||
include_str!("../shaders/main_vertex_100es.glsl"),
|
||||
include_str!("../shaders/main_fragment_100es.glsl"),
|
||||
)?;
|
||||
let vao = gl.create_vertex_array().unwrap();
|
||||
gl.bind_vertex_array(Some(&vao));
|
||||
@@ -183,7 +182,7 @@ impl WebGl2Painter {
|
||||
WebGl2RenderingContext::FLOAT,
|
||||
false,
|
||||
8 * num_bytes_per_f32,
|
||||
(0 * num_bytes_per_f32) as i32,
|
||||
0,
|
||||
);
|
||||
gl.enable_vertex_attrib_array(0);
|
||||
|
||||
@@ -425,7 +424,7 @@ impl WebGl2Painter {
|
||||
WebGl2RenderingContext::FLOAT,
|
||||
false,
|
||||
8 * num_bytes_per_f32,
|
||||
(0 * num_bytes_per_f32) as i32,
|
||||
0,
|
||||
);
|
||||
gl.enable_vertex_attrib_array(0);
|
||||
|
||||
@@ -41,7 +41,7 @@ struct S {
|
||||
dec: f64,
|
||||
}
|
||||
|
||||
use crate::ui::{Gui, GuiRef};
|
||||
use al_ui::{Gui, GuiRef};
|
||||
pub struct App {
|
||||
pub gl: WebGl2Context,
|
||||
|
||||
@@ -106,7 +106,7 @@ struct ZoomAnimation {
|
||||
goal_fov: Angle<f64>,
|
||||
w0: f64,
|
||||
}
|
||||
use crate::log::log;
|
||||
use al_core::log::log;
|
||||
const BLEND_TILE_ANIM_DURATION: f32 = 500.0; // in ms
|
||||
use crate::buffer::Tile;
|
||||
use crate::time::Time;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// can be run concurrently on one thread under a time limit period
|
||||
// When the time limit is reached, the executor stops polling the remaining
|
||||
// futures and return the results of the finished ones
|
||||
use task_async_executor::Executor;
|
||||
use al_task_exec::Executor;
|
||||
pub type TaskExecutor = Executor<TaskType, TaskResult>;
|
||||
|
||||
pub use crate::buffer::Tile;
|
||||
@@ -239,7 +239,7 @@ where
|
||||
texture_array: Rc<Texture2DArray>,
|
||||
}
|
||||
|
||||
use super::al_core::Texture2DArray;
|
||||
use al_core::Texture2DArray;
|
||||
use crate::buffer::{HiPSConfig, Texture};
|
||||
use al_core::image::Image;
|
||||
|
||||
|
||||
@@ -584,7 +584,7 @@ impl ImageSurveyTextures {
|
||||
}
|
||||
}
|
||||
use crate::buffer::TextureUniforms;
|
||||
use crate::log::*;
|
||||
use al_core::log::*;
|
||||
use al_core::shader::{SendUniforms, ShaderBound};
|
||||
impl SendUniforms for ImageSurveyTextures {
|
||||
fn attach_uniforms<'a>(&self, shader: &'a ShaderBound<'a>) -> &'a ShaderBound<'a> {
|
||||
@@ -603,7 +603,7 @@ impl SendUniforms for ImageSurveyTextures {
|
||||
}
|
||||
let num_tiles = textures.len() as i32;
|
||||
|
||||
log!(num_tiles);
|
||||
al_core::log!(num_tiles);
|
||||
shader
|
||||
.attach_uniform("num_tiles", &num_tiles)
|
||||
.attach_uniforms_from(&self.config)
|
||||
|
||||
@@ -112,7 +112,7 @@ impl RequestSystem {
|
||||
TileResolved::Found { image, time_req }
|
||||
} else {
|
||||
let err = image.err().unwrap();
|
||||
log!(err);
|
||||
al_core::log!(err);
|
||||
TileResolved::Missing { time_req }
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ pub enum TileResolved {
|
||||
use std::collections::HashMap;
|
||||
pub type ResolvedTiles = HashMap<Tile, TileResolved>;
|
||||
|
||||
use crate::log::*;
|
||||
use al_core::log::*;
|
||||
use crate::ImageSurveys;
|
||||
use wasm_bindgen::JsValue;
|
||||
impl TileDownloader {
|
||||
|
||||
@@ -20,17 +20,12 @@ extern crate num_traits;
|
||||
extern crate rand;
|
||||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
extern crate task_async_executor;
|
||||
use al_core;
|
||||
|
||||
use std::panic;
|
||||
|
||||
#[macro_use]
|
||||
mod utils;
|
||||
|
||||
#[macro_use]
|
||||
mod log;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
mod app;
|
||||
@@ -54,7 +49,6 @@ mod shaders;
|
||||
mod sphere_geometry;
|
||||
mod time;
|
||||
mod transfert_function;
|
||||
mod ui;
|
||||
|
||||
use crate::{
|
||||
camera::CameraViewPort,
|
||||
|
||||
@@ -98,7 +98,7 @@ impl ProjetedGrid {
|
||||
WebGl2RenderingContext::FLOAT,
|
||||
false,
|
||||
2 * num_bytes_per_f32,
|
||||
(0 * num_bytes_per_f32) as i32,
|
||||
0,
|
||||
);
|
||||
gl.enable_vertex_attrib_array(0);
|
||||
|
||||
@@ -978,11 +978,7 @@ fn lines_gpu<P: Projection>(camera: &CameraViewPort) -> (Vec<f64>, Vec<f64>) {
|
||||
}
|
||||
|
||||
// Add parallels
|
||||
let step_lat = if fov.contains_pole() {
|
||||
select_grid_step(&bbox, bbox.get_lat_size().0 as f64, NUM_LINES)
|
||||
} else {
|
||||
select_grid_step(&bbox, bbox.get_lat_size().0 as f64, NUM_LINES)
|
||||
};
|
||||
let step_lat = select_grid_step(&bbox, bbox.get_lat_size().0 as f64, NUM_LINES);
|
||||
let mut alpha = bbox.lat_min().0 - (bbox.lat_min().0 % step_lat);
|
||||
if alpha == -HALF_PI {
|
||||
alpha += step_lat;
|
||||
@@ -1088,11 +1084,7 @@ fn lines<P: Projection>(
|
||||
}
|
||||
|
||||
// Add parallels
|
||||
let step_lat = if fov.contains_pole() {
|
||||
select_grid_step(&bbox, bbox.get_lat_size().0 as f64, NUM_LINES)
|
||||
} else {
|
||||
select_grid_step(&bbox, bbox.get_lat_size().0 as f64, NUM_LINES)
|
||||
};
|
||||
let step_lat = select_grid_step(&bbox, bbox.get_lat_size().0 as f64, NUM_LINES);
|
||||
let mut alpha = bbox.lat_min().0 - (bbox.lat_min().0 % step_lat);
|
||||
if alpha == -HALF_PI {
|
||||
alpha += step_lat;
|
||||
|
||||
@@ -583,7 +583,7 @@ impl ImageSurvey {
|
||||
WebGl2RenderingContext::FLOAT,
|
||||
false,
|
||||
13 * num_bytes_per_f32,
|
||||
(0 * num_bytes_per_f32) as i32,
|
||||
0,
|
||||
);
|
||||
gl.enable_vertex_attrib_array(0);
|
||||
|
||||
@@ -825,7 +825,7 @@ impl ImageSurvey {
|
||||
|
||||
impl Drop for ImageSurvey {
|
||||
fn drop(&mut self) {
|
||||
drop(&mut self.textures);
|
||||
//drop(self.textures);
|
||||
|
||||
// Drop the vertex arrays
|
||||
self.gl.delete_buffer(Some(&self.vbo));
|
||||
|
||||
@@ -567,7 +567,7 @@ impl Projection for Mollweide {
|
||||
true
|
||||
}
|
||||
|
||||
const RASTER_THRESHOLD_ANGLE: Angle<f64> = Angle((180.0 / 180.0) * std::f64::consts::PI);
|
||||
const RASTER_THRESHOLD_ANGLE: Angle<f64> = Angle(std::f64::consts::PI);
|
||||
}
|
||||
|
||||
use crate::renderable::Angle;
|
||||
@@ -719,7 +719,7 @@ impl Projection for AzimuthalEquidistant {
|
||||
r = math::sinc_positive(r);
|
||||
|
||||
let pos_world_space = if longitude_reversed {
|
||||
Vector4::new(-x * r, y * r, z, 1.0)
|
||||
Vector4::new(x * r, y * r, z, 1.0)
|
||||
} else {
|
||||
Vector4::new(-x * r, y * r, z, 1.0)
|
||||
};
|
||||
@@ -966,7 +966,7 @@ impl Projection for Mercator {
|
||||
true
|
||||
}
|
||||
|
||||
const RASTER_THRESHOLD_ANGLE: Angle<f64> = Angle((180.0 / 180.0) * std::f64::consts::PI);
|
||||
const RASTER_THRESHOLD_ANGLE: Angle<f64> = Angle(std::f64::consts::PI);
|
||||
}
|
||||
|
||||
mod tests {
|
||||
|
||||
@@ -110,7 +110,7 @@ impl RayTracer {
|
||||
WebGl2RenderingContext::FLOAT,
|
||||
false,
|
||||
(2 * mem::size_of::<f32>()) as i32,
|
||||
(0 * mem::size_of::<f32>()) as i32,
|
||||
0,
|
||||
);
|
||||
gl.enable_vertex_attrib_array(0);
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ impl Time {
|
||||
}
|
||||
}
|
||||
|
||||
use std::cmp::Ordering;
|
||||
/*use std::cmp::Ordering;
|
||||
impl Ord for Time {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.partial_cmp(&other).unwrap()
|
||||
}
|
||||
}
|
||||
}*/
|
||||
impl Eq for Time {}
|
||||
|
||||
use core::ops::Sub;
|
||||
|
||||
Reference in New Issue
Block a user