forked from 1b-agent/opencadstudio-upstream
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>
75 lines
2.0 KiB
Rust
75 lines
2.0 KiB
Rust
// Group tool — ribbon definition + CadCommand implementation.
|
|
|
|
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
|
|
|
pub fn tool() -> ToolDef {
|
|
ToolDef {
|
|
id: "GROUP",
|
|
label: "Group",
|
|
icon: IconKind::Svg(include_bytes!("../../../../assets/icons/group.svg")),
|
|
event: ModuleEvent::Command("GROUP".to_string()),
|
|
}
|
|
}
|
|
|
|
// ── CadCommand implementation ─────────────────────────────────────────────
|
|
|
|
use acadrust::Handle;
|
|
use glam::DVec3;
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
use crate::scene::model::wire_model::WireModel;
|
|
|
|
pub struct GroupCommand {
|
|
handles: Vec<Handle>,
|
|
/// Auto-generated fallback name shown in the prompt.
|
|
auto_name: String,
|
|
}
|
|
|
|
impl GroupCommand {
|
|
pub fn new(handles: Vec<Handle>, auto_name: String) -> Self {
|
|
Self { handles, auto_name }
|
|
}
|
|
}
|
|
|
|
impl CadCommand for GroupCommand {
|
|
fn name(&self) -> &'static str {
|
|
"GROUP"
|
|
}
|
|
|
|
fn prompt(&self) -> String {
|
|
format!("GROUP Enter group name [{}]:", self.auto_name)
|
|
}
|
|
|
|
fn wants_text_input(&self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
|
let name = if text.trim().is_empty() {
|
|
std::mem::take(&mut self.auto_name)
|
|
} else {
|
|
text.trim().to_string()
|
|
};
|
|
Some(CmdResult::CreateGroup {
|
|
handles: std::mem::take(&mut self.handles),
|
|
name,
|
|
})
|
|
}
|
|
|
|
fn on_enter(&mut self) -> CmdResult {
|
|
// Enter with no typed name uses the auto-generated name.
|
|
CmdResult::CreateGroup {
|
|
handles: std::mem::take(&mut self.handles),
|
|
name: std::mem::take(&mut self.auto_name),
|
|
}
|
|
}
|
|
|
|
fn on_point(&mut self, _pt: DVec3) -> CmdResult {
|
|
CmdResult::NeedPoint
|
|
}
|
|
|
|
fn on_hover_entity(&mut self, _handle: Handle, _pt: DVec3) -> Vec<WireModel> {
|
|
vec![]
|
|
}
|
|
}
|