// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "JFJochScalingPanel.h" #include #include #include #include #include JFJochScalingPanel::JFJochScalingPanel(const ScalingSettings &settings, QWidget *parent) : QWidget(parent) { auto *layout = new QVBoxLayout(this); auto *group = new QGroupBox("Scaling && merging", this); auto *form = new QFormLayout(group); m_partiality = new QComboBox(this); m_partiality->addItem("Fixed", static_cast(PartialityModel::Fixed)); m_partiality->addItem("Rotation", static_cast(PartialityModel::Rotation)); m_partiality->addItem("Unity", static_cast(PartialityModel::Unity)); const auto pm = settings.GetPartialityModel().value_or(PartialityModel::Fixed); if (const int idx = m_partiality->findData(static_cast(pm)); idx >= 0) m_partiality->setCurrentIndex(idx); form->addRow("Partiality model", m_partiality); m_mergeFriedel = new QCheckBox("Merge Friedel pairs", this); m_mergeFriedel->setChecked(settings.GetMergeFriedel()); form->addRow("", m_mergeFriedel); m_refineB = new QCheckBox("Refine per-image B-factor", this); m_refineB->setChecked(settings.GetRefineB()); form->addRow("", m_refineB); m_minPartiality = new SliderPlusBox(0.0, 1.0, 0.01, 2, this); m_minPartiality->setValue(settings.GetMinPartiality()); form->addRow("Minimum partiality", m_minPartiality); m_outlierNsigma = new SliderPlusBox(0.0, 10.0, 0.5, 1, this); m_outlierNsigma->setValue(settings.GetOutlierRejectNsigma()); form->addRow("Outlier rejection [σ, 0 = off]", m_outlierNsigma); m_limitResolution = new QCheckBox("Limit resolution", this); m_limitResolution->setChecked(settings.GetHighResolutionLimit_A().has_value()); form->addRow("", m_limitResolution); m_highRes = new SliderPlusBox(0.5, 5.0, 0.1, 1, this); m_highRes->setValue(settings.GetHighResolutionLimit_A().value_or(2.0)); m_highRes->setEnabled(m_limitResolution->isChecked()); form->addRow("High-resolution limit [Å]", m_highRes); layout->addWidget(group); layout->addStretch(); connect(m_partiality, &QComboBox::currentIndexChanged, this, [this](int) { emitChanged(); }); connect(m_mergeFriedel, &QCheckBox::toggled, this, [this](bool) { emitChanged(); }); connect(m_refineB, &QCheckBox::toggled, this, [this](bool) { emitChanged(); }); connect(m_minPartiality, &SliderPlusBox::valueChanged, this, [this](double) { emitChanged(); }); connect(m_outlierNsigma, &SliderPlusBox::valueChanged, this, [this](double) { emitChanged(); }); connect(m_limitResolution, &QCheckBox::toggled, this, [this](bool checked) { m_highRes->setEnabled(checked); emitChanged(); }); connect(m_highRes, &SliderPlusBox::valueChanged, this, [this](double) { emitChanged(); }); } void JFJochScalingPanel::emitChanged() { ScalingSettings s; s.SetPartialityModel(static_cast(m_partiality->currentData().toInt())); s.MergeFriedel(m_mergeFriedel->isChecked()); s.RefineB(m_refineB->isChecked()); s.MinPartiality(m_minPartiality->value()); s.OutlierRejectNsigma(m_outlierNsigma->value()); if (m_limitResolution->isChecked()) s.HighResolutionLimit_A(m_highRes->value()); emit settingsChanged(s); }