Preferences: turn the view to isometric when Extrude opens, and back afterwards (#9176) (#9948)

* claim: #9176

* Preferences: turn the view to isometric when Extrude opens, and back afterwards (#9176)

Two new preferences on the Design page, next to "Extrude to a picked target", both off by
default:

- `extrude_view_isometric`: each time Extrude opens, the view turns to the isometric view, so
  the depth can be seen right after a sketch seen face-on.
- `extrude_view_return` (only with the first): when Extrude closes, by OK, Cancel or Esc, the
  view goes back to where it was before it turned, keeping the projection as the end of a sketch
  does (#7038). The check is per frame, so every way the dialog closes is covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EMbqRqYimvY26QzcvrojSC

---------

Co-authored-by: sascha2101 <221609842+sascha2101@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sascha2101
2026-10-31 10:13:08 +00:00
committed by GitHub
parent a2365228ab
commit f0d47e1d26
5 changed files with 132 additions and 0 deletions
@@ -0,0 +1,9 @@
{
"en": { "prefs.extrude_view_isometric": "Turn the view to isometric when Extrude opens", "prefs.extrude_view_return": "Go back to the earlier view when Extrude closes" },
"de": { "prefs.extrude_view_isometric": "Beim Öffnen von Extrudieren isometrisch ausrichten", "prefs.extrude_view_return": "Beim Schließen von Extrudieren zur vorigen Ansicht zurück" },
"ar": { "prefs.extrude_view_isometric": "تدوير العرض إلى المتساوي القياس عند فتح البثق", "prefs.extrude_view_return": "العودة إلى العرض السابق عند إغلاق البثق" },
"he": { "prefs.extrude_view_isometric": "סיבוב התצוגה לאיזומטרית בפתיחת שליפה", "prefs.extrude_view_return": "חזרה לתצוגה הקודמת בסגירת שליפה" },
"ja": { "prefs.extrude_view_isometric": "押し出しを開いたときに等角ビューにする", "prefs.extrude_view_return": "押し出しを閉じたときに元のビューに戻す" },
"vi": { "prefs.extrude_view_isometric": "Xoay sang góc nhìn trục đo khi mở Đùn khối", "prefs.extrude_view_return": "Trở lại góc nhìn trước khi đóng Đùn khối" },
"zh": { "prefs.extrude_view_isometric": "打开拉伸时转到等轴测视图", "prefs.extrude_view_return": "关闭拉伸时回到之前的视图" }
}
+33
View File
@@ -505,6 +505,9 @@ pub struct SolveApp {
/// The views around opening the open sketch. Leaving it goes back to the earlier one as the
/// "When a sketch ends" preference says (#7038).
pub pre_sketch_cam: Option<PreSketchView>,
/// The view from before Extrude turned it to isometric (#9176); the view goes back to it when
/// the dialog closes, as the "and back when it closes" preference says.
pub pre_extrude_cam: Option<Camera>,
/// The component active before Edit Sketch activated the one the sketch is in (#8127);
/// leaving the sketch makes it active again.
pub pre_sketch_component: Option<PreSketchComponent>,
@@ -762,6 +765,7 @@ impl SolveApp {
now: 0.0,
pre_sketch_marker: None,
pre_sketch_cam: None,
pre_extrude_cam: None,
pre_sketch_component: None,
services,
file_picker: None,
@@ -1938,7 +1942,11 @@ impl SolveApp {
if d.wants_picks() && !self.session.selection.is_empty() {
let _ = self.session.execute("select.clear", &json!({}));
}
let extrude = matches!(d.kind, dialogs::Kind::Extrude { .. });
self.dialog = Some(d);
if extrude {
self.turn_for_extrude();
}
return;
}
// Undo and redo can recompute much of the history: off the window thread when slow.
@@ -2076,6 +2084,30 @@ impl SolveApp {
turn
}
/// Extrude opened: turn the view to isometric when Preferences say so, and remember the view
/// from before for when the dialog closes (#9176).
fn turn_for_extrude(&mut self) {
if !self.preferences.extrude_view_isometric {
return;
}
let before = self.settled_cam();
let mut to = before;
to.set_view(StandardView::Iso);
self.pre_extrude_cam = self.preferences.extrude_view_return.then_some(before);
self.animate_to(to);
}
/// Once Extrude has closed, however it closed, the view goes back to where it was before
/// Extrude turned it (#9176). Going back keeps the projection, as at the end of a sketch.
fn return_from_extrude_view(&mut self) {
if self.dialog.as_ref().is_some_and(|d| matches!(d.kind, dialogs::Kind::Extrude { .. })) {
return;
}
if let Some(before) = self.pre_extrude_cam.take() {
self.animate_to(Camera { fov: self.settled_cam().fov, ..before });
}
}
/// Where the camera is going: the end of the running camera animation, else where it is.
pub(crate) fn settled_cam(&self) -> Camera {
self.cam_anim.map_or(self.cam, |a| a.to)
@@ -2586,6 +2618,7 @@ impl SolveApp {
self.poll_control_jobs(ctx);
self.drain_control(ctx);
self.follow_view_request(true);
self.return_from_extrude_view();
agent_cursor::step(self, ctx);
browser::eye_drag_frame(self, ctx);
if !self.synthetic.is_empty() {
+6
View File
@@ -1211,6 +1211,12 @@ preference_settings! {
/// Extrude: with a profile picked, a face, vertex or parallel plane picked off its plane
/// switches the extent to To Object (off: picks only add profiles, as before).
extrude_auto_to_object: bool = false, PAGE_DESIGN => check("Extrude to a picked target", "In Extrude, with a profile picked, picking a face, vertex or parallel plane off its plane switches the extent to To Object");
/// Extrude turns the view to isometric each time it opens, so the depth can be seen (#9176).
/// Off (the default): the view stays as it is.
extrude_view_isometric: bool = false, PAGE_DESIGN => check_id("prefs.extrude_view_isometric");
/// With `extrude_view_isometric`: when Extrude closes (OK or Cancel) the view goes back to
/// where it was before it turned (#9176). Off (the default): it stays isometric.
extrude_view_return: bool = false, PAGE_DESIGN => check_id("prefs.extrude_view_return");
/// Feature windows choose Join, New Body or Cut from what their material touches (`op_auto`,
/// #6901). Off: they keep the operation they open with (Extrude its own Join or Cut), as before.
auto_operation: bool = true, PAGE_DESIGN => check_id("prefs.auto_operation");
+4
View File
@@ -83,6 +83,10 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
},
);
setting::extrude_auto_to_object(app, ui);
// Extrude's view (#9176): isometric when it opens, and back afterwards only with that.
setting::extrude_view_isometric(app, ui);
let isometric = app.preferences.extrude_view_isometric;
ui.add_enabled_ui(isometric, |ui| setting::extrude_view_return(app, ui));
let auto = setting::auto_operation(app, ui);
crate::scenario::publish_handle("prefs:auto_operation", auto.rect.center());
ui_kit::text(ui, app.tr("prefs.auto_operation_note"), ui_kit::Text::Hint("auto_operation"));
+80
View File
@@ -368,6 +368,86 @@ mod exit_view_preference {
}
}
/// Preferences › Design › Extrude's view (#9176): with the first preference on, the view turns to
/// isometric each time Extrude opens; with the second as well, it goes back to the view from
/// before when Extrude closes, by OK, Cancel or Esc. Both are off by default: the view stays.
mod extrude_view_preference {
use crate::scenario::Harness;
use serde_json::json;
use solidcraft_engine::render::{Camera, StandardView};
/// A finished sketch on XY, seen from the top, with the two preferences set; and that view.
fn from_the_top(isometric: bool, back: bool) -> (Harness, Camera) {
let mut h = Harness::new();
h.app.preferences.extrude_view_isometric = isometric;
h.app.preferences.extrude_view_return = back;
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [40, 30]})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
h.call("ui.view", json!({"view": "top"}));
h.settle();
crate::scenario::check(&mut h, &json!({"camera": {"yaw_deg": 0, "pitch_deg": 90}})).unwrap();
let top = h.app.cam;
(h, top)
}
fn open_extrude(h: &mut Harness) {
h.step(&json!({"start": "solid.extrude"})).unwrap();
h.settle();
assert!(h.app.dialog.is_some(), "Extrude is open");
}
fn iso_of(cam: Camera) -> Camera {
let mut iso = cam;
iso.set_view(StandardView::Iso);
iso
}
#[test]
fn both_are_off_by_default_and_the_view_stays() {
let prefs = crate::prefs::Prefs::default();
assert!(!prefs.extrude_view_isometric && !prefs.extrude_view_return);
let (mut h, top) = from_the_top(false, false);
open_extrude(&mut h);
assert_eq!(h.app.cam, top);
// The second one alone does nothing either.
let (mut h, top) = from_the_top(false, true);
open_extrude(&mut h);
assert_eq!(h.app.cam, top);
}
#[test]
fn extrude_turns_the_view_to_isometric_and_leaves_it_there() {
let (mut h, top) = from_the_top(true, false);
open_extrude(&mut h);
assert_eq!(h.app.cam, iso_of(top), "isometric when Extrude opens");
h.step(&json!({"widget": "Cancel"})).unwrap();
h.settle();
assert!(h.app.dialog.is_none());
assert_eq!(h.app.cam, iso_of(top), "without the second preference it stays isometric");
}
#[test]
fn ok_cancel_and_escape_go_back_to_the_view_from_before() {
for close in ["OK", "Cancel", "Escape"] {
let (mut h, top) = from_the_top(true, true);
open_extrude(&mut h);
assert_eq!(h.app.cam, iso_of(top), "{close}: isometric while Extrude is open");
match close {
"Escape" => h.step(&json!({"key": "Escape"})).unwrap(),
other => h.step(&json!({"widget": other})).unwrap(),
};
h.settle();
assert!(h.app.dialog.is_none(), "{close}");
assert_eq!(h.app.session.doc.features.len(), if close == "OK" { 2 } else { 1 }, "{close}: OK adds the extrude");
assert_eq!(h.app.cam, top, "{close}: back to the view from before");
// Each time it opens, not only the first.
open_extrude(&mut h);
assert_eq!(h.app.cam, iso_of(top), "{close}: isometric again");
}
}
}
/// #8127: a sketch inside an inserted fastener, opened from its row in the browser, activates the
/// fastener's component while it is open; Finish and Cancel make the design active again, so the
/// other bodies are no longer drawn faded. Editing it with the fastener already active leaves the