Skip to content

Split painter.py into smaller modules#57

Merged
bjmorgan merged 5 commits intomainfrom
split-painter
Apr 4, 2026
Merged

Split painter.py into smaller modules#57
bjmorgan merged 5 commits intomainfrom
split-painter

Conversation

@bjmorgan
Copy link
Copy Markdown
Owner

@bjmorgan bjmorgan commented Apr 4, 2026

Summary

Splits rendering/painter.py (1035 lines) into three focused modules (closes #56):

  • precompute.py (389 lines) — scene construction: _PrecomputedScene, _PolyhedronRenderData, _precompute_scene, _apply_slab_clip, _collect_polyhedra_faces
  • painter.py (514 lines) — scene drawing: projection, depth sorting, painter's algorithm, PolyCollection assembly
  • axes_widget.py (172 lines) — crystallographic axes orientation widget (same pattern as legend.py)

Pure move refactor — no logic changes. Also removes a dead from typing import Any import.

Copilot AI review requested due to automatic review settings April 4, 2026 12:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the rendering subsystem by splitting the previously monolithic rendering/painter.py into smaller, single-responsibility modules, aligning with issue #56’s separation of concerns (precomputation vs. drawing vs. widgets) while keeping behavior the same.

Changes:

  • Introduces rendering/precompute.py containing scene precomputation + slab-clip/polyhedra face collection helpers previously in painter.py.
  • Introduces rendering/axes_widget.py containing the crystallographic axes corner widget previously in painter.py.
  • Updates renderer call sites and tests to import _precompute_scene (and related helpers) from hofmann.rendering.precompute.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/hofmann/rendering/precompute.py New module housing view-independent scene precomputation and polyhedra-related helpers.
src/hofmann/rendering/axes_widget.py New module containing the axes-orientation widget drawing routine.
src/hofmann/rendering/painter.py Slimmed to focus on projection/depth sorting and drawing; now imports helpers from the new modules.
src/hofmann/rendering/interactive.py Updated imports to pull _precompute_scene from rendering.precompute.
src/hofmann/rendering/animation.py Updated imports to pull _precompute_scene from rendering.precompute.
tests/test_rendering/test_painter.py Updated imports for moved precompute/polyhedra helpers.
tests/test_rendering/test_animation.py Updated import for moved _precompute_scene.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bjmorgan bjmorgan merged commit 00cd5a7 into main Apr 4, 2026
5 checks passed
@bjmorgan bjmorgan deleted the split-painter branch April 4, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split painter.py into smaller modules

2 participants