rename GenericSim -> AbstractSim

This commit is contained in:
2022-07-28 22:32:29 -07:00
parent 3104c06d95
commit 4f2345f608
8 changed files with 65 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
use crate::geom::Meters;
use crate::real::ToFloat as _;
use crate::cross::vec::{Vec2, Vec3};
use crate::sim::{GenericSim, Sample, StaticSim};
use crate::sim::{AbstractSim, Sample, StaticSim};
use crate::meas::{self, AbstractMeasurement};
use crossterm::{cursor, QueueableCommand as _};
use crossterm::style::{style, Color, PrintStyledContent, Stylize as _};
@@ -55,7 +55,7 @@ fn scale_vector(x: Vec2<f32>, typical_mag: f32) -> Vec2<f32> {
x.with_mag(new_mag)
}
fn im_size<S: GenericSim>(state: &S, max_w: u32, max_h: u32) -> (u32, u32) {
fn im_size<S: AbstractSim>(state: &S, max_w: u32, max_h: u32) -> (u32, u32) {
let mut width = max_w;
let mut height = width * state.height() / state.width();
if height > max_h {
@@ -134,7 +134,7 @@ struct RenderSteps<'a, S> {
z: u32,
}
impl<'a, S: GenericSim> RenderSteps<'a, S> {
impl<'a, S: AbstractSim> RenderSteps<'a, S> {
// TODO: this could probably be a single measurement, and we just let collections of
// measurements also behave as measurements
/// Render using default configuration constants
@@ -354,12 +354,12 @@ pub trait Renderer<S>: Send + Sync {
}
}
fn default_render_z_slice<S: GenericSim, R: Renderer<S>>(
fn default_render_z_slice<S: AbstractSim, R: Renderer<S>>(
me: &R, state: &S, z: u32, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig,
) {
me.render_with_image(state, &RenderSteps::render(state, measurements, z), measurements, config);
}
fn default_render<S: GenericSim, R: Renderer<S>>(
fn default_render<S: AbstractSim, R: Renderer<S>>(
me: &R, state: &S, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig
) {
me.render_z_slice(state, state.depth() / 2, measurements, config);
@@ -388,7 +388,7 @@ fn default_render<S: GenericSim, R: Renderer<S>>(
#[derive(Default)]
pub struct ColorTermRenderer;
impl<S: GenericSim> Renderer<S> for ColorTermRenderer {
impl<S: AbstractSim> Renderer<S> for ColorTermRenderer {
fn render(&self, state: &S, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig) {
default_render(self, state, measurements, config)
}
@@ -450,7 +450,7 @@ impl Y4MRenderer {
}
}
impl<S: GenericSim> Renderer<S> for Y4MRenderer {
impl<S: AbstractSim> Renderer<S> for Y4MRenderer {
fn render_z_slice(&self, state: &S, z: u32, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig) {
default_render_z_slice(self, state, z, measurements, config)
}
@@ -542,7 +542,7 @@ impl<S> MultiRenderer<S> {
}
}
impl<S: GenericSim> Renderer<S> for MultiRenderer<S> {
impl<S: AbstractSim> Renderer<S> for MultiRenderer<S> {
fn render_z_slice(&self, state: &S, z: u32, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig) {
default_render_z_slice(self, state, z, measurements, config)
}
@@ -569,10 +569,10 @@ pub struct SerializedFrame<S=StaticSim> {
pub measurements: Vec<meas::Evaluated>,
}
impl<S: GenericSim> SerializedFrame<S> {
impl<S: AbstractSim> SerializedFrame<S> {
pub fn to_static(self) -> SerializedFrame<StaticSim> {
SerializedFrame {
state: GenericSim::to_static(&self.state),
state: AbstractSim::to_static(&self.state),
measurements: self.measurements,
}
}
@@ -607,7 +607,7 @@ impl SerializerRenderer {
}
impl SerializerRenderer {
fn serialize<S: GenericSim + Serialize>(&self, state: &S, measurements: Vec<meas::Evaluated>) {
fn serialize<S: AbstractSim + Serialize>(&self, state: &S, measurements: Vec<meas::Evaluated>) {
let frame = SerializedFrame {
state,
measurements,
@@ -618,13 +618,13 @@ impl SerializerRenderer {
bincode::serialize_into(out, &frame).unwrap();
}
pub fn try_load<S: GenericSim + for <'a> Deserialize<'a>>(&self) -> Option<SerializedFrame<S>> {
pub fn try_load<S: AbstractSim + for <'a> Deserialize<'a>>(&self) -> Option<SerializedFrame<S>> {
let mut reader = BufReader::new(File::open(&*self.fmt_str).ok()?);
bincode::deserialize_from(&mut reader).ok()
}
}
impl<S: GenericSim + Serialize> Renderer<S> for SerializerRenderer {
impl<S: AbstractSim + Serialize> Renderer<S> for SerializerRenderer {
fn render_z_slice(&self, state: &S, z: u32, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig) {
default_render_z_slice(self, state, z, measurements, config)
}
@@ -667,7 +667,7 @@ impl CsvRenderer {
}
}
impl<S: GenericSim> Renderer<S> for CsvRenderer {
impl<S: AbstractSim> Renderer<S> for CsvRenderer {
fn render_z_slice(&self, state: &S, z: u32, measurements: &[&dyn AbstractMeasurement<S>], config: RenderConfig) {
default_render_z_slice(self, state, z, measurements, config)
}