Files
Jungfraujoch/viewer/windows/JFJochViewerImageListWindow.h
leonarski_fandClaude Opus 5 4ea5e6d01b viewer: stop rebuilding closed windows on every dataset tick
The queue-level fix for the live-follow OOM bounded how many datasets are
in flight, but not what each tick costs. Three handlers did full-dataset or
full-detector work per tick regardless of whether their window was open:

- the calibration window copied the whole pixel mask (GetMask returns a
  reference; it was taken by value), memcpy'd it and ran a full-resolution
  recolour on the GUI thread;
- the image-list window rebuilt one row of eight QStandardItems per image,
  and then repainted every cell of the model on every frame to move a
  one-row highlight;
- the dataset-info plot was rebuilt twice per tick, because setCurrentIndex
  fires currentIndexChanged -> comboBoxSelected -> UpdatePlot and the
  caller then called UpdatePlot again.

The first two now defer to showEvent while hidden, following the pattern
JFJochViewerReciprocalSpaceWindow::rebuildGL already uses; the highlight
repaints only the two rows that change; and the combo is blocked around
setCurrentIndex so the plot is built once.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 14:58:35 +02:00

59 lines
1.8 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <QMainWindow>
#include <QTableView>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include "JFJochHelperWindow.h"
#include "../../reader/JFJochReader.h"
class JFJochViewerImageListWindow : public JFJochHelperWindow {
Q_OBJECT
QTableView *tableView;
QStandardItemModel *tableModel;
QSortFilterProxyModel *proxyModel;
void setupTableModel();
void 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);
void clearAllData();
void fillTable();
void setRowBackground(int row, const QBrush &brush);
// Filling the table is one row per image, so it is skipped while the window is closed: the
// dataset is kept here and showEvent() fills it. highlighted_row is the row currently marked
// as the loaded image, so only it and its successor need repainting per frame.
std::shared_ptr<const JFJochReaderDataset> dataset;
bool pending_fill = false;
int highlighted_row = -1;
public:
explicit JFJochViewerImageListWindow(QWidget *parent = nullptr);
protected:
void showEvent(QShowEvent *event) override;
signals:
void imageSelected(int64_t image_number, int64_t summation);
public slots:
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset) override;
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image) override;
private slots:
void onTableRowDoubleClicked(const QModelIndex &index);
};