Co-locate CadCommand impls with their ribbon toolbar modules
Each command implementation is now in the same file as its ribbon tool definition. Groups moved to a dedicated groups/ toolbar folder. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
bdde862597
commit
468633c1fe
18 changed files with 264 additions and 275 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// Match Layer tool — ribbon definition + CadCommand implementation.
|
||||
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
|
|
@ -8,3 +10,70 @@ pub fn tool() -> ToolDef {
|
|||
event: ModuleEvent::Command("LAYMATCH".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
// ── CadCommand implementation ─────────────────────────────────────────────
|
||||
|
||||
use acadrust::Handle;
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::scene::wire_model::WireModel;
|
||||
|
||||
pub struct LayMatchCommand {
|
||||
dest_handles: Vec<Handle>,
|
||||
}
|
||||
|
||||
impl LayMatchCommand {
|
||||
pub fn new(dest: Vec<Handle>) -> Self {
|
||||
Self { dest_handles: dest }
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for LayMatchCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"LAYMATCH"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
if self.dest_handles.is_empty() {
|
||||
"LAYMATCH Select objects to change layer:".into()
|
||||
} else {
|
||||
"LAYMATCH Select source object to match layer from:".into()
|
||||
}
|
||||
}
|
||||
|
||||
fn is_selection_gathering(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn on_selection_complete(&mut self, handles: Vec<Handle>) -> CmdResult {
|
||||
if handles.is_empty() {
|
||||
return CmdResult::NeedPoint;
|
||||
}
|
||||
if self.dest_handles.is_empty() {
|
||||
// Phase 1 complete — store destinations, move to phase 2.
|
||||
self.dest_handles = handles;
|
||||
CmdResult::NeedPoint
|
||||
} else {
|
||||
// Phase 2 complete — first handle is the source object.
|
||||
let src = handles[0];
|
||||
CmdResult::MatchEntityLayer {
|
||||
dest: std::mem::take(&mut self.dest_handles),
|
||||
src,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
fn on_escape(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
fn on_hover_entity(&mut self, _handle: Handle, _pt: Vec3) -> Vec<WireModel> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue