feat(f64): command layer compiles on DVec3

Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.

- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
  in full f64; others via point methods), modify, annotate, insert, view,
  inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
  wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
  non-critical, casting at the DVec3 boundary; key draw commands store f64.

Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-24 03:51:50 +03:00
1 parent 3da71698b1
commit 4f7a98a2ad
84 files changed
+358 -336

No files matched your search

+2 -2
View File
@@ -422,7 +422,7 @@ impl OpenCADStudio {
if let Some(r) = self.tabs[i] if let Some(r) = self.tabs[i]
.active_cmd .active_cmd
.as_mut() .as_mut()
.map(|c| c.on_entity_pick(handle, pt)) .map(|c| c.on_entity_pick(handle, pt.as_dvec3()))
{ {
let _ = self.apply_cmd_result(r); let _ = self.apply_cmd_result(r);
} }
@@ -436,7 +436,7 @@ impl OpenCADStudio {
} }
} }
self.last_point = Some(pt); self.last_point = Some(pt);
if let Some(r) = self.tabs[i].active_cmd.as_mut().map(|c| c.on_point(pt)) { if let Some(r) = self.tabs[i].active_cmd.as_mut().map(|c| c.on_point(pt.as_dvec3())) {
let _ = self.apply_cmd_result(r); let _ = self.apply_cmd_result(r);
} }
} else if let Some(r) = self.tabs[i] } else if let Some(r) = self.tabs[i]
+3 -3
View File
@@ -5402,7 +5402,7 @@ impl OpenCADStudio {
if selected.len() == 1 { if selected.len() == 1 {
let handle = selected[0].0; let handle = selected[0].0;
let mut cmd = ExtrudeCommand::new(color); let mut cmd = ExtrudeCommand::new(color);
cmd.on_entity_pick(handle, glam::Vec3::ZERO); cmd.on_entity_pick(handle, glam::DVec3::ZERO);
self.command_line.push_info(&cmd.prompt()); self.command_line.push_info(&cmd.prompt());
self.tabs[i].active_cmd = Some(Box::new(cmd)); self.tabs[i].active_cmd = Some(Box::new(cmd));
} else { } else {
@@ -5931,7 +5931,7 @@ impl CadCommand for DrawOrderRefCommand {
fn on_entity_pick( fn on_entity_pick(
&mut self, &mut self,
handle: acadrust::Handle, handle: acadrust::Handle,
_pt: glam::Vec3, _pt: glam::DVec3,
) -> crate::command::CmdResult { ) -> crate::command::CmdResult {
if handle.is_null() { if handle.is_null() {
return crate::command::CmdResult::NeedPoint; return crate::command::CmdResult::NeedPoint;
@@ -5941,7 +5941,7 @@ impl CadCommand for DrawOrderRefCommand {
crate::command::CmdResult::Relaunch(cmd, std::mem::take(&mut self.to_move)) crate::command::CmdResult::Relaunch(cmd, std::mem::take(&mut self.to_move))
} }
fn on_point(&mut self, _pt: glam::Vec3) -> crate::command::CmdResult { fn on_point(&mut self, _pt: glam::DVec3) -> crate::command::CmdResult {
crate::command::CmdResult::NeedPoint crate::command::CmdResult::NeedPoint
} }
+2 -2
View File
@@ -232,7 +232,7 @@ impl crate::command::CadCommand for PluginInteractiveAdapter {
crate::plugin::guard("InteractiveCommand::prompt", || self.inner.prompt()) crate::plugin::guard("InteractiveCommand::prompt", || self.inner.prompt())
.unwrap_or_default() .unwrap_or_default()
} }
fn on_point(&mut self, pt: glam::Vec3) -> crate::command::CmdResult { fn on_point(&mut self, pt: glam::DVec3) -> crate::command::CmdResult {
crate::plugin::guard("InteractiveCommand::on_point", || { crate::plugin::guard("InteractiveCommand::on_point", || {
self.inner.on_point([pt.x as f64, pt.y as f64, pt.z as f64]) self.inner.on_point([pt.x as f64, pt.y as f64, pt.z as f64])
}) })
@@ -250,7 +250,7 @@ impl crate::command::CadCommand for PluginInteractiveAdapter {
}) })
.unwrap_or(false) .unwrap_or(false)
} }
fn on_entity_pick(&mut self, handle: Handle, pt: glam::Vec3) -> crate::command::CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: glam::DVec3) -> crate::command::CmdResult {
crate::plugin::guard("InteractiveCommand::on_object_pick", || { crate::plugin::guard("InteractiveCommand::on_object_pick", || {
self.inner self.inner
.on_object_pick(handle, [pt.x as f64, pt.y as f64, pt.z as f64]) .on_object_pick(handle, [pt.x as f64, pt.y as f64, pt.z as f64])
+1 -1
View File
@@ -270,7 +270,7 @@ impl OpenCADStudio {
// A command may drive a typed scalar by mouse (e.g. a // A command may drive a typed scalar by mouse (e.g. a
// perpendicular distance to a picked object); show that live // perpendicular distance to a picked object); show that live
// value in the box until the user types over it. // value in the box until the user types over it.
let live = tab.active_cmd.as_ref().and_then(|c| c.dyn_live_value(w)); let live = tab.active_cmd.as_ref().and_then(|c| c.dyn_live_value(w.as_dvec3()));
let boxes: Vec<overlay::DynBox> = tab let boxes: Vec<overlay::DynBox> = tab
.dyn_fields .dyn_fields
.iter() .iter()
+2 -2
View File
@@ -188,9 +188,9 @@ impl Grippable for Hatch {
fn resolve(apply: &GripApply, cur: Vec3) -> (f64, f64) { fn resolve(apply: &GripApply, cur: Vec3) -> (f64, f64) {
let p = match apply { let p = match apply {
GripApply::Absolute(p) => *p, GripApply::Absolute(p) => *p,
GripApply::Translate(d) => cur + *d, GripApply::Translate(d) => cur.as_dvec3() + *d,
}; };
(p.x as f64, p.y as f64) (p.x, p.y)
} }
'outer: for path in &mut self.paths { 'outer: for path in &mut self.paths {
+1 -1
View File
@@ -24,7 +24,7 @@ pub(crate) fn mleader_v_anchor(attach: TextAttachmentType) -> MTextVAnchor {
| TextAttachmentType::BottomOfTopLineUnderlineAll => MTextVAnchor::BottomOfTopLine, | TextAttachmentType::BottomOfTopLineUnderlineAll => MTextVAnchor::BottomOfTopLine,
} }
} }
use glam::{DVec3, Vec3}; use glam::DVec3;
use crate::command::EntityTransform; use crate::command::EntityTransform;
use crate::entities::common::{ use crate::entities::common::{
+3 -3
View File
@@ -78,7 +78,7 @@ impl Grippable for Solid3D {
self.point_of_reference.x += d.x as f64; self.point_of_reference.x += d.x as f64;
self.point_of_reference.y += d.y as f64; self.point_of_reference.y += d.y as f64;
self.point_of_reference.z += d.z as f64; self.point_of_reference.z += d.z as f64;
translate_wires(&mut self.wires, d); translate_wires(&mut self.wires, d.as_vec3());
} }
} }
} }
@@ -154,7 +154,7 @@ impl Grippable for Region {
self.point_of_reference.x += d.x as f64; self.point_of_reference.x += d.x as f64;
self.point_of_reference.y += d.y as f64; self.point_of_reference.y += d.y as f64;
self.point_of_reference.z += d.z as f64; self.point_of_reference.z += d.z as f64;
translate_wires(&mut self.wires, d); translate_wires(&mut self.wires, d.as_vec3());
} }
} }
} }
@@ -222,7 +222,7 @@ impl Grippable for Body {
self.point_of_reference.x += d.x as f64; self.point_of_reference.x += d.x as f64;
self.point_of_reference.y += d.y as f64; self.point_of_reference.y += d.y as f64;
self.point_of_reference.z += d.z as f64; self.point_of_reference.z += d.z as f64;
translate_wires(&mut self.wires, d); translate_wires(&mut self.wires, d.as_vec3());
} }
} }
} }
+3 -3
View File
@@ -3,7 +3,7 @@
use acadrust::entities::{Dimension, DimensionAligned}; use acadrust::entities::{Dimension, DimensionAligned};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -49,7 +49,7 @@ impl CadCommand for AlignedDimensionCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::First => { Step::First => {
self.step = Step::Second(pt); self.step = Step::Second(pt);
@@ -83,7 +83,7 @@ impl CadCommand for AlignedDimensionCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let (p1, p2) = match self.step { let (p1, p2) = match self.step {
Step::First => return None, Step::First => return None,
Step::Second(p1) => (p1, pt), Step::Second(p1) => (p1, pt),
+3 -3
View File
@@ -5,7 +5,7 @@ use acadrust::EntityType;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_angular.svg")); pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_angular.svg"));
@@ -56,7 +56,7 @@ impl CadCommand for AngularDimensionCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::Vertex => { Step::Vertex => {
self.step = Step::FirstRay(pt); self.step = Step::FirstRay(pt);
@@ -98,7 +98,7 @@ impl CadCommand for AngularDimensionCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step { match self.step {
Step::Vertex => None, Step::Vertex => None,
Step::FirstRay(vertex) => Some(preview_wire(vec![vertex, pt])), Step::FirstRay(vertex) => Some(preview_wire(vec![vertex, pt])),
+3 -3
View File
@@ -8,7 +8,7 @@
// entity it annotates. // entity it annotates.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -45,7 +45,7 @@ impl CadCommand for DdeditCommand {
true true
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -54,7 +54,7 @@ impl CadCommand for DdeditCommand {
CmdResult::EditTextEntity { handle } CmdResult::EditTextEntity { handle }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+3 -3
View File
@@ -3,7 +3,7 @@
use acadrust::entities::{Dimension, DimensionDiameter}; use acadrust::entities::{Dimension, DimensionDiameter};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -51,7 +51,7 @@ impl CadCommand for DiameterDimensionCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::CenterPoint => { Step::CenterPoint => {
self.step = Step::ArcPoint(pt); self.step = Step::ArcPoint(pt);
@@ -77,7 +77,7 @@ impl CadCommand for DiameterDimensionCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step { match self.step {
Step::CenterPoint => None, Step::CenterPoint => None,
Step::ArcPoint(center) => Some(preview_line(center, pt)), Step::ArcPoint(center) => Some(preview_line(center, pt)),
+3 -3
View File
@@ -9,7 +9,7 @@
use acadrust::entities::{Dimension, DimensionLinear}; use acadrust::entities::{Dimension, DimensionLinear};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -107,7 +107,7 @@ impl CadCommand for DimBaselineCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if !self.ready { if !self.ready {
return CmdResult::Cancel; return CmdResult::Cancel;
} }
@@ -136,7 +136,7 @@ impl CadCommand for DimBaselineCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !self.ready { if !self.ready {
return None; return None;
} }
+3 -3
View File
@@ -9,7 +9,7 @@
use acadrust::entities::{Dimension, DimensionLinear}; use acadrust::entities::{Dimension, DimensionLinear};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -87,7 +87,7 @@ impl CadCommand for DimContinueCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if !self.ready { if !self.ready {
return CmdResult::Cancel; return CmdResult::Cancel;
} }
@@ -116,7 +116,7 @@ impl CadCommand for DimContinueCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !self.ready { if !self.ready {
return None; return None;
} }
+3 -3
View File
@@ -10,7 +10,7 @@
// and emits a ReplaceEntity sentinel that commands.rs intercepts to apply the break. // and emits a ReplaceEntity sentinel that commands.rs intercepts to apply the break.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -61,7 +61,7 @@ impl CadCommand for DimBreakCommand {
true true
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -81,7 +81,7 @@ impl CadCommand for DimBreakCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
+3 -3
View File
@@ -5,7 +5,7 @@
// 2. Enter new text (blank = reset to auto-measured value, "<>" = measured value placeholder) // 2. Enter new text (blank = reset to auto-measured value, "<>" = measured value placeholder)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -56,7 +56,7 @@ impl CadCommand for DimEditCommand {
matches!(self.step, Step::PickDim) matches!(self.step, Step::PickDim)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -78,7 +78,7 @@ impl CadCommand for DimEditCommand {
Some(CmdResult::DdeditEntity { handle, new_text }) Some(CmdResult::DdeditEntity { handle, new_text })
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+4 -4
View File
@@ -5,7 +5,7 @@
// 2. Click the position on the dimension line where the jog should appear // 2. Click the position on the dimension line where the jog should appear
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -55,7 +55,7 @@ impl CadCommand for DimJogLineCommand {
matches!(self.step, Step::PickDim) matches!(self.step, Step::PickDim)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -63,7 +63,7 @@ impl CadCommand for DimJogLineCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Step::PickJogPos { handle } = &self.step { if let Step::PickJogPos { handle } = &self.step {
let h = *handle; let h = *handle;
// Emit sentinel for commands.rs to store the jog position // Emit sentinel for commands.rs to store the jog position
@@ -79,7 +79,7 @@ impl CadCommand for DimJogLineCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !matches!(self.step, Step::PickJogPos { .. }) { if !matches!(self.step, Step::PickJogPos { .. }) {
return None; return None;
} }
+3 -3
View File
@@ -6,7 +6,7 @@
// 3. Enter spacing value (or 0 for automatic equal spacing) // 3. Enter spacing value (or 0 for automatic equal spacing)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -60,7 +60,7 @@ impl CadCommand for DimSpaceCommand {
matches!(self.step, Step::PickBase | Step::PickOthers { .. }) matches!(self.step, Step::PickBase | Step::PickOthers { .. })
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -109,7 +109,7 @@ impl CadCommand for DimSpaceCommand {
None None
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
+4 -4
View File
@@ -5,7 +5,7 @@
// 2. Click the new text position (entity data is injected by update.rs after pick) // 2. Click the new text position (entity data is injected by update.rs after pick)
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -58,7 +58,7 @@ impl CadCommand for DimTeditCommand {
matches!(self.step, Step::PickDim) matches!(self.step, Step::PickDim)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -69,7 +69,7 @@ impl CadCommand for DimTeditCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Step::PickTextPos { handle, entity } = &mut self.step { if let Step::PickTextPos { handle, entity } = &mut self.step {
let h = *handle; let h = *handle;
if let Some(mut ent) = entity.take() { if let Some(mut ent) = entity.take() {
@@ -92,7 +92,7 @@ impl CadCommand for DimTeditCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !matches!(self.step, Step::PickTextPos { .. }) { if !matches!(self.step, Step::PickTextPos { .. }) {
return None; return None;
} }
+3 -3
View File
@@ -13,7 +13,7 @@ use acadrust::entities::mtext::AttachmentPoint;
use acadrust::entities::{Leader, LeaderCreationType, MText}; use acadrust::entities::{Leader, LeaderCreationType, MText};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::{Mat4, Vec3}; use glam::{DVec3, Mat4, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -61,7 +61,7 @@ impl CadCommand for LeaderCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
self.verts.push(pt); self.verts.push(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -85,7 +85,7 @@ impl CadCommand for LeaderCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.verts.is_empty() { if self.verts.is_empty() {
return None; return None;
} }
+3 -3
View File
@@ -5,7 +5,7 @@ use acadrust::EntityType;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::{Mat4, Vec3}; use glam::{DVec3, Mat4, Vec3};
/// World-space measurement axis for a linear dimension between `first` and /// World-space measurement axis for a linear dimension between `first` and
/// `second`, chosen as the UCS X or Y axis (whichever the span is closer to). /// `second`, chosen as the UCS X or Y axis (whichever the span is closer to).
@@ -69,7 +69,7 @@ impl CadCommand for LinearDimensionCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::FirstPoint => { Step::FirstPoint => {
self.step = Step::SecondPoint(pt); self.step = Step::SecondPoint(pt);
@@ -113,7 +113,7 @@ impl CadCommand for LinearDimensionCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step { match self.step {
Step::FirstPoint => None, Step::FirstPoint => None,
Step::SecondPoint(first) => Some(preview_wire(vec![first, pt])), Step::SecondPoint(first) => Some(preview_wire(vec![first, pt])),
+3 -3
View File
@@ -8,7 +8,7 @@
use acadrust::entities::MultiLeader; use acadrust::entities::MultiLeader;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::{Mat4, Vec3}; use glam::{DVec3, Mat4, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -56,7 +56,7 @@ impl CadCommand for MLeaderCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
self.verts.push(pt); self.verts.push(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -75,7 +75,7 @@ impl CadCommand for MLeaderCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.verts.is_empty() { if self.verts.is_empty() {
return None; return None;
} }
+11 -11
View File
@@ -8,7 +8,7 @@
use acadrust::entities::{LeaderLine, MultiLeader}; use acadrust::entities::{LeaderLine, MultiLeader};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -73,7 +73,7 @@ impl CadCommand for MLeaderAddCommand {
matches!(self.step, AddStep::PickMLeader) matches!(self.step, AddStep::PickMLeader)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -84,7 +84,7 @@ impl CadCommand for MLeaderAddCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &mut self.step { match &mut self.step {
AddStep::PickArrowhead { handle, entity } => { AddStep::PickArrowhead { handle, entity } => {
if let Some(ent) = entity.take() { if let Some(ent) = entity.take() {
@@ -132,7 +132,7 @@ impl CadCommand for MLeaderAddCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let existing_pts = match &self.step { let existing_pts = match &self.step {
AddStep::CollectPoints { pts, .. } => pts.clone(), AddStep::CollectPoints { pts, .. } => pts.clone(),
_ => return None, _ => return None,
@@ -201,7 +201,7 @@ impl CadCommand for MLeaderRemoveCommand {
matches!(self.step, RemoveStep::PickMLeader) matches!(self.step, RemoveStep::PickMLeader)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -212,7 +212,7 @@ impl CadCommand for MLeaderRemoveCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let RemoveStep::PickLeaderToRemove { handle, entity } = &mut self.step { if let RemoveStep::PickLeaderToRemove { handle, entity } = &mut self.step {
if let Some(mut ent) = entity.take() { if let Some(mut ent) = entity.take() {
let h = *handle; let h = *handle;
@@ -247,7 +247,7 @@ impl CadCommand for MLeaderRemoveCommand {
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
@@ -321,7 +321,7 @@ impl CadCommand for MLeaderAlignCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &mut self.step { match &mut self.step {
AlignStep::PickDirection { handles } => { AlignStep::PickDirection { handles } => {
let h = handles.clone(); let h = handles.clone();
@@ -359,7 +359,7 @@ impl CadCommand for MLeaderAlignCommand {
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
@@ -423,7 +423,7 @@ impl CadCommand for MLeaderCollectCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let CollectStep::PickLocation { handles } = &self.step { if let CollectStep::PickLocation { handles } = &self.step {
let h = handles.clone(); let h = handles.clone();
// Build a new combined multileader at the collection point, delete originals. // Build a new combined multileader at the collection point, delete originals.
@@ -447,7 +447,7 @@ impl CadCommand for MLeaderCollectCommand {
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
+3 -3
View File
@@ -1,7 +1,7 @@
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::DVec3;
pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/mtext.svg")); pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/mtext.svg"));
@@ -41,7 +41,7 @@ impl CadCommand for MTextCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
// Hand off to the in-place editor (toolbar + text area + live preview). // Hand off to the in-place editor (toolbar + text area + live preview).
CmdResult::OpenMTextEditor { CmdResult::OpenMTextEditor {
pos: pt, pos: pt,
@@ -58,7 +58,7 @@ impl CadCommand for MTextCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
+3 -3
View File
@@ -11,7 +11,7 @@
use acadrust::entities::{Dimension, DimensionOrdinate}; use acadrust::entities::{Dimension, DimensionOrdinate};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -55,7 +55,7 @@ impl CadCommand for OrdinateDimCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::FeaturePoint => { Step::FeaturePoint => {
self.step = Step::LeaderEndpoint { feature: pt }; self.step = Step::LeaderEndpoint { feature: pt };
@@ -78,7 +78,7 @@ impl CadCommand for OrdinateDimCommand {
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+3 -3
View File
@@ -9,7 +9,7 @@
use acadrust::entities::{Dimension, DimensionLinear}; use acadrust::entities::{Dimension, DimensionLinear};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -67,7 +67,7 @@ impl CadCommand for QdimCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Step::PlaceLine { handles } = &self.step { if let Step::PlaceLine { handles } = &self.step {
CmdResult::Relaunch( CmdResult::Relaunch(
format!("QDIM_PLACE {:.6} {:.6} {:.6}", pt.x, pt.y, pt.z), format!("QDIM_PLACE {:.6} {:.6} {:.6}", pt.x, pt.y, pt.z),
@@ -82,7 +82,7 @@ impl CadCommand for QdimCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !matches!(self.step, Step::PlaceLine { .. }) { if !matches!(self.step, Step::PlaceLine { .. }) {
return None; return None;
} }
+3 -3
View File
@@ -5,7 +5,7 @@ use acadrust::EntityType;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_radius.svg")); pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_radius.svg"));
@@ -49,7 +49,7 @@ impl CadCommand for RadiusDimensionCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::CenterPoint => { Step::CenterPoint => {
self.step = Step::RadiusPoint(pt); self.step = Step::RadiusPoint(pt);
@@ -79,7 +79,7 @@ impl CadCommand for RadiusDimensionCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match self.step { match self.step {
Step::CenterPoint => None, Step::CenterPoint => None,
Step::RadiusPoint(center) => Some(preview_wire(vec![center, pt])), Step::RadiusPoint(center) => Some(preview_wire(vec![center, pt])),
+3 -3
View File
@@ -10,7 +10,7 @@
use acadrust::entities::TableBuilder; use acadrust::entities::TableBuilder;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -116,7 +116,7 @@ impl CadCommand for TableCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Step::Insertion { cols, rows } = self.step { if let Step::Insertion { cols, rows } = self.step {
let ins = Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64); let ins = Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64);
let table = TableBuilder::new(rows, cols) let table = TableBuilder::new(rows, cols)
@@ -130,7 +130,7 @@ impl CadCommand for TableCommand {
} }
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if let Step::Insertion { cols, rows } = self.step { if let Step::Insertion { cols, rows } = self.step {
// Preview: outline of the table bounding box. // Preview: outline of the table bounding box.
let w = (cols as f32) * COL_WIDTH as f32; let w = (cols as f32) * COL_WIDTH as f32;
+3 -3
View File
@@ -1,7 +1,7 @@
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::DVec3;
pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/text.svg")); pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/text.svg"));
@@ -41,7 +41,7 @@ impl CadCommand for TextCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
// Hand off to the in-place plain-text editor anchored at the click. // Hand off to the in-place plain-text editor anchored at the click.
CmdResult::OpenTextEditor { CmdResult::OpenTextEditor {
pos: pt, pos: pt,
@@ -58,7 +58,7 @@ impl CadCommand for TextCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
+4 -4
View File
@@ -8,7 +8,7 @@
// 4. In Single mode, editing an object exits the command immediately. // 4. In Single mode, editing an object exits the command immediately.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -95,7 +95,7 @@ impl CadCommand for TexteditCommand {
self.step == Step::PickObject self.step == Step::PickObject
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -160,7 +160,7 @@ impl CadCommand for TexteditCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -248,7 +248,7 @@ impl CadCommand for TexteditmodeCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
+3 -3
View File
@@ -7,7 +7,7 @@
use acadrust::entities::Tolerance; use acadrust::entities::Tolerance;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -64,7 +64,7 @@ impl CadCommand for ToleranceCommand {
Some(CmdResult::NeedPoint) Some(CmdResult::NeedPoint)
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Step::Insertion { text } = &self.step { if let Step::Insertion { text } = &self.step {
let ins = Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64); let ins = Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64);
let tol = Tolerance::with_text(ins, text.clone()); let tol = Tolerance::with_text(ins, text.clone());
@@ -78,7 +78,7 @@ impl CadCommand for ToleranceCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !matches!(self.step, Step::Insertion { .. }) { if !matches!(self.step, Step::Insertion { .. }) {
return None; return None;
} }
+4 -4
View File
@@ -16,7 +16,7 @@ pub const MENU_ITEMS: &[(&str, &str, IconKind)] = &[
// ── CadCommand implementation ───────────────────────────────────────────── // ── CadCommand implementation ─────────────────────────────────────────────
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -43,7 +43,7 @@ impl CadCommand for PasteCommand {
"PASTECLIP Pick insertion point:".into() "PASTECLIP Pick insertion point:".into()
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
CmdResult::PasteClipboard { base_pt: pt } CmdResult::PasteClipboard { base_pt: pt }
} }
@@ -51,11 +51,11 @@ impl CadCommand for PasteCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> { let pt = pt.as_vec3();
let delta = pt - self.centroid; let delta = pt - self.centroid;
self.wires.iter().map(|w| w.translated(delta)).collect() self.wires.iter().map(|w| w.translated(delta)).collect()
} }
+3 -3
View File
@@ -9,7 +9,7 @@
use acadrust::entities::AttributeDefinition; use acadrust::entities::AttributeDefinition;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -106,7 +106,7 @@ impl CadCommand for AttdefCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Step::Insertion { if let Step::Insertion {
tag, tag,
prompt, prompt,
@@ -153,7 +153,7 @@ impl CadCommand for AttdefCommand {
} }
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if !matches!(self.step, Step::Insertion { .. }) { if !matches!(self.step, Step::Insertion { .. }) {
return None; return None;
} }
+2 -2
View File
@@ -12,7 +12,7 @@
use acadrust::entities::{LwPolyline, LwVertex}; use acadrust::entities::{LwPolyline, LwVertex};
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -91,7 +91,7 @@ impl CadCommand for DonutCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.state { match &self.state {
DonutState::PlaceCenter => { DonutState::PlaceCenter => {
let entity = make_donut(pt.x as f64, pt.y as f64, self.inner_r, self.outer_r); let entity = make_donut(pt.x as f64, pt.y as f64, self.inner_r, self.outer_r);
+6 -6
View File
@@ -13,7 +13,7 @@ use crate::command::{CadCommand, CmdResult};
use crate::modules::IconKind; use crate::modules::IconKind;
use crate::scene::model::hatch_model::{HatchModel, HatchPattern, PatFamily}; use crate::scene::model::hatch_model::{HatchModel, HatchPattern, PatFamily};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
// ── Icons ────────────────────────────────────────────────────────────────── // ── Icons ──────────────────────────────────────────────────────────────────
@@ -154,7 +154,7 @@ impl CadCommand for HatchCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &self.mode { match &self.mode {
Mode::PickInside => { Mode::PickInside => {
let xy = [pt.x, pt.y]; let xy = [pt.x, pt.y];
@@ -204,7 +204,7 @@ impl CadCommand for HatchCommand {
None None
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if let Mode::Manual = &self.mode { if let Mode::Manual = &self.mode {
if self.manual_pts.is_empty() { if self.manual_pts.is_empty() {
return None; return None;
@@ -292,7 +292,7 @@ impl CadCommand for GradientCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &self.mode { match &self.mode {
Mode::PickInside => { Mode::PickInside => {
let xy = [pt.x, pt.y]; let xy = [pt.x, pt.y];
@@ -342,7 +342,7 @@ impl CadCommand for GradientCommand {
None None
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if let Mode::Manual = &self.mode { if let Mode::Manual = &self.mode {
if self.manual_pts.is_empty() { if self.manual_pts.is_empty() {
return None; return None;
@@ -395,7 +395,7 @@ impl CadCommand for BoundaryCommand {
format!("BOUNDARY Pick internal point:{miss}") format!("BOUNDARY Pick internal point:{miss}")
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
let xy = [pt.x, pt.y]; let xy = [pt.x, pt.y];
for outline in &self.outlines { for outline in &self.outlines {
if point_in_polygon(xy, outline) { if point_in_polygon(xy, outline) {
+3 -3
View File
@@ -9,7 +9,7 @@
// Press Enter to apply changes. // Press Enter to apply changes.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -67,7 +67,7 @@ impl CadCommand for HatcheditCommand {
matches!(self.step, HatcheditStep::PickHatch) matches!(self.step, HatcheditStep::PickHatch)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -136,7 +136,7 @@ impl CadCommand for HatcheditCommand {
Some(CmdResult::NeedPoint) Some(CmdResult::NeedPoint)
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+10 -7
View File
@@ -12,7 +12,7 @@ use acadrust::{EntityType, Line};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::DVec3;
// ── Ribbon definition ───────────────────────────────────────────────────── // ── Ribbon definition ─────────────────────────────────────────────────────
@@ -29,7 +29,7 @@ pub fn tool() -> ToolDef {
pub struct LineCommand { pub struct LineCommand {
/// The last committed point (start of the next segment). /// The last committed point (start of the next segment).
last: Option<Vec3>, last: Option<DVec3>,
} }
impl LineCommand { impl LineCommand {
@@ -51,11 +51,11 @@ impl CadCommand for LineCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
if let Some(last) = self.last { if let Some(last) = self.last {
let line = Line::from_points( let line = Line::from_points(
Vector3::new(last.x as f64, last.y as f64, last.z as f64), Vector3::new(last.x, last.y, last.z),
Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64), Vector3::new(pt.x, pt.y, pt.z),
); );
self.last = Some(pt); self.last = Some(pt);
CmdResult::CommitEntity(EntityType::Line(line)) CmdResult::CommitEntity(EntityType::Line(line))
@@ -73,11 +73,14 @@ impl CadCommand for LineCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> {
let last = self.last?; let last = self.last?;
Some(WireModel { Some(WireModel {
name: "rubber_band".to_string(), name: "rubber_band".to_string(),
points: vec![[last.x, last.y, last.z], [pt.x, pt.y, pt.z]], points: vec![
[last.x as f32, last.y as f32, last.z as f32],
[pt.x as f32, pt.y as f32, pt.z as f32],
],
points_low: Vec::new(), points_low: Vec::new(),
color: WireModel::CYAN, color: WireModel::CYAN,
selected: false, selected: false,
+3 -3
View File
@@ -8,7 +8,7 @@
use acadrust::entities::MLine; use acadrust::entities::MLine;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -111,7 +111,7 @@ impl CadCommand for MlineCommand {
None None
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
self.points.push(pt); self.points.push(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -124,7 +124,7 @@ impl CadCommand for MlineCommand {
CmdResult::CommitAndExit(entity) CmdResult::CommitAndExit(entity)
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.points.is_empty() { if self.points.is_empty() {
return None; return None;
} }
+3 -3
View File
@@ -9,7 +9,7 @@ use acadrust::{EntityType, Point as CadPoint};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::DVec3;
#[allow(dead_code)] #[allow(dead_code)]
pub fn tool() -> ToolDef { pub fn tool() -> ToolDef {
@@ -37,7 +37,7 @@ impl CadCommand for PointCommand {
"POINT Specify point [Enter=done]:".into() "POINT Specify point [Enter=done]:".into()
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
let p = CadPoint { let p = CadPoint {
location: Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64), location: Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64),
..Default::default() ..Default::default()
@@ -51,7 +51,7 @@ impl CadCommand for PointCommand {
fn on_escape(&mut self) -> CmdResult { fn on_escape(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
+3 -3
View File
@@ -12,7 +12,7 @@
use acadrust::entities::LwVertex; use acadrust::entities::LwVertex;
use acadrust::types::Vector2; use acadrust::types::Vector2;
use acadrust::{EntityType, Handle, LwPolyline}; use acadrust::{EntityType, Handle, LwPolyline};
use glam::{Vec2, Vec3}; use glam::{DVec3, Vec2, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -224,7 +224,7 @@ impl CadCommand for PlineCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if !self.vertices.is_empty() { if !self.vertices.is_empty() {
let last = *self.vertices.last().unwrap(); let last = *self.vertices.last().unwrap();
let last_idx = self.vertices.len() - 1; let last_idx = self.vertices.len() - 1;
@@ -302,7 +302,7 @@ impl CadCommand for PlineCommand {
} }
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
// The committed vertices already render as a real document entity, so // The committed vertices already render as a real document entity, so
// the preview is just the pending segment from the last vertex to the // the preview is just the pending segment from the last vertex to the
// cursor. (#119) // cursor. (#119)
+3 -3
View File
@@ -9,7 +9,7 @@
use acadrust::entities::RasterImage; use acadrust::entities::RasterImage;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -75,7 +75,7 @@ impl CadCommand for ImageCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Some(origin) = self.origin { if let Some(origin) = self.origin {
let entity = self.make_entity(origin, pt); let entity = self.make_entity(origin, pt);
CmdResult::CommitAndExit(entity) CmdResult::CommitAndExit(entity)
@@ -97,7 +97,7 @@ impl CadCommand for ImageCommand {
} }
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let origin = self.origin?; let origin = self.origin?;
let world_width = (pt.x - origin.x).abs().max(0.001); let world_width = (pt.x - origin.x).abs().max(0.001);
let world_height = world_width / self.aspect() as f32; let world_height = world_width / self.aspect() as f32;
+5 -5
View File
@@ -10,7 +10,7 @@ use acadrust::EntityType;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
const DISPLAY_EXTENT: f32 = 1_000_000.0; const DISPLAY_EXTENT: f32 = 1_000_000.0;
@@ -39,7 +39,7 @@ impl CadCommand for RayCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Some(base) = self.base { if let Some(base) = self.base {
let dir = pt - base; let dir = pt - base;
let len = dir.length(); let len = dir.length();
@@ -69,7 +69,7 @@ impl CadCommand for RayCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let base = self.base?; let base = self.base?;
let dir = (pt - base).normalize_or_zero(); let dir = (pt - base).normalize_or_zero();
let far = base + dir * DISPLAY_EXTENT; let far = base + dir * DISPLAY_EXTENT;
@@ -120,7 +120,7 @@ impl CadCommand for XLineCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Some(base) = self.base { if let Some(base) = self.base {
let dir = pt - base; let dir = pt - base;
let len = dir.length(); let len = dir.length();
@@ -148,7 +148,7 @@ impl CadCommand for XLineCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let base = self.base?; let base = self.base?;
let dir = (pt - base).normalize_or_zero(); let dir = (pt - base).normalize_or_zero();
let far_pos = base + dir * DISPLAY_EXTENT; let far_pos = base + dir * DISPLAY_EXTENT;
+3 -3
View File
@@ -7,7 +7,7 @@
use acadrust::entities::LwPolyline; use acadrust::entities::LwPolyline;
use acadrust::types::Vector2; use acadrust::types::Vector2;
use acadrust::{entities::LwVertex, EntityType}; use acadrust::{entities::LwVertex, EntityType};
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -59,7 +59,7 @@ impl CadCommand for RevCloudCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
self.points.push(pt); self.points.push(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -72,7 +72,7 @@ impl CadCommand for RevCloudCommand {
CmdResult::CommitAndExit(entity) CmdResult::CommitAndExit(entity)
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.points.is_empty() { if self.points.is_empty() {
return None; return None;
} }
+3 -3
View File
@@ -9,7 +9,7 @@ use acadrust::{EntityType, Spline};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
#[allow(dead_code)] #[allow(dead_code)]
pub fn tool() -> ToolDef { pub fn tool() -> ToolDef {
@@ -84,7 +84,7 @@ impl CadCommand for SplineCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
self.pts.push(pt); self.pts.push(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -103,7 +103,7 @@ impl CadCommand for SplineCommand {
} }
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.pts.is_empty() { if self.pts.is_empty() {
return None; return None;
} }
+3 -3
View File
@@ -7,7 +7,7 @@
use acadrust::entities::Wipeout; use acadrust::entities::Wipeout;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -79,7 +79,7 @@ impl CadCommand for WipeoutCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &self.mode { match &self.mode {
WipeoutMode::Rectangular => { WipeoutMode::Rectangular => {
if let Some(p1) = self.first { if let Some(p1) = self.first {
@@ -107,7 +107,7 @@ impl CadCommand for WipeoutCommand {
} }
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
match &self.mode { match &self.mode {
WipeoutMode::Rectangular => { WipeoutMode::Rectangular => {
let p1 = self.first?; let p1 = self.first?;
+3 -3
View File
@@ -14,7 +14,7 @@ pub fn tool() -> ToolDef {
// ── CadCommand implementation ───────────────────────────────────────────── // ── CadCommand implementation ─────────────────────────────────────────────
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -64,11 +64,11 @@ impl CadCommand for GroupCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+3 -3
View File
@@ -14,7 +14,7 @@ pub fn tool() -> ToolDef {
// ── CadCommand implementation ───────────────────────────────────────────── // ── CadCommand implementation ─────────────────────────────────────────────
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -47,7 +47,7 @@ impl CadCommand for UngroupCommand {
CmdResult::DeleteGroups { handles } CmdResult::DeleteGroups { handles }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -55,7 +55,7 @@ impl CadCommand for UngroupCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+3 -3
View File
@@ -1,7 +1,7 @@
// AREA command — compute area and perimeter of a polygon picked point by point. // AREA command — compute area and perimeter of a polygon picked point by point.
// Press Enter to close and calculate. // Press Enter to close and calculate.
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -32,7 +32,7 @@ impl CadCommand for AreaCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
self.points.push(pt); self.points.push(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
@@ -56,7 +56,7 @@ impl CadCommand for AreaCommand {
CmdResult::Measurement(msg) CmdResult::Measurement(msg)
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.points.is_empty() { if self.points.is_empty() {
return None; return None;
} }
+3 -3
View File
@@ -1,6 +1,6 @@
// DIST command — measure distance and angle between two picked points. // DIST command — measure distance and angle between two picked points.
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -28,7 +28,7 @@ impl CadCommand for DistCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Some(p1) = self.first { if let Some(p1) = self.first {
let delta = pt - p1; let delta = pt - p1;
let dist = delta.length(); let dist = delta.length();
@@ -56,7 +56,7 @@ impl CadCommand for DistCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let p1 = self.first?; let p1 = self.first?;
Some(WireModel { Some(WireModel {
name: "dist_preview".into(), name: "dist_preview".into(),
+5 -5
View File
@@ -6,7 +6,7 @@ use std::f64::consts::PI;
use acadrust::entities::Point as PointEnt; use acadrust::entities::Point as PointEnt;
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -43,7 +43,7 @@ impl CadCommand for DivideCommand {
self.target.is_none() self.target.is_none()
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -71,7 +71,7 @@ impl CadCommand for DivideCommand {
Some(CmdResult::DivideEntity { handle, n }) Some(CmdResult::DivideEntity { handle, n })
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -112,7 +112,7 @@ impl CadCommand for MeasureCommand {
self.target.is_none() self.target.is_none()
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -148,7 +148,7 @@ impl CadCommand for MeasureCommand {
}) })
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+2 -2
View File
@@ -1,6 +1,6 @@
// ID command — report coordinates of a picked point. // ID command — report coordinates of a picked point.
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -21,7 +21,7 @@ impl CadCommand for IdCommand {
"ID Specify point:".into() "ID Specify point:".into()
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
// Drawing plane is world XY (z = elevation). // Drawing plane is world XY (z = elevation).
let x = pt.x; let x = pt.x;
let y = pt.y; let y = pt.y;
+3 -3
View File
@@ -16,7 +16,7 @@ pub fn tool() -> ToolDef {
// ── CadCommand implementation ───────────────────────────────────────────── // ── CadCommand implementation ─────────────────────────────────────────────
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -66,7 +66,7 @@ impl CadCommand for LayMatchCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -75,7 +75,7 @@ impl CadCommand for LayMatchCommand {
fn on_escape(&mut self) -> CmdResult { fn on_escape(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+6 -6
View File
@@ -10,7 +10,7 @@
// With 2 pairs: translate + rotate (+ optional uniform scale to fit) // With 2 pairs: translate + rotate (+ optional uniform scale to fit)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::command::{CadCommand, CmdResult, EntityTransform};
@@ -74,7 +74,7 @@ impl CadCommand for AlignCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.state { match self.state {
AlignState::Gathering => CmdResult::NeedPoint, AlignState::Gathering => CmdResult::NeedPoint,
AlignState::Src1 => { AlignState::Src1 => {
@@ -117,7 +117,7 @@ impl CadCommand for AlignCommand {
let delta = d - s; let delta = d - s;
CmdResult::TransformSelected( CmdResult::TransformSelected(
self.handles.clone(), self.handles.clone(),
EntityTransform::Translate(delta), EntityTransform::Translate(delta.as_dvec3()),
) )
} }
_ => CmdResult::Cancel, _ => CmdResult::Cancel,
@@ -163,7 +163,7 @@ impl AlignCommand {
let delta = d1 - s1; let delta = d1 - s1;
return CmdResult::TransformSelected( return CmdResult::TransformSelected(
self.handles.clone(), self.handles.clone(),
EntityTransform::Translate(delta), EntityTransform::Translate(delta.as_dvec3()),
); );
} }
@@ -182,8 +182,8 @@ impl AlignCommand {
// Compose via AlignTransform CmdResult // Compose via AlignTransform CmdResult
CmdResult::AlignSelected { CmdResult::AlignSelected {
handles: self.handles.clone(), handles: self.handles.clone(),
src1: s1, src1: s1.as_dvec3(),
dst1: d1, dst1: d1.as_dvec3(),
angle_rad: angle, angle_rad: angle,
scale: scale_factor, scale: scale_factor,
} }
+4 -4
View File
@@ -7,7 +7,7 @@
// After all attributes are processed, commit via ReplaceMany. // After all attributes are processed, commit via ReplaceMany.
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -59,7 +59,7 @@ impl CadCommand for AtteditCommand {
matches!(self.step, Step::SelectInsert) matches!(self.step, Step::SelectInsert)
} }
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -114,13 +114,13 @@ impl CadCommand for AtteditCommand {
None None
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
+9 -9
View File
@@ -15,7 +15,7 @@ use acadrust::entities::{
}; };
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::{DVec3, Vec3};
use truck_modeling::base::{BoundedCurve, Cut}; use truck_modeling::base::{BoundedCurve, Cut};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -382,7 +382,7 @@ impl CadCommand for BreakInteractiveCommand {
self.target.is_none() self.target.is_none()
} }
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -391,7 +391,7 @@ impl CadCommand for BreakInteractiveCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
let handle = match self.target { let handle = match self.target {
Some(h) => h, Some(h) => h,
None => return CmdResult::Cancel, None => return CmdResult::Cancel,
@@ -403,14 +403,14 @@ impl CadCommand for BreakInteractiveCommand {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
}; };
CmdResult::BreakEntity { handle, p1, p2: pt } CmdResult::BreakEntity { handle, p1: p1.as_dvec3(), p2: pt.as_dvec3() }
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
@@ -444,7 +444,7 @@ impl CadCommand for BreakAtPointCommand {
self.target.is_none() self.target.is_none()
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -452,12 +452,12 @@ impl CadCommand for BreakAtPointCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.target { match self.target {
Some(handle) => CmdResult::BreakEntity { Some(handle) => CmdResult::BreakEntity {
handle, handle,
p1: pt, p1: pt.as_dvec3(),
p2: pt, p2: pt.as_dvec3(),
}, },
None => CmdResult::Cancel, None => CmdResult::Cancel,
} }
+9 -6
View File
@@ -6,7 +6,7 @@
// Step 2+: each click makes another copy at (click - base); Enter to finish. // Step 2+: each click makes another copy at (click - base); Enter to finish.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::command::{CadCommand, CmdResult, EntityTransform};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -27,7 +27,7 @@ pub fn tool() -> ToolDef {
enum Step { enum Step {
Base, Base,
Placing(Vec3), Placing(DVec3),
} }
pub struct CopyCommand { pub struct CopyCommand {
@@ -66,7 +66,7 @@ impl CadCommand for CopyCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.step { match &self.step {
Step::Base => { Step::Base => {
self.step = Step::Placing(pt); self.step = Step::Placing(pt);
@@ -87,7 +87,7 @@ impl CadCommand for CopyCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
let Step::Placing(base) = &self.step else { let Step::Placing(base) = &self.step else {
return vec![]; return vec![];
}; };
@@ -95,11 +95,14 @@ impl CadCommand for CopyCommand {
let mut out: Vec<WireModel> = self let mut out: Vec<WireModel> = self
.wire_models .wire_models
.iter() .iter()
.map(|w| w.translated(delta)) .map(|w| w.translated(delta.as_vec3()))
.collect(); .collect();
out.push(WireModel::solid( out.push(WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], vec![
[base.x as f32, base.y as f32, base.z as f32],
[pt.x as f32, pt.y as f32, pt.z as f32],
],
WireModel::CYAN, WireModel::CYAN,
false, false,
)); ));
+2 -2
View File
@@ -26,7 +26,7 @@ use acadrust::{CadDocument, EntityType, Handle};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use glam::Vec3; use glam::DVec3;
// ── Ribbon definition ────────────────────────────────────────────────────── // ── Ribbon definition ──────────────────────────────────────────────────────
@@ -447,7 +447,7 @@ impl CadCommand for ExplodeCommand {
"EXPLODE Select objects to explode:".into() "EXPLODE Select objects to explode:".into()
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+7 -7
View File
@@ -12,7 +12,7 @@
use acadrust::entities::{Arc as ArcEnt, Line as LineEnt, LwPolyline}; use acadrust::entities::{Arc as ArcEnt, Line as LineEnt, LwPolyline};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::DVec3;
const TAU: f64 = std::f64::consts::TAU; const TAU: f64 = std::f64::consts::TAU;
@@ -1328,7 +1328,7 @@ impl CadCommand for FilletCommand {
!matches!(self.step, FilletStep::WaitingForRadius) !matches!(self.step, FilletStep::WaitingForRadius)
} }
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -1406,7 +1406,7 @@ impl CadCommand for FilletCommand {
} }
} }
fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec<WireModel> {
if handle.is_null() { if handle.is_null() {
return vec![]; return vec![];
} }
@@ -1484,7 +1484,7 @@ impl CadCommand for FilletCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -1743,7 +1743,7 @@ impl CadCommand for ChamferCommand {
) )
} }
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -1825,7 +1825,7 @@ impl CadCommand for ChamferCommand {
} }
} }
fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec<WireModel> {
if handle.is_null() { if handle.is_null() {
return vec![]; return vec![];
} }
@@ -1915,7 +1915,7 @@ impl CadCommand for ChamferCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+2 -2
View File
@@ -11,7 +11,7 @@
use acadrust::types::{Vector2, Vector3}; use acadrust::types::{Vector2, Vector3};
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::{DVec3, Vec3}; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -52,7 +52,7 @@ impl CadCommand for JoinCommand {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
+4 -3
View File
@@ -13,7 +13,7 @@ use acadrust::entities::{
}; };
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::{DVec3, Vec3};
use truck_modeling::base::{BoundedCurve, Cut}; use truck_modeling::base::{BoundedCurve, Cut};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -53,7 +53,7 @@ impl CadCommand for LengthenCommand {
matches!(self.state, LenState::PickEntity) matches!(self.state, LenState::PickEntity)
} }
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -81,6 +81,7 @@ impl CadCommand for LengthenCommand {
LenState::PickOption { handle, pick_pt } => (*handle, *pick_pt), LenState::PickOption { handle, pick_pt } => (*handle, *pick_pt),
_ => return None, _ => return None,
}; };
let pick_pt = pick_pt.as_dvec3();
let text = text.trim().to_uppercase(); let text = text.trim().to_uppercase();
if let Some(rest) = text.strip_prefix("DE ").or_else(|| text.strip_prefix("DE")) { if let Some(rest) = text.strip_prefix("DE ").or_else(|| text.strip_prefix("DE")) {
@@ -125,7 +126,7 @@ impl CadCommand for LengthenCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+11 -8
View File
@@ -9,7 +9,7 @@
// Yes → flip the original in place (no copy kept) // Yes → flip the original in place (no copy kept)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::command::{CadCommand, CmdResult, EntityTransform};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -26,9 +26,9 @@ pub fn tool() -> ToolDef {
enum Step { enum Step {
P1, P1,
P2(Vec3), P2(DVec3),
/// Both mirror-line points fixed; waiting on the erase-source answer. /// Both mirror-line points fixed; waiting on the erase-source answer.
AskErase { p1: Vec3, p2: Vec3 }, AskErase { p1: DVec3, p2: DVec3 },
} }
pub struct MirrorCommand { pub struct MirrorCommand {
@@ -66,7 +66,7 @@ impl CadCommand for MirrorCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.step { match &self.step {
Step::P1 => { Step::P1 => {
self.step = Step::P2(pt); self.step = Step::P2(pt);
@@ -113,7 +113,7 @@ impl CadCommand for MirrorCommand {
Some(self.finish(p1, p2, erase)) Some(self.finish(p1, p2, erase))
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
// While picking the second point the ghost tracks the cursor; once it // While picking the second point the ghost tracks the cursor; once it
// is fixed (erase prompt) the ghost freezes at the chosen axis. // is fixed (erase prompt) the ghost freezes at the chosen axis.
let (p1, p2) = match &self.step { let (p1, p2) = match &self.step {
@@ -125,12 +125,15 @@ impl CadCommand for MirrorCommand {
let mut out: Vec<WireModel> = self let mut out: Vec<WireModel> = self
.wire_models .wire_models
.iter() .iter()
.map(|w| w.mirrored(p1, p2)) .map(|w| w.mirrored(p1.as_vec3(), p2.as_vec3()))
.collect(); .collect();
// Mirror-axis line (rubber-band). // Mirror-axis line (rubber-band).
out.push(WireModel::solid( out.push(WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
vec![[p1.x, p1.y, p1.z], [p2.x, p2.y, p2.z]], vec![
[p1.x as f32, p1.y as f32, p1.z as f32],
[p2.x as f32, p2.y as f32, p2.z as f32],
],
WireModel::CYAN, WireModel::CYAN,
false, false,
)); ));
@@ -141,7 +144,7 @@ impl CadCommand for MirrorCommand {
impl MirrorCommand { impl MirrorCommand {
/// Commit the mirror. `erase` true flips the originals in place; false /// Commit the mirror. `erase` true flips the originals in place; false
/// keeps them and adds a mirrored copy. Either way the command ends. /// keeps them and adds a mirrored copy. Either way the command ends.
fn finish(&self, p1: Vec3, p2: Vec3, erase: bool) -> CmdResult { fn finish(&self, p1: DVec3, p2: DVec3, erase: bool) -> CmdResult {
let xform = EntityTransform::Mirror { p1, p2 }; let xform = EntityTransform::Mirror { p1, p2 };
if erase { if erase {
CmdResult::TransformSelected(self.handles.clone(), xform) CmdResult::TransformSelected(self.handles.clone(), xform)
+11 -11
View File
@@ -18,7 +18,7 @@ use acadrust::entities::{
Spline as SplineEnt, Spline as SplineEnt,
}; };
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::draw::defaults; use crate::modules::draw::defaults;
@@ -632,7 +632,7 @@ impl CadCommand for OffsetCommand {
matches!(self.step, Step::SelectObject) matches!(self.step, Step::SelectObject)
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() || !matches!(self.step, Step::SelectObject) { if handle.is_null() || !matches!(self.step, Step::SelectObject) {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -672,10 +672,10 @@ impl CadCommand for OffsetCommand {
} }
} }
fn dyn_live_value(&self, cursor: Vec3) -> Option<f64> { fn dyn_live_value(&self, cursor: DVec3) -> Option<f64> {
match &self.step { match &self.step {
Step::PickSide { entity, locked, .. } => { Step::PickSide { entity, locked, .. } => {
Some(locked.unwrap_or_else(|| perp_distance(entity, cursor))) Some(locked.unwrap_or_else(|| perp_distance(entity, cursor.as_vec3())))
} }
_ => None, _ => None,
} }
@@ -697,7 +697,7 @@ impl CadCommand for OffsetCommand {
None None
} }
fn on_hover_entity(&mut self, handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, handle: Handle, _pt: DVec3) -> Vec<WireModel> {
if handle.is_null() { if handle.is_null() {
return vec![]; return vec![];
} }
@@ -719,33 +719,33 @@ impl CadCommand for OffsetCommand {
vec![] vec![]
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
let (locked, entity) = match &self.step { let (locked, entity) = match &self.step {
Step::PickSide { locked, entity, .. } => (*locked, entity.clone()), Step::PickSide { locked, entity, .. } => (*locked, entity.clone()),
_ => return CmdResult::NeedPoint, _ => return CmdResult::NeedPoint,
}; };
let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt)); let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt.as_vec3()));
if mag < 1e-9 { if mag < 1e-9 {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
match compute_offset(&entity, mag, pt) { match compute_offset(&entity, mag, pt.as_vec3()) {
Some(new_entity) => CmdResult::CommitAndExit(new_entity), Some(new_entity) => CmdResult::CommitAndExit(new_entity),
None => CmdResult::NeedPoint, None => CmdResult::NeedPoint,
} }
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
let (locked, entity) = match &self.step { let (locked, entity) = match &self.step {
Step::PickSide { locked, entity, .. } => (*locked, entity.clone()), Step::PickSide { locked, entity, .. } => (*locked, entity.clone()),
_ => return vec![], _ => return vec![],
}; };
let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt)); let mag = locked.unwrap_or_else(|| perp_distance(&entity, pt.as_vec3()));
if mag < 1e-9 { if mag < 1e-9 {
return vec![]; return vec![];
} }
if let Some(result) = compute_offset(&entity, mag, pt) { if let Some(result) = compute_offset(&entity, mag, pt.as_vec3()) {
let pts = entity_wire_pts(&result); let pts = entity_wire_pts(&result);
if !pts.is_empty() { if !pts.is_empty() {
return vec![WireModel::solid( return vec![WireModel::solid(
+3 -3
View File
@@ -10,7 +10,7 @@
// X / EXIT — exit // X / EXIT — exit
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -41,7 +41,7 @@ impl CadCommand for PeditCommand {
self.target.is_none() self.target.is_none()
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -90,7 +90,7 @@ impl CadCommand for PeditCommand {
None None
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+4 -4
View File
@@ -14,7 +14,7 @@
// require per-entity matrix transforms not yet in EntityTransform. // require per-entity matrix transforms not yet in EntityTransform.
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -80,7 +80,7 @@ impl CadCommand for RefEditPickCommand {
true true
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -89,7 +89,7 @@ impl CadCommand for RefEditPickCommand {
CmdResult::Relaunch(format!("REFEDIT_BEGIN:{}", handle.value()), vec![handle]) CmdResult::Relaunch(format!("REFEDIT_BEGIN:{}", handle.value()), vec![handle])
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -134,7 +134,7 @@ impl CadCommand for RefCloseCommand {
// Default: SAVE // Default: SAVE
CmdResult::Relaunch("REFCLOSE_SAVE".into(), vec![]) CmdResult::Relaunch("REFCLOSE_SAVE".into(), vec![])
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
} }
+17 -14
View File
@@ -7,7 +7,7 @@
// Step 3: pick destination point → rotates by (dest_angle - ref_angle) // Step 3: pick destination point → rotates by (dest_angle - ref_angle)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult, DynField, EntityTransform}; use crate::command::{CadCommand, CmdResult, DynField, EntityTransform};
use crate::modules::draw::defaults; use crate::modules::draw::defaults;
@@ -29,8 +29,8 @@ pub fn tool() -> ToolDef {
enum Step { enum Step {
Center, Center,
RefPoint { center: Vec3 }, RefPoint { center: DVec3 },
Angle { center: Vec3, ref_angle: f32 }, Angle { center: DVec3, ref_angle: f64 },
} }
pub struct RotateCommand { pub struct RotateCommand {
@@ -73,7 +73,7 @@ impl CadCommand for RotateCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.step { match &self.step {
Step::Center => { Step::Center => {
self.step = Step::RefPoint { center: pt }; self.step = Step::RefPoint { center: pt };
@@ -90,13 +90,13 @@ impl CadCommand for RotateCommand {
let ref_angle = *ref_angle; let ref_angle = *ref_angle;
let dest_angle = (pt.y - center.y).atan2(pt.x - center.x); let dest_angle = (pt.y - center.y).atan2(pt.x - center.x);
let delta = dest_angle - ref_angle; let delta = dest_angle - ref_angle;
defaults::set_rotate_angle(delta.to_degrees()); defaults::set_rotate_angle(delta.to_degrees() as f32);
self.default_angle = delta.to_degrees(); self.default_angle = delta.to_degrees() as f32;
CmdResult::TransformSelected( CmdResult::TransformSelected(
self.handles.clone(), self.handles.clone(),
EntityTransform::Rotate { EntityTransform::Rotate {
center, center,
angle_rad: delta, angle_rad: delta as f32,
}, },
) )
} }
@@ -137,14 +137,17 @@ impl CadCommand for RotateCommand {
None None
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
let (center, ref_angle) = match &self.step { let (center, ref_angle) = match &self.step {
Step::Angle { center, ref_angle } => (*center, *ref_angle), Step::Angle { center, ref_angle } => (*center, *ref_angle),
Step::RefPoint { center } => { Step::RefPoint { center } => {
// Show a reference line from center to cursor only. // Show a reference line from center to cursor only.
return vec![WireModel::solid( return vec![WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
vec![[center.x, center.y, center.z], [pt.x, pt.y, pt.z]], vec![
[center.x as f32, center.y as f32, center.z as f32],
[pt.x as f32, pt.y as f32, pt.z as f32],
],
WireModel::CYAN, WireModel::CYAN,
false, false,
)]; )];
@@ -157,12 +160,12 @@ impl CadCommand for RotateCommand {
// committing with Enter rotates the way the cursor is dragging — the // committing with Enter rotates the way the cursor is dragging — the
// dynamic-input box shows the unsigned magnitude, but the committed // dynamic-input box shows the unsigned magnitude, but the committed
// value must keep its direction (clockwise = negative). // value must keep its direction (clockwise = negative).
self.default_angle = angle_rad.to_degrees(); self.default_angle = angle_rad.to_degrees() as f32;
// Object ghosts rotated to the new angle. The rotation sweep arc is // Object ghosts rotated to the new angle. The rotation sweep arc is
// drawn by the dynamic-input overlay (polar guide), not here. // drawn by the dynamic-input overlay (polar guide), not here.
self.wire_models self.wire_models
.iter() .iter()
.map(|w| w.rotated(center, angle_rad)) .map(|w| w.rotated(center.as_vec3(), angle_rad as f32))
.collect() .collect()
} }
@@ -179,7 +182,7 @@ impl CadCommand for RotateCommand {
// direction. The polar guide arc is anchored at the centre and starts // direction. The polar guide arc is anchored at the centre and starts
// at the reference (via ref_point), with the value box centred on it. // at the reference (via ref_point), with the value box centred on it.
if let Step::Angle { center, ref_angle } = self.step { if let Step::Angle { center, ref_angle } = self.step {
let ref_dir = Vec3::new(center.x + ref_angle.cos(), center.y + ref_angle.sin(), center.z); let ref_dir = DVec3::new(center.x + ref_angle.cos(), center.y + ref_angle.sin(), center.z);
Some(DynSpec { Some(DynSpec {
anchor: DynAnchor::Point(center), anchor: DynAnchor::Point(center),
fields: vec![DynFieldSpec::new(DynRole::Angle)], fields: vec![DynFieldSpec::new(DynRole::Angle)],
@@ -195,12 +198,12 @@ impl CadCommand for RotateCommand {
matches!(self.step, Step::Angle { .. }) matches!(self.step, Step::Angle { .. })
} }
fn dyn_live_value(&self, cursor: Vec3) -> Option<f64> { fn dyn_live_value(&self, cursor: DVec3) -> Option<f64> {
// The rotation amount = cursor direction from the centre minus the // The rotation amount = cursor direction from the centre minus the
// reference angle, so the box reads the actual rotation. // reference angle, so the box reads the actual rotation.
if let Step::Angle { center, ref_angle } = &self.step { if let Step::Angle { center, ref_angle } = &self.step {
let dest = (cursor.y - center.y).atan2(cursor.x - center.x); let dest = (cursor.y - center.y).atan2(cursor.x - center.x);
Some(crate::command::dyn_display_angle_deg(dest - ref_angle) as f64) Some(crate::command::dyn_display_angle_deg((dest - ref_angle) as f32) as f64)
} else { } else {
None None
} }
+22 -16
View File
@@ -13,7 +13,7 @@
// Step 2b: specify new length (pick a point or type a length) // Step 2b: specify new length (pick a point or type a length)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::command::{CadCommand, CmdResult, EntityTransform};
use crate::modules::draw::defaults; use crate::modules::draw::defaults;
@@ -33,11 +33,11 @@ pub fn tool() -> ToolDef {
enum Step { enum Step {
Base, Base,
/// Default flow: factor is the cursor distance from `base`. /// Default flow: factor is the cursor distance from `base`.
Factor { base: Vec3 }, Factor { base: DVec3 },
/// Reference flow: defining the reference length from `base`. /// Reference flow: defining the reference length from `base`.
RefLen { base: Vec3 }, RefLen { base: DVec3 },
/// Reference flow: factor is `cursor_dist / ref_dist` from `base`. /// Reference flow: factor is `cursor_dist / ref_dist` from `base`.
RefNew { base: Vec3, ref_dist: f32 }, RefNew { base: DVec3, ref_dist: f32 },
} }
pub struct ScaleCommand { pub struct ScaleCommand {
@@ -58,7 +58,7 @@ impl ScaleCommand {
} }
/// Commit a uniform scale about `base` and end the command. /// Commit a uniform scale about `base` and end the command.
fn commit(&self, base: Vec3, factor: f32) -> CmdResult { fn commit(&self, base: DVec3, factor: f32) -> CmdResult {
defaults::set_scale_factor(factor); defaults::set_scale_factor(factor);
CmdResult::TransformSelected( CmdResult::TransformSelected(
self.handles.clone(), self.handles.clone(),
@@ -95,7 +95,7 @@ impl CadCommand for ScaleCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.step { match &self.step {
Step::Base => { Step::Base => {
self.step = Step::Factor { base: pt }; self.step = Step::Factor { base: pt };
@@ -103,18 +103,18 @@ impl CadCommand for ScaleCommand {
} }
Step::Factor { base } => { Step::Factor { base } => {
let base = *base; let base = *base;
let factor = base.distance(pt).max(1e-6); let factor = base.distance(pt).max(1e-6) as f32;
self.commit(base, factor) self.commit(base, factor)
} }
Step::RefLen { base } => { Step::RefLen { base } => {
let base = *base; let base = *base;
let ref_dist = base.distance(pt).max(1e-6); let ref_dist = base.distance(pt).max(1e-6) as f32;
self.step = Step::RefNew { base, ref_dist }; self.step = Step::RefNew { base, ref_dist };
CmdResult::NeedPoint CmdResult::NeedPoint
} }
Step::RefNew { base, ref_dist } => { Step::RefNew { base, ref_dist } => {
let base = *base; let base = *base;
let new_dist = base.distance(pt).max(1e-6); let new_dist = base.distance(pt).max(1e-6) as f32;
self.commit(base, new_dist / *ref_dist) self.commit(base, new_dist / *ref_dist)
} }
} }
@@ -164,19 +164,22 @@ impl CadCommand for ScaleCommand {
} }
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
let (base, factor) = match &self.step { let (base, factor): (DVec3, f32) = match &self.step {
// Default flow: scale live by cursor distance from the base. // Default flow: scale live by cursor distance from the base.
Step::Factor { base } => (*base, base.distance(pt).max(1e-6)), Step::Factor { base } => (*base, base.distance(pt).max(1e-6) as f32),
// Reference flow, new-length step: factor = cursor_dist / ref_dist. // Reference flow, new-length step: factor = cursor_dist / ref_dist.
Step::RefNew { base, ref_dist } => { Step::RefNew { base, ref_dist } => {
(*base, base.distance(pt).max(1e-6) / ref_dist) (*base, base.distance(pt).max(1e-6) as f32 / ref_dist)
} }
// Reference-length step: rubber-band only, no factor defined yet. // Reference-length step: rubber-band only, no factor defined yet.
Step::RefLen { base } => { Step::RefLen { base } => {
return vec![WireModel::solid( return vec![WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], vec![
[base.x as f32, base.y as f32, base.z as f32],
[pt.x as f32, pt.y as f32, pt.z as f32],
],
WireModel::CYAN, WireModel::CYAN,
false, false,
)]; )];
@@ -186,11 +189,14 @@ impl CadCommand for ScaleCommand {
let mut out: Vec<WireModel> = self let mut out: Vec<WireModel> = self
.wire_models .wire_models
.iter() .iter()
.map(|w| w.scaled(base, factor)) .map(|w| w.scaled(base.as_vec3(), factor))
.collect(); .collect();
out.push(WireModel::solid( out.push(WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], vec![
[base.x as f32, base.y as f32, base.z as f32],
[pt.x as f32, pt.y as f32, pt.z as f32],
],
WireModel::CYAN, WireModel::CYAN,
false, false,
)); ));
+4 -4
View File
@@ -10,7 +10,7 @@
// Control-point dragging is already supported via the grip editing system. // Control-point dragging is already supported via the grip editing system.
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -61,7 +61,7 @@ impl CadCommand for SplineditCommand {
matches!(self.step, Step::SelectSpline) matches!(self.step, Step::SelectSpline)
} }
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -96,13 +96,13 @@ impl CadCommand for SplineditCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+6 -6
View File
@@ -16,7 +16,7 @@
// All others : move the whole entity if any point is inside. // All others : move the whole entity if any point is inside.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -86,7 +86,7 @@ impl CadCommand for StretchCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &self.step { match &self.step {
Step::WindowCorner1 => { Step::WindowCorner1 => {
self.step = Step::WindowCorner2(pt); self.step = Step::WindowCorner2(pt);
@@ -115,9 +115,9 @@ impl CadCommand for StretchCommand {
let delta = pt - *base; let delta = pt - *base;
CmdResult::StretchEntities { CmdResult::StretchEntities {
handles: self.handles.clone(), handles: self.handles.clone(),
win_min: *win_min, win_min: win_min.as_dvec3(),
win_max: *win_max, win_max: win_max.as_dvec3(),
delta, delta: delta.as_dvec3(),
} }
} }
} }
@@ -130,7 +130,7 @@ impl CadCommand for StretchCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> { let pt = pt.as_vec3();
match &self.step { match &self.step {
Step::WindowCorner2(c1) => { Step::WindowCorner2(c1) => {
// Show crossing-window rectangle preview (dashed green) // Show crossing-window rectangle preview (dashed green)
+3 -3
View File
@@ -6,7 +6,7 @@
// Step 2: If first point picked, pick second point to define angle vector. // Step 2: If first point picked, pick second point to define angle vector.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult, DynField}; use crate::command::{CadCommand, CmdResult, DynField};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -122,7 +122,7 @@ impl CadCommand for TorientCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
Step::AngleOrFirstPoint => { Step::AngleOrFirstPoint => {
self.step = Step::SecondPoint { first_point: pt }; self.step = Step::SecondPoint { first_point: pt };
@@ -157,7 +157,7 @@ impl CadCommand for TorientCommand {
} }
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> { let pt = pt.as_vec3();
if let Step::SecondPoint { first_point } = self.step { if let Step::SecondPoint { first_point } = self.step {
vec![WireModel::solid( vec![WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
+9 -6
View File
@@ -6,7 +6,7 @@
// Step 2: pick destination → translates all selected entities by (dest - base) // Step 2: pick destination → translates all selected entities by (dest - base)
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult, EntityTransform}; use crate::command::{CadCommand, CmdResult, EntityTransform};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -27,7 +27,7 @@ pub fn tool() -> ToolDef {
enum Step { enum Step {
Base, Base,
Target(Vec3), Target(DVec3),
} }
pub struct MoveCommand { pub struct MoveCommand {
@@ -64,7 +64,7 @@ impl CadCommand for MoveCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.step { match &self.step {
Step::Base => { Step::Base => {
self.step = Step::Target(pt); self.step = Step::Target(pt);
@@ -87,7 +87,7 @@ impl CadCommand for MoveCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
let Step::Target(base) = &self.step else { let Step::Target(base) = &self.step else {
return vec![]; return vec![];
}; };
@@ -96,11 +96,14 @@ impl CadCommand for MoveCommand {
let mut out: Vec<WireModel> = self let mut out: Vec<WireModel> = self
.wire_models .wire_models
.iter() .iter()
.map(|w| w.translated(delta)) .map(|w| w.translated(delta.as_vec3()))
.collect(); .collect();
out.push(WireModel::solid( out.push(WireModel::solid(
"rubber_band".into(), "rubber_band".into(),
vec![[base.x, base.y, base.z], [pt.x, pt.y, pt.z]], vec![
[base.x as f32, base.y as f32, base.z as f32],
[pt.x as f32, pt.y as f32, pt.z as f32],
],
WireModel::CYAN, WireModel::CYAN,
false, false,
)); ));
+7 -7
View File
@@ -16,7 +16,7 @@ use acadrust::entities::{
}; };
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};
use glam::Vec3; use glam::DVec3;
use truck_modeling::base::{BoundedCurve, Cut, ParametricCurve}; use truck_modeling::base::{BoundedCurve, Cut, ParametricCurve};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -1990,7 +1990,7 @@ impl CadCommand for TrimCommand {
true true
} }
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -2169,7 +2169,7 @@ impl CadCommand for TrimCommand {
self.geos = build_geos(&self.all_entities); self.geos = build_geos(&self.all_entities);
} }
fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec<WireModel> {
if handle.is_null() { if handle.is_null() {
return vec![]; return vec![];
} }
@@ -2407,7 +2407,7 @@ impl CadCommand for TrimCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -2458,7 +2458,7 @@ impl CadCommand for ExtendCommand {
true true
} }
fn on_entity_pick(&mut self, handle: Handle, pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -2555,7 +2555,7 @@ impl CadCommand for ExtendCommand {
} }
} }
fn on_hover_entity(&mut self, handle: Handle, pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, handle: Handle, pt: DVec3) -> Vec<WireModel> {
if handle.is_null() { if handle.is_null() {
return vec![]; return vec![];
} }
@@ -2643,7 +2643,7 @@ impl CadCommand for ExtendCommand {
vec![] vec![]
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
+4 -4
View File
@@ -14,7 +14,7 @@ pub fn tool() -> ToolDef {
// ── CadCommand implementation ───────────────────────────────────────────── // ── CadCommand implementation ─────────────────────────────────────────────
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -53,7 +53,7 @@ impl CadCommand for MatchPropCommand {
!self.phase1_done() !self.phase1_done()
} }
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; // nothing hit, keep waiting return CmdResult::NeedPoint; // nothing hit, keep waiting
} }
@@ -81,11 +81,11 @@ impl CadCommand for MatchPropCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+3 -3
View File
@@ -6,7 +6,7 @@
// immediately — no Enter required. // immediately — no Enter required.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -47,7 +47,7 @@ impl CadCommand for SelectObjectsCommand {
// These are never called while is_selection_gathering is true, but the // These are never called while is_selection_gathering is true, but the
// trait requires implementations. // trait requires implementations.
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -56,7 +56,7 @@ impl CadCommand for SelectObjectsCommand {
fn on_escape(&mut self) -> CmdResult { fn on_escape(&mut self) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> { fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+3 -3
View File
@@ -1,5 +1,5 @@
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -52,7 +52,7 @@ impl CadCommand for CreateBlockCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
match &self.step { match &self.step {
Step::Name => CmdResult::NeedPoint, Step::Name => CmdResult::NeedPoint,
Step::Base { name } => CmdResult::CreateBlock { Step::Base { name } => CmdResult::CreateBlock {
@@ -85,7 +85,7 @@ impl CadCommand for CreateBlockCommand {
Some(CmdResult::NeedPoint) Some(CmdResult::NeedPoint)
} }
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
} }
+3 -3
View File
@@ -1,7 +1,7 @@
use acadrust::entities::{AttributeEntity, Insert}; use acadrust::entities::{AttributeEntity, Insert};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -103,7 +103,7 @@ impl CadCommand for InsertBlockCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match &self.step { match &self.step {
Step::Name => CmdResult::NeedPoint, Step::Name => CmdResult::NeedPoint,
Step::Point { name } => { Step::Point { name } => {
@@ -156,7 +156,7 @@ impl CadCommand for InsertBlockCommand {
} }
} }
fn on_preview_wires(&mut self, pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> { let pt = pt.as_vec3();
match (&self.step, &self.preview) { match (&self.step, &self.preview) {
(Step::Point { .. }, Some((wires, base))) => { (Step::Point { .. }, Some((wires, base))) => {
let delta = pt - *base; let delta = pt - *base;
+11 -11
View File
@@ -7,7 +7,7 @@
// live in the Model tab (`modules::model::primitive_cmd`). // live in the Model tab (`modules::model::primitive_cmd`).
use acadrust::{entities::Solid3D, EntityType}; use acadrust::{entities::Solid3D, EntityType};
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -53,7 +53,7 @@ impl CadCommand for ExtrudeCommand {
fn needs_entity_pick(&self) -> bool { fn needs_entity_pick(&self) -> bool {
self.step == ExtrudeStep::Pick self.step == ExtrudeStep::Pick
} }
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -61,7 +61,7 @@ impl CadCommand for ExtrudeCommand {
self.step = ExtrudeStep::Height; self.step = ExtrudeStep::Height;
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if self.step == ExtrudeStep::Height { if self.step == ExtrudeStep::Height {
return CmdResult::ExtrudeEntity { return CmdResult::ExtrudeEntity {
handle: self.target_handle, handle: self.target_handle,
@@ -135,7 +135,7 @@ impl CadCommand for RevolveCommand {
fn needs_entity_pick(&self) -> bool { fn needs_entity_pick(&self) -> bool {
self.step == RevolveStep::Pick self.step == RevolveStep::Pick
} }
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -143,7 +143,7 @@ impl CadCommand for RevolveCommand {
self.step = RevolveStep::AxisStart; self.step = RevolveStep::AxisStart;
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.step { match self.step {
RevolveStep::AxisStart => { RevolveStep::AxisStart => {
self.axis_start = pt; self.axis_start = pt;
@@ -186,8 +186,8 @@ impl RevolveCommand {
fn make_revolve(&self, angle_deg: f32) -> CmdResult { fn make_revolve(&self, angle_deg: f32) -> CmdResult {
CmdResult::RevolveEntity { CmdResult::RevolveEntity {
handle: self.target_handle, handle: self.target_handle,
axis_start: self.axis_start, axis_start: self.axis_start.as_dvec3(),
axis_end: self.axis_end, axis_end: self.axis_end.as_dvec3(),
angle_deg, angle_deg,
color: self.color, color: self.color,
} }
@@ -231,7 +231,7 @@ impl CadCommand for SweepCommand {
fn needs_entity_pick(&self) -> bool { fn needs_entity_pick(&self) -> bool {
true true
} }
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -248,7 +248,7 @@ impl CadCommand for SweepCommand {
}, },
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_enter(&mut self) -> CmdResult { fn on_enter(&mut self) -> CmdResult {
@@ -289,7 +289,7 @@ impl CadCommand for LoftCommand {
fn needs_entity_pick(&self) -> bool { fn needs_entity_pick(&self) -> bool {
true true
} }
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: Vec3) -> CmdResult { fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() { if handle.is_null() {
return CmdResult::NeedPoint; return CmdResult::NeedPoint;
} }
@@ -299,7 +299,7 @@ impl CadCommand for LoftCommand {
} }
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::NeedPoint CmdResult::NeedPoint
} }
fn wants_text_input(&self) -> bool { fn wants_text_input(&self) -> bool {
+3 -3
View File
@@ -12,7 +12,7 @@ use acadrust::entities::{Block, BlockEnd, Insert};
use acadrust::tables::block_record::{BlockFlags, BlockRecord}; use acadrust::tables::block_record::{BlockFlags, BlockRecord};
use acadrust::types::Vector3; use acadrust::types::Vector3;
use acadrust::EntityType; use acadrust::EntityType;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -50,7 +50,7 @@ impl CadCommand for XAttachCommand {
format!("XATTACH Specify insertion point for \"{}\":", self.block_name) format!("XATTACH Specify insertion point for \"{}\":", self.block_name)
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult {
// We return the INSERT entity; the command handler in commands.rs // We return the INSERT entity; the command handler in commands.rs
// calls `prepare_xref_block` on the scene before committing. // calls `prepare_xref_block` on the scene before committing.
CmdResult::CommitAndExit(EntityType::Insert(Insert::new( CmdResult::CommitAndExit(EntityType::Insert(Insert::new(
@@ -63,7 +63,7 @@ impl CadCommand for XAttachCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_preview_wires(&mut self, _pt: Vec3) -> Vec<WireModel> { fn on_preview_wires(&mut self, _pt: DVec3) -> Vec<WireModel> {
vec![] vec![]
} }
+3 -3
View File
@@ -11,7 +11,7 @@ use acadrust::EntityType;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef}; use crate::modules::{IconKind, ModuleEvent, ToolDef};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
// ── Ribbon definition ───────────────────────────────────────────────────── // ── Ribbon definition ─────────────────────────────────────────────────────
@@ -49,7 +49,7 @@ impl CadCommand for MviewCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Some(c1) = self.corner1 { if let Some(c1) = self.corner1 {
let w = (pt.x - c1.x).abs() as f64; let w = (pt.x - c1.x).abs() as f64;
let h = (pt.y - c1.y).abs() as f64; let h = (pt.y - c1.y).abs() as f64;
@@ -77,7 +77,7 @@ impl CadCommand for MviewCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let c1 = self.corner1?; let c1 = self.corner1?;
Some(WireModel { Some(WireModel {
name: "mview_preview".to_string(), name: "mview_preview".to_string(),
+3 -3
View File
@@ -11,7 +11,7 @@
// Layer names are case-insensitive. Multiple space-separated names are accepted. // Layer names are case-insensitive. Multiple space-separated names are accepted.
use acadrust::Handle; use acadrust::Handle;
use glam::Vec3; use glam::DVec3;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -94,7 +94,7 @@ impl CadCommand for VplayerCommand {
} }
} }
fn on_point(&mut self, _pt: Vec3) -> CmdResult { fn on_point(&mut self, _pt: DVec3) -> CmdResult {
CmdResult::Cancel CmdResult::Cancel
} }
@@ -102,7 +102,7 @@ impl CadCommand for VplayerCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, _pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, _pt: DVec3) -> Option<WireModel> {
None None
} }
} }
+3 -3
View File
@@ -9,7 +9,7 @@
use acadrust::entities::Solid3D; use acadrust::entities::Solid3D;
use acadrust::{primitives, EntityType}; use acadrust::{primitives, EntityType};
use glam::Vec3; use glam::{DVec3, Vec3};
use truck_modeling::Solid; use truck_modeling::Solid;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
@@ -209,7 +209,7 @@ impl CadCommand for PrimitiveCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if self.height_step { if self.height_step {
// A click in the ground plane has no Z; use its distance from the // A click in the ground plane has no Z; use its distance from the
// footprint centre as the height magnitude. // footprint centre as the height magnitude.
@@ -253,7 +253,7 @@ impl CadCommand for PrimitiveCommand {
Some(self.commit(h)) Some(self.commit(h))
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
if self.height_step || self.pts.is_empty() { if self.height_step || self.pts.is_empty() {
return None; return None;
} }
+4 -4
View File
@@ -5,7 +5,7 @@
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
use glam::Vec3; use glam::{DVec3, Vec3};
pub struct PlotWindowCommand { pub struct PlotWindowCommand {
p1: Option<Vec3>, p1: Option<Vec3>,
@@ -30,13 +30,13 @@ impl CadCommand for PlotWindowCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
match self.p1 { match self.p1 {
None => { None => {
self.p1 = Some(pt); self.p1 = Some(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
} }
Some(p1) => CmdResult::SetPlotWindow { p1, p2: pt }, Some(p1) => CmdResult::SetPlotWindow { p1: p1.as_dvec3(), p2: pt.as_dvec3() },
} }
} }
@@ -44,7 +44,7 @@ impl CadCommand for PlotWindowCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let p1 = self.p1?; let p1 = self.p1?;
// Draw the selection rectangle. // Draw the selection rectangle.
Some(WireModel { Some(WireModel {
+4 -4
View File
@@ -1,6 +1,6 @@
// ZOOM WINDOW command — pick two corners to define the zoom area. // ZOOM WINDOW command — pick two corners to define the zoom area.
use glam::Vec3; use glam::{DVec3, Vec3};
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
@@ -28,9 +28,9 @@ impl CadCommand for ZoomWindowCommand {
} }
} }
fn on_point(&mut self, pt: Vec3) -> CmdResult { fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
if let Some(p1) = self.first { if let Some(p1) = self.first {
CmdResult::ZoomToWindow { p1, p2: pt } CmdResult::ZoomToWindow { p1: p1.as_dvec3(), p2: pt.as_dvec3() }
} else { } else {
self.first = Some(pt); self.first = Some(pt);
CmdResult::NeedPoint CmdResult::NeedPoint
@@ -45,7 +45,7 @@ impl CadCommand for ZoomWindowCommand {
CmdResult::Cancel CmdResult::Cancel
} }
fn on_mouse_move(&mut self, pt: Vec3) -> Option<WireModel> { fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
let p1 = self.first?; let p1 = self.first?;
let min = p1.min(pt); let min = p1.min(pt);
let max = p1.max(pt); let max = p1.max(pt);
+2 -2
View File
@@ -4175,7 +4175,7 @@ impl Scene {
.add_entity(EntityType::BlockEnd(block_end)) .add_entity(EntityType::BlockEnd(block_end))
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
let local = EntityTransform::Translate(-base); let local = EntityTransform::Translate((-base).as_dvec3());
for (old_handle, mut entity) in source_entities { for (old_handle, mut entity) in source_entities {
view::dispatch::apply_transform(&mut entity, &local); view::dispatch::apply_transform(&mut entity, &local);
entity = crate::modules::draw::modify::explode::normalize_entity_for_block(entity); entity = crate::modules::draw::modify::explode::normalize_entity_for_block(entity);
@@ -4248,7 +4248,7 @@ impl Scene {
.add_entity(EntityType::BlockEnd(block_end)) .add_entity(EntityType::BlockEnd(block_end))
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
let local = EntityTransform::Translate(-base); let local = EntityTransform::Translate((-base).as_dvec3());
for mut entity in entities { for mut entity in entities {
view::dispatch::apply_transform(&mut entity, &local); view::dispatch::apply_transform(&mut entity, &local);
entity = crate::modules::draw::modify::explode::normalize_entity_for_block(entity); entity = crate::modules::draw::modify::explode::normalize_entity_for_block(entity);
+1 -1
View File
@@ -1,7 +1,7 @@
// Shared value types used by the dispatch and grip systems. // Shared value types used by the dispatch and grip systems.
use acadrust::types::{Color as AcadColor, LineWeight}; use acadrust::types::{Color as AcadColor, LineWeight};
use glam::{DVec3, Vec3}; use glam::DVec3;
/// The kind of value held by a property row. /// The kind of value held by a property row.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
+1 -1
View File
@@ -1,7 +1,7 @@
//! OpenCADStudio-style grip editing. //! OpenCADStudio-style grip editing.
use acadrust::Handle; use acadrust::Handle;
use glam::{DVec3, Vec3}; use glam::DVec3;
use iced::{Point, Rectangle}; use iced::{Point, Rectangle};
use crate::scene::model::object::{GripDef, GripShape}; use crate::scene::model::object::{GripDef, GripShape};