BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ItemFileNameUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/ItemFileNameUtils.cpp
6 //! @brief Defines auxiliary functions in ItemFileNameUtils 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 
20 
21 namespace {
22 const QString jobdata_file_prefix = "jobdata";
23 const QString refdata_file_prefix = "refdata";
24 const QString realdata_file_prefix = "realdata";
25 const QString instrument_file_prefix = "instrdata";
26 const QString nativedata_file_prefix = "nativedata";
27 
28 //! Constructs the name of the file for intensity data.
29 QString intensityDataFileName(const QString& itemName, const QString& prefix);
30 } // namespace
31 
32 //! Constructs the name of the file with simulated intensities.
33 
35 {
36  return intensityDataFileName(jobItem.itemName(), jobdata_file_prefix);
37 }
38 
39 //! Constructs the name of the file with reference data.
40 
42 {
43  return intensityDataFileName(jobItem.itemName(), refdata_file_prefix);
44 }
45 
47 {
48  return intensityDataFileName(jobItem.getIdentifier(), nativedata_file_prefix);
49 }
50 
51 //! Constructs the name of the intensity file belonging to real data item.
52 
54 {
55  return intensityDataFileName(realDataItem.name(), realdata_file_prefix);
56 }
57 
59 {
60  return intensityDataFileName(realDataItem.name(), nativedata_file_prefix);
61 }
62 
64 {
65  return intensityDataFileName(instrumentItem.id(), instrument_file_prefix);
66 }
67 
68 //! Returns list of fileName filters related to nonXML data stored by JobModel and RealDataModel.
69 
71 {
72  QStringList result = QStringList() << QString(jobdata_file_prefix + "_*.int.gz")
73  << QString(refdata_file_prefix + "_*.int.gz")
74  << QString(realdata_file_prefix + "_*.int.gz")
75  << QString(nativedata_file_prefix + "_*.int.gz")
76  << QString(instrument_file_prefix + "_*.int.gz");
77 
78  return result;
79 }
80 
81 namespace {
82 QString intensityDataFileName(const QString& itemName, const QString& prefix)
83 {
84  QString bodyName = GUIHelpers::getValidFileName(itemName);
85  return QString("%1_%2_0.int.gz").arg(prefix).arg(bodyName);
86 }
87 } // namespace
Defines class GUIHelpers functions.
Defines InstrumentItems classes.
Defines auxiliary functions in ItemFileNameUtils namespace.
Defines class JobItem.
Defines class RealDataItem.
QString id() const
QString getIdentifier() const
Definition: JobItem.cpp:103
The RealDataItem class represents intensity data imported from file and intended for fitting.
Definition: RealDataItem.h:35
QString name() const
The name which is presented to the user.
QString itemName() const
Get item name, return display name if no name is set.
QString getValidFileName(const QString &proposed_name)
Returns valid file name to be saved on disk.
Definition: GUIHelpers.cpp:144
QStringList nonXMLFileNameFilters()
Returns list of fileName filters related to nonXML data stored by JobModel and RealDataModel.
QString nativeDataFileName(const RealDataItem &realDataItem)
QString instrumentDataFileName(const InstrumentItem &instrumentItem)
QString jobResultsFileName(const JobItem &jobItem)
Constructs the name of the file with simulated intensities.
QString realDataFileName(const RealDataItem &realDataItem)
Constructs the name of the intensity file belonging to real data item.
QString jobReferenceFileName(const JobItem &jobItem)
Constructs the name of the file with reference data.
QString jobNativeDataFileName(const JobItem &jobItem)