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>
121 lines
4.6 KiB
C++
121 lines
4.6 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochViewerReflectionListWindow.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QHeaderView>
|
|
|
|
JFJochViewerReflectionListWindow::JFJochViewerReflectionListWindow(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 on underlying values
|
|
|
|
tableView->setModel(proxyModel);
|
|
tableView->sortByColumn(7, Qt::DescendingOrder); // default: I (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("Reflections");
|
|
resize(900, 600);
|
|
|
|
connect(tableView, &QTableView::doubleClicked,
|
|
this, &JFJochViewerReflectionListWindow::onTableRowDoubleClicked);
|
|
}
|
|
|
|
void JFJochViewerReflectionListWindow::setupTableModel() {
|
|
tableModel->setColumnCount(9);
|
|
tableModel->setHeaderData(0, Qt::Horizontal, "h");
|
|
tableModel->setHeaderData(1, Qt::Horizontal, "k");
|
|
tableModel->setHeaderData(2, Qt::Horizontal, "l");
|
|
tableModel->setHeaderData(3, Qt::Horizontal, "Pred. x");
|
|
tableModel->setHeaderData(4, Qt::Horizontal, "Pred. y");
|
|
tableModel->setHeaderData(5, Qt::Horizontal, "d [Å]");
|
|
tableModel->setHeaderData(6, Qt::Horizontal, "I");
|
|
tableModel->setHeaderData(7, Qt::Horizontal, "Sigma");
|
|
tableModel->setHeaderData(8, Qt::Horizontal, "Bkg");
|
|
}
|
|
|
|
static QStandardItem* mkNumItem(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;
|
|
}
|
|
|
|
void JFJochViewerReflectionListWindow::addReflectionRow(int index, const Reflection& r) {
|
|
QList<QStandardItem*> row;
|
|
|
|
row.append(mkNumItem(static_cast<qlonglong>(r.h)));
|
|
row.append(mkNumItem(static_cast<qlonglong>(r.k)));
|
|
row.append(mkNumItem(static_cast<qlonglong>(r.l)));
|
|
row.append(mkNumItem(static_cast<double>(r.predicted_x),
|
|
QString::number(r.predicted_x, 'f', 2)));
|
|
row.append(mkNumItem(static_cast<double>(r.predicted_y),
|
|
QString::number(r.predicted_y, 'f', 2)));
|
|
row.append(mkNumItem(static_cast<double>(r.d),
|
|
QString::number(r.d, 'f', 3)));
|
|
row.append(mkNumItem(static_cast<double>(r.I),
|
|
QString::number(r.I, 'f', 1)));
|
|
row.append(mkNumItem(static_cast<double>(r.sigma),
|
|
QString::number(r.sigma, 'f', 2)));
|
|
row.append(mkNumItem(static_cast<double>(r.bkg),
|
|
QString::number(r.bkg, 'f', 1)));
|
|
|
|
tableModel->appendRow(row);
|
|
}
|
|
|
|
void JFJochViewerReflectionListWindow::onTableRowDoubleClicked(const QModelIndex& index) {
|
|
if (!index.isValid())
|
|
return;
|
|
|
|
QModelIndex src = proxyModel->mapToSource(index);
|
|
int reflIndex = src.row();
|
|
|
|
if (!image)
|
|
return;
|
|
if (reflIndex >= 0 && reflIndex < image->ImageData().reflections.size())
|
|
emit zoom(QPointF(image->ImageData().reflections[reflIndex].predicted_x,
|
|
image->ImageData().reflections[reflIndex].predicted_y));
|
|
}
|
|
|
|
void JFJochViewerReflectionListWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) {
|
|
image = {};
|
|
tableModel->removeRows(0, tableModel->rowCount());
|
|
}
|
|
|
|
void JFJochViewerReflectionListWindow::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().reflections.size(); ++i)
|
|
addReflectionRow(i, image->ImageData().reflections[i]);
|
|
}
|
|
}
|