BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ImportDataUtils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.h
6 //! @brief Defines ImportDataUtils namespace
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_IMPORTDATAWIDGETS_IMPORTDATAUTILS_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_IMPORTDATAWIDGETS_IMPORTDATAUTILS_H
17 
19 #include <QString>
20 #include <memory>
21 #include <vector>
22 
23 template <class T> class OutputData;
24 class RealDataItem;
25 class InstrumentItem;
27 class AbstractDataLoader;
28 
29 //! Provides utility methods to import data files.
30 
31 namespace ImportDataUtils {
32 std::unique_ptr<OutputData<double>> Import2dData(const QString& baseNameOfLoadedFile);
33 
34 //! Import 1D data into the given item.
35 //! Returns an error text if a fatal error occurred (discard item). "Empty string" means "no fatal
36 //! error" => imported item should be kept. The imported item still can have errors, but they might
37 //! be solvable by different import settings or by using a different data loader.
38 //! selectedLoader is the one which was selected in the open-file-dialog (or null if none selected).
39 QString Import1dData(RealDataItem* realDataItem, const AbstractDataLoader* selectedLoader);
40 
41 std::unique_ptr<OutputData<double>> ImportKnownData(const QString& baseNameOfLoadedFile);
42 std::unique_ptr<OutputData<double>> ImportReflectometryData(const QString& baseNameOfLoadedFile);
43 
44 //! Creates OutputData with bin-valued axes.
45 std::unique_ptr<OutputData<double>> CreateSimplifiedOutputData(const OutputData<double>& data);
46 
47 //! Check whether data item is compatible with instrument (same rank)
48 bool Compatible(const InstrumentItem& instrumentItem, const RealDataItem& realDataItem);
49 
50 //! Composes a message with the shapes of InstrumentItem and RealDataItem.
51 QString printShapeMessage(const std::vector<int>& instrument_shape,
52  const std::vector<int>& data_shape);
53 }; // namespace ImportDataUtils
54 
55 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_IMPORTDATAWIDGETS_IMPORTDATAUTILS_H
Defines ImportDataInfo helper struct.
Base class for all data loaders (classes which can import real data)
Templated class to store data of type double or CumulativeValue in multi-dimensional space.
Definition: OutputData.h:32
The RealDataItem class represents intensity data imported from file and intended for fitting.
Definition: RealDataItem.h:35
Provides utility methods to import data files.
std::unique_ptr< OutputData< double > > CreateSimplifiedOutputData(const OutputData< double > &data)
Creates OutputData with bin-valued axes.
std::unique_ptr< OutputData< double > > ImportReflectometryData(const QString &baseNameOfLoadedFile)
QString Import1dData(RealDataItem *realDataItem, const AbstractDataLoader *selectedLoader)
Import 1D data into the given item.
QString printShapeMessage(const std::vector< int > &instrument_shape, const std::vector< int > &data_shape)
Composes a message with the shapes of InstrumentItem and RealDataItem.
std::unique_ptr< OutputData< double > > ImportKnownData(const QString &baseNameOfLoadedFile)
bool Compatible(const InstrumentItem &instrumentItem, const RealDataItem &realDataItem)
Check whether data item is compatible with instrument (same rank)
std::unique_ptr< OutputData< double > > Import2dData(const QString &baseNameOfLoadedFile)