Files
Jungfraujoch/viewer/widgets/ResolutionRingWidget.cpp
Filip Leonarski 224cc8b89c
All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 7m46s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m45s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 6m56s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 5m58s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 6m59s
Build Packages / build:rpm (rocky8) (push) Successful in 7m33s
Build Packages / Generate python client (push) Successful in 19s
Build Packages / Build documentation (push) Successful in 41s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky9) (push) Successful in 8m45s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m51s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m12s
Build Packages / Unit tests (push) Successful in 1h8m51s
v1.0.0-rc.110 (#16)
This is an UNSTABLE release.

* jfjoch_broker: Add auto-contrast option for preview images
* Frontend: Add logo image
* jfjoch_viewer: Add logo image
* jfjoch_viewer: For image chart allow to set min value to zero
* jfjoch_viewer: For resolution estimation plots, visualization uses 1/d^2 as measure
* jfjoch_viewer: Add 3D unit cell visualization (experimental/WIP/not really there)
* Documentation: Add logo image

Reviewed-on: #16
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
2025-11-28 12:47:35 +01:00

115 lines
3.9 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);
ice_rings_button = new QRadioButton("Ice rings (d > 1.5 Å)", 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);
button_group->addButton(ice_rings_button, 4);
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);
layout->addWidget(ice_rings_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);
connect(ice_rings_button, &QRadioButton::clicked, this, &ResolutionRingWidget::iceRingsButtonClicked);
}
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::iceRingsButtonClicked() {
res_rings_edit->setEnabled(false);
emit ringModeSet(JFJochDiffractionImage::RingMode::IceRings);
}
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) {
/* */
}