fix(vpclip): drop the new boundary when the clip is refused; translate prompts

Review of #1485: VPCLIP added the polygon it drew to the drawing before
checking its area, so a boundary with no usable area was refused but left
behind as a stray object. It is erased again. The VPCLIP prompts and
messages go through t! like the rest of mview.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-09-25 15:18:33 +03:00
1 parent 22a5a8d16c
commit bb390cad58
2 files changed
+21 -11

No files matched your search

+7 -1
View File
@@ -74,13 +74,15 @@ impl OpenCADStudio {
_ => false, _ => false,
}); });
if !closed { if !closed {
self.command_line.push_error("Object is not a closed curve."); self.command_line
.push_error(crate::t!("Object is not a closed curve.").as_ref());
return; return;
} }
} }
self.push_undo_snapshot(i, "VPCLIP"); self.push_undo_snapshot(i, "VPCLIP");
let old = vp.clip_boundary_handle; let old = vp.clip_boundary_handle;
let scene = &mut self.tabs[i].scene; let scene = &mut self.tabs[i].scene;
let created = boundary.is_some();
let clip = match boundary { let clip = match boundary {
Some(entity) => scene.add_entity(entity), Some(entity) => scene.add_entity(entity),
None => boundary_handle, None => boundary_handle,
@@ -93,6 +95,10 @@ impl OpenCADStudio {
.map(|(lo, hi)| (glam::DVec2::from(lo), glam::DVec2::from(hi))) .map(|(lo, hi)| (glam::DVec2::from(lo), glam::DVec2::from(hi)))
.unwrap_or((glam::DVec2::ZERO, glam::DVec2::ZERO)); .unwrap_or((glam::DVec2::ZERO, glam::DVec2::ZERO));
if hi.x - lo.x < 1e-6 || hi.y - lo.y < 1e-6 { if hi.x - lo.x < 1e-6 || hi.y - lo.y < 1e-6 {
// The polygon drawn for this clip must not stay behind.
if created {
scene.erase_entities(&[clip]);
}
self.command_line self.command_line
.push_error(crate::t!("MVIEW: the clipping boundary has no usable area.").as_ref()); .push_error(crate::t!("MVIEW: the clipping boundary has no usable area.").as_ref());
return; return;
+14 -10
View File
@@ -233,11 +233,15 @@ impl MviewCommand {
if self.chord_step() { if self.chord_step() {
let default = format!("{:.4}", self.tangent_degrees()); let default = format!("{:.4}", self.tangent_degrees());
let default = default.trim_end_matches('0').trim_end_matches('.'); let default = default.trim_end_matches('0').trim_end_matches('.');
return Some(format!( return Some(
"Specify direction of chord for arc (hold Ctrl to switch direction) <{default}>:" t!(
)); "Specify direction of chord for arc (hold Ctrl to switch direction) <%{default}>:",
default = default
)
.into_owned(),
);
} }
Some(match self.arc_sub { Some(t!(match self.arc_sub {
Sub::ArcCenterAngle { .. } => "Specify included angle (hold Ctrl to switch direction):", Sub::ArcCenterAngle { .. } => "Specify included angle (hold Ctrl to switch direction):",
Sub::ArcAngle | Sub::ArcRadiusAngle { .. } => "Specify included angle:", Sub::ArcAngle | Sub::ArcRadiusAngle { .. } => "Specify included angle:",
Sub::ArcAngleEnd { .. } => "Specify endpoint of arc (hold Ctrl to switch direction) or [CEnter/Radius]:", Sub::ArcAngleEnd { .. } => "Specify endpoint of arc (hold Ctrl to switch direction) or [CEnter/Radius]:",
@@ -251,8 +255,8 @@ impl MviewCommand {
Sub::ArcSecond => "Specify second point on arc:", Sub::ArcSecond => "Specify second point on arc:",
Sub::ArcSecondEnd { .. } => "Specify end point of arc:", Sub::ArcSecondEnd { .. } => "Specify end point of arc:",
_ => return None, _ => return None,
} })
.to_string()) .into_owned())
} }
fn clip_text(&mut self, upper: &str) -> Option<CmdResult> { fn clip_text(&mut self, upper: &str) -> Option<CmdResult> {
@@ -535,7 +539,7 @@ impl CadCommand for MviewCommand {
} }
} }
if self.clip.is_some() { if self.clip.is_some() {
return match self.step { return t!(match self.step {
Step::ClipSelect => "Select viewport to clip:", Step::ClipSelect => "Select viewport to clip:",
Step::ClipChoice => "Select clipping object or [Polygonal] <Polygonal>:", Step::ClipChoice => "Select clipping object or [Polygonal] <Polygonal>:",
Step::ClipLength => "Specify length of line:", Step::ClipLength => "Specify length of line:",
@@ -545,8 +549,8 @@ impl CadCommand for MviewCommand {
} }
Step::Polygon if self.polygon.len() < 3 => "Specify next point or [Arc/Length/Undo]:", Step::Polygon if self.polygon.len() < 3 => "Specify next point or [Arc/Length/Undo]:",
_ => "Specify next point or [Arc/Close/Length/Undo]:", _ => "Specify next point or [Arc/Close/Length/Undo]:",
} })
.to_string(); .into_owned();
} }
match self.step { match self.step {
Step::RectangleFirst => t!( Step::RectangleFirst => t!(
@@ -799,7 +803,7 @@ impl CadCommand for MviewCommand {
self.step = Step::ClipChoice; self.step = Step::ClipChoice;
CmdResult::NeedPoint CmdResult::NeedPoint
} }
_ => CmdResult::ReportError("Object selected was not a viewport\n.".to_string()), _ => CmdResult::ReportError(t!("Object selected was not a viewport\n.").into_owned()),
}; };
} }
CmdResult::MviewCreateClipped { CmdResult::MviewCreateClipped {