Files
Jungfraujoch/viewer/widgets/JFJochViewerMagnifier.cpp
T
leonarski_fandClaude Opus 5.5 4d90053899 Viewer and preview show a panel detector as it lies on the detector plane
With a panel table, the viewer and the broker preview gather the stored image
onto the detector plane (AssembleToPlane) and draw on that: spots,
predictions, rings, beam centre and ROIs are plane coordinates, so they now
land on the right pixels for a stored (stacked or moved-module) layout, where
they were drawn as image pixels before. The viewer scene is the plane; its
image item sits at the raster's origin (JFJochImage::origin_, zero for a flat
detector). Mouse readout, pixel labels and the magnifier read the shown
raster; top pixels and saturation crosses are mapped from the stored pixel to
the plane; an ROI turned into a user mask is tested per stored pixel at its
plane position.

A flat detector (empty table) takes the old path verbatim: the shown pixels
alias the image, origin (0, 0) - a JF/EIGER file renders identically.

common/AssembleToPlane.h is a TEMPORARY header-only version so this stage
builds on its own; stage 3 owns the file and its version replaces this one at
merge (callers use AssembleToPlane(modules, image, width, height,
PlaneBounds, gap) -> PlaneRaster{x0, y0, width, height, pixels}).

Test: PreviewImage_PanelLayout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
2026-10-21 10:28:23 +02:00

71 lines
2.6 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "JFJochViewerMagnifier.h"
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QToolButton>
#include <QVBoxLayout>
JFJochViewerMagnifier::JFJochViewerMagnifier(QWidget *parent) : QWidget(parent) {
auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
// Screen pixels per detector pixel and label font size; the labels are sized to fit a
// six-digit count inside its pixel.
struct Level { const char *name; const char *tooltip; double zoom; int font_px; };
const Level levels[] = {
{"\u00d764", "Pixel values in large text", 64.0, 15},
{"\u00d732", "Pixel values in small text", 32.0, 9},
{"\u00d710", "Wider field, no pixel values", 10.0, 0},
};
auto buttons = new QHBoxLayout();
auto group = new QButtonGroup(this);
for (const auto &l : levels) {
auto b = new QToolButton(this);
b->setText(QString::fromUtf8(l.name));
b->setToolTip(l.tooltip);
b->setCheckable(true);
group->addButton(b);
buttons->addWidget(b);
connect(b, &QToolButton::toggled, this, [this, l](bool on) {
if (on)
image_->SetZoom(l.zoom, l.font_px);
});
}
buttons->addStretch();
pop_out_ = new QToolButton(this);
connect(pop_out_, &QToolButton::clicked, this, &JFJochViewerMagnifier::popOutClicked);
setPoppedOut(false);
buttons->addWidget(pop_out_);
layout->addLayout(buttons);
image_ = new JFJochFollowerImage(this);
image_->setMinimumHeight(200);
image_->setToolTip("Hold Shift and move the cursor over the diffraction image to update");
image_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layout->addWidget(image_, 1);
connect(image_, &JFJochFollowerImage::fieldChanged, this, &JFJochViewerMagnifier::fieldChanged);
group->buttons().first()->setChecked(true);
}
void JFJochViewerMagnifier::setPoppedOut(bool on) {
pop_out_->setText(on ? "Dock" : "Pop out");
pop_out_->setToolTip(on ? "Put the magnifier back into its panel" : "Show the magnifier in a window of its own");
}
void JFJochViewerMagnifier::setFrame(std::shared_ptr<const QImage> frame) {
image_->SetFrame(std::move(frame));
}
void JFJochViewerMagnifier::setPixelValues(std::shared_ptr<const std::vector<int32_t>> pixels) {
image_->SetPixelValues(std::move(pixels));
}
void JFJochViewerMagnifier::centerAt(QPointF scenePos) {
image_->CenterAt(scenePos);
}