From a431e02378e2607f054987ed2331804266586118 Mon Sep 17 00:00:00 2001 From: Karim Jerbi Date: Tue, 16 Jun 2026 09:53:32 +0100 Subject: [PATCH] Temporarily suppress Ortho mode during RECTANG commands --- src/app/cmd_result.rs | 7 ++++++- src/app/commands.rs | 12 ++++++++++++ src/app/mod.rs | 3 +++ src/app/update.rs | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs index 60c0c8c4..ed016876 100644 --- a/src/app/cmd_result.rs +++ b/src/app/cmd_result.rs @@ -1674,13 +1674,18 @@ impl OpenCADStudio { self.focus_cmd_input() } - /// Restore the tangent snap state that was in effect before the command started. + /// Restore the tangent-snap / ortho state that was in effect before the command started. fn restore_pre_cmd_tangent(&mut self) { if let Some(was_on) = self.pre_cmd_tangent.take() { if !was_on { self.snapper.enabled.remove(&crate::snap::SnapType::Tangent); } } + if self.rect_suppressed_ortho { + self.rect_suppressed_ortho = false; + self.ortho_mode = true; + self.polar_mode = false; + } } } diff --git a/src/app/commands.rs b/src/app/commands.rs index 8f35b9d6..e99ba389 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -1006,18 +1006,30 @@ impl OpenCADStudio { use crate::modules::draw::draw::shapes::RectCommand; let new_cmd = RectCommand::new(); self.command_line.push_info(&new_cmd.prompt()); + if self.ortho_mode { + self.rect_suppressed_ortho = true; + self.ortho_mode = false; + } self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "RECT_ROT" => { use crate::modules::draw::draw::shapes::RectRotCommand; let new_cmd = RectRotCommand::new(); self.command_line.push_info(&new_cmd.prompt()); + if self.ortho_mode { + self.rect_suppressed_ortho = true; + self.ortho_mode = false; + } self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "RECT_CEN" => { use crate::modules::draw::draw::shapes::RectCenCommand; let new_cmd = RectCenCommand::new(); self.command_line.push_info(&new_cmd.prompt()); + if self.ortho_mode { + self.rect_suppressed_ortho = true; + self.ortho_mode = false; + } self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } "POLY" | "POLYGON" | "POL" => { diff --git a/src/app/mod.rs b/src/app/mod.rs index ae19fe7e..885da338 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -209,6 +209,8 @@ pub(super) struct OpenCADStudio { otrack_active: Option<(glam::Vec3, glam::Vec3)>, /// Whether Tangent snap was enabled before a tangent-pick command started. pre_cmd_tangent: Option, + /// Whether Ortho mode was temporarily suppressed by a command (e.g. RECTANG). + rect_suppressed_ortho: bool, /// Orthogonal drawing constraint (F8): constrains picks to 0°/90°/180°/270°. ortho_mode: bool, /// Polar tracking (F10): constrains picks to configurable angle increments. @@ -1371,6 +1373,7 @@ impl OpenCADStudio { perf_hud: false, cycle_candidates: None, pre_cmd_tangent: None, + rect_suppressed_ortho: false, ortho_mode: false, polar_mode: false, polar_increment_deg: 45.0, diff --git a/src/app/update.rs b/src/app/update.rs index d6d34748..1e2421f6 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -4098,6 +4098,10 @@ impl OpenCADStudio { if self.ortho_mode { self.polar_mode = false; } + // If the user manually toggles ortho during a command that + // suppressed it (e.g. RECTANG), the toggle is permanent — + // don't restore the pre-command state when the command ends. + self.rect_suppressed_ortho = false; Task::none() } Message::ToggleLineweightDisplay => {