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
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>
105 lines
4.9 KiB
C++
105 lines
4.9 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||
// SPDX-License-Identifier: GPL-3.0-only
|
||
|
||
#include "JFJochCalibrationResultWindow.h"
|
||
|
||
#include <QFrame>
|
||
#include <QHBoxLayout>
|
||
#include <QHeaderView>
|
||
#include <QLabel>
|
||
#include <QTableWidget>
|
||
#include <QVBoxLayout>
|
||
|
||
#include "../../common/JFJochMath.h" // PI
|
||
|
||
namespace {
|
||
constexpr double RAD_TO_DEG = 180.0 / PI;
|
||
|
||
// A big-number "card" for the hero row, as in the merge-statistics window.
|
||
QWidget *MakeCard(const QString &value, const QString &caption, QWidget *parent) {
|
||
auto *card = new QFrame(parent);
|
||
card->setFrameShape(QFrame::StyledPanel);
|
||
auto *l = new QVBoxLayout(card);
|
||
l->setContentsMargins(12, 8, 12, 8);
|
||
l->setSpacing(0);
|
||
auto *v = new QLabel(value, card);
|
||
QFont f = v->font();
|
||
f.setPointSizeF(f.pointSizeF() * 2.2);
|
||
f.setBold(true);
|
||
v->setFont(f);
|
||
v->setStyleSheet("color: #1F3A5F;");
|
||
v->setAlignment(Qt::AlignCenter);
|
||
auto *c = new QLabel(caption, card);
|
||
c->setStyleSheet("color: gray;");
|
||
c->setAlignment(Qt::AlignCenter);
|
||
l->addWidget(v);
|
||
l->addWidget(c);
|
||
return card;
|
||
}
|
||
}
|
||
|
||
JFJochCalibrationResultWindow::JFJochCalibrationResultWindow(const QString &title,
|
||
const CalibrationResult &calibration,
|
||
const DiffractionGeometry &header,
|
||
const QString &poni_path,
|
||
QWidget *parent)
|
||
: QWidget(parent, Qt::Window) {
|
||
setWindowTitle("Detector calibration — " + title);
|
||
setAttribute(Qt::WA_DeleteOnClose);
|
||
resize(640, 380);
|
||
|
||
const DiffractionGeometry &g = calibration.geometry;
|
||
const double pxl_mm = g.GetPixelSize_mm();
|
||
|
||
auto *layout = new QVBoxLayout(this);
|
||
|
||
auto *hero = new QHBoxLayout();
|
||
hero->addWidget(MakeCard(QString::number(calibration.rms_radial_pxl, 'f', 2), "Radial rms [px]", this));
|
||
hero->addWidget(MakeCard(QString::number(calibration.beam_sigma_pxl, 'f', 3), "Beam σ [px]", this));
|
||
hero->addWidget(MakeCard(QString::number(calibration.ring_points), "Ring points", this));
|
||
layout->addLayout(hero);
|
||
|
||
auto *table = new QTableWidget(6, 4, this);
|
||
table->setHorizontalHeaderLabels({"Quantity", "Fitted", "From header", "Change"});
|
||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||
table->verticalHeader()->setVisible(false);
|
||
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||
|
||
const struct { QString name; double fitted; double header; int digits; } rows[] = {
|
||
{"PONI x [px]", g.GetBeamX_pxl(), header.GetBeamX_pxl(), 3},
|
||
{"PONI y [px]", g.GetBeamY_pxl(), header.GetBeamY_pxl(), 3},
|
||
{"Rot1 [°]", g.GetPoniRot1_rad() * RAD_TO_DEG, header.GetPoniRot1_rad() * RAD_TO_DEG, 4},
|
||
{"Rot2 [°]", g.GetPoniRot2_rad() * RAD_TO_DEG, header.GetPoniRot2_rad() * RAD_TO_DEG, 4},
|
||
{"Distance [mm]", g.GetDetectorDistance_mm(), header.GetDetectorDistance_mm(), 4},
|
||
};
|
||
|
||
for (int i = 0; i < 5; i++) {
|
||
const double change = rows[i].fitted - rows[i].header;
|
||
table->setItem(i, 0, new QTableWidgetItem(rows[i].name));
|
||
table->setItem(i, 1, new QTableWidgetItem(QString::number(rows[i].fitted, 'f', rows[i].digits)));
|
||
table->setItem(i, 2, new QTableWidgetItem(QString::number(rows[i].header, 'f', rows[i].digits)));
|
||
table->setItem(i, 3, new QTableWidgetItem(
|
||
QStringLiteral("%1%2").arg(change >= 0 ? "+" : "").arg(change, 0, 'f', rows[i].digits)));
|
||
}
|
||
|
||
// The PONI is the point of normal incidence, which is what the .poni file stores; the direct beam
|
||
// is where the beam actually lands, which is what every other program calls the beam centre. They
|
||
// part company by distance*tan(rot) as soon as the detector is tilted, so show both.
|
||
const auto [beam_x, beam_y] = g.GetDirectBeam_pxl();
|
||
table->setItem(5, 0, new QTableWidgetItem("Direct beam [px]"));
|
||
table->setItem(5, 1, new QTableWidgetItem(QStringLiteral("%1, %2")
|
||
.arg(beam_x, 0, 'f', 3).arg(beam_y, 0, 'f', 3)));
|
||
table->setItem(5, 2, new QTableWidgetItem("—"));
|
||
table->setItem(5, 3, new QTableWidgetItem("—"));
|
||
layout->addWidget(table);
|
||
|
||
auto *note = new QLabel(this);
|
||
note->setWordWrap(true);
|
||
note->setStyleSheet("color: gray;");
|
||
note->setText(QStringLiteral("PONI x = %1 mm, PONI y = %2 mm.%3")
|
||
.arg(g.GetBeamX_pxl() * pxl_mm, 0, 'f', 4)
|
||
.arg(g.GetBeamY_pxl() * pxl_mm, 0, 'f', 4)
|
||
.arg(poni_path.isEmpty() ? QString() : " Written to " + poni_path));
|
||
layout->addWidget(note);
|
||
}
|