forked from 1b-agent/opencadstudio-upstream
refactor: split four oversized files into submodule trees
Break up the four giant files (~29k lines total) into focused submodule
directories, one concern per file. Pure mechanical moves — behavior is
unchanged.
- app/update.rs (9650) -> app/update/{mod,viewport,command,style,file,
dynamic,dialog,util}. The 384-arm update_inner match stays in mod.rs
with thin delegating arms; the 66 fattest arm bodies move to topic
methods. Arm set preserved exactly (384 -> 384).
- scene/mod.rs (9017) -> scene/{mod,entity,tess,hittest,layout,paper,
mspace,project,selection,modify,group_layer,preview}. The impl Scene
body is split across files via inherent-impl-per-file; struct, ctor,
fields and load-time helpers stay in the root. fn count 123 -> 123.
- app/commands.rs (6082) -> app/commands/* grouped by command family.
The 233-arm dispatch match becomes source-ordered per-family
dispatch_* handlers, preserving first-match precedence (233 -> 233).
- app/view.rs (4686) -> app/view/{mod,overlay,modal,viewcube,controls}.
Largest file drops from 9650 to 3343. Builds clean; app launches and
loads plugins with no panic.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
2baabdf4a0
commit
bddc050b3e
39 files changed
+26674
-26113
No files matched your search
@@ -0,0 +1,98 @@
|
||||
// Auto-split from scene/mod.rs. Pure text-move; behaviour unchanged.
|
||||
use super::*;
|
||||
|
||||
impl Scene {
|
||||
// ── Group helpers ──────────────────────────────────────────────────────
|
||||
|
||||
pub fn groups(&self) -> impl Iterator<Item = &acadrust::objects::Group> {
|
||||
self.document.objects.values().filter_map(|obj| match obj {
|
||||
ObjectType::Group(g) => Some(g),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the names of all groups that contain `handle`.
|
||||
pub fn group_names_for_entity(&self, handle: Handle) -> Vec<String> {
|
||||
self.groups()
|
||||
.filter(|g| g.contains(handle))
|
||||
.map(|g| g.name.clone())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Creates a named group from the given handles and registers it in the group dictionary.
|
||||
pub fn create_group(&mut self, name: String, handles: Vec<Handle>) -> Handle {
|
||||
let group_dict_handle = self.document.header.acad_group_dict_handle;
|
||||
let mut group = acadrust::objects::Group::new(&name);
|
||||
group.handle = self.document.allocate_handle();
|
||||
group.owner = group_dict_handle;
|
||||
group.add_entities(handles);
|
||||
let gh = group.handle;
|
||||
self.document.objects.insert(gh, ObjectType::Group(group));
|
||||
if let Some(ObjectType::Dictionary(dict)) =
|
||||
self.document.objects.get_mut(&group_dict_handle)
|
||||
{
|
||||
dict.add_entry(&name, gh);
|
||||
}
|
||||
gh
|
||||
}
|
||||
|
||||
/// Dissolves all groups that contain any of the given handles.
|
||||
/// Returns the number of groups removed.
|
||||
pub fn delete_groups_containing(&mut self, handles: &[Handle]) -> usize {
|
||||
let group_dict_handle = self.document.header.acad_group_dict_handle;
|
||||
let to_delete: Vec<Handle> = self
|
||||
.document
|
||||
.objects
|
||||
.values()
|
||||
.filter_map(|obj| match obj {
|
||||
ObjectType::Group(g) if handles.iter().any(|h| g.contains(*h)) => Some(g.handle),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let count = to_delete.len();
|
||||
for gh in &to_delete {
|
||||
if let Some(ObjectType::Dictionary(dict)) =
|
||||
self.document.objects.get_mut(&group_dict_handle)
|
||||
{
|
||||
dict.entries.retain(|(_, h)| h != gh);
|
||||
}
|
||||
self.document.objects.remove(gh);
|
||||
}
|
||||
count
|
||||
}
|
||||
|
||||
/// If `handle` belongs to any selectable groups, also select all other members of those groups.
|
||||
pub fn expand_selection_for_groups(&mut self, handles: &[Handle]) {
|
||||
let to_add: Vec<Handle> = self
|
||||
.document
|
||||
.objects
|
||||
.values()
|
||||
.filter_map(|obj| match obj {
|
||||
ObjectType::Group(g) if g.selectable && handles.iter().any(|h| g.contains(*h)) => {
|
||||
Some(g.entities.clone())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
for h in to_add {
|
||||
self.selected.insert(h);
|
||||
}
|
||||
self.bump_selection();
|
||||
}
|
||||
|
||||
// ── Layer helpers ──────────────────────────────────────────────────────
|
||||
|
||||
pub fn toggle_layer_visibility(&mut self, name: &str) {
|
||||
if let Some(layer) = self.document.layers.get_mut(name) {
|
||||
layer.flags.off = !layer.flags.off;
|
||||
}
|
||||
self.bump_geometry();
|
||||
}
|
||||
|
||||
pub fn toggle_layer_lock(&mut self, name: &str) {
|
||||
if let Some(layer) = self.document.layers.get_mut(name) {
|
||||
layer.flags.locked = !layer.flags.locked;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user