Add Qt5/Qt6 dual GUI build, detachable Plot settings and simplified scale panel

Build: SLS_GUI_QT_MAJOR=5|6 (default 6) selects Qt5/Qt6; cmk.sh -g is Qt5 and new -G is Qt6, both set SLS_USE_GUI=ON and the major version.  CPack GUI requirements follow the selected major; tests/demo/plotting library are Qt-major aware.  Qt5.9 compatibility shims cover QMouseEvent/QWheelEvent positions, QFontMetrics::horizontalAdvance, QButtonGroup::idClicked and the QWheelEvent constructor used by the tests.  cmk.sh now stops on configure/build errors, auto-detects cmake3/cmake and passes CONDA_PREFIX for conda Qt.

GUI: the Plot settings tab can be moved to a movable/floatable dock from View -> Detach Plot Settings so it stays usable while acquisition is started/stopped.  The 2D scale panel no longer shows min/max spin boxes; the colour range is edited in the Plot tab and the panel keeps synchronising its range with the image.

Verified: ./cmk.sh -cbgj8 (Qt5) and ./cmk.sh -cbGj16 (Qt6) both build; plotting_test 31/31 passes on both; slsDetectorGui -v starts headless with each Qt version.
This commit is contained in:
Qt6 Port committed 2026-11-12 15:25:45 +01:00
1 parent d680d2a496
commit c2b50d0a60
21 files changed
+366 -187

No files matched your search

