// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include #include "JFJochViewerROIResult.h" #include "../../common/ROIDefinition.h" #include "../../reader/JFJochReaderImage.h" #include "LiveComboBox.h" // Manages the dataset's ROI list: select one, add (box/circle/azimuthal), rename or // delete, and show the selected ROI's statistics for the current image. Edits are // emitted as a complete ROIDefinition; the reading worker is the source of truth and // recomputes the per-image ROI results, which arrive back via loadImage(). class JFJochViewerROIList : public QWidget { Q_OBJECT LiveComboBox *combo_; QComboBox *type_combo_; QLabel *flabel_[4]; QLineEdit *fedit_[4]; JFJochViewerROIResult *result_; ROIDefinition rois_; std::shared_ptr image_; bool rebuilding_ = false; void RebuildCombo(const QString &keep_selected); void UpdateEditor(); // populate the numeric fields for the selected ROI void ApplyEditor(); // rebuild the selected ROI from the numeric fields void ShowSelectedResult(); [[nodiscard]] QString SelectedName() const; [[nodiscard]] std::string UniqueName() const; public: explicit JFJochViewerROIList(QWidget *parent = nullptr); public slots: void loadImage(std::shared_ptr image); void setSelected(QString name); // select an ROI by name (e.g. clicked on the canvas) private slots: void OnSelectionChanged(); void OnAdd(); void OnDelete(); void OnRename(); signals: void roisChanged(ROIDefinition rois); void selectedROIChanged(QString name); void downloadROIs(); // fetch ROIs from the connected broker void uploadROIs(); // push ROIs to the connected broker void maskFromROI(QString name, bool add); // add/subtract the selected ROI to/from the user mask };