2511-viewer-enh (#5)
All checks were successful
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 11m52s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m47s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m58s
Build Packages / build:rpm (rocky8) (push) Successful in 12m13s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 12m34s
Build Packages / Unit tests (push) Has been skipped
Build Packages / Create release (push) Has been skipped
Build Packages / Generate python client (push) Successful in 23s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m33s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / build:rpm (rocky9) (push) Successful in 9m57s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m9s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m34s
All checks were successful
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 11m52s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m47s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m58s
Build Packages / build:rpm (rocky8) (push) Successful in 12m13s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 12m34s
Build Packages / Unit tests (push) Has been skipped
Build Packages / Create release (push) Has been skipped
Build Packages / Generate python client (push) Successful in 23s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m33s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / build:rpm (rocky9) (push) Successful in 9m57s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m9s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m34s
## 1.0.0-rc.100 This is an UNSTABLE release. * jfjoch_viewer: Fix dbus registration * jfjoch_viewer: Remove background slider for diffraction image * jfjoch_viewer: Adjustments for 2D azimuthal image viewer Reviewed-on: #5 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
This commit was merged in pull request #5.
This commit is contained in:
95
viewer/widgets/JFJochAzIntImage.cpp
Normal file
95
viewer/widgets/JFJochAzIntImage.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "JFJochAzIntImage.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../../common/JFJochException.h"
|
||||
|
||||
JFJochAzIntImage::JFJochAzIntImage(QWidget *parent)
|
||||
: JFJochImage(parent) {
|
||||
}
|
||||
|
||||
void JFJochAzIntImage::Clear() {
|
||||
W = 0;
|
||||
H = 0;
|
||||
image_fp.clear();
|
||||
if (scene())
|
||||
scene()->clear();
|
||||
}
|
||||
|
||||
// data: size = azimuthal_bins * q_bins
|
||||
// Layout: q varies fastest (i % q_bins == q index)
|
||||
void JFJochAzIntImage::SetData(const std::vector<float> &data,
|
||||
const std::vector<float> &in_phi,
|
||||
const std::vector<float> &in_q,
|
||||
int azimuthal_bins) {
|
||||
if (azimuthal_bins <= 0) {
|
||||
Clear();
|
||||
throw std::runtime_error("azimuthal_bins <= 0");
|
||||
}
|
||||
|
||||
int q_bins = data.size() / azimuthal_bins;
|
||||
|
||||
if (q_bins <= 0 || in_phi.size() != data.size() || in_q.size() != data.size()) {
|
||||
Clear();
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Mismatch in input size");
|
||||
}
|
||||
|
||||
float local_min = range_min, local_max = range_max;
|
||||
if (auto_range) {
|
||||
local_min = std::numeric_limits<float>::infinity();
|
||||
local_max = -std::numeric_limits<float>::infinity();
|
||||
for (float v : data) {
|
||||
if (std::isfinite(v)) {
|
||||
if (v < local_min) local_min = v;
|
||||
if (v > local_max) local_max = v;
|
||||
}
|
||||
}
|
||||
if (!std::isfinite(local_min) || !std::isfinite(local_max) || local_max <= local_min) {
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!(std::isfinite(local_min) && std::isfinite(local_max) && local_max > local_min)) {
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
phi = in_phi;
|
||||
q = in_q;
|
||||
|
||||
// Update base class members
|
||||
W = q_bins;
|
||||
H = azimuthal_bins;
|
||||
image_fp = data;
|
||||
|
||||
// Update foreground/background for color mapping
|
||||
background = local_min;
|
||||
foreground = local_max;
|
||||
|
||||
// Generate pixmap and redraw using base class functionality
|
||||
GeneratePixmap();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
void JFJochAzIntImage::mouseHover(QMouseEvent* event) {
|
||||
if (!scene() || W == 0 || H == 0) return;
|
||||
|
||||
QPointF scenePos = mapToScene(event->pos());
|
||||
int x = static_cast<int>(scenePos.x());
|
||||
int y = static_cast<int>(scenePos.y());
|
||||
|
||||
if (x >= 0 && x < static_cast<int>(W) && y >= 0 && y < static_cast<int>(H)) {
|
||||
size_t idx = y * W + x;
|
||||
|
||||
QString statusText = QString("Q: %1 Å^-1 phi: %2° value: %3")
|
||||
.arg(QString::number(q[idx], 'f', 3))
|
||||
.arg(QString::number(phi[idx], 'f', 3))
|
||||
.arg(QString::number(image_fp[idx], 'f', 3));
|
||||
|
||||
emit writeStatusBar(statusText, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user