// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "JFJochMagnifierWindow.h" #include "../image_viewer/JFJochFollowerImage.h" #include 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 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 image) { m_image->SetPixelValues(std::move(image)); } void JFJochMagnifierWindow::centerAt(QPointF scenePos) { m_last_scene_pos = scenePos; if (!isVisible()) return; m_image->CenterAt(scenePos); } void JFJochMagnifierWindow::showEvent(QShowEvent *event) { JFJochHelperWindow::showEvent(event); // setFrame keeps the pixels current while hidden, but the centre does not move, so without this // the window re-opens showing wherever the cursor happened to be when it was closed. if (m_last_scene_pos) m_image->CenterAt(*m_last_scene_pos); }