Files
Jungfraujoch/viewer/JFJochViewerWindow.h
T
leonarski_fandClaude Opus 5.5 d397717ff7
Build Packages / Unit tests (push) Successful in 1h11m40s
Build Packages / build:windows:nocuda (push) Successful in 17m39s
Build Packages / build:windows:cuda (push) Successful in 20m10s
Build Packages / build:viewer-tgz:cpu (push) Successful in 10m2s
Build Packages / build:viewer-tgz:cuda (push) Successful in 11m28s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 9m4s
Build Packages / build:rugnux:windows (push) Successful in 11m20s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 7m46s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 16m15s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 16m21s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 18m1s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m19s
Build Packages / build:rpm (rocky8) (push) Successful in 18m17s
Build Packages / build:rpm (rocky9) (push) Successful in 18m48s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 15m59s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 16m19s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m2s
Build Packages / Generate python client (push) Successful in 1m3s
Build Packages / Build documentation (push) Successful in 1m28s
Build Packages / Create release (push) Successful in 18s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 10m50s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 11m15s
Viewer: dock the magnifier, fixed zoom levels, Shift-driven with a frame
The magnifier moves from a helper window into its own dock below the
inspector. It has three fixed zoom levels (x64 and x32 with the pixel
values written on the pixels, x10 without) instead of wheel zoom, and
follows the cursor only while Shift is held over the diffraction image.
Meanwhile the diffraction view draws a frame around the area it covers,
just outside that area so it stays visible at low zoom without hiding the
pixels; releasing Shift (seen by the application-wide key filter, so
wherever the focus is), moving without it or leaving the image hides it.

A "Pop out" button moves the magnifier into a separate window and back.
Qt's own dock floating stays disabled: a floated dock is placed
off-screen on WSLg. Whether it was popped out, and the window geometry,
persist across sessions. The inspector's image statistics become a
collapsible section so a small screen can give the space to the
magnifier. kLayoutVersion is bumped for the new dock.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 13:47:28 +02:00

126 lines
6.0 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <QElapsedTimer>
#include <QMainWindow>
#include <QProgressDialog>
#include <QTimer>
#include "JFJochViewerMenu.h"
#include "../reader/JFJochHDF5Reader.h"
#include "JFJochImageReadingWorker.h"
#include "JFJochViewerDatasetInfo.h"
#include "JFJochViewerStatusBar.h"
#include "toolbar/JFJochViewerToolbarDisplay.h"
class JFJochProcessingJobsWindow;
class JFJochDiffractionImage;
class JFJochHelperWindow;
class JFJochViewerMagnifier;
class QDockWidget;
class QScrollArea;
class JFJochViewerWindow : public QMainWindow {
Q_OBJECT
// Theming is done via the application palette in main() (salmon panels, white entry fields,
// navy accent) so it applies consistently to every widget, including dialogs.
public:
explicit JFJochViewerWindow(QWidget *parent = nullptr, bool dbus = true, const QString &file = "");
~JFJochViewerWindow() override;
private:
JFJochViewerMenu *menuBar;
JFJochImageReadingWorker *reading_worker;
JFJochDiffractionImage *viewer; // central diffraction image
JFJochViewerToolbarDisplay *toolBarDisplay;
JFJochViewerStatusBar *statusbar;
JFJochProcessingJobsWindow *processingJobsWindow;
std::shared_ptr<const JFJochReaderDataset> lastDataset; // added
std::shared_ptr<const JFJochReaderImage> lastImage; // added
// Remote-display frame throttle (see OnImageReady): the newest frame not yet fanned out,
// delivered at most every kRemoteRepaintIntervalMs while a fast producer runs.
std::shared_ptr<const JFJochReaderImage> pendingImage;
QElapsedTimer image_rate_;
QTimer *image_tail_timer_ = nullptr;
void DeliverPendingImage();
QVector<RunData> lastRuns; // for dataset-info docks opened later
QString lastActiveRunId;
QProgressDialog *retryDialog = nullptr;
QDockWidget *lastDatasetInfoDock = nullptr; // most recent dataset-info dock, for docking layout
QDockWidget *inspectorDock = nullptr; // image inspector (former right-hand side panel)
QScrollArea *inspectorScroll = nullptr; // its scroll area; width bounds follow the font
QDockWidget *settingsDock = nullptr; // inline MX/AzInt settings panel
QDockWidget *fileBrowserDock = nullptr; // data-root directory tree, tabbed with settingsDock
QDockWidget *processingDock = nullptr; // processing jobs panel
JFJochViewerMagnifier *magnifier = nullptr;
QDockWidget *magnifierDock = nullptr; // where the magnifier normally sits
JFJochHelperWindow *magnifierWindow = nullptr; // ... and its window when popped out
void PopOutMagnifier();
QByteArray defaultLayoutState; // captured after construction, for "Reset layout"
int datasetInfoCounter = 0; // gives each dataset-info dock a unique objectName
void ResetAllSettings();
void UpdateInspectorWidth();
// Both ways of opening a dataset from outside the file manager - the File menu and D-Bus -
// come through here, so the browser follows the same way for either.
void FollowInFileBrowser(const QString &filename);
QThread *reading_thread;
// Named layouts. Image = just the image + inspector; Processing = also the plots + jobs panel.
enum class Perspective { Image, Processing };
void ApplyPerspective(Perspective p);
// Keyboard shortcuts (F/B/A, Home/End/PageUp/PageDown) are handled in an application-wide
// event filter rather than keyPressEvent, so they work wherever the focus happens to be,
// stepping aside when the focused widget genuinely uses the key (text entry, item views).
bool eventFilter(QObject *obj, QEvent *event) override;
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent *event) override;
private slots:
// Single cross-thread sink for the worker's imageLoaded: fans out to every GUI consumer
// (synchronously, same thread) via imageReady, then acks the worker so it may produce the next.
void OnImageReady(std::shared_ptr<const JFJochReaderImage> image);
// Single cross-thread sink for the worker's datasetLoaded, mirroring OnImageReady: fans out to
// every GUI consumer synchronously via datasetReady, then acks the worker (datasetConsumed) so the
// worker can cap how many datasets are in flight - without this the queued datasetLoaded backlog
// (each event pinning a full dataset) grew without bound in live follow (100 GB OOM).
void OnDatasetReady(std::shared_ptr<const JFJochReaderDataset> dataset);
public slots:
void LoadFile(const QString &filename, qint64 image_number, qint64 summation, bool retry);
void LoadImage(qint64 image_number, qint64 summation);
void NewDatasetInfo();
void OnFileLoadError(QString title, QString message);
void OnFileLoadRetryStatus(bool active, QString message);
signals:
// Internal GUI-thread fan-out of the newest frame: OnImageReady re-emits this to every GUI
// consumer synchronously, then acks via imageConsumed (see OnImageReady).
void imageReady(std::shared_ptr<const JFJochReaderImage> image);
void imageConsumed(); // ack to the worker that one frame has been consumed (backpressure)
// Same GUI-thread fan-out + ack for the dataset stream (see OnDatasetReady).
void datasetReady(std::shared_ptr<const JFJochReaderDataset> dataset);
void datasetConsumed(); // ack to the worker that one dataset has been consumed (backpressure)
void LoadFileRequest(const QString &filename, qint64 image_number, qint64 summation, bool retry);
void LoadImageRequest(int64_t image_number, int64_t summation);
void adjustForegroundButton(bool input);
void adjustBackgroundButton(bool input);
void setAutoForeground(bool val);
void oneShotAutoForeground();
// Re-emitted by the shortcut filter; the navigation toolbar applies the step, clamped.
void stepImage(int steps);
};