viewer: calibrate a sample cell against its own space group, as the CLI does

The powder-calibration widget built its ring list with CalculateXtalRings(cell),
which assumes a primitive lattice. The overload taking a space group exists
precisely because the fit pairs the innermost OBSERVED ring with the innermost
LISTED one, so a list opening with a reflection the symmetry forbids scales the
whole calibration by the ratio between that ring and the first real one.

rugnux_cli was moved to the new overload when it landed; the viewer was not. So
on any centred sample cell the viewer's calibration was scaled wrong - the exact
failure the overload was added to prevent.

The widget already takes the cell from the loaded dataset; it now takes the group
with it and uses both. Where the dataset has no group the old call stands, which
is the same P-lattice assumption as before and no worse.

Found by a whole-branch review, which saw the two call sites side by side where a
per-commit read of either could not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-02 17:38:40 +02:00
co-authored by Claude Opus 5
parent 7bb74a9dc8
commit 2456bbe7f6
2 changed files with 15 additions and 2 deletions
+11 -2
View File
@@ -80,8 +80,15 @@ std::vector<float> PowderCalibrationWidget::GetCalibrantRings() const {
const auto &table = Calibrants();
if (idx >= 0 && idx < static_cast<int>(table.size()))
return CalibrantRings(table[idx].name);
if (sample_cell)
if (sample_cell) {
// With the group where the dataset has one: the absences then come from the symmetry rather
// than from a bare P-lattice assumption, and a centred cell's list no longer opens with a
// reflection that is not there - which would scale the whole calibration by the ratio between
// that ring and the first real one. Same call the CLI makes.
if (sample_sg)
return CalculateXtalRings(sample_cell.value(), *sample_sg);
return CalculateXtalRings(sample_cell.value());
}
return CalibrantRings(table.front().name);
}
@@ -108,8 +115,10 @@ void PowderCalibrationWidget::updateCalibrantList() {
}
void PowderCalibrationWidget::loadImage(std::shared_ptr<const JFJochReaderImage> image) {
if (image)
if (image) {
sample_cell = image->Dataset().experiment.GetUnitCell();
sample_sg = image->Dataset().experiment.GetGemmiSpaceGroup();
}
updateCalibrantList();
}
+4
View File
@@ -4,6 +4,7 @@
#pragma once
#include <QWidget>
#include <gemmi/symmetry.hpp>
#include <QCheckBox>
#include <QComboBox>
#include <QVector>
@@ -26,6 +27,9 @@ struct CalibrationSelection {
class PowderCalibrationWidget : public QWidget {
Q_OBJECT
std::optional<UnitCell> sample_cell;
// Taken with the cell, and used with it: the ring list a user-supplied cell produces has to carry
// the group's absences, or the fit pairs the innermost OBSERVED ring with a forbidden one.
std::optional<gemmi::SpaceGroup> sample_sg;
QComboBox* calibrantCombo{nullptr}; // stores current calibrant selection
QComboBox* methodCombo{nullptr}; // rings / spots, for the whole-dataset run