Files
Jungfraujoch/viewer/toolbar/JFJochViewerToolbarDisplay.cpp
Filip Leonarski 9aaa70c5b6
All checks were successful
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 12m22s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 14m4s
Build Packages / Generate python client (push) Successful in 13s
Build Packages / build:rpm (rocky8) (push) Successful in 14m15s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 14m21s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (ubuntu2204) (push) Successful in 14m15s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 14m27s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 15m5s
Build Packages / Build documentation (push) Successful in 52s
Build Packages / build:rpm (rocky9) (push) Successful in 15m1s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 9m14s
Build Packages / build:rpm (ubuntu2204_nocuda) (pull_request) Successful in 13m5s
Build Packages / build:rpm (ubuntu2404_nocuda) (pull_request) Successful in 12m35s
Build Packages / build:rpm (rocky8_nocuda) (pull_request) Successful in 13m24s
Build Packages / Generate python client (pull_request) Successful in 11s
Build Packages / build:rpm (rocky8) (pull_request) Successful in 12m58s
Build Packages / build:rpm (rocky8_sls9) (pull_request) Successful in 13m8s
Build Packages / Create release (pull_request) Has been skipped
Build Packages / build:rpm (rocky9_nocuda) (pull_request) Successful in 14m12s
Build Packages / Build documentation (pull_request) Successful in 41s
Build Packages / build:rpm (rocky9) (pull_request) Successful in 10m40s
Build Packages / build:rpm (ubuntu2404) (pull_request) Successful in 7m23s
Build Packages / build:rpm (ubuntu2204) (pull_request) Successful in 8m0s
Build Packages / Unit tests (push) Successful in 1h0m8s
Build Packages / Unit tests (pull_request) Successful in 50m6s
jfjoch_viewer: Improve HDR mode
2026-01-31 23:35:40 +01:00

92 lines
3.7 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "JFJochViewerToolbarDisplay.h"
#include <QLabel>
#include "../../common/ColorScale.h"
constexpr double MAX_SLIDER_NO_IMAGE = 65000;
JFJochViewerToolbarDisplay::JFJochViewerToolbarDisplay(QWidget *parent)
: QToolBar(parent) {
addWidget(new QLabel("<b>Foreground </b>&nbsp;&nbsp;"));
foreground_slider = new SliderPlusBox(1, MAX_SLIDER_NO_IMAGE, 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(false);
addWidget(auto_foreground_button);
hdr_mode_button = new QPushButton("HDR");
hdr_mode_button->setCheckable(true);
hdr_mode_button->setChecked(false);
addWidget(hdr_mode_button);
addWidget(new QLabel("&nbsp;&nbsp;<b>Color map</b>&nbsp;&nbsp;"));
// Initialize QComboBox with the options
color_map_select = new QComboBox(this);
color_map_select->addItem("Indigo", static_cast<int>(ColorScaleEnum::Indigo));
color_map_select->addItem("Viridis", static_cast<int>(ColorScaleEnum::Viridis));
color_map_select->addItem("Magma", static_cast<int>(ColorScaleEnum::Magma));
color_map_select->addItem("Inferno", static_cast<int>(ColorScaleEnum::Inferno));
color_map_select->addItem("Heat", static_cast<int>(ColorScaleEnum::Heat));
color_map_select->addItem("Black on white", static_cast<int>(ColorScaleEnum::BW));
color_map_select->addItem("White on black", static_cast<int>(ColorScaleEnum::WB));
color_map_select->addItem("Green", static_cast<int>(ColorScaleEnum::Green));
color_map_select->setCurrentIndex(static_cast<int>(ColorScaleEnum::Indigo));
addWidget(color_map_select);
connect(foreground_slider, &SliderPlusBox::valueChanged, this, &JFJochViewerToolbarDisplay::foregroundSet);
connect(color_map_select, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &JFJochViewerToolbarDisplay::colorComboBoxSet);
connect(auto_foreground_button, &QPushButton::clicked, this, &JFJochViewerToolbarDisplay::autoForegroundButtonPressed);
connect(hdr_mode_button, &QPushButton::clicked, this, &JFJochViewerToolbarDisplay::HDRModeButtonPressed);
auto *stretch = new QWidget(this);
stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
addWidget(stretch);
}
void JFJochViewerToolbarDisplay::foregroundSet(double val) {
emit setForeground(static_cast<float>(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() {
emit setAutoForeground(auto_foreground_button->isChecked());
}
void JFJochViewerToolbarDisplay::updateAutoForeground(bool val) {
QSignalBlocker blocker(auto_foreground_button);
auto_foreground_button->setChecked(val);
}
void JFJochViewerToolbarDisplay::HDRModeButtonPressed() {
emit setHDRMode(hdr_mode_button->isChecked());
}
void JFJochViewerToolbarDisplay::imageLoaded(std::shared_ptr<const JFJochReaderImage> image) {
if (image) {
auto valid = image->ValidMinMax();
if (valid.has_value() && valid->second > 1)
foreground_slider->setMax(valid->second);
else
foreground_slider->setMax(MAX_SLIDER_NO_IMAGE);
} else {
foreground_slider->setMax(MAX_SLIDER_NO_IMAGE);
}
}