From c56ade3f2e523fb3eb576675d78590b9f3748552 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Fri, 11 Sep 2026 09:33:06 +0300 Subject: [PATCH] Expose Draw Order in the Modify extension --- assets/icons/modify_draworder.svg | 1 + src/app/commands/mod.rs | 4 +++ src/app/commands/view.rs | 31 ++++++++++++++++++++++ src/ui/ribbon/modify_tools/13_draworder.rs | 6 +++++ 4 files changed, 42 insertions(+) create mode 100644 assets/icons/modify_draworder.svg create mode 100644 src/ui/ribbon/modify_tools/13_draworder.rs diff --git a/assets/icons/modify_draworder.svg b/assets/icons/modify_draworder.svg new file mode 100644 index 000000000..a5ae19f04 --- /dev/null +++ b/assets/icons/modify_draworder.svg @@ -0,0 +1 @@ + diff --git a/src/app/commands/mod.rs b/src/app/commands/mod.rs index e3650b5d1..b7ac14663 100644 --- a/src/app/commands/mod.rs +++ b/src/app/commands/mod.rs @@ -598,6 +598,10 @@ inventory::submit!(crate::command::CommandRegistration { "DIMSTYLE", "DONATE", "DRAWORDER", + "DRAWORDER_FRONT", + "DRAWORDER_BACK", + "DRAWORDER_ABOVE", + "DRAWORDER_UNDER", "DWGPROP", "DWGPROPS", "EATTEXT", diff --git a/src/app/commands/view.rs b/src/app/commands/view.rs index 2ac432f68..33a936d2a 100644 --- a/src/app/commands/view.rs +++ b/src/app/commands/view.rs @@ -941,6 +941,37 @@ impl OpenCADStudio { return Some(Task::none()); } + "DRAWORDER_FRONT" | "DRAWORDER_BACK" | "DRAWORDER_ABOVE" | "DRAWORDER_UNDER" => { + let selected: Vec = self.tabs[i] + .scene + .selected_entities() + .iter() + .map(|(h, _)| *h) + .collect(); + if selected.is_empty() { + use crate::modules::draw::select::SelectObjectsCommand; + let selection = SelectObjectsCommand::plain("DRAWORDER", cmd); + self.command_line.push_info(&selection.prompt()); + self.tabs[i].active_cmd = Some(Box::new(selection)); + } else if matches!(cmd, "DRAWORDER_ABOVE" | "DRAWORDER_UNDER") { + let command = DrawOrderCommand::for_reference_pick( + selected, + cmd == "DRAWORDER_ABOVE", + ); + self.command_line.push_info(&command.prompt()); + self.tabs[i].active_cmd = Some(Box::new(command)); + } else { + let primitive = if cmd == "DRAWORDER_FRONT" { + "DRAWORDER FRONT" + } else { + "DRAWORDER BACK" + }; + return Some(self.apply_cmd_result(crate::command::CmdResult::Relaunch( + primitive.to_string(), + selected, + ))); + } + } "DRAWORDER" => { let selected: Vec = self.tabs[i] .scene diff --git a/src/ui/ribbon/modify_tools/13_draworder.rs b/src/ui/ribbon/modify_tools/13_draworder.rs new file mode 100644 index 000000000..ecd78fbdf --- /dev/null +++ b/src/ui/ribbon/modify_tools/13_draworder.rs @@ -0,0 +1,6 @@ +Tool { + command: "DRAWORDER_FRONT", + label: "Draw Order", + icon: include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/icons/modify_draworder.svg")), + options: &[("DRAWORDER_FRONT", "Bring to Front"), ("DRAWORDER_BACK", "Send to Back"), ("DRAWORDER_ABOVE", "Bring Above Objects"), ("DRAWORDER_UNDER", "Send Under Objects")], +}