forked from 1b-agent/opencadstudio-upstream
Merge pull request #1752 from ramox81/codex/refedit-parity
REFEDIT: reference prompts, -REFEDIT, REFSET, nested references and xref write-back
This commit is contained in:
commit
7e763080cb
16 files changed
+1296
-380
No files matched your search
Vendored
+23
@@ -1531,6 +1531,29 @@ pub(crate) fn fade_toward_bg(color: [f32; 4], bg: [f32; 4]) -> [f32; 4] {
|
||||
]
|
||||
}
|
||||
|
||||
/// XFADECTL: how far objects outside the REFEDIT working set fade toward the
|
||||
/// background, in percent (0–90, default 70).
|
||||
static REFEDIT_FADE: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(70);
|
||||
|
||||
pub fn refedit_fade_ctl() -> i32 {
|
||||
REFEDIT_FADE.load(std::sync::atomic::Ordering::Relaxed)
|
||||
}
|
||||
|
||||
pub fn set_refedit_fade_ctl(value: i32) {
|
||||
REFEDIT_FADE.store(value.clamp(0, 90), std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A colour outside the REFEDIT working set, faded by XFADECTL.
|
||||
pub(crate) fn refedit_fade(color: [f32; 4], bg: [f32; 4]) -> [f32; 4] {
|
||||
let t = refedit_fade_ctl().clamp(0, 90) as f32 / 100.0;
|
||||
[
|
||||
color[0] * (1.0 - t) + bg[0] * t,
|
||||
color[1] * (1.0 - t) + bg[1] * t,
|
||||
color[2] * (1.0 - t) + bg[2] * t,
|
||||
color[3],
|
||||
]
|
||||
}
|
||||
|
||||
/// XDWGFADECTL: how far referenced drawings fade toward the background, in
|
||||
/// percent (0–90); zero or negative shows them unfaded.
|
||||
static XREF_FADE: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(50);
|
||||
|
||||
+14
-4
@@ -2147,6 +2147,8 @@ pub struct Scene {
|
||||
/// edited geometry stands out while the surrounding drawing stays visible
|
||||
/// for context. `None` = not editing. (#136)
|
||||
pub refedit_keep: Option<HashSet<Handle>>,
|
||||
/// REFEDIT locks the objects outside the working set (`refedit_keep`).
|
||||
pub refedit_lock: bool,
|
||||
/// COUNT mode colours: counted references in COUNTCOLOR, overlapping
|
||||
/// duplicates in COUNTERRORCOLOR, everything else faded. `None` outside
|
||||
/// count mode.
|
||||
@@ -2775,6 +2777,7 @@ impl Scene {
|
||||
preview_hidden: HashSet::default(),
|
||||
command_preview_hidden: HashSet::default(),
|
||||
refedit_keep: None,
|
||||
refedit_lock: false,
|
||||
count_display: None,
|
||||
hover_highlight: None,
|
||||
constraint_hover_highlights: HashSet::default(),
|
||||
@@ -4337,7 +4340,7 @@ impl Scene {
|
||||
);
|
||||
if let Some(keep) = &self.refedit_keep {
|
||||
if !keep.contains(&h) {
|
||||
material.diffuse = crate::scene::cache::block_cache::fade_toward_bg(
|
||||
material.diffuse = crate::scene::cache::block_cache::refedit_fade(
|
||||
material.diffuse,
|
||||
bg,
|
||||
);
|
||||
@@ -4393,7 +4396,7 @@ impl Scene {
|
||||
.is_some_and(|keep| !keep.contains(&handle))
|
||||
{
|
||||
material.diffuse =
|
||||
crate::scene::cache::block_cache::fade_toward_bg(material.diffuse, bg);
|
||||
crate::scene::cache::block_cache::refedit_fade(material.diffuse, bg);
|
||||
}
|
||||
if self.meshes.contains_key(&handle) {
|
||||
material.diffuse = self.count_color(handle, material.diffuse, bg);
|
||||
@@ -4538,7 +4541,7 @@ impl Scene {
|
||||
let keep_bright =
|
||||
Self::handle_from_wire_name(&w.name).is_some_and(|h| keep.contains(&h));
|
||||
if !keep_bright {
|
||||
w.color = crate::scene::cache::block_cache::fade_toward_bg(w.color, bg);
|
||||
w.color = crate::scene::cache::block_cache::refedit_fade(w.color, bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9389,6 +9392,13 @@ impl Scene {
|
||||
.layers
|
||||
.get(&entity.common().layer)
|
||||
.is_some_and(|l| l.is_locked())
|
||||
// REFEDIT with "Lock objects not in working set": only the
|
||||
// working set can be edited.
|
||||
|| (self.refedit_lock
|
||||
&& self
|
||||
.refedit_keep
|
||||
.as_ref()
|
||||
.is_some_and(|keep| !keep.contains(&handle)))
|
||||
}
|
||||
|
||||
/// The name of the locked layer `handle` sits on, if any (for messages).
|
||||
@@ -9682,7 +9692,7 @@ impl Scene {
|
||||
};
|
||||
if let Some(keep) = &self.refedit_keep {
|
||||
if !keep.contains(&h) {
|
||||
c = crate::scene::cache::block_cache::fade_toward_bg(c, self.current_bg());
|
||||
c = crate::scene::cache::block_cache::refedit_fade(c, self.current_bg());
|
||||
}
|
||||
}
|
||||
Some(c)
|
||||
|
||||
Reference in new issue
Block a user