// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include "charts/JFJochDatasetInfoChartView.h" #include "../reader/JFJochReader.h" #include "image_viewer/JFJochGridScanImage.h" #include "widgets/JFJochViewerSidePanelChart.h" #include "RunData.h" #include "widgets/LiveComboBox.h" class JFJochViewerDatasetInfo : public QWidget { Q_OBJECT LiveComboBox *combo_box; JFJochDatasetInfoChartView *chart_view; // Second half-height plot under the first, shown only for "Spots + background": the spot // count and the background each get their own compact plot instead of sharing twin axes. JFJochDatasetInfoChartView *chart_view2; QWidget *charts_holder; // the two stacked chart views, as one stack page const std::vector *GetDataset(); std::shared_ptr dataset; // the active (primary) run std::shared_ptr image; JFJochGridScanImage *grid_scan_image = nullptr; JFJochViewerSidePanelChart *image_chart = nullptr; // per-image profiles (azimuthal, Wilson, ...) QVector runs_; // all runs, for overlay lines QString active_id_; // which run is primary std::shared_ptr live_run_; // in-progress reprocessing, if any bool http_connected_ = false; // live source: default the plot to spots + background bool user_picked_ = false; // ... unless the user has picked a metric themselves QStackedWidget *stack = nullptr; QPushButton *reset_button = nullptr; QPushButton *grid_button = nullptr; QPushButton *image_button = nullptr; // toggle: show per-image profiles instead of the metric QPushButton *add_plot_button = nullptr; // The button row is sized in character widths, so it follows the font zoom. void UpdateButtonWidths(); int last_selection = 0; // last per-dataset metric, by combo data code int last_image_selection = 0; // last per-image plot type, by combo data code bool combo_is_image_mode_ = false; // which of the two the combo currently lists // Dataset kind (grid scan or not) whose saved favourite is applied; grid scans and standard // scans each remember their own plot choice and toggle states across viewer restarts. std::optional favourite_kind_; void SaveFavourite(); // persist the current choice for the loaded dataset's kind void ApplyFavourite(bool grid_scan); // apply the saved choice for that kind and re-plot void UpdatePlot(); // Rebuild the combo for whichever mode the toggles now select and re-plot. Every mode switch // must go through this. void ModeChanged(); 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 ExtractMetric(const JFJochReaderDataset &ds, int val, bool &one_over_d2) const; void changeEvent(QEvent *event) override; 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 dataset); void imageLoaded(std::shared_ptr image); void setColorMap(int color_map); // All runs (original + reprocessing snapshots) and which one is active/primary. void runsChanged(QVector 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 dataset); // Connected to / disconnected from a live (HTTP) source. void setHttpConnection(bool connected, QString addr = QString()); // "Reset all settings to defaults": back to the state a first load of this dataset would show. void resetPlotDefaults(); };