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 ofQCPColorMapDatathat owns anSiFrame<double>buffer and provides auto-bounds, interpolation, integrals, and contour generation. ImageWidgetwraps QCustomPlot to display 2D images with cross-hair, horizontal/vertical cuts, contour lines, polar projection, pinning, and beam center overlay.CutWidgetcomposesImageWidgetwith two sidePlot1Dpanels for linked 1D cuts, toolbar controls, and FWHM reporting.- Plotting primitives are abstracted via
QCPWidget,PlotWidget, andPlot1D. - 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 -
ImageWidgetand supportingImageData,ColorScale,PolyLine. Image display with cuts, autoscale, log scale, contour, polar, interpolation, beam center, pinned cuts. - qtsnbl_cutwidget -
CutWidgethigh-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
QCPWidgetsubclass of QCustomPlot with common event handling. - qtsnbl_plotwidget -
PlotWidget1D plot wrapper with autoscale, log X/Y buttons, zoom/select modes. Also buildsPlot1D, the QObject core for 1D data management used byPlotWidgetand the cuts;Plot1Dhas no library of its own.
Data and math
- qtsnbl_autoboundsettings -
AutoBoundSettingsfor 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 -
SNBLNameParserSplitandSNBLNameParserRefor parsing SNBL file names into basename, period, frame.
Utilities
- qtsnbl_addressinfo - address resolution helper.
- qtsnbl_fixeddialog - fixed-size modal dialog.
- qtsnbl_updater -
WUpdaterQMessageBox-based update notification widget. - qtsnbl_linetextedit -
LineTextEditQPlainTextEdit with line numbers. - qtsnbl_spinbox - custom
SpinBox,DoubleSpinBoxwith 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=1disables AVX instructions.-DQTSNBL_BUILD_TESTS=1enables unit tests undertests/.
Install targets place libraries to lib/ and headers to include/qtsnbl.
Usage notes
ImageDatais non-copyable; useclone()for deep copies. It can wrap anSiFrame<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
AutoBoundSettingsand can be persisted per widget name. - Fitting classes are used via
Fitter::run(x, y, errors, p0)and connect toresults(bool success, QVector<double> y, QVector<double> params, QVector<double> errors).
Tests
Tests are in tests/:
tests.cpp- test harnesstest1.cpp,test2.cpp- widget and data testsbenches.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+