Is your feature request related to a problem? Please describe.
Yes. The codebase currently contains a significant amount of duplicate code related to the structure tree data models.
Specifically, the classes StructureTreeItem and StructureTreeModel are defined almost identically in two separate files:
brainrender_napari/widgets/structure_view.py
brainrender_napari/data_models/structure_tree_model.py
This introduces a clear maintenance risk. If a bug is fixed or a feature is added to one implementation, the same change must be manually applied to the other. This is error-prone and likely to result in inconsistent behavior over time.
Describe the solution you'd like
I propose refactoring the codebase to consolidate the structure tree model into a single source of truth.
Refactor Plan
-
Keep StructureTreeItem and StructureTreeModel definitions in
brainrender_napari/data_models/structure_tree_model.py
as the canonical implementation
-
Remove the redundant class definitions from:
brainrender_napari/widgets/structure_view.py
-
Update structure_view.py to import the shared model instead:
from brainrender_napari.data_models.structure_tree_model import StructureTreeModel
Is your feature request related to a problem? Please describe.
Yes. The codebase currently contains a significant amount of duplicate code related to the structure tree data models.
Specifically, the classes
StructureTreeItemandStructureTreeModelare defined almost identically in two separate files:brainrender_napari/widgets/structure_view.pybrainrender_napari/data_models/structure_tree_model.pyThis introduces a clear maintenance risk. If a bug is fixed or a feature is added to one implementation, the same change must be manually applied to the other. This is error-prone and likely to result in inconsistent behavior over time.
Describe the solution you'd like
I propose refactoring the codebase to consolidate the structure tree model into a single source of truth.
Refactor Plan
Keep
StructureTreeItemandStructureTreeModeldefinitions inbrainrender_napari/data_models/structure_tree_model.pyas the canonical implementation
Remove the redundant class definitions from:
brainrender_napari/widgets/structure_view.pyUpdate
structure_view.pyto import the shared model instead: