forked from 1b-agent/opencadstudio-upstream
Merge pull request #1462 from ramox81:codex/xref-attach-parity
This commit is contained in:
commit
1988424638
47 files changed
+2716
-362
No files matched your search
@@ -3515,6 +3515,46 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let Some(axis) = match field {
|
||||
"xref_x_scale" => Some(0),
|
||||
"xref_y_scale" => Some(1),
|
||||
"xref_z_scale" => Some(2),
|
||||
_ => None,
|
||||
} {
|
||||
// An xref's Scale rows show the scale without the
|
||||
// unit conversion its INSERT carries; write it back
|
||||
// with that conversion.
|
||||
let value = val
|
||||
.trim()
|
||||
.parse::<f64>()
|
||||
.ok()
|
||||
.filter(|v| v.is_finite() && *v != 0.0);
|
||||
if let Some(value) = value {
|
||||
let host = self.tabs[i].scene.document.header.insertion_units;
|
||||
for &handle in &handles {
|
||||
let factor = match self.tabs[i].scene.document.get_entity(handle) {
|
||||
Some(acadrust::EntityType::Insert(ins)) => self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.block_records
|
||||
.get(&ins.block_name)
|
||||
.and_then(|br| {
|
||||
crate::app::properties::insert_unit_scale(host, br.units)
|
||||
})
|
||||
.unwrap_or(1.0),
|
||||
_ => continue,
|
||||
};
|
||||
if let Some(acadrust::EntityType::Insert(ins)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
match axis {
|
||||
0 => ins.set_x_scale(value * factor),
|
||||
1 => ins.set_y_scale(value * factor),
|
||||
_ => ins.set_z_scale(value * factor),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if field == "block" {
|
||||
// Name row on a block reference: an existing name
|
||||
// re-points the selected inserts; a new one renames
|
||||
|
||||
+19
-1
@@ -2149,7 +2149,8 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
let mut recent_task = Task::none();
|
||||
let saved = match crate::io::save_to_bytes(&self.tabs[i].scene.document, &ext, version) {
|
||||
let document = self.tabs[i].scene.document_for_save();
|
||||
let saved = match crate::io::save_to_bytes(&document, &ext, version) {
|
||||
Ok(bytes) => {
|
||||
crate::sys::download_bytes(&filename, &bytes);
|
||||
let cache_name = std::path::Path::new(&filename)
|
||||
@@ -2347,6 +2348,15 @@ impl OpenCADStudio {
|
||||
});
|
||||
let clone_started = iced::time::Instant::now();
|
||||
let mut snapshot = self.tabs[i].scene.document_for_save();
|
||||
// First save: references attached with a relative path type while
|
||||
// the drawing had no file become relative to it.
|
||||
if self.tabs[i].current_path.is_none() && purpose != crate::app::SavePurpose::Autosave {
|
||||
crate::io::xref::make_relative(
|
||||
&mut snapshot,
|
||||
&self.tabs[i].xref_relative_on_save,
|
||||
&path,
|
||||
);
|
||||
}
|
||||
// Save-As across folders: rebase relative reference paths onto the
|
||||
// new base dir inside the snapshot only (live strings are untouched).
|
||||
if purpose == crate::app::SavePurpose::SaveAs {
|
||||
@@ -2649,6 +2659,14 @@ impl OpenCADStudio {
|
||||
}
|
||||
if outcome.set_current_path {
|
||||
let old_path = self.tabs[i].current_path.clone();
|
||||
if old_path.is_none() {
|
||||
let pending = std::mem::take(&mut self.tabs[i].xref_relative_on_save);
|
||||
crate::io::xref::make_relative(
|
||||
&mut self.tabs[i].scene.document,
|
||||
&pending,
|
||||
&outcome.path,
|
||||
);
|
||||
}
|
||||
self.tabs[i].current_path = Some(outcome.path.clone());
|
||||
self.tabs[i].scene.document.version = outcome.version;
|
||||
if outcome.purpose == crate::app::SavePurpose::SaveAs {
|
||||
|
||||
@@ -208,6 +208,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
Some(GeometricTolerance) => self.geometric_tolerance = None,
|
||||
Some(BlockDefinition) => self.block_definition = None,
|
||||
Some(XrefAttach) => self.xref_attach = None,
|
||||
Some(Hyperlink) => {
|
||||
self.hyperlink_editor_handles.clear();
|
||||
self.hyperlink_editor_url.clear();
|
||||
@@ -1354,15 +1355,13 @@ impl OpenCADStudio {
|
||||
),
|
||||
|
||||
Message::XAttachPickResult(Ok(path)) => {
|
||||
use crate::command::CadCommand;
|
||||
use crate::modules::insert::xattach::XAttachCommand;
|
||||
let path_str = path.to_string_lossy().into_owned();
|
||||
let cmd = XAttachCommand::with_path(path_str);
|
||||
let i = self.active_tab;
|
||||
self.command_line.push_info(&cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd));
|
||||
self.open_xref_attach_dialog(path);
|
||||
Task::none()
|
||||
}
|
||||
message @ (Message::AttachPick
|
||||
| Message::AttachPickResult(_)
|
||||
| Message::XrefAttach(_)
|
||||
| Message::XrefAttachBrowseResult(_)) => self.update_xref_attach(message),
|
||||
|
||||
Message::XAttachPickResult(Err(e)) => {
|
||||
if e != "Cancelled" {
|
||||
|
||||
Reference in new issue
Block a user