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
* 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>
243 lines
8.7 KiB
C++
243 lines
8.7 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochViewerImageListWindow.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QHeaderView>
|
|
#include <QCloseEvent>
|
|
|
|
namespace {
|
|
constexpr int ScaleSortRole = Qt::UserRole + 1;
|
|
constexpr double ScaleNotAvailableSortValue = -1.0e100;
|
|
}
|
|
|
|
JFJochViewerImageListWindow::JFJochViewerImageListWindow(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(ScaleSortRole);
|
|
|
|
tableView->setModel(proxyModel);
|
|
tableView->sortByColumn(0, Qt::AscendingOrder);
|
|
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("Image statistics");
|
|
resize(800, 600);
|
|
|
|
connect(tableView, &QTableView::doubleClicked, this, &JFJochViewerImageListWindow::onTableRowDoubleClicked);
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::setupTableModel()
|
|
{
|
|
tableModel->setColumnCount(8);
|
|
tableModel->setHeaderData(0, Qt::Horizontal, "#");
|
|
tableModel->setHeaderData(1, Qt::Horizontal, "Bkg");
|
|
tableModel->setHeaderData(2, Qt::Horizontal, "Index");
|
|
tableModel->setHeaderData(3, Qt::Horizontal, "Spots");
|
|
tableModel->setHeaderData(4, Qt::Horizontal, "Res. [A]");
|
|
tableModel->setHeaderData(5, Qt::Horizontal, "Max val");
|
|
tableModel->setHeaderData(6, Qt::Horizontal, "Scale factor");
|
|
tableModel->setHeaderData(7, Qt::Horizontal, "Scale CC");
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::addDataRow(int imageNumber, double backgroundEstimate,
|
|
const QString& indexingResult,
|
|
int spotCount,
|
|
double resolutionEstimate,
|
|
int64_t max_value,
|
|
double image_scale_factor,
|
|
double image_scale_cc_percent) {
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
QStandardItem *imageItem = new QStandardItem();
|
|
imageItem->setData(imageNumber, Qt::DisplayRole);
|
|
imageItem->setData(imageNumber, ScaleSortRole);
|
|
rowItems.append(imageItem);
|
|
|
|
QStandardItem *bgItem = new QStandardItem();
|
|
bgItem->setData(backgroundEstimate, Qt::DisplayRole);
|
|
bgItem->setData(backgroundEstimate, ScaleSortRole);
|
|
rowItems.append(bgItem);
|
|
|
|
QStandardItem *indexingItem = new QStandardItem(indexingResult);
|
|
if (indexingResult == "Yes")
|
|
indexingItem->setData(1, ScaleSortRole);
|
|
else if (indexingResult == "No")
|
|
indexingItem->setData(0, ScaleSortRole);
|
|
else
|
|
indexingItem->setData(-1, ScaleSortRole);
|
|
rowItems.append(indexingItem);
|
|
|
|
QStandardItem *spotItem = new QStandardItem();
|
|
spotItem->setData(spotCount, Qt::DisplayRole);
|
|
spotItem->setData(spotCount, ScaleSortRole);
|
|
rowItems.append(spotItem);
|
|
|
|
QStandardItem *resolutionItem = new QStandardItem();
|
|
resolutionItem->setData(QString::number(resolutionEstimate, 'f', 2), Qt::DisplayRole);
|
|
resolutionItem->setData(resolutionEstimate, ScaleSortRole);
|
|
rowItems.append(resolutionItem);
|
|
|
|
QStandardItem *maxValueItem = new QStandardItem();
|
|
maxValueItem->setData(static_cast<int32_t>(max_value), Qt::DisplayRole);
|
|
maxValueItem->setData(static_cast<int32_t>(max_value), ScaleSortRole);
|
|
rowItems.append(maxValueItem);
|
|
|
|
QStandardItem *scaleFactorItem = new QStandardItem();
|
|
if (std::isfinite(image_scale_factor)) {
|
|
scaleFactorItem->setData(image_scale_factor, Qt::DisplayRole);
|
|
scaleFactorItem->setData(image_scale_factor, ScaleSortRole);
|
|
} else {
|
|
scaleFactorItem->setData("N/A", Qt::DisplayRole);
|
|
scaleFactorItem->setData(ScaleNotAvailableSortValue, ScaleSortRole);
|
|
}
|
|
rowItems.append(scaleFactorItem);
|
|
|
|
QStandardItem *scaleCCItem = new QStandardItem();
|
|
if (std::isfinite(image_scale_cc_percent)) {
|
|
scaleCCItem->setData(QString::number(image_scale_cc_percent, 'f', 1) + "%", Qt::DisplayRole);
|
|
|
|
scaleCCItem->setData(image_scale_cc_percent, ScaleSortRole);
|
|
} else {
|
|
scaleCCItem->setData("N/A", Qt::DisplayRole);
|
|
scaleCCItem->setData(ScaleNotAvailableSortValue, ScaleSortRole);
|
|
}
|
|
rowItems.append(scaleCCItem);
|
|
|
|
tableModel->appendRow(rowItems);
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::clearAllData() {
|
|
tableModel->removeRows(0, tableModel->rowCount());
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) {
|
|
dataset = std::move(in_dataset);
|
|
|
|
// One row of eight QStandardItems per image, arriving on every dataset tick of a live
|
|
// acquisition. Not worth doing for a window nobody has open.
|
|
if (!isVisible()) {
|
|
pending_fill = true;
|
|
return;
|
|
}
|
|
fillTable();
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::showEvent(QShowEvent *event) {
|
|
JFJochHelperWindow::showEvent(event);
|
|
if (pending_fill) {
|
|
pending_fill = false;
|
|
fillTable();
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::fillTable() {
|
|
clearAllData();
|
|
highlighted_row = -1;
|
|
|
|
if (!dataset)
|
|
return;
|
|
|
|
for (int i = 0; i < dataset->experiment.GetImageNum(); i++) {
|
|
float bkg_estimate = 0;
|
|
if (dataset->bkg_estimate.size() > i)
|
|
bkg_estimate = dataset->bkg_estimate[i];
|
|
|
|
int32_t spot_count = 0;
|
|
if (dataset->spot_count.size() > i)
|
|
spot_count = dataset->spot_count[i];
|
|
|
|
float res_estimation = 0.0f;
|
|
if (dataset->resolution_estimate.size() > i)
|
|
res_estimation = dataset->resolution_estimate[i];
|
|
|
|
QString indexing_result = "N/A";
|
|
if (dataset->indexing_result.size() > i) {
|
|
if (dataset->indexing_result[i] == 0)
|
|
indexing_result = "No";
|
|
else
|
|
indexing_result = "Yes";
|
|
}
|
|
|
|
int64_t max_value = 0;
|
|
if (dataset->max_value.size() > i)
|
|
max_value = dataset->max_value[i];
|
|
|
|
double image_scale_factor = NAN;
|
|
if (dataset->image_scale_factor.size() > i)
|
|
image_scale_factor = dataset->image_scale_factor[i];
|
|
|
|
double image_scale_cc_percent = NAN;
|
|
if (dataset->image_scale_cc.size() > i)
|
|
image_scale_cc_percent = dataset->image_scale_cc[i] * 100.0;
|
|
|
|
addDataRow(i + 1,
|
|
bkg_estimate,
|
|
indexing_result,
|
|
spot_count,
|
|
res_estimation,
|
|
max_value,
|
|
image_scale_factor,
|
|
image_scale_cc_percent);
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::setRowBackground(int row, const QBrush &brush) {
|
|
if (row < 0 || row >= tableModel->rowCount())
|
|
return;
|
|
for (int col = 0; col < tableModel->columnCount(); ++col) {
|
|
if (QStandardItem *item = tableModel->item(row, col))
|
|
item->setBackground(brush);
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage> image) {
|
|
int curr_row = -1;
|
|
if (image)
|
|
curr_row = image->ImageData().number;
|
|
|
|
if (curr_row == highlighted_row)
|
|
return;
|
|
|
|
// Only the row losing the highlight and the row gaining it change. Repainting every cell
|
|
// emitted dataChanged for the whole model - and a proxy re-sort - on each frame.
|
|
setRowBackground(highlighted_row, QBrush()); // back to the palette's own
|
|
// A translucent wash of the palette's highlight, so the text keeps its own colour and stays
|
|
// readable on the light and the dark palette alike.
|
|
QColor wash = palette().color(QPalette::Highlight);
|
|
wash.setAlpha(90);
|
|
setRowBackground(curr_row, wash);
|
|
highlighted_row = curr_row;
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::onTableRowDoubleClicked(const QModelIndex &index) {
|
|
if (!index.isValid())
|
|
return;
|
|
|
|
QModelIndex sourceIndex = proxyModel->mapToSource(index);
|
|
int imageNumber = tableModel->item(sourceIndex.row(), 0)->data(Qt::DisplayRole).toInt();
|
|
emit imageSelected(imageNumber - 1, 1);
|
|
}
|