Files
Jungfraujoch/viewer/widgets/PowderCalibrationWidget.cpp
T
leonarski_f 58c60e03fe viewer: Phase 1b — inline MX/AzInt settings dock
Surface a surgical subset of processing settings in an always-visible dock
instead of hidden windows:

- New JFJochViewerSettingsDock with an MX / AzInt segmented toggle.
  MX page: geometry (energy, distance, beam X/Y), a new unit-cell +
  space-group editor (no such input existed before; enables known-cell
  ffbidx), spot finding (S/N, photon count, min pixels/spot), indexing
  algorithm and geometry refinement. AzInt page: q range / spacing /
  azimuthal bins plus the existing powder-calibration widget.
- Edits feed straight into the worker (UpdateSpotFindingSettings,
  UpdateAzintSettings, UpdateDataset, FindCenter); fields populate from the
  loaded dataset.
- Add CeO2 and Silicon calibrant presets.
- Dock it left, objectName "settingsDock", show it in the Processing
  perspective (hidden in Image).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 16:26:15 +02:00

104 lines
3.7 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "PowderCalibrationWidget.h"
#include <QPushButton>
#include <QGridLayout>
#include <QLabel>
#include "../../common/JFJochMath.h"
#include "../image_analysis/geom_refinement/AssignSpotsToRings.h"
PowderCalibrationWidget::PowderCalibrationWidget(QWidget *parent) : QWidget(parent) {
auto layout = new QVBoxLayout(this);
calibrantCombo = new QComboBox(this);
updateCalibrantList();
auto findBeamCenterButton = new QPushButton("Guess detector calibration", this);
connect(findBeamCenterButton, &QPushButton::clicked,this, &PowderCalibrationWidget::findBeamCenterClicked);
auto optimizeBeamCenterButton = new QPushButton("Refine detector calibration", this);
connect(optimizeBeamCenterButton, &QPushButton::clicked,this, &PowderCalibrationWidget::optimizeBeamCenterClicked);
auto calibrantRingsButton = new QPushButton("Display calibrant rings", this);
connect(calibrantRingsButton, &QPushButton::clicked, this, [this]() {
std::vector<float> rings = CalculateXtalRings(GetCalibrant(), 10);
QVector<float> q_rings;
for (float ring : rings) {
q_rings.append(2 * PI / ring);
}
emit ringsFromCalibration(q_rings);
});
auto refine_row = new QGridLayout();
refine_row->setSpacing(12);
refine_row->addWidget(new QLabel("Calibrant:"),0,0);
refine_row->addWidget(calibrantCombo,0,1);
refine_row->addWidget(findBeamCenterButton,1, 0);
refine_row->addWidget(optimizeBeamCenterButton,1, 1);
refine_row->addWidget(calibrantRingsButton,2, 0);
layout->addLayout(refine_row);
setLayout(layout);
}
UnitCell PowderCalibrationWidget::GetCalibrant() const {
UnitCell uc(LAB6_CELL_A, LAB6_CELL_A, LAB6_CELL_A, 90, 90, 90);
switch (calibrantCombo->currentIndex()) {
case 1:
// T. C. Huang , H. Toraya, T. N. Blanton, Y. Wu, J. Appl. Cryst. 26 (1993), 180-184.
uc = UnitCell(5.1769, 4.7218, 58.380, 89.440, 89.634, 75.854);
break;
case 2:
// CeO2, cubic fluorite (a = 5.4115 Å), NIST SRM 674b.
uc = UnitCell(5.4115, 5.4115, 5.4115, 90, 90, 90);
break;
case 3:
// Silicon, cubic (a = 5.43102 Å), NIST SRM 640.
uc = UnitCell(5.43102, 5.43102, 5.43102, 90, 90, 90);
break;
case 4:
if (sample_cell)
uc = sample_cell.value();
break;
default:
break;
}
return uc;
}
void PowderCalibrationWidget::updateCalibrantList() {
calibrantCombo->clear();
calibrantCombo->addItem("LaB6");
calibrantCombo->addItem("Silver Behenate");
calibrantCombo->addItem("CeO2");
calibrantCombo->addItem("Silicon");
if (sample_cell)
calibrantCombo->addItem(QString("Current sample (%1 %2 %3 %4 %5 %6)")
.arg(QString::number(sample_cell->a, 'f', 1))
.arg(QString::number(sample_cell->b, 'f', 1))
.arg(QString::number(sample_cell->c, 'f', 1))
.arg(QString::number(sample_cell->alpha, 'f', 1))
.arg(QString::number(sample_cell->beta, 'f', 1))
.arg(QString::number(sample_cell->gamma, 'f', 1)));
calibrantCombo->setCurrentIndex(0);
}
void PowderCalibrationWidget::loadImage(std::shared_ptr<const JFJochReaderImage> image) {
if (image)
sample_cell = image->Dataset().experiment.GetUnitCell();
updateCalibrantList();
}
void PowderCalibrationWidget::findBeamCenterClicked() {
emit findBeamCenter(GetCalibrant(), true);
}
void PowderCalibrationWidget::optimizeBeamCenterClicked() {
emit findBeamCenter(GetCalibrant(), false);
}