use crate::controls::ArcballControls;
use crate::history::History;
use crate::pick::{self, PickOptions};
use crate::scene::RenderScene;
use crate::style::{Emphasis, RenderSettings};
use crate::view::ViewCamera;
use crate::widgets::{gizmo_camera, WidgetOverlay, WidgetRegistry};
use brep_kernel::HistoryRequest;
use std::collections::HashMap;
#[derive(Clone)]
pub(crate) struct DialogHover {
pub(crate) owner: &'static str,
pub(crate) row: String,
pub(crate) candidate: Option<pick::PickCandidate>,
}
pub struct EngineState {
pub scene: RenderScene,
pub camera: ViewCamera,
pub controls: ArcballControls,
pub settings: RenderSettings,
pub emphasis: Emphasis,
pub widgets: WidgetRegistry,
pub history: History,
history_report: String,
pub metadata: crate::metadata::MetadataStore,
pub settings_generation: u64,
pub dirty: bool,
pub ref_select: Option<RefSelectState>,
pub selection_filter: SelectionFilter,
pub transform_gizmo: TransformArm,
pub component_move: ComponentMoveArm,
sketch_edit: Option<SketchEdit>,
sketch_camera_locked: bool,
sketch_list_hover_active: bool,
notices: Vec<String>,
hidden_sketches: std::collections::HashSet<String>,
shown_sketch_ids: Vec<String>,
construction_frames: Vec<(String, brep_kernel::Frame)>,
sketch_profiles: Vec<(String, brep_kernel::SketchProfile)>,
sketch_paths: Vec<(String, Vec<brep_kernel::NurbsCurve>)>,
sketch_points: Vec<(String, brep_kernel::ScenePoint)>,
sketch_axes: Vec<(String, brep_kernel::Axis)>,
wire_harness_report: Option<brep_kernel::WireHarnessReport>,
pub(crate) pmi_report: Option<brep_kernel::PmiReport>,
pub(crate) pmi_active_view: Option<String>,
pub(crate) pmi_open_annotation: Option<String>,
pub(crate) pmi_modeling: Option<pmi_ops::PmiModelingSnapshot>,
pub(crate) pmi_explode_originals: std::collections::HashMap<String, crate::scene::SolidDisplay>,
pub(crate) pmi_overlay_key: Option<(f64, [f64; 3])>,
pub(crate) pmi_hovered: Option<String>,
pub(crate) pmi_label_hover_active: bool,
spline_overlay_key: Option<(String, Option<usize>, u64)>,
component_ports_visible: bool,
spline_edit_feature: Option<String>,
spline_anchor_picked: Option<usize>,
hidden_datums: std::collections::HashSet<String>,
shown_datum_names: Vec<String>,
pub(crate) runner: Box<dyn crate::runner::HistoryRunner>,
run_generation: u64,
applied_generation: u64,
run_progress: Option<crate::runner::RunProgress>,
cancelled_run: Option<String>,
pending_fit: bool,
pub(crate) provenance: std::collections::HashMap<String, String>,
pub(crate) entity_origin: std::collections::HashMap<String, String>,
pub(crate) info_cache: std::collections::HashMap<String, String>,
pub(crate) pending_query: std::collections::HashMap<u64, String>,
pub(crate) next_query_id: u64,
pub(crate) pending_mesh_imports: std::collections::HashMap<u64, MeshImportDestination>,
pub(crate) mesh_preview_results: std::collections::VecDeque<crate::runner::MeshImportReply>,
pub(crate) next_mesh_import_id: u64,
pub(crate) assembly_components: Vec<brep_kernel::ComponentRecord>,
pub(crate) assembly_synced_generation: Option<u64>,
pub(crate) library_resync: bool,
pub(crate) parts_library_block_revision: Option<u64>,
pub(crate) constraint_overlays: Vec<crate::constraint_overlays::ConstraintOverlay>,
pub(crate) constraint_drag: Option<ConstraintDrag>,
constraint_overlay_wpp: f64,
pub(crate) feature_dim_overlay_wpp: f64,
pub(crate) sketch_overlay_wpp: f64,
constraint_hovered: Option<String>,
constraint_label_hover_active: bool,
scene_tree_hovered: Option<pick::PickCandidate>,
scene_tree_hover_active: bool,
dialog_hovered: Option<DialogHover>,
dialog_hover_active: bool,
selected_constraint: Option<String>,
pub(crate) pending_step_assembly: Option<brep_kernel::StepAssembly>,
pub(crate) pending_step_probes: std::collections::HashSet<u64>,
pub(crate) step_probe_results: std::collections::VecDeque<(u64, StepProbeOutcome)>,
pub(crate) next_step_probe_id: u64,
}
#[derive(Debug, Clone, PartialEq)]
pub enum StepProbeOutcome {
Structure(model_io::StepAssemblyProbe),
Flat,
Failed(String),
}
#[derive(Debug, Clone)]
pub struct ConstraintDrag {
pub id: String,
pub field: &'static str,
pub params: serde_json::Value,
pub preview: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RefSelectTarget {
#[default]
Feature,
AssemblyConstraint,
SplineAnchor { index: usize },
Pmi,
}
#[derive(Debug, Clone, Default)]
pub struct RefSelectState {
pub feature_id: String,
pub path: Vec<String>,
pub label: String,
pub filter: Vec<String>,
pub multiple: bool,
pub names: Vec<String>,
pub restore_index: usize,
pub target: RefSelectTarget,
}
impl Default for EngineState {
fn default() -> Self {
Self {
scene: RenderScene::new(),
camera: ViewCamera::default(),
controls: ArcballControls::new(),
settings: RenderSettings::default(),
emphasis: Emphasis::default(),
widgets: WidgetRegistry::new(),
history: History::default(),
history_report: String::new(),
metadata: crate::metadata::MetadataStore::new(),
settings_generation: 1,
dirty: true,
ref_select: None,
selection_filter: SelectionFilter::default(),
transform_gizmo: TransformArm::default(),
component_move: ComponentMoveArm::default(),
sketch_edit: None,
sketch_camera_locked: true,
sketch_list_hover_active: false,
notices: Vec::new(),
hidden_sketches: std::collections::HashSet::new(),
shown_sketch_ids: Vec::new(),
construction_frames: Vec::new(),
sketch_profiles: Vec::new(),
sketch_paths: Vec::new(),
sketch_points: Vec::new(),
sketch_axes: Vec::new(),
wire_harness_report: None,
pmi_report: None,
pmi_active_view: None,
pmi_open_annotation: None,
pmi_modeling: None,
pmi_explode_originals: std::collections::HashMap::new(),
pmi_overlay_key: None,
pmi_hovered: None,
pmi_label_hover_active: false,
spline_overlay_key: None,
component_ports_visible: false,
spline_edit_feature: None,
spline_anchor_picked: None,
hidden_datums: std::collections::HashSet::new(),
shown_datum_names: Vec::new(),
runner: Box::new(crate::runner::InlineRunner::new()),
run_generation: 0,
applied_generation: 0,
run_progress: None,
cancelled_run: None,
pending_fit: false,
provenance: std::collections::HashMap::new(),
entity_origin: std::collections::HashMap::new(),
info_cache: std::collections::HashMap::new(),
pending_query: std::collections::HashMap::new(),
next_query_id: 0,
pending_mesh_imports: std::collections::HashMap::new(),
mesh_preview_results: std::collections::VecDeque::new(),
next_mesh_import_id: 0,
assembly_components: Vec::new(),
assembly_synced_generation: None,
library_resync: false,
parts_library_block_revision: None,
constraint_overlays: Vec::new(),
constraint_drag: None,
constraint_overlay_wpp: 0.0,
feature_dim_overlay_wpp: 0.0,
sketch_overlay_wpp: 0.0,
constraint_hovered: None,
constraint_label_hover_active: false,
scene_tree_hovered: None,
scene_tree_hover_active: false,
dialog_hovered: None,
dialog_hover_active: false,
selected_constraint: None,
pending_step_assembly: None,
pending_step_probes: std::collections::HashSet::new(),
step_probe_results: std::collections::VecDeque::new(),
next_step_probe_id: 1,
}
}
}
impl EngineState {
pub fn new() -> Self {
Self::default()
}
fn pick_options(&self) -> PickOptions {
PickOptions {
double_sided: self.settings.pick_double_sided,
..PickOptions::default()
}
}
}
pub(crate) fn overlay_wpp_stale(baked: f64, now: f64) -> bool {
baked > 0.0 && (now - baked).abs() > baked * 0.005
}
mod assembly_ops;
mod assembly_overlay;
mod bom;
mod camera_widgets;
mod committed_sketches;
mod component_move;
mod components;
mod construction_datums;
mod expressions;
mod feature_dims;
mod interference;
mod history_ops;
mod model_io;
mod plane_pick;
mod scene_query;
mod selection_filter;
mod selection_ux;
mod sketch_edit_ops;
mod sketch_input;
mod sketch_mode;
mod sketch_panel;
mod transform_gizmo;
mod wire_harness_ops;
mod pmi_ops;
pub use pmi_ops::{world_vertex_ref, PmiModelingSnapshot, PmiViewPatch};
mod pmi_overlay;
mod spline_edit;
pub use assembly_ops::{document_signature, ComponentInsert};
pub use bom::PART_ATTRIBUTES;
pub use component_move::ComponentMoveArm;
pub use components::ComponentInfo;
pub use interference::{InterferencePair, InterferenceReport};
pub use model_io::{
EmbeddedOnly, PartSink, StepAssemblyImport, StepAssemblyProbe, StepAssemblyReport,
};
pub use selection_filter::SelectionFilter;
pub use sketch_mode::{SketchDrag, SketchEdit};
pub use sketch_panel::{SketchConstraintAction, SketchEntityRow};
pub use wire_harness_ops::ConnectionPatch;
pub use spline_edit::SplineAnchorRow;
pub use transform_gizmo::{GizmoMode, TransformArm};
pub(crate) use transform_gizmo::rotate_euler_xyz_f64;
#[derive(Clone, Copy, PartialEq, Eq)]
pub(crate) enum MeshImportDestination {
Document,
Preview,
}