BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
applicationmodels.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/model/applicationmodels.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
19 #include "gui2/model/jobmodel.h"
22 #include "gui2/model/sampleitems.h"
23 #include "gui2/model/samplemodel.h"
26 #include "mvvm/model/itempool.h"
27 #include "mvvm/model/modelutils.h"
28 #include "mvvm/model/sessionitem.h"
29 
30 namespace gui2 {
31 
32 using namespace ModelView;
33 
35  std::unique_ptr<MaterialModel> m_material_model;
36  std::unique_ptr<SampleModel> m_sample_model;
37  std::unique_ptr<SLDElementModel> m_sld_view_model;
38  std::unique_ptr<JobModel> m_job_model;
39  std::unique_ptr<ExperimentalDataModel> m_experimental_model;
40  std::unique_ptr<InstrumentModel> m_instrument_model;
41  std::unique_ptr<MaterialPropertyController> m_material_controller;
42  std::unique_ptr<ExperimentalDataController> m_data_controller;
43  std::shared_ptr<ItemPool> item_pool;
44 
46  {
47  item_pool = std::make_shared<ItemPool>();
48  m_material_model = std::make_unique<MaterialModel>(item_pool);
49  m_sample_model = std::make_unique<SampleModel>(item_pool);
50  m_sld_view_model = std::make_unique<SLDElementModel>();
51  m_job_model = std::make_unique<JobModel>(item_pool);
52  m_experimental_model = std::make_unique<ExperimentalDataModel>(item_pool);
53  m_instrument_model = std::make_unique<InstrumentModel>(item_pool);
54  m_material_controller = std::make_unique<MaterialPropertyController>(m_material_model.get(),
55  m_sample_model.get());
56  m_data_controller = std::make_unique<ExperimentalDataController>(m_experimental_model.get(),
57  m_instrument_model.get());
58  m_sample_model->create_default_multilayer();
59  update_material_properties();
60  }
61 
62  //! Runs through all layers and assign materials.
63  //! Expecting 3 materials existing by default (air, default, Si) to assign to our 3 layers.
64 
66  {
67  auto multilayer = Utils::TopItem<MultiLayerItem>(m_sample_model.get());
68  auto layers = multilayer->items<LayerItem>(MultiLayerItem::T_LAYERS);
69  size_t index(0);
70  for (const auto& material_property : m_material_model->material_data()) {
71  if (index < layers.size())
72  layers[index]->setProperty(LayerItem::P_MATERIAL, material_property);
73  ++index;
74  }
75  }
76 
77  //! Models intended for saving.
78  std::vector<SessionModel*> persistent_models() const
79  {
80  return {m_material_model.get(), m_sample_model.get(), m_instrument_model.get(),
81  m_experimental_model.get()};
82  }
83 
84  //! All application models.
85  std::vector<SessionModel*> application_models() const
86  {
87  return {m_material_model.get(), m_sample_model.get(), m_instrument_model.get(),
88  m_sld_view_model.get(), m_job_model.get(), m_experimental_model.get()};
89  }
90 };
91 
93 
95 
97 {
98  return p_impl->m_material_model.get();
99 }
100 
102 {
103  return p_impl->m_sample_model.get();
104 }
105 
107 {
108  return p_impl->m_sld_view_model.get();
109 }
110 
112 {
113  return p_impl->m_job_model.get();
114 }
115 
117 {
118  return p_impl->m_experimental_model.get();
119 }
120 
122 {
123  return p_impl->m_instrument_model.get();
124 }
125 
126 std::vector<SessionModel*> ApplicationModels::persistent_models() const
127 {
128  return p_impl->persistent_models();
129 }
130 
131 //! Return vector of all models of our application.
132 
133 std::vector<SessionModel*> ApplicationModels::application_models() const
134 {
135  return p_impl->application_models();
136 }
137 
138 } // namespace gui2
Defines class CLASS?
std::vector< ModelView::SessionModel * > application_models() const
Return vector of all models of our application.
SLDElementModel * sldViewModel()
ExperimentalDataModel * experimentalDataModel()
MaterialModel * materialModel()
std::unique_ptr< ApplicationModelsImpl > p_impl
std::vector< ModelView::SessionModel * > persistent_models() const override
Returns vector of models intended for saving on disk.
InstrumentModel * instrumentModel()
The model to store imported reflectometry data.
Model to store specular instruments settings.
The model to store results of (possibly) multiple reflectometry simulation, and all viewports,...
Definition: jobmodel.h:36
Layer with name, thickness and reference to material.
Definition: sampleitems.h:39
static const std::string P_MATERIAL
Definition: sampleitems.h:42
Model to hold MaterialItems.
Definition: materialmodel.h:35
static const std::string T_LAYERS
Definition: sampleitems.h:54
The model of the sld layer visual representation.
Model to hold layers and multi-layers.
Definition: samplemodel.h:24
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Definition: filesystem.h:81
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
std::unique_ptr< MaterialModel > m_material_model
std::unique_ptr< SLDElementModel > m_sld_view_model
std::unique_ptr< ExperimentalDataModel > m_experimental_model
std::unique_ptr< MaterialPropertyController > m_material_controller
std::vector< SessionModel * > application_models() const
All application models.
std::unique_ptr< InstrumentModel > m_instrument_model
std::vector< SessionModel * > persistent_models() const
Models intended for saving.
void update_material_properties()
Runs through all layers and assign materials.
std::unique_ptr< ExperimentalDataController > m_data_controller