BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
samplemodel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/model/samplemodel.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 
15 #include "gui2/model/samplemodel.h"
16 #include "gui2/model/sampleitems.h"
18 
19 using namespace ModelView;
20 
21 namespace gui2 {
22 
23 namespace {
24 std::unique_ptr<ItemCatalogue> CreateItemCatalogue()
25 {
26  auto result = std::make_unique<ItemCatalogue>();
27  result->registerItem<MultiLayerItem>();
28  result->registerItem<LayerItem>();
29  result->registerItem<RoughnessItem>();
30  return result;
31 }
32 } // namespace
33 
34 SampleModel::SampleModel(std::shared_ptr<ModelView::ItemPool> pool)
35  : SessionModel("SampleModel", pool)
36 {
37  setItemCatalogue(CreateItemCatalogue());
38 }
39 
40 //! Populate the model with default MultiLayer with 3 layers.
41 
43 {
44  auto multilayer = insertItem<MultiLayerItem>();
45 
46  auto top = insertItem<LayerItem>(multilayer);
47  top->setProperty(LayerItem::P_NAME, std::string("Ambient"));
48  auto middle = insertItem<LayerItem>(multilayer);
49  middle->setProperty(LayerItem::P_NAME, std::string("Middle"));
50  auto substrate = insertItem<LayerItem>(multilayer);
51  substrate->setProperty(LayerItem::P_NAME, std::string("Substrate"));
52 
53  middle->setProperty(LayerItem::P_THICKNESS, 42.0);
54 }
55 
56 } // namespace gui2
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
void setItemCatalogue(std::unique_ptr< ItemCatalogue > catalogue)
Sets brand new catalog of user-defined items.
SampleModel(QObject *parent=nullptr)
Definition: SampleModel.cpp:18
static const std::string P_THICKNESS
Definition: sampleitems.h:43
static const std::string P_NAME
Definition: sampleitems.h:41
void create_default_multilayer()
Populate the model with default MultiLayer with 3 layers.
Definition: samplemodel.cpp:42
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
Defines class CLASS?
Defines class CLASS?