1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * File: mod.rs
 * Project: backend
 * Created Date: 16/07/2023
 * Author: Shun Suzuki
 * -----
 * Last Modified: 12/10/2023
 * Modified By: Shun Suzuki (suzuki@hapis.k.u-tokyo.ac.jp)
 * -----
 * Copyright (c) 2023 Shun Suzuki. All rights reserved.
 *
 */

mod null;
#[cfg(feature = "plotters")]
mod plotters;
#[cfg(feature = "python")]
mod python;

use crate::error::VisualizerError;

use autd3_driver::{
    defined::{float, Complex},
    geometry::{Geometry, Transducer},
};

/// Plotting backend
pub trait Backend: Send + Sync {
    type PlotConfig;

    fn new() -> Self;

    fn initialize(&mut self) -> Result<(), VisualizerError>;

    fn plot_1d(
        observe_points: Vec<float>,
        acoustic_pressures: Vec<Complex>,
        resolution: float,
        x_label: &str,
        config: Self::PlotConfig,
    ) -> Result<(), VisualizerError>;

    #[allow(clippy::too_many_arguments)]
    fn plot_2d(
        observe_x: Vec<float>,
        observe_y: Vec<float>,
        acoustic_pressures: Vec<Complex>,
        resolution: float,
        x_label: &str,
        y_label: &str,
        config: Self::PlotConfig,
    ) -> Result<(), VisualizerError>;

    fn plot_modulation(
        modulation: Vec<float>,
        config: Self::PlotConfig,
    ) -> Result<(), VisualizerError>;

    fn plot_phase<T: Transducer>(
        config: Self::PlotConfig,
        geometry: &Geometry<T>,
        phases: Vec<float>,
    ) -> Result<(), VisualizerError>;
}

#[cfg(feature = "plotters")]
pub use self::plotters::*;
pub use null::*;
#[cfg(feature = "python")]
pub use python::*;