2026-05-19 15:24:06 +02:00
2022-10-16 18:33:54 +02:00
2026-07-03 15:16:21 +02:00
2026-09-30 09:55:42 +02:00
2026-08-14 12:34:48 +02:00

QTSNBL - Qt Widgets and Utilities for SNBL

QTSNBL is a collection of reusable Qt-based widgets and routines developed for the SNBL beamline at the ESRF. It provides image visualization, 1D/2D plotting, fitting, and utility components used by Pylatus and related tools. The library is built on Qt 5/6, QCustomPlot, and the internal LLR math library.

Overview

The package is organized as a CMake library set under qtsnbl/. Each widget is built as a static library with AUTOMOC enabled, and headers are installed to include/qtsnbl. The code targets C++17 and uses AVX/AVX2 when available.

Key design points:

  • Image handling is centered on ImageData, a subclass of QCPColorMapData that owns an SiFrame<double> buffer and provides auto-bounds, interpolation, integrals, and contour generation.
  • ImageWidget wraps QCustomPlot to display 2D images with cross-hair, horizontal/vertical cuts, contour lines, polar projection, pinning, and beam center overlay.
  • CutWidget composes ImageWidget with two side Plot1D panels for linked 1D cuts, toolbar controls, and FWHM reporting.
  • Plotting primitives are abstracted via QCPWidget, PlotWidget, and Plot1D.
  • Fitting is provided by a threaded MPFIT-based framework with Gaussian, Lorentzian, Student, and Pseudo-Voigt models.
  • Utility widgets cover file dialogs, spin boxes, busy indicator, fixed-size dialog, updater, temperature plot, and name parsing.

Components

Core image and plotting

  • qtsnbl_imagewidget - ImageWidget and supporting ImageData, ColorScale, PolyLine. Image display with cuts, autoscale, log scale, contour, polar, interpolation, beam center, pinned cuts.
  • qtsnbl_cutwidget - CutWidget high-level container for image + 1D cuts with toolbar, settings persistence, FWHM calculation.
  • qtsnbl_imagewidgettoolbar - toolbar actions for image widget: autoscale, log, interpolate, integrate, contour, layout, etc.
  • qtsnbl_qcpwidget - base QCPWidget subclass of QCustomPlot with common event handling.
  • qtsnbl_plotwidget - PlotWidget 1D plot wrapper with autoscale, log X/Y buttons, zoom/select modes. Also builds Plot1D, the QObject core for 1D data management used by PlotWidget and the cuts; Plot1D has no library of its own.

Data and math

  • qtsnbl_autoboundsettings - AutoBoundSettings for configurable autoscaling: min/max or percentile, with lower/upper percentages.
  • qtsnbl_fitter - MPFIT-based fitting framework: Fitter, PeakFitter, GaussFitter, LorentzFitter, StudentFitter, PseudoVoigtFitter. Runs in a QThread, emits results, supports user curves.
  • qtsnbl_snblnameparser - SNBLNameParserSplit and SNBLNameParserRe for parsing SNBL file names into basename, period, frame.

Utilities

  • qtsnbl_addressinfo - address resolution helper.
  • qtsnbl_fixeddialog - fixed-size modal dialog.
  • qtsnbl_updater - WUpdater QMessageBox-based update notification widget.
  • qtsnbl_linetextedit - LineTextEdit QPlainTextEdit with line numbers.
  • qtsnbl_spinbox - custom SpinBox, DoubleSpinBox with improved editing.
  • qtsnbl_busyindicator - simple busy indicator widget.
  • qtsnbl_wtempplot - temperature plot widget with UI.
  • qtsnbl_common - time formatting and string conversion helpers.
  • qtsnbl_filedialogs - consistent file dialog wrappers.

Dependencies

Build requirements:

  • CMake >= 3.27
  • Qt5 or Qt6: Core, Widgets, Gui, Network
  • QCustomPlot
  • cmpfit
  • LLR - llr_autobounds, llr_sumcolrow, llr_divide, llr_minmax
  • cmake-tools recipes for Qt and QCustomPlot

The CMakeLists.txt uses bootstrap.cmake to download cmake-tools if not present in the parent.

Build

From the pylatus root or as a subproject:

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)

Options:

  • -DNO_AVX=1 disables AVX instructions.
  • -DQTSNBL_BUILD_TESTS=1 enables unit tests under tests/.

Install targets place libraries to lib/ and headers to include/qtsnbl.

Usage notes

  • ImageData is non-copyable; use clone() for deep copies. It can wrap an SiFrame<double> directly or act as a non-owning view.
  • ImageWidget::setImage(ImageData*) transfers ownership of display; cuts are calculated lazily from the visible area.
  • Auto-bounds are controlled via AutoBoundSettings and can be persisted per widget name.
  • Fitting classes are used via Fitter::run(x, y, errors, p0) and connect to results(bool success, QVector<double> y, QVector<double> params, QVector<double> errors).

Tests

Tests are in tests/:

  • tests.cpp - test harness
  • test1.cpp, test2.cpp - widget and data tests
  • benches.cpp - performance benchmarks
  • Data in tests/data/

Enable with -DQTSNBL_BUILD_TESTS=1.

Repository

Submodule URL: https://git.3lp.cx/dyadkin/qtsnbl Parent meta repo: pylatus

License

GPL-3.0+

S
Description
Qt widgets for SNBL software in C++
Readme
1.6 MiB
0 Stars 1 Watchers 0 Forks
Languages
C++ 94.4%
CMake 5.6%