use crate::{render_traits::AspectRatioAlignmentMode, wgpu};
use crate::zarr::AsyncZarritaStore;
use crate::render_traits::AspectRatioMode;
use serde::{Deserialize, Serialize};
use svg::node::element::Group;
use std::sync::Arc;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum RenderBackend {
Gpu,
Cpu,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ComputeBackend {
Gpu,
Cpu,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum GraphicsFormat {
Raster,
Vector,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ViewMode {
#[serde(rename = "2d")]
TwoD,
#[serde(rename = "3d")]
ThreeD,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LayerParams {
pub layer_type: String,
pub layer_params: serde_json::Value,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LayeredPlotRenderParams {
pub layers: Vec<LayerParams>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(tag = "plot_type", content = "plot_params")]
pub enum PlotParams {
LayeredPlot(LayeredPlotRenderParams),
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RenderParams {
pub width: u32,
pub height: u32,
pub format: GraphicsFormat,
pub device_pixel_ratio: f32,
pub camera_view: Option<[f32; 16]>,
pub aspect_ratio_mode: AspectRatioMode,
pub aspect_ratio_alignment_mode: AspectRatioAlignmentMode,
pub view_mode: ViewMode,
#[serde(flatten)]
pub plot_params: PlotParams,
pub plot_id: String,
pub store_name: String,
pub wait_for_store_gets: bool,
pub timeout: Option<u32>,
pub cache_enabled: bool,
pub svg_compression_enabled: bool,
pub svg_include_document: bool,
pub margin_left: Option<f32>,
pub margin_right: Option<f32>,
pub margin_top: Option<f32>,
pub margin_bottom: Option<f32>,
pub pickable: bool,
pub render_backend: Option<RenderBackend>,
pub compute_backend: Option<ComputeBackend>,
}
impl Default for RenderParams {
fn default() -> Self {
Self {
width: 100,
height: 100,
format: GraphicsFormat::Raster,
device_pixel_ratio: 1.0,
aspect_ratio_mode: AspectRatioMode::Contain,
aspect_ratio_alignment_mode: AspectRatioAlignmentMode::Center,
view_mode: ViewMode::TwoD,
camera_view: None,
plot_id: "default_plot".to_string(),
store_name: "default_store".to_string(),
plot_params: PlotParams::LayeredPlot(LayeredPlotRenderParams {
layers: vec![],
}),
wait_for_store_gets: true,
timeout: None,
cache_enabled: true,
svg_compression_enabled: false,
svg_include_document: true,
margin_left: None,
margin_right: None,
margin_top: None,
margin_bottom: None,
pickable: false,
render_backend: None,
compute_backend: None,
}
}
}