forked from 1b-agent/opencadstudio-upstream
feat(layer-state): add saved-state editor
This commit is contained in:
1 parent
1e624cc6b7
commit
6ecd67ff6e
12 files changed
+691
-14
No files matched your search
Vendored
+9
-2
@@ -78,6 +78,7 @@ pub struct LocalWire {
|
||||
/// *layer* (the layer-0 inheritance rule) instead of the cached layer-0
|
||||
/// value baked here.
|
||||
pub color_l0: bool,
|
||||
pub transparency_l0: bool,
|
||||
pub lt_l0: bool,
|
||||
pub lw_l0: bool,
|
||||
/// XY bounding box of this wire in block-local coordinates.
|
||||
@@ -641,6 +642,7 @@ fn tessellate_sub_local(
|
||||
let on_l0 = crate::scene::view::render::is_effective_layer_zero(&sub.common().layer);
|
||||
let color_l0 =
|
||||
!has_book_color && on_l0 && sub.common().color == AcadColor::ByLayer;
|
||||
let transparency_l0 = on_l0 && sub.common().transparency.alpha() == 0;
|
||||
let lt_l0 = on_l0 && {
|
||||
let lt = &sub.common().linetype;
|
||||
lt.is_empty() || lt.eq_ignore_ascii_case("bylayer")
|
||||
@@ -719,6 +721,7 @@ fn tessellate_sub_local(
|
||||
lt_is_byblock,
|
||||
lw_is_byblock,
|
||||
color_l0: color_l0 && wire_on_base_color,
|
||||
transparency_l0: transparency_l0 && wire_on_base_color,
|
||||
lt_l0,
|
||||
lw_l0,
|
||||
aabb_local,
|
||||
@@ -1542,8 +1545,12 @@ fn resolve_wire_color(lw: &LocalWire, ctx: &ExpandCtx) -> [f32; 4] {
|
||||
} else if lw.color_is_byblock {
|
||||
ctx.ins_color
|
||||
} else if lw.color_l0 {
|
||||
// Inherit the insert layer's RGB but keep the child's own transparency.
|
||||
[ctx.l0.color[0], ctx.l0.color[1], ctx.l0.color[2], lw.color[3]]
|
||||
let alpha = if lw.transparency_l0 {
|
||||
ctx.l0.color[3]
|
||||
} else {
|
||||
lw.color[3]
|
||||
};
|
||||
[ctx.l0.color[0], ctx.l0.color[1], ctx.l0.color[2], alpha]
|
||||
} else {
|
||||
lw.color
|
||||
};
|
||||
|
||||
+4
-1
@@ -588,7 +588,10 @@ impl Scene {
|
||||
.map(|l| &l.color)
|
||||
.unwrap_or(&acadrust::types::Color::WHITE);
|
||||
let [r, g, b, _] = crate::scene::convert::tess_util::aci_to_rgba(color);
|
||||
[r, g, b, 1.0]
|
||||
let alpha = layer_entry
|
||||
.map(|layer| 1.0 - layer.transparency.as_percent() as f32)
|
||||
.unwrap_or(1.0);
|
||||
[r, g, b, alpha]
|
||||
}
|
||||
|
||||
pub fn custom_block_names(&self) -> Vec<String> {
|
||||
|
||||
@@ -1575,7 +1575,16 @@ pub(in crate::scene) fn render_style_for(
|
||||
_ => 0,
|
||||
};
|
||||
let [r, g, b, _] = tess_util::aci_to_rgba(resolved);
|
||||
let alpha = 1.0 - e.common().transparency.as_percent() as f32;
|
||||
let transparency = if common.transparency.alpha() == 0 {
|
||||
document
|
||||
.layers
|
||||
.get(layer_name)
|
||||
.map(|layer| layer.transparency)
|
||||
.unwrap_or(common.transparency)
|
||||
} else {
|
||||
common.transparency
|
||||
};
|
||||
let alpha = 1.0 - transparency.as_percent() as f32;
|
||||
([r, g, b, alpha], aci)
|
||||
};
|
||||
|
||||
@@ -1648,12 +1657,15 @@ pub(crate) fn layer_render_style(document: &CadDocument, layer_name: &str) -> In
|
||||
let layer = document.layers.get(layer_name);
|
||||
let color = layer.map(|l| &l.color).unwrap_or(&AcadColor::WHITE);
|
||||
let [r, g, b, _] = tess_util::aci_to_rgba(color);
|
||||
let alpha = layer
|
||||
.map(|layer| 1.0 - layer.transparency.as_percent() as f32)
|
||||
.unwrap_or(1.0);
|
||||
let lt_name = layer.map(|l| l.line_type.as_str()).unwrap_or("Continuous");
|
||||
let lt_scale = document.header.linetype_scale as f32;
|
||||
let (pat_len, pat) = resolve_pattern(&document.line_types, lt_name, lt_scale);
|
||||
let lw = layer.map(|l| &l.line_weight).unwrap_or(&LineWeight::Default);
|
||||
InheritStyle {
|
||||
color: [r, g, b, 1.0],
|
||||
color: [r, g, b, alpha],
|
||||
pat_len,
|
||||
pat,
|
||||
lw_px: lineweight_to_px(lw),
|
||||
@@ -1694,8 +1706,12 @@ pub(crate) fn render_style_for_block_sub(
|
||||
let final_color = if !has_book_color && common.color == AcadColor::ByBlock {
|
||||
insert_color
|
||||
} else if !has_book_color && on_l0 && common.color == AcadColor::ByLayer {
|
||||
// Inherit the insert layer's RGB but keep the child's own transparency.
|
||||
[l0.color[0], l0.color[1], l0.color[2], color[3]]
|
||||
let alpha = if common.transparency.alpha() == 0 {
|
||||
l0.color[3]
|
||||
} else {
|
||||
color[3]
|
||||
};
|
||||
[l0.color[0], l0.color[1], l0.color[2], alpha]
|
||||
} else {
|
||||
color
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user