BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DataItemUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Tool/DataItemUtils.cpp
6 //! @brief Implements namespace DataItemUtils
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 
19 #include "GUI/Model/Job/JobItem.h"
20 
21 namespace {
22 
23 template <class DataItemType>
24 DataItemType* dataItem(SessionItem* parent)
25 {
26  ASSERT(parent && "Assertion failed in GUI::Model::DataItemUtils::dataItem: nullptr passed.");
27 
28  if (parent->modelType() == JobItem::M_TYPE)
29  return dynamic_cast<DataItemType*>(dynamic_cast<JobItem*>(parent)->dataItem());
30  if (auto* real_data = dynamic_cast<RealDataItem*>(parent))
31  return dynamic_cast<DataItemType*>(real_data->dataItem());
32  if (auto* self = dynamic_cast<DataItemType*>(parent))
33  return self;
34  ASSERT(0);
35 }
36 
37 } // namespace
38 
40 {
41  return dataItem<IntensityDataItem>(parent);
42 }
43 
45 {
46  return dataItem<SpecularDataItem>(parent);
47 }
Defines functions in namespace GUI::Model::DataItemUtils.
Defines class IntensityDataItem.
Defines class JobItem.
Defines class RealDataItem.
Defines class SpecularDataItem.
static constexpr auto M_TYPE
Definition: JobItem.h:62
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33
Base class for a GUI data item.
Definition: SessionItem.h:204
QString modelType() const
Get model type.
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.