Merge pull request #1409 from ramox81/codex/equal-followups

Equal follow-ups: one glyph per object, unshown Multiple bars, typed object picks
This commit is contained in:
Hakan Seven committed 2026-09-21 22:35:00 +03:00
commit 2208be9506
5 files changed
+47 -8

No files matched your search

+12 -4
View File
@@ -3357,8 +3357,13 @@ impl OpenCADStudio {
|| equal_size_follower(&self.tabs[i].scene.document, first, other) || equal_size_follower(&self.tabs[i].scene.document, first, other)
.is_none() .is_none()
{ {
self.command_line // The reference names the kind the first object
.push_error(EqualConstraintCommand::INVALID_OBJECT); // asks for.
let message = match equal_size(&self.tabs[i].scene.document, first) {
Some(EqualSize::Radius(_)) => EqualConstraintCommand::INVALID_RADIUS_OBJECT,
_ => EqualConstraintCommand::INVALID_LENGTH_OBJECT,
};
self.command_line.push_error(message);
continue; continue;
} }
let exists = self.tabs[i] let exists = self.tabs[i]
@@ -3378,7 +3383,10 @@ impl OpenCADStudio {
} }
followers.push(other); followers.push(other);
} }
if multiple && !finishing { // A refused second object is asked for again, as in the
// reference; Multiple keeps asking anyway.
let keep = (multiple && !finishing) || (!multiple && followers.is_empty());
if keep {
if let Some(prompt) = if let Some(prompt) =
self.tabs[i].active_cmd.as_ref().map(|command| command.prompt()) self.tabs[i].active_cmd.as_ref().map(|command| command.prompt())
{ {
@@ -3599,7 +3607,7 @@ impl OpenCADStudio {
("No valid constraint point found.", Some(first)) ("No valid constraint point found.", Some(first))
} else { } else {
( (
"The object or point is already selected. Select a different object or constraint point.", "The object or point is already selected. Select a different object or constraint point.",
Some(first), Some(first),
) )
}; };
+5 -1
View File
@@ -31,8 +31,12 @@ impl EqualConstraintCommand {
pub const NO_OBJECT: &'static str = "No object found."; pub const NO_OBJECT: &'static str = "No object found.";
pub const INVALID_OBJECT: &'static str = pub const INVALID_OBJECT: &'static str =
"Invalid selection for Equal. Select a line, polyline segment, circle or arc."; "Invalid selection for Equal. Select a line, polyline segment, circle or arc.";
pub const INVALID_LENGTH_OBJECT: &'static str =
"Invalid selection for Equal. Select a line segment, polyline segment, text, MText, major or minor axis of ellipse or elliptical arc.";
pub const INVALID_RADIUS_OBJECT: &'static str =
"Invalid selection for Equal. Select a circle or arc.";
pub const SAME_OBJECT: &'static str = pub const SAME_OBJECT: &'static str =
"The object or point is already selected. Select a different object or constraint point."; "The object or point is already selected. Select a different object or constraint point.";
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
+4
View File
@@ -104,6 +104,10 @@ impl CadCommand for FixConstraintCommand {
true true
} }
fn typed_point_picks_entity(&self) -> bool {
matches!(self.step, Step::Object)
}
fn entity_pick_highlights_hover(&self) -> bool { fn entity_pick_highlights_hover(&self) -> bool {
true true
} }
+5 -1
View File
@@ -200,7 +200,7 @@ impl HorizontalConstraintCommand {
if first.handle == second.handle && (first.point - second.point).length() <= 1.0e-9 { if first.handle == second.handle && (first.point - second.point).length() <= 1.0e-9 {
self.step = Step::SecondPoint(first); self.step = Step::SecondPoint(first);
return CmdResult::ReportError( return CmdResult::ReportError(
"The object or point is already selected. Select a different object or constraint point." "The object or point is already selected. Select a different object or constraint point."
.to_string(), .to_string(),
); );
} }
@@ -269,6 +269,10 @@ impl CadCommand for HorizontalConstraintCommand {
true true
} }
fn typed_point_picks_entity(&self) -> bool {
matches!(self.step, Step::ObjectOrTwoPoints)
}
fn entity_pick_highlights_hover(&self) -> bool { fn entity_pick_highlights_hover(&self) -> bool {
true true
} }
+21 -2
View File
@@ -1859,7 +1859,8 @@ impl super::Scene {
let cam = self.camera.borrow(); let cam = self.camera.borrow();
(cam.view_proj_rte(bounds), cam.eye()) (cam.view_proj_rte(bounds), cam.eye())
}; };
set.constraints let mut placements = set
.constraints
.iter() .iter()
.filter(|c| c.enabled) .filter(|c| c.enabled)
.filter(|c| { .filter(|c| {
@@ -1952,7 +1953,25 @@ impl super::Scene {
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
}) })
.collect() .collect::<Vec<_>>();
// The reference marks an object once for Equal however many
// relations of that kind it carries; the stacked duplicates only
// repeated the same badge.
let mut equal_anchors: Vec<iced::Point> = Vec::new();
placements.retain(|(_, point, _, label, _, _)| {
if label != "=" {
return true;
}
if equal_anchors
.iter()
.any(|seen| (seen.x - point.x).abs() < 0.5 && (seen.y - point.y).abs() < 0.5)
{
return false;
}
equal_anchors.push(*point);
true
});
placements
} }
/// Hit-tests screen point `p` (same coordinate space as `p_full` in the /// Hit-tests screen point `p` (same coordinate space as `p_full` in the