feat(layers): add non-printing layer support

This commit is contained in:
gianlucafiore committed 2026-08-20 20:37:27 -03:00
1 parent b1b5d31be5
commit eb5cbaeca0
7 files changed
+192 -6

No files matched your search

+41 -1
View File
@@ -339,8 +339,48 @@ pub(crate) fn tessellate_entity_dim_text(
}
wires
}
pub(crate) fn tessellate_entity(
document: &acadrust::CadDocument,
selected: &HashSet<Handle>,
active_viewport: Option<Handle>,
bg_color: [f32; 4],
anno_scale: f32,
annotation_scale_handle: Option<Handle>,
e: &EntityType,
block_cache: Option<&cache::block_cache::BlockCache>,
view_aabb: Option<[f32; 4]>,
world_per_pixel: Option<f32>,
paper_space: bool,
) -> Vec<WireModel> {
let mut wires = tessellate_entity_inner(
document,
selected,
active_viewport,
bg_color,
anno_scale,
annotation_scale_handle,
e,
block_cache,
view_aabb,
world_per_pixel,
paper_space,
);
let layer_plottable = document
.layers
.get(&e.common().layer)
.map(|layer| layer.is_plottable)
.unwrap_or(true);
if !layer_plottable {
for wire in &mut wires {
wire.plot_visible = false;
}
}
wires
}
fn tessellate_entity_inner(
document: &acadrust::CadDocument,
selected: &HashSet<Handle>,
active_viewport: Option<Handle>,
+46 -2
View File
@@ -1144,9 +1144,31 @@ impl Scene {
viewport,
None,
false,
false,
)
}
pub(super) fn instanced_plot_hatch_models(
&self,
layout_block: Handle,
hatch_bg: [f32; 4],
frozen: Option<&rustc_hash::FxHashSet<Handle>>,
annotation_scale_handle: Option<Handle>,
all_visible: bool,
viewport: Option<Handle>,
) -> Vec<HatchModel> {
self.instanced_hatch_models_filtered(
layout_block,
hatch_bg,
false,
frozen,
annotation_scale_handle,
all_visible,
viewport,
None,
false,
true,
)
}
/// Build live hatch overlays for INSERT grip previews. The edited INSERT
/// is intentionally hidden from the resident scene while its current
/// document entity moves, so include that hidden target and reuse the full
@@ -1183,6 +1205,7 @@ impl Scene {
self.active_viewport,
Some(&targets),
true,
false,
)
}
@@ -1197,6 +1220,7 @@ impl Scene {
viewport: Option<Handle>,
targets: Option<&rustc_hash::FxHashSet<Handle>>,
include_preview_hidden: bool,
plot_only: bool,
) -> Vec<HatchModel> {
let depth_map = self.draw_depth_map();
let graph = crate::scene::render_graph::RenderSceneGraph::new(
@@ -1213,10 +1237,21 @@ impl Scene {
graph.walk_root(
self.render_scene_root(layout_block),
|entity, context| {
let common = entity.common();
if plot_only
&& self
.document
.layers
.get(&common.layer)
.is_some_and(|layer| !layer.is_plottable)
{
return false;
}
if context.is_instanced() {
return true;
}
let common = entity.common();
if self.object_isolation.hides(common.handle)
|| (!include_preview_hidden
&& self.preview_hidden.contains(&common.handle))
@@ -1254,6 +1289,15 @@ impl Scene {
let EntityType::Hatch(source_hatch) = entity else {
return;
};
if plot_only
&& self
.document
.layers
.get(&source_hatch.common.layer)
.is_some_and(|layer| !layer.is_plottable)
{
return;
}
let style = context.style_for(&self.document, entity);
let preserve_white_mask = source_hatch.is_solid
&& matches!(
+19 -2
View File
@@ -482,6 +482,16 @@ impl Scene {
models.extend(instanced);
Arc::new(models)
}
pub fn paper_plot_hatches(&self) -> Arc<Vec<HatchModel>> {
let layout_block = self.current_layout_block_handle();
Arc::new(self.plot_hatches_for_block(
layout_block,
None,
self.paper_annotation_scale_handle(),
self.annotation_all_visible(),
))
}
/// Plot-only hatch set for a specific block. Paper PDF generation uses this
/// for the model block behind each floating viewport; unlike
@@ -500,6 +510,13 @@ impl Scene {
.map(|l| l.flags.off || l.flags.frozen)
.unwrap_or(false)
};
let layer_plottable = |layer: &str| {
self.document
.layers
.get(layer)
.map(|l| l.is_plottable)
.unwrap_or(true)
};
let mut models = Vec::new();
for (&handle, model) in self.hatches.iter() {
let Some(source) = self.document.get_entity(handle) else {
@@ -515,6 +532,7 @@ impl Scene {
if common.invisible
|| self.entity_temporarily_hidden(handle)
|| layer_hidden(&common.layer)
|| !layer_plottable(&common.layer)
|| self.layer_frozen_in(&common.layer, frozen)
|| crate::scene::annotative::annotative_offscale_for(
&self.document,
@@ -554,10 +572,9 @@ impl Scene {
}
models.push(hatch);
}
models.extend(self.instanced_hatch_models(
models.extend(self.instanced_plot_hatch_models(
block,
self.paper_bg_color,
false,
frozen,
annotation_scale_handle,
all_visible,