Refactor optical repetition: base view class, shared geometry, and control helpers - #9
Merged
Merged
Conversation
…ntrol helpers A. EditContainerNode._buildControls: extract numberControlOptions(delta, decimalPlaces) factory and buildSegmentLengthControl(element, label, triggerRebuild) helper to eliminate copy-pasted NumberControl options (~10 occurrences) and lenProp/lazyLink blocks (5 occurrences for BeamSource, IdealLens, IdealCurvedMirror, SegmentMirror/LineBlocker, TransmissionGrating/ReflectionGrating). B. Create BaseOpticalElementView abstract base class (Node subclass) with abstract bodyDragListener, onRebuild callback, and abstract rebuild(). Update all 19 *View classes to extend it, removing duplicate field declarations and widening rebuild() from private to protected override. GlassView satisfies bodyDragListener via getter; SphericalLensView inherits through GlassView. C. Move circumcenter and sampleArcPoints to Geometry.ts. ArcMirrorView.ts imports them from there instead of defining them locally. ArcMirror.ts replaces its linesIntersection-of-perpendicularBisectors approach with the shared circumcenter(). https://claude.ai/code/session_01Mm6vZucruGjT52Za6wSAQD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A. EditContainerNode._buildControls: extract numberControlOptions(delta, decimalPlaces)
factory and buildSegmentLengthControl(element, label, triggerRebuild) helper to
eliminate copy-pasted NumberControl options (~10 occurrences) and lenProp/lazyLink
blocks (5 occurrences for BeamSource, IdealLens, IdealCurvedMirror,
SegmentMirror/LineBlocker, TransmissionGrating/ReflectionGrating).
B. Create BaseOpticalElementView abstract base class (Node subclass) with abstract
bodyDragListener, onRebuild callback, and abstract rebuild(). Update all 19 *View
classes to extend it, removing duplicate field declarations and widening rebuild()
from private to protected override. GlassView satisfies bodyDragListener via getter;
SphericalLensView inherits through GlassView.
C. Move circumcenter and sampleArcPoints to Geometry.ts. ArcMirrorView.ts imports them
from there instead of defining them locally. ArcMirror.ts replaces its
linesIntersection-of-perpendicularBisectors approach with the shared circumcenter().
https://claude.ai/code/session_01Mm6vZucruGjT52Za6wSAQD