mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-11-18 17:24:04 +01:00
SlsQtFastImage - Remove what the gui never used: the colour bar inside the view, the ROI editor, the extra ROI rectangles, pixel aspect and zero-white. - Report changes with signals instead of std::function callbacks. - Keep the image as double so that pixel values are shown exactly. - Draw interpolated images and contour lines itself, which removes the second colour mapped image and the paint hook from SlsQt2DPlot. - One Mapping struct for the image to widget transformation. SlsQtScalePanel - Connect to the signals of the view instead of chaining callbacks. - The histogram strip keeps its own copy of the 256 bins, so there is no pointer into the view to guard and no snapshot during a drag. - Remove the hooks that only the tests used. - Histogram bins now have the same width as the bars drawn for them. SlsQt2DPlot - Remove the pass-through methods the gui does not call and the duplicated state (log scale, palette, ROI rectangles). Tests and demo rewritten for the new interfaces. The demo now shows the 2D and the 1D plot of the gui with synthetic frames.
100 lines
2.7 KiB
C++
100 lines
2.7 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2026 Contributors to the SLS Detector Package
|
|
#pragma once
|
|
|
|
#include <QWidget>
|
|
|
|
#include <vector>
|
|
|
|
class QComboBox;
|
|
|
|
namespace sls {
|
|
|
|
class SlsQtFastImage;
|
|
|
|
/**
|
|
* Histogram of the image with the two ends of the colour range as markers.
|
|
*
|
|
* The markers stay at 1/4 and 3/4 of the width and the value axis rescales
|
|
* under them, so the strip shows the colour range plus half a range on either
|
|
* side. Dragging a marker moves that end of the range.
|
|
*
|
|
* Only a preview line follows the cursor during a drag and the new range is
|
|
* reported on release. Rescaling the axis under a dragged marker would make
|
|
* the marker run away from the cursor.
|
|
*/
|
|
class SlsQtScaleHisto : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SlsQtScaleHisto(QWidget *parent = nullptr);
|
|
|
|
/**
|
|
* Ignored while a marker is dragged.
|
|
* @param counts histogram of the image
|
|
* @param binLo lower edge of the first bin
|
|
* @param binHi upper edge of the last bin
|
|
* @param colorLo lower end of the colour range
|
|
* @param colorHi upper end of the colour range
|
|
* @param logX the colour scale is logarithmic, the bins are in log10
|
|
* @param logY draw log10(count + 1)
|
|
*/
|
|
void setData(const std::vector<int> &counts, double binLo, double binHi,
|
|
double colorLo, double colorHi, bool logX, bool logY);
|
|
bool isDragging() const;
|
|
|
|
signals:
|
|
/** A marker was dragged and released */
|
|
void rangeChanged(double lo, double hi);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
private:
|
|
enum class Marker { None, Lo, Hi };
|
|
|
|
void axisRange(double &lo, double &hi) const;
|
|
|
|
std::vector<int> m_counts;
|
|
double m_binLo = 0.0;
|
|
double m_binHi = 1.0;
|
|
double m_colorLo = 0.0;
|
|
double m_colorHi = 1.0;
|
|
bool m_logX = false;
|
|
bool m_logY = false;
|
|
|
|
Marker m_dragged = Marker::None;
|
|
double m_dragX = 0.0; // widget x of the cursor
|
|
};
|
|
|
|
/**
|
|
* Colour controls of an image view: the histogram strip, the palette and
|
|
* lin/log switches for the image and for the histogram.
|
|
*/
|
|
class SlsQtScalePanel : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SlsQtScalePanel(SlsQtFastImage *view, QWidget *parent = nullptr);
|
|
|
|
SlsQtScaleHisto *histogramWidget() const;
|
|
|
|
signals:
|
|
/** The user dragged a marker of the histogram strip */
|
|
void colorRangeEdited(double lo, double hi);
|
|
|
|
private:
|
|
void refresh();
|
|
|
|
SlsQtFastImage *m_view;
|
|
SlsQtScaleHisto *m_histo;
|
|
QComboBox *m_paletteCombo;
|
|
QComboBox *m_imageLogCombo;
|
|
QComboBox *m_histoLogCombo;
|
|
};
|
|
|
|
} // namespace sls
|