forked from 1b-agent/opencadstudio-upstream
Merge pull request #1743 from ramox81/codex/layout-create-viewport
This commit is contained in:
commit
7095802e8e
9 files changed
+120
-14
No files matched your search
@@ -712,6 +712,7 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
"UOSNAP",
|
||||
"FIELDDISPLAY",
|
||||
"SURFACEASSOCIATIVITY",
|
||||
"LAYOUTCREATEVIEWPORT",
|
||||
"FIELDEVAL",
|
||||
"PDFIMPORTMODE",
|
||||
"PDFIMPORTFILTER",
|
||||
|
||||
@@ -1213,6 +1213,7 @@ impl OpenCADStudio {
|
||||
| "SURFACEASSOCIATIVITY"
|
||||
| "UCSORTHO"
|
||||
| "UCSVIEW"
|
||||
| "LAYOUTCREATEVIEWPORT"
|
||||
| "PDFIMPORTMODE"
|
||||
| "PDFIMPORTFILTER"
|
||||
| "PDFIMPORTLAYERS"
|
||||
@@ -1451,6 +1452,39 @@ impl OpenCADStudio {
|
||||
}
|
||||
return Some(self.finish_dispatch(cmd));
|
||||
}
|
||||
if name == "LAYOUTCREATEVIEWPORT" {
|
||||
// A profile switch shown and taken as ON / OFF or 1 / 0.
|
||||
let current = if crate::scene::layout_create_viewport() { "ON" } else { "OFF" };
|
||||
let parsed = value.as_deref().map(|v| {
|
||||
match v.trim().trim_start_matches('_').to_ascii_uppercase().as_str() {
|
||||
"1" | "ON" => Some(true),
|
||||
"0" | "OFF" => Some(false),
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
match parsed {
|
||||
Some(Some(on)) => {
|
||||
if crate::scene::layout_create_viewport() != on {
|
||||
crate::scene::set_layout_create_viewport(on);
|
||||
self.save_config();
|
||||
}
|
||||
}
|
||||
Some(None) => {
|
||||
self.command_line.push_error(
|
||||
crate::t!("Requires 0 or 1 only, or option keyword.").as_ref(),
|
||||
);
|
||||
self.command_line
|
||||
.push_output(&format!("Enter new value for {name} <{current}>:"));
|
||||
self.pending_setvar = Some(name.clone());
|
||||
}
|
||||
None => {
|
||||
self.command_line
|
||||
.push_output(&format!("Enter new value for {name} <{current}>:"));
|
||||
self.pending_setvar = Some(name.clone());
|
||||
}
|
||||
}
|
||||
return Some(self.finish_dispatch(cmd));
|
||||
}
|
||||
if matches!(name.as_str(), "UCSORTHO" | "UCSVIEW") {
|
||||
use crate::modules::view::view_cmd;
|
||||
let current = i16::from(if name == "UCSORTHO" { view_cmd::ucs_ortho() } else { view_cmd::ucs_view() });
|
||||
|
||||
@@ -136,7 +136,6 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "LAYOUTCREATE");
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.add_layout(&name)
|
||||
.map_err(|e| failure("layout_failed", e))?;
|
||||
let plot_style = self
|
||||
|
||||
@@ -423,6 +423,9 @@ pub struct UserSettings {
|
||||
pub ucs_ortho: bool,
|
||||
/// UCSVIEW: a saved named view keeps the current UCS.
|
||||
pub ucs_view: bool,
|
||||
/// LAYOUTCREATEVIEWPORT: a layout opened for the first time gets a
|
||||
/// viewport.
|
||||
pub layout_create_viewport: bool,
|
||||
/// Nested-copy symbol handling: false inserts, true binds.
|
||||
pub ncopy_bind: bool,
|
||||
/// Last Options page; unknown saved names fall back without rejecting the config.
|
||||
@@ -842,6 +845,7 @@ impl Default for UserSettings {
|
||||
surface_associativity: true,
|
||||
ucs_ortho: true,
|
||||
ucs_view: true,
|
||||
layout_create_viewport: true,
|
||||
ncopy_bind: false,
|
||||
cursor_type: CursorType::Crosshair,
|
||||
crosshair_color: None,
|
||||
|
||||
@@ -796,6 +796,7 @@ impl OpenCADStudio {
|
||||
surface_associativity: crate::scene::model::sweep_model::surface_associativity(),
|
||||
ucs_ortho: crate::modules::view::view_cmd::ucs_ortho(),
|
||||
ucs_view: crate::modules::view::view_cmd::ucs_view(),
|
||||
layout_create_viewport: crate::scene::layout_create_viewport(),
|
||||
ncopy_bind: self.ncopy_bind,
|
||||
cursor_type: self.cursor_type,
|
||||
crosshair_color: self.crosshair_color,
|
||||
@@ -911,6 +912,7 @@ impl OpenCADStudio {
|
||||
crate::scene::model::sweep_model::set_surface_associativity(s.surface_associativity);
|
||||
crate::modules::view::view_cmd::set_ucs_ortho(s.ucs_ortho);
|
||||
crate::modules::view::view_cmd::set_ucs_view(s.ucs_view);
|
||||
crate::scene::set_layout_create_viewport(s.layout_create_viewport);
|
||||
self.ncopy_bind = s.ncopy_bind;
|
||||
self.cursor_type = s.cursor_type;
|
||||
self.crosshair_color = s.crosshair_color;
|
||||
|
||||
@@ -6549,10 +6549,17 @@ properties={:.1}ms picked={}",
|
||||
self.tabs[i].scene.ensure_sheet_viewport(&new_name);
|
||||
let switch_task = self.on_layout_switch(new_name.clone());
|
||||
self.tabs[i].scene.fit_all();
|
||||
self.command_line.push_output(
|
||||
crate::tf!("Layout \"{new_name}\" created — use MVIEW to add a viewport")
|
||||
.as_ref(),
|
||||
);
|
||||
// Opened, it already has its first viewport unless
|
||||
// LAYOUTCREATEVIEWPORT is off.
|
||||
if crate::scene::layout_create_viewport() {
|
||||
let name = new_name.clone();
|
||||
self.command_line.push_output(crate::tf!("Layout '{name}' created.").as_ref());
|
||||
} else {
|
||||
self.command_line.push_output(
|
||||
crate::tf!("Layout \"{new_name}\" created — use MVIEW to add a viewport")
|
||||
.as_ref(),
|
||||
);
|
||||
}
|
||||
// The option that greets every new layout with its page setup.
|
||||
let switch_task = if self.plot_dialog.page_setup_on_new_layout {
|
||||
Task::batch([switch_task, self.on_plot_dialog_open()])
|
||||
|
||||
Reference in new issue
Block a user