mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-03 02:25:55 +00:00
* claim: #9188 * Preference: keep the view when a sketch opens, Look At faces it on request (#9188) Preferences > Sketch > "Turn to face a sketch when it opens" (on by default, so nothing changes unless it is turned off). Off: creating or editing a sketch leaves the view as it is, a sketch started on a face no longer re-centres on the picked point, and Look At (the palette button, Ctrl+8) still turns to face the sketch. The control channel sets it as `ui.prefs {"sketch_open_look_at": false}`. Changes a default: no Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"en": {
|
||||
"prefs.sketch_open_look_at": "Turn to face a sketch when it opens",
|
||||
"prefs.sketch_open_look_at_note": "Off: creating or editing a sketch leaves the view as it is. Look At faces the sketch when you want it."
|
||||
},
|
||||
"ja": {
|
||||
"prefs.sketch_open_look_at": "スケッチを開いたときに正対させる",
|
||||
"prefs.sketch_open_look_at_note": "オフ: スケッチの作成や編集でビューを動かしません。必要なときは「正面視」でスケッチに正対します。"
|
||||
},
|
||||
"zh": {
|
||||
"prefs.sketch_open_look_at": "打开草图时转向正对草图",
|
||||
"prefs.sketch_open_look_at_note": "关闭:创建或编辑草图时视图保持不变。需要时用“朝向”正对草图。"
|
||||
},
|
||||
"de": {
|
||||
"prefs.sketch_open_look_at": "Beim Öffnen einer Skizze auf sie ausrichten",
|
||||
"prefs.sketch_open_look_at_note": "Aus: Beim Erstellen oder Bearbeiten einer Skizze bleibt die Ansicht, wie sie ist. „Ansehen“ richtet die Ansicht bei Bedarf auf die Skizze aus."
|
||||
},
|
||||
"ko": {
|
||||
"prefs.sketch_open_look_at": "스케치를 열 때 정면으로 돌리기",
|
||||
"prefs.sketch_open_look_at_note": "끄기: 스케치를 만들거나 편집해도 뷰가 그대로입니다. 필요할 때 '바라보기'로 스케치를 정면으로 봅니다."
|
||||
},
|
||||
"ar": {
|
||||
"prefs.sketch_open_look_at": "توجيه العرض نحو الرسم عند فتحه",
|
||||
"prefs.sketch_open_look_at_note": "عند الإيقاف: إنشاء الرسم أو تحريره يُبقي العرض كما هو. يوجّه «النظر إلى» العرض نحو الرسم عند الحاجة."
|
||||
},
|
||||
"he": {
|
||||
"prefs.sketch_open_look_at": "הפניית התצוגה אל הסקיצה בפתיחתה",
|
||||
"prefs.sketch_open_look_at_note": "כבוי: יצירה או עריכה של סקיצה משאירות את התצוגה כפי שהיא. «מבט אל» מפנה את התצוגה אל הסקיצה כשרוצים."
|
||||
},
|
||||
"vi": {
|
||||
"prefs.sketch_open_look_at": "Xoay góc nhìn trực diện phác thảo khi mở",
|
||||
"prefs.sketch_open_look_at_note": "Tắt: tạo hoặc chỉnh sửa phác thảo sẽ giữ nguyên góc nhìn. Dùng Nhìn trực diện để nhìn thẳng vào phác thảo khi cần."
|
||||
}
|
||||
}
|
||||
@@ -3754,10 +3754,11 @@ pub fn start_sketch(app: &mut SolveApp, sel: &Sel) -> Result<(), String> {
|
||||
}
|
||||
let before = app.settled_cam();
|
||||
app.run("sketch.create", params).map_err(|error| crate::friendly_error("sketch.create", &error))?;
|
||||
app.look_at_opened_sketch(before);
|
||||
let turned = app.look_at_opened_sketch(before);
|
||||
// On a face: look at the picked point, not the plane's origin (a corner of the face),
|
||||
// which left the face filling the view off-centre like a big square.
|
||||
if let Sel::Face { point, .. } = sel
|
||||
if turned
|
||||
&& let Sel::Face { point, .. } = sel
|
||||
&& let Some(mut to) = app.cam_anim.as_ref().map(|a| a.to)
|
||||
{
|
||||
to.target = *point;
|
||||
|
||||
@@ -1962,11 +1962,16 @@ impl SolveApp {
|
||||
let _ = self.run("component.activate", p);
|
||||
}
|
||||
|
||||
/// Turn the view to face the sketch just opened, and remember the view from `before` it and
|
||||
/// the one facing it for when the sketch ends (#7038).
|
||||
pub(crate) fn look_at_opened_sketch(&mut self, before: Camera) {
|
||||
dialogs::look_at_sketch(self);
|
||||
/// Turn the view to face the sketch just opened, unless the "Turn to face a sketch when it
|
||||
/// opens" preference is off, and remember the view from `before` it and the one facing it for
|
||||
/// when the sketch ends (#7038). Returns whether the view turned.
|
||||
pub(crate) fn look_at_opened_sketch(&mut self, before: Camera) -> bool {
|
||||
let turn = self.preferences.sketch_open_look_at;
|
||||
if turn {
|
||||
dialogs::look_at_sketch(self);
|
||||
}
|
||||
self.pre_sketch_cam = self.session.active_sketch.map(|sketch| PreSketchView { sketch, before, facing: self.settled_cam() });
|
||||
turn
|
||||
}
|
||||
|
||||
/// Where the camera is going: the end of the running camera animation, else where it is.
|
||||
|
||||
@@ -1298,6 +1298,9 @@ preference_settings! {
|
||||
/// A sketch tool's shortcut pressed again before the first point steps to the tool's next
|
||||
/// creation mode (#2459). Off (the default): the key starts the tool again, as it always has.
|
||||
shortcut_cycles_modes: bool = false, PAGE_SKETCH;
|
||||
/// Opening or editing a sketch turns the view to face it (the default). Off: the view stays as
|
||||
/// it is, and Look At faces the sketch when asked.
|
||||
sketch_open_look_at: bool = true, PAGE_SKETCH;
|
||||
/// Where the view goes when a sketch ends (#7038). Keep (the default) leaves it as it is.
|
||||
sketch_exit_view: SketchExitView = SketchExitView::default(), PAGE_SKETCH;
|
||||
/// A shape drawn in a sketch gets all its dimensions at once: the typed values, and every
|
||||
|
||||
@@ -50,6 +50,8 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
});
|
||||
});
|
||||
ui_kit::checkbox(ui, app.tr("prefs.sketch_open_look_at"), &mut app.preferences.sketch_open_look_at)
|
||||
.on_hover_text(app.tr("prefs.sketch_open_look_at_note"));
|
||||
ui_kit::settings_block_hint(
|
||||
ui,
|
||||
app.tr("prefs.sketch_exit_view"),
|
||||
|
||||
@@ -412,3 +412,44 @@ fn a_sketch_opened_inside_a_component_gives_the_active_component_back() {
|
||||
app.finish_sketch();
|
||||
assert_eq!(app.session.active_component, washer, "the component activated meanwhile stays active");
|
||||
}
|
||||
|
||||
/// "Turn to face a sketch when it opens": off, creating or editing a sketch leaves the view as it
|
||||
/// is, and Look At still faces the sketch when asked.
|
||||
mod open_view_preference {
|
||||
use crate::scenario::Harness;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn turning_is_the_default() {
|
||||
assert!(crate::prefs::Prefs::default().sketch_open_look_at);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn off_a_new_sketch_keeps_the_view_and_look_at_still_turns() {
|
||||
let mut h = Harness::new();
|
||||
h.call("ui.prefs", json!({"sketch_open_look_at": false}));
|
||||
assert!(!h.app.preferences.sketch_open_look_at, "set through the control channel");
|
||||
h.call("ui.view", json!({"view": "iso"}));
|
||||
h.settle();
|
||||
let iso = h.app.cam;
|
||||
h.step(&json!({"start": "sketch.create"})).unwrap();
|
||||
h.step(&json!({"click": {"plane": "XY"}})).unwrap();
|
||||
h.settle();
|
||||
assert!(h.app.session.active_sketch.is_some());
|
||||
assert_eq!(h.app.cam, iso, "the view stays where it was");
|
||||
crate::dialogs::look_at_sketch_again(&mut h.app);
|
||||
h.settle();
|
||||
crate::scenario::check(&mut h, &json!({"sketching": true, "camera": {"yaw_deg": 0, "pitch_deg": 90}})).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn off_editing_a_sketch_keeps_the_view() {
|
||||
let mut app = crate::test_support::sample_app();
|
||||
app.preferences.sketch_open_look_at = false;
|
||||
let id = super::first_sketch(&app);
|
||||
let before = app.cam;
|
||||
app.edit_sketch(id);
|
||||
assert!(app.session.active_sketch.is_some());
|
||||
assert_eq!(app.settled_cam(), before);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ plane the sketch will lie on before you click.
|
||||
keeping what changed since the sketch was created or opened for editing: a new sketch is removed,
|
||||
an edited one goes back to how it was, as one step that Undo brings back.
|
||||
|
||||
Opening a sketch turns the view to face it. When the sketch ends, the view stays where it is by default. Preferences › Sketch › **When a sketch ends** changes that: **Return to the previous view** goes back to the view from before the sketch, and **Return unless rotated** goes back only when you panned or zoomed the sketch view but didn't turn it.
|
||||
Opening a sketch turns the view to face it; to keep the view as it is and face the sketch only with **Look At**, turn off Preferences › Sketch › **Turn to face a sketch when it opens**. When the sketch ends, the view stays where it is by default. Preferences › Sketch › **When a sketch ends** changes that: **Return to the previous view** goes back to the view from before the sketch, and **Return unless rotated** goes back only when you panned or zoomed the sketch view but didn't turn it.
|
||||
|
||||
In scripts, `XY`, `XZ`, `YZ` and their `Top`, `Front`, `Right` aliases name origin planes.
|
||||
Preferences › Interface › **Origin plane names** shows them as Top, Front and Right in the
|
||||
|
||||
@@ -422,6 +422,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
|
||||
- `sketch_conflict_colour` (default true: while the open sketch's constraints conflict, the curves and points a failing constraint holds are drawn in the theme's `sketch_conflict` colour too, not only its glyph or dimension; false: only the glyphs and dimensions are red, in `error`, as before, #7244)
|
||||
- `sketch_construction_lines` (default true: show the Construction Line tool family in Sketch CREATE; false restores the earlier menu)
|
||||
- `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned))
|
||||
- `sketch_open_look_at` (default true: creating or editing a sketch turns the view to face it; false leaves the view as it is, and Look At faces the sketch when asked)
|
||||
- `sketch_recent_snap` (default false: while drawing, the cursor snaps where the horizontal guide of one recent circle or arc centre or straight-edge midpoint meets the vertical guide of another; a free coordinate, with no constraint and no construction geometry. Off: those guides stay visual and the cursor does not move. The references come from `sketch_tracking_guides`, #8694)
|
||||
- `sketch_state_icons` (default true: a sketch's icon in History and the browser takes the colour of its solve state, `sketch` under constrained, `sketch_fixed` fully constrained, `error` while its constraints conflict, and its tooltip names the state; false: every sketch row's icon and tooltip as before, #7245)
|
||||
- `sketch_tab_always` (default false: the SKETCH tab stays in the ribbon right after MODEL while no sketch is open; a tool in its CREATE or REFERENCE section then opens Create Sketch, on the selected plane or planar face or else on the plane picked next, and starts in the new sketch, #7904)
|
||||
|
||||
Reference in New Issue
Block a user