+13 -3
View File
@@ -129,6 +129,10 @@ option(SLS_USE_DETECTOR "Detector libs" ON)
option(SLS_USE_RECEIVER "Receiver" ON)
option(SLS_USE_RECEIVER_BINARIES "Receiver binaries" ON)
option(SLS_USE_GUI "GUI" OFF)
# Qt major version used by slsDetectorGui when SLS_USE_GUI=ON. Qt 5 is kept
# for older distributions (e.g. RHEL 7); Qt 6 is the default.
set(SLS_GUI_QT_MAJOR "6" CACHE STRING "Qt major version for slsDetectorGui (5 or 6)")
set_property(CACHE SLS_GUI_QT_MAJOR PROPERTY STRINGS 5 6)
option(SLS_USE_SIMULATOR "Simulator" OFF)
option(SLS_USE_TESTS "TESTS" OFF)
option(SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF)
@@ -416,9 +420,15 @@ set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_GUI_PACKAGE_REQUIRES
"qt6-qtbase, qt6-qtbase-gui"
)
if(SLS_GUI_QT_MAJOR STREQUAL "5")
set(CPACK_RPM_GUI_PACKAGE_REQUIRES
"qt5-qtbase, qt5-qtbase-gui"
)
else()
set(CPACK_RPM_GUI_PACKAGE_REQUIRES
"qt6-qtbase, qt6-qtbase-gui"
)
endif()
#control which RPMs are generated
set(CPACK_COMPONENTS_ALL cli receiver zmq gui)
+36 -17
View File
@@ -99,13 +99,17 @@ To use the basic building blocks, meaning sls_detector_get/put and the shared li
#### GUI
* Qt 6 (>= 6.2, components Widgets, Gui, Core and Concurrent)
* Qt 5 (>= 5.9) **or** Qt 6 (>= 6.2), components Widgets, Gui, Core and
Concurrent. Qt 6 is the default; Qt 5 keeps older distributions such as
RHEL 7 buildable.
* libpng and zlib
The GUI plotting (1D/2D plots, colour maps, scale panel) is implemented with
plain Qt Widgets painting; Qwt, ROOT and OpenGL are no longer dependencies and
the bundled Qwt copy has been removed.
the bundled Qwt copy has been removed. The Plot settings tab can be detached
with **View -> Detach Plot Settings**, so the configuration stays reachable
while an acquisition is started/stopped.
#### Moench executables
@@ -188,7 +192,7 @@ ccmake ..
```
The binaries are generated in slsDetectorPackage/build/bin directory.
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-G] [-h] [-i]
[-j <Number of threads>] [-k <CMake command>] [-l <Install directory>]
[-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
-[no option]: only make
@@ -196,7 +200,8 @@ Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
-c: Clean
-d: HDF5 Custom Directory
-e: Debug mode
-g: Build/Rebuilds gui
-g: Build/Rebuilds gui with Qt5
-G: Build/Rebuilds gui with Qt6
-h: Builds/Rebuilds Cmake files with HDF5 package
-i: Builds tests
-j: Number of threads to compile through
@@ -221,11 +226,13 @@ Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
# new build, python and compile in parallel:
./cmk.sh -cbpj5
# new build including the Qt6 GUI (see 3.5 for the Qt6 packages)
./cmk.sh -cbgj9
# new build including the GUI (see 3.5 for the Qt packages)
./cmk.sh -cbgj9 # Qt 5 GUI (RHEL 7/older)
./cmk.sh -cbGj9 # Qt 6 GUI
#For rebuilding only certain sections
./cmk.sh -tg #only text client and gui
./cmk.sh -tg #text client and Qt5 gui
./cmk.sh -tG #text client and Qt6 gui
./cmk.sh -r #only receiver
```
@@ -251,11 +258,18 @@ make -j12
> **Note:** For v7.x.x of slsDetectorPackage and older, refer [zeromq notes for dependencies for conda](#4-pybind-and-zeromq).
### 3.5. Build slsDetectorGui (Qt6)
### 3.5. Build slsDetectorGui (Qt 5 or Qt 6)
The GUI needs Qt 6 (>= 6.2) with the Widgets, Gui, Core and Concurrent modules.
Qwt, Qt5, expat and Qt6Svg are no longer needed; the plotting is done with
plain Qt Widgets painting.
The GUI builds against Qt 5 (>= 5.9) or Qt 6 (>= 6.2), selected with
`-DSLS_GUI_QT_MAJOR=5|6` (default 6). Use Qt 5 on older distributions such as
RHEL 7; Qt 6 is the default elsewhere. Qwt, expat and Qt6Svg are no longer
needed; the plotting is done with plain Qt Widgets painting.
With cmk.sh, use `-g` for Qt 5 and `-G` for Qt 6:
```
./cmk.sh -cbgj9 # Qt 5 GUI
./cmk.sh -cbGj9 # Qt 6 GUI
```
1. Using pre-built binary on conda
```
@@ -263,14 +277,19 @@ conda create -n myenv slsdetgui=7.0.0
conda activate myenv
```
2. Using system installation on RHEL8/RHEL9/Fedora
2. Using system installation on RHEL 7 / RHEL 8 / RHEL 9 / Fedora
```
# Qt 6 (RHEL 8/9, Fedora)
dnf install qt6-qtbase-devel
# Qt 5 (RHEL 7 and older)
dnf install qt5-qtbase-devel
```
3. Using system installation on Debian/Ubuntu
```
apt install qt6-base-dev
apt install qt6-base-dev # Qt 6
apt install qtbase5-dev # Qt 5
```
4. Using conda
@@ -280,7 +299,7 @@ conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
# create environment to compile (qt6-main is the Qt6 base package on conda-forge)
# create environment to compile (qt6-main is the Qt 6 base package on conda-forge; use qt-main for Qt 5)
conda create -n slsgui zeromq gxx_linux-64 qt6-main
# activate environment
@@ -288,12 +307,12 @@ conda activate slsgui
# compile with cmake outside slsDetecorPackage folder
mkdir build && cd build
cmake ../slsDetectorPackage -DSLS_USE_GUI=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
cmake ../slsDetectorPackage -DSLS_USE_GUI=ON -DSLS_GUI_QT_MAJOR=6 -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make -j12
# or compile with cmk.sh
# or compile with cmk.sh (Qt 6; use -g instead of -G for Qt 5)
cd slsDetectorPackage
./cmk.sh -cbgj9
./cmk.sh -cbGj9
```
> **Note:** For v7.x.x of slsDetectorPackage and older, refer [zeromq notes for dependencies for conda](#4-pybind-and-zeromq).
+31 -7
View File
@@ -1,6 +1,9 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
# Stop at the first failing configure/build step so a failed GUI build is not
# reported as success by the final (possibly skipped) install step.
set -e
# Prefer cmake3 when the distribution provides it (RHEL/CentOS), otherwise
# use the default cmake. -k <cmd> still overrides this.
if command -v cmake3 >/dev/null 2>&1; then
@@ -16,6 +19,8 @@ COMPILERTHREADS=0
TEXTCLIENT=0
RECEIVER=0
GUI=0
QT5=0
QT6=0
DEBUG=0
PYTHON=0
TESTS=0
@@ -32,13 +37,14 @@ CMAKE_PRE=""
CMAKE_POST=""
usage() { echo -e "
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-G] [-h] [-i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
-[no option]: only make
-b: Builds/Rebuilds CMake files normal mode
-c: Clean
-d: HDF5 Custom Directory
-e: Debug mode
-g: Build/Rebuilds gui (requires Qt6)
-g: Build/Rebuilds gui with Qt5
-G: Build/Rebuilds gui with Qt6
-h: Builds/Rebuilds Cmake files with HDF5 package
-i: Builds tests
-j: Number of threads to compile through
@@ -82,12 +88,13 @@ For using multiple cores to compile faster:
./cmk.sh -j9 -h #with hdf
For rebuilding only certain sections
./cmk.sh -tg #only text client and gui
./cmk.sh -tg #text client and Qt5 gui
./cmk.sh -tG #text client and Qt6 gui
./cmk.sh -r #only receiver
" ; exit 1; }
while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
while getopts ":bcd:eghij:k:l:mnpGq:rstuz" opt ; do
case $opt in
b)
echo "Building of CMake files Required"
@@ -106,8 +113,15 @@ while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
DEBUG=1
;;
g)
echo "Compiling Options: GUI"
echo "Compiling Options: GUI (Qt5)"
GUI=1
QT5=1
REBUILD=1
;;
G)
echo "Compiling Options: GUI (Qt6)"
GUI=1
QT6=1
REBUILD=1
;;
h)
@@ -180,6 +194,11 @@ while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
done
if [ $QT5 -eq 1 ] && [ $QT6 -eq 1 ]; then
echo "Invalid options: -g (Qt5 GUI) and -G (Qt6 GUI) are mutually exclusive" >&2
exit 1
fi
#python
if [ $PYTHON -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_PYTHON=ON "
@@ -200,8 +219,13 @@ else
echo "Enabling Compile Option: Receiver"
fi
if [ $GUI -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_GUI=ON "
echo "Enabling Compile Option: GUI"
if [ $QT6 -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_GUI=ON -DSLS_GUI_QT_MAJOR=6 "
echo "Enabling Compile Option: GUI (Qt6)"
else
CMAKE_POST+=" -DSLS_USE_GUI=ON -DSLS_GUI_QT_MAJOR=5 "
echo "Enabling Compile Option: GUI (Qt5)"
fi
fi
fi
+3 -1
View File
@@ -46,7 +46,9 @@ ZeroMQ
GUI
-----------------------
* Qt 6 (>= 6.2, components Widgets, Gui, Core and Concurrent)
* Qt 5 (>= 5.9) **or** Qt 6 (>= 6.2), components Widgets, Gui, Core and
Concurrent. Qt 6 is the default; Qt 5 is kept for older distributions
such as RHEL 7.
* libpng and zlib
The GUI plotting (1D/2D plots, colour maps, scale panel) is implemented with
+15 -10
View File
@@ -1,12 +1,14 @@
Plotting in slsDetectorGui (Qt6)
================================
Plotting in slsDetectorGui (Qt 5 / Qt 6)
=======================================
The detector GUI used to draw every plot with the bundled **Qwt 6.1.5**
library. That dependency has been removed together with its build rules and
sources. All plots in `slsDetectorGui` are now painted by a small,
self-contained stack that only needs **Qt 6 Widgets / Gui / Core** (plus
`Qt6::Concurrent` for the acquisition thread). There is no ROOT, Qwt,
Qt Charts or OpenGL dependency and no Qt5 compatibility layer.
self-contained stack that needs only **Qt Widgets / Gui / Core** (plus the
Qt `Concurrent` module for the acquisition thread). It builds against **Qt 5
(>= 5.9) or Qt 6 (>= 6.2)**; Qt 6 is the default, while Qt 5 keeps older
distributions such as RHEL 7 usable. There is no ROOT, Qwt, Qt Charts or
OpenGL dependency.
The stack lives in `slsDetectorGui/slsDetectorPlotting` and is compiled once
into the static library `slsDetectorPlotting`, which is linked by the GUI
@@ -32,8 +34,9 @@ Components
* - `SlsQtScaleHisto`
- Thin 256-bin histogram strip with two draggable range markers.
* - `SlsQtScalePanel`
- The strip plus palette chooser, image/histogram lin-log switches and
min/max spin boxes, kept in sync with the image view in both directions.
- The strip plus palette chooser and image/histogram lin-log switches.
The colour min/max are edited in the Plot tab; the panel synchronises
its range with the image view in both directions.
* - `SlsQt2DPlot` / `SlsQt2DHist`
- The GUI 2D detector plot and its plain data container: z range, lin/log
z, bilinear interpolation, contour lines and ROI boxes. The z-axis
@@ -117,6 +120,8 @@ Removing Qwt
`libs/qwt` is gone from the source tree and the build; `slsDetectorGui` no
longer finds or links Qwt, and no source under `slsDetectorPlotting` includes
a `qwt_*` header. The package metadata and documentation refer to the Qt6
runtime packages instead (`qt6-qtbase` on RPM based systems, `qt6-base-dev`
on Debian/Ubuntu, `qt6-main` in conda).
a `qwt_*` header. The package metadata and documentation refer to the Qt
runtime packages instead (`qt6-qtbase`/`qt5-qtbase` on RPM based systems,
`qt6-base-dev`/`qtbase5-dev` on Debian/Ubuntu, `qt6-main`/`qt-main` in
conda), selected by `SLS_GUI_QT_MAJOR` (or `cmk.sh -G` for Qt 6 and `-g` for
Qt 5).
+32 -16
View File
@@ -198,7 +198,7 @@ Example cmake options Comment
The binaries are generated in slsDetectorPackage/build/bin directory.
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-G] [-h] [-i]
[-j <Number of threads>] [-k <CMake command>] [-l <Install directory>]
[-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
-[no option]: only make
@@ -206,7 +206,8 @@ Example cmake options Comment
-c: Clean
-d: HDF5 Custom Directory
-e: Debug mode
-g: Build/Rebuilds gui
-g: Build/Rebuilds gui with Qt5
-G: Build/Rebuilds gui with Qt6
-h: Builds/Rebuilds Cmake files with HDF5 package
-i: Builds tests
-j: Number of threads to compile through
@@ -231,11 +232,13 @@ Example cmake options Comment
# new build, python and compile in parallel:
./cmk.sh -cbpj5
# new build including the Qt6 GUI (see 3.5 for the Qt6 packages)
./cmk.sh -cbgj9
# new build including the GUI (see 3.5 for the Qt packages)
./cmk.sh -cbgj9 # Qt 5 GUI (RHEL 7/older)
./cmk.sh -cbGj9 # Qt 6 GUI
#For rebuilding only certain sections
./cmk.sh -tg #only text client and gui
./cmk.sh -tg #text client and Qt5 gui
./cmk.sh -tG #text client and Qt6 gui
./cmk.sh -r #only receiver
.. note ::
@@ -314,12 +317,20 @@ using this compiler
3.4. Build slsDetectorGui (Qt6)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3.4. Build slsDetectorGui (Qt 5 or Qt 6)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The GUI needs Qt 6 (>= 6.2) with the Widgets, Gui, Core and Concurrent modules.
Qwt, Qt5, expat and Qt6Svg are no longer needed; plotting is done with plain
Qt Widgets painting.
The GUI builds against Qt 5 (>= 5.9) or Qt 6 (>= 6.2), selected with
``-DSLS_GUI_QT_MAJOR=5|6`` (default 6). Qt 5 is the option for older
systems such as RHEL 7; Qt 6 is the default elsewhere. Qwt, expat and
Qt6Svg are no longer needed; plotting is done with plain Qt Widgets painting.
With cmk.sh, use ``-g`` for Qt 5 and ``-G`` for Qt 6:
.. code-block:: bash
./cmk.sh -cbgj9 # Qt 5 GUI
./cmk.sh -cbGj9 # Qt 6 GUI
1. Using pre-built binary on conda
@@ -329,17 +340,22 @@ Qt Widgets painting.
conda activate myenv
2. Using system installation on RHEL8/RHEL9/Fedora
2. Using system installation on RHEL 7 / RHEL 8 / RHEL 9 / Fedora
.. code-block:: bash
# Qt 6 (RHEL 8/9, Fedora)
dnf install qt6-qtbase-devel
# Qt 5 (RHEL 7 and older)
dnf install qt5-qtbase-devel
3. Using system installation on Debian/Ubuntu
.. code-block:: bash
apt install qt6-base-dev
apt install qt6-base-dev # Qt 6
apt install qtbase5-dev # Qt 5
4. Using conda
@@ -350,7 +366,7 @@ Qt Widgets painting.
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
# create environment to compile (qt6-main is the Qt6 base package on conda-forge)
# create environment to compile (qt6-main is the Qt 6 base package on conda-forge; use qt-main for Qt 5)
conda create -n slsgui zeromq gxx_linux-64 qt6-main
# activate environment
@@ -358,12 +374,12 @@ Qt Widgets painting.
# compile with cmake outside slsDetecorPackage folder
mkdir build && cd build
cmake ../slsDetectorPackage -DSLS_USE_GUI=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
cmake ../slsDetectorPackage -DSLS_USE_GUI=ON -DSLS_GUI_QT_MAJOR=6 -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make -j12
# or compile with cmk.sh
# or compile with cmk.sh (Qt 6; use -g instead of -G for Qt 5)
cd slsDetectorPackage
./cmk.sh -cbgj9
./cmk.sh -cbGj9
.. note ::
+27 -12
View File
@@ -5,9 +5,20 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# Qt6 only (Widgets/Gui/Core). Concurrent is needed for the acquisition
# thread in qDrawPlot.cpp. No Qwt, no Qt5 compatibility modules.
find_package(Qt6 6.2 REQUIRED COMPONENTS Widgets Gui Core Concurrent)
# Qt 5 or 6 (Widgets/Gui/Core). Concurrent is needed for the acquisition
# thread in qDrawPlot.cpp. No Qwt. SLS_GUI_QT_MAJOR selects the Qt major
# version; Qt 5 is needed on older distributions such as RHEL 7.
if(SLS_GUI_QT_MAJOR STREQUAL "6")
find_package(Qt6 6.2 REQUIRED COMPONENTS Widgets Gui Core Concurrent)
set(SLS_QT_LIBS Qt6::Widgets Qt6::Gui Qt6::Core)
set(SLS_QT_CONCURRENT Qt6::Concurrent)
elseif(SLS_GUI_QT_MAJOR STREQUAL "5")
find_package(Qt5 5.9 REQUIRED COMPONENTS Widgets Gui Core Concurrent)
set(SLS_QT_LIBS Qt5::Widgets Qt5::Gui Qt5::Core)
set(SLS_QT_CONCURRENT Qt5::Concurrent)
else()
message(FATAL_ERROR "SLS_GUI_QT_MAJOR must be 5 or 6 (got ${SLS_GUI_QT_MAJOR})")
endif()
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)
@@ -50,9 +61,7 @@ target_link_libraries(slsDetectorPlotting
slsProjectOptions
# sls/ansi.h, sls/sls_detector_defs.h and the logger symbols
slsSupportStatic
Qt6::Widgets
Qt6::Gui
Qt6::Core
${SLS_QT_LIBS}
PRIVATE
slsProjectWarnings
)
@@ -89,7 +98,11 @@ set(FORMS
forms/form_cloneplot.ui
)
qt6_wrap_ui(FORMS_H ${FORMS})
if(SLS_GUI_QT_MAJOR STREQUAL "6")
qt6_wrap_ui(FORMS_H ${FORMS})
else()
qt5_wrap_ui(FORMS_H ${FORMS})
endif()
set(HEADERS
include/qDefs.h
@@ -110,7 +123,11 @@ set(HEADERS
set(RESOURCES
include/icons.qrc
)
qt6_add_resources(RESOURCES_SRCS ${RESOURCES})
if(SLS_GUI_QT_MAJOR STREQUAL "6")
qt6_add_resources(RESOURCES_SRCS ${RESOURCES})
else()
qt5_add_resources(RESOURCES_SRCS ${RESOURCES})
endif()
add_executable(slsDetectorGui
@@ -134,10 +151,8 @@ target_link_libraries(slsDetectorGui PUBLIC
slsDetectorPlotting
PNG::PNG
ZLIB::ZLIB
Qt6::Widgets
Qt6::Gui
Qt6::Core
Qt6::Concurrent
${SLS_QT_LIBS}
${SLS_QT_CONCURRENT}
PRIVATE
slsProjectWarnings
+6 -2
View File
@@ -1,14 +1,18 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2026 Contributors to the SLS Detector Package
#
# Standalone Qt Widgets demo / benchmark for the Qt6-only plotting stack.
# Standalone Qt Widgets demo / benchmark for the Qt5/Qt6 plotting stack.
# Wired in from slsDetectorGui/CMakeLists.txt by an EXISTS guard; links the
# shared slsDetectorPlotting static library built by the GUI CMake file.
#
# Build: cmake --build <build> --target plot_demo
# Run: QT_QPA_PLATFORM=offscreen <build>/bin/plot_demo --frames 120
find_package(Qt6 6.2 REQUIRED COMPONENTS Widgets Gui Core)
if(SLS_GUI_QT_MAJOR STREQUAL "5")
find_package(Qt5 5.9 REQUIRED COMPONENTS Widgets Gui Core)
else()
find_package(Qt6 6.2 REQUIRED COMPONENTS Widgets Gui Core)
endif()
if(NOT TARGET slsDetectorPlotting)
message(FATAL_ERROR
+2 -2
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2026 Contributors to the SLS Detector Package
//
// Standalone offscreen demo / benchmark for the Qt6-only plotting stack.
// Standalone offscreen demo / benchmark for the Qt5/Qt6 plotting stack.
//
// It builds a synthetic 1024x512 float frame (sin(x/40)+cos(y/30) plus a moving
// hotspot) at ~20 Hz, feeds it to SlsQtFastImage, keeps SlsQtScalePanel in sync
@@ -438,7 +438,7 @@ int main(int argc, char **argv) {
QCommandLineParser parser;
parser.setApplicationDescription(
QStringLiteral("Qt6-only plotting stack demo / offline benchmark"));
QStringLiteral("Qt5/Qt6 plotting stack demo / offline benchmark"));
parser.addHelpOption();
parser.addVersionOption();
const QCommandLineOption framesOpt(
+5
View File
@@ -5,6 +5,8 @@
#include "sls/Detector.h"
#include "ui_form_detectormain.h"
class QResizeEvent;
class QAction;
class QDockWidget;
namespace sls {
@@ -38,6 +40,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
void ResizeMainWindow(bool b);
void EnableTabs(bool enable);
void SetZoomToolTip(bool disable);
void SetPlotSettingsDetached(bool detached);
protected:
void resizeEvent(QResizeEvent *event);
@@ -71,6 +74,8 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
qTabDebugging *tabDebugging;
qTabDeveloper *tabDeveloper;
qTabMessages *tabMessages;
QDockWidget *dockWidgetPlotSettings{nullptr};
QAction *actionDetachPlotSettings{nullptr};
int isDeveloper{false};
QString zoomToolTip;
QColor defaultTabColor;
@@ -3,7 +3,7 @@
#ifndef SLSQT1DPLOT_H
#define SLSQT1DPLOT_H
// Qt6-only replacement for the qwt based 1D plotting layer of slsDetectorGui.
// Qt5/Qt6 replacement for the qwt based 1D plotting layer of slsDetectorGui.
//
// SlsQt1DPlot is a plain QWidget that paints its own frame, ticks, grid,
// clipped curves, legend, ROI boxes and tracker and implements the zoom / pan
@@ -2,7 +2,7 @@
// Copyright (C) 2026 Contributors to the SLS Detector Package
#pragma once
// Shared plotting primitives for the Qt6-only plotting stack used by
// Shared plotting primitives for the Qt5/Qt6 plotting stack used by
// slsDetectorGui. Nothing here depends on qwt, ROOT or OpenGL.
//
// The palettes and the 1/2/5 tick rules are the ones the previous
@@ -12,10 +12,14 @@
#include <QColor>
#include <QFont>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QRect>
#include <QRgb>
#include <QSize>
#include <QString>
#include <QWheelEvent>
#include <QtGlobal>
#include <cmath>
#include <vector>
@@ -23,6 +27,39 @@
namespace sls {
namespace plot {
// Qt5/Qt6 compatibility helpers. The GUI and the plotting stack are built
// against whichever Qt major version the distribution provides (see the
// SLS_GUI_QT_MAJOR CMake option); keep the version-specific calls in one place.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
inline QPointF eventPosition(const QMouseEvent *event) {
return event->position();
}
inline QPointF eventPosition(const QWheelEvent *event) {
return event->position();
}
#else
inline QPointF eventPosition(const QMouseEvent *event) {
return event->localPos();
}
inline QPointF eventPosition(const QWheelEvent *event) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
return event->position();
#else
return event->posF();
#endif
}
#endif
// QFontMetrics::horizontalAdvance() arrived in Qt 5.11; Qt 5.9 (RHEL 7)
// still needs width().
inline int textWidth(const QFontMetrics &metrics, const QString &text) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
return metrics.horizontalAdvance(text);
#else
return metrics.width(text);
#endif
}
// Palettes offered by the image scale panel. Color / BW1 / BW2 are the
// original three and stay first (the b / B / c shortcuts use those indices).
// Gain4 is the fixed, muted palette for the 0..3 gain bits and is *not* in the
@@ -2,11 +2,12 @@
// Copyright (C) 2026 Contributors to the SLS Detector Package
#pragma once
// Thin histogram strip + scale panel of the Qt6 plotting stack: the strip
// shows the distribution of the last frame over the window the colour mapping
// currently shows and carries the two draggable range ends; the panel owns the
// palette chooser, the image/histogram lin-log switches and the min/max spin
// boxes. See AGENT_INSTRUCTIONS.md: "the three-way freeze rule".
// Thin histogram strip + scale panel of the Qt5/Qt6 plotting stack: the
// strip shows the distribution of the last frame over the window the colour
// mapping currently shows and carries the two draggable range ends; the panel
// owns the palette chooser and the image/histogram lin-log switches. The
// colour min/max live in the Plot tab, not here. See AGENT_INSTRUCTIONS.md:
// "the three-way freeze rule".
#include "SlsQtPlotCommon.h"
@@ -18,7 +19,6 @@
#include <vector>
class QComboBox;
class QDoubleSpinBox;
namespace sls {
@@ -91,10 +91,10 @@ class SlsQtScaleHisto : public QWidget {
int m_previewX = 0;
};
// Histogram strip + palette combo + image lin/log + histogram lin/log + min/max
// spin boxes. push() = controls -> view, refresh() = view -> controls, with a
// Histogram strip + palette combo + image lin/log + histogram lin/log.
// push() = controls -> view, refresh() = view -> controls, with a
// re-entrancy guard; refresh() is skipped while the strip is being dragged and
// the range is applied on release.
// the range is applied on release. The z min/max are edited in the Plot tab.
class SlsQtScalePanel : public QWidget {
Q_OBJECT
@@ -127,14 +127,14 @@ class SlsQtScalePanel : public QWidget {
bool isDragging() const; // strip drag in progress
// ---- test / programmatic hooks ---------------------------------------
// The values currently shown in the min/max spin boxes (1-decimal
// rounded). Stays frozen while the strip marker is dragged (R1).
// The colour range last read from / written to the view. Stays frozen
// while the strip marker is dragged (R1).
void controlRange(double &lo, double &hi) const;
// Sets both spin boxes as if the user had typed them: this is the only
// path that pushes the colour range from the controls, so a test can
// trigger a "user edit" without synthesising spin-box events.
// Applies a colour range as a user edit would: this is the only path that
// pushes the colour range from the panel controls, so a test can trigger
// one without synthesising events.
void setControlRange(double lo, double hi);
// Range last pushed to the view by a spin-box edit; false if no edit was
// Range last pushed to the view by a control edit; false if no edit was
// pushed yet. Palette/log changes never update this (R2).
bool lastPushedRange(double &lo, double &hi) const;
@@ -148,13 +148,14 @@ class SlsQtScalePanel : public QWidget {
QComboBox *m_paletteCombo = nullptr;
QComboBox *m_imageLogCombo = nullptr;
QComboBox *m_histoLogCombo = nullptr;
QDoubleSpinBox *m_loSpin = nullptr;
QDoubleSpinBox *m_hiSpin = nullptr;
// The colour range last read from the view (kept for the R1 freeze rule
// and for programmatic/test edits; there are no min/max spin boxes here).
double m_controlLo = 0.0;
double m_controlHi = 1.0;
int m_suppress = 0;
// R2: only a real edit of the min/max spin boxes may push the colour
// range. Refreshes (automatic z range) and palette/log changes only
// update the controls.
// R2: only an explicit control edit may push the colour range. Refreshes
// (automatic z range) and palette/log changes only update the controls.
bool m_rangeEdited = false;
bool m_lastPushedValid = false;
double m_lastPushedLo = 0.0;
@@ -989,7 +989,7 @@ SlsQt1DPlot::Geometry SlsQt1DPlot::computeGeometry() const {
const int w =
20 + (h->title().isEmpty()
? 0
: fmTick.horizontalAdvance(h->title()) + 4);
: sls::plot::textWidth(fmTick, h->title()) + 4);
if (used > 0 && used + w > avail) {
++rows;
used = 0;
@@ -1020,7 +1020,7 @@ SlsQt1DPlot::Geometry SlsQt1DPlot::computeGeometry() const {
}
int yLabelW = 0;
for (const QString &s : g.yLabels)
yLabelW = std::max(yLabelW, fmTick.horizontalAdvance(s));
yLabelW = std::max(yLabelW, sls::plot::textWidth(fmTick, s));
int left = 3 + yTitleW + yLabelW + kTickLen + 2;
const int right = 8;
@@ -1035,7 +1035,7 @@ SlsQt1DPlot::Geometry SlsQt1DPlot::computeGeometry() const {
std::vector<QString> xl = tickLabels(xt, m_xLo, m_xHi, m_logX);
int maxXLabelW = 12;
for (const QString &s : xl)
maxXLabelW = std::max(maxXLabelW, fmTick.horizontalAdvance(s));
maxXLabelW = std::max(maxXLabelW, sls::plot::textWidth(fmTick, s));
int maxXT = std::max(2, std::min(8, plotW / (maxXLabelW + 12)));
g.xTicks = tickValues(m_xLo, m_xHi, m_logX, maxXT);
g.xLabels = tickLabels(g.xTicks, m_xLo, m_xHi, m_logX);
@@ -1246,7 +1246,7 @@ void SlsQt1DPlot::paintFrame(QPainter &p, const Geometry &g) const {
if (i < static_cast<int>(g.xLabels.size())) {
const QString &lab = g.xLabels[static_cast<size_t>(i)];
p.setPen(m_theme.text);
int w = fmTick.horizontalAdvance(lab) + 8;
int w = sls::plot::textWidth(fmTick, lab) + 8;
int lx = x - w / 2;
if (lx < 0)
lx = 0;
@@ -1269,7 +1269,7 @@ void SlsQt1DPlot::paintFrame(QPainter &p, const Geometry &g) const {
if (i < static_cast<int>(g.yLabels.size())) {
const QString &lab = g.yLabels[static_cast<size_t>(i)];
p.setPen(m_theme.text);
const int w = fmTick.horizontalAdvance(lab) + 4;
const int w = sls::plot::textWidth(fmTick, lab) + 4;
int lx = r.left() - kTickLen - 2 - w;
if (lx < 0)
lx = 0;
@@ -1326,7 +1326,7 @@ void SlsQt1DPlot::paintLegend(QPainter &p, const Geometry &g) const {
const int w =
20 + (h->title().isEmpty()
? 0
: fm.horizontalAdvance(h->title()) + 4);
: sls::plot::textWidth(fm, h->title()) + 4);
if (!current.empty() && curW + w > avail) {
rows.push_back(current);
rowW.push_back(curW);
@@ -1362,7 +1362,7 @@ void SlsQt1DPlot::paintLegend(QPainter &p, const Geometry &g) const {
x += 20;
if (!h->title().isEmpty()) {
p.setPen(m_theme.text);
const int tw = fm.horizontalAdvance(h->title());
const int tw = sls::plot::textWidth(fm, h->title());
p.drawText(QRect(x, y, tw + 2, rowH),
Qt::AlignLeft | Qt::AlignVCenter, h->title());
x += tw + 4;
@@ -1461,7 +1461,7 @@ void SlsQt1DPlot::paintEvent(QPaintEvent *event) {
// ---------------------------------------------------------------------------
void SlsQt1DPlot::mousePressEvent(QMouseEvent *event) {
const QPointF pos = event->position();
const QPointF pos = sls::plot::eventPosition(event);
const Geometry g = computeGeometry();
if (zoomAllowed()) {
if (event->button() == Qt::LeftButton &&
@@ -1498,7 +1498,7 @@ void SlsQt1DPlot::mousePressEvent(QMouseEvent *event) {
}
void SlsQt1DPlot::mouseMoveEvent(QMouseEvent *event) {
const QPointF pos = event->position();
const QPointF pos = sls::plot::eventPosition(event);
const Geometry g = computeGeometry();
const bool inside = g.plot.contains(pos.toPoint());
if (inside != m_trackValid || pos != m_trackPos) {
@@ -1578,7 +1578,7 @@ void SlsQt1DPlot::wheelEvent(QWheelEvent *event) {
event->ignore();
return;
}
const QPointF pos = event->position();
const QPointF pos = sls::plot::eventPosition(event);
const Geometry g = computeGeometry();
if (!g.plot.contains(pos.toPoint())) {
event->ignore();
@@ -930,7 +930,7 @@ double SlsQtFastImage::valueAt(const QPoint &pos) const {
void SlsQtFastImage::mousePressEvent(QMouseEvent *e) {
if (e->button() != Qt::LeftButton)
return;
const QPoint ip = e->position().toPoint();
const QPoint ip = sls::plot::eventPosition(e).toPoint();
if (m_roiEdit && hasImage()) {
// which part of the yellow rectangle was grabbed?
const QPointF d = widgetToData(QPointF(ip));
@@ -996,7 +996,7 @@ void SlsQtFastImage::mousePressEvent(QMouseEvent *e) {
}
void SlsQtFastImage::mouseMoveEvent(QMouseEvent *e) {
const QPointF pos = e->position();
const QPointF pos = sls::plot::eventPosition(e);
if (m_roiEdit && hasImage()) {
const QPointF d = widgetToData(pos);
const double x = std::max(0.0, std::min(double(m_nx), d.x()));
@@ -1087,7 +1087,7 @@ void SlsQtFastImage::mouseMoveEvent(QMouseEvent *e) {
const QRect sr = scaleRect();
if (sr.height() <= 0)
return;
const double delta = double(e->position().toPoint().y() - m_dragScaleY) /
const double delta = double(sls::plot::eventPosition(e).toPoint().y() - m_dragScaleY) /
double(sr.height()) * (m_dragChi - m_dragClo);
if (m_dragMax) {
m_chi = m_dragChi - delta;
@@ -1165,7 +1165,7 @@ void SlsQtFastImage::mouseReleaseEvent(QMouseEvent *e) {
void SlsQtFastImage::wheelEvent(QWheelEvent *e) {
if (!hasImage() || !m_zoomEnabled)
return;
const QPointF imgPt = widgetToData(e->position());
const QPointF imgPt = widgetToData(sls::plot::eventPosition(e));
const double mx = imgPt.x(), my = imgPt.y();
const double factor = (e->angleDelta().y() > 0) ? 1.0 / 1.18 : 1.18;
@@ -1198,7 +1198,7 @@ void SlsQtFastImage::wheelEvent(QWheelEvent *e) {
void SlsQtFastImage::mouseDoubleClickEvent(QMouseEvent *e) {
const QRect sr = scaleRect();
if (sr.height() > 0 && sr.contains(e->position().toPoint())) {
if (sr.height() > 0 && sr.contains(sls::plot::eventPosition(e).toPoint())) {
m_clo = m_defClo;
m_chi = m_defChi;
m_histMs = 0;
@@ -5,7 +5,6 @@
#include "SlsQtFastImage.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QMouseEvent>
@@ -181,8 +180,8 @@ void SlsQtScaleHisto::paintEvent(QPaintEvent *) {
void SlsQtScaleHisto::mousePressEvent(QMouseEvent *e) {
const double xa = 0.25 * width(), xb = 0.75 * width();
const double d = std::abs(e->position().x() - xa);
const double d2 = std::abs(e->position().x() - xb);
const double d = std::abs(sls::plot::eventPosition(e).x() - xa);
const double d2 = std::abs(sls::plot::eventPosition(e).x() - xb);
if (std::min(d, d2) > 10) {
m_dragMin = -1; // too far from either marker: ignore
return;
@@ -197,7 +196,7 @@ void SlsQtScaleHisto::mousePressEvent(QMouseEvent *e) {
m_snap = *m_hist; // the bars: frozen as well (the image keeps updating)
m_preClo = m_clo; // the axis basis: frozen until the button is released
m_preChi = m_chi;
m_previewX = e->position().toPoint().x();
m_previewX = sls::plot::eventPosition(e).toPoint().x();
mouseMoveEvent(e);
}
@@ -213,14 +212,14 @@ void SlsQtScaleHisto::mouseMoveEvent(QMouseEvent *e) {
// mapped to a different value, so the marker chased itself.
double wlo = 0.0, whi = 1.0;
windowFor(m_preClo, m_preChi, wlo, whi);
const double t = std::max(0.0, std::min(1.0, double(e->position().x()) / W));
const double t = std::max(0.0, std::min(1.0, double(sls::plot::eventPosition(e).x()) / W));
const double vBin = wlo + t * (whi - wlo);
const double v = m_logX ? std::pow(10.0, vBin) : vBin;
if (m_dragMin == 1)
m_clo = std::min(v, m_chi - 1e-9);
else
m_chi = std::max(v, m_clo + 1e-9);
m_previewX = e->position().toPoint().x();
m_previewX = sls::plot::eventPosition(e).toPoint().x();
update(); // only the preview line moves; bars and axis stay frozen
}
@@ -266,15 +265,6 @@ SlsQtScalePanel::SlsQtScalePanel(SlsQtFastImage *view, QWidget *parent)
QStringLiteral("histogram bars: linear counts, or log10(count+1).\n"
"The histogram's value axis always follows the image\n"
"mapping above."));
m_loSpin = new QDoubleSpinBox(this);
m_hiSpin = new QDoubleSpinBox(this);
for (QDoubleSpinBox *b : {m_loSpin, m_hiSpin}) {
b->setRange(-1e9, 1e9);
b->setDecimals(1);
b->setSingleStep(1.0);
b->setKeyboardTracking(false);
b->setFixedWidth(84);
}
m_paletteCombo->setMinimumContentsLength(12);
row->addWidget(new QLabel(QStringLiteral("palette:"), this));
@@ -283,10 +273,6 @@ SlsQtScalePanel::SlsQtScalePanel(SlsQtFastImage *view, QWidget *parent)
row->addWidget(m_imageLogCombo);
row->addWidget(new QLabel(QStringLiteral("histo"), this));
row->addWidget(m_histoLogCombo);
row->addWidget(new QLabel(QStringLiteral("min"), this));
row->addWidget(m_loSpin);
row->addWidget(new QLabel(QStringLiteral("max"), this));
row->addWidget(m_hiSpin);
row->addStretch(1);
col->addLayout(row);
@@ -303,28 +289,12 @@ SlsQtScalePanel::SlsQtScalePanel(SlsQtFastImage *view, QWidget *parent)
connect(m_histoLogCombo,
QOverload<int>::of(&QComboBox::currentIndexChanged), this,
[this](int) { updateHisto(); });
// Only a real edit of the spin boxes may push the colour range; values set
// by refresh() happen under m_suppress and never mark an edit (R2).
connect(m_loSpin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
[this](double) {
if (!m_suppress)
m_rangeEdited = true;
push();
});
connect(m_hiSpin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
[this](double) {
if (!m_suppress)
m_rangeEdited = true;
push();
});
m_histo->onRangeChanged = [this](double a, double b) {
if (m_suppress || !m_view)
return;
m_view->setColorRange(a, b);
m_suppress++;
m_loSpin->setValue(a);
m_hiSpin->setValue(b);
m_suppress--;
m_controlLo = a;
m_controlHi = b;
refresh();
};
@@ -415,18 +385,16 @@ void SlsQtScalePanel::refresh() {
// range fed the drag back into the bars. Frozen until release, when
// onScaleReleased() calls this again.
// R1: the same holds while one of the strip's own markers is dragged -
// otherwise the incoming frames keep moving the min/max spin boxes (and
// the strip labels) under the frozen marker.
// otherwise the incoming frames keep moving the control range (and the
// strip labels) under the frozen marker.
if (m_view->isScaleDragging() ||
(m_histo && m_histo->isDragging()))
return;
m_suppress++;
double a = 0.0, b = 1.0;
m_view->colorRange(a, b);
if (m_loSpin)
m_loSpin->setValue(a);
if (m_hiSpin)
m_hiSpin->setValue(b);
m_controlLo = a;
m_controlHi = b;
if (m_imageLogCombo)
m_imageLogCombo->setCurrentIndex(m_view->logScale() ? 1 : 0);
const int pi = m_view->paletteIndex();
@@ -446,22 +414,17 @@ void SlsQtScalePanel::push() { // controls -> view
if (pi >= 0)
m_view->setPaletteLut(
sls::plot::paletteLut(static_cast<sls::plot::Palette>(pi)));
// R2: only push the colour range when the min/max spin boxes were really
// edited. The spins show 1-decimal values, while the automatic z range
// computed by SlsQt2DPlot is not rounded; pushing the spins on a palette or
// log change would perturb that range and (via onColorRangeChanged) pin
// the 2D panel override forever. A strip-marker drag applies its range
// directly in the onRangeChanged handler, not here.
// R2: only push the colour range on an explicit control edit (the Plot
// tab owns min/max; the panel only synchronises it). Palette/log changes
// must not perturb the automatic z range. A strip-marker drag applies its
// range directly in the onRangeChanged handler, not here.
if (m_rangeEdited) {
m_rangeEdited = false;
double a = m_loSpin ? m_loSpin->value() : 0.0;
double b = m_hiSpin ? m_hiSpin->value() : 1.0;
double a = m_controlLo;
double b = m_controlHi;
if (!(b > a)) {
b = a + 1.0;
m_suppress++;
if (m_hiSpin)
m_hiSpin->setValue(b);
m_suppress--;
m_controlHi = b;
}
m_lastPushedValid = true;
m_lastPushedLo = a;
@@ -472,19 +435,14 @@ void SlsQtScalePanel::push() { // controls -> view
}
void SlsQtScalePanel::controlRange(double &lo, double &hi) const {
lo = m_loSpin ? m_loSpin->value() : 0.0;
hi = m_hiSpin ? m_hiSpin->value() : 1.0;
lo = m_controlLo;
hi = m_controlHi;
}
void SlsQtScalePanel::setControlRange(double lo, double hi) {
// Mimic the operator typing both ends: programmatic setValue() calls are
// suppressed (so they do not push individually), then one edit is pushed.
m_suppress++;
if (m_loSpin)
m_loSpin->setValue(lo);
if (m_hiSpin)
m_hiSpin->setValue(hi);
m_suppress--;
// Mimic the operator applying both ends from the Plot tab.
m_controlLo = lo;
m_controlHi = hi;
m_rangeEdited = true;
push();
}
+58
View File
@@ -15,9 +15,14 @@
#include "sls/ToString.h"
#include "sls/versionAPI.h"
#include <QAction>
#include <QDockWidget>
#include <QFileDialog>
#include <QMenu>
#include <QLayout>
#include <QResizeEvent>
#include <QSizePolicy>
#include <QVBoxLayout>
#include "sls/Version.h"
#include <getopt.h>
@@ -148,6 +153,26 @@ void qDetectorMain::SetUpWidgetWindow() {
scrollMeasurement->setWidget(tabMeasurement);
scrollDataOutput->setWidget(tabDataOutput);
scrollPlot->setWidget(tabPlot);
// The Plot settings can be detached into a dock (or floated) so the
// operator can change them while an acquisition is being started/stopped
// without switching tabs in the main window.
dockWidgetPlotSettings = new QDockWidget(tr("Plot Settings"), this);
dockWidgetPlotSettings->setObjectName(
QStringLiteral("dockWidgetPlotSettings"));
dockWidgetPlotSettings->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea |
Qt::BottomDockWidgetArea);
dockWidgetPlotSettings->setFeatures(QDockWidget::DockWidgetMovable |
QDockWidget::DockWidgetFloatable);
auto *plotSettingsDockPage = new QWidget(dockWidgetPlotSettings);
auto *plotSettingsDockLayout = new QVBoxLayout(plotSettingsDockPage);
plotSettingsDockLayout->setContentsMargins(0, 0, 0, 0);
plotSettingsDockLayout->addStretch(1);
dockWidgetPlotSettings->setWidget(plotSettingsDockPage);
addDockWidget(Qt::RightDockWidgetArea, dockWidgetPlotSettings);
dockWidgetPlotSettings->hide();
scrollSettings->setWidget(tabSettings);
scrollAdvanced->setWidget(tabAdvanced);
scrollDebugging->setWidget(tabDebugging);
@@ -244,6 +269,15 @@ void qDetectorMain::Initialization() {
// Help Menu
connect(menuHelp, SIGNAL(triggered(QAction *)), this,
SLOT(ExecuteHelp(QAction *)));
// View Menu: detach the Plot settings so they stay usable while the
// acquisition is starting/stopping.
QMenu *menuView = menuBar()->addMenu(tr("&View"));
actionDetachPlotSettings = new QAction(tr("Detach Plot Settings"), this);
actionDetachPlotSettings->setCheckable(true);
menuView->addAction(actionDetachPlotSettings);
connect(actionDetachPlotSettings, &QAction::toggled, this,
&qDetectorMain::SetPlotSettingsDetached);
}
void qDetectorMain::LoadConfigFile(const std::string &config_file) {
@@ -549,6 +583,30 @@ void qDetectorMain::EnableTabs(bool enable) {
}
}
void qDetectorMain::SetPlotSettingsDetached(bool detached) {
if (!dockWidgetPlotSettings || !scrollPlot || !tabPlot)
return;
auto *dockPage = dockWidgetPlotSettings->widget();
auto *dockLayout =
dockPage ? qobject_cast<QVBoxLayout *>(dockPage->layout()) : nullptr;
if (!dockLayout)
return;
if (detached) {
QWidget *page = scrollPlot->takeWidget();
if (!page)
return;
dockLayout->insertWidget(0, page);
dockWidgetPlotSettings->show();
dockWidgetPlotSettings->raise();
tabs->setTabText(PLOT, tr("Plot (detached)"));
} else {
dockLayout->removeWidget(tabPlot);
scrollPlot->setWidget(tabPlot);
dockWidgetPlotSettings->hide();
tabs->setTabText(PLOT, tr("Plot"));
}
}
void qDetectorMain::SetZoomToolTip(bool disable) {
if (disable)
dockWidgetPlot->setToolTip(
+12 -3
View File
@@ -3,6 +3,15 @@
#include "qTabDataOutput.h"
#include "qDefs.h"
// QButtonGroup::idClicked arrived in Qt 5.15; older Qt5 releases (RHEL 7 has
// Qt 5.9) only provide the deprecated buttonClicked(int) overload, and Qt6
// removed that overload. Keep the three connect/disconnect sites in sync.
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#define SLS_RATE_GROUP_SIGNAL &QButtonGroup::idClicked
#else
#define SLS_RATE_GROUP_SIGNAL QOverload<int>::of(&QButtonGroup::buttonClicked)
#endif
#include <QButtonGroup>
#include <QFileDialog>
#include <QStandardItemModel>
@@ -79,7 +88,7 @@ void qTabDataOutput::Initialization() {
if (chkRate->isEnabled()) {
connect(chkRate, SIGNAL(toggled(bool)), this,
SLOT(EnableRateCorrection()));
connect(btnGroupRate, &QButtonGroup::idClicked, this,
connect(btnGroupRate, SLS_RATE_GROUP_SIGNAL, this,
&qTabDataOutput::SetRateCorrection);
connect(spinCustomDeadTime, SIGNAL(valueChanged(int)), this,
SLOT(SetRateCorrection()));
@@ -309,7 +318,7 @@ void qTabDataOutput::GetRateCorrection() {
LOG(logDEBUG) << "Getting Rate Correction";
disconnect(chkRate, SIGNAL(toggled(bool)), this,
SLOT(EnableRateCorrection()));
disconnect(btnGroupRate, &QButtonGroup::idClicked, this,
disconnect(btnGroupRate, SLS_RATE_GROUP_SIGNAL, this,
&qTabDataOutput::SetRateCorrection);
disconnect(spinCustomDeadTime, SIGNAL(valueChanged(int)), this,
SLOT(SetRateCorrection()));
@@ -326,7 +335,7 @@ void qTabDataOutput::GetRateCorrection() {
CATCH_DISPLAY("Could not get rate correction.",
"qTabDataOutput::GetRateCorrection")
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, &QButtonGroup::idClicked, this,
connect(btnGroupRate, SLS_RATE_GROUP_SIGNAL, this,
&qTabDataOutput::SetRateCorrection);
connect(spinCustomDeadTime, SIGNAL(valueChanged(int)), this,
SLOT(SetRateCorrection()));
+6
View File
@@ -6,7 +6,13 @@ namespace sls {
int qResolve_GetQFontWidth(const QFontMetrics fm, const QString &text,
int len) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
return fm.horizontalAdvance(text, len);
#else
// RHEL 7 still ships Qt 5.9, where QFontMetrics::width() is the only
// available overload for this.
return fm.width(text, len);
#endif
}
} // namespace sls
+9 -3
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2026 Contributors to the SLS Detector Package
#
# Qt6::Test suite for the Qt6-only plotting stack.
# QtTest suite for the Qt5/Qt6 plotting stack.
#
# Wired in from slsDetectorGui/CMakeLists.txt by an EXISTS guard; the plotting
# sources are compiled once into the slsDetectorPlotting static library there
@@ -12,7 +12,13 @@
# (or "ctest -R plotting" when the project is configured with
# -DSLS_USE_TESTS=ON)
find_package(Qt6 6.2 REQUIRED COMPONENTS Test)
if(SLS_GUI_QT_MAJOR STREQUAL "5")
find_package(Qt5 5.9 REQUIRED COMPONENTS Test)
set(SLS_QT_TEST Qt5::Test)
else()
find_package(Qt6 6.2 REQUIRED COMPONENTS Test)
set(SLS_QT_TEST Qt6::Test)
endif()
if(NOT TARGET slsDetectorPlotting)
message(FATAL_ERROR
@@ -25,7 +31,7 @@ add_executable(plotting_test
)
target_link_libraries(plotting_test PRIVATE
slsDetectorPlotting
Qt6::Test
${SLS_QT_TEST}
)
set_target_properties(plotting_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+13 -9
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2026 Contributors to the SLS Detector Package
//
// Qt6::Test suite for the Qt6-only plotting stack (verification task).
// QtTest suite for the Qt5/Qt6 plotting stack (verification task).
//
// Everything is checked through the public API or through rendered pixels; the
// widgets are shown on the offscreen QPA platform and rendered synchronously
@@ -92,9 +92,16 @@ void sendMouse(QWidget &w, QEvent::Type type, const QPointF &pos,
}
void sendWheel(QWidget &w, const QPointF &pos, int deltaY) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
QWheelEvent e(pos, QPointF(w.mapToGlobal(pos.toPoint())), QPoint(),
QPoint(0, deltaY), Qt::NoButton, Qt::NoModifier,
Qt::NoScrollPhase, false);
#else
// Qt 5.9 (RHEL 7): the scroll-phase constructor does not exist yet.
QWheelEvent e(pos, QPointF(w.mapToGlobal(pos.toPoint())), QPoint(),
QPoint(0, deltaY), 0, Qt::Vertical, Qt::NoButton,
Qt::NoModifier);
#endif
QCoreApplication::sendEvent(&w, &e);
}
@@ -908,7 +915,9 @@ void PlottingTest::scalePanelReentrancy() {
QVERIFY(!panel.isDragging());
// view -> controls -> view must not recurse (sympass guard): one change,
// one spin-box update, no push-back loop.
// one control update, no push-back loop. The min/max spin boxes were
// removed from the plot window; the range is owned by the Plot tab, so
// the panel only keeps the last range it read from/wrote to the view.
int rangeCalls = 0;
view.onColorRangeChanged = [&](double, double) { rangeCalls++; };
panel.setColorRange(1.0, 5.0);
@@ -916,13 +925,8 @@ void PlottingTest::scalePanelReentrancy() {
double a = 0.0, b = 0.0;
view.colorRange(a, b);
QVERIFY(near(a, 1.0) && near(b, 5.0));
const QList<QDoubleSpinBox *> spins = panel.findChildren<QDoubleSpinBox *>();
QCOMPARE(int(spins.size()), 2);
QStringList spinValues;
for (QDoubleSpinBox *s : spins)
spinValues << QString::number(s->value(), 'f', 1);
QVERIFY(spinValues.contains(QStringLiteral("1.0")));
QVERIFY(spinValues.contains(QStringLiteral("5.0")));
panel.controlRange(a, b);
QVERIFY(near(a, 1.0) && near(b, 5.0));
// refresh()/push() round trip is stable (idempotent, no re-entrancy).
panel.refresh();