centerAt returns early while the window is hidden, and nothing replays the last position when it comes back, so re-opening the magnifier showed whatever region the cursor was over when it was closed - with current pixels, which makes it look like a live view of the wrong place. Remember the position while hidden and apply it on show. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
#include "JFJochHelperWindow.h"
|
|
#include <QPointF>
|
|
|
|
class JFJochFollowerImage;
|
|
class QImage;
|
|
|
|
// ADXV-style magnifier: a small window showing a high-zoom close-up of the main image that
|
|
// follows the cursor. It displays the frame the main view has already rendered, so it does no
|
|
// conversion or colouring of its own and always agrees with the main view on colour map,
|
|
// contrast and HDR mode.
|
|
class JFJochMagnifierWindow : public JFJochHelperWindow {
|
|
Q_OBJECT
|
|
|
|
JFJochFollowerImage *m_image;
|
|
// Where the cursor last was. Hover positions arriving while the window is hidden are remembered
|
|
// rather than dropped, so re-opening shows the region the cursor is over now and not the one it
|
|
// was over when the window was closed.
|
|
std::optional<QPointF> m_last_scene_pos;
|
|
|
|
public:
|
|
explicit JFJochMagnifierWindow(QWidget *parent = nullptr);
|
|
|
|
// Raw counts for the per-pixel labels. This only stores the pointer - the pixels are
|
|
// displayed from the frame the main view rendered, nothing is converted here.
|
|
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image) override;
|
|
|
|
protected:
|
|
void showEvent(QShowEvent *event) override;
|
|
|
|
public slots:
|
|
void setFrame(std::shared_ptr<const QImage> frame);
|
|
void centerAt(QPointF scenePos);
|
|
};
|