Files
Jungfraujoch/viewer/widgets/JFJochViewerSettingsDock.h
T
leonarski_fandFilip Leonarski 19b135186d
Build Packages / Create release (push) Successful in 7s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m56s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 9m10s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 13m51s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 16m56s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 20m59s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 21m25s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 21m17s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 14m14s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m59s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 25m48s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 15m52s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 19m33s
Build Packages / Generate python client (push) Successful in 29s
Build Packages / Build documentation (push) Successful in 1m19s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m49s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 25m31s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 25m24s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 26m5s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 22m19s
Build Packages / Unit tests (push) Failing after 2h28m24s
Build Packages / Validation Battery (push) Successful in 40m33s
v1.0.0-rc.175 (#85)
* Rugnux: Processes a collection live while jfjoch_broker writes it (`rugnux <master.h5> <broker URL>`).
* Rugnux: Processing starts on the first images and confirms its choices once all are in, so analysis can begin during collection.
* Rugnux: Faster processing, especially on servers with several GPUs and CPU sockets and on computers without a GPU (`--no-gpu`, macOS).
* Rugnux: Uses much less GPU memory, so large data sets stay on the GPU of smaller cards, and a data set too large for the card is processed on the CPU instead.
* Rugnux: On macOS, Bragg integration runs on the Apple GPU.
* Rugnux: Better handling of twinning and pseudo-symmetry, with the twin hypothesis written as `<prefix>_twin_<SG>.mtz`, and a wrong `--model` no longer confirms the data or decides the hand.
* Rugnux: `--model` accepts predicted (AlphaFold) models and falls back to molecular replacement when the model is not placed as a rigid body (experimental `--mr` forces it), settling space group, hand and twinning and writing a different answer as `<prefix>_mr.mtz`.
* Rugnux: Molecular replacement is faster and settles the space group in more cases with several copies in the asymmetric unit.
* Rugnux: Deposition-ready mmCIF, a richer report, and numbered steps on the terminal with the full log in `<prefix>_log.txt`; `_P1.mtz`, `--estimate-beam-center` and `--beam-center-search` are removed.
* Rugnux: The beam-stop shadow is found correctly on tilted detectors.
* Rugnux: Stills files that record a stationary goniometer axis get the default stills geometry refinement.
* jfjoch_viewer: "Analyze dataset" uses the same defaults as a bare `rugnux <file>`, and shows the results of processed CBF, marCCD and SMV sweeps.
* jfjoch_viewer: The Files panel refreshes on F5 and every few seconds, and the plot type and other selections stay put during live collection.
* jfjoch_writer: Memory stays bounded and old data files are closed efficiently on long runs, any failure ends the run in an error state the broker is told about, and the master file appears only after its data files; the ZeroMQ pusher logs when a stalled writer makes it drop images.
* Fixes: The TCP image pusher no longer blocks the broker's receiver, GPU out-of-memory failures stop with a clear message, and the XDS plugin masks module and chip edges.

---------

Co-authored-by: Filip Leonarski <jungfrau@filips-mac-mini.home>
Reviewed-on: #85
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-10-16 15:34:43 +02:00

170 lines
8.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <QWidget>
#include <memory>
#include "../../common/DiffractionExperiment.h"
#include "../../common/IndexingSettings.h"
#include "../../common/AzimuthalIntegrationSettings.h"
#include "../../common/BraggIntegrationSettings.h"
#include "../../common/ScalingSettings.h"
#include "../../image_analysis/spot_finding/SpotFindingSettings.h"
#include "../../reader/JFJochReaderDataset.h"
#include "../../reader/JFJochReaderImage.h"
#include "../../rugnux/Rugnux.h" // ProcessMode
#include "../../rugnux/RugnuxDefaults.h"
#include "../ReferenceMtzInfo.h"
#include "PowderCalibrationWidget.h" // CalibrationSelection
class QStackedWidget;
class QCheckBox;
class QComboBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SliderPlusBox;
class NumberLineEdit;
// The single, always-visible settings panel: an MX / AzInt / Calib toggle picks the page, and the panel
// is the one place all processing settings live (there is no separate window, so no synchronisation).
// "Analyze image" / "Analyze dataset" sit on top; the page choice decides what a dataset run does.
// Edits feed straight back into the running analysis via the worker.
class JFJochViewerSettingsDock : public QWidget {
Q_OBJECT
public:
JFJochViewerSettingsDock(const SpotFindingSettings &spot, const IndexingSettings &indexing,
const AzimuthalIntegrationSettings &azint, const BraggIntegrationSettings &bragg,
const ScalingSettings &scaling, QWidget *parent = nullptr);
public slots:
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset);
// A new file, or a run's results shown: the crystal they store is shown but not used until "Known
// unit cell" is ticked, as a bare `rugnux` forgets it (ClearStoredCrystal).
void forgetStoredCrystal();
void loadImage(std::shared_ptr<const JFJochReaderImage> image);
void referenceLoaded(ReferenceMtzInfo info); // worker reports a (un)loaded reference MTZ
// Dataset re-processing reads a stored HDF5 file, so it is unavailable on a live HTTP stream:
// grey out "Analyze dataset" while connected rather than failing with a dialog afterwards.
void setHttpConnection(bool connected, QString addr);
signals:
void spotFindingChanged(const SpotFindingSettings &spot, const IndexingSettings &indexing, int64_t max_spots);
void azintChanged(const AzimuthalIntegrationSettings &settings);
void braggChanged(BraggIntegrationSettings settings);
void scalingChanged(ScalingSettings settings);
void experimentChanged(const DiffractionExperiment &experiment);
void findBeamCenter(QVector<float> ring_q, bool guess, bool refine_tilt);
void ringsFromCalibration(QVector<float> rings);
void referenceSelected(QString path, QString column); // user picked a reference MTZ / SF-mmCIF / column
void modelSelected(QString path); // user picked (or cleared) the atomic model for validation
void reanalyzeImage(bool armed); // "Analyze image" toggle
// "Analyze dataset". The mode is the selected page; the calibrant selection is only read for
// ProcessMode::Calibration and is carried along so the job needs no second copy of the controls.
void analyzeDataset(ProcessMode mode, CalibrationSelection calibration);
private:
SpotFindingSettings spot_;
IndexingSettings indexing_;
AzimuthalIntegrationSettings azint_;
BraggIntegrationSettings bragg_;
ScalingSettings scaling_;
DiffractionExperiment experiment_;
bool have_experiment_ = false; // geometry edits only take effect once a dataset is loaded
int64_t max_spots_ = RUGNUX_MAX_SPOT_COUNT;
// Min-pix is kept as the pair the UI shows - the fixed value AND whether to choose it per image -
// because spot_.min_pix_per_spot can only hold one of the two (unset = per image). SyncMinPix()
// turns the pair into that field, and per-image only ever applies to stills.
bool adaptive_min_pix_ = false;
int64_t min_pix_value_ = 2;
ProcessMode mode_ = ProcessMode::FullAnalysis; // the selected page, and what "Analyze dataset" runs
// "Analyze dataset" hero button, disabled while a live HTTP source is connected.
QPushButton *analyzeDatasetBtn_ = nullptr;
// Indexing-algorithm combo + the description line under it (kept so the Auto resolution refreshes).
QComboBox *algo_ = nullptr;
QLabel *algoDesc_ = nullptr;
// Geometry fields (shared by both MX and AzInt, since both need the same geometry)
NumberLineEdit *energy_ = nullptr;
NumberLineEdit *distance_ = nullptr;
NumberLineEdit *beamX_ = nullptr;
NumberLineEdit *beamY_ = nullptr;
NumberLineEdit *rot1_ = nullptr; // detector tilt (PONI rot1), deg
NumberLineEdit *rot2_ = nullptr; // detector tilt (PONI rot2), deg
// Polarization factor, also shared: it corrects the azimuthal profile and the Bragg intensities
// alike. Unchecked = no polarization correction (the experiment's factor is unset).
QCheckBox *polarizationOn_ = nullptr;
NumberLineEdit *polarization_ = nullptr;
// How the sample moves between images — the three cases a dataset can be, exactly as a file
// stores them (a rotation axis, a grid scan, or neither). The choice sets or clears the
// experiment's goniometer / grid scan, and ApplyProcessingMode() turns it into the
// indexing/scaling mode. Each group keeps its values while another mode is selected.
QRadioButton *modeStill_ = nullptr;
QRadioButton *modeRotation_ = nullptr;
QRadioButton *modeGrid_ = nullptr;
QLineEdit *axisName_ = nullptr;
NumberLineEdit *axisX_ = nullptr, *axisY_ = nullptr, *axisZ_ = nullptr;
NumberLineEdit *rotStart_ = nullptr, *rotIncrement_ = nullptr;
// Not editable here, but part of the file's goniometer — kept so rebuilding the axis from the
// fields does not drop them.
std::optional<Coord> gonioHelicalStep_;
std::optional<float> gonioScreeningWedge_;
// Grid scan. Only the fast-axis point count is a free parameter: the number of slow rows follows
// from the image count (GridScanSettings::ImageNum), which is why there is no second count field
// and why gridSummary_ spells out the grid the settings actually make.
NumberLineEdit *gridNFast_ = nullptr;
NumberLineEdit *gridStepX_ = nullptr, *gridStepY_ = nullptr;
QCheckBox *gridVertical_ = nullptr, *gridSnake_ = nullptr;
QLabel *gridSummary_ = nullptr;
// Crystal fields
QCheckBox *cellKnown_ = nullptr;
NumberLineEdit *cellA_ = nullptr, *cellB_ = nullptr, *cellC_ = nullptr;
NumberLineEdit *cellAlpha_ = nullptr, *cellBeta_ = nullptr, *cellGamma_ = nullptr;
NumberLineEdit *spaceGroup_ = nullptr;
QLabel *spaceGroupName_ = nullptr; // resolved Hermann–Mauguin symbol
// Reference dataset (MTZ) for scaling / CCref. The chosen file is remembered so a
// column change re-loads the same file; the worker owns the reflections, this just drives it.
QPushButton *refButton_ = nullptr;
QComboBox *refColumn_ = nullptr;
QLabel *refSummary_ = nullptr;
QLabel *refWarning_ = nullptr;
QString refPath_;
QPushButton *modelButton_ = nullptr;
QPushButton *modelClear_ = nullptr;
QLabel *modelLabel_ = nullptr;
QString modelPath_;
PowderCalibrationWidget *powder_ = nullptr;
// Azimuthal integration: one section, shared by the AzInt and Calib pages (a calibration by rings
// integrates the run in azimuthal sectors), so it sits outside the page stack and is hidden on MX.
QWidget *azintSection_ = nullptr;
QWidget *BuildGeometrySection();
QWidget *BuildMXPage();
QWidget *BuildGoniometerSection();
QWidget *BuildBraggSection();
QWidget *BuildScalingSection();
QWidget *BuildReferenceSection();
QWidget *BuildAzIntSection();
QWidget *BuildCalibrationPage();
void SyncMinPix();
void EmitSpotFinding();
void EmitExperiment();
void ApplyProcessingMode(); // sample-motion mode -> indexing + scaling rotation/stills mode
void UpdateAlgorithmDescription();
void RefreshGeometryFields();
void UpdateSpaceGroupName();
void EnableRotationFields(bool on);
void EnableGridFields(bool on);
void UpdateGridSummary();
[[nodiscard]] std::optional<GoniometerAxis> GoniometerFromFields() const;
[[nodiscard]] std::optional<GridScanSettings> GridScanFromFields() const;
};