jfjoch_viewer: list every format it opens in the file browser and the open dialog

The file browser listed only *_master.h5, *_process.h5 and *.cbf, and the open
dialog had no filter covering frames numbered in their extension, so a marCCD or
ADSC sweep written as name.001 / name.0001 was invisible in both, as were .cbf.gz,
.mccd, .osc, .sfrm, .nxs, .cxi and .xtc in the browser.

One list of wildcards (reader/FileNamePatterns.h) now serves both: the HDF5
masters and processing results, .nxs, .cxi, .xtc, the raw frame extensions and
frame numbers of three to five digits. The open dialog offers it first as
"All supported", plus any .h5 and .geom for the files of an XFEL run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-20 02:41:11 +01:00
1 parent 4809c1622c
commit 4c322b3e39
5 files changed
+39 -8

No files matched your search

+1
View File
@@ -38,6 +38,7 @@ ADD_LIBRARY(JFJochReader STATIC
SFRM.h
JFJochSFRMReader.cpp
JFJochSFRMReader.h
FileNamePatterns.h
HDF5ImageLocator.cpp
JFJochStartMessageReader.cpp
JFJochStartMessageReader.h
+20
View File
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <string>
#include <vector>
// The files the viewer lists as openable, as wildcards in the QDir name-filter syntax. Only what is
// listed is decided here: the readers tell the formats apart by content (.img is miniCBF, marCCD or
// SMV depending on the writer).
//
// An HDF5 dataset is opened by its master or its processing result, never by the _data_NNNNNN.h5
// shards a master links to. A raw frame is one image per file, and naming any frame opens its whole
// sweep; the marCCD and ADSC software number a frame in its extension ("name.001", "name.0001").
inline const std::vector<std::string> OPENABLE_FILE_PATTERNS = {
"*_master.h5", "*_process.h5", "*.nxs", "*.cxi", "*.xtc",
"*.cbf", "*.cbf.gz", "*.img", "*.mccd", "*.marccd", "*.tif", "*.tiff", "*.smv", "*.osc", "*.sfrm",
"*.[0-9][0-9][0-9]", "*.[0-9][0-9][0-9][0-9]", "*.[0-9][0-9][0-9][0-9][0-9]"
};
+9 -2
View File
@@ -27,6 +27,7 @@
#include "windows/JFJochAcknowledgementWindow.h"
#include "../common/GitInfo.h"
#include "../common/CUDAWrapper.h"
#include "../reader/FileNamePatterns.h"
JFJochViewerMenu::JFJochViewerMenu(QWidget *parent) : QMenuBar(parent) {
// Create "File" menu
@@ -261,12 +262,18 @@ void JFJochViewerMenu::acknowledgementsSelected() {
void JFJochViewerMenu::openSelected() {
// Several files are one dataset: the files of a serial XFEL run (SACLA HDF5, CXI, XTC), opened as
// rugnux opens them, with a CrystFEL geometry file among them taken as their module geometry.
// A raw frame is one image per file: picking any frame opens the sweep it belongs to. Any .h5 and
// a .geom are offered as well, for the files of an XFEL run.
QStringList supported;
for (const auto &p: OPENABLE_FILE_PATTERNS)
supported << QString::fromStdString(p);
supported << "*.h5" << "*.geom";
const QStringList fileNames = QFileDialog::getOpenFileNames(
this,
"Open File(s)", // Dialog title
"", // Default folder
// A CBF is one frame per file: picking any frame opens the sweep it belongs to.
"HDF5 Master Files (*_master.h5 *_process.h5);; HDF5 Files (*.h5);; CBF Images (*.cbf *.cbf.gz);; CCD Images (*.img *.mccd *.smv);; XFEL Stills (*.h5 *.cxi *.xtc *.geom);;All Files (*)"
"All supported (" + supported.join(' ') + ");;HDF5 Master Files (*_master.h5 *_process.h5);;"
"XFEL Stills (*.h5 *.cxi *.xtc *.geom);;All Files (*)"
);
if (!fileNames.isEmpty()) {
+8 -4
View File
@@ -21,6 +21,8 @@
#include <QApplication>
#include <QSet>
#include "../../reader/FileNamePatterns.h"
namespace {
constexpr auto kDataRootEnvVar = "JUNGFRAUJOCH_DATA_ROOT";
constexpr auto kSettingsKey = "fileBrowserRoot";
@@ -101,10 +103,12 @@ JFJochViewerFileBrowser::JFJochViewerFileBrowser(QWidget *parent) : QWidget(pare
model_ = new QFileSystemModel(this);
model_->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
// Directories are always listed regardless of these; only *_master.h5 / *_process.h5 and
// miniCBF frames among files. The many _data_NNNNNN.h5 shards of a dataset are not meant to be
// opened directly; a .cbf is one frame per file, and opening any of them opens its whole sweep.
model_->setNameFilters({"*_master.h5", "*_process.h5", "*.cbf"});
// Directories are always listed regardless of these; among files only those the viewer opens
// (FileNamePatterns.h).
QStringList patterns;
for (const auto &p: OPENABLE_FILE_PATTERNS)
patterns << QString::fromStdString(p);
model_->setNameFilters(patterns);
model_->setNameFilterDisables(false); // hide non-matching files rather than just greying them out
proxy_ = new FileOnlyFilterProxy(this);
+1 -2
View File
@@ -14,8 +14,7 @@ class QTreeView;
class QModelIndex;
// Left-side dock alternative to the Processing (reprocessing settings) panel: a directory tree rooted at a
// configurable data root, filtered down to subdirectories and *_master.h5 / *_process.h5 / *.cbf
// files, for browsing to and opening a dataset without caring about reprocessing. Backed by QFileSystemModel,
// configurable data root, filtered down to subdirectories and the files the viewer opens, for browsing to and opening a dataset without caring about reprocessing. Backed by QFileSystemModel,
// which only lists a directory once it is expanded - so a root with hundreds of sibling directories
// (e.g. an SLS beamline's /sls/mx/data/) costs one readdir at each level actually opened, never a
// recursive scan of the whole tree.