forked from 1b-agent/opencadstudio-upstream
feat(plot): complete plot configuration
- unify Model and Paper Space plot area behavior - add CTB discovery, read/write, and bundled defaults - apply scale, render mode, and output options consistently
This commit is contained in:
1 parent
6705e65e81
commit
325cd2474c
11 files changed
+1141
-600
No files matched your search
+9
-4
@@ -647,8 +647,6 @@ pub(super) struct OpenCADStudio {
|
||||
mtext_click_time: Option<Instant>,
|
||||
mtext_click_off: usize,
|
||||
mtext_click_count: u8,
|
||||
/// Plot scale for model-space window plots: "Fit" | "1:1" | … | "2:1".
|
||||
plot_scale: String,
|
||||
/// Pending model-space plot window (x0, y0, x1, y1) in world XY, or None.
|
||||
plot_window: Option<(f64, f64, f64, f64)>,
|
||||
plot_format: crate::io::paper_sizes::PaperSize,
|
||||
@@ -2773,7 +2771,6 @@ impl OpenCADStudio {
|
||||
mtext_click_time: None,
|
||||
mtext_click_off: 0,
|
||||
mtext_click_count: 0,
|
||||
plot_scale: "Fit".to_string(),
|
||||
plot_window: None,
|
||||
plot_format: crate::io::paper_sizes::PaperSize::A4,
|
||||
plot_orientation: crate::io::paper_sizes::Orientation::Landscape,
|
||||
@@ -2800,7 +2797,15 @@ impl OpenCADStudio {
|
||||
save_dialog_for_unsaved: false,
|
||||
default_save_format: crate::io::DEFAULT_SAVE_FORMAT.to_string(),
|
||||
// Plot style
|
||||
active_plot_style: None,
|
||||
active_plot_style: crate::io::plot_style::PlotStyleTable::load_named(
|
||||
crate::io::plot_style::DEFAULT_PLOT_STYLE,
|
||||
)
|
||||
.or_else(|_| {
|
||||
crate::io::plot_style::PlotStyleTable::builtin(
|
||||
crate::io::plot_style::DEFAULT_PLOT_STYLE,
|
||||
)
|
||||
})
|
||||
.ok(),
|
||||
// Color scheme (default: Oxocarbon)
|
||||
active_theme: Theme::Oxocarbon,
|
||||
ui_theme: config::UiThemeConfig::default(),
|
||||
|
||||
+397
-297
File diff suppressed because it is too large.
Load diff
+27
-6
@@ -5176,7 +5176,6 @@ impl OpenCADStudio {
|
||||
}
|
||||
self.plot_dialog.style_name = table.name.clone();
|
||||
self.plot_dialog.style_missing = false;
|
||||
self.plot_dialog.with_styles = true;
|
||||
self.command_line.push_output(&format!(
|
||||
"Plot style '{}' loaded ({} color entries).",
|
||||
table.name,
|
||||
@@ -5187,6 +5186,7 @@ impl OpenCADStudio {
|
||||
.count()
|
||||
));
|
||||
self.active_plot_style = Some(table);
|
||||
self.plot_dialog.plot_styles = crate::io::plot_style::available_ctb_names();
|
||||
Task::none()
|
||||
}
|
||||
Message::PlotStyleLoaded(None) => Task::none(),
|
||||
@@ -5194,7 +5194,6 @@ impl OpenCADStudio {
|
||||
self.active_plot_style = None;
|
||||
self.plot_dialog.style_name.clear();
|
||||
self.plot_dialog.style_missing = false;
|
||||
self.plot_dialog.with_styles = false;
|
||||
self.command_line.push_output("Plot style table cleared.");
|
||||
Task::none()
|
||||
}
|
||||
@@ -5264,12 +5263,34 @@ impl OpenCADStudio {
|
||||
Message::PlotStylePanelSave => self.on_plot_style_panel_save(),
|
||||
|
||||
Message::PlotStylePanelSavePath(Some(path)) => {
|
||||
let path = if path
|
||||
.extension()
|
||||
.is_some_and(|extension| extension.eq_ignore_ascii_case("ctb"))
|
||||
{
|
||||
path
|
||||
} else {
|
||||
path.with_extension("ctb")
|
||||
};
|
||||
if let Some(table) = &self.active_plot_style {
|
||||
match table.save(&path) {
|
||||
Ok(()) => self.command_line.push_output(&format!(
|
||||
"Plot style table saved to \"{}\".",
|
||||
path.display()
|
||||
)),
|
||||
Ok(()) => {
|
||||
let name = path
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
if let Some(table) = self.active_plot_style.as_mut() {
|
||||
table.name = name.clone();
|
||||
}
|
||||
self.plot_dialog.style_name = name;
|
||||
self.plot_dialog.style_missing = false;
|
||||
self.plot_dialog.plot_styles =
|
||||
crate::io::plot_style::available_ctb_names();
|
||||
self.command_line.push_output(&format!(
|
||||
"Plot style table saved to \"{}\".",
|
||||
path.display()
|
||||
));
|
||||
}
|
||||
Err(e) => self.command_line.push_error(&format!("Save error: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user