// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "JFJochViewerProcessingWidget.h" #include #include #include #include JFJochViewerProcessingWidget::JFJochViewerProcessingWidget(QWidget *parent) : QWidget(parent) { m_settings.enable = false; auto centralWidget = new QWidget(this); auto mainLayout = new QVBoxLayout(centralWidget); auto generalGroup = new QGroupBox("Spot finding", this); auto generalLayout = new QFormLayout(generalGroup); m_enableCheckBox = new QCheckBox("Enable", this); generalLayout->addRow("", m_enableCheckBox); connect(m_enableCheckBox, &QCheckBox::toggled, [this](bool checked) { m_settings.enable = checked; emit settingsChanged(m_settings); }); m_signalToNoise = new SliderPlusBox(1.0, 10.0, 0.1, 1, this); generalLayout->addRow("Signal to Noise threshold:", m_signalToNoise); connect(m_signalToNoise, &SliderPlusBox::valueChanged, [this] (double val) { m_settings.signal_to_noise_threshold = val; emit settingsChanged(m_settings); }); m_photonCount = new SliderPlusBox(0.0, 100.0, 1.0, 0, this); generalLayout->addRow("Photon count threshold:", m_photonCount); connect(m_photonCount, &SliderPlusBox::valueChanged, [this] (double val) { m_settings.photon_count_threshold = val; emit settingsChanged(m_settings); }); m_minPixPerSpot = new SliderPlusBox(1.0, 20.0, 1.0, 0, this); generalLayout->addRow("Minimum pixels per spot:", m_minPixPerSpot); connect(m_minPixPerSpot, &SliderPlusBox::valueChanged, [this] (double val) { m_settings.min_pix_per_spot = std::lround(val); emit settingsChanged(m_settings); }); m_maxPixPerSpot = new SliderPlusBox(10.0, 200.0, 1.0, 0, this); generalLayout->addRow("Maximum pixels per spot:", m_maxPixPerSpot); connect(m_maxPixPerSpot, &SliderPlusBox::valueChanged, [this] (double val) { m_settings.max_pix_per_spot = std::lround(val); emit settingsChanged(m_settings); }); m_highResolution = new SliderPlusBox(0.8, 10.0, 0.1, 1, this); generalLayout->addRow("High resolution", m_highResolution); connect(m_highResolution, &SliderPlusBox::valueChanged, [this] (double val) { m_settings.high_resolution_limit = val; emit settingsChanged(m_settings); }); m_lowResolution = new SliderPlusBox(10.0, 100.0, 0.1, 1, this); generalLayout->addRow("Low resolution", m_lowResolution); connect(m_lowResolution, &SliderPlusBox::valueChanged, [this] (double val) { m_settings.low_resolution_limit = val; emit settingsChanged(m_settings); }); auto processingGroup = new QGroupBox("Other steps", this); auto processingLayout = new QFormLayout(processingGroup); m_indexingCheckBox = new QCheckBox("Enable Indexing", this); processingLayout->addRow("", m_indexingCheckBox); connect(m_indexingCheckBox, &QCheckBox::toggled, [this](bool checked) { m_settings.indexing = checked; emit settingsChanged(m_settings); }); m_quickIntegrationCheckBox = new QCheckBox("Enable Quick Integration", this); processingLayout->addRow("", m_quickIntegrationCheckBox); connect(m_quickIntegrationCheckBox, &QCheckBox::toggled, [this](bool checked) { m_settings.quick_integration = checked; emit settingsChanged(m_settings); }); auto buttonsLayout = new QHBoxLayout(); m_resetButton = new QPushButton("Reset to Defaults", this); buttonsLayout->addWidget(m_resetButton); buttonsLayout->addStretch(); connect(m_resetButton, &QPushButton::clicked, this, &JFJochViewerProcessingWidget::resetToDefaults); mainLayout->addWidget(generalGroup); mainLayout->addWidget(processingGroup); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); updateUiFromSettings(); } void JFJochViewerProcessingWidget::updateUiFromSettings() { m_enableCheckBox->setChecked(m_settings.enable); m_signalToNoise->setValue(m_settings.signal_to_noise_threshold); m_photonCount->setValue(std::lround(m_settings.photon_count_threshold)); m_minPixPerSpot->setValue(std::lround(m_settings.min_pix_per_spot)); m_maxPixPerSpot->setValue(std::lround(m_settings.max_pix_per_spot)); m_highResolution->setValue(m_settings.high_resolution_limit); m_lowResolution->setValue(m_settings.low_resolution_limit); m_indexingCheckBox->setChecked(m_settings.indexing); m_quickIntegrationCheckBox->setChecked(m_settings.quick_integration); } void JFJochViewerProcessingWidget::resetToDefaults() { // Reset to default values m_settings = SpotFindingSettings(); m_settings.enable = false; updateUiFromSettings(); emit settingsChanged(m_settings); }