Some checks failed
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m11s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 9m9s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 9m18s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m14s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 10m3s
Build Packages / Generate python client (push) Successful in 15s
Build Packages / Build documentation (push) Successful in 50s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8) (push) Successful in 8m31s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m21s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m42s
Build Packages / build:rpm (rocky9) (push) Successful in 9m11s
Build Packages / Unit tests (push) Failing after 1h13m19s
This is an UNSTABLE release and not recommended for production use (please use rc.96 instead). * jfjoch_broker: For DECTRIS detectors add dark data collection during initialization for bad pixel mask * jfjoch_broker: Refactor of calibration logic for more clear code (likely to introduce problems) * jfjoch_viewer: Add option to handle user pixel mask (experimental) * jfjoch_viewer: More options for ROI * jfjoch_viewer: Add window to display calibration Reviewed-on: #2 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
143 lines
5.2 KiB
C++
143 lines
5.2 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->setStyleSheet("background-color: white;");
|
|
|
|
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));
|
|
}
|
|
|