Files
Jungfraujoch/viewer/widgets/JFJochViewerSettingsDock.h
T
leonarski_fandClaude Opus 5 6194fe6fbf
Build Packages / build:viewer-tgz:cpu (push) Successful in 11m45s
Build Packages / build:viewer-tgz:cuda (push) Successful in 17m11s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 18m59s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 21m9s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 24m51s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 25m1s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 21m32s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 17m49s
Build Packages / build:rpm (rocky8) (push) Successful in 23m8s
Build Packages / build:rpm (rocky9) (push) Successful in 20m8s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 20m4s
Build Packages / XDS test (durin plugin) (push) Successful in 10m53s
Build Packages / Generate python client (push) Successful in 28s
Build Packages / Create release (push) Skipped
Build Packages / Build documentation (push) Successful in 1m30s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 23m22s
Build Packages / DIALS test (push) Successful in 18m9s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m55s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 8m56s
Build Packages / Unit tests (push) Successful in 1h54m52s
Build Packages / build:windows:nocuda (push) Canceled after 0s
Build Packages / build:windows:cuda (push) Canceled after 0s
viewer: calibrate the whole dataset from "Analyze dataset"
The powder panel could only calibrate the image on screen. Calibration is now a
third page beside MX and AzInt, so the dataset button runs it over every image the
same way it runs the other two - which is the point, since a powder ring is
measured far better by summing a run than by one frame.

The page carries the calibrant and the method (rings or spots); the interactive
Guess/Refine buttons stay where they were and now share the one calibrant
selection, so there is no second combo to drift. analyzeDataset() carries the
ProcessMode rather than a bool: a third state was coming, and two bools would have
had one combination that cannot be valid.

The calibrant list gains ICE, which it could not offer before: the widget worked
in unit cells, and hexagonal ice has none that generates its rings correctly
(P6_3/mmc would include systematically absent ones). FindCenter now takes the ring
list its first line used to derive, so the interactive path gets ice as well.

The result window leads with the residual rms rather than the fitted sigma. The
sigma is a formal scatter estimate and understates a bad fit badly - measured on
ice, 0.215 px reported against a 1.70 px residual - while the rms separates a
usable fit from one that has locked onto the wrong thing.

A rings run needs the profile binned in azimuth; below four sectors it returns
nothing at all. The viewer raises the count to 32 exactly as the CLI does, and
says so in the panel and in the job dialog rather than doing it silently.

Also fixes a CLI inconsistency this comparison exposed: rugnux's calibration
branch never applied the standard offline analysis defaults, so it measured the
rings in a profile built with the file's polarization factor while every other
mode - and the viewer - uses 0.99. Found because the two disagreed by 0.005 px in
PONI x, and confirmed by reproducing the viewer exactly with --polarization 0.99.
With it applied the CLI and the viewer write byte-identical .poni files on LaB6
by rings, LaB6 by spots, and an iced dataset over 1800 images.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 10:45:39 +02:00

127 lines
5.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 QPushButton;
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;
// "Process as stills" — kept so datasetLoaded can enable it only when the dataset has a goniometer
// (a rotation dataset); it drives indexing/scaling mode via ApplyProcessingMode().
QCheckBox *stills_ = 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
// 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;
QWidget *BuildGeometrySection();
QWidget *BuildMXPage();
QWidget *BuildBraggSection();
QWidget *BuildScalingSection();
QWidget *BuildReferenceSection();
QWidget *BuildAzIntPage();
QWidget *BuildCalibrationPage();
void SyncMinPix();
void EmitSpotFinding();
void EmitExperiment();
void ApplyProcessingMode(); // "Process as stills" -> indexing + scaling rotation/stills mode
void UpdateAlgorithmDescription();
void RefreshGeometryFields();
void UpdateSpaceGroupName();
};