BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ImportDataInfo Class Reference

Description

Carries information about loaded data.

Definition at line 26 of file ImportDataInfo.h.

Collaboration diagram for ImportDataInfo:
[legend]

Public Member Functions

 ImportDataInfo (Datafield &&data, Coords units)
 
 ImportDataInfo (ImportDataInfo &&other)
 
 ImportDataInfo (std::unique_ptr< Datafield > data, const QString &units)
 
 ImportDataInfo (std::unique_ptr< Datafield > data, Coords units)
 
 ~ImportDataInfo ()
 
QString axisLabel (size_t axis_index) const
 
std::unique_ptr< Datafield > clonedData () const &
 
size_t dataRank () const
 Returns number of dimensions. More...
 
std::unique_ptr< Datafield > intensityData () &&
 
 operator bool () const
 True if the contained data is not nullptr (no info about empty data) More...
 
QString unitsLabel () const
 

Private Member Functions

void checkValidity ()
 

Private Attributes

const Coords m_coords
 
std::unique_ptr< Datafield > m_data
 

Constructor & Destructor Documentation

◆ ImportDataInfo() [1/4]

ImportDataInfo::ImportDataInfo ( std::unique_ptr< Datafield >  data,
Coords  units 
)

Definition at line 47 of file ImportDataInfo.cpp.

48  : m_data(units == Coords::NBINS && data ? GUI::Util::IO::binifyAxes(*data) : std::move(data))
49  , m_coords(units)
50 {
51  checkValidity();
52 }
std::unique_ptr< Datafield > m_data
const Coords m_coords
std::unique_ptr< Datafield > binifyAxes(const Datafield &data)
Creates Datafield with bin-valued axes.
Definition: IOUtils.cpp:22

References checkValidity().

Here is the call graph for this function:

◆ ImportDataInfo() [2/4]

ImportDataInfo::ImportDataInfo ( Datafield &&  data,
Coords  units 
)

Definition at line 61 of file ImportDataInfo.cpp.

62  : ImportDataInfo(std::make_unique<Datafield>(std::move(data)), units)
63 {
64 }
ImportDataInfo(std::unique_ptr< Datafield > data, Coords units)

◆ ImportDataInfo() [3/4]

ImportDataInfo::ImportDataInfo ( std::unique_ptr< Datafield >  data,
const QString &  units 
)

Definition at line 54 of file ImportDataInfo.cpp.

55  : m_data(std::move(data))
57 {
58  checkValidity();
59 }
Coords coordFromName(const QString &name)
Returns domain axes units type from their GUI name.
Definition: CoordName.cpp:46

References checkValidity().

Here is the call graph for this function:

◆ ImportDataInfo() [4/4]

ImportDataInfo::ImportDataInfo ( ImportDataInfo &&  other)

Definition at line 41 of file ImportDataInfo.cpp.

42  : m_data(std::move(other.m_data))
43  , m_coords(other.m_coords)
44 {
45 }
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)

References other.

◆ ~ImportDataInfo()

ImportDataInfo::~ImportDataInfo ( )
default

Member Function Documentation

◆ axisLabel()

QString ImportDataInfo::axisLabel ( size_t  axis_index) const

Definition at line 97 of file ImportDataInfo.cpp.

98 {
99  if (!m_data)
100  return "";
101 
102  const size_t rank = m_data->rank();
103  if (rank == 2)
104  return axis_index == 0 ? "X [nbins]" : "Y [nbins]";
105  if (rank == 1) {
106  if (axis_index > 0)
107  return "Signal [a.u.]";
108  return QString::fromStdString(DataUtils::AxisNames::specAxis.at(m_coords));
109  }
110  throw Error("Error in ImportDataInfo::axisLabel: unsupported data type");
111 }

References Error, m_coords, and m_data.

Referenced by IntensityDataItem::reset(), and SpecularDataItem::reset().

◆ checkValidity()

void ImportDataInfo::checkValidity ( )
private

Definition at line 113 of file ImportDataInfo.cpp.

114 {
115  if (!m_data)
116  return;
117  auto iter = available_units.find(m_data->rank());
118  if (iter == available_units.end())
119  throw Error("Error in ImportDataInfo constructor: unsupported data type");
120  for (auto& value : iter->second)
121  if (m_coords == value)
122  return;
123 
124  throw Error("Error in ImportDataInfo constructor: inacceptable units passed.");
125 }

References Error, m_coords, and m_data.

Referenced by ImportDataInfo().

◆ clonedData()

std::unique_ptr< Datafield > ImportDataInfo::clonedData ( ) const &

Definition at line 73 of file ImportDataInfo.cpp.

74 {
75  if (!m_data)
76  return nullptr;
77  return std::unique_ptr<Datafield>(m_data->clone());
78 }

References m_data.

Referenced by RealDataItem::setImportData().

◆ dataRank()

size_t ImportDataInfo::dataRank ( ) const

Returns number of dimensions.

Definition at line 85 of file ImportDataInfo.cpp.

86 {
87  if (!m_data)
88  return 0;
89  return m_data->rank();
90 }

References m_data.

Referenced by RealDataItem::setImportData().

◆ intensityData()

std::unique_ptr< Datafield > ImportDataInfo::intensityData ( ) &&

Definition at line 80 of file ImportDataInfo.cpp.

81 {
82  return std::move(m_data);
83 }

◆ operator bool()

ImportDataInfo::operator bool ( ) const

True if the contained data is not nullptr (no info about empty data)

Definition at line 68 of file ImportDataInfo.cpp.

69 {
70  return static_cast<bool>(m_data);
71 }

◆ unitsLabel()

QString ImportDataInfo::unitsLabel ( ) const

Definition at line 92 of file ImportDataInfo.cpp.

93 {
95 }
QString nameFromCoord(Coords units)
Returns axes units names from their domain counterpart.
Definition: CoordName.cpp:36

References m_coords, and GUI::Util::CoordName::nameFromCoord().

Referenced by IntensityDataItem::reset(), SpecularDataItem::reset(), and RealDataItem::setImportData().

Here is the call graph for this function:

Member Data Documentation

◆ m_coords

const Coords ImportDataInfo::m_coords
private

Definition at line 51 of file ImportDataInfo.h.

Referenced by axisLabel(), checkValidity(), and unitsLabel().

◆ m_data

std::unique_ptr<Datafield> ImportDataInfo::m_data
private

Definition at line 50 of file ImportDataInfo.h.

Referenced by axisLabel(), checkValidity(), clonedData(), and dataRank().


The documentation for this class was generated from the following files: