Files
Jungfraujoch/viewer/JFJochViewerDatasetInfo.h
T
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

67 lines
2.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 <QComboBox>
#include <QStackedWidget>
#include <QPushButton>
#include "charts/JFJochDatasetInfoChartView.h"
#include "../reader/JFJochReader.h"
#include "image_viewer/JFJochGridScanImage.h"
#include "widgets/JFJochViewerSidePanelChart.h"
#include "RunData.h"
class JFJochViewerDatasetInfo : public QWidget {
Q_OBJECT
QComboBox *combo_box;
JFJochDatasetInfoChartView *chart_view;
const std::vector<float> *GetDataset();
std::shared_ptr<const JFJochReaderDataset> dataset; // the active (primary) run
std::shared_ptr<const JFJochReaderImage> image;
JFJochGridScanImage *grid_scan_image = nullptr;
JFJochViewerSidePanelChart *image_chart = nullptr; // per-image profiles (azimuthal, Wilson, ...)
QVector<RunData> runs_; // all runs, for overlay lines
QString active_id_; // which run is primary
std::shared_ptr<const JFJochReaderDataset> live_run_; // in-progress reprocessing, if any
QStackedWidget *stack = nullptr;
QPushButton *grid_button = nullptr;
QPushButton *image_button = nullptr; // toggle: show per-image profiles instead of the metric
int last_selection;
void UpdatePlot();
void UpdateView(); // pick the stack page from the grid / per-image toggles
// Pull the metric selected by combo value `val` out of one run's dataset.
std::vector<float> ExtractMetric(const JFJochReaderDataset &ds, int val, bool &one_over_d2) const;
void UpdateLabels();
// Restores the combo selection after UpdateLabels() repopulated it, without firing
// currentIndexChanged: the callers run UpdatePlot() themselves straight afterwards.
void RestoreSelection();
signals:
void imageSelected(int64_t number, int64_t summation);
void writeStatusBar(QString string, int timeout_ms = 0);
void addPlot(); // request another dataset-info plot dock
public:
explicit JFJochViewerDatasetInfo(QWidget *parent = nullptr);
private slots:
void imageSelectedInChart(int64_t number);
void comboBoxSelected(int val);
void resetZoomButtonPressed();
public slots:
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> dataset);
void imageLoaded(std::shared_ptr<const JFJochReaderImage> image);
void setColorMap(int color_map);
// All runs (original + reprocessing snapshots) and which one is active/primary.
void runsChanged(QVector<RunData> runs, QString active_id);
// Live results of the in-progress reprocessing run (updated as it goes), or nullptr to clear.
void liveRunUpdated(std::shared_ptr<const JFJochReaderDataset> dataset);
};