BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RealDataItem.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Data/RealDataItem.h
6 //! @brief Defines class RealDataItem
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_MODEL_DATA_REALDATAITEM_H
16 #define BORNAGAIN_GUI_MODEL_DATA_REALDATAITEM_H
17 
20 
21 class DataItem;
22 class InstrumentItem;
23 class IntensityDataItem;
24 class SpecularDataItem;
25 class MaskContainerItem;
26 class Datafield;
27 class ImportDataInfo;
28 class AbstractDataLoader;
29 
30 //! Provides access to experimental data, for display and fitting.
31 //! Owns an AbstractDataLoader.
32 
33 class BA_CORE_API_ RealDataItem : public QObject, public SessionItem {
34  Q_OBJECT
35 
36  friend class TestView;
37 
38 private:
39  static constexpr auto P_INSTRUMENT_ID{"Instrument Id"};
40  static constexpr auto T_INTENSITY_DATA{"Intensity data"};
41  static constexpr auto T_NATIVE_DATA{"Native user data axis"};
42  static constexpr auto P_NATIVE_DATA_UNITS{"Native user data units"};
43 
44 public:
45  static constexpr auto M_TYPE{"RealData"};
46 
47  RealDataItem();
48 
49  void initAsSpecularItem();
50  void initAsIntensityItem();
51 
52  //! The name which is presented to the user
53  QString dataName() const;
54  void setDataName(const QString& name);
55 
57  const IntensityDataItem* intensityDataItem() const;
58 
60  const SpecularDataItem* specularDataItem() const;
61 
62  DataItem* dataItem();
63  const DataItem* dataItem() const;
64 
65  DataItem* nativeData();
66  const DataItem* nativeData() const;
67  void initNativeData();
68  QString nativeDataUnits() const;
69  void setNativeDataUnits(const QString& units);
70  void removeNativeData();
71  bool hasNativeData() const;
72  const Datafield* nativeDatafield() const;
73  void setNativeDatafield(Datafield* data);
74 
75  void setDatafield(Datafield* data);
76  void setImportData(ImportDataInfo info);
77  bool holdsDimensionalData() const;
78 
79  QString instrumentId() const;
80  void linkToInstrument(const InstrumentItem* instrument);
81  void unlinkFromInstrument();
82 
83  //! Returns the shape of underlying data item
84  std::vector<int> shape() const;
85 
86  bool isIntensityData() const;
87  bool isSpecularData() const;
88 
89  bool hasImportErrors() const;
90 
91  //! Returns mask container item
92  MaskContainerItem* maskContainerItem();
93 
94  //! The name from where the native data was originally imported
95  void setNativeFileName(const QString& filename);
96  QString nativeFileName() const;
97 
98  QByteArray serializeBinaryData() const override;
99  void deserializeBinaryData(const QByteArray& data) override;
100 
101  //! Takes ownership of loader
102  void setDataLoader(AbstractDataLoader* loader);
103  AbstractDataLoader* dataLoader() const;
104 
105  //! Returns true, if rotation will affect linked instrument or mask presence.
106  bool rotationAffectsSetup() const;
107  void rotateData();
108 
109  void updateNonXMLDataFileNames();
110 
111 signals:
113 
114 private:
115  void initDataItem(size_t data_rank, const QString& tag);
116  QModelIndex index() const;
117 
118  //! This does not set the link to the instrument! Use linkToInstrument() if you want
119  //! to link to this instrument.
120  void updateToInstrument(const InstrumentItem* instrument);
121 
122  QByteArray m_importSettings;
124 
125  std::unique_ptr<AbstractDataLoader> m_dataLoader;
126 };
127 
128 #endif // BORNAGAIN_GUI_MODEL_DATA_REALDATAITEM_H
Defines class AbstractDataLoader.
Defines class SessionItem.
Abstract base class for all data loaders (classes to import real data).
Abstract base class for IntensityDataItem and SpecularDataItem. Owns one simulated data set of type D...
Definition: DataItem.h:34
Carries information about loaded data.
Abstract base class for instrument-specific item classes.
Container holding various masks as children.
Definition: MaskItems.h:202
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33
QModelIndex index() const
QByteArray m_importSettings
Definition: RealDataItem.h:122
std::unique_ptr< AbstractDataLoader > m_dataLoader
Definition: RealDataItem.h:125
QString m_nativeFileName
Definition: RealDataItem.h:123
void importContentsProcessed()
Base class for a GUI data item.
Definition: SessionItem.h:204
virtual void deserializeBinaryData(const QByteArray &data)
virtual QByteArray serializeBinaryData() const
SpecularDataItem * specularDataItem(SessionItem *parent)
Returns SpecularDataItem contained as a child in givent parent.
IntensityDataItem * intensityDataItem(SessionItem *parent)
Returns IntensityDataItem contained as a child in givent parent.
QString const & name(EShape k)
Definition: particles.cpp:20