55 lines
2.2 KiB
C++
55 lines
2.2 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochViewerROIResult.h"
|
|
#include <QGridLayout>
|
|
|
|
JFJochViewerROIResult::JFJochViewerROIResult(QWidget *parent) : QWidget(parent) {
|
|
QGridLayout *layout = new QGridLayout;
|
|
|
|
roi_sum = new QLabel("", this);
|
|
roi_mean = new QLabel("", this);
|
|
roi_var = new QLabel("", this);
|
|
roi_max = new QLabel("", this);
|
|
roi_npixel = new QLabel("", this);
|
|
roi_masked = new QLabel("", this);
|
|
roi_x = new QLabel("", this);
|
|
roi_y = new QLabel("", this);
|
|
|
|
layout->addWidget(roi_mean, 0, 0);
|
|
layout->addWidget(roi_var, 0, 1);
|
|
layout->addWidget(roi_sum, 0, 2);
|
|
layout->addWidget(roi_max, 0, 3);
|
|
layout->addWidget(roi_npixel, 1, 0);
|
|
layout->addWidget(roi_masked, 1, 1);
|
|
layout->addWidget(roi_x, 1, 2);
|
|
layout->addWidget(roi_y, 1, 3);
|
|
setLayout(layout);
|
|
}
|
|
|
|
void JFJochViewerROIResult::SetROIResult(ROIMessage roi) {
|
|
if ( roi.pixels > 0) {
|
|
auto roi_npixel_val = static_cast<double>(roi.pixels);
|
|
double roi_mean_val = static_cast<double>(roi.sum) / roi_npixel_val;
|
|
double variance = static_cast<double>(roi.sum_square) / roi_npixel_val - roi_mean_val * roi_mean_val;
|
|
|
|
roi_sum->setText(QString("Sum <b>%1</b>").arg(roi.sum));
|
|
roi_mean->setText(QString("Mean <b>%1</b>").arg(QString::number(roi_mean_val, 'f', 3)));
|
|
roi_var->setText(QString("Var <b>%1</b>").arg(QString::number(variance, 'f', 3)));
|
|
roi_max->setText(QString("Max <b>%1</b>").arg(roi.max_count));
|
|
roi_npixel->setText(QString("Pixels <b>%1</b>").arg(roi.pixels));
|
|
roi_masked->setText(QString("Masked <b>%1</b>").arg(roi.pixels_masked));
|
|
roi_x->setText(QString("x: <b>%1</b>").arg(static_cast<float>(roi.x_weighted) / roi.sum));
|
|
roi_y->setText(QString("y: <b>%1</b>").arg(static_cast<float>(roi.y_weighted) / roi.sum));
|
|
} else {
|
|
roi_sum->setText("");
|
|
roi_mean->setText("");
|
|
roi_var->setText("");
|
|
roi_max->setText("");
|
|
roi_npixel->setText("");
|
|
roi_masked->setText("");
|
|
roi_x->setText("");
|
|
roi_y->setText("");
|
|
}
|
|
}
|