Files
Jungfraujoch/viewer/windows/JFJochMagnifierWindow.cpp
T
leonarski_fandClaude Opus 5 7a893bb1e7 Viewer: per-pixel counts in the magnifier, read from the int32 image
Users expect a magnifier to tell them the counts, which the follower view could
not do: it has the rendered pixels but not the numbers behind them.

Take them from the detector's int32 buffer directly, the same source the main
view colours from, so no float copy of the image is needed - the magnifier
still holds nothing full-size of its own, only a shared_ptr to the frame and
one to the reader image.

The labels are painted in drawForeground() rather than as scene items. The main
view creates up to 5000 QGraphicsSimpleTextItems per overlay rebuild for this;
here they are just drawn, so there is no item churn and no scene invalidation.
Text is laid out in viewport pixels so it stays a constant readable size, and
black/white is chosen from the luminance of the rendered pixel underneath, as
the main view does.

Threshold is the same 30x as the main view, so the default 12x magnification
shows no labels until the user wheels in; a cap keeps pathological window sizes
from drawing thousands of them.

Verified in the GUI at 32x: counts drawn per pixel with white text over the
dark centre of a Bragg peak and black elsewhere, and "Gap" across a module gap.
Main image panel still pixel-identical to the pre-series baseline.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-26 21:18:20 +02:00

30 lines
1015 B
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "JFJochMagnifierWindow.h"
#include "../image_viewer/JFJochFollowerImage.h"
JFJochMagnifierWindow::JFJochMagnifierWindow(QWidget *parent)
: JFJochHelperWindow(parent) {
setWindowTitle("Magnifier");
m_image = new JFJochFollowerImage(this);
setCentralWidget(m_image);
resize(320, 320);
}
void JFJochMagnifierWindow::setFrame(std::shared_ptr<const QImage> frame) {
// Just a pointer assignment plus an update() that a hidden window never acts on, so this
// needs no visibility guard: there is nothing expensive left to skip.
m_image->SetFrame(std::move(frame));
}
void JFJochMagnifierWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage> image) {
m_image->SetPixelValues(std::move(image));
}
void JFJochMagnifierWindow::centerAt(QPointF scenePos) {
if (!isVisible())
return;
m_image->CenterAt(scenePos);
}