feat(plot): complete plot workflow

This commit is contained in:
Hakan Seven committed 2026-07-31 12:06:12 +03:00
1 parent eb0861cf6e
commit bd1b5b4293
14 files changed
+1141 -541

No files matched your search

+8 -3
View File
@@ -1238,7 +1238,7 @@ impl Scene {
// Resolve ByBlock / layer-0 inheritance for this block
// child, then adapt to the background (#221). Pattern /
// lineweight args are unused by a hatch's colour.
let color = crate::scene::view::render::render_style_for_block_sub(
let style = crate::scene::view::render::render_style_for_block_sub(
&self.document,
&EntityType::Hatch(dxf.clone()),
sub_ins_color,
@@ -1246,13 +1246,14 @@ impl Scene {
[0.0; 8],
0.0,
sub_l0,
)
.0;
);
let color = style.0;
let color =
crate::scene::view::render::adapt_to_bg(color, hatch_bg);
if let Some(mut model) =
Self::hatch_model_from_dxf(&dxf, color)
{
model.aci = style.4;
// In-block rank → within the insert's depth slot.
model.draw_depth = d_base
+ depth_map
@@ -1358,6 +1359,7 @@ impl Scene {
pattern: model::hatch_model::HatchPattern::Solid,
name: "WIPEOUT_FILL".into(),
color: fill_color,
aci: 0,
angle_offset: 0.0,
scale: 1.0,
world_origin: fill_origin,
@@ -1475,6 +1477,7 @@ impl Scene {
pattern: model::hatch_model::HatchPattern::Solid,
name: "WIPEOUT_FILL".into(),
color: fill_color,
aci: 0,
angle_offset: 0.0,
scale: 1.0,
world_origin: fill_origin,
@@ -2034,6 +2037,7 @@ impl Scene {
// A gradient starts from its first stop; other fills use the
// entity colour.
color: gradient_color1.unwrap_or(color),
aci: 0,
angle_offset: if prebaked { 0.0 } else { dxf.pattern_angle as f32 },
scale: if prebaked { 1.0 } else { dxf.pattern_scale as f32 },
world_origin,
@@ -2338,6 +2342,7 @@ impl Scene {
pattern: model::hatch_model::HatchPattern::Solid,
name: "SOLID".into(),
color,
aci: 0,
angle_offset: 0.0,
scale: 1.0,
world_origin,
+15
View File
@@ -3159,6 +3159,7 @@ impl Scene {
pattern: crate::scene::model::hatch_model::HatchPattern::Solid,
name: "SOLID".to_string(),
color: self.paper_bg_color,
aci: 0,
angle_offset: 0.0,
scale: 1.0,
// Draw-order bias is signed: entity fills/wires land in (-1, 1)
@@ -4823,6 +4824,20 @@ impl Scene {
self.entity_wires_arc()
}
/// Return paper entities and projected model-viewport entities separately.
/// Keeping the two groups distinct lets non-GPU plotters honor the requested
/// paper/model draw order.
pub fn plot_wire_groups(&self) -> (Vec<WireModel>, Vec<WireModel>) {
if self.current_layout == "Model" {
return (self.entity_wires_arc().as_ref().clone(), Vec::new());
}
let paper_block = self.current_layout_block_handle();
(
self.paper_sheet_wires_arc().as_ref().clone(),
self.viewport_content_wires(paper_block, None, None),
)
}
/// Per-entity stable draw-order depth, keyed by entity handle value.
/// A full build assigns sparse labels in effective draw order. Incremental
/// Add/Remove then changes only the named handle: existing siblings retain
+2
View File
@@ -177,6 +177,8 @@ pub struct HatchModel {
pub name: String,
/// RGBA color in [0,1].
pub color: [f32; 4],
/// Effective indexed color used by plot style tables; 0 means RGB/default.
pub aci: u8,
/// Pattern rotation offset in radians (from DXF `pattern_angle`).
/// Applied on top of each family's base angle at render time.
pub angle_offset: f32,
+8 -2
View File
@@ -376,7 +376,9 @@ impl Scene {
}
_ => model.clone(),
};
m.color = self.render_style(entity).0;
let style = self.render_style(entity);
m.color = style.0;
m.aci = style.4;
if let EntityType::Hatch(dxf) = entity {
// Only re-apply pattern_scale/angle for catalog-derived patterns
// (empty stored lines). A pattern built from the hatch's own
@@ -454,7 +456,9 @@ impl Scene {
}
_ => model.clone(),
};
hatch.color = self.render_style(entity).0;
let style = self.render_style(entity);
hatch.color = style.0;
hatch.aci = style.4;
if let EntityType::Hatch(dxf) = entity {
if let model::hatch_model::HatchPattern::Pattern(_) = &hatch.pattern {
if dxf.pattern.lines.is_empty() {
@@ -511,6 +515,7 @@ impl Scene {
pattern: model::hatch_model::HatchPattern::Solid,
name: "WIPEOUT_FILL".into(),
color: self.paper_bg_color,
aci: 0,
angle_offset: 0.0,
scale: 1.0,
world_origin,
@@ -598,6 +603,7 @@ impl Scene {
pattern: model::hatch_model::HatchPattern::Solid,
name: "WIPEOUT_FILL".into(),
color: fill_color,
aci: 0,
angle_offset: 0.0,
scale: 1.0,
world_origin: fill_origin,
+1
View File
@@ -468,6 +468,7 @@ impl Scene {
hatch.color,
false,
);
wire.aci = hatch.aci;
wire.aabb = aabb;
pattern_wires.push(wire);
}