feat: zone placement — pin tones to zones, solve density and grade - #719
Merged
Conversation
Spot densitometer made actionable, the way a darkroom enlarging analyser works: pin 1-2 spots on the canvas, step each pin's target zone, and Print Density (one pin) or Density + ISO-R Grade (two pins) solve so the pinned tones print there. Solver bisects the chart's own print_curve so measured/target/achieved share one ruler with the chart and step wedge; pins are ephemeral proofs on the test-strip grammar. Apply commits one undo step and turns the matching autos off so a meter can't re-move the placed tones. No render-path change.
A placed pin is a handle: press it to drag, and the tone under it is re-read as it travels, so finding the spot to meter no longer means clicking, reading, clicking again. A pin still sitting on its own reading follows the tone it lands on; one whose target has been stepped keeps it, and the caption reads "1 · IV⅓ → VI" until the two agree. The solve waits for the drag to end — the two-pin nested bisection is ~15 ms, too slow per mouse-move. Tool gains a crosshair cursor, and a hand over a grabbable pin.
The toolbar toggle and its shortcut go; the strip in the Analysis panel becomes the control. Click zone V, click the photo, and that spot is asked to print there — the zone comes first, which is the order a darkroom analyser works in, and the strip is where you can already see whether the zone is occupied. Clicking the armed cell again cancels; a click on the photo with nothing armed still just meters. Place zones (now the panel's primary action) or Enter over the canvas commits and closes the tool; Esc discards the armed zone, then the pins and their preview. Each row carries its own remove button, and dropping the last pin rolls back to the committed print. Strip height matched to the step wedge above it.
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.
What
The spot densitometer made actionable — what a darkroom enlarging analyser (RH Designs Analyser Pro) does. A new crosshair tool on the canvas toolbar:
→ lands …with the closest achievable zone; the solve pegs at the slider bound like an analyser pegging at grade 5.How
negpy/features/exposure/placement.py: bisection over the chart's ownprint_curve(green/base channel) viacurve_params_from_metrics→print_curve_output→zone_of_encoded, so measured/target/achieved sit on one ruler with the chart and step wedge. Two-pin is a nested bisection (outer grade, inner density pinning the dark tone). Bisection depth matches slider resolution (0.01 density / 1 R) — 2-pin solve ~33 ms.encoded_of_zoneadded besidezone_of_encoded(exact closed-form inverse, same file, so the ruler can't fork).load_file, kept through the one render Apply fires. Patch sampling is a 5×5 mean ofnormalized_logthrough a_sample_normalized_loghelper factored out of the hover probe (hover keeps its 1×1 read).ExposureConfigfields; no CPU/GPU/WGSL work, no parity surface.Docs
USER_GUIDE gains a Zone placement subsection in the Analysis panel section (feeds the in-app ⓘ guide). PIPELINE.md untouched — no pixel math changed.
Verification
tests/test_zone_placement.py): solver landing/clamping/degenerate/split-grade/rounding, controller pin lifecycle, sidebar widget. TDD, each watched fail first.make allgreen; full suite 2947 passed.samples/DSC00448.ARW): one-pin landed 8.326 vs target 8.333; two-pin landed 9.00/3.35 vs targets 9.00/3.33 with grade solving to 159 R; autos, single undo step, Esc grammar and pin ephemerality all asserted.Update — pins are draggable, and read live
1 · IV⅓ → VI— where the pin reads now, and where it is asked to print; the arrow drops once the two agree.tests/test_zone_pin_drag.py+ controller lifecycle cases); headless E2E drives real Qt press/move/release on the overlay: pin placed, dragged, zone re-read (IX⅓ → VI⅔), target retention verified, applied tone landed 8.326 vs target 8.333.Update 2 — the zone strip is the control
Entry point redesigned: the toolbar crosshair button and its (unbound) shortcut are gone.
ToolMode.ZONE_PLACEstays internally (crosshair cursor, pin hit-testing, drop-pins-on-exit).