Files
Jungfraujoch/viewer/windows/JFJochCalibrationWindow.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

52 lines
1.4 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 <QComboBox>
#include <QString>
#include <QStatusBar>
#include "JFJochHelperWindow.h"
#include "../image_viewer/JFJochSimpleImage.h"
#include "../../reader/JFJochReaderDataset.h"
#include "../SimpleImage.h"
#include "../widgets/SliderPlusBox.h"
class JFJochCalibrationWindow : public JFJochHelperWindow {
Q_OBJECT
QComboBox *calibration_option;
QComboBox *color_map_select;
SliderPlusBox *foreground_slider;
SliderPlusBox *background_slider;
QStatusBar *statusBar;
std::shared_ptr<const JFJochReaderDataset> dataset;
JFJochSimpleImage *viewer = nullptr;
// LoadMask() is skipped while the window is closed - it only records that a reload is owed,
// and showEvent() pays it.
bool pending_mask_reload = false;
public:
JFJochCalibrationWindow(QWidget *parent = nullptr);
protected:
void showEvent(QShowEvent *event) override;
signals:
void loadCalibration(QString name);
private slots:
void LoadMask();
void CalibrationSelected(int val);
public slots:
void datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) override;
void calibrationLoaded(std::shared_ptr<const SimpleImage> image);
void setFeatureColor(QColor input);
};