forked from 1b-agent/opencadstudio-upstream
feat(frame): complete frame controls
Preserve frame geometry for selection while separating viewport and plot visibility across supported reference entities. Refs #642
This commit is contained in:
commit
44efb8fd53
88 files changed
+1538
-702
No files matched your search
@@ -711,6 +711,8 @@ pub(crate) fn tessellate_entity(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1063,6 +1065,8 @@ pub(crate) fn tessellate_entity(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1148,14 +1152,21 @@ pub(crate) fn tessellate_entity(
|
||||
wire.render_instance = Some(instance);
|
||||
}
|
||||
}
|
||||
if document.header.xclip_frame != 0 && polygon.len() >= 3 {
|
||||
wires.push(pick::xclip::frame_wire(
|
||||
let frame_mode = crate::scene::frame::mode(
|
||||
document,
|
||||
crate::scene::frame::FrameKind::Xclip,
|
||||
);
|
||||
if polygon.len() >= 3 {
|
||||
let mut frame = pick::xclip::frame_wire(
|
||||
&polygon,
|
||||
format!("{}_xclipframe", h.value()),
|
||||
h.value().to_string(),
|
||||
ins_color,
|
||||
sel,
|
||||
ins_lw_px,
|
||||
));
|
||||
);
|
||||
frame.display_visible = frame_mode != 0;
|
||||
frame.plot_visible = frame_mode == 1;
|
||||
wires.push(frame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,6 +1211,8 @@ pub(crate) fn tessellate_entity(
|
||||
bg_color,
|
||||
false,
|
||||
);
|
||||
let frame_mode = crate::scene::frame::entity_kind(e)
|
||||
.map(|kind| crate::scene::frame::mode(document, kind));
|
||||
for b in &mut bases {
|
||||
b.aci = aci;
|
||||
// SDF text wires carry a glyph-bounds AABB (the true text extent) set
|
||||
@@ -1208,8 +1221,18 @@ pub(crate) fn tessellate_entity(
|
||||
if b.text_verts.is_empty() {
|
||||
set_wire_aabb(b, aabb);
|
||||
}
|
||||
if let Some(mode) = frame_mode {
|
||||
b.display_visible = mode != 0;
|
||||
b.plot_visible = mode == 1;
|
||||
}
|
||||
if matches!(e, EntityType::Wipeout(_)) {
|
||||
b.depth_override = Some(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
// A hidden mask frame remains selectable and appears while selected, but
|
||||
// contributes no visible line work during normal display. The interior
|
||||
// pick triangles remain intact.
|
||||
// Complex linetypes (with embedded shapes / text) expand the *base*
|
||||
// polyline along its tangent. Text-type entities never have a complex
|
||||
// linetype assigned, so we only consult the first wire here — multi-wire
|
||||
@@ -1437,6 +1460,8 @@ fn lod_stub_wire(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1528,6 +1553,8 @@ fn lod_stub_wire_3d(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
|
||||
@@ -127,6 +127,75 @@ pub(crate) fn points_to_ds(
|
||||
(high, low)
|
||||
}
|
||||
|
||||
fn point_cloud_wires(
|
||||
document: &CadDocument,
|
||||
handle: Handle,
|
||||
entity: &EntityType,
|
||||
selected: bool,
|
||||
color: [f32; 4],
|
||||
line_weight_px: f32,
|
||||
) -> Option<Vec<WireModel>> {
|
||||
let EntityType::Extended(extended) = entity else {
|
||||
return None;
|
||||
};
|
||||
let frame_points = crate::entities::extended::point_cloud_frame_lines(extended)?;
|
||||
let rendered = convert(entity, document)?;
|
||||
let RenderObject::Lines(body_points) = rendered.object else {
|
||||
return None;
|
||||
};
|
||||
let (points, points_low) = points_to_ds(body_points);
|
||||
let mut wires = vec![WireModel {
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
pick_tris: Vec::new(),
|
||||
pick_tris_low: Vec::new(),
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: handle.value().to_string(),
|
||||
points,
|
||||
points_low,
|
||||
color,
|
||||
selected,
|
||||
pattern_length: 0.0,
|
||||
pattern: [0.0; 8],
|
||||
line_weight_px,
|
||||
snap_pts: rendered.snap_pts,
|
||||
tangent_geoms: rendered.tangent_geoms,
|
||||
aci: 0,
|
||||
key_vertices: rendered.key_vertices,
|
||||
aabb: WireModel::UNBOUNDED_AABB,
|
||||
plinegen: true,
|
||||
fill_tris: Vec::new(),
|
||||
fill_tris_low: Vec::new(),
|
||||
}];
|
||||
let mode = crate::scene::frame::mode(
|
||||
document,
|
||||
crate::scene::frame::FrameKind::PointCloudClip,
|
||||
);
|
||||
if !frame_points.is_empty() {
|
||||
let (points, points_low) = points_to_ds(frame_points);
|
||||
let mut frame = WireModel::solid(
|
||||
handle.value().to_string(),
|
||||
points,
|
||||
color,
|
||||
selected,
|
||||
);
|
||||
frame.points_low = points_low;
|
||||
frame.line_weight_px = line_weight_px;
|
||||
frame.display_visible = mode != 0;
|
||||
frame.plot_visible = mode == 1;
|
||||
wires.push(frame);
|
||||
}
|
||||
Some(wires)
|
||||
}
|
||||
|
||||
/// Lift a WireModel built in a local frame (a fixed f64 origin subtracted) back
|
||||
/// to absolute world coordinates, re-splitting every position — polyline points
|
||||
/// and SDF glyph vertices — into double-single so it stays precise at UTM scale.
|
||||
@@ -434,6 +503,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -482,6 +553,17 @@ pub fn tessellate(
|
||||
return out;
|
||||
}
|
||||
|
||||
if let Some(wires) = point_cloud_wires(
|
||||
document,
|
||||
handle,
|
||||
entity,
|
||||
selected,
|
||||
color,
|
||||
line_weight_px,
|
||||
) {
|
||||
return wires;
|
||||
}
|
||||
|
||||
// ── Try the kernel path first ───────────────────────────────────────────
|
||||
// Relative-PDSIZE points size their glyph from the current zoom so they
|
||||
// stay a roughly constant on-screen size; otherwise the header-driven path.
|
||||
@@ -728,6 +810,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -775,6 +859,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -824,6 +910,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -854,6 +942,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -914,6 +1004,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -956,6 +1048,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -995,6 +1089,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1027,6 +1123,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1093,6 +1191,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1214,6 +1314,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: polyline_band_width(entity),
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1279,6 +1381,8 @@ pub fn tessellate(
|
||||
fill_is_2d_solid: matches!(entity, EntityType::Solid(_)),
|
||||
render_instance: None,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1287,6 +1391,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1332,6 +1438,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: polyline_band_width(entity),
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1378,6 +1486,8 @@ pub fn tessellate(
|
||||
taper_widths: widths,
|
||||
world_width,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
@@ -1497,6 +1607,8 @@ pub fn tessellate(
|
||||
taper_widths: Vec::new(),
|
||||
world_width: 0.0,
|
||||
depth_override: None,
|
||||
display_visible: true,
|
||||
plot_visible: true,
|
||||
fill_is_3d: false,
|
||||
fill_is_2d_solid: false,
|
||||
render_instance: None,
|
||||
|
||||
Reference in new issue
Block a user