BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
layerviewmodelcontroller.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/layereditor/layerviewmodelcontroller.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 
16 #include "gui2/model/sampleitems.h"
21 
22 using namespace ModelView;
23 
24 namespace gui2 {
25 
26 //! Custom strategy to form table rows for nested multilayers and layers.
27 
29 public:
30  QStringList horizontalHeaderLabels() const
31  {
32  return QStringList() << "Name"
33  << "Nr."
34  << "Material"
35  << "Thickness [nm]"
36  << "Sigma [nm]";
37  }
38 
39  std::vector<std::unique_ptr<ViewItem>> constructRow(SessionItem* item)
40  {
41  std::vector<std::unique_ptr<ViewItem>> result;
42 
43  // multilayer row contains its name, repetion and placeholders (instead of material and
44  // thickness)
45  if (auto multilayer = dynamic_cast<MultiLayerItem*>(item)) {
46  result.emplace_back(
47  std::make_unique<ViewDataItem>(multilayer->getItem(LayerItem::P_NAME)));
48  // result.push_back(new ViewLabelItem(multilayer));
49  result.emplace_back(std::make_unique<ViewDataItem>(
50  multilayer->getItem(MultiLayerItem::P_NREPETITIONS)));
51  result.emplace_back(std::make_unique<ViewEmptyItem>()); // instead of P_MATERIAL
52  result.emplace_back(std::make_unique<ViewEmptyItem>()); // instead of P_THICKNESS
53  result.emplace_back(std::make_unique<ViewEmptyItem>()); // instead of P_ROUGHNESS
54  }
55 
56  // layer row contains its name, placeholder for repetition, layer material and thickness
57  if (auto layer = dynamic_cast<LayerItem*>(item)) {
58  result.emplace_back(std::make_unique<ViewDataItem>(layer->getItem(LayerItem::P_NAME)));
59  // result.push_back(new ViewLabelItem(layer));
60  result.emplace_back(std::make_unique<ViewEmptyItem>()); // instead of P_NREPETITIONS
61  result.emplace_back(
62  std::make_unique<ViewDataItem>(layer->getItem(LayerItem::P_MATERIAL)));
63  result.emplace_back(
64  std::make_unique<ViewDataItem>(layer->getItem(LayerItem::P_THICKNESS)));
65  result.emplace_back(std::make_unique<ViewDataItem>(
66  layer->getItem(LayerItem::P_ROUGHNESS)->getItem(RoughnessItem::P_SIGMA)));
67  }
68 
69  return result;
70  }
71 };
72 
73 LayerViewModelController::LayerViewModelController(SessionModel* model, ViewModel* view_model)
74  : ViewModelController(model, view_model)
75 {
76  setRowStrategy(std::make_unique<CustomLayerRowStrategy>());
77  setChildrenStrategy(std::make_unique<TopItemsStrategy>());
78 }
79 
80 } // namespace gui2
static const QString P_MATERIAL
Definition: LayerItem.h:24
static const QString P_THICKNESS
Definition: LayerItem.h:22
static const QString P_ROUGHNESS
Definition: LayerItem.h:23
Base class to construct row of ViewItem's from given SessionItem.
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
Propagates changes from SessionModel to its ViewModelBase.
void setChildrenStrategy(std::unique_ptr< ChildrenStrategyInterface > children_strategy)
void setRowStrategy(std::unique_ptr< RowStrategyInterface > row_strategy)
Main class to represent content of SessionModel in Qt's trees and tables.
Definition: viewmodel.h:29
static const QString P_NAME
Definition: SessionItem.h:37
Custom strategy to form table rows for nested multilayers and layers.
std::vector< std::unique_ptr< ViewItem > > constructRow(SessionItem *item)
Layer with name, thickness and reference to material.
Definition: sampleitems.h:39
Multi layer capable of holding layers and other multi-layers.
Definition: sampleitems.h:51
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?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?