use scirs2_core::ndarray::Array2;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NativePlotConfig {
pub width: usize,
pub height: usize,
pub enable_interactivity: bool,
pub enable_animations: bool,
pub animation_fps: f64,
pub color_scheme: PlotColorScheme,
pub export_quality: ExportQuality,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PlotColorScheme {
Quantum,
Neuromorphic,
AI,
Scientific,
Custom(Vec<[u8; 3]>),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ExportQuality {
Draft,
Standard,
High,
Publication,
}
#[derive(Debug)]
pub struct SvgCanvas {
pub(crate) width: usize,
pub(crate) height: usize,
pub(crate) elements: Vec<SvgElement>,
pub(crate) styles: HashMap<String, String>,
}
#[derive(Debug, Clone)]
pub enum SvgElement {
Circle {
cx: f64,
cy: f64,
r: f64,
fill: String,
stroke: String,
stroke_width: f64,
opacity: f64,
},
Line {
x1: f64,
y1: f64,
x2: f64,
y2: f64,
stroke: String,
stroke_width: f64,
opacity: f64,
},
Path {
d: String,
fill: String,
stroke: String,
stroke_width: f64,
opacity: f64,
},
Text {
x: f64,
y: f64,
content: String,
font_size: f64,
fill: String,
text_anchor: String,
},
Group {
id: String,
elements: Vec<SvgElement>,
transform: String,
},
}
#[derive(Debug)]
pub struct AnimationEngine {
pub(crate) frames: Vec<AnimationFrame>,
pub(crate) current_frame: usize,
pub(crate) frame_duration: f64,
pub(crate) total_duration: f64,
}
#[derive(Debug, Clone)]
pub struct AnimationFrame {
pub timestamp: f64,
pub elements: Vec<SvgElement>,
pub transformations: Vec<Transformation>,
}
#[derive(Debug, Clone)]
pub enum Transformation {
Translate { dx: f64, dy: f64 },
Rotate { angle: f64, cx: f64, cy: f64 },
Scale { sx: f64, sy: f64 },
Fade { from: f64, to: f64 },
ColorTransition { from: String, to: String },
}
#[derive(Debug)]
pub struct InteractiveController {
pub(crate) zoom_level: f64,
pub(crate) pan_offset: (f64, f64),
pub(crate) selected_elements: Vec<String>,
pub(crate) hover_element: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct NativeDendrogramPlot {
pub tree: DendrogramTree,
pub node_positions: HashMap<String, (f64, f64)>,
pub branch_lengths: HashMap<String, f64>,
pub quantum_enhancements: HashMap<String, f64>,
pub interactive_features: Vec<InteractiveFeature>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DendrogramTree {
pub root: DendrogramNode,
pub height: f64,
pub leaf_count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DendrogramNode {
pub id: String,
pub height: f64,
pub children: Vec<DendrogramNode>,
pub data_indices: Vec<usize>,
pub quantum_coherence: f64,
pub neuromorphic_activity: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum InteractiveFeature {
ZoomPan,
NodeSelection,
Tooltip,
RealTimeFilter,
AnimationControls,
ExportOptions,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Native3DClusterPlot {
pub points_3d: Array2<f64>,
pub point_colors: Vec<[u8; 3]>,
pub centroids_3d: Array2<f64>,
pub camera: Camera3D,
pub lighting: Lighting3D,
pub quantum_field: QuantumField3D,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Camera3D {
pub position: [f64; 3],
pub target: [f64; 3],
pub up: [f64; 3],
pub fov: f64,
pub near: f64,
pub far: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Lighting3D {
pub ambient: f64,
pub directional_lights: Vec<DirectionalLight>,
pub point_lights: Vec<PointLight>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DirectionalLight {
pub direction: [f64; 3],
pub intensity: f64,
pub color: [f64; 3],
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PointLight {
pub position: [f64; 3],
pub intensity: f64,
pub color: [f64; 3],
pub attenuation: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuantumField3D {
pub field_strength: Array2<f64>,
pub coherence: Array2<f64>,
pub phase: Array2<f64>,
pub entanglement_lines: Vec<([f64; 3], [f64; 3], f64)>,
}
#[derive(Debug)]
pub struct NativeClusterPlot {
pub data: Array2<f64>,
pub point_elements: Vec<SvgElement>,
pub centroid_elements: Vec<SvgElement>,
pub quantum_enhancements: Vec<f64>,
pub bounds: (f64, f64, f64, f64),
pub scale: (f64, f64),
}
#[derive(Debug)]
pub struct NativeVisualizationOutput {
pub cluster_plot: NativeClusterPlot,
pub dendrogram: Option<NativeDendrogramPlot>,
pub plot_3d: Option<Native3DClusterPlot>,
pub quantum_animation: Option<QuantumCoherenceAnimation>,
pub neuromorphic_plot: NeuromorphicActivityPlot,
pub performance_dashboard: InteractivePerformanceDashboard,
pub svg_content: String,
pub interactive_script: String,
}
#[derive(Debug)]
pub struct QuantumCoherenceAnimation {
pub frames: Vec<QuantumCoherenceFrame>,
pub duration: f64,
pub fps: f64,
}
#[derive(Debug, Clone)]
pub struct QuantumCoherenceFrame {
pub timestamp: f64,
pub elements: Vec<SvgElement>,
pub field_strength: Array2<f64>,
}
#[derive(Debug)]
pub struct NeuromorphicActivityPlot {
pub activity_matrix: Array2<f64>,
pub spike_trains: Array2<f64>,
pub plasticity_changes: Array2<f64>,
pub time_resolution: f64,
}
#[derive(Debug)]
pub struct InteractivePerformanceDashboard {
pub performance_metrics: HashMap<String, f64>,
pub improvements: HashMap<String, f64>,
pub metrics_timeline: Vec<MetricTimelinePoint>,
pub execution_summary: ExecutionSummary,
}
#[derive(Debug, Clone)]
pub struct MetricTimelinePoint {
pub timestamp: f64,
pub quantum_coherence: f64,
pub neural_adaptation: f64,
pub ai_confidence: f64,
}
#[derive(Debug, Clone)]
pub struct ExecutionSummary {
pub total_time: f64,
pub memory_usage: f64,
pub iterations: usize,
pub algorithm: String,
pub confidence: f64,
}
impl Default for NativePlotConfig {
fn default() -> Self {
Self {
width: 1200,
height: 800,
enable_interactivity: true,
enable_animations: true,
animation_fps: 30.0,
color_scheme: PlotColorScheme::Quantum,
export_quality: ExportQuality::High,
}
}
}