Files
Jungfraujoch/viewer/widgets/JFJochViewerSettingsDock.h
T
leonarski_f 538f3504d3
Build Packages / build:windows:nocuda (push) Successful in 20m4s
Build Packages / Unit tests (push) Skipped
Build Packages / build:viewer-tgz:cpu (push) Successful in 16m5s
Build Packages / build:viewer-tgz:cuda (push) Successful in 17m26s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 27m46s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 20m17s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 26m13s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 23m17s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 28m11s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m30s
Build Packages / build:rpm (rocky8) (push) Successful in 24m34s
Build Packages / build:rpm (rocky9) (push) Successful in 21m30s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 23m33s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 20m18s
Build Packages / DIALS test (push) Successful in 18m23s
Build Packages / XDS test (durin plugin) (push) Successful in 11m30s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 10m16s
Build Packages / XDS test (neggia plugin) (push) Successful in 8m2s
Build Packages / Generate python client (push) Successful in 49s
Build Packages / Build documentation (push) Successful in 1m21s
Build Packages / Create release (push) Skipped
Build Packages / build:windows:cuda (push) Successful in 29m45s
v1.0.0.rc-161 (#71)
This is an UNSTABLE release. It includes many experimental features, as well as many AI generated fixes. We recommend using rc.152 for production use.

* **rugnux: significantly better quality of results, and faster.** A large rework of integration, scaling, merging, geometry refinement and space-group determination, together with measurements the program previously made no attempt at - the direct beam before indexing, the beam stop, the goniometer rotation scale, and the stretches of a sweep the crystal did not deliver. A rotation dataset typically gains observations at better <I/sigma> and R_meas, and every `mx` and `scale` run writes a `<prefix>_report.txt` results report modelled on XDS's `CORRECT.LP`. Many defaults moved with it: spot detection is self-calibrating, beam-stop detection and rotation geometry post-refinement are on, resolution limits default to as far as the detector reaches, and ice-ring handling engages only where the crystal is measured to have ice.
* **jfjoch_viewer:** the beam-stop shadow, the detector calibration and the beam-centre measurement are reachable from "Analyze dataset"; the settings panel reports how the sample moved and how polarized the beam was; image rendering and interaction are faster.
* **Performance:** bitshuffle+LZ4 images are decoded on the GPU rather than on the host, with the bitshuffle inverse fused into preprocessing so the decompressed frame is never held in device memory.
* **Broker, writer, packaging and build:** image-slot lifetime and locking fixes, per-image datasets sized by the images actually written, the Debian/Ubuntu broker package renamed to `jfjoch`, and `image_analysis` compiling under MSVC again.

**Breaking change to the rugnux command line:**
* `--azint-only` and `--scale` are **removed**, replaced by `--mode azint` and `--mode scale`; the full pipeline is `--mode mx` and remains the default. A script passing the old flags now fails with the list of valid modes rather than silently running the wrong one.
* `-t`/`--stride` is **refused on rotation data**: skipping frames cuts every reflection's rocking curve, so the combined fulls and their partiality would be measured over frames the sweep never recorded. Select a contiguous range with `-s`/`-e` instead. `--mode azint` and `--force-still` still take a stride.

**Breaking changes to OpenAPI** - regenerate the client (`jfjoch-client` 1.0.0-rc.161, `frontend/src/client`) or read the affected fields as optional:
* `image_scale_b` is removed from the `plot_type` enum, so a client requesting that plot now gets an error rather than a curve.
* `azim_int_settings.high_q_recipA`, `spot_finding_settings.high_resolution_limit` and `spot_finding_settings.low_resolution_limit` are no longer `required`. All three mean "no limit at that end" when unset and are omitted from the response instead of carrying a placeholder value, which raises in a client generated from an rc.160-or-earlier spec. A value of 0 is still accepted and means the same thing.

**Breaking changes to the stored formats** - a consumer reading these fields must treat them as optional:
* The per-image image-scale B factor is no longer computed, so `/entry/MX/imageScaleBFactor` is absent from newly written HDF5 files and the corresponding key is absent from the CBOR DataMessage and END blocks. Files written by rc.160 and earlier still contain it and still open; nothing in the pipeline reads it any more.
* `_reflns.jfjoch_diffrn_ISa` now carries the whole-range `1/sqrt(a*b)` that XDS's ISa denotes, and the error-model `a` and `b` are reported in XDS's convention; the strong-reflection asymptote moves to `_reflns.jfjoch_diffrn_ISa_asymptotic`. **A file written by an earlier version carries the asymptote under the plain `ISa` name.**

Reviewed-on: #71
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-08-13 17:03:10 +02:00

161 lines
7.9 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 "../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);
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);
void ringsFromCalibration(QVector<float> rings);
void referenceSelected(QString path, QString column); // user picked a reference MTZ / column
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_ = 1000;
// 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 HermannMauguin 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_;
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;
};