Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 7m45s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 7m3s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 8m0s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m48s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 7m41s
Build Packages / build:rpm (rocky8) (push) Successful in 7m20s
Build Packages / Generate python client (push) Successful in 20s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m25s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 32s
Build Packages / build:rpm (rocky9) (push) Successful in 8m15s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m6s
Build Packages / Unit tests (push) Successful in 1h12m12s
This is an UNSTABLE release and not recommended for production use (please use rc.111 instead). * jfjoch_viewer: Add binning options in the context menu Reviewed-on: #23 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
113 lines
2.9 KiB
C++
113 lines
2.9 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#ifndef JFJOCH_JFJOCHCHARTVIEW_H
|
|
#define JFJOCH_JFJOCHCHARTVIEW_H
|
|
|
|
#include <QtCharts/QChartView>
|
|
#include <QtCharts/QValueAxis>
|
|
#include <QtCharts/QLineSeries>
|
|
#include <QtCharts/QScatterSeries>
|
|
#include <QMouseEvent>
|
|
#include <QGraphicsLineItem>
|
|
#include <QTimer>
|
|
|
|
#ifdef JFJOCH_USE_FFTW
|
|
#include <fftw3.h>
|
|
#endif
|
|
|
|
#include "../../common/GoniometerAxis.h"
|
|
#include "../../reader/JFJochReaderDataset.h"
|
|
|
|
class JFJochDatasetInfoChartView : public QChartView {
|
|
Q_OBJECT
|
|
|
|
QLineSeries *series = nullptr;
|
|
QScatterSeries *currentSeries = nullptr;
|
|
QGraphicsLineItem *m_hoverLine = nullptr;
|
|
QTimer *m_hoverLoadTimer = nullptr;
|
|
int64_t m_hoverPendingIdx = -1;
|
|
|
|
std::vector<float> values;
|
|
int64_t binning = 1;
|
|
int64_t curr_image = 0;
|
|
|
|
bool m_minYZeroEnabled = true;
|
|
bool m_yOneOverD = false;
|
|
bool m_xUseGoniometerAxis = true;
|
|
|
|
std::optional<GoniometerAxis> goniometer_axis;
|
|
std::optional<float> image_time_us;
|
|
|
|
void updateChart();
|
|
|
|
// Build regular (index or goniometer) chart
|
|
void buildTimeDomainChart();
|
|
|
|
// FFT view toggle
|
|
bool m_showFFT = false;
|
|
|
|
#ifdef JFJOCH_USE_FFTW
|
|
// Cached FFT data for hover/status bar etc.
|
|
void buildFFTChart();
|
|
std::vector<double> m_fftMagnitudes;
|
|
std::vector<double> m_fftFrequenciesHz;
|
|
#endif
|
|
|
|
signals:
|
|
void imageSelected(int64_t number);
|
|
void writeStatusBar(QString string, int timeout_ms = 0);
|
|
|
|
private slots:
|
|
void onHoverLoadTimeout();
|
|
void setBinning(int64_t val);
|
|
|
|
private:
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void leaveEvent(QEvent *event) override;
|
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
|
|
|
public:
|
|
explicit JFJochDatasetInfoChartView(QWidget *parent = nullptr);
|
|
void setImage(int64_t val);
|
|
|
|
public slots:
|
|
void resetZoom();
|
|
|
|
public:
|
|
template<class T>
|
|
void loadValues(const std::vector<T> &input,
|
|
int64_t image,
|
|
bool one_over_d2,
|
|
const JFJochReaderDataset *dataset = nullptr) {
|
|
m_yOneOverD = one_over_d2;
|
|
|
|
values.resize(input.size());
|
|
|
|
if (dataset != nullptr) {
|
|
goniometer_axis = dataset->experiment.GetGoniometer();
|
|
image_time_us = dataset->experiment.GetImageTime().count();
|
|
} else {
|
|
goniometer_axis = {};
|
|
image_time_us = {};
|
|
}
|
|
|
|
for (int i = 0; i < input.size(); i++) {
|
|
if (one_over_d2) {
|
|
float d = static_cast<float>(input[i]);
|
|
if (!std::isfinite(d))
|
|
values[i] = 0.0f;
|
|
else
|
|
values[i] = 1.0f / (d * d);
|
|
} else
|
|
values[i] = static_cast<float>(input[i]);
|
|
}
|
|
curr_image = image;
|
|
updateChart();
|
|
}
|
|
};
|
|
|
|
|
|
#endif //JFJOCH_JFJOCHCHARTVIEW_H
|