Support tracking and direct distance input for grip editing

This commit is contained in:
gianlucafiore committed 2026-08-06 23:35:58 -03:00
1 parent 6752df6ea4
commit 62457be90e
4 files changed
+231 -11

No files matched your search

+24 -5
View File
@@ -22,6 +22,25 @@ use iced::{mouse, Point, Task};
impl OpenCADStudio {
pub(in crate::app) fn active_distance_ray(
&self,
i: usize,
) -> Option<(glam::DVec3, glam::DVec3)> {
// OTRACK already exposes its acquired world-space ray.
if let Some((base, dir)) = self.otrack_active {
return Some((base, dir));
}
// Extension stores the snapped point. Recover the acquired endpoint
// and outward segment direction that produced that snap.
let snap = self.tabs[i].snap_result?;
if snap.snap_type == crate::snap::SnapType::Extension {
return self.snapper.extension_input_ray(snap.world);
}
None
}
/// Rebuild the active tab's dynamic-input field set to match what the
/// command is currently asking for. Called on cursor move and after
/// command-state changes. The field set only changes shape when the
@@ -79,11 +98,11 @@ impl OpenCADStudio {
let has_base = self.last_point.is_some();
// While aligned to an OTRACK ray, the point step reads a single
// distance along the ray (issue #69) — show one Distance box.
let otrack_dist = self.otrack_active.is_some()
let guided_dist = self.active_distance_ray(i).is_some()
&& !wants_text
&& matches!(field, crate::command::DynField::Point);
let default: Vec<DynComponent> = match field {
_ if otrack_dist => vec![DynComponent::Distance],
_ if guided_dist => vec![DynComponent::Distance],
crate::command::DynField::Distance => vec![DynComponent::Distance],
crate::command::DynField::Angle => vec![DynComponent::Angle],
crate::command::DynField::Scalar => vec![DynComponent::Scalar],
@@ -528,9 +547,9 @@ impl OpenCADStudio {
{
return None;
}
// OTRACK: while aligned to a tracking ray, a typed value is a distance
// along the ray from the tracking point (issue #69).
if let Some((base, dir)) = self.otrack_active {
// OTRACK and Extension both allow a typed scalar to act as a
// distance measured along the active reference ray.
if let Some((base, dir)) = self.active_distance_ray(i) {
let wants_text = self.tabs[i]
.active_cmd
.as_ref()