Enable auto levels by default in SkyFit2#921
Conversation
Auto levels are now turned on when SkyFit2 starts, so images appear properly stretched immediately instead of using the full bit range. The histogram region is no longer locked while auto levels are active: dragging the region (or Ctrl+clicking to set a level) switches to manual mode, keeping the auto-determined levels as the starting point. Ctrl+A still toggles auto levels on and off. Full-range setLevels calls on station change and state load now only apply in manual mode so they don't override the auto stretch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8022cf747
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not self.tab.hist.auto_levels: | ||
| self.tab.hist.setLevels(0, 2**(8*self.img.data.itemsize) - 1) |
There was a problem hiding this comment.
Keep the zoom image synced after auto-level reloads
When auto levels are enabled and a station is changed, self.img.changeHandle() recalculates the histogram levels and emits them to img_zoom before self.img_zoom.changeHandle() reloads the zoom image. That reload calls setImage() without levels, so pyqtgraph assigns independent min/max levels to the zoom item; because this guard skips the following hist.setLevels(...), nothing resynchronizes the zoom window. The same ordering exists in the running-state load path, so after switching stations/loading state in default auto mode the zoom view can be stretched differently from the main image.
Useful? React with 👍 / 👎.
img_zoom.changeHandle() reloads the zoom image via setImage() without levels, so pyqtgraph assigns it independent min/max levels. With auto levels on, the histogram was updated before the zoom reload and never re-emitted, leaving the zoom window stretched differently from the main image. The manual path had the same latent issue: setLevels() with an unchanged full range early-returns in setRegion() without emitting. Explicitly reapply the histogram levels to both image items after the reload, matching the existing pattern in updateImage handling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
setLevelscalls on station change and on loading a state into a running instance now only apply in manual mode, so they don't override the auto stretch.Guides/SkyFit.mdaccordingly.Implementation notes
User drags are distinguished from programmatic level updates via pyqtgraph's
movingflags (region.movingfor whole-region drags,line.movingfor edge drags), which are never set bysetRegion(). This means the periodic auto-level updates on image change never kick the user out of auto mode, but any manual interaction does.Saved
.statefiles are unaffected — the histogram widget is never pickled and is rebuilt insetupUI(), so auto levels are on after loading old states too.Testing
🤖 Generated with Claude Code