Files
Jungfraujoch/viewer/JFJochViewerImage.h
2025-09-24 22:52:31 +02:00

103 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 JFJOCHVIEWERIMAGE_H
#define JFJOCHVIEWERIMAGE_H
#include <QGraphicsView>
#include <QVector>
#include "../reader/JFJochHDF5Reader.h"
#include "../common/ColorScale.h"
class JFJochViewerImage : public QGraphicsView {
Q_OBJECT
QColor feature_color = Qt::magenta;
QColor spot_color = Qt::green;
QColor prediction_color = Qt::darkRed;
QColor ice_ring_color = Qt::cyan;
QPixmap pixmap;
QRectF roi_box;
public:
JFJochViewerImage(QWidget *parent = nullptr);
signals:
void foregroundChanged(float val);
void roiBoxUpdated(QRect box);
void roiCircleUpdated(double x, double y, double radius);
void writeStatusBar(QString string);
private:
void wheelEvent(QWheelEvent *event) override; // Zooming
void mousePressEvent(QMouseEvent *event) override; // Panning start
void mouseMoveEvent(QMouseEvent *event) override; // Panning interaction
void mouseReleaseEvent(QMouseEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void updateOverlay();
void updateROI();
void LoadImageInternal();
void Redraw();
void DrawResolutionRings();
void DrawSpots();
void DrawPredictions();
void DrawBeamCenter();
void DrawTopPixels();
void DrawSaturation();
void DrawCross(float x, float y, float size, float width, float z = 1);
double scale_factor = 1.0;
ColorScale color_scale;
std::shared_ptr<const JFJochReaderImage> image;
std::vector<rgb> image_rgb;
float foreground = 10;
float background = 0;
int32_t show_highest_pixels = 0;
QVector<float> res_ring = {};
bool res_ring_auto = false;
bool show_spots = true;
bool show_predictions = false;
bool show_saturation = false;
bool highlight_ice_rings = true;
float ice_ring_width_Q_recipA = 0.01;
QPoint lastMousePos; // To track panning movement
QPointF roiStartPos;
QPointF roiEndPos;
enum class RoiType {RoiBox, RoiCircle};
enum class MouseEventType {None, Panning, DrawingROI, MovingROI};
MouseEventType mouse_event_type = MouseEventType::None;
RoiType roi_type = RoiType::RoiBox;
protected slots:
void onScroll(int value);
public slots:
void loadImage(std::shared_ptr<const JFJochReaderImage> image);
void changeForeground(float val);
void changeBackground(float val);
void setResolutionRing(QVector<float> v);
void setResolutionRingAuto();
void showSpots(bool input);
void showPredictions(bool input);
void setColorMap(int color_map);
void setFeatureColor(QColor input);
void setSpotColor(QColor input);
void setPredictionColor(QColor input);
void showHighestPixels(int32_t v);
void showSaturation(bool input);
void highlightIceRings(bool input);
void centerOnSpot(double x, double y);
};
#endif //JFJOCHVIEWERIMAGE_H