BornAgain  1.19.79
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/Support/IO/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 
16 #include "GUI/Util/Path.h"
17 
18 namespace {
19 
20 const QString jobdata_file_prefix = "jobdata";
21 const QString refdata_file_prefix = "refdata";
22 const QString realdata_file_prefix = "realdata";
23 const QString instrument_file_prefix = "instrdata";
24 const QString nativedata_file_prefix = "nativedata";
25 
26 //! Constructs the name of the file for intensity data.
27 QString intensityDataFileName(const QString& itemName, const QString& prefix)
28 {
29  QString bodyName = GUI::Util::Path::getValidFileName(itemName);
30  return QString("%1_%2_0.int.gz").arg(prefix).arg(bodyName);
31 }
32 
33 } // namespace
34 
35 
36 //! Constructs the name of the file with simulated intensities.
37 
38 QString GUI::Model::FilenameUtils::jobResultsFileName(const QString& itemName)
39 {
40  return intensityDataFileName(itemName, jobdata_file_prefix);
41 }
42 
43 //! Constructs the name of the file with reference data.
44 
45 QString GUI::Model::FilenameUtils::jobReferenceFileName(const QString& itemName)
46 {
47  return intensityDataFileName(itemName, refdata_file_prefix);
48 }
49 
51 {
52  return intensityDataFileName(id, nativedata_file_prefix);
53 }
54 
55 //! Constructs the name of the intensity file belonging to real data item.
56 
57 QString GUI::Model::FilenameUtils::realDataFileName(const QString& dataName)
58 {
59  return intensityDataFileName(dataName, realdata_file_prefix);
60 }
61 
62 QString GUI::Model::FilenameUtils::nativeDataFileName(const QString& dataName)
63 {
64  return intensityDataFileName(dataName, nativedata_file_prefix);
65 }
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 }
Defines namespace GUI::Model::FilenameUtils.
Defines class Helpers functions.
QString jobReferenceFileName(const QString &itemName)
Constructs the name of the file with reference data.
QString jobResultsFileName(const QString &itemName)
Constructs the name of the file with simulated intensities.
QStringList nonXMLFileNameFilters()
Returns list of fileName filters related to nonXML data stored by JobModel and RealDataModel.
QString nativeDataFileName(const QString &dataName)
QString realDataFileName(const QString &dataName)
Constructs the name of the intensity file belonging to real data item.
QString jobNativeDataFileName(const QString &id)
QString getValidFileName(const QString &proposed_name)
Returns valid file name to be saved on disk. This name is constructed from proposed_name by replacing...
Definition: Path.cpp:74