forked from 1b-agent/opencadstudio-upstream
Merge PR #1177: Copy picked nested objects with placement and array options
This commit is contained in:
commit
bfadf1c04e
8 files changed
+77
-13
No files matched your search
@@ -1274,6 +1274,12 @@ impl OpenCADStudio {
|
||||
|
||||
fn apply_cmd_result_inner(&mut self, result: CmdResult) -> Task<Message> {
|
||||
let i = self.active_tab;
|
||||
if let Some(bind) = self.tabs[i].active_cmd.as_ref().and_then(|command| command.nested_copy_bind_setting()) {
|
||||
if self.ncopy_bind != bind {
|
||||
self.ncopy_bind = bind;
|
||||
self.persist_settings_if_changed();
|
||||
}
|
||||
}
|
||||
let preserve_commit_style = self.tabs[i].active_cmd.as_ref()
|
||||
.is_some_and(|command| command.preserve_commit_style());
|
||||
let preserve_commit_layer = self.tabs[i]
|
||||
@@ -1413,7 +1419,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
}
|
||||
CmdResult::CommitEntities(entities) => {
|
||||
CmdResult::CommitEntities(mut entities) => {
|
||||
let locked_source = entities.iter().find_map(|entity| {
|
||||
let handle = entity.common().handle;
|
||||
(!handle.is_null()
|
||||
@@ -1426,10 +1432,19 @@ impl OpenCADStudio {
|
||||
return Task::none();
|
||||
}
|
||||
let label = self.history_label_from_active_cmd(i, "ENTITY");
|
||||
let delta_safe = entities
|
||||
let symbol_names = self.tabs[i].active_cmd.as_ref()
|
||||
.and_then(|command| command.nested_copy_symbol_names()).cloned();
|
||||
let delta_safe = symbol_names.is_none() && entities
|
||||
.iter()
|
||||
.all(|entity| self.delta_add_safe(i, entity));
|
||||
let pending = self.begin_undo(i, label, entities.len(), delta_safe);
|
||||
if let Some(names) = symbol_names {
|
||||
let retained = self.tabs[i].scene.document.localize_nested_copy_symbols(&mut entities, &names);
|
||||
if retained > 0 {
|
||||
self.command_line.push_info(&format!("{} copied object(s) retain imported style references whose dependencies cannot be localized.", retained));
|
||||
}
|
||||
self.refresh_layer_panel();
|
||||
}
|
||||
for entity in entities {
|
||||
if preserve_commit_style {
|
||||
let _ = self.commit_entity_handle_preserve_style(entity);
|
||||
@@ -1449,12 +1464,21 @@ impl OpenCADStudio {
|
||||
self.commit_undo_delta(i, pd);
|
||||
}
|
||||
}
|
||||
CmdResult::CommitEntitiesAndExit(entities) => {
|
||||
CmdResult::CommitEntitiesAndExit(mut entities) => {
|
||||
let label = self.history_label_from_active_cmd(i, "ENTITY");
|
||||
let delta_safe = entities
|
||||
let symbol_names = self.tabs[i].active_cmd.as_ref()
|
||||
.and_then(|command| command.nested_copy_symbol_names()).cloned();
|
||||
let delta_safe = symbol_names.is_none() && entities
|
||||
.iter()
|
||||
.all(|entity| self.delta_add_safe(i, entity));
|
||||
let pending = self.begin_undo(i, label, entities.len(), delta_safe);
|
||||
if let Some(names) = symbol_names {
|
||||
let retained = self.tabs[i].scene.document.localize_nested_copy_symbols(&mut entities, &names);
|
||||
if retained > 0 {
|
||||
self.command_line.push_info(&format!("{} copied object(s) retain imported style references whose dependencies cannot be localized.", retained));
|
||||
}
|
||||
self.refresh_layer_panel();
|
||||
}
|
||||
for entity in entities {
|
||||
if preserve_commit_style {
|
||||
let _ = self.commit_entity_handle_preserve_style(entity);
|
||||
|
||||
@@ -656,7 +656,7 @@ impl OpenCADStudio {
|
||||
|
||||
"NCOPY" | "NCOPYALL" => {
|
||||
let command = crate::modules::draw::modify::ncopy::NcopyCommand::new(
|
||||
&self.tabs[i].scene.document,
|
||||
&self.tabs[i].scene.document, self.ncopy_bind,
|
||||
);
|
||||
self.command_line.push_info(&command.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
|
||||
@@ -509,6 +509,7 @@ pub(super) struct OpenCADStudio {
|
||||
/// Selected-object count past which grips stop being generated
|
||||
/// (GRIPOBJLIMIT, 0..=32767; 0 = no limit).
|
||||
grip_object_limit: i32,
|
||||
ncopy_bind: bool,
|
||||
/// Drawing viewport cursor style (CURSORTYPE).
|
||||
cursor_type: settings::CursorType,
|
||||
/// Explicit crosshair colour; `None` retains automatic contrast.
|
||||
@@ -3526,6 +3527,7 @@ impl OpenCADStudio {
|
||||
double_click_block_refedit: false,
|
||||
double_click_block_attedit: true,
|
||||
grip_object_limit: settings::DEFAULT_GRIP_OBJECT_LIMIT,
|
||||
ncopy_bind: false,
|
||||
cursor_type: settings::CursorType::Crosshair,
|
||||
crosshair_color: None,
|
||||
crosshair_color_input: String::new(),
|
||||
|
||||
@@ -203,6 +203,8 @@ pub struct UserSettings {
|
||||
/// GRIPOBJLIMIT: past this many selected objects, no grips are drawn at
|
||||
/// all. 0 means no limit. The drawing header carries no slot for it.
|
||||
pub grip_object_limit: i32,
|
||||
/// Nested-copy symbol handling: false inserts, true binds.
|
||||
pub ncopy_bind: bool,
|
||||
/// Last Options page; unknown saved names fall back without rejecting the config.
|
||||
#[serde(default, deserialize_with = "deserialize_options_tab")]
|
||||
pub options_tab: crate::ui::window::options::OptionsTab,
|
||||
@@ -386,6 +388,7 @@ impl Default for UserSettings {
|
||||
double_click_block_refedit: false,
|
||||
double_click_block_attedit: true,
|
||||
grip_object_limit: DEFAULT_GRIP_OBJECT_LIMIT,
|
||||
ncopy_bind: false,
|
||||
cursor_type: CursorType::Crosshair,
|
||||
crosshair_color: None,
|
||||
lineweight_display_scale: 100,
|
||||
|
||||
@@ -404,6 +404,7 @@ impl OpenCADStudio {
|
||||
double_click_block_refedit: self.double_click_block_refedit,
|
||||
double_click_block_attedit: self.double_click_block_attedit,
|
||||
grip_object_limit: self.grip_object_limit,
|
||||
ncopy_bind: self.ncopy_bind,
|
||||
cursor_type: self.cursor_type,
|
||||
crosshair_color: self.crosshair_color,
|
||||
lineweight_display_scale: self.lineweight_display_scale,
|
||||
@@ -469,6 +470,7 @@ impl OpenCADStudio {
|
||||
self.double_click_block_refedit = s.double_click_block_refedit;
|
||||
self.double_click_block_attedit = s.double_click_block_attedit;
|
||||
self.grip_object_limit = s.grip_object_limit.clamp(0, 32767);
|
||||
self.ncopy_bind = s.ncopy_bind;
|
||||
self.cursor_type = s.cursor_type;
|
||||
self.crosshair_color = s.crosshair_color;
|
||||
self.crosshair_color_input = s
|
||||
|
||||
Reference in new issue
Block a user