use super::*; fn selected_edge_body(app: &OpenCADStudio, tab: usize) -> Option { let scene = &app.tabs.get(tab)?.scene; let selected = scene.selected_handles_in_order(); let [handle] = selected.as_slice() else { return None; }; if matches!( scene.document.get_entity(*handle), Some(acadrust::EntityType::Solid3D(_) | acadrust::EntityType::Surface(_)) ) { Some(*handle) } else { None } } fn solid_edge_sources( app: &mut OpenCADStudio, tab: usize, ) -> Vec<(acadrust::Handle, cadkernel::brep::Body)> { let handles = app.tabs[tab] .scene .document .entities() .filter_map(|entity| { matches!( entity, acadrust::EntityType::Solid3D(_) | acadrust::EntityType::Surface(_) ) .then_some(entity.common().handle) }) .collect::>(); app.tabs[tab].scene.restore_solid_models(&handles); handles .into_iter() .filter_map(|handle| { app.tabs[tab] .scene .solid_models .get(&handle) .cloned() .map(|body| (handle, body)) }) .collect() } impl OpenCADStudio { pub(super) fn dispatch_dim(&mut self, cmd: &str, i: usize) -> Option> { match cmd { "DIMALIGNED" => { use crate::modules::annotate::aligned_dim::AlignedDimensionCommand; let cmd = AlignedDimensionCommand::new(); self.command_line.push_info(&cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(cmd)); } "DIMDIAMETER" => { use crate::modules::annotate::diameter_dim::DiameterDimensionCommand; let cmd = DiameterDimensionCommand::new(); self.command_line.push_info(&cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(cmd)); } "DIMLINEAR" => { use crate::modules::annotate::linear_dim::LinearDimensionCommand; let new_cmd = LinearDimensionCommand::new(); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "DIMRADIUS" => { use crate::modules::annotate::radius_dim::RadiusDimensionCommand; let new_cmd = RadiusDimensionCommand::new(); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "DIMJOGGED" | "DIMJOG" => { use crate::modules::annotate::jogged_radius_dim::JoggedRadiusDimensionCommand; let defaults = crate::scene::creation_style::current_dimension_defaults( &self.tabs[i].scene.document, ); let multiplier = self.tabs[i].scene.creation_annotation_multiplier(); let new_cmd = JoggedRadiusDimensionCommand::new(defaults, multiplier); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "DIMANGULAR" => { use crate::modules::annotate::angular_dim::AngularDimensionCommand; let new_cmd = AngularDimensionCommand::new(); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "DIMARC" => { use crate::modules::annotate::arc_length_dim::ArcLengthDimensionCommand; let new_cmd = ArcLengthDimensionCommand::new(); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "DIMORDINATE" => { use crate::modules::annotate::ordinate_dim::OrdinateDimCommand; let new_cmd = OrdinateDimCommand::new(); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } // LEADER draws a leader line with an annotation; QLEADER is the same // quick leader-plus-annotation operation. "LEADER" | "QLEADER" => { use crate::modules::annotate::leader_cmd::LeaderCommand; let defaults = crate::scene::creation_style::current_dimension_defaults( &self.tabs[i].scene.document, ); let multiplier = self.tabs[i].scene.creation_annotation_multiplier(); let new_cmd = LeaderCommand::with_defaults(defaults, multiplier); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } // JUSTIFYTEXT