// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "JFJochViewerToolbarDisplay.h" #include #include "../common/ColorScale.h" JFJochViewerToolbarDisplay::JFJochViewerToolbarDisplay(QWidget *parent) : QToolBar(parent) { addWidget(new QLabel("Foreground   ")); foreground_slider = new SliderPlusBox(1, 65000, 1.0, 1, this, SliderPlusBox::ScaleType::Logarithmic); foreground_slider->setValue(10); addWidget(foreground_slider); auto_foreground_button = new QPushButton("Auto"); auto_foreground_button->setCheckable(true); auto_foreground_button->setChecked(auto_foreground); addWidget(auto_foreground_button); addWidget(new QLabel("  Color map  ")); // Initialize QComboBox with the options color_map_select = new QComboBox(this); color_map_select->addItem("Viridis", static_cast(ColorScaleEnum::Viridis)); color_map_select->addItem("Heat", static_cast(ColorScaleEnum::Heat)); color_map_select->addItem("Indigo", static_cast(ColorScaleEnum::Indigo)); color_map_select->addItem("B/W", static_cast(ColorScaleEnum::BW)); color_map_select->setCurrentIndex(static_cast(ColorScaleEnum::Indigo)); addWidget(color_map_select); addWidget(new QLabel("  Background   ")); background_slider = new SliderPlusBox(-30000, 30000, 1.0, 1, this, SliderPlusBox::ScaleType::Linear); background_slider->setValue(0); addWidget(background_slider); auto *stretch = new QWidget(this); stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); addWidget(stretch); connect(foreground_slider, &SliderPlusBox::valueChanged, this, &JFJochViewerToolbarDisplay::foregroundSet); connect(background_slider, &SliderPlusBox::valueChanged, this, &JFJochViewerToolbarDisplay::backgroundSet); connect(color_map_select, QOverload::of(&QComboBox::currentIndexChanged), this, &JFJochViewerToolbarDisplay::colorComboBoxSet); connect(auto_foreground_button, &QPushButton::clicked, this, &JFJochViewerToolbarDisplay::autoForegroundButtonPressed); } void JFJochViewerToolbarDisplay::foregroundSet(double val) { if (auto_foreground) { auto_foreground = false; auto_foreground_button->setChecked(false); emit setAutoForeground(false); } emit setForeground(static_cast(val)); } void JFJochViewerToolbarDisplay::backgroundSet(double val) { emit setBackground(static_cast(val)); } void JFJochViewerToolbarDisplay::updateForeground(float val) { QSignalBlocker blocker(foreground_slider); foreground_slider->setValue(val); } void JFJochViewerToolbarDisplay::colorComboBoxSet(int val) { emit colorMapChanged(val); } void JFJochViewerToolbarDisplay::autoForegroundButtonPressed() { auto_foreground = !auto_foreground; auto_foreground_button->setChecked(auto_foreground); emit setAutoForeground(auto_foreground); }