forked from 1b-agent/opencadstudio-upstream
fix: restore workspace verification
This commit is contained in:
1 parent
d36134900d
commit
1dded7f881
19 files changed
+91
-71
No files matched your search
+14
-6
@@ -549,10 +549,14 @@ mod tests {
|
||||
_ => None,
|
||||
})
|
||||
.expect("CIRCLE should create one entity");
|
||||
let center = crate::scene::view::transform::ocs_point_to_wcs(
|
||||
(circle.center.x, circle.center.y, circle.center.z),
|
||||
(circle.normal.x, circle.normal.y, circle.normal.z),
|
||||
);
|
||||
let close = |a: f64, b: f64| (a - b).abs() < 1e-9;
|
||||
assert!(close(circle.center.x, 2.0));
|
||||
assert!(close(circle.center.y, 0.0));
|
||||
assert!(close(circle.center.z, 3.0));
|
||||
assert!(close(center.0, 2.0));
|
||||
assert!(close(center.1, 0.0));
|
||||
assert!(close(center.2, 3.0));
|
||||
assert!(close(circle.normal.x, 0.0));
|
||||
assert!(close(circle.normal.y, -1.0));
|
||||
assert!(close(circle.normal.z, 0.0));
|
||||
@@ -612,6 +616,10 @@ mod tests {
|
||||
use crate::app::Message;
|
||||
use crate::modules::ModuleEvent;
|
||||
|
||||
let command_refusal =
|
||||
crate::t!("No drawing open. Use NEW or OPEN to start a drawing.");
|
||||
let tool_refusal = crate::t!("No drawing open — use New or Open first.");
|
||||
|
||||
// Fresh app = welcome tab, no drawing.
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
assert!(
|
||||
@@ -633,7 +641,7 @@ mod tests {
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert!(
|
||||
!out.contains("No drawing open"),
|
||||
!out.contains(command_refusal.as_ref()),
|
||||
"ABOUT needs no drawing and must not be refused on the welcome page: {out:?}"
|
||||
);
|
||||
|
||||
@@ -649,7 +657,7 @@ mod tests {
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert!(
|
||||
out.contains("No drawing open"),
|
||||
out.contains(command_refusal.as_ref()),
|
||||
"LINE must still be refused on the welcome page: {out:?}"
|
||||
);
|
||||
assert!(
|
||||
@@ -669,7 +677,7 @@ mod tests {
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert!(
|
||||
out.contains("No drawing open"),
|
||||
out.contains(tool_refusal.as_ref()),
|
||||
"a scene-touching event must stay inert on the welcome page: {out:?}"
|
||||
);
|
||||
|
||||
|
||||
+1
-11
@@ -1694,6 +1694,7 @@ pub enum Message {
|
||||
Tick(Instant),
|
||||
/// Periodic drain of plugin-to-host requests that arrived outside a host
|
||||
/// call (e.g. mutations from the Python REPL).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
DrainPluginRequests,
|
||||
/// Web: periodic check for per-script fonts a drawing needs but hasn't
|
||||
/// fetched yet (#141). Native: never emitted.
|
||||
@@ -3485,17 +3486,6 @@ impl OpenCADStudio {
|
||||
self.command_line.push_error(msg);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn command_history_info(&self) -> Vec<String> {
|
||||
use crate::ui::command_line::EntryKind;
|
||||
self.command_line
|
||||
.history
|
||||
.iter()
|
||||
.filter(|e| e.kind == EntryKind::Info)
|
||||
.map(|e| e.text.clone())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Boot function for `iced::daemon`: returns initial state plus a task that
|
||||
/// opens the primary application window. Native only — the web build uses
|
||||
/// [`Self::boot_web`].
|
||||
|
||||
@@ -111,6 +111,7 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
self.pending_close = Some(crate::app::PendingClose::Tab(idx));
|
||||
return self.open_unsaved_dialog_window();
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let tab_id = self.tabs.get(idx).map(|t| t.id);
|
||||
// This tab is closing for good — drop its autosave recovery copy.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
@@ -135,8 +136,8 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
self.sync_ribbon_layers();
|
||||
self.sync_ribbon_styles();
|
||||
self.sync_ribbon_from_selection();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Some(tab_id) = tab_id {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
v4_support::on_tab_closed(tab_id);
|
||||
}
|
||||
Task::none()
|
||||
|
||||
@@ -4202,15 +4202,16 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
|
||||
.unwrap_or("export.ctb".into());
|
||||
Task::perform(
|
||||
async move {
|
||||
let mut dialog = crate::sys::file_dialog()
|
||||
let dialog = crate::sys::file_dialog()
|
||||
.set_title("Save Plot Style Table")
|
||||
.set_file_name(&default_name)
|
||||
.add_filter("Plot Style Files", &["ctb", "CTB"])
|
||||
.add_filter("All Files", &["*"]);
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Ok(dir) = crate::io::plot_style::ensure_plot_styles_dir() {
|
||||
dialog = dialog.set_directory(dir);
|
||||
}
|
||||
let dialog = match crate::io::plot_style::ensure_plot_styles_dir() {
|
||||
Ok(dir) => dialog.set_directory(dir),
|
||||
Err(_) => dialog,
|
||||
};
|
||||
dialog.save_file().await
|
||||
.map(|h| crate::sys::handle_path(&h))
|
||||
},
|
||||
|
||||
@@ -6635,16 +6635,17 @@ impl OpenCADStudio {
|
||||
|
||||
Message::PlotStylePanelApply => self.on_plot_style_panel_apply(),
|
||||
|
||||
Message::PlotStylePanelSaveDirect => {
|
||||
let Some(table) = self.active_plot_style.as_ref() else {
|
||||
Message::PlotStylePanelSaveDirect => {
|
||||
if self.active_plot_style.is_none() {
|
||||
self.command_line.push_error(
|
||||
crate::t!("No plot style table loaded. Load or create one first.").as_ref(),
|
||||
);
|
||||
return Task::none();
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let table = self.active_plot_style.as_ref().expect("checked above");
|
||||
let table_name = table.name.clone();
|
||||
|
||||
let result = crate::io::plot_style::ensure_plot_styles_dir().and_then(|dir| {
|
||||
|
||||
Reference in new issue
Block a user