forked from 1b-agent/opencadstudio-upstream
Merge pull request #1357 from ramox81/codex/vertical-constraint-parity
Match Vertical geometric constraint behavior # Conflicts: # src/app/commands/draw.rs # src/scene/parametric_constraints.rs # src/ui/overlay.rs
This commit is contained in:
commit
3ba7b38934
6 files changed
+267
-88
No files matched your search
+56
-1
@@ -39,11 +39,16 @@ fn is_fixed_glyph(label: &str) -> bool {
|
||||
label == "F" || label == crate::scene::parametric_constraints::FIXED_POINT_GLYPH
|
||||
}
|
||||
|
||||
/// Vertical's two axis-mark labels (`parametric_constraints::vertical_glyph_label`).
|
||||
fn is_vertical_glyph(label: &str) -> bool {
|
||||
label == "│" || label == crate::scene::parametric_constraints::VERTICAL_POINTS_GLYPH
|
||||
}
|
||||
|
||||
fn constraint_glyph_size(label: &str) -> Size {
|
||||
if is_compact_coincident_glyph(label) {
|
||||
return Size::new(COINCIDENT_GLYPH_SIZE, COINCIDENT_GLYPH_SIZE);
|
||||
}
|
||||
if label == "G²" || is_fixed_glyph(label) {
|
||||
if label == "G²" || is_fixed_glyph(label) || is_vertical_glyph(label) {
|
||||
let side = CONSTRAINT_GLYPH_SIZE + CONSTRAINT_GLYPH_PAD_Y * 2.0;
|
||||
return Size::new(side, side);
|
||||
}
|
||||
@@ -157,6 +162,49 @@ fn draw_fixed_constraint_glyph(
|
||||
}
|
||||
}
|
||||
|
||||
/// The reference bar's Vertical mark: a red datum line hatched on its left,
|
||||
/// the constrained direction beside it, plus the orange point marker for a
|
||||
/// two-point relation.
|
||||
fn draw_vertical_constraint_glyph(
|
||||
frame: &mut canvas::Frame,
|
||||
center: Point,
|
||||
text: Color,
|
||||
point_marker: bool,
|
||||
) {
|
||||
let datum = Color::from_rgb8(214, 76, 76);
|
||||
let datum_x = center.x - 2.5;
|
||||
let stroke = canvas::Stroke::default().with_color(datum).with_width(1.5);
|
||||
frame.stroke(
|
||||
&canvas::Path::line(
|
||||
Point::new(datum_x, center.y - 6.5),
|
||||
Point::new(datum_x, center.y + 6.5),
|
||||
),
|
||||
stroke.clone(),
|
||||
);
|
||||
for step in 0..3 {
|
||||
let y = center.y - 4.5 + step as f32 * 4.0;
|
||||
frame.stroke(
|
||||
&canvas::Path::line(Point::new(datum_x, y), Point::new(datum_x - 4.0, y + 3.5)),
|
||||
stroke.clone(),
|
||||
);
|
||||
}
|
||||
frame.stroke(
|
||||
&canvas::Path::line(
|
||||
Point::new(center.x + 2.5, center.y - 6.0),
|
||||
Point::new(center.x + 2.5, center.y + 6.0),
|
||||
),
|
||||
canvas::Stroke::default().with_color(text).with_width(1.4),
|
||||
);
|
||||
if point_marker {
|
||||
frame.stroke(
|
||||
&canvas::Path::rectangle(Point::new(center.x + 4.5, center.y - 2.3), Size::new(4.6, 4.6)),
|
||||
canvas::Stroke::default()
|
||||
.with_color(Color::from_rgb8(224, 130, 62))
|
||||
.with_width(1.2),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn constraint_glyph_box(
|
||||
anchor: Point,
|
||||
outward: [f32; 2],
|
||||
@@ -2091,6 +2139,13 @@ impl canvas::Program<Message> for SelectionCanvas {
|
||||
bg,
|
||||
label == crate::scene::parametric_constraints::FIXED_POINT_GLYPH,
|
||||
);
|
||||
} else if is_vertical_glyph(label) {
|
||||
draw_vertical_constraint_glyph(
|
||||
&mut frame,
|
||||
glyph_center,
|
||||
fg,
|
||||
label == crate::scene::parametric_constraints::VERTICAL_POINTS_GLYPH,
|
||||
);
|
||||
} else {
|
||||
frame.fill_text(canvas::Text {
|
||||
content: label.clone(),
|
||||
|
||||
Reference in new issue
Block a user