use std::ptr; use glib::{timeout_add, timeout_add_local}; use glib_macros::clone; use gtk::gdk::builders::RGBABuilder; use gtk::gdk::Display; use gtk::{ gio, glib, style_context_add_provider_for_display, Application, ApplicationWindow, CssProvider, FontButton, GestureDrag, }; use gtk::{prelude::*, DrawingArea}; mod data; mod monitor; mod painter; mod render; mod tree; mod window; use data::{Npz, Radar2d, RadarData2d}; use monitor::Monitor; use ndarray::parallel::prelude::{IntoParallelIterator, ParallelIterator}; use painter::wgs84::{LatLonCoord, Mercator, ProjectionS, Range}; use render::Render; use render::{BackgroundConfig, BackgroundWidget}; const APP_ID: &str = "org.gtk_rs.HelloWorld2"; fn main() -> glib::ExitCode { // Load GL pointers from epoxy (GL context management library used by GTK). { #[cfg(target_os = "macos")] let library = unsafe { libloading::os::unix::Library::new("libepoxy.0.dylib") }.unwrap(); #[cfg(all(unix, not(target_os = "macos")))] let library = unsafe { libloading::os::unix::Library::new("libepoxy.so.0") }.unwrap(); #[cfg(windows)] let library = libloading::os::windows::Library::open_already_loaded("libepoxy-0.dll") .or_else(|_| libloading::os::windows::Library::open_already_loaded("epoxy-0.dll")) .unwrap(); epoxy::load_with(|name| { unsafe { library.get::<_>(name.as_bytes()) } .map(|symbol| *symbol) .unwrap_or(ptr::null()) }); } // gio::resources_register_include!("monitor.gresource").expect("Failed to register resources"); // Create a new application let app = Application::builder().application_id(APP_ID).build(); // Connect to "activate" signal of `app` app.connect_activate(build_ui); // Run the application app.run() } fn build_ui(app: &Application) { // Create a window and set the title let window = ApplicationWindow::builder() .application(app) .title("My GTK App") .build(); let mut background_config = BackgroundConfig::new(); let background_widget = BackgroundWidget::new(background_config); let drawing_area = Render::new(); // let path = "/Users/ruomu/test2.npz"; // let data = Radar2d::::load(path, Npz).unwrap(); // let projection = Mercator::new(); // let aa = Range::from((*data.dim1.first().unwrap(), *data.dim1.last().unwrap())); // let ab = Range::from((*data.dim2.first().unwrap(), *data.dim2.last().unwrap())); // let coord = LatLonCoord::new(Some(aa), Some(ab), ((0, 1000), (0, 1000)), projection); // let result = data.mapped(&coord); let monitor = Monitor::new(); window.set_child(Some(&monitor)); window.set_default_width(1000); window.set_default_height(800); window.present(); }