forked from 1b-agent/opencadstudio-upstream
Merge pull request #1360 from HakanSeven12/plot/b4-ctb-leniency
fix(plot-style): load plot style tables written by other applications # Conflicts: # src/app/update/file.rs # src/ui/window/plot.rs
This commit is contained in:
commit
f20c823ffe
28 files changed
+339
-35
No files matched your search
+23
-4
@@ -4670,18 +4670,22 @@ impl OpenCADStudio {
|
||||
self.plot_dialog.apply_plot_styles = false;
|
||||
self.plot_dialog.show_plot_styles = false;
|
||||
self.plot_dialog.style_missing = false;
|
||||
self.plot_dialog.style_error = None;
|
||||
} else {
|
||||
match crate::io::plot_style::PlotStyleTable::load_named(&name) {
|
||||
Ok(table) => {
|
||||
self.plot_dialog.style_name = table.name.clone();
|
||||
self.plot_dialog.apply_plot_styles = true;
|
||||
self.plot_dialog.style_missing = false;
|
||||
self.plot_dialog.style_error = None;
|
||||
self.report_plot_style_warnings(&table);
|
||||
self.active_plot_style = Some(table);
|
||||
}
|
||||
Err(error) => {
|
||||
self.plot_dialog.style_name = name;
|
||||
self.plot_dialog.style_missing = true;
|
||||
self.command_line.push_error(&error);
|
||||
self.plot_dialog.style_error = Some(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4950,16 +4954,19 @@ impl OpenCADStudio {
|
||||
));
|
||||
self.plot_dialog.window = self.plot_window;
|
||||
}
|
||||
let mut style_error = None;
|
||||
if !ps.current_style_sheet.is_empty()
|
||||
&& self
|
||||
.active_plot_style
|
||||
.as_ref()
|
||||
.is_none_or(|table| !table.name.eq_ignore_ascii_case(&ps.current_style_sheet))
|
||||
{
|
||||
if let Ok(table) =
|
||||
crate::io::plot_style::PlotStyleTable::load_named(&ps.current_style_sheet)
|
||||
{
|
||||
self.active_plot_style = Some(table);
|
||||
match crate::io::plot_style::PlotStyleTable::load_named(&ps.current_style_sheet) {
|
||||
Ok(table) => {
|
||||
self.report_plot_style_warnings(&table);
|
||||
self.active_plot_style = Some(table);
|
||||
}
|
||||
Err(error) => style_error = Some(error),
|
||||
}
|
||||
}
|
||||
let active_style_name = self
|
||||
@@ -5113,6 +5120,18 @@ impl OpenCADStudio {
|
||||
d.show_plot_styles = ps.flags.show_plot_styles;
|
||||
d.style_missing = !d.style_name.is_empty() && !style_loaded;
|
||||
self.refresh_custom_scale_fields();
|
||||
d.style_error = if d.style_missing { style_error } else { None };
|
||||
}
|
||||
|
||||
/// Tell the user what a plot style table's loader had to tolerate.
|
||||
pub(in crate::app) fn report_plot_style_warnings(
|
||||
&mut self,
|
||||
table: &crate::io::plot_style::PlotStyleTable,
|
||||
) {
|
||||
for warning in &table.load_warnings {
|
||||
let name = &table.name;
|
||||
self.command_line.push_warning(&format!("{name}: {warning}"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy transient paper/scale choices out of the dialog without changing
|
||||
|
||||
Reference in new issue
Block a user