use crate::{tools, settings::{EquipmentSettings}, utils};

#[derive(Debug)]
pub struct Context<'a>
{
	equipment: &'a EquipmentSettings,
	magnification: f64
}

impl<'a> Context<'a>
{
	pub fn new(equipment: &'a EquipmentSettings, magnification: f64) -> Self
	{
		Self{equipment, magnification}
	}

	fn camera_pixel_size_nm(&self) -> f64
	{
		self.equipment.camera_pixel_size_nm()
	}

	pub fn widefield_pixel_size_nm(&self) -> f64
	{
		self.equipment.camera_pixel_size_nm()
	}	

	pub fn psf_px(&self) -> f64
	{
		let magnification = self.magnification;
		let equipment_settings = self.equipment;
		let psf_nm = equipment_settings.instrument_psf_fwhm_nm() * (magnification as f64);
		let settings = equipment_settings.clone().with_instrument_psf_fwhm_nm(psf_nm);
		tools::calculate_psf_in_pixels(&settings)
	}

	pub fn super_res_pixel_size_nm(&self) -> f64
	{
		utils::sr_pixel_size(self.camera_pixel_size_nm(), self.magnification)
	}
}