BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DataLoaderUtil.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Loaders/DataLoaderUtil.cpp
6 //! @brief Implements class UserDefinedDataLoader1D
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
20 
21 void cloneAsUserDefinedLoader(AbstractDataLoader1D* loader, const QString& name)
22 {
23  loader->applyImportSettings();
24  auto* clonedLoader = dynamic_cast<AbstractDataLoader1D*>(loader->clone());
25  const auto defaultProperties = loader->serialize();
26 
28  new UserDefinedDataLoader1D(clonedLoader, name, defaultProperties));
29 }
30 
31 
32 namespace {
33 
34 //! simple factory method for a QREDataLoader
35 QREDataLoader* createQREDataLoader()
36 {
37  return new QREDataLoader();
38 }
39 
40 //! simple factory method for a AutomaticDataLoader1D
41 AutomaticDataLoader1D* createAutomaticDataLoader1D()
42 {
43  return new AutomaticDataLoader1D();
44 }
45 
46 } // namespace
47 
48 //! register the concrete data loaders with the registration facility
50 {
51  // the ordering in here defines the ordering in the selection combo box in the open file dialog
52  // and also in the selection combo box on the format configuration page. Furthermore the first
53  // returned loader will be used as default in the open file dialog if it is started for the
54  // first time
55  DataLoaders1D::instance().addBuiltInLoader(QREDataLoader().persistentClassName(),
56  createQREDataLoader);
58  createAutomaticDataLoader1D);
59 }
Defines class AutomaticDataLoader1D.
void cloneAsUserDefinedLoader(AbstractDataLoader1D *loader, const QString &name)
clones the loader as a user defined loader and puts it in DataLoaders1D store
void register1DDataLoaders()
register the concrete data loaders with the registration facility
Utility functions for data loaders.
Defines class DataLoaders1D.
Defines class QREDataLoader.
Defines class UserDefinedDataLoader1D.
Abstract base class for reflectometry data loaders.
virtual QByteArray serialize() const
Returns every internal setting so it can be restored completely.
virtual void applyImportSettings()
Read all values from the properties UI into the internal variables.
virtual AbstractDataLoader * clone() const =0
Create a complete clone, including all internal states.
The legacy importer for reflectometry, with no user interaction.
void addBuiltInLoader(const QString &persistentClassName, const std::function< AbstractDataLoader1D *()> &create)
Register a built-in loader with the given class name and factory function.
void addUserDefinedLoader(AbstractDataLoader1D *loader)
add a user defined loader
static DataLoaders1D & instance()
The one and only instance.
Loader for experimental reflectometry CSV files that contain three columns with Q,...
Definition: QREDataLoader.h:29
A user defined data loader. This is a thin wrapper around the real loader implementation,...
QString const & name(EShape k)
Definition: particles.cpp:20