forked from 1b-agent/opencadstudio-upstream
feat(ucs): integrate coordinate systems
Route coordinate input, geometry creation, transforms, properties,\nviews, and viewport persistence through a shared working plane.\n\nRefs #484
This commit is contained in:
1 parent
b1d55c6a7e
commit
657d023fb7
61 files changed
+2218
-747
No files matched your search
@@ -417,8 +417,8 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
// independent of DYN: `@` forces relative, `#` forces
|
||||
// absolute, and a bare value is absolute. (Relative-by-
|
||||
// default lives in the DYN tooltip path — see
|
||||
// `dyn_resolve_point` — matching AutoCAD, where the
|
||||
// command line stays absolute regardless of DYN.)
|
||||
// `dyn_resolve_point`; command-line coordinates stay
|
||||
// absolute regardless of the DYN setting.)
|
||||
let want_relative = matches!(kind, CoordKind::Relative);
|
||||
let ucs = self.tabs[i].active_ucs.clone();
|
||||
let wcs_pt = match (want_relative, self.last_point) {
|
||||
@@ -474,7 +474,7 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
}
|
||||
|
||||
self.command_line.push_error(crate::tf!(
|
||||
"Expected coordinates (x,y) or a number, got: \"{text}\""
|
||||
"Expected Cartesian, polar, cylindrical or spherical coordinates, or a number; got: \"{text}\""
|
||||
).as_ref());
|
||||
return self.focus_cmd_input();
|
||||
}
|
||||
@@ -1874,10 +1874,20 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let plane = if self.tabs[i].editing_model_space() {
|
||||
self.tabs[i].ucs_xform().working_plane()
|
||||
} else {
|
||||
crate::command::WorkingPlane::default()
|
||||
};
|
||||
for &handle in &handles {
|
||||
if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
crate::scene::view::dispatch::apply_geom_prop(entity, field, &value);
|
||||
crate::scene::view::dispatch::apply_geom_prop_in_working_plane(
|
||||
entity,
|
||||
field,
|
||||
&value,
|
||||
plane,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1936,6 +1946,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
crate::scene::view::dispatch::set_prop_current_vertex(
|
||||
self.tabs[i].properties.prop_vertex,
|
||||
);
|
||||
let plane = if self.tabs[i].editing_model_space() {
|
||||
self.tabs[i].ucs_xform().working_plane()
|
||||
} else {
|
||||
crate::command::WorkingPlane::default()
|
||||
};
|
||||
for &handle in &handles {
|
||||
// Skip objects on a locked layer.
|
||||
if self.tabs[i].scene.is_layer_locked(handle) {
|
||||
@@ -2007,8 +2022,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
if let Some(entity) =
|
||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
crate::scene::view::dispatch::apply_geom_prop(
|
||||
entity, field, &val,
|
||||
crate::scene::view::dispatch::apply_geom_prop_in_working_plane(
|
||||
entity,
|
||||
field,
|
||||
&val,
|
||||
plane,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,13 +188,15 @@ impl OpenCADStudio {
|
||||
/// values. Locked fields use their typed buffer; the rest fall back to
|
||||
/// the live cursor-derived value. Returns `None` when the field set
|
||||
/// isn't one we know how to turn into a point.
|
||||
/// Hand the active command the current UCS (as a UCS→wire affine) so
|
||||
/// axis-aligned constructions build square to the user's coordinate system.
|
||||
/// No-op for commands that don't override `set_ucs`.
|
||||
/// Hand the active command the current full-precision coordinate frame.
|
||||
pub(in crate::app) fn push_ucs_to_cmd(&mut self, i: usize) {
|
||||
let ucs = self.tabs[i].ucs_wire_affine();
|
||||
let plane = if self.tabs[i].editing_model_space() {
|
||||
self.tabs[i].ucs_xform().working_plane()
|
||||
} else {
|
||||
crate::command::WorkingPlane::default()
|
||||
};
|
||||
if let Some(c) = self.tabs[i].active_cmd.as_mut() {
|
||||
c.set_ucs(ucs);
|
||||
c.set_working_plane(plane);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2086,7 +2086,11 @@ impl OpenCADStudio {
|
||||
match (a, b) {
|
||||
(None, None) => true,
|
||||
(Some(a), Some(b)) => {
|
||||
a.origin == b.origin && a.x_axis == b.x_axis && a.y_axis == b.y_axis
|
||||
a.origin == b.origin
|
||||
&& a.x_axis == b.x_axis
|
||||
&& a.y_axis == b.y_axis
|
||||
&& a.handle == b.handle
|
||||
&& a.name.eq_ignore_ascii_case(&b.name)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user