Some checks failed
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 8m11s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 7m28s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m46s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 7m48s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m0s
Build Packages / build:rpm (rocky8) (push) Successful in 8m21s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m20s
Build Packages / Generate python client (push) Successful in 18s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 36s
Build Packages / build:rpm (rocky9) (push) Successful in 9m19s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m43s
Build Packages / Unit tests (push) Failing after 1h25m28s
This is an UNSTABLE release. * jfjoch_viewer: Fix bug when resolution estimation/B-Factor/Profile radius were not set (NaN) * jfjoch_viewer: Show spots is off by default, resolution ring mode is enabled by default * jfjoch_viewer: Fit to window of image is now default when size of the grid changes Reviewed-on: #13 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
106 lines
3.5 KiB
C++
106 lines
3.5 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QLabel>
|
|
|
|
#include "ResolutionRingWidget.h"
|
|
|
|
ResolutionRingWidget::ResolutionRingWidget(QWidget *parent)
|
|
: QWidget(parent) {
|
|
|
|
res_rings_edit = new QLineEdit(this);
|
|
res_rings_edit->setPlaceholderText("Ring positions, e.g., 1.0,2.5,3.7");
|
|
res_rings_edit->setEnabled(false); // Initially disabled as "Auto Res Rings" is checked by default
|
|
|
|
none_button = new QRadioButton("None", this);
|
|
auto_button = new QRadioButton("Auto", this);
|
|
manual_button = new QRadioButton("Manual", this);
|
|
est_button = new QRadioButton("Resolution estimation from processing", this);
|
|
|
|
est_button->setChecked(true);
|
|
|
|
button_group = new QButtonGroup(this);
|
|
button_group->addButton(none_button, 0);
|
|
button_group->addButton(auto_button, 1);
|
|
button_group->addButton(manual_button, 2);
|
|
button_group->addButton(est_button, 3);
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
layout->addWidget(none_button);
|
|
layout->addWidget(auto_button);
|
|
|
|
QHBoxLayout *manual_layout = new QHBoxLayout();
|
|
manual_layout->addWidget(manual_button);
|
|
manual_layout->addWidget(res_rings_edit);
|
|
layout->addLayout(manual_layout);
|
|
layout->addWidget(est_button);
|
|
|
|
connect(res_rings_edit, &QLineEdit::editingFinished, this, &ResolutionRingWidget::editingFinished);
|
|
connect(auto_button, &QRadioButton::clicked, this, &ResolutionRingWidget::autoButtonClicked);
|
|
connect(manual_button, &QRadioButton::clicked, this, &ResolutionRingWidget::manualButtonClicked);
|
|
connect(est_button, &QRadioButton::clicked, this, &ResolutionRingWidget::estButtonClicked);
|
|
connect(none_button, &QRadioButton::clicked, this, &ResolutionRingWidget::noneButtonClicked);
|
|
}
|
|
|
|
void ResolutionRingWidget::setRings(const QVector<float> &v) {
|
|
QString txt;
|
|
for (float i : v) {
|
|
txt += QString::number(i, 'f', 4) + ",";
|
|
}
|
|
res_rings_edit->setText(txt);
|
|
res_rings_edit->setEnabled(true);
|
|
manual_button->setChecked(true);
|
|
editingFinished();
|
|
}
|
|
|
|
void ResolutionRingWidget::autoButtonClicked() {
|
|
res_rings_edit->setEnabled(false);
|
|
emit ringModeSet(JFJochDiffractionImage::RingMode::Auto);
|
|
}
|
|
|
|
void ResolutionRingWidget::estButtonClicked() {
|
|
res_rings_edit->setEnabled(false);
|
|
emit ringModeSet(JFJochDiffractionImage::RingMode::Estimation);
|
|
}
|
|
|
|
void ResolutionRingWidget::noneButtonClicked() {
|
|
res_rings_edit->setEnabled(false);
|
|
emit ringModeSet(JFJochDiffractionImage::RingMode::None);
|
|
}
|
|
|
|
void ResolutionRingWidget::manualButtonClicked() {
|
|
res_rings_edit->setEnabled(true);
|
|
editingFinished();
|
|
}
|
|
|
|
void ResolutionRingWidget::editingFinished() {
|
|
QString text = res_rings_edit->text();
|
|
QStringList stringList = text.split(',', Qt::SkipEmptyParts);
|
|
QVector<float> manualResRings;
|
|
|
|
bool validInput = true;
|
|
for (const QString &str: stringList) {
|
|
bool ok;
|
|
float value = str.toFloat(&ok);
|
|
if (ok && value >= 0) {
|
|
manualResRings.append(value);
|
|
} else {
|
|
validInput = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!validInput) {
|
|
res_rings_edit->setStyleSheet("border: 1px solid red;"); // Highlight error
|
|
} else {
|
|
res_rings_edit->setStyleSheet(""); // Reset to default style
|
|
emit resRingsSet(manualResRings); // Update resolution ring vector
|
|
}
|
|
}
|
|
|
|
void ResolutionRingWidget::setRingMode(JFJochDiffractionImage::RingMode mode) {
|
|
/* */
|
|
}
|