All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 8m0s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 7m30s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 7m54s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m41s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m19s
Build Packages / build:rpm (rocky8) (push) Successful in 8m8s
Build Packages / Generate python client (push) Successful in 13s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m57s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 30s
Build Packages / build:rpm (rocky9) (push) Successful in 9m0s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m54s
Build Packages / Unit tests (push) Successful in 1h10m42s
This is an UNSTABLE release. * jfjoch_viewer: Clean-up widgets slightly * jfjoch_viewer: Limit right panel to 600 pixels * jfjoch_viewer: Parse crystal symmetry type * jfjoch_viewer: Grid scan view takes color map and can be fit to zoom Reviewed-on: #10 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
102 lines
3.7 KiB
C++
102 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 "../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 * M_PI / ring);
|
|
}
|
|
emit ringsFromCalibration(q_rings);
|
|
});
|
|
|
|
// Add preset ice rings button below LaB6 calibration
|
|
auto iceRingsButton = new QPushButton("Display ice rings", this);
|
|
connect(iceRingsButton, &QPushButton::clicked, this, [this]() {
|
|
// Set manual rings and enable display
|
|
const QVector<float> ice_rings(ICE_RING_RES_A.begin(), ICE_RING_RES_A.end());
|
|
emit ringsFromCalibration(ice_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);
|
|
refine_row->addWidget(iceRingsButton,2, 1);
|
|
|
|
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:
|
|
if (sample_cell)
|
|
uc = sample_cell.value();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return uc;
|
|
}
|
|
|
|
void PowderCalibrationWidget::updateCalibrantList() {
|
|
calibrantCombo->clear();
|
|
|
|
calibrantCombo->addItem("LaB6");
|
|
calibrantCombo->addItem("Silver Behenate");
|
|
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);
|
|
}
|
|
|