Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36dbcb6553 | ||
|
|
0fc495b182 | ||
|
|
17142847ab |
No files matched your search
Generated
+1
@@ -4242,6 +4242,7 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"winit",
|
||||
"x11rb",
|
||||
"zbus 5.19.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -104,5 +104,10 @@ winit = { version = "0.30", default-features = false, features = ["x11"] }
|
||||
raw-window-handle = "0.6"
|
||||
x11rb = { version = "0.13", default-features = false }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
# The desktop's dark or light preference through the XDG Desktop Portal (src/desktop_theme.rs,
|
||||
# #7944); already in the tree through eframe's accessibility support (accesskit_unix).
|
||||
zbus = { version = "5", default-features = false, features = ["async-io", "blocking-api"] }
|
||||
|
||||
[build-dependencies]
|
||||
embed-resource = "3.0.11"
|
||||
@@ -0,0 +1,195 @@
|
||||
//! Linux: the desktop's dark or light preference, for Theme: System (#7944).
|
||||
//!
|
||||
//! The window toolkit does not pass it on everywhere: on GNOME (Wayland, or X11 through XWayland)
|
||||
//! the window never learns it, nor when it changes, so the app kept its colours. This reads the
|
||||
//! freedesktop setting through the XDG Desktop Portal's Settings interface on the session bus
|
||||
//! (`org.freedesktop.appearance color-scheme`, then GNOME's `color-scheme` and `gtk-theme`), the
|
||||
//! same setting other applications follow, and inside a Flatpak too. It runs on a thread of its
|
||||
//! own: the first reading, then the portal's `SettingChanged` signal; where the signal can't be
|
||||
//! had, a reading every few seconds. Without a portal it asks `gsettings` instead, on the same
|
||||
//! thread. The window reads the last answer with an atomic load
|
||||
//! (`solidcraft_ui_egui::Services::desktop_dark`), and the decision from the raw values is
|
||||
//! `solidcraft_ui_egui::prefs::desktop_prefers_dark`.
|
||||
|
||||
use std::io::Read;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU8, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
use zbus::zvariant::{OwnedValue, Value};
|
||||
|
||||
const UNKNOWN: u8 = 0;
|
||||
const DARK: u8 = 1;
|
||||
const LIGHT: u8 = 2;
|
||||
|
||||
/// How often to read again where the portal's change signal is not available.
|
||||
const POLL: Duration = Duration::from_secs(5);
|
||||
/// How long one `gsettings` reading may take before it is given up.
|
||||
const GSETTINGS_TIMEOUT: Duration = Duration::from_secs(2);
|
||||
|
||||
const PORTAL: &str = "org.freedesktop.portal.Desktop";
|
||||
const PORTAL_PATH: &str = "/org/freedesktop/portal/desktop";
|
||||
const SETTINGS: &str = "org.freedesktop.portal.Settings";
|
||||
const APPEARANCE: &str = "org.freedesktop.appearance";
|
||||
const GNOME: &str = "org.gnome.desktop.interface";
|
||||
|
||||
/// Start following the desktop's preference; the closure answers the latest reading (`None`
|
||||
/// until there is one, or when the desktop says nothing).
|
||||
pub fn start(ctx: &egui::Context) -> Box<dyn Fn() -> Option<bool>> {
|
||||
let state = Arc::new(AtomicU8::new(UNKNOWN));
|
||||
let (thread_state, ctx) = (state.clone(), ctx.clone());
|
||||
if let Err(e) = std::thread::Builder::new().name("desktop-theme".into()).spawn(move || follow(&thread_state, &ctx)) {
|
||||
log::warn!("desktop theme: no thread to follow it: {e}");
|
||||
}
|
||||
Box::new(move || match state.load(Ordering::Relaxed) {
|
||||
DARK => Some(true),
|
||||
LIGHT => Some(false),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Keep `state` on the desktop's preference, asking for a frame whenever it changes.
|
||||
fn follow(state: &AtomicU8, ctx: &egui::Context) {
|
||||
let publish = |dark: Option<bool>| {
|
||||
let code = match dark {
|
||||
Some(true) => DARK,
|
||||
Some(false) => LIGHT,
|
||||
None => UNKNOWN,
|
||||
};
|
||||
if state.swap(code, Ordering::Relaxed) != code {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
};
|
||||
let portal = match portal() {
|
||||
Ok(p) => Some(p),
|
||||
Err(e) => {
|
||||
log::info!("desktop theme: no settings portal ({e}); asking gsettings");
|
||||
None
|
||||
}
|
||||
};
|
||||
// The portal first; gsettings where there is none or it says nothing (its backend missing).
|
||||
let read = |portal: Option<&zbus::blocking::Proxy<'static>>| portal.and_then(read_portal).or_else(read_gsettings);
|
||||
let from_portal = portal.as_ref().and_then(read_portal);
|
||||
let first = from_portal.or_else(read_gsettings);
|
||||
publish(first);
|
||||
// Wait for the portal's signal only when the portal answers: else the reading is gsettings',
|
||||
// which only a new reading notices.
|
||||
if let Some(p) = portal.as_ref().filter(|_| from_portal.is_some()) {
|
||||
match p.receive_signal("SettingChanged") {
|
||||
Ok(changes) => {
|
||||
for message in changes {
|
||||
if relevant(&message) {
|
||||
publish(read(Some(p)));
|
||||
}
|
||||
}
|
||||
log::info!("desktop theme: the portal's change signal ended; reading every few seconds");
|
||||
}
|
||||
Err(e) => log::info!("desktop theme: no change signal ({e}); reading every few seconds"),
|
||||
}
|
||||
} else if portal.is_none() && first.is_none() && !gsettings_available() {
|
||||
// Neither the portal nor gsettings: nothing to follow; the window toolkit's theme stays.
|
||||
return;
|
||||
}
|
||||
loop {
|
||||
std::thread::sleep(POLL);
|
||||
publish(read(portal.as_ref()));
|
||||
}
|
||||
}
|
||||
|
||||
/// The portal's Settings interface on the session bus.
|
||||
fn portal() -> zbus::Result<zbus::blocking::Proxy<'static>> {
|
||||
let connection = zbus::blocking::Connection::session()?;
|
||||
zbus::blocking::Proxy::new(&connection, PORTAL, PORTAL_PATH, SETTINGS)
|
||||
}
|
||||
|
||||
/// One reading through the portal.
|
||||
fn read_portal(portal: &zbus::blocking::Proxy<'static>) -> Option<bool> {
|
||||
let appearance = read_setting(portal, APPEARANCE, "color-scheme").and_then(|v| as_u32(&v));
|
||||
// The GNOME settings only matter when the freedesktop one has no preference.
|
||||
if matches!(appearance, Some(1 | 2)) {
|
||||
return solidcraft_ui_egui::prefs::desktop_prefers_dark(appearance, None, None);
|
||||
}
|
||||
let gnome = read_setting(portal, GNOME, "color-scheme").and_then(|v| as_string(&v));
|
||||
let gtk_theme = read_setting(portal, GNOME, "gtk-theme").and_then(|v| as_string(&v));
|
||||
solidcraft_ui_egui::prefs::desktop_prefers_dark(appearance, gnome.as_deref(), gtk_theme.as_deref())
|
||||
}
|
||||
|
||||
/// A setting through `ReadOne` (portal version 2), else the older `Read`.
|
||||
fn read_setting(portal: &zbus::blocking::Proxy<'static>, namespace: &str, key: &str) -> Option<OwnedValue> {
|
||||
let one: zbus::Result<OwnedValue> = portal.call("ReadOne", &(namespace, key));
|
||||
one.or_else(|_| -> zbus::Result<OwnedValue> { portal.call("Read", &(namespace, key)) }).ok()
|
||||
}
|
||||
|
||||
/// Whether a `SettingChanged` signal is about a setting the preference is read from.
|
||||
fn relevant(message: &zbus::Message) -> bool {
|
||||
let body = message.body();
|
||||
let Ok((namespace, key, _)) = body.deserialize::<(String, String, OwnedValue)>() else { return false };
|
||||
matches!((namespace.as_str(), key.as_str()), (APPEARANCE, "color-scheme") | (GNOME, "color-scheme" | "gtk-theme"))
|
||||
}
|
||||
|
||||
/// The value inside the variants `Read` wraps it in (a portal answers one or two deep).
|
||||
fn unwrap_variants<'v, 'a>(value: &'v Value<'a>) -> &'v Value<'a> {
|
||||
let mut value = value;
|
||||
for _ in 0..4 {
|
||||
match value {
|
||||
Value::Value(inner) => value = &**inner,
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
fn as_u32(value: &Value<'_>) -> Option<u32> {
|
||||
match unwrap_variants(value) {
|
||||
Value::U32(n) => Some(*n),
|
||||
Value::I32(n) => u32::try_from(*n).ok(),
|
||||
Value::U8(n) => Some(u32::from(*n)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn as_string(value: &Value<'_>) -> Option<String> {
|
||||
match unwrap_variants(value) {
|
||||
Value::Str(s) => Some(s.as_str().to_string()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Without a portal: GNOME's settings through `gsettings` (`None` when it is not there).
|
||||
fn read_gsettings() -> Option<bool> {
|
||||
let gnome = gsettings("color-scheme");
|
||||
let gtk_theme = gsettings("gtk-theme");
|
||||
solidcraft_ui_egui::prefs::desktop_prefers_dark(None, gnome.as_deref(), gtk_theme.as_deref())
|
||||
}
|
||||
|
||||
fn gsettings_available() -> bool {
|
||||
gsettings("gtk-theme").is_some()
|
||||
}
|
||||
|
||||
/// `gsettings get org.gnome.desktop.interface <key>`, its quoted answer, or `None` when the
|
||||
/// program is missing, fails or does not answer in time.
|
||||
fn gsettings(key: &str) -> Option<String> {
|
||||
let mut child = std::process::Command::new("gsettings")
|
||||
.args(["get", GNOME, key])
|
||||
.stdin(std::process::Stdio::null())
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.spawn()
|
||||
.ok()?;
|
||||
let started = std::time::Instant::now();
|
||||
loop {
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) if status.success() => break,
|
||||
Ok(None) if started.elapsed() < GSETTINGS_TIMEOUT => std::thread::sleep(Duration::from_millis(20)),
|
||||
_ => {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut out = String::new();
|
||||
child.stdout.take()?.take(4096).read_to_string(&mut out).ok()?;
|
||||
let value = out.trim().trim_matches('\'').to_string();
|
||||
(!value.is_empty()).then_some(value)
|
||||
}
|
||||
@@ -5,12 +5,25 @@
|
||||
//! for recovery as a forced quit does, and starts again ([`restart`]), and the new start says what
|
||||
//! happened ([`note`]). A device lost again soon after such a restart starts the next one on the
|
||||
//! software renderer, which doesn't depend on the graphics driver.
|
||||
//!
|
||||
//! The old process ends without tearing down its GPU objects ([`end`]): on a lost NVIDIA device
|
||||
//! destroying the window's swap chain busy-waits in the driver and never returns (#9044).
|
||||
|
||||
use crate::startup;
|
||||
|
||||
/// Set on the start after a lost device: when the device was lost (seconds since 1970).
|
||||
pub const LOST_ENV: &str = "SOLIDCRAFT_DEVICE_LOST";
|
||||
|
||||
/// Set on the start after a lost device: why it was lost, as wgpu said it. The old process's
|
||||
/// session journal, which recorded it, is gone by then.
|
||||
pub const REASON_ENV: &str = "SOLIDCRAFT_DEVICE_LOST_REASON";
|
||||
|
||||
/// The longest reason passed on ([`REASON_ENV`]) and shown, in characters.
|
||||
const REASON_CHARS: usize = 300;
|
||||
|
||||
/// How long the process may take to end ([`end`]) before it is aborted.
|
||||
const END_GRACE: std::time::Duration = std::time::Duration::from_secs(3);
|
||||
|
||||
/// A loss this recent (seconds) counts for the start after it: its note, and a second loss
|
||||
/// within it starts on the software renderer. Inherited by later starts, an older stamp is
|
||||
/// ignored.
|
||||
@@ -32,27 +45,54 @@ pub fn restart_on_software(after_recent_loss: bool, cpu_renderer: bool) -> bool
|
||||
after_recent_loss || cpu_renderer
|
||||
}
|
||||
|
||||
/// `reason` on one line, at most [`REASON_CHARS`] long; None when there is nothing to say.
|
||||
pub fn reason(reason: Option<&str>) -> Option<String> {
|
||||
let line = reason?.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
(!line.is_empty()).then(|| line.chars().take(REASON_CHARS).collect())
|
||||
}
|
||||
|
||||
/// What the start after a lost device tells the user, `software` when it runs on the software
|
||||
/// renderer.
|
||||
pub fn note(software: bool) -> String {
|
||||
/// renderer, with what the driver reported ([`REASON_ENV`]).
|
||||
pub fn note(software: bool, reason: Option<&str>) -> String {
|
||||
let mut note = String::from(
|
||||
"The graphics device was reset (the graphics driver stopped responding), so SolidCraft closed and started again. Unsaved changes were kept for recovery.",
|
||||
);
|
||||
if software {
|
||||
note.push_str(" This start uses software rendering, which doesn't depend on the graphics driver.");
|
||||
}
|
||||
if let Some(reason) = self::reason(reason) {
|
||||
note.push_str(&format!(" The graphics driver reported: {reason}"));
|
||||
}
|
||||
note
|
||||
}
|
||||
|
||||
/// Start SolidCraft again with the same arguments, the loss stamped at `lost_at`, on the software
|
||||
/// renderer when `software`.
|
||||
pub fn restart(software: bool, lost_at: u64) {
|
||||
let Ok(exe) = std::env::current_exe() else { return };
|
||||
/// The command that starts `exe` again with `args`, the loss stamped at `lost_at` and its
|
||||
/// `reason`, on the software renderer when `software`.
|
||||
fn command(
|
||||
exe: std::path::PathBuf,
|
||||
args: impl IntoIterator<Item = std::ffi::OsString>,
|
||||
software: bool,
|
||||
lost_at: u64,
|
||||
reason: &str,
|
||||
) -> std::process::Command {
|
||||
let mut command = std::process::Command::new(exe);
|
||||
command.args(std::env::args_os().skip(1)).env(LOST_ENV, lost_at.to_string());
|
||||
command.args(args).env(LOST_ENV, lost_at.to_string());
|
||||
match self::reason(Some(reason)) {
|
||||
Some(reason) => command.env(REASON_ENV, reason),
|
||||
// Not one inherited from an earlier loss.
|
||||
None => command.env_remove(REASON_ENV),
|
||||
};
|
||||
if software {
|
||||
command.env(startup::RENDERER_ENV, "cpu");
|
||||
}
|
||||
command
|
||||
}
|
||||
|
||||
/// Start SolidCraft again with the same arguments, the loss stamped at `lost_at` and its `reason`,
|
||||
/// on the software renderer when `software`.
|
||||
pub fn restart(software: bool, lost_at: u64, reason: &str) {
|
||||
let Ok(exe) = std::env::current_exe() else { return };
|
||||
let mut command = command(exe, std::env::args_os().skip(1), software, lost_at, reason);
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
@@ -64,6 +104,23 @@ pub fn restart(software: bool, lost_at: u64) {
|
||||
}
|
||||
}
|
||||
|
||||
/// End the process now, without tearing down what is left on the lost device: the window's swap
|
||||
/// chain, the viewport's buffers and pipelines. On NVIDIA's Vulkan driver destroying the swap
|
||||
/// chain of a lost device busy-waits forever, which left the old window frozen at 100% of a core
|
||||
/// beside the new one (#9044). Should the exit itself get stuck in a library's exit handler, the
|
||||
/// process is aborted after [`END_GRACE`].
|
||||
pub fn end() -> ! {
|
||||
let watchdog = std::thread::Builder::new().name("solidcraft-exit".into()).spawn(|| {
|
||||
std::thread::sleep(END_GRACE);
|
||||
eprintln!("SolidCraft graphics: still closing after the device was lost; aborting");
|
||||
std::process::abort();
|
||||
});
|
||||
if let Err(e) = watchdog {
|
||||
log::warn!("graphics: no exit watchdog: {e}");
|
||||
}
|
||||
std::process::exit(0)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
/// Only a recent, well-formed stamp counts: a later start that inherited it says nothing.
|
||||
@@ -84,8 +141,34 @@ mod tests {
|
||||
assert!(!super::restart_on_software(false, false));
|
||||
assert!(super::restart_on_software(true, false));
|
||||
assert!(super::restart_on_software(false, true));
|
||||
assert!(super::note(true).contains("software rendering"));
|
||||
assert!(!super::note(false).contains("software rendering"));
|
||||
assert!(super::note(false).contains("kept for recovery"));
|
||||
assert!(super::note(true, None).contains("software rendering"));
|
||||
assert!(!super::note(false, None).contains("software rendering"));
|
||||
assert!(super::note(false, None).contains("kept for recovery"));
|
||||
}
|
||||
|
||||
/// The start after a loss is told why (#9044): the old process's journal held the reason, and
|
||||
/// it is deleted as that process closes.
|
||||
#[test]
|
||||
fn the_next_start_is_told_why_the_device_was_lost() {
|
||||
let exe = std::path::PathBuf::from("solidcraft");
|
||||
let args = ["--control".into(), "7979".into()];
|
||||
let command = super::command(exe.clone(), args, true, 1_000, "Lost: Device lost\n (vkQueueSubmit)");
|
||||
let env = |command: &std::process::Command, name: &str| {
|
||||
command.get_envs().find(|(k, _)| *k == name).map(|(_, v)| v.map(|v| v.to_string_lossy().into_owned()))
|
||||
};
|
||||
assert_eq!(env(&command, super::LOST_ENV), Some(Some("1000".into())));
|
||||
assert_eq!(env(&command, super::REASON_ENV), Some(Some("Lost: Device lost (vkQueueSubmit)".into())), "on one line");
|
||||
assert_eq!(env(&command, crate::startup::RENDERER_ENV), Some(Some("cpu".into())));
|
||||
assert_eq!(command.get_args().collect::<Vec<_>>(), ["--control", "7979"]);
|
||||
// No reason: none inherited from an earlier loss either.
|
||||
let command = super::command(exe, Vec::new(), false, 1_000, " ");
|
||||
assert_eq!(env(&command, super::REASON_ENV), Some(None));
|
||||
assert_eq!(env(&command, crate::startup::RENDERER_ENV), None);
|
||||
|
||||
let note = super::note(false, Some("Lost: Device lost"));
|
||||
assert!(note.ends_with("The graphics driver reported: Lost: Device lost"), "{note}");
|
||||
assert!(!super::note(false, Some(" \n ")).contains("reported"));
|
||||
let long = "x".repeat(1_000);
|
||||
assert_eq!(super::reason(Some(&long)).map(|r| r.chars().count()), Some(300));
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@
|
||||
mod app_icon;
|
||||
mod come_forward;
|
||||
mod control_server;
|
||||
#[cfg(target_os = "linux")]
|
||||
mod desktop_theme;
|
||||
mod device_lost;
|
||||
#[cfg(target_os = "windows")]
|
||||
mod native_crash;
|
||||
@@ -202,13 +204,29 @@ impl eframe::App for App {
|
||||
}
|
||||
solidcraft_ui_egui::recovery_ui::close(&mut self.solve);
|
||||
solidcraft_ui_egui::open_elsewhere::close(&mut self.solve);
|
||||
// Before a restart below starts the next instance, which would otherwise get nothing from
|
||||
// the 3D mouse driver (`solidcraft_3dx_client::stop`).
|
||||
// Before a restart (`Drop for App`) starts the next instance, which would otherwise get
|
||||
// nothing from the 3D mouse driver (`solidcraft_3dx_client::stop`).
|
||||
#[cfg(target_os = "macos")]
|
||||
solidcraft_3dx_client::stop();
|
||||
solidcraft_engine::crash::end_session();
|
||||
if let Some(lost_at) = self.gpu.as_ref().and_then(|g| g.lost_at) {
|
||||
device_lost::restart(self.gpu.as_ref().is_some_and(|g| g.restart_on_software), lost_at);
|
||||
// The next start (after a lost device, or into an update) begins once the app is dropped
|
||||
// (`Drop for App`), when the settings are on disk.
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for App {
|
||||
/// eframe drops its settings storage first, which waits for `app.ron` to be written, then the
|
||||
/// app, then the window and its GPU surface. So the next start begins here: started from
|
||||
/// `on_exit`, it read `app.ron` while the old process was still writing it, found it
|
||||
/// unreadable and moved it aside, resetting every setting (#9044).
|
||||
fn drop(&mut self) {
|
||||
if let Some(gpu) = &self.gpu
|
||||
&& let Some(lost_at) = gpu.lost_at
|
||||
{
|
||||
device_lost::restart(gpu.restart_on_software, lost_at, &gpu.reason);
|
||||
// The window's GPU surface is still to be dropped, and on a lost device that may
|
||||
// never return (#9044).
|
||||
device_lost::end();
|
||||
}
|
||||
// An update asked to restart into the new version or to run its installer.
|
||||
if let Some((program, args)) = solidcraft_ui_egui::update::take_launch(&mut self.solve) {
|
||||
@@ -236,6 +254,8 @@ struct LostWatch {
|
||||
restart_on_software: bool,
|
||||
/// When the loss was seen: the app is closing to start again.
|
||||
lost_at: Option<u64>,
|
||||
/// Why, as wgpu said it: passed to the next start ([`device_lost::REASON_ENV`]).
|
||||
reason: String,
|
||||
}
|
||||
|
||||
impl App {
|
||||
@@ -249,6 +269,7 @@ impl App {
|
||||
eprintln!("SolidCraft graphics: the device was lost ({reason}); starting again");
|
||||
solidcraft_engine::crash::phase(&format!("graphics device lost: {reason}"));
|
||||
gpu.lost_at = Some(device_lost::now_secs());
|
||||
gpu.reason = reason;
|
||||
self.solve.quit_requested = true;
|
||||
}
|
||||
}
|
||||
@@ -422,6 +443,12 @@ fn services(cc: &eframe::CreationContext<'_>, folder: &DialogFolder) -> Services
|
||||
graphics_adapters: Vec::new(),
|
||||
graphics_path: graphics_path().map(|p| p.to_string_lossy().to_string()),
|
||||
window_system: window_system_now(),
|
||||
// Linux: the desktop's dark or light setting, which the window is not told on every
|
||||
// desktop (#7944). Windows and macOS: the window's own theme.
|
||||
#[cfg(target_os = "linux")]
|
||||
desktop_dark: Some(desktop_theme::start(&cc.egui_ctx)),
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
desktop_dark: None,
|
||||
http_get: Some(std::sync::Arc::new(http_get)),
|
||||
http_download: Some(std::sync::Arc::new(http_download)),
|
||||
// Already an installed app: only the browser build offers to install.
|
||||
@@ -821,7 +848,11 @@ fn main() -> eframe::Result {
|
||||
// The launch before this one closed because its graphics device was lost (`App::watch_device`).
|
||||
let after_loss = device_lost::recent(std::env::var(device_lost::LOST_ENV).ok().as_deref(), device_lost::now_secs());
|
||||
if after_loss {
|
||||
notes.push(device_lost::note(cpu_renderer));
|
||||
let reason = std::env::var(device_lost::REASON_ENV).ok();
|
||||
if let Some(reason) = device_lost::reason(reason.as_deref()) {
|
||||
log::warn!("graphics: the last launch lost its device ({reason})");
|
||||
}
|
||||
notes.push(device_lost::note(cpu_renderer, reason.as_deref()));
|
||||
}
|
||||
if safe_mode {
|
||||
notes.push("Safe mode: default settings (yours are kept for the next normal start), no recovery offer, software rendering.".into());
|
||||
@@ -961,6 +992,7 @@ fn main() -> eframe::Result {
|
||||
lost: rs.device_lost.clone(),
|
||||
restart_on_software: device_lost::restart_on_software(after_loss, cpu_renderer),
|
||||
lost_at: None,
|
||||
reason: String::new(),
|
||||
});
|
||||
if !safe_mode {
|
||||
app.preferences.graphics_adapter =
|
||||
|
||||
@@ -201,6 +201,7 @@ polygon false
|
||||
polygon_circumscribed false
|
||||
polygon_edge false
|
||||
presspull false
|
||||
print_face false
|
||||
project false
|
||||
project_surface false
|
||||
rack_pinion false
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Print Face</title>
|
||||
<path d="M9.72 26.17L4.5 20.95L4.5 40.85L9.72 46.07Z" fill="#b8c3cf"/>
|
||||
<path d="M9.72 26.17L4.5 20.95L4.5 40.85L9.72 46.07Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M18.77 23.15L9.72 26.17L9.72 46.07L18.77 43.05Z" fill="#328bd3"/>
|
||||
<path d="M18.77 23.15L9.72 26.17L9.72 46.07L18.77 43.05Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M13.55 17.93L18.77 23.15L9.72 26.17L4.5 20.95Z" fill="#e2e8ef"/>
|
||||
<path d="M13.55 17.93L18.77 23.15L9.72 26.17L4.5 20.95Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M50.45 37.54L38.27 25.35L38.27 33.88L50.45 46.07Z" fill="#b8c3cf"/>
|
||||
<path d="M50.45 37.54L38.27 25.35L38.27 33.88L50.45 46.07Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M59.5 34.53L50.45 37.54L50.45 46.07L59.5 43.05Z" fill="#8e9faf"/>
|
||||
<path d="M59.5 34.53L50.45 37.54L50.45 46.07L59.5 43.05Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M47.31 22.34L59.5 34.53L50.45 37.54L38.27 25.35Z" fill="#e2e8ef"/>
|
||||
<path d="M47.31 22.34L59.5 34.53L50.45 37.54L38.27 25.35Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M50.45 46.07L38.27 33.88" fill="none" stroke="#236ead" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M59.5 43.05L50.45 46.07" fill="none" stroke="#236ead" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M24.17 34.2L28.31 34.2" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M35.31 34.2L27.31 38.7L27.31 29.7Z" fill="#236ead"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,332 @@
|
||||
{
|
||||
"en": {
|
||||
"cmd.body.print_face": "Print Face",
|
||||
"ui.clear_print_face": "Clear Print Face",
|
||||
"ui.print_face_cleared": "{body}: print face cleared",
|
||||
"ui.print_face_input": "Print face",
|
||||
"ui.print_face_one_body": "A print face is picked for one body: send that body on its own to change it",
|
||||
"ui.print_face_pick": "Select one flat face of a solid body to make it the print face",
|
||||
"ui.print_face_set": "{body}: print face set; Send to Slicer lays the body on it",
|
||||
"prefs.print_face_highlight": "Print face highlight",
|
||||
"prefs.print_face_highlight_tip": "How strongly the print face of a body is tinted and outlined in the view. 0 % shows no highlight."
|
||||
},
|
||||
"de": {
|
||||
"cmd.body.print_face": "Auflagefläche",
|
||||
"ui.clear_print_face": "Auflagefläche entfernen",
|
||||
"ui.print_face_cleared": "{body}: Auflagefläche entfernt",
|
||||
"ui.print_face_input": "Auflagefläche",
|
||||
"ui.print_face_one_body": "Eine Auflagefläche gehört zu einem Körper: Sende diesen Körper allein, um sie zu ändern",
|
||||
"ui.print_face_pick": "Eine plane Fläche eines Volumenkörpers auswählen, um sie zur Auflagefläche zu machen",
|
||||
"ui.print_face_set": "{body}: Auflagefläche gesetzt; An Slicer senden legt den Körper darauf",
|
||||
"prefs.print_face_highlight": "Hervorhebung der Auflagefläche",
|
||||
"prefs.print_face_highlight_tip": "Wie stark die Auflagefläche eines Körpers in der Ansicht eingefärbt und umrandet wird. 0 % zeigt keine Hervorhebung."
|
||||
},
|
||||
"ja": {
|
||||
"cmd.body.print_face": "造形面",
|
||||
"ui.clear_print_face": "造形面を解除",
|
||||
"ui.print_face_cleared": "{body}: 造形面を解除しました",
|
||||
"ui.print_face_input": "造形面",
|
||||
"ui.print_face_one_body": "造形面はボディごとに選びます。変更するにはそのボディだけを送信してください",
|
||||
"ui.print_face_pick": "ソリッドボディの平面を1つ選択すると造形面になります",
|
||||
"ui.print_face_set": "{body}: 造形面を設定しました。スライサーへ送るとこの面を下にして置きます",
|
||||
"prefs.print_face_highlight": "造形面の強調",
|
||||
"prefs.print_face_highlight_tip": "ビューでボディの造形面を色付けし輪郭を描く強さ。0 % で強調しません。"
|
||||
},
|
||||
"zh": {
|
||||
"cmd.body.print_face": "打印底面",
|
||||
"ui.clear_print_face": "清除打印底面",
|
||||
"ui.print_face_cleared": "{body}:已清除打印底面",
|
||||
"ui.print_face_input": "打印底面",
|
||||
"ui.print_face_one_body": "打印底面属于单个实体:请单独发送该实体以更改它",
|
||||
"ui.print_face_pick": "选择实体的一个平面,将其设为打印底面",
|
||||
"ui.print_face_set": "{body}:已设置打印底面;发送到切片软件时实体将放在此面上",
|
||||
"prefs.print_face_highlight": "打印底面高亮",
|
||||
"prefs.print_face_highlight_tip": "视图中实体打印底面的着色和轮廓强度。0 % 不显示高亮。"
|
||||
},
|
||||
"ko": {
|
||||
"cmd.body.print_face": "출력 바닥면",
|
||||
"ui.clear_print_face": "출력 바닥면 해제",
|
||||
"ui.print_face_cleared": "{body}: 출력 바닥면을 해제했습니다",
|
||||
"ui.print_face_input": "출력 바닥면",
|
||||
"ui.print_face_one_body": "출력 바닥면은 바디마다 하나입니다. 변경하려면 그 바디만 보내십시오",
|
||||
"ui.print_face_pick": "솔리드 바디의 평면 하나를 선택하면 출력 바닥면이 됩니다",
|
||||
"ui.print_face_set": "{body}: 출력 바닥면을 설정했습니다. 슬라이서로 보내면 이 면이 아래로 놓입니다",
|
||||
"prefs.print_face_highlight": "출력 바닥면 강조",
|
||||
"prefs.print_face_highlight_tip": "뷰에서 바디의 출력 바닥면을 색칠하고 윤곽을 그리는 강도입니다. 0 %이면 강조하지 않습니다."
|
||||
},
|
||||
"ar": {
|
||||
"cmd.body.print_face": "وجه الطباعة",
|
||||
"ui.clear_print_face": "مسح وجه الطباعة",
|
||||
"ui.print_face_cleared": "{body}: تم مسح وجه الطباعة",
|
||||
"ui.print_face_input": "وجه الطباعة",
|
||||
"ui.print_face_one_body": "يُختار وجه الطباعة لجسم واحد: أرسل ذلك الجسم وحده لتغييره",
|
||||
"ui.print_face_pick": "اختر وجهًا مستويًا واحدًا لجسم صلب لجعله وجه الطباعة",
|
||||
"ui.print_face_set": "{body}: تم تعيين وجه الطباعة؛ الإرسال إلى برنامج التقطيع يضع الجسم عليه",
|
||||
"prefs.print_face_highlight": "إبراز وجه الطباعة",
|
||||
"prefs.print_face_highlight_tip": "مدى قوة تلوين وجه الطباعة للجسم وتحديده في العرض. 0 % لا يُظهر أي إبراز."
|
||||
},
|
||||
"he": {
|
||||
"cmd.body.print_face": "פאת הדפסה",
|
||||
"ui.clear_print_face": "נקה פאת הדפסה",
|
||||
"ui.print_face_cleared": "{body}: פאת ההדפסה נוקתה",
|
||||
"ui.print_face_input": "פאת הדפסה",
|
||||
"ui.print_face_one_body": "פאת הדפסה נבחרת לגוף אחד: שלח את הגוף הזה לבדו כדי לשנות אותה",
|
||||
"ui.print_face_pick": "בחר פאה שטוחה אחת של גוף מוצק כדי להפוך אותה לפאת ההדפסה",
|
||||
"ui.print_face_set": "{body}: פאת ההדפסה הוגדרה; שליחה לסלייסר מניחה את הגוף עליה",
|
||||
"prefs.print_face_highlight": "הדגשת פאת ההדפסה",
|
||||
"prefs.print_face_highlight_tip": "עד כמה חזק צובעים ומקיפים את פאת ההדפסה של גוף בתצוגה. 0 % אינו מציג הדגשה."
|
||||
},
|
||||
"vi": {
|
||||
"cmd.body.print_face": "Mặt in",
|
||||
"ui.clear_print_face": "Xóa mặt in",
|
||||
"ui.print_face_cleared": "{body}: đã xóa mặt in",
|
||||
"ui.print_face_input": "Mặt in",
|
||||
"ui.print_face_one_body": "Mặt in được chọn cho một thân: hãy gửi riêng thân đó để thay đổi",
|
||||
"ui.print_face_pick": "Chọn một mặt phẳng của thân đặc để đặt làm mặt in",
|
||||
"ui.print_face_set": "{body}: đã đặt mặt in; Gửi đến Slicer sẽ đặt thân lên mặt này",
|
||||
"prefs.print_face_highlight": "Tô sáng mặt in",
|
||||
"prefs.print_face_highlight_tip": "Mức tô màu và viền mặt in của thân trong khung nhìn. 0 % không tô sáng."
|
||||
},
|
||||
"bs": {
|
||||
"cmd.body.print_face": "Površina za štampu",
|
||||
"ui.clear_print_face": "Ukloni površinu za štampu",
|
||||
"ui.print_face_cleared": "{body}: površina za štampu uklonjena",
|
||||
"ui.print_face_input": "Površina za štampu",
|
||||
"ui.print_face_one_body": "Površina za štampu pripada jednom tijelu: pošaljite to tijelo samo da biste je promijenili",
|
||||
"ui.print_face_pick": "Odaberite ravnu površinu punog tijela da postane površina za štampu",
|
||||
"ui.print_face_set": "{body}: površina za štampu postavljena; Pošalji u slajser polaže tijelo na nju",
|
||||
"prefs.print_face_highlight": "Isticanje površine za štampu",
|
||||
"prefs.print_face_highlight_tip": "Koliko se jako površina za štampu tijela boji i obrubljuje u prikazu. 0 % ne prikazuje isticanje."
|
||||
},
|
||||
"cs": {
|
||||
"cmd.body.print_face": "Tisková plocha",
|
||||
"ui.clear_print_face": "Zrušit tiskovou plochu",
|
||||
"ui.print_face_cleared": "{body}: tisková plocha zrušena",
|
||||
"ui.print_face_input": "Tisková plocha",
|
||||
"ui.print_face_one_body": "Tisková plocha patří jednomu tělesu: odešlete toto těleso samostatně, abyste ji změnili",
|
||||
"ui.print_face_pick": "Vyberte rovinnou plochu objemového tělesa, aby se stala tiskovou plochou",
|
||||
"ui.print_face_set": "{body}: tisková plocha nastavena; Odeslat do sliceru položí těleso na ni",
|
||||
"prefs.print_face_highlight": "Zvýraznění tiskové plochy",
|
||||
"prefs.print_face_highlight_tip": "Jak výrazně se tisková plocha tělesa v pohledu obarví a obtáhne. 0 % nezobrazí žádné zvýraznění."
|
||||
},
|
||||
"da": {
|
||||
"cmd.body.print_face": "Printflade",
|
||||
"ui.clear_print_face": "Ryd printflade",
|
||||
"ui.print_face_cleared": "{body}: printflade ryddet",
|
||||
"ui.print_face_input": "Printflade",
|
||||
"ui.print_face_one_body": "En printflade hører til ét legeme: send det legeme alene for at ændre den",
|
||||
"ui.print_face_pick": "Vælg en plan flade på et massivt legeme for at gøre den til printfladen",
|
||||
"ui.print_face_set": "{body}: printflade sat; Send til slicer lægger legemet på den",
|
||||
"prefs.print_face_highlight": "Fremhævning af printflade",
|
||||
"prefs.print_face_highlight_tip": "Hvor kraftigt et legemes printflade farves og omrids i visningen. 0 % viser ingen fremhævning."
|
||||
},
|
||||
"es": {
|
||||
"cmd.body.print_face": "Cara de impresión",
|
||||
"ui.clear_print_face": "Quitar cara de impresión",
|
||||
"ui.print_face_cleared": "{body}: cara de impresión quitada",
|
||||
"ui.print_face_input": "Cara de impresión",
|
||||
"ui.print_face_one_body": "Una cara de impresión pertenece a un solo cuerpo: envía ese cuerpo solo para cambiarla",
|
||||
"ui.print_face_pick": "Selecciona una cara plana de un cuerpo sólido para convertirla en la cara de impresión",
|
||||
"ui.print_face_set": "{body}: cara de impresión definida; Enviar al laminador apoya el cuerpo sobre ella",
|
||||
"prefs.print_face_highlight": "Resaltado de la cara de impresión",
|
||||
"prefs.print_face_highlight_tip": "Intensidad del tinte y del contorno de la cara de impresión de un cuerpo en la vista. 0 % no muestra resaltado."
|
||||
},
|
||||
"fr": {
|
||||
"cmd.body.print_face": "Face d’impression",
|
||||
"ui.clear_print_face": "Effacer la face d’impression",
|
||||
"ui.print_face_cleared": "{body} : face d’impression effacée",
|
||||
"ui.print_face_input": "Face d’impression",
|
||||
"ui.print_face_one_body": "Une face d’impression appartient à un seul corps : envoyez ce corps seul pour la modifier",
|
||||
"ui.print_face_pick": "Sélectionnez une face plane d’un corps solide pour en faire la face d’impression",
|
||||
"ui.print_face_set": "{body} : face d’impression définie ; Envoyer au slicer pose le corps sur cette face",
|
||||
"prefs.print_face_highlight": "Mise en évidence de la face d’impression",
|
||||
"prefs.print_face_highlight_tip": "Intensité de la teinte et du contour de la face d’impression d’un corps dans la vue. 0 % n’affiche aucune mise en évidence."
|
||||
},
|
||||
"gl": {
|
||||
"cmd.body.print_face": "Cara de impresión",
|
||||
"ui.clear_print_face": "Quitar cara de impresión",
|
||||
"ui.print_face_cleared": "{body}: cara de impresión quitada",
|
||||
"ui.print_face_input": "Cara de impresión",
|
||||
"ui.print_face_one_body": "Unha cara de impresión pertence a un só corpo: envía ese corpo só para cambiala",
|
||||
"ui.print_face_pick": "Selecciona unha cara plana dun corpo sólido para facela a cara de impresión",
|
||||
"ui.print_face_set": "{body}: cara de impresión definida; Enviar ao laminador apoia o corpo sobre ela",
|
||||
"prefs.print_face_highlight": "Resaltado da cara de impresión",
|
||||
"prefs.print_face_highlight_tip": "Intensidade da tinguidura e do contorno da cara de impresión dun corpo na vista. 0 % non mostra resaltado."
|
||||
},
|
||||
"hr": {
|
||||
"cmd.body.print_face": "Ploha ispisa",
|
||||
"ui.clear_print_face": "Ukloni plohu ispisa",
|
||||
"ui.print_face_cleared": "{body}: ploha ispisa uklonjena",
|
||||
"ui.print_face_input": "Ploha ispisa",
|
||||
"ui.print_face_one_body": "Ploha ispisa pripada jednom tijelu: pošaljite to tijelo samo da biste je promijenili",
|
||||
"ui.print_face_pick": "Odaberite ravnu plohu punog tijela da postane ploha ispisa",
|
||||
"ui.print_face_set": "{body}: ploha ispisa postavljena; Pošalji u slicer polaže tijelo na nju",
|
||||
"prefs.print_face_highlight": "Isticanje plohe ispisa",
|
||||
"prefs.print_face_highlight_tip": "Koliko se jako ploha ispisa tijela boji i obrubljuje u prikazu. 0 % ne prikazuje isticanje."
|
||||
},
|
||||
"hu": {
|
||||
"cmd.body.print_face": "Nyomtatási lap",
|
||||
"ui.clear_print_face": "Nyomtatási lap törlése",
|
||||
"ui.print_face_cleared": "{body}: nyomtatási lap törölve",
|
||||
"ui.print_face_input": "Nyomtatási lap",
|
||||
"ui.print_face_one_body": "A nyomtatási lap egy testhez tartozik: a módosításhoz küldd el azt a testet egyedül",
|
||||
"ui.print_face_pick": "Válassz ki egy tömör test egy sík lapját, hogy az legyen a nyomtatási lap",
|
||||
"ui.print_face_set": "{body}: nyomtatási lap beállítva; a Küldés szeletelőnek erre a lapra fekteti a testet",
|
||||
"prefs.print_face_highlight": "Nyomtatási lap kiemelése",
|
||||
"prefs.print_face_highlight_tip": "Milyen erősen színezi és körvonalazza a nézet a test nyomtatási lapját. 0 % esetén nincs kiemelés."
|
||||
},
|
||||
"id": {
|
||||
"cmd.body.print_face": "Permukaan cetak",
|
||||
"ui.clear_print_face": "Hapus permukaan cetak",
|
||||
"ui.print_face_cleared": "{body}: permukaan cetak dihapus",
|
||||
"ui.print_face_input": "Permukaan cetak",
|
||||
"ui.print_face_one_body": "Permukaan cetak milik satu bodi: kirim bodi itu sendiri untuk mengubahnya",
|
||||
"ui.print_face_pick": "Pilih satu permukaan datar dari bodi padat untuk dijadikan permukaan cetak",
|
||||
"ui.print_face_set": "{body}: permukaan cetak diatur; Kirim ke slicer meletakkan bodi di atasnya",
|
||||
"prefs.print_face_highlight": "Sorotan permukaan cetak",
|
||||
"prefs.print_face_highlight_tip": "Seberapa kuat permukaan cetak sebuah bodi diwarnai dan diberi garis tepi di tampilan. 0 % tidak menampilkan sorotan."
|
||||
},
|
||||
"it": {
|
||||
"cmd.body.print_face": "Faccia di stampa",
|
||||
"ui.clear_print_face": "Rimuovi faccia di stampa",
|
||||
"ui.print_face_cleared": "{body}: faccia di stampa rimossa",
|
||||
"ui.print_face_input": "Faccia di stampa",
|
||||
"ui.print_face_one_body": "Una faccia di stampa appartiene a un solo corpo: invia quel corpo da solo per cambiarla",
|
||||
"ui.print_face_pick": "Seleziona una faccia piana di un corpo solido per renderla la faccia di stampa",
|
||||
"ui.print_face_set": "{body}: faccia di stampa impostata; Invia allo slicer appoggia il corpo su di essa",
|
||||
"prefs.print_face_highlight": "Evidenziazione della faccia di stampa",
|
||||
"prefs.print_face_highlight_tip": "Intensità della tinta e del contorno della faccia di stampa di un corpo nella vista. 0 % non mostra evidenziazione."
|
||||
},
|
||||
"ms": {
|
||||
"cmd.body.print_face": "Muka cetakan",
|
||||
"ui.clear_print_face": "Kosongkan muka cetakan",
|
||||
"ui.print_face_cleared": "{body}: muka cetakan dikosongkan",
|
||||
"ui.print_face_input": "Muka cetakan",
|
||||
"ui.print_face_one_body": "Muka cetakan dimiliki oleh satu jasad: hantar jasad itu sahaja untuk menukarnya",
|
||||
"ui.print_face_pick": "Pilih satu muka rata pada jasad pepejal untuk menjadikannya muka cetakan",
|
||||
"ui.print_face_set": "{body}: muka cetakan ditetapkan; Hantar ke penghiris meletakkan jasad di atasnya",
|
||||
"prefs.print_face_highlight": "Serlahan muka cetakan",
|
||||
"prefs.print_face_highlight_tip": "Sejauh mana muka cetakan sesuatu jasad diwarnakan dan digaris dalam paparan. 0 % tidak menunjukkan serlahan."
|
||||
},
|
||||
"nb": {
|
||||
"cmd.body.print_face": "Utskriftsflate",
|
||||
"ui.clear_print_face": "Fjern utskriftsflate",
|
||||
"ui.print_face_cleared": "{body}: utskriftsflate fjernet",
|
||||
"ui.print_face_input": "Utskriftsflate",
|
||||
"ui.print_face_one_body": "En utskriftsflate hører til ett legeme: send det legemet alene for å endre den",
|
||||
"ui.print_face_pick": "Velg en plan flate på et massivt legeme for å gjøre den til utskriftsflaten",
|
||||
"ui.print_face_set": "{body}: utskriftsflate satt; Send til slicer legger legemet på den",
|
||||
"prefs.print_face_highlight": "Utheving av utskriftsflate",
|
||||
"prefs.print_face_highlight_tip": "Hvor sterkt et legemes utskriftsflate fargelegges og omrisses i visningen. 0 % viser ingen utheving."
|
||||
},
|
||||
"nl": {
|
||||
"cmd.body.print_face": "Printvlak",
|
||||
"ui.clear_print_face": "Printvlak wissen",
|
||||
"ui.print_face_cleared": "{body}: printvlak gewist",
|
||||
"ui.print_face_input": "Printvlak",
|
||||
"ui.print_face_one_body": "Een printvlak hoort bij één lichaam: stuur dat lichaam alleen om het te wijzigen",
|
||||
"ui.print_face_pick": "Selecteer één vlak van een massief lichaam om het het printvlak te maken",
|
||||
"ui.print_face_set": "{body}: printvlak ingesteld; Naar slicer sturen legt het lichaam erop",
|
||||
"prefs.print_face_highlight": "Markering van het printvlak",
|
||||
"prefs.print_face_highlight_tip": "Hoe sterk het printvlak van een lichaam in de weergave wordt gekleurd en omlijnd. 0 % toont geen markering."
|
||||
},
|
||||
"pl": {
|
||||
"cmd.body.print_face": "Powierzchnia druku",
|
||||
"ui.clear_print_face": "Usuń powierzchnię druku",
|
||||
"ui.print_face_cleared": "{body}: usunięto powierzchnię druku",
|
||||
"ui.print_face_input": "Powierzchnia druku",
|
||||
"ui.print_face_one_body": "Powierzchnia druku należy do jednej bryły: wyślij tę bryłę osobno, aby ją zmienić",
|
||||
"ui.print_face_pick": "Wybierz płaską powierzchnię bryły, aby ustawić ją jako powierzchnię druku",
|
||||
"ui.print_face_set": "{body}: ustawiono powierzchnię druku; Wyślij do slicera kładzie bryłę na niej",
|
||||
"prefs.print_face_highlight": "Wyróżnienie powierzchni druku",
|
||||
"prefs.print_face_highlight_tip": "Jak mocno powierzchnia druku bryły jest barwiona i obrysowywana w widoku. 0 % nie pokazuje wyróżnienia."
|
||||
},
|
||||
"pt-BR": {
|
||||
"cmd.body.print_face": "Face de impressão",
|
||||
"ui.clear_print_face": "Limpar face de impressão",
|
||||
"ui.print_face_cleared": "{body}: face de impressão removida",
|
||||
"ui.print_face_input": "Face de impressão",
|
||||
"ui.print_face_one_body": "Uma face de impressão pertence a um único corpo: envie esse corpo sozinho para alterá-la",
|
||||
"ui.print_face_pick": "Selecione uma face plana de um corpo sólido para torná-la a face de impressão",
|
||||
"ui.print_face_set": "{body}: face de impressão definida; Enviar ao fatiador apoia o corpo sobre ela",
|
||||
"prefs.print_face_highlight": "Destaque da face de impressão",
|
||||
"prefs.print_face_highlight_tip": "Intensidade da cor e do contorno da face de impressão de um corpo na vista. 0 % não mostra destaque."
|
||||
},
|
||||
"ro": {
|
||||
"cmd.body.print_face": "Față de imprimare",
|
||||
"ui.clear_print_face": "Șterge fața de imprimare",
|
||||
"ui.print_face_cleared": "{body}: fața de imprimare a fost ștearsă",
|
||||
"ui.print_face_input": "Față de imprimare",
|
||||
"ui.print_face_one_body": "O față de imprimare aparține unui singur corp: trimiteți acel corp singur pentru a o schimba",
|
||||
"ui.print_face_pick": "Selectați o față plană a unui corp solid pentru a o face fața de imprimare",
|
||||
"ui.print_face_set": "{body}: fața de imprimare a fost setată; Trimite la slicer așază corpul pe ea",
|
||||
"prefs.print_face_highlight": "Evidențierea feței de imprimare",
|
||||
"prefs.print_face_highlight_tip": "Cât de puternic este colorată și conturată fața de imprimare a unui corp în vizualizare. 0 % nu afișează evidențiere."
|
||||
},
|
||||
"ru": {
|
||||
"cmd.body.print_face": "Грань печати",
|
||||
"ui.clear_print_face": "Сбросить грань печати",
|
||||
"ui.print_face_cleared": "{body}: грань печати сброшена",
|
||||
"ui.print_face_input": "Грань печати",
|
||||
"ui.print_face_one_body": "Грань печати относится к одному телу: отправьте это тело отдельно, чтобы изменить её",
|
||||
"ui.print_face_pick": "Выберите плоскую грань твёрдого тела, чтобы сделать её гранью печати",
|
||||
"ui.print_face_set": "{body}: грань печати задана; «Отправить в слайсер» кладёт тело на неё",
|
||||
"prefs.print_face_highlight": "Подсветка грани печати",
|
||||
"prefs.print_face_highlight_tip": "Насколько сильно грань печати тела окрашивается и обводится в виде. 0 % — без подсветки."
|
||||
},
|
||||
"sr": {
|
||||
"cmd.body.print_face": "Површина за штампу",
|
||||
"ui.clear_print_face": "Уклони површину за штампу",
|
||||
"ui.print_face_cleared": "{body}: површина за штампу уклоњена",
|
||||
"ui.print_face_input": "Површина за штампу",
|
||||
"ui.print_face_one_body": "Површина за штампу припада једном телу: пошаљите то тело само да бисте је променили",
|
||||
"ui.print_face_pick": "Изаберите равну површину пуног тела да постане површина за штампу",
|
||||
"ui.print_face_set": "{body}: површина за штампу постављена; Пошаљи у слајсер полаже тело на њу",
|
||||
"prefs.print_face_highlight": "Истицање површине за штампу",
|
||||
"prefs.print_face_highlight_tip": "Колико се јако површина за штампу тела боји и обрубљује у приказу. 0 % не приказује истицање."
|
||||
},
|
||||
"sv": {
|
||||
"cmd.body.print_face": "Utskriftsyta",
|
||||
"ui.clear_print_face": "Rensa utskriftsyta",
|
||||
"ui.print_face_cleared": "{body}: utskriftsyta rensad",
|
||||
"ui.print_face_input": "Utskriftsyta",
|
||||
"ui.print_face_one_body": "En utskriftsyta hör till en kropp: skicka den kroppen ensam för att ändra den",
|
||||
"ui.print_face_pick": "Välj en plan yta på en solid kropp för att göra den till utskriftsytan",
|
||||
"ui.print_face_set": "{body}: utskriftsyta angiven; Skicka till slicer lägger kroppen på den",
|
||||
"prefs.print_face_highlight": "Markering av utskriftsyta",
|
||||
"prefs.print_face_highlight_tip": "Hur starkt en kropps utskriftsyta färgas och konturmarkeras i vyn. 0 % visar ingen markering."
|
||||
},
|
||||
"tr": {
|
||||
"cmd.body.print_face": "Baskı yüzeyi",
|
||||
"ui.clear_print_face": "Baskı yüzeyini temizle",
|
||||
"ui.print_face_cleared": "{body}: baskı yüzeyi temizlendi",
|
||||
"ui.print_face_input": "Baskı yüzeyi",
|
||||
"ui.print_face_one_body": "Baskı yüzeyi tek bir gövdeye aittir: değiştirmek için o gövdeyi tek başına gönderin",
|
||||
"ui.print_face_pick": "Baskı yüzeyi yapmak için katı bir gövdenin düz bir yüzeyini seçin",
|
||||
"ui.print_face_set": "{body}: baskı yüzeyi ayarlandı; Dilimleyiciye gönder gövdeyi bu yüzeyin üzerine koyar",
|
||||
"prefs.print_face_highlight": "Baskı yüzeyi vurgusu",
|
||||
"prefs.print_face_highlight_tip": "Bir gövdenin baskı yüzeyinin görünümde ne kadar güçlü renklendirilip çerçeveleneceği. %0 vurgu göstermez."
|
||||
},
|
||||
"uk": {
|
||||
"cmd.body.print_face": "Грань друку",
|
||||
"ui.clear_print_face": "Скинути грань друку",
|
||||
"ui.print_face_cleared": "{body}: грань друку скинуто",
|
||||
"ui.print_face_input": "Грань друку",
|
||||
"ui.print_face_one_body": "Грань друку належить одному тілу: надішліть це тіло окремо, щоб змінити її",
|
||||
"ui.print_face_pick": "Виберіть плоску грань твердого тіла, щоб зробити її гранню друку",
|
||||
"ui.print_face_set": "{body}: грань друку задано; «Надіслати в слайсер» кладе тіло на неї",
|
||||
"prefs.print_face_highlight": "Підсвічування грані друку",
|
||||
"prefs.print_face_highlight_tip": "Наскільки сильно грань друку тіла зафарбовується й обводиться у вигляді. 0 % — без підсвічування."
|
||||
},
|
||||
"zh-TW": {
|
||||
"cmd.body.print_face": "列印底面",
|
||||
"ui.clear_print_face": "清除列印底面",
|
||||
"ui.print_face_cleared": "{body}:已清除列印底面",
|
||||
"ui.print_face_input": "列印底面",
|
||||
"ui.print_face_one_body": "列印底面屬於單一實體:請單獨傳送該實體以變更它",
|
||||
"ui.print_face_pick": "選取實體的一個平面,將其設為列印底面",
|
||||
"ui.print_face_set": "{body}:已設定列印底面;傳送到切片軟體時實體會放在此面上",
|
||||
"prefs.print_face_highlight": "列印底面醒目提示",
|
||||
"prefs.print_face_highlight_tip": "在檢視中為實體的列印底面著色及描邊的強度。0 % 不顯示醒目提示。"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| assets/icons/ui/design/svg/model/print_face.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
|
||||
@@ -2736,6 +2736,9 @@ pub struct Document {
|
||||
/// Physical material per body (by body name); others use the default.
|
||||
#[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")]
|
||||
pub materials: std::collections::BTreeMap<String, String>,
|
||||
/// The flat face per body (by body name) that a slicer export lays on the print bed.
|
||||
#[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")]
|
||||
pub print_faces: std::collections::BTreeMap<String, crate::config::ConfigFaceTarget>,
|
||||
/// Physical materials defined in this design (`material.create`), next to the built-in ones.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub user_materials: Vec<UserMaterial>,
|
||||
@@ -2982,6 +2985,7 @@ impl Document {
|
||||
body_components: Default::default(),
|
||||
body_offsets: Default::default(),
|
||||
materials: Default::default(),
|
||||
print_faces: Default::default(),
|
||||
user_materials: Vec::new(),
|
||||
appearances: Default::default(),
|
||||
favorites: Default::default(),
|
||||
@@ -2997,7 +3001,7 @@ impl Document {
|
||||
}
|
||||
|
||||
/// Rename body `old` to `new` where the design keeps things by body name outside its
|
||||
/// features: materials, appearances, plastic rules, configuration columns, offsets, components and the
|
||||
/// features: materials, print faces, appearances, plastic rules, configuration columns, offsets, components and the
|
||||
/// browser's groups and order. (The features are the rename command's to change.)
|
||||
///
|
||||
/// A name the design numbered (`Body1`) is not used again after the rename: the design's
|
||||
@@ -3013,6 +3017,10 @@ impl Document {
|
||||
if let Some(m) = self.materials.remove(old) {
|
||||
self.materials.insert(new.to_string(), m);
|
||||
}
|
||||
if let Some(mut face) = self.print_faces.remove(old) {
|
||||
face.body = new.to_string();
|
||||
self.print_faces.insert(new.to_string(), face);
|
||||
}
|
||||
if let Some(rule) = self.plastic.assigned.remove(old) {
|
||||
self.plastic.assigned.insert(new.to_string(), rule);
|
||||
}
|
||||
|
||||
@@ -172,32 +172,7 @@ impl Document {
|
||||
author: u64,
|
||||
author_path: &[u64],
|
||||
) -> Result<FaceAnchor> {
|
||||
// A construction certificate that names this face alone, else its exact history name.
|
||||
let certified = body
|
||||
.body
|
||||
.face_plane(index)
|
||||
.ok_or_else(|| DocError::Invalid("this face has no exact planar source; choose a fixed plane instead".into()))
|
||||
.and_then(|source| {
|
||||
let target = self.strong_face_target(body, index, source.origin)?;
|
||||
if target.certificate.is_none() {
|
||||
return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into()));
|
||||
}
|
||||
let indices = self.configuration_face_indices(body, &target)?;
|
||||
// A copy a pattern or mirror made on the same body carries its seed's certificate,
|
||||
// which finds the seed's face: the copy is attached by its own history name below.
|
||||
if !indices.contains(&index) {
|
||||
return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into()));
|
||||
}
|
||||
self.coplanar_pieces(body, &indices, |_| true)?;
|
||||
Ok(target)
|
||||
});
|
||||
let target = match certified {
|
||||
Ok(target) => target,
|
||||
Err(error) => match body.body.planar_face(index).and_then(|plane| self.lineage_face_target(body, index, plane.origin)) {
|
||||
Some(target) => target,
|
||||
None => return Err(error),
|
||||
},
|
||||
};
|
||||
let target = self.flat_face_target(body, index)?;
|
||||
let source = self
|
||||
.anchor_face_plane(body, index, target.certificate.as_ref())
|
||||
.ok_or_else(|| DocError::Invalid("this face has no exact planar source; choose a fixed plane instead".into()))?;
|
||||
@@ -220,6 +195,34 @@ impl Document {
|
||||
Ok(anchor)
|
||||
}
|
||||
|
||||
/// A target for flat face `index` of `body` that a rebuild finds again: a construction
|
||||
/// certificate that names this face alone, else its exact history name. What a sketch on a
|
||||
/// face and a print face hold.
|
||||
pub(crate) fn flat_face_target(&self, body: &ModelBody, index: usize) -> Result<ConfigFaceTarget> {
|
||||
let certified = body
|
||||
.body
|
||||
.face_plane(index)
|
||||
.ok_or_else(|| DocError::Invalid("this face has no exact planar source; choose a fixed plane instead".into()))
|
||||
.and_then(|source| {
|
||||
let target = self.strong_face_target(body, index, source.origin)?;
|
||||
if target.certificate.is_none() {
|
||||
return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into()));
|
||||
}
|
||||
let indices = self.configuration_face_indices(body, &target)?;
|
||||
// A copy a pattern or mirror made on the same body carries its seed's certificate,
|
||||
// which finds the seed's face: the copy is attached by its own history name below.
|
||||
if !indices.contains(&index) {
|
||||
return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into()));
|
||||
}
|
||||
self.coplanar_pieces(body, &indices, |_| true)?;
|
||||
Ok(target)
|
||||
});
|
||||
match certified {
|
||||
Ok(target) => Ok(target),
|
||||
Err(error) => body.body.planar_face(index).and_then(|plane| self.lineage_face_target(body, index, plane.origin)).ok_or(error),
|
||||
}
|
||||
}
|
||||
|
||||
/// The faces an attachment stands for, and a note when they were found by fallback.
|
||||
///
|
||||
/// An extrude's cap is certified by the loop of sketch curves around it, so editing that
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//! A design saves the print face of its bodies (`print_faces`, by body name): the flat face a
|
||||
//! slicer export lays on the print bed, held by the same face target a sketch on a face holds.
|
||||
//! An older design has none, and every body is exported as it lies, as before. The last
|
||||
//! release refuses a design that has print faces and asks for an update, instead of opening it
|
||||
//! and losing them on the next save.
|
||||
@@ -61,6 +61,8 @@ pub use thread_catalog::{TappedThread, TappedThreadFamily, parse_tapped_thread,
|
||||
mod walk;
|
||||
pub use profile_refs::{capture_profile_selection, profile_fallback_notes, profile_selection_indices, profile_selection_indices_lenient};
|
||||
pub mod plastic;
|
||||
mod print_face;
|
||||
pub use print_face::PrintFace;
|
||||
pub mod project;
|
||||
mod project3d;
|
||||
pub mod render_aging;
|
||||
|
||||
@@ -127,6 +127,7 @@ fn same_geometry_inputs(a: &Document, b: &Document) -> bool {
|
||||
text_params,
|
||||
next_component_color_index,
|
||||
materials,
|
||||
print_faces,
|
||||
user_materials,
|
||||
appearances,
|
||||
body_components,
|
||||
@@ -162,6 +163,7 @@ fn same_geometry_inputs(a: &Document, b: &Document) -> bool {
|
||||
&& *text_params == b.text_params
|
||||
&& *next_component_color_index == b.next_component_color_index
|
||||
&& *materials == b.materials
|
||||
&& *print_faces == b.print_faces
|
||||
&& *user_materials == b.user_materials
|
||||
&& *appearances == b.appearances
|
||||
&& *body_components == b.body_components
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
//! The print face: the flat face of a body that a slicer export lays on the print bed (#8429).
|
||||
//! A body has at most one (`Document::print_faces`, by body name). It is held by the target a
|
||||
//! sketch on a face holds ([`Document::flat_face_target`]), so a rebuild that adds, removes or
|
||||
//! reorders faces finds the same face again, or says it is gone.
|
||||
|
||||
use solidcraft_geom::Vec3;
|
||||
|
||||
use crate::config::ConfigFaceTarget;
|
||||
use crate::{DocError, Document, ModelBody, ModelState, Result};
|
||||
|
||||
/// Where a print face is: a point on it and its outward unit normal, in the coordinates of the
|
||||
/// body it was found on.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct PrintFace {
|
||||
/// The face's index on the body (its first piece, when a change split it).
|
||||
pub index: usize,
|
||||
pub point: Vec3,
|
||||
pub normal: Vec3,
|
||||
}
|
||||
|
||||
impl Document {
|
||||
/// The target that marks flat face `index` of `body` as its print face.
|
||||
pub fn print_face_target(&self, body: &ModelBody, index: usize) -> Result<ConfigFaceTarget> {
|
||||
if body.body.is_mesh() {
|
||||
return Err(DocError::Invalid("not supported yet: a print face on a mesh body".into()));
|
||||
}
|
||||
if body.body.planar_face(index).is_none() {
|
||||
return Err(DocError::Invalid("only a flat face can be the print face".into()));
|
||||
}
|
||||
// The sketch-on-a-face wording ("choose a fixed plane") offers what a print face has not.
|
||||
self.flat_face_target(body, index).map_err(|_| {
|
||||
DocError::Invalid(
|
||||
"this face can't be the print face: the body's history no longer tells it apart from its other faces (as after a shell of a shell body); pick a face of another body, or edit the feature that reshaped it".into(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Where `body`'s print face is now. `None`: it has none. An error: the face can't be found
|
||||
/// any more, or is no longer flat.
|
||||
pub fn print_face(&self, state: &ModelState, body: &ModelBody) -> Option<Result<PrintFace>> {
|
||||
let target = self.print_faces.get(body.definition_name())?;
|
||||
Some(self.locate_print_face(state, body, target))
|
||||
}
|
||||
|
||||
/// The print face a copy of `source` gets (Move/Copy, Mirror): the face of `copy` named after
|
||||
/// `source`'s print face (a copy's faces carry their source's names, followed by the copy's
|
||||
/// instance, `F1:+x@F2.1`). `None`:
|
||||
/// `source` has no print face.
|
||||
pub fn copied_print_face(&self, state: &ModelState, source: &ModelBody, copy: &ModelBody) -> Option<Result<ConfigFaceTarget>> {
|
||||
let target = self.print_faces.get(source.definition_name())?;
|
||||
let found = || {
|
||||
let (indices, _) = self.anchored_face_indices(state, source, target)?;
|
||||
let first = indices.first().copied().ok_or_else(|| DocError::Unknown("the print face no longer exists".into()))?;
|
||||
let names = crate::naming::face_names(source);
|
||||
let name =
|
||||
names.get(first).map(|n| crate::naming::strip_piece(n)).ok_or_else(|| DocError::Unknown("the print face has no name".into()))?;
|
||||
let index = crate::naming::face_names(copy)
|
||||
.iter()
|
||||
.position(|n| crate::naming::strip_piece(without_last_instance(n)) == name)
|
||||
.ok_or_else(|| DocError::Unknown(format!("the copy has no face `{name}`")))?;
|
||||
self.print_face_target(copy, index)
|
||||
};
|
||||
Some(found())
|
||||
}
|
||||
|
||||
fn locate_print_face(&self, state: &ModelState, body: &ModelBody, target: &ConfigFaceTarget) -> Result<PrintFace> {
|
||||
if body.body.is_mesh() {
|
||||
return Err(DocError::Invalid("not supported yet: a print face on a mesh body".into()));
|
||||
}
|
||||
let (indices, _) = self.anchored_face_indices(state, body, target)?;
|
||||
let first = indices.first().copied().ok_or_else(|| DocError::Unknown("the print face no longer exists".into()))?;
|
||||
let plane = body.body.planar_face(first).ok_or_else(|| DocError::Invalid("the print face is no longer flat".into()))?;
|
||||
let scale = 1. + body.body.size();
|
||||
for index in indices.iter().skip(1) {
|
||||
let other = body.body.planar_face(*index).ok_or_else(|| DocError::Invalid("the print face is no longer flat".into()))?;
|
||||
if plane.normal().dot(other.normal()).abs() < 1. - 1e-8 || (other.origin - plane.origin).dot(plane.normal()).abs() > 1e-7 * scale {
|
||||
return Err(DocError::Invalid("the print face's pieces no longer lie on one plane".into()));
|
||||
}
|
||||
}
|
||||
// The surface's own orientation is how the kernel built it, so the side the material is
|
||||
// on is taken from the face's triangles, which point out of the body.
|
||||
let mesh = body.mesh();
|
||||
let mut area = Vec3::ZERO;
|
||||
for (t, f) in mesh.triangles.iter().zip(&mesh.tri_face) {
|
||||
if let (true, Some([a, b, c])) = (indices.contains(&(*f as usize)), mesh.tri(t)) {
|
||||
area += (b - a).cross(c - a);
|
||||
}
|
||||
}
|
||||
let normal = plane.normal().normalized().ok_or_else(|| DocError::Invalid("the print face's plane is degenerate".into()))?;
|
||||
let outward = area.dot(normal);
|
||||
if !(outward.abs() > 0.) {
|
||||
return Err(DocError::Invalid("the print face has no surface to lie on".into()));
|
||||
}
|
||||
Ok(PrintFace { index: first, point: plane.origin, normal: if outward < 0. { -normal } else { normal } })
|
||||
}
|
||||
}
|
||||
|
||||
/// A face name without the copy instance at its end (`F1:+x@F2.1` is `F1:+x`; a copy of a copy,
|
||||
/// `F1:+x@F2.1@F5.1`, is `F1:+x@F2.1`).
|
||||
fn without_last_instance(n: &str) -> &str {
|
||||
let Some(at) = n.rfind('@') else { return n };
|
||||
let instance = n.get(at + 1..).and_then(|t| t.strip_prefix('F')).and_then(|t| t.split_once('.'));
|
||||
let digits = |t: &str| !t.is_empty() && t.bytes().all(|b| b.is_ascii_digit());
|
||||
if instance.is_some_and(|(feature, k)| digits(feature) && digits(k)) { n.get(..at).unwrap_or(n) } else { n }
|
||||
}
|
||||
@@ -1892,6 +1892,7 @@ fn move_body_feature(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
)?;
|
||||
if copy {
|
||||
copy_keeps_appearance(s, &reply, &bodies, cmd)?;
|
||||
super::print_face::copies_keep_print_faces(s, &reply, &bodies);
|
||||
}
|
||||
Ok(reply)
|
||||
}
|
||||
@@ -2098,7 +2099,12 @@ fn mirror(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let plane = plane_param(s, p.get("plane"), cmd)?;
|
||||
let combine = bool_(p, "combine").unwrap_or(false);
|
||||
let (bodies, placements) = placed_bodies(s, bodies, cmd)?;
|
||||
add_feature(s, p, FeatureKind::Mirror { features, plane, bodies: bodies.into_iter().map(BodyName).collect(), combine, placements })
|
||||
let reply =
|
||||
add_feature(s, p, FeatureKind::Mirror { features, plane, bodies: bodies.iter().cloned().map(BodyName).collect(), combine, placements })?;
|
||||
if !combine {
|
||||
super::print_face::copies_keep_print_faces(s, &reply, &bodies);
|
||||
}
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Bodies picked where the viewport shows them: each world name ("Body1", or "Body1 (Occ:2)"
|
||||
|
||||
@@ -18,6 +18,7 @@ use solidcraft_doc::Document;
|
||||
use solidcraft_io::Format;
|
||||
|
||||
use super::CommandSpec;
|
||||
use super::print_face;
|
||||
use crate::params::{bad, bool_, num, str_, string_list};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
@@ -694,6 +695,26 @@ fn export_to(
|
||||
Ok(json!({"path": path, "bytes": bytes.len(), "format": format!("{format:?}")}))
|
||||
}
|
||||
|
||||
/// [`export_to`] for a mesh file a slicer is sent (STL or 3MF): each body laid on its print face.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn export_laid_to(
|
||||
s: &Session,
|
||||
path: &str,
|
||||
format: Format,
|
||||
bodies: &[String],
|
||||
parts: &[(String, Vec<String>)],
|
||||
quality: solidcraft_io::MeshQuality,
|
||||
) -> Result<Value> {
|
||||
let name = std::path::Path::new(path).file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_else(|| s.doc.name.clone());
|
||||
let mut state = s.doc.painted(&s.world_state());
|
||||
let laid = print_face::lay_on_print_faces(s, &mut state, bodies, parts);
|
||||
let bytes = solidcraft_io::export_with_parts(&state, bodies, parts, format, &name, &s.doc.metadata, quality)?;
|
||||
solidcraft_io::vfs::write(path, &bytes).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
|
||||
let mut out = json!({"path": path, "bytes": bytes.len(), "format": format!("{format:?}")});
|
||||
laid.report(&mut out);
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn export(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "file.export";
|
||||
let path = path_arg(p, cmd)?;
|
||||
|
||||
@@ -19,10 +19,12 @@ pub(super) struct Exported {
|
||||
pub fell_back: bool,
|
||||
/// The bodies that went in: the ones named, else the selected ones.
|
||||
pub bodies: Vec<String>,
|
||||
/// The bodies laid on their print face, and the ones that couldn't be.
|
||||
pub laid: super::print_face::Laid,
|
||||
}
|
||||
|
||||
/// Export the bodies (the selected ones when none are named). A 3MF that can't be written is
|
||||
/// written as an STL, and `fell_back` says so.
|
||||
/// Export the bodies (the selected ones when none are named), each laid on its print face. A
|
||||
/// 3MF that can't be written is written as an STL, and `fell_back` says so.
|
||||
pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Format) -> Result<Exported> {
|
||||
let mut bodies = named.to_vec();
|
||||
if bodies.is_empty() {
|
||||
@@ -31,7 +33,8 @@ pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Fo
|
||||
if bodies.is_empty() {
|
||||
return Err(bad(cmd, "select the bodies to send, or give `bodies`"));
|
||||
}
|
||||
let doc = s.doc.painted(&s.world_state());
|
||||
let mut doc = s.doc.painted(&s.world_state());
|
||||
let laid = super::print_face::lay_on_print_faces(s, &mut doc, &bodies, &[]);
|
||||
let write = |format| solidcraft_io::export_with_metadata(&doc, &bodies, format, &s.doc.name, &s.doc.metadata);
|
||||
let mut fell_back = false;
|
||||
let (bytes, ext) = match (format, write(format)) {
|
||||
@@ -42,7 +45,7 @@ pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Fo
|
||||
}
|
||||
(_, Err(e)) => return Err(e.into()),
|
||||
};
|
||||
Ok(Exported { bytes, ext, fell_back, bodies })
|
||||
Ok(Exported { bytes, ext, fell_back, bodies, laid })
|
||||
}
|
||||
|
||||
pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
@@ -56,7 +59,7 @@ pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !bool_(p, "consent").unwrap_or(false) {
|
||||
return Err(bad(cmd, "this uploads the model to Printables' servers: ask the user, then pass `consent: true`"));
|
||||
}
|
||||
let Exported { bytes, ext, fell_back, .. } = export_bodies(s, cmd, &string_list(cmd, p, "bodies")?, format)?;
|
||||
let Exported { bytes, ext, fell_back, laid, .. } = export_bodies(s, cmd, &string_list(cmd, p, "bodies")?, format)?;
|
||||
if bytes.len() > MAX_BYTES {
|
||||
let mb = bytes.len().div_ceil(1_000_000);
|
||||
return Err(bad(cmd, format!("the model is {mb} MB and EasyPrint takes {} MB at most: send fewer bodies", MAX_BYTES / 1_000_000)));
|
||||
@@ -64,5 +67,7 @@ pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let name = easyprint::file_name(&s.doc.name, ext);
|
||||
let size = bytes.len();
|
||||
upload(&name, bytes).map_err(|e| bad(cmd, e))?;
|
||||
Ok(json!({"file_name": name, "bytes": size, "format": ext, "stl_fallback": fell_back, "uploading": true}))
|
||||
let mut out = json!({"file_name": name, "bytes": size, "format": ext, "stl_fallback": fell_back, "uploading": true});
|
||||
laid.report(&mut out);
|
||||
Ok(out)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ use serde_json::{Value, json};
|
||||
use solidcraft_io::Format;
|
||||
|
||||
use super::easyprint::{Exported, export_bodies};
|
||||
use super::export_to;
|
||||
use super::export_laid_to;
|
||||
use crate::params::bad;
|
||||
use crate::slicers::{self, Slicer, TargetKind};
|
||||
use crate::{EngineError, Result, Session};
|
||||
@@ -81,7 +81,7 @@ pub(super) fn send(s: &mut Session, r: Send<'_>) -> Result<Value> {
|
||||
return Err(bad(r.cmd, format!("{} does not take {}", target.name, format_name(r.format))));
|
||||
}
|
||||
let mut out = match r.dest {
|
||||
Dest::Path(path) => export_to(s, path, r.format, &r.bodies, &r.parts, r.quality)?,
|
||||
Dest::Path(path) => export_laid_to(s, path, r.format, &r.bodies, &r.parts, r.quality)?,
|
||||
Dest::Folder => write_in_folder(s, &r)?,
|
||||
};
|
||||
let path = out.get("path").and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
@@ -92,11 +92,13 @@ pub(super) fn send(s: &mut Session, r: Send<'_>) -> Result<Value> {
|
||||
/// Write the bodies into the slicer folder.
|
||||
fn write_in_folder(s: &mut Session, r: &Send<'_>) -> Result<Value> {
|
||||
use crate::slicer_files;
|
||||
let Exported { bytes, ext, fell_back, bodies } = export_bodies(s, r.cmd, &r.bodies, r.format)?;
|
||||
let Exported { bytes, ext, fell_back, bodies, laid } = export_bodies(s, r.cmd, &r.bodies, r.format)?;
|
||||
let dir = slicer_files::dir().ok_or_else(|| bad(r.cmd, "no per-user folder on this system"))?;
|
||||
let stem = slicer_files::stem(&s.doc.name, s.path.as_deref(), s.uid, &bodies);
|
||||
let (file, numbered) = slicer_files::write(&dir, &stem, ext, &bytes).map_err(|e| EngineError::Other(format!("{}: {e}", dir.display())))?;
|
||||
Ok(json!({"path": file.to_string_lossy(), "bytes": bytes.len(), "format": ext, "numbered": numbered, "stl_fallback": fell_back}))
|
||||
let mut out = json!({"path": file.to_string_lossy(), "bytes": bytes.len(), "format": ext, "numbered": numbered, "stl_fallback": fell_back});
|
||||
laid.report(&mut out);
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Hand the file at `path` to `target`, starting it first if it has to be, and say what happened in
|
||||
|
||||
@@ -78,6 +78,7 @@ mod kernel_heal_tests;
|
||||
mod parameter_sweep;
|
||||
mod parameters;
|
||||
mod plastic;
|
||||
mod print_face;
|
||||
mod render;
|
||||
mod render_ui;
|
||||
#[cfg(test)]
|
||||
@@ -332,6 +333,7 @@ pub fn command_specs() -> Vec<&'static CommandSpec> {
|
||||
v.extend(parameters::COMMANDS.iter());
|
||||
v.extend(parameter_sweep::COMMANDS.iter());
|
||||
v.extend(file::COMMANDS.iter());
|
||||
v.extend(print_face::COMMANDS.iter());
|
||||
v.extend(metadata::COMMANDS.iter());
|
||||
v.extend(inspect::COMMANDS.iter());
|
||||
v.extend(compare::COMMANDS.iter());
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
//! Laying bodies on their print face for a slicer (#8429). The bodies being sent are copied (the
|
||||
//! state the export writes is already a copy), and each copy whose body has a print face is
|
||||
//! turned so the face points down, its centre of mass moved onto the world origin in X and Y,
|
||||
//! and the face moved onto Z = 0: one rigid transform, applied once. The design and its timeline
|
||||
//! are not touched. Each body is placed on its own, so several land on the origin together and
|
||||
//! the slicer arranges them.
|
||||
|
||||
use serde_json::Value;
|
||||
use solidcraft_doc::{ModelState, PrintFace};
|
||||
use solidcraft_geom::Vec3;
|
||||
|
||||
use super::CommandSpec;
|
||||
use crate::params::{bad, str_};
|
||||
use crate::schema::print_face::PrintFaceResult;
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
pub static COMMANDS: &[CommandSpec] = &[CommandSpec::new("body.print_face", "Print Face", crate::checked!("body.print_face", print_face))
|
||||
.icon("print_face")
|
||||
.key("Ctrl+B")
|
||||
.contract(&PRINT_FACE_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<PrintFaceResult>)
|
||||
.params("body: its name; point?: [x, y, z] on a flat face of it, in mm (omit to clear) → {body, face?}: marks the face a slicer export (file.send_to_slicer, file.save_mesh with slicer, file.open_in_easyprint) lays the body on: turned so the face points down at Z = 0, the centre of mass over the origin. One per body, replacing the last; flat faces of solid bodies only. A print face that is gone or no longer flat is reported in the export's warnings, and the body exported as it lies")];
|
||||
|
||||
const PRINT_FACE_CONTRACT: crate::schema::TypedContract<crate::schema::print_face::PrintFaceParams> = crate::schema::TypedContract::new();
|
||||
|
||||
/// Mark or clear a body's print face.
|
||||
fn print_face(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "body.print_face";
|
||||
let name = str_(p, "body").ok_or_else(|| bad(cmd, "give `body`"))?;
|
||||
let point = match p.get("point") {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(v) => Some(crate::params::vec3(v).ok_or_else(|| bad(cmd, "`point` must be [x, y, z] of numbers"))?),
|
||||
};
|
||||
let world = s.world_state();
|
||||
let body = world.body(name).ok_or_else(|| bad(cmd, format!("no body `{name}`")))?;
|
||||
let key = body.definition_name().to_string();
|
||||
let face = match point {
|
||||
None => {
|
||||
s.doc_mut().print_faces.remove(&key);
|
||||
None
|
||||
}
|
||||
Some(point) => {
|
||||
let index = solidcraft_doc::appearance::face_index_at(body, point).ok_or_else(|| bad(cmd, "no face of the body at `point`"))?;
|
||||
let target = s.doc.print_face_target(body, index).map_err(|e| bad(cmd, e.to_string()))?;
|
||||
let face = target.name.clone();
|
||||
s.doc_mut().print_faces.insert(key, target);
|
||||
Some(face)
|
||||
}
|
||||
};
|
||||
let reply = PrintFaceResult { body: name.to_string(), face, param_warnings: Vec::new() };
|
||||
serde_json::to_value(reply).map_err(|e| EngineError::Other(e.to_string()))
|
||||
}
|
||||
|
||||
/// Which bodies were laid on their print face, and a warning for each that has one but was
|
||||
/// exported as it lies.
|
||||
#[derive(Debug, Default)]
|
||||
pub(super) struct Laid {
|
||||
pub bodies: Vec<String>,
|
||||
pub warnings: Vec<String>,
|
||||
}
|
||||
|
||||
impl Laid {
|
||||
/// Add what happened to an export's reply.
|
||||
pub(super) fn report(self, out: &mut serde_json::Value) {
|
||||
let Some(obj) = out.as_object_mut() else { return };
|
||||
if !self.bodies.is_empty() {
|
||||
obj.insert("print_faces".into(), serde_json::json!(self.bodies));
|
||||
}
|
||||
if !self.warnings.is_empty() {
|
||||
obj.insert("warnings".into(), serde_json::json!(self.warnings));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Copies keep the print faces of the bodies they were made from (Move/Copy, Mirror), as they
|
||||
/// keep their look: the copies are the bodies feature `reply` made, in the order of `sources`.
|
||||
/// A copy whose face can't be matched is left without one.
|
||||
pub(super) fn copies_keep_print_faces(s: &mut Session, reply: &Value, sources: &[String]) {
|
||||
let Some(id) = reply.get("feature").and_then(Value::as_u64) else { return };
|
||||
let state = s.model.state();
|
||||
let copies: Vec<_> = state.bodies.iter().filter(|b| b.feature == id).collect();
|
||||
if copies.len() != sources.len() {
|
||||
return;
|
||||
}
|
||||
let mut inherited = Vec::new();
|
||||
for (source, copy) in sources.iter().zip(copies) {
|
||||
let Some(source) = state.body(source) else { continue };
|
||||
if let Some(Ok(target)) = s.doc.copied_print_face(&state, source, copy) {
|
||||
inherited.push((copy.definition_name().to_string(), target));
|
||||
}
|
||||
}
|
||||
for (body, target) in inherited {
|
||||
s.doc_mut().print_faces.insert(body, target);
|
||||
}
|
||||
}
|
||||
|
||||
/// Lay the bodies of `state` named in `bodies` (all of them when it is empty) on their print faces.
|
||||
/// A body that is one of several parts of a 3MF object (`parts`, `objects: component`) stays as it
|
||||
/// lies, so the object keeps its shape: turning one part on its own would pull it out of the rest.
|
||||
pub(super) fn lay_on_print_faces(s: &Session, state: &mut ModelState, bodies: &[String], parts: &[(String, Vec<String>)]) -> Laid {
|
||||
let mut laid = Laid::default();
|
||||
let mut moves = Vec::new();
|
||||
for (i, b) in state.bodies.iter().enumerate() {
|
||||
if !bodies.is_empty() && !bodies.contains(&b.name) {
|
||||
continue;
|
||||
}
|
||||
if let Some((object, _)) = parts.iter().find(|(_, members)| members.contains(&b.name)) {
|
||||
if s.doc.print_faces.contains_key(b.definition_name()) {
|
||||
laid.warnings.push(format!("`{}` was exported as it lies: it is a part of the object `{object}`, which keeps its shape", b.name));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let face = match s.doc.print_face(state, b) {
|
||||
None => continue,
|
||||
Some(Ok(face)) => face,
|
||||
Some(Err(e)) => {
|
||||
laid.warnings.push(format!("`{}` was exported as it lies: {e}", b.name));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let centre = match solidcraft_kernel::measure_mass(&b.body) {
|
||||
Ok(m) => m.centroid,
|
||||
Err(e) => {
|
||||
laid.warnings.push(format!("`{}` was exported as it lies: no centre of mass ({e})", b.name));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
moves.push((i, bed_matrix(face, centre)));
|
||||
}
|
||||
for (i, m) in moves {
|
||||
let Some(b) = state.bodies.get_mut(i) else { continue };
|
||||
match solidcraft_kernel::transform_matrix(&b.body, m) {
|
||||
Ok(body) => {
|
||||
b.body = body;
|
||||
laid.bodies.push(b.name.clone());
|
||||
}
|
||||
Err(e) => laid.warnings.push(format!("`{}` was exported as it lies: {e}", b.name)),
|
||||
}
|
||||
}
|
||||
laid
|
||||
}
|
||||
|
||||
/// The rotation (rows) that turns unit vector `n` to −Z. A face that already points down is
|
||||
/// left as it is; one that points straight up is turned half a turn about X.
|
||||
fn turn_down(n: Vec3) -> [Vec3; 3] {
|
||||
let down = Vec3::new(0., 0., -1.);
|
||||
let c = n.dot(down);
|
||||
let v = n.cross(down);
|
||||
let s2 = v.len2();
|
||||
if s2 <= 1e-24 {
|
||||
return if c > 0. { [Vec3::X, Vec3::Y, Vec3::Z] } else { [Vec3::X, -Vec3::Y, -Vec3::Z] };
|
||||
}
|
||||
// Rodrigues: R e = e + v × e + v × (v × e) (1 − c) / |v|²; these are R's columns.
|
||||
let k = (1. - c) / s2;
|
||||
let [x, y, z] = [Vec3::X, Vec3::Y, Vec3::Z].map(|e| e + v.cross(e) + v.cross(v.cross(e)) * k);
|
||||
[Vec3::new(x.x, y.x, z.x), Vec3::new(x.y, y.y, z.y), Vec3::new(x.z, y.z, z.z)]
|
||||
}
|
||||
|
||||
/// The column-major transform that lays `face` on the bed with `centre` above the origin.
|
||||
fn bed_matrix(face: PrintFace, centre: Vec3) -> [[f64; 4]; 4] {
|
||||
let r = turn_down(face.normal);
|
||||
let apply = |p: Vec3| Vec3::new(r[0].dot(p), r[1].dot(p), r[2].dot(p));
|
||||
let c = apply(centre);
|
||||
let z = apply(face.point).z;
|
||||
let t = Vec3::new(-c.x, -c.y, -z);
|
||||
[[r[0].x, r[1].x, r[2].x, 0.], [r[0].y, r[1].y, r[2].y, 0.], [r[0].z, r[1].z, r[2].z, 0.], [t.x, t.y, t.z, 1.]]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
fn run(s: &mut Session, id: &str, p: Value) -> Value {
|
||||
match s.execute(id, &p) {
|
||||
Ok(v) => v,
|
||||
Err(e) => panic!("{id} {p}: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A box `L` x 10 x 5 (L = 20 mm) from the origin, called Block.
|
||||
fn block() -> Session {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "parameters.add", json!({"name": "L", "expression": "20 mm"}));
|
||||
run(&mut s, "solid.box", json!({"length": "L", "width": 10, "height": 5, "corner": [0, 0, 0], "body_name": "Block"}));
|
||||
s
|
||||
}
|
||||
|
||||
/// Lay every body of `s` on its print face, as a slicer export does: Block's box and centre
|
||||
/// of mass afterwards, and what was reported.
|
||||
fn laid(s: &Session) -> (solidcraft_geom::Aabb3, Vec3, Laid) {
|
||||
let mut state = s.doc.painted(&s.world_state());
|
||||
let laid = lay_on_print_faces(s, &mut state, &[], &[]);
|
||||
let block = state.bodies.iter().find(|b| b.name == "Block").expect("Block");
|
||||
let m = solidcraft_kernel::measure_mass(&block.body).expect("measure");
|
||||
(m.bbox, m.centroid, laid)
|
||||
}
|
||||
|
||||
fn near(a: f64, b: f64) -> bool {
|
||||
(a - b).abs() < 1e-6
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_part_of_a_3mf_object_keeps_its_place_in_the_object() {
|
||||
// With `objects: component` the bodies of a component are the parts of one object:
|
||||
// turning one of them on its own would pull it out of the others, so it stays as it lies.
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]}));
|
||||
let mut state = s.doc.painted(&s.world_state());
|
||||
let parts = [("Bracket".to_string(), vec!["Block".to_string(), "Other".to_string()])];
|
||||
let laid = lay_on_print_faces(&s, &mut state, &[], &parts);
|
||||
assert!(laid.bodies.is_empty(), "{:?}", laid.bodies);
|
||||
assert_eq!(laid.warnings.len(), 1, "{:?}", laid.warnings);
|
||||
assert!(laid.warnings.first().is_some_and(|w| w.contains("Block") && w.contains("Bracket")), "{:?}", laid.warnings);
|
||||
let block = state.bodies.iter().find(|b| b.name == "Block").expect("Block");
|
||||
let bbox = solidcraft_kernel::measure_mass(&block.body).expect("measure").bbox;
|
||||
assert!(near(bbox.min.x, 0.) && near(bbox.max.x, 20.) && near(bbox.max.z, 5.), "{bbox:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_side_face_is_laid_down_at_z_0_with_the_centre_of_mass_over_the_origin() {
|
||||
let mut s = block();
|
||||
let reply = run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]}));
|
||||
assert!(reply["face"].is_string(), "{reply}");
|
||||
let (bbox, centre, laid) = laid(&s);
|
||||
assert_eq!(laid.bodies, ["Block"]);
|
||||
assert!(laid.warnings.is_empty(), "{:?}", laid.warnings);
|
||||
// The 10 x 5 end face is on the bed, so the 20 mm length now stands up.
|
||||
assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 20.), "{bbox:?}");
|
||||
assert!(near(centre.x, 0.) && near(centre.y, 0.) && near(centre.z, 10.), "{centre:?}");
|
||||
assert!(near((bbox.max.x - bbox.min.x) * (bbox.max.y - bbox.min.y), 50.), "{bbox:?}");
|
||||
// The design itself has not moved.
|
||||
let m = solidcraft_kernel::measure_mass(&s.model.state().bodies[0].body).expect("measure");
|
||||
assert!(near(m.bbox.min.x, 0.) && near(m.bbox.max.x, 20.) && near(m.bbox.max.z, 5.), "{:?}", m.bbox);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_face_that_points_up_is_turned_over() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]}));
|
||||
let (bbox, centre, laid) = laid(&s);
|
||||
assert_eq!(laid.bodies, ["Block"]);
|
||||
assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 5.), "{bbox:?}");
|
||||
assert!(near(bbox.max.x - bbox.min.x, 20.) && near(bbox.max.y - bbox.min.y, 10.), "{bbox:?}");
|
||||
assert!(near(centre.x, 0.) && near(centre.y, 0.) && near(centre.z, 2.5), "{centre:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_print_face_follows_the_body_through_a_rebuild() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]}));
|
||||
run(&mut s, "parameters.change", json!({"name": "L", "expression": "30 mm"}));
|
||||
let (bbox, centre, laid) = laid(&s);
|
||||
assert!(laid.warnings.is_empty(), "{:?}", laid.warnings);
|
||||
assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 30.), "{bbox:?}");
|
||||
assert!(near(centre.x, 0.) && near(centre.y, 0.) && near(centre.z, 15.), "{centre:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_a_print_face_the_body_is_exported_as_it_lies() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]}));
|
||||
let reply = run(&mut s, "body.print_face", json!({"body": "Block"}));
|
||||
assert!(reply.get("face").is_none(), "{reply}");
|
||||
assert!(s.doc.print_faces.is_empty());
|
||||
let (bbox, _, laid) = laid(&s);
|
||||
assert!(laid.bodies.is_empty() && laid.warnings.is_empty());
|
||||
assert!(near(bbox.min.x, 0.) && near(bbox.max.x, 20.) && near(bbox.min.z, 0.) && near(bbox.max.z, 5.), "{bbox:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_print_face_that_was_cut_away_is_reported_and_the_body_exported_as_it_lies() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]}));
|
||||
// A cut takes the top 2 mm off: the marked face is gone; the new top is the cut's.
|
||||
run(&mut s, "solid.box", json!({"length": 30, "width": 20, "height": 5, "corner": [-5, -5, 3], "operation": "cut"}));
|
||||
let (bbox, _, laid) = laid(&s);
|
||||
assert!(laid.bodies.is_empty());
|
||||
assert_eq!(laid.warnings.len(), 1, "{:?}", laid.warnings);
|
||||
assert!(laid.warnings[0].contains("Block"), "{:?}", laid.warnings);
|
||||
assert!(near(bbox.min.x, 0.) && near(bbox.max.z, 3.), "{bbox:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_print_face_is_saved_with_the_design_and_an_older_design_has_none() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]}));
|
||||
let saved = serde_json::to_value(&*s.doc).expect("save");
|
||||
assert!(saved["print_faces"]["Block"].is_object(), "{}", saved["print_faces"]);
|
||||
let opened: solidcraft_doc::Document = serde_json::from_value(saved.clone()).expect("open");
|
||||
assert_eq!(opened.print_faces, s.doc.print_faces);
|
||||
let mut older = saved;
|
||||
older.as_object_mut().expect("object").remove("print_faces");
|
||||
let opened: solidcraft_doc::Document = serde_json::from_value(older).expect("open");
|
||||
assert!(opened.print_faces.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renaming_the_body_keeps_its_print_face() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]}));
|
||||
run(&mut s, "body.rename", json!({"body": "Block", "name": "Lid"}));
|
||||
assert!(s.doc.print_faces.contains_key("Lid") && !s.doc.print_faces.contains_key("Block"));
|
||||
assert_eq!(s.doc.print_faces["Lid"].body, "Lid");
|
||||
}
|
||||
|
||||
/// Every body laid on its print face: (name, box, centre of mass) of those laid.
|
||||
fn all_laid(s: &Session) -> Vec<(String, solidcraft_geom::Aabb3, Vec3)> {
|
||||
let mut state = s.doc.painted(&s.world_state());
|
||||
let laid = lay_on_print_faces(s, &mut state, &[], &[]);
|
||||
assert!(laid.warnings.is_empty(), "{:?}", laid.warnings);
|
||||
laid.bodies
|
||||
.iter()
|
||||
.map(|name| {
|
||||
let b = state.bodies.iter().find(|b| &b.name == name).expect("laid body");
|
||||
let m = solidcraft_kernel::measure_mass(&b.body).expect("measure");
|
||||
(name.clone(), m.bbox, m.centroid)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_copy_keeps_the_print_face_of_the_body_it_was_copied_from() {
|
||||
let mut s = block();
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]}));
|
||||
run(&mut s, "solid.move", json!({"bodies": ["Block"], "translate": [0, 50, 0], "copy": true}));
|
||||
assert_eq!(s.doc.print_faces.len(), 2, "{:?}", s.doc.print_faces.keys().collect::<Vec<_>>());
|
||||
let laid = all_laid(&s);
|
||||
assert_eq!(laid.len(), 2, "{laid:?}");
|
||||
for (name, bbox, centre) in &laid {
|
||||
assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 20.), "{name}: {bbox:?}");
|
||||
assert!(near(centre.x, 0.) && near(centre.y, 0.), "{name}: {centre:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mirrored_copy_keeps_the_mirrored_print_face() {
|
||||
let mut s = block();
|
||||
// The end at X = 20; its mirror image in YZ is the copy's end at X = -20.
|
||||
run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]}));
|
||||
run(&mut s, "solid.mirror", json!({"bodies": ["Block"], "plane": "YZ"}));
|
||||
assert_eq!(s.doc.print_faces.len(), 2, "{:?}", s.doc.print_faces.keys().collect::<Vec<_>>());
|
||||
let copy = s.doc.print_faces.keys().find(|k| *k != "Block").expect("the copy's print face").clone();
|
||||
let world = s.world_state();
|
||||
let body = world.body(©).expect("copy");
|
||||
let face = s.doc.print_face(&world, body).expect("marked").expect("found");
|
||||
assert!(near(face.point.x, -20.) && near(face.normal.x, -1.), "{face:?}");
|
||||
let laid = all_laid(&s);
|
||||
assert_eq!(laid.len(), 2, "{laid:?}");
|
||||
for (name, bbox, _) in &laid {
|
||||
assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 20.), "{name}: {bbox:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_copy_of_a_body_without_a_print_face_gets_none() {
|
||||
let mut s = block();
|
||||
run(&mut s, "solid.move", json!({"bodies": ["Block"], "translate": [0, 50, 0], "copy": true}));
|
||||
run(&mut s, "solid.mirror", json!({"bodies": ["Block"], "plane": "XZ"}));
|
||||
assert!(s.doc.print_faces.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_point_off_the_body_or_a_body_that_is_not_there_is_refused() {
|
||||
let mut s = block();
|
||||
assert!(s.execute("body.print_face", &json!({"body": "Block", "point": [100, 100, 100]})).is_err());
|
||||
assert!(s.execute("body.print_face", &json!({"body": "Nope", "point": [10, 5, 5]})).is_err());
|
||||
assert!(s.execute("body.print_face", &json!({"body": "Block", "point": "top"})).is_err());
|
||||
assert!(s.doc.print_faces.is_empty());
|
||||
}
|
||||
|
||||
fn turned(n: Vec3) -> Vec3 {
|
||||
let r = turn_down(n);
|
||||
Vec3::new(r[0].dot(n), r[1].dot(n), r[2].dot(n))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_normal_is_turned_to_point_down_by_a_rotation() {
|
||||
let down = Vec3::new(0., 0., -1.);
|
||||
for n in [Vec3::X, -Vec3::X, Vec3::Y, -Vec3::Y, Vec3::Z, -Vec3::Z, Vec3::new(1., 2., 3.), Vec3::new(-0.3, 0.1, 0.9), Vec3::new(1e-9, 0., 1.)]
|
||||
{
|
||||
let n = n.normalized().unwrap();
|
||||
assert!(turned(n).dist(down) < 1e-12, "{n:?} → {:?}", turned(n));
|
||||
let r = turn_down(n);
|
||||
// Orthonormal rows with a positive determinant: a rotation, never a mirror.
|
||||
for i in 0..3 {
|
||||
assert!((r[i].len() - 1.).abs() < 1e-12);
|
||||
for j in i + 1..3 {
|
||||
assert!(r[i].dot(r[j]).abs() < 1e-12);
|
||||
}
|
||||
}
|
||||
assert!((r[0].cross(r[1]).dot(r[2]) - 1.).abs() < 1e-12);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_face_that_points_straight_up_is_turned_half_a_turn_about_x() {
|
||||
let r = turn_down(Vec3::Z);
|
||||
assert_eq!(r, [Vec3::X, -Vec3::Y, -Vec3::Z]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bed_matrix_puts_the_face_at_z_0_and_the_centre_over_the_origin() {
|
||||
let face = PrintFace { index: 0, point: Vec3::new(3., 4., 10.), normal: Vec3::Z };
|
||||
let m = bed_matrix(face, Vec3::new(3., 4., 5.));
|
||||
let apply = |p: Vec3| {
|
||||
Vec3::new(
|
||||
m[0][0] * p.x + m[1][0] * p.y + m[2][0] * p.z + m[3][0],
|
||||
m[0][1] * p.x + m[1][1] * p.y + m[2][1] * p.z + m[3][1],
|
||||
m[0][2] * p.x + m[1][2] * p.y + m[2][2] * p.z + m[3][2],
|
||||
)
|
||||
};
|
||||
assert!(apply(face.point).z.abs() < 1e-12);
|
||||
let c = apply(Vec3::new(3., 4., 5.));
|
||||
assert!(c.x.abs() < 1e-12 && c.y.abs() < 1e-12 && c.z > 0., "{c:?}");
|
||||
}
|
||||
}
|
||||
@@ -1976,6 +1976,7 @@ fn same_but_features(a: &Document, b: &Document) -> bool {
|
||||
point_clouds,
|
||||
param_comments,
|
||||
materials,
|
||||
print_faces,
|
||||
user_materials,
|
||||
appearances,
|
||||
body_components,
|
||||
@@ -2011,6 +2012,7 @@ fn same_but_features(a: &Document, b: &Document) -> bool {
|
||||
&& *point_clouds == b.point_clouds
|
||||
&& *param_comments == b.param_comments
|
||||
&& *materials == b.materials
|
||||
&& *print_faces == b.print_faces
|
||||
&& *user_materials == b.user_materials
|
||||
&& *appearances == b.appearances
|
||||
&& *body_components == b.body_components
|
||||
|
||||
@@ -59,6 +59,7 @@ pub mod construct;
|
||||
pub mod edit;
|
||||
pub mod features;
|
||||
pub mod inspect;
|
||||
pub mod print_face;
|
||||
pub mod render;
|
||||
pub mod render_lights;
|
||||
pub mod render_ui;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//! Contracts and result types for the commands in `cmd/print_face.rs`.
|
||||
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::types::Point3;
|
||||
|
||||
/// Mark the flat face of a body at a point as the body's print face, or clear it. A slicer
|
||||
/// export (`file.send_to_slicer`, `file.save_mesh` with `slicer`, `file.open_in_easyprint`) lays
|
||||
/// the body on its print face: turned so the face points down and lies at Z = 0, the centre of
|
||||
/// mass over the origin. A body has one print face at most; marking another replaces it.
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct PrintFaceParams {
|
||||
/// The body, by name. Solid bodies only: a mesh body can't have a print face yet.
|
||||
pub body: String,
|
||||
/// A point on the flat face to mark, in mm. Default: none, which clears the body's print face.
|
||||
#[serde(default)]
|
||||
pub point: Option<Point3>,
|
||||
}
|
||||
|
||||
/// What `body.print_face` returns.
|
||||
#[derive(Debug, Serialize, JsonSchema)]
|
||||
pub struct PrintFaceResult {
|
||||
/// The body.
|
||||
pub body: String,
|
||||
/// The persistent name of the face now marked. Absent when the print face was cleared.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub face: Option<String>,
|
||||
/// In the warn parameter-check mode: what the call's parameters got wrong.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub param_warnings: Vec<String>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use super::PrintFaceParams;
|
||||
use crate::Session;
|
||||
use crate::schema::input_schema_for;
|
||||
use crate::schema::tests::assert_keys;
|
||||
|
||||
#[test]
|
||||
fn schemas_and_the_key_check_agree() {
|
||||
assert_keys(input_schema_for::<PrintFaceParams>(), &["body", "point"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_calls_say_what_is_wrong_and_change_nothing() {
|
||||
let mut s = Session::default();
|
||||
s.execute("solid.box", &json!({"length": 20, "width": 10, "height": 5, "body_name": "Block"})).unwrap_or_else(|e| panic!("{e}"));
|
||||
let undo = s.undo.len();
|
||||
let e = s.execute("body.print_face", &json!({"point": [20, 5, 2.5]})).unwrap_err().to_string();
|
||||
assert!(e.contains("body"), "{e}");
|
||||
let e = s.execute("body.print_face", &json!({"body": "Bracket", "point": [20, 5, 2.5]})).unwrap_err().to_string();
|
||||
assert!(e.contains("Bracket"), "{e}");
|
||||
let e = s.execute("body.print_face", &json!({"body": "Block", "point": "top"})).unwrap_err().to_string();
|
||||
assert!(e.contains("point"), "{e}");
|
||||
assert!(s.doc.print_faces.is_empty() && s.undo.len() == undo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_reply_names_the_marked_face_and_leaves_it_out_when_cleared() {
|
||||
let mut s = Session::default();
|
||||
s.execute("solid.box", &json!({"length": 20, "width": 10, "height": 5, "body_name": "Block"})).unwrap_or_else(|e| panic!("{e}"));
|
||||
let r = s.execute("body.print_face", &json!({"body": "Block", "point": [20, 5, 2.5]})).unwrap_or_else(|e| panic!("{e}"));
|
||||
assert_eq!(r["body"], "Block");
|
||||
assert!(r["face"].as_str().is_some_and(|f| !f.is_empty()), "{r}");
|
||||
let r = s.execute("body.print_face", &json!({"body": "Block"})).unwrap_or_else(|e| panic!("{e}"));
|
||||
assert_eq!(r["body"], "Block");
|
||||
assert!(r.get("face").is_none(), "{r}");
|
||||
}
|
||||
}
|
||||
@@ -667,6 +667,9 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
|
||||
let planar =
|
||||
sel.iter().any(|s| matches!(s, Sel::Face { body, index, .. } if crate::dialogs::planar_face(&app.session, body, *index).is_some()));
|
||||
v.push(act("ui.lookAt", "Look At", "lookat").on(planar));
|
||||
let marked = matches!(sel.as_slice(), [Sel::Face { body, index, .. }] if crate::print_face_ui::is_print_face(app, body, *index));
|
||||
let one_flat = planar && matches!(sel.as_slice(), [Sel::Face { .. }]);
|
||||
v.push(cmd(app, "body.print_face", if marked { "Clear Print Face" } else { "Print Face" }).on(one_flat));
|
||||
v.push(Item::sep());
|
||||
v.push(act("ui.appearance", "Appearance", "appearance").key("A"));
|
||||
v.push(act("ui.properties", "Properties", "measure").with(json!({ "bodies": [face] })));
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
//! send the bodies to: it always asks, and pre-selects the slicer used last time. The list also has
|
||||
//! a plain text row for EasyPrint (`file.open_in_easyprint`), which works in a browser too.
|
||||
//!
|
||||
//! Send to Slicer also has a Print face input (#8429): it shows the print face of the one body being
|
||||
//! sent, takes a flat face picked in the viewport as that body's print face, and clears it when
|
||||
//! emptied. Each change runs `body.print_face` at once, so it undoes like any other.
|
||||
//!
|
||||
//! Every place that saves a mesh opens this dialog: File › Export STL / Export 3MF, the Mesh tab, and the
|
||||
//! Save As Mesh item of the body menus. The slicer list (Send to Slicer only) holds the programs the user added (kept
|
||||
//! between runs, newest first), then the slicers found on this machine, then "Custom…", which asks
|
||||
@@ -19,7 +23,7 @@ use solidcraft_engine::slicers::{self, Slicer};
|
||||
|
||||
use crate::SolveApp;
|
||||
use crate::dialogs::{Kind, form_row};
|
||||
use crate::selection::{BODIES, SelInput};
|
||||
use crate::selection::{BODIES, PLANAR_FACES, SelInput};
|
||||
use crate::theme::Tokens;
|
||||
use solidcraft_engine::Sel;
|
||||
|
||||
@@ -47,6 +51,9 @@ pub struct SaveMesh {
|
||||
slicer: String,
|
||||
/// The slicer list has not been read for this opening yet.
|
||||
stale: bool,
|
||||
/// Send to Slicer: the bodies and the print face the Print face input last showed, to tell
|
||||
/// a pick or a clear in it from a change of the bodies.
|
||||
shown: Option<(Vec<String>, Option<Sel>)>,
|
||||
}
|
||||
|
||||
impl SaveMesh {
|
||||
@@ -128,8 +135,12 @@ pub fn start(app: &SolveApp, id: &str) -> Option<(Kind, Vec<SelInput>)> {
|
||||
_ => String::new(),
|
||||
};
|
||||
let quality = QUALITIES.iter().position(|q| q.1 == p.save_mesh_quality).unwrap_or(0);
|
||||
let kind = Kind::SaveMesh(SaveMesh { format, quality, open, slicer, stale: true });
|
||||
Some((kind, vec![SelInput::new("Bodies", BODIES, true)]))
|
||||
let kind = Kind::SaveMesh(SaveMesh { format, quality, open, slicer, stale: true, shown: None });
|
||||
let mut inputs = vec![SelInput::new("Bodies", BODIES, true)];
|
||||
if open {
|
||||
inputs.push(SelInput::new("Print face", PLANAR_FACES, false));
|
||||
}
|
||||
Some((kind, inputs))
|
||||
}
|
||||
|
||||
/// Send to Slicer needs a way to start a program (a browser has none) or a way to reach EasyPrint.
|
||||
@@ -310,8 +321,44 @@ pub(crate) fn body_picks(app: &SolveApp, visible: bool) -> Vec<Sel> {
|
||||
st.bodies.iter().filter(|b| shown(&b.name)).map(|b| Sel::Body { name: b.name.clone() }).collect()
|
||||
}
|
||||
|
||||
/// Keep the Print face input and the design in step. A face picked into it becomes the print
|
||||
/// face of its body, which must be the one body being sent; emptying it clears that body's print
|
||||
/// face. When the bodies change, it shows the print face of the one body, or nothing for several.
|
||||
fn sync_print_face(app: &mut SolveApp, k: &mut SaveMesh, inputs: &mut [SelInput]) {
|
||||
let bodies = crate::selection::items(inputs, 0).body_names();
|
||||
let Some(input) = inputs.get_mut(1) else { return };
|
||||
let picked = input.items.first().cloned();
|
||||
match k.shown.take() {
|
||||
Some((shown_bodies, shown)) if shown_bodies == bodies && shown != picked => {
|
||||
let one = bodies.first().filter(|_| bodies.len() == 1).cloned();
|
||||
let target = match (&picked, &shown) {
|
||||
(Some(Sel::Face { body, .. }), _) => Some(body.clone()),
|
||||
(None, Some(Sel::Face { body, .. })) => Some(body.clone()),
|
||||
_ => None,
|
||||
};
|
||||
match (target, one) {
|
||||
(Some(body), Some(one)) if body == one => {
|
||||
crate::print_face_ui::set(app, &body, picked.as_ref());
|
||||
}
|
||||
_ => app.set_status(crate::i18n::tr("ui.print_face_one_body"), true),
|
||||
}
|
||||
}
|
||||
Some(shown) if shown.0 == bodies => {
|
||||
k.shown = Some(shown);
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let current = bodies.first().filter(|_| bodies.len() == 1).and_then(|b| crate::print_face_ui::current(app, b));
|
||||
input.items = current.iter().cloned().collect();
|
||||
k.shown = Some((bodies, current));
|
||||
}
|
||||
|
||||
/// The rows after the Bodies input; true when Enter was pressed in a field.
|
||||
pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh, inputs: &mut [SelInput]) -> bool {
|
||||
if k.open {
|
||||
sync_print_face(app, k, inputs);
|
||||
}
|
||||
// One row each: the two side by side do not fit the dialog's width.
|
||||
for (label, visible) in [("Add all bodies", false), ("Add visible bodies", true)] {
|
||||
form_row(ui, "", |ui| {
|
||||
@@ -879,7 +926,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn send_to_slicer_asks_for_bodies_and_a_slicer_but_not_a_format() {
|
||||
let k = SaveMesh { format: 0, quality: 0, open: true, slicer: "prusa".into(), stale: false };
|
||||
let k = SaveMesh { format: 0, quality: 0, open: true, slicer: "prusa".into(), stale: false, shown: None };
|
||||
let mut input = SelInput::new("Bodies", BODIES, true);
|
||||
assert!(commands(&k, std::slice::from_ref(&input)).is_err());
|
||||
input.items = vec![Sel::Body { name: "Part".into() }];
|
||||
@@ -898,7 +945,7 @@ mod tests {
|
||||
fn a_remembered_quality_goes_to_save_but_not_to_send() {
|
||||
let mut input = SelInput::new("Bodies", BODIES, true);
|
||||
input.items = vec![Sel::Body { name: "Part".into() }];
|
||||
let k = SaveMesh { format: 0, quality: 2, open: true, slicer: "prusa".into(), stale: false };
|
||||
let k = SaveMesh { format: 0, quality: 2, open: true, slicer: "prusa".into(), stale: false, shown: None };
|
||||
let (_, sent) = commands(&k, std::slice::from_ref(&input)).unwrap().remove(0);
|
||||
assert_eq!(sent.get("quality"), None, "sending has no quality row: the default applies");
|
||||
let (_, saved) = commands(&SaveMesh { open: false, ..k }, &[input]).unwrap().remove(0);
|
||||
|
||||
@@ -207,6 +207,7 @@ pub mod preview;
|
||||
mod primitive_placement;
|
||||
#[cfg(test)]
|
||||
mod primitive_units_tests;
|
||||
mod print_face_ui;
|
||||
pub mod recovery_ui;
|
||||
pub mod ref_images;
|
||||
mod render_ui;
|
||||
@@ -407,6 +408,11 @@ pub struct Services {
|
||||
pub graphics_path: Option<String>,
|
||||
/// Linux: the window system this run uses, `wayland` or `x11` (Preferences shows it, #3083).
|
||||
pub window_system: Option<&'static str>,
|
||||
/// The desktop's dark (`Some(true)`) or light preference as the host reads it, for Theme:
|
||||
/// System where the window toolkit does not report it (Linux desktops, #7944). Called every
|
||||
/// frame, so it only reads a value kept up to date elsewhere. None, or `None` from it: the
|
||||
/// window toolkit's theme.
|
||||
pub desktop_dark: Option<Box<dyn Fn() -> Option<bool>>>,
|
||||
/// Adapter names and descriptive labels from the desktop renderer's chosen backends.
|
||||
pub graphics_adapters: Vec<(String, String)>,
|
||||
/// HTTPS GET for the update check (`update`); None: never check (browser, tests).
|
||||
@@ -1486,6 +1492,11 @@ impl SolveApp {
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Print Face (Ctrl+B) acts on the selected face at once: it has no dialog.
|
||||
if id == "body.print_face" {
|
||||
print_face_ui::toggle(self);
|
||||
return;
|
||||
}
|
||||
if id == "view.normal_to" {
|
||||
if self.run(id, json!({"camera": self.cam})).is_ok() {
|
||||
self.follow_view_request(true);
|
||||
|
||||
@@ -1231,6 +1231,9 @@ preference_settings! {
|
||||
send_slicer: String = String::new();
|
||||
/// Slicers that can load a file into the window that is already open do so (default on).
|
||||
slicer_single_instance: bool = true, 0;
|
||||
/// How strongly a print face stands out in the viewport (#8429): the share of the section
|
||||
/// colour in its tint, 0 to 1; its outline follows. 0 draws no highlight.
|
||||
print_face_highlight: f32 = 0.2, PAGE_GENERAL, accept(0.0..=1.0);
|
||||
/// The line about sending again replacing the slicer's file has been shown.
|
||||
slicer_resend_hint_seen: bool = false;
|
||||
/// The user has agreed to Open with EasyPrint uploading a model to Printables' servers.
|
||||
@@ -1737,7 +1740,7 @@ fn theme_row(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
}
|
||||
Some("export") => {
|
||||
let system_dark = ui.ctx().system_theme().map_or(app.ui.dark, |theme| theme == egui::Theme::Dark);
|
||||
let system_dark = system_dark(app, ui.ctx()).unwrap_or(app.ui.dark);
|
||||
let file = theme_file(app, action_theme.as_deref().unwrap_or(&app.preferences.theme), system_dark);
|
||||
let name = file.get("name").and_then(serde_json::Value::as_str).unwrap_or("Theme").to_string();
|
||||
let text = serde_json::to_string_pretty(&file).unwrap_or_default();
|
||||
@@ -1879,6 +1882,39 @@ fn defaults(app: &mut SolveApp, page: usize) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the desktop asks for dark colours, for Theme: System; `None` when nothing says.
|
||||
/// The host's own reading of the desktop (`Services::desktop_dark`, the freedesktop setting on
|
||||
/// Linux, #7944) comes first, as the window toolkit does not report it on every desktop
|
||||
/// (GNOME on Wayland), nor its changes; then the window toolkit's.
|
||||
pub(crate) fn system_dark(app: &SolveApp, ctx: &egui::Context) -> Option<bool> {
|
||||
app.services.desktop_dark.as_ref().and_then(|f| f()).or_else(|| ctx.system_theme().map(|t| t == egui::Theme::Dark))
|
||||
}
|
||||
|
||||
/// The desktop's dark or light preference from the freedesktop settings a Linux host reads
|
||||
/// (#7944): `appearance` is `org.freedesktop.appearance color-scheme` (1 prefer dark, 2 prefer
|
||||
/// light, 0 no preference), `gnome` is GNOME's `org.gnome.desktop.interface color-scheme`
|
||||
/// (`prefer-dark`, `prefer-light`, `default`) and `gtk_theme` its `gtk-theme` name. An explicit
|
||||
/// preference wins; otherwise a dark-named GTK theme ("Adwaita-dark") means dark, and anything
|
||||
/// else light, as GTK applications read it (GNOME's Light is `default`). `None` when no setting
|
||||
/// was read at all.
|
||||
pub fn desktop_prefers_dark(appearance: Option<u32>, gnome: Option<&str>, gtk_theme: Option<&str>) -> Option<bool> {
|
||||
match appearance {
|
||||
Some(1) => return Some(true),
|
||||
Some(2) => return Some(false),
|
||||
_ => {}
|
||||
}
|
||||
match gnome.map(|s| s.trim().trim_matches('\'')) {
|
||||
Some("prefer-dark") => return Some(true),
|
||||
Some("prefer-light") => return Some(false),
|
||||
_ => {}
|
||||
}
|
||||
let theme = gtk_theme.map(|s| s.trim().trim_matches('\'').to_ascii_lowercase()).filter(|s| !s.is_empty());
|
||||
if theme.as_deref().is_some_and(|t| t.ends_with("-dark") || t.ends_with(":dark")) {
|
||||
return Some(true);
|
||||
}
|
||||
(appearance.is_some() || gnome.is_some() || theme.is_some()).then_some(false)
|
||||
}
|
||||
|
||||
/// Settings that follow the preferences every frame: the theme when it follows the system, and
|
||||
/// the interface scale.
|
||||
/// Tell the native window which appearance to take (#8983): the operating system's while the
|
||||
@@ -1915,9 +1951,9 @@ pub fn apply(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
}
|
||||
follow_view_fov(app);
|
||||
if app.preferences.theme == "system"
|
||||
&& let Some(t) = ctx.system_theme()
|
||||
&& let Some(dark) = system_dark(app, ctx)
|
||||
{
|
||||
app.ui.dark = t == egui::Theme::Dark;
|
||||
app.ui.dark = dark;
|
||||
}
|
||||
// A theme file's palette, in place of its base's (dark or light); the visuals follow. A
|
||||
// followed file (#7573) wins while it is followed and has read completely once.
|
||||
@@ -3431,6 +3467,9 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valu
|
||||
if !accepted::ui_scale(&new) || !accepted::look_at_speed(&new) {
|
||||
return Err("`ui_scale` must be 0.5…2.5 and `look_at_speed` 0.25…4".into());
|
||||
}
|
||||
if !accepted::print_face_highlight(&new) {
|
||||
return Err("`print_face_highlight` must be 0…1".into());
|
||||
}
|
||||
if !accepted::perspective_fov(&new) {
|
||||
return Err("`perspective_fov` must be 15°…90° in radians (0.2618…1.5708)".into());
|
||||
}
|
||||
@@ -5176,6 +5215,59 @@ mod tests {
|
||||
assert_eq!(h.app.preferences.browser_bodies_folders, BodiesFolders::Several, "Interface's Restore Defaults");
|
||||
}
|
||||
|
||||
/// Theme: System on a Linux desktop (#7944): the freedesktop preference wins, GNOME's
|
||||
/// settings decide when it has none (its Light is `default`, so a plain theme name is
|
||||
/// light), and nothing read leaves the window toolkit to say.
|
||||
#[test]
|
||||
fn the_desktops_colour_scheme_setting_decides_dark_or_light() {
|
||||
use super::desktop_prefers_dark as d;
|
||||
assert_eq!(d(Some(1), Some("prefer-light"), Some("Adwaita")), Some(true), "freedesktop: prefer dark");
|
||||
assert_eq!(d(Some(2), Some("prefer-dark"), Some("Adwaita-dark")), Some(false), "freedesktop: prefer light");
|
||||
assert_eq!(d(Some(0), Some("prefer-dark"), None), Some(true), "no preference: GNOME's");
|
||||
assert_eq!(d(Some(0), Some("'prefer-light'"), Some("Adwaita-dark")), Some(false), "gsettings quotes its answer");
|
||||
assert_eq!(d(Some(0), Some("default"), Some("Adwaita-dark")), Some(true), "a dark GTK theme");
|
||||
assert_eq!(d(None, None, Some("Yaru:dark")), Some(true));
|
||||
assert_eq!(d(Some(0), Some("default"), Some("Adwaita")), Some(false), "GNOME's Light");
|
||||
assert_eq!(d(Some(0), None, None), Some(false), "no preference at all: light, as GTK applications");
|
||||
assert_eq!(d(Some(u32::MAX), None, None), Some(false), "an unknown value is no preference");
|
||||
assert_eq!(d(None, None, Some(" ")), None, "nothing read");
|
||||
assert_eq!(d(None, None, None), None);
|
||||
}
|
||||
|
||||
/// The host's reading of the desktop comes before the window toolkit's theme, which egui
|
||||
/// reports as None in tests, and Theme: System follows it every frame (#7944).
|
||||
#[test]
|
||||
fn theme_system_follows_the_hosts_desktop_setting() {
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU8, Ordering};
|
||||
let desktop = Arc::new(AtomicU8::new(0));
|
||||
let reading = desktop.clone();
|
||||
let services = crate::Services {
|
||||
desktop_dark: Some(Box::new(move || match reading.load(Ordering::Relaxed) {
|
||||
1 => Some(true),
|
||||
2 => Some(false),
|
||||
_ => None,
|
||||
})),
|
||||
..Default::default()
|
||||
};
|
||||
let mut app = SolveApp::new(solidcraft_engine::Session::default(), services);
|
||||
app.preferences.theme = "system".into();
|
||||
app.ui.dark = true;
|
||||
let ctx = egui::Context::default();
|
||||
super::apply(&mut app, &ctx);
|
||||
assert!(app.ui.dark, "nothing known: the colours stay");
|
||||
desktop.store(2, Ordering::Relaxed);
|
||||
super::apply(&mut app, &ctx);
|
||||
assert!(!app.ui.dark, "the desktop turned light");
|
||||
desktop.store(1, Ordering::Relaxed);
|
||||
super::apply(&mut app, &ctx);
|
||||
assert!(app.ui.dark, "and dark again");
|
||||
app.preferences.theme = "light".into();
|
||||
app.ui.dark = false;
|
||||
super::apply(&mut app, &ctx);
|
||||
assert!(!app.ui.dark, "an explicit theme does not follow the desktop");
|
||||
}
|
||||
|
||||
/// Theme files (#2255): a built-in one and an imported one turn on through `ui.prefs`, the
|
||||
/// next frame draws with their colours (dark following the base), an export gives the theme
|
||||
/// back complete, imported themes are saved with the preferences, Remove falls back to the
|
||||
|
||||
@@ -56,6 +56,17 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let (single, tip) = (app.tr("ui.slicer_single_instance").to_string(), app.tr("ui.slicer_single_instance_tip").to_string());
|
||||
ui_kit::checkbox(ui, &single, &mut app.preferences.slicer_single_instance).on_hover_text(tip);
|
||||
});
|
||||
ui_kit::settings_block(ui, app.tr("prefs.print_face_highlight"), labels, |ui| {
|
||||
let tip = app.tr("prefs.print_face_highlight_tip").to_string();
|
||||
let response = ui_kit::slider(
|
||||
ui,
|
||||
&mut app.preferences.print_face_highlight,
|
||||
0.0..=1.0,
|
||||
ui_kit::Slider { step: Some(0.05), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },
|
||||
);
|
||||
crate::scenario::publish_target("prefs:print_face_highlight", response.rect);
|
||||
response.on_hover_text(tip);
|
||||
});
|
||||
});
|
||||
ui_kit::settings_section(ui, "updates", app.tr("prefs.updates"), |ui| {
|
||||
ui_kit::settings_block(ui, app.tr("update.prefs_label"), labels, |ui| crate::update::prefs_rows(app, ui));
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
//! The print face in the app (#8429): Ctrl+B and the face menu mark the selected flat face as its
|
||||
//! body's print face, or clear it when it already is one; the Send to Slicer window shows and
|
||||
//! changes it (`dialogs_save_mesh`). Each change is a `body.print_face` command, so it undoes.
|
||||
|
||||
use serde_json::json;
|
||||
use solidcraft_engine::Sel;
|
||||
|
||||
use crate::SolveApp;
|
||||
|
||||
/// Whether face `index` of `body` (as the viewport names it) is that body's print face now.
|
||||
pub(crate) fn is_print_face(app: &SolveApp, body: &str, index: usize) -> bool {
|
||||
let world = app.session.world_state();
|
||||
world.body(body).and_then(|b| app.session.doc.print_face(&world, b)).and_then(Result::ok).is_some_and(|f| f.index == index)
|
||||
}
|
||||
|
||||
/// `body`'s print face as a face pick, for the Send to Slicer window; `None` when it has none,
|
||||
/// or it can't be found.
|
||||
pub(crate) fn current(app: &SolveApp, body: &str) -> Option<Sel> {
|
||||
let world = app.session.world_state();
|
||||
let b = world.body(body)?;
|
||||
let face = app.session.doc.print_face(&world, b)?.ok()?;
|
||||
let point = solidcraft_engine::doc::naming::face_spot(b, face.index).map_or(face.point, |spot| spot.point);
|
||||
Some(Sel::Face { body: body.to_string(), index: face.index, point })
|
||||
}
|
||||
|
||||
/// Mark face `face` as its body's print face (a face pick), or clear `body`'s with none.
|
||||
pub(crate) fn set(app: &mut SolveApp, body: &str, face: Option<&Sel>) -> bool {
|
||||
let params = match face {
|
||||
Some(Sel::Face { body, point, .. }) => json!({"body": body, "point": [point.x, point.y, point.z]}),
|
||||
_ => json!({"body": body}),
|
||||
};
|
||||
app.run("body.print_face", params).is_ok()
|
||||
}
|
||||
|
||||
/// Ctrl+B and the face menu: the one selected face becomes its body's print face, or stops being
|
||||
/// it when it already is.
|
||||
pub(crate) fn toggle(app: &mut SolveApp) {
|
||||
let picked = match app.session.selection.as_slice() {
|
||||
[face @ Sel::Face { body, index, .. }] => Some((face.clone(), body.clone(), *index)),
|
||||
_ => None,
|
||||
};
|
||||
let Some((face, body, index)) = picked else {
|
||||
app.set_status(crate::i18n::tr("ui.print_face_pick"), true);
|
||||
return;
|
||||
};
|
||||
let clear = is_print_face(app, &body, index);
|
||||
if set(app, &body, if clear { None } else { Some(&face) }) {
|
||||
let id = if clear { "ui.print_face_cleared" } else { "ui.print_face_set" };
|
||||
app.set_status(crate::i18n::format(id, &[("body", &body)]), false);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
use solidcraft_engine::Sel;
|
||||
|
||||
fn app() -> crate::SolveApp {
|
||||
let mut app = crate::SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
|
||||
app.run("solid.box", json!({"length": 20, "width": 10, "height": 5, "corner": [0, 0, 0], "body_name": "Block"})).unwrap();
|
||||
app
|
||||
}
|
||||
|
||||
/// Select the face of Block at `point`; its index.
|
||||
fn select_face(app: &mut crate::SolveApp, point: [f64; 3]) -> usize {
|
||||
let world = app.session.world_state();
|
||||
let body = world.body("Block").unwrap();
|
||||
let p = solidcraft_engine::geom::Vec3::new(point[0], point[1], point[2]);
|
||||
let index = solidcraft_engine::doc::appearance::face_index_at(body, p).unwrap();
|
||||
app.session.selection = vec![Sel::Face { body: "Block".into(), index, point: p }];
|
||||
index
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_b_marks_the_selected_face_and_clears_it_the_second_time() {
|
||||
let mut app = app();
|
||||
let index = select_face(&mut app, [20.0, 5.0, 2.5]);
|
||||
app.start("body.print_face");
|
||||
assert!(app.session.doc.print_faces.contains_key("Block"));
|
||||
assert!(super::is_print_face(&app, "Block", index));
|
||||
assert!(super::current(&app, "Block").is_some());
|
||||
app.start("body.print_face");
|
||||
assert!(app.session.doc.print_faces.is_empty());
|
||||
assert!(super::current(&app, "Block").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_b_without_one_face_selected_marks_nothing() {
|
||||
let mut app = app();
|
||||
app.session.selection = vec![Sel::Body { name: "Block".into() }];
|
||||
app.start("body.print_face");
|
||||
assert!(app.session.doc.print_faces.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_highlight_strength_defaults_to_a_fifth_and_ui_prefs_keeps_it_in_range() {
|
||||
let mut app = app();
|
||||
assert!((app.preferences.print_face_highlight - 0.2).abs() < 1e-6);
|
||||
crate::prefs::set(&mut app, &json!({"print_face_highlight": 0.5})).unwrap();
|
||||
assert!((app.preferences.print_face_highlight - 0.5).abs() < 1e-6);
|
||||
assert!(crate::prefs::set(&mut app, &json!({"print_face_highlight": 1.5})).is_err());
|
||||
assert!((app.preferences.print_face_highlight - 0.5).abs() < 1e-6);
|
||||
}
|
||||
}
|
||||
@@ -3388,6 +3388,8 @@ fn highlight_geometry_key(app: &SolveApp) -> u64 {
|
||||
app.session.visibility.hidden_bodies.hash(&mut h);
|
||||
app.session.visibility.hidden_occurrences.hash(&mut h);
|
||||
app.session.visibility.hidden_folders.hash(&mut h);
|
||||
// How strongly print faces are tinted (Preferences › General › Slicer).
|
||||
app.preferences.print_face_highlight.to_bits().hash(&mut h);
|
||||
h.finish()
|
||||
}
|
||||
|
||||
@@ -3745,6 +3747,32 @@ pub(crate) fn build_highlight(app: &SolveApp) -> GpuScene {
|
||||
(EdgeColours::new(&mut feedback, t.hover_edge, t.hover_edge_halo), EdgeColours::new(&mut feedback, t.sel_edge, t.sel_edge_rim));
|
||||
let mut hover_instances = HighlightInstances::default();
|
||||
let mut selected_instances = HighlightInstances::default();
|
||||
// Print faces (#8429): tinted towards the colour section views give cut faces, and outlined,
|
||||
// so the face a slicer export lays its body on shows at a glance. Drawn before the selection,
|
||||
// which lights over it.
|
||||
// The share of that colour is the user's (Preferences › General › Slicer, default a fifth); the
|
||||
// outline takes a little over twice it, so the face reads as marked without outshouting the model.
|
||||
let strength = app.preferences.print_face_highlight.clamp(0.0, 1.0);
|
||||
if !product && strength > 0.0 {
|
||||
let cap = t.section_cap;
|
||||
let blend = |from: u8, to: u8, k: f32| (f32::from(from) + (f32::from(to) - f32::from(from)) * k).round().clamp(0.0, 255.0) as u8;
|
||||
let mix = |body: u8, tint: u8| blend(body, tint, strength);
|
||||
let edge = t.body_edge;
|
||||
let k = (strength * 2.25).min(1.0);
|
||||
let rim = Color32::from_rgb(blend(edge.r(), cap.r(), k), blend(edge.g(), cap.g(), k), blend(edge.b(), cap.b(), k));
|
||||
let outline = EdgeColours::new(&mut feedback, rim, rim);
|
||||
for b in st.bodies.iter().filter(|b| app.session.body_visible(&b.name) && !app.preview.effective_replaced().contains(&b.name)) {
|
||||
let Some(Ok(face)) = s.doc.print_face(&st, b) else { continue };
|
||||
let (r, g, bl) = body_rgb(app, &b.name);
|
||||
face_tris(&mut feedback, &shown(b), face.index, [mix(r, cap.r()), mix(g, cap.g()), mix(bl, cap.b()), 255], true);
|
||||
let m = drawn_mesh(app, b);
|
||||
for (ei, e) in m.edges.iter().enumerate() {
|
||||
if m.edge_pickable(ei) && m.edge_faces.get(ei).is_some_and(|fs| fs.iter().any(|f| *f as usize == face.index)) {
|
||||
edge_lines(&mut feedback, e, outline, 2.0, &[]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Selected things.
|
||||
for x in &sel {
|
||||
match x {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[
|
||||
{"note":"#8429: Ctrl+B marks the one selected flat face as its body's print face, the design saves it, and Ctrl+B on it again clears it. Without a face selected it says what to select."},
|
||||
{"call":"engine.execute","params":{"command":"solid.box","params":{"length":20,"width":10,"height":5,"body_name":"Block"}}},
|
||||
{"call":"ui.camera","params":{"target":[10,5,2.5],"yaw":-0.785398,"pitch":0.61548,"distance":70}},
|
||||
{"key":"B","ctrl":true},
|
||||
{"expect":{"status":"Select one flat face","errors":0}},
|
||||
{"click":{"world":[20,5,2.5]}},
|
||||
{"expect":{"selection":1}},
|
||||
{"key":"B","ctrl":true},
|
||||
{"expect":{"status":"Block: print face set","errors":0}},
|
||||
{"shot":"print_face_ctrl_b"},
|
||||
{"call":"engine.execute","params":{"command":"file.save_as","params":{"path":"$DIR/print-face.json"}}},
|
||||
{"expect":{"file_contains":{"file":"print-face.json","text":"\"print_faces\""}}},
|
||||
{"key":"B","ctrl":true},
|
||||
{"expect":{"status":"Block: print face cleared","errors":0}}
|
||||
]
|
||||
@@ -67,6 +67,17 @@ with a `slicer`, which sends without a dialog. They can start only the slicers i
|
||||
list and programs you added under **Custom…**; any other program path is refused, and an AI agent's
|
||||
request to save a mesh or send it to a slicer asks first and names the slicer.
|
||||
|
||||
A body can have a **print face**: the flat face it should lie on in the slicer. Select the face
|
||||
and press **Ctrl+B** (or **Print Face** in the face's right-click menu); press it again to clear
|
||||
it. The Send to Slicer window shows the print face of the one body being sent in its **Print
|
||||
face** row, where you can pick another face in the viewport or clear it. Each send then turns a
|
||||
copy of the body so the print face points down at Z = 0, with its centre of mass over the
|
||||
origin; the design itself does not move. The face is tinted and outlined in the viewport, and a
|
||||
copy made with Move/Copy or Mirror keeps it. A print face that is gone or no longer flat is
|
||||
reported, and the body is sent as it lies. Curved faces and mesh bodies can't be print faces.
|
||||
Known limitation: after a shell of a body that is already shelled, no face of that body can be
|
||||
marked, as no sketch can be attached to one either; this needs kernel work, which is paused.
|
||||
|
||||
The list also has a plain **EasyPrint (Printables, in the browser)** row, and it is the one entry
|
||||
that works in the browser build too. EasyPrint is Printables' slicer, so choosing it uploads the
|
||||
selected bodies (a 3MF, 100 MB at most) to Printables' servers and opens the model there in your
|
||||
|
||||
@@ -158,9 +158,12 @@ When the graphics driver stops responding, the system resets it (on Windows, "Di
|
||||
stopped responding and has recovered"), and the graphics device SolidCraft draws with is gone
|
||||
for good: the window can't draw anything more. SolidCraft then closes, keeps your unsaved
|
||||
changes for recovery as it does after a crash, and starts again; the new window says what
|
||||
happened and offers the changes back. If the device is reset again within ten minutes of that
|
||||
restart, the next start uses software rendering, which doesn't depend on the graphics driver.
|
||||
Updating the graphics driver from the GPU maker usually stops the resets.
|
||||
happened, with what the graphics driver reported, and offers the changes back. The old window
|
||||
closes on its own; SolidCraft doesn't wait for the driver to release it. If the device is reset
|
||||
again within ten minutes of that restart, the next start uses software rendering, which doesn't
|
||||
depend on the graphics driver. Updating the graphics driver from the GPU maker usually stops the
|
||||
resets. Laptops that lose the device on waking from sleep (often with an NVIDIA GPU that doesn't
|
||||
drive the screen) can keep SolidCraft on the integrated GPU instead: Preferences › Graphics.
|
||||
|
||||
## A design saved by 0.10 won't open in an older version
|
||||
|
||||
|
||||
@@ -203,7 +203,9 @@ too narrow for a section's buttons, its menu lists them again.
|
||||
|
||||
### Colour themes
|
||||
|
||||
Interface › **Theme** lists Dark, Light and System (follows the operating system), the built-in
|
||||
Interface › **Theme** lists Dark, Light and System (follows the operating system, and changes
|
||||
with it; on Linux it reads the desktop's dark or light style through the desktop portal, as
|
||||
GNOME and KDE set it), the built-in
|
||||
themes and any themes you have imported. A choice applies at once. Under the themes, **Viewport** draws the 3D view in the Light or Dark theme's colours whatever the window uses, for example the model on a light view in a dark window (**Follow theme**, the default, keeps the theme's own). **Logo** draws the SolidCraft logo at the top left in shades of the theme's accent instead of the theme's logo colours. The built-in themes are Gruvbox
|
||||
(dark and light, each in hard, normal and soft contrast), SolidCraft 95, Platinum 9, Cupertino,
|
||||
Green Phosphor, Amber Phosphor, Blueprint, One Dark, Tokyo Night, Solarized Light, Nord, High
|
||||
|
||||
@@ -324,6 +324,19 @@ The first instance is the original.
|
||||
- **Elsewhere:** instance, element, occurrence.
|
||||
- **For translators:** not an occurrence of a component.
|
||||
|
||||
### print face
|
||||
|
||||
The flat face of a body that lies on the print bed when the body is sent to a slicer.
|
||||
|
||||
A body has one print face at most. The export turns a copy of the body so this face points down
|
||||
at Z = 0, with the centre of mass over the origin; the design itself does not move.
|
||||
|
||||
- **In SolidCraft:** `body.print_face`; the `print_faces` of a design; the `print_faces` and
|
||||
`warnings` of a `file.send_to_slicer` reply.
|
||||
- **Don't use:** bottom face, base face (both say where a face is now, not where it is printed).
|
||||
- **Elsewhere:** place on face, lay flat, bed face.
|
||||
- **For translators:** the face the part stands on while it prints, not the printer's bed.
|
||||
|
||||
### reference edge
|
||||
|
||||
A straight edge of a flat face that a Single hole's centre or a cylinder's base centre keeps a
|
||||
|
||||
@@ -435,6 +435,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
|
||||
- `pan_reverse_y` (default false: vertical scrolling pans the other way)
|
||||
- `perspective_fov` (Perspective view's vertical field of view in radians, 0.2618…1.5708 (15°…90°), default 0.6; when it changes, the camera's distance scales so the view keeps its size)
|
||||
- `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it)
|
||||
- `print_face_highlight` (0…1, default 0.2: how strongly a print face is tinted and outlined in the view, #8429; 0 draws no highlight)
|
||||
- `ribbon_reveal` (default false: hovering a result in Search commands switches the ribbon to the command's tab and marks its button, or opens the panel drop-down that holds it on its row, handle `ribbon:reveal`; leaving the results goes back to the tab before; a command started from the search blinks there, and a running command from a drop-down marks its panel label, `ribbon:running_section:<TAB>:<SECTION>`, #7287)
|
||||
- `right_drag_orbits` (default true; false: a right drag the mouse preset would orbit leaves the camera alone, #6492)
|
||||
- `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle)
|
||||
|
||||
@@ -404,6 +404,10 @@ completed drawings publish atomically. The browser still exports synchronously.
|
||||
|
||||
- Associative shell-face sketches require a unique certified planar source. Nested shell
|
||||
attachments and ambiguous coincident sources remain unsupported.
|
||||
- Print faces (#8429) are held like sketches on faces, so the same limit applies: after a shell
|
||||
of a body that is already shelled, no face of that body has an exact name, and none can be
|
||||
marked (`body.print_face` says so). Fixing it needs the shell to report its face history,
|
||||
which is kernel work, paused for now (CONTRIBUTING.md, "Kernel work is paused").
|
||||
- G2 fillets: exact quintic blends of straight edges between planar faces, with one planar
|
||||
end face at each end, including sloped ends (#2708). The UI and `solid.fillet` expose
|
||||
`curvature` (alias `g2`); the size is an equivalent circular setback. Curved faces/edges,
|
||||
|
||||
Reference in new issue
Block a user