forked from 1b-agent/opencadstudio-upstream
Merge pull request #1362 from ramox81/codex/axis-point-reprompt
Report a missed first 2Points pick at once for Horizontal/Vertical
This commit is contained in:
commit
f137ce96f1
3 files changed
+44
-8
No files matched your search
@@ -3318,6 +3318,31 @@ impl OpenCADStudio {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
CmdResult::CheckHorizontalPoint { kind, pick } => {
|
||||||
|
use crate::modules::parametric::HorizontalConstraintCommand;
|
||||||
|
use crate::scene::parametric_constraints::nearest_parametric_point;
|
||||||
|
|
||||||
|
// The reference rejects a missed first point right away and
|
||||||
|
// asks for it again; a hit moves on to the second point.
|
||||||
|
let scope = self.tabs[i].current_parametric_scope();
|
||||||
|
let found = nearest_parametric_point(
|
||||||
|
&self.tabs[i].scene.document,
|
||||||
|
scope,
|
||||||
|
acadrust::types::Vector3::new(pick.point.x, pick.point.y, pick.point.z),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.is_some();
|
||||||
|
if !found {
|
||||||
|
self.command_line
|
||||||
|
.push_error("No valid constraint point found.");
|
||||||
|
}
|
||||||
|
let command = HorizontalConstraintCommand::resume(kind, found.then_some(pick));
|
||||||
|
self.command_line
|
||||||
|
.push_info(&crate::command::CadCommand::prompt(&command));
|
||||||
|
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||||
|
self.tabs[i].snap_result = None;
|
||||||
|
return Task::none();
|
||||||
|
}
|
||||||
CmdResult::AddHorizontalConstraint {
|
CmdResult::AddHorizontalConstraint {
|
||||||
kind,
|
kind,
|
||||||
selection,
|
selection,
|
||||||
|
|||||||
@@ -1592,6 +1592,13 @@ pub enum CmdResult {
|
|||||||
direction: acadrust::types::Vector3,
|
direction: acadrust::types::Vector3,
|
||||||
label: &'static str,
|
label: &'static str,
|
||||||
},
|
},
|
||||||
|
/// Resolves the first 2Points pick of a Horizontal or Vertical constraint
|
||||||
|
/// against the live document so a miss is reported at once, before the
|
||||||
|
/// second point is asked for.
|
||||||
|
CheckHorizontalPoint {
|
||||||
|
kind: crate::scene::parametric_constraints::ConstraintKind,
|
||||||
|
pick: CoincidentPick,
|
||||||
|
},
|
||||||
/// Adds a point or object symmetry relation around a picked line. The
|
/// Adds a point or object symmetry relation around a picked line. The
|
||||||
/// first reference and axis remain fixed during initial placement.
|
/// first reference and axis remain fixed during initial placement.
|
||||||
AddSymmetricConstraint {
|
AddSymmetricConstraint {
|
||||||
|
|||||||
@@ -321,10 +321,12 @@ impl CadCommand for HorizontalConstraintCommand {
|
|||||||
fn on_point(&mut self, point: DVec3) -> CmdResult {
|
fn on_point(&mut self, point: DVec3) -> CmdResult {
|
||||||
let pick = Self::point_pick(None, point);
|
let pick = Self::point_pick(None, point);
|
||||||
match self.step {
|
match self.step {
|
||||||
Step::ObjectOrTwoPoints | Step::FirstPoint => {
|
// The host resolves the pick against the document: a hit resumes
|
||||||
self.step = Step::SecondPoint(pick);
|
// at the second point, a miss re-asks for the first one at once.
|
||||||
CmdResult::NeedPoint
|
Step::ObjectOrTwoPoints | Step::FirstPoint => CmdResult::CheckHorizontalPoint {
|
||||||
}
|
kind: self.kind,
|
||||||
|
pick,
|
||||||
|
},
|
||||||
Step::SecondPoint(first) => self.finish_points(first, pick),
|
Step::SecondPoint(first) => self.finish_points(first, pick),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -375,10 +377,12 @@ mod tests {
|
|||||||
fn enter_starts_the_two_point_flow() {
|
fn enter_starts_the_two_point_flow() {
|
||||||
let mut command = HorizontalConstraintCommand::new();
|
let mut command = HorizontalConstraintCommand::new();
|
||||||
assert!(matches!(command.on_enter(), CmdResult::NeedPoint));
|
assert!(matches!(command.on_enter(), CmdResult::NeedPoint));
|
||||||
assert!(matches!(
|
let CmdResult::CheckHorizontalPoint { kind, pick } =
|
||||||
command.on_point(DVec3::new(1.0, 2.0, 0.0)),
|
command.on_point(DVec3::new(1.0, 2.0, 0.0))
|
||||||
CmdResult::NeedPoint
|
else {
|
||||||
));
|
panic!("the host must check the first point");
|
||||||
|
};
|
||||||
|
let mut command = HorizontalConstraintCommand::resume(kind, Some(pick));
|
||||||
let CmdResult::AddHorizontalConstraint {
|
let CmdResult::AddHorizontalConstraint {
|
||||||
selection: HorizontalConstraintSelection::Points(first, second),
|
selection: HorizontalConstraintSelection::Points(first, second),
|
||||||
direction,
|
direction,
|
||||||
|
|||||||
Reference in new issue
Block a user