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>
161 lines
5.4 KiB
C++
161 lines
5.4 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>
|
|
|
|
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);
|
|
|
|
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(6);
|
|
tableModel->setHeaderData(0, Qt::Horizontal, "#");
|
|
tableModel->setHeaderData(1, Qt::Horizontal, "Background");
|
|
tableModel->setHeaderData(2, Qt::Horizontal, "Indexing");
|
|
tableModel->setHeaderData(3, Qt::Horizontal, "Spots");
|
|
tableModel->setHeaderData(4, Qt::Horizontal, "Res. estimate");
|
|
tableModel->setHeaderData(5, Qt::Horizontal, "Max");
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::addDataRow(int imageNumber, double backgroundEstimate,
|
|
const QString& indexingResult,
|
|
int spotCount,
|
|
double resolutionEstimate,
|
|
int64_t max_value) {
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
QStandardItem *imageItem = new QStandardItem();
|
|
imageItem->setData(imageNumber, Qt::DisplayRole);
|
|
rowItems.append(imageItem);
|
|
|
|
QStandardItem *bgItem = new QStandardItem();
|
|
bgItem->setData(backgroundEstimate, Qt::DisplayRole);
|
|
rowItems.append(bgItem);
|
|
|
|
QStandardItem *indexingItem = new QStandardItem(indexingResult);
|
|
rowItems.append(indexingItem);
|
|
|
|
QStandardItem *spotItem = new QStandardItem();
|
|
spotItem->setData(spotCount, Qt::DisplayRole);
|
|
rowItems.append(spotItem);
|
|
|
|
QStandardItem *resolutionItem = new QStandardItem();
|
|
resolutionItem->setData(resolutionEstimate, Qt::DisplayRole);
|
|
rowItems.append(resolutionItem);
|
|
|
|
|
|
QStandardItem *maxValueItem = new QStandardItem();
|
|
maxValueItem->setData(static_cast<int32_t>(max_value), Qt::DisplayRole);
|
|
rowItems.append(maxValueItem);
|
|
|
|
tableModel->appendRow(rowItems);
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::clearAllData() {
|
|
tableModel->removeRows(0, tableModel->rowCount());
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) {
|
|
clearAllData();
|
|
|
|
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];
|
|
|
|
addDataRow(i,
|
|
bkg_estimate,
|
|
indexing_result,
|
|
spot_count,
|
|
res_estimation,
|
|
max_value);
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage> image) {
|
|
int curr_row = -1;
|
|
if (image)
|
|
curr_row = image->ImageData().number;
|
|
|
|
for (int row = 0; row < tableModel->rowCount(); row++) {
|
|
for (int col = 0; col < tableModel->columnCount(); ++col) {
|
|
QStandardItem *item = tableModel->item(row, col);
|
|
if (item) {
|
|
if (row == curr_row)
|
|
item->setBackground(Qt::blue);
|
|
else
|
|
item->setBackground(Qt::white);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|