Files
Jungfraujoch/viewer/windows/JFJochViewerSpotListWindow.cpp
T
leonarski_f 84228bf8be
Build Packages / Create release (push) Successful in 24s
Build Packages / build:viewer:macos-arm64:nocuda (push) Successful in 3m29s
Build Packages / build:rugnux:macos-arm64:nocuda (push) Successful in 2m43s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 8m27s
Build Packages / build:rugnux:linux-x86_64:cuda (push) Successful in 9m53s
Build Packages / build:viewer:linux-x86_64:nocuda (push) Successful in 9m58s
Build Packages / build:viewer:linux-x86_64:cuda (push) Successful in 11m22s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 13m39s
Build Packages / build:viewer:windows-x86_64:nocuda (push) Successful in 18m37s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 16m32s
Build Packages / build:viewer:windows-x86_64:cuda (push) Successful in 24m11s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m30s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 19m3s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 20m23s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 19m41s
Build Packages / Generate python client (push) Successful in 50s
Build Packages / Build documentation (push) Successful in 1m16s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 21m0s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 18m38s
Build Packages / build:rugnux:windows-x86_64:cuda (push) Successful in 14m33s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 17m55s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m50s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 18m38s
Build Packages / Unit tests (push) Successful in 1h46m14s
v1.0.0-rc.173 (#83)
* jfjoch_broker: Optional per-dataset authentication - statistics, images and plots can require a bearer token, which jfjoch_viewer supports.
* jfjoch_viewer: Dark mode and a theme-matched colour scheme, a magnifier panel, and simpler contrast and background controls.
* Rugnux: Multiple performance improvements on GPU and CPU (CPU-only processing up to 40% faster, faster image decoding on ARM), with unchanged results.
* Rugnux: `--model` rigid-body refinement runs on the GPU, and the model-validation check is faster and more reliable.
* Rugnux: Improved scaling and merging - error model, outlier rejection, absorption correction and French-Wilson amplitudes now agree more closely with XDS and ctruncate.
* Rugnux: Improved integration - radial background on powder and ice rings, crowded rotation data keep their reflections, and CPU-only builds integrate large unit cells as GPU builds do.
* Rugnux: More robust detector geometry - measured beam centre, X-ray bandwidth and goniometer rate, and geometry refinement accepted only on significant evidence.
* Rugnux: Merged files are written in the standard setting, or in the setting of a reference MTZ, structure-factor mmCIF or model, with its free-R flags.
* Rugnux: Richer report - ice and powder rings, further lattices, superstructure candidates and mosaicity, with warnings worded as prompts to check.
* Rugnux: Clear error messages when a data set needs more GPU or host memory than is available.

Reviewed-on: #83
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-09-29 15:57:32 +02:00

142 lines
5.1 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "JFJochViewerSpotListWindow.h"
#include <QVBoxLayout>
#include <QHeaderView>
JFJochViewerSpotListWindow::JFJochViewerSpotListWindow(QWidget* parent)
: JFJochHelperWindow(parent) {
QWidget* centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
QVBoxLayout* layout = new QVBoxLayout(centralWidget);
tableView = new QTableView(this);
tableModel = new QStandardItemModel(this);
setupTableModel();
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(tableModel);
proxyModel->setSortRole(Qt::UserRole); // numeric sort based on UserRole
tableView->setModel(proxyModel);
tableView->sortByColumn(2, Qt::DescendingOrder); // default: Intensity desc
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableView->setSortingEnabled(true);
tableView->verticalHeader()->setVisible(false);
tableView->horizontalHeader()->setSectionsClickable(true);
tableView->horizontalHeader()->setSortIndicatorShown(true);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
layout->addWidget(tableView);
setWindowTitle("Observed spots");
resize(800, 600);
connect(tableView, &QTableView::doubleClicked,
this, &JFJochViewerSpotListWindow::onTableRowDoubleClicked);
}
void JFJochViewerSpotListWindow::setupTableModel()
{
// Columns: 0..11
tableModel->setColumnCount(12);
tableModel->setHeaderData(0, Qt::Horizontal, "#");
tableModel->setHeaderData(1, Qt::Horizontal, "x");
tableModel->setHeaderData(2, Qt::Horizontal, "y");
tableModel->setHeaderData(3, Qt::Horizontal, "Intensity");
tableModel->setHeaderData(4, Qt::Horizontal, "Max value");
tableModel->setHeaderData(5, Qt::Horizontal, "d [Å]");
tableModel->setHeaderData(6, Qt::Horizontal, "Ice ring");
tableModel->setHeaderData(7, Qt::Horizontal, "Indexed");
tableModel->setHeaderData(8, Qt::Horizontal, "h");
tableModel->setHeaderData(9, Qt::Horizontal, "k");
tableModel->setHeaderData(10, Qt::Horizontal, "l");
tableModel->setHeaderData(11, Qt::Horizontal, "Dist. Ewald [Å^-1]");
}
void JFJochViewerSpotListWindow::addSpotRow(int index, const SpotToSave& s) {
QList<QStandardItem*> row;
auto mkNum = [](const QVariant& userValue, const QString& displayText = QString()) {
auto* it = new QStandardItem();
if (displayText.isEmpty()) {
it->setData(userValue, Qt::DisplayRole);
} else {
it->setData(displayText, Qt::DisplayRole);
}
it->setData(userValue, Qt::UserRole);
it->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
return it;
};
row.append(mkNum(index));
// x (two decimals, right-aligned, numeric sort on value)
row.append(mkNum(static_cast<double>(s.x), QString::number(s.x, 'f', 2)));
// y (two decimals, right-aligned, numeric sort on value)
row.append(mkNum(static_cast<double>(s.y), QString::number(s.y, 'f', 2)));
// Intensity (right-aligned)
row.append(mkNum(static_cast<double>(s.intensity)));
// Max value (right-aligned)
row.append(mkNum(static_cast<qlonglong>(s.maxc)));
// d_A (right-aligned)
row.append(mkNum(static_cast<double>(s.d_A)));
// Ice ring (text)
{
auto* it = new QStandardItem(s.ice_ring ? "Yes" : "No");
it->setData(s.ice_ring ? 1 : 0, Qt::UserRole); // add numeric sort key
row.append(it);
}
// Indexed (text)
{
auto* it = new QStandardItem(s.indexed ? "Yes" : "No");
it->setData(s.indexed ? 1 : 0, Qt::UserRole); // add numeric sort key
row.append(it);
}
// h (right-aligned)
row.append(mkNum(static_cast<qlonglong>(s.h)));
// k (right-aligned)
row.append(mkNum(static_cast<qlonglong>(s.k)));
// l (right-aligned)
row.append(mkNum(static_cast<qlonglong>(s.l)));
// dist_ewald_sphere (right-aligned)
row.append(mkNum(static_cast<double>(s.dist_ewald_sphere)));
tableModel->appendRow(row);
}
void JFJochViewerSpotListWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) {
image = {};
tableModel->removeRows(0, tableModel->rowCount());
}
void JFJochViewerSpotListWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage> in_image) {
tableModel->removeRows(0, tableModel->rowCount());
image = in_image;
if (image) {
for (int i = 0; i < image->ImageData().spots.size(); ++i)
addSpotRow(i, image->ImageData().spots[i]);
}
}
void JFJochViewerSpotListWindow::onTableRowDoubleClicked(const QModelIndex& index) {
if (!index.isValid())
return;
QModelIndex src = proxyModel->mapToSource(index);
int spotIndex = src.row();
if (!image)
return;
if (spotIndex >= 0 && spotIndex < image->ImageData().spots.size())
emit zoom(QPointF(image->ImageData().spots[spotIndex].x, image->ImageData().spots[spotIndex].y));
}