BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
layereditorwidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/layereditor/layereditorwidget.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 
21 #include "gui2/model/sampleitems.h"
22 #include "gui2/model/samplemodel.h"
24 #include <QVBoxLayout>
25 
26 namespace gui2 {
27 
29  : QWidget(parent)
30  , m_layerView(new LayerTreeView)
31  , m_delegate(std::make_unique<ModelView::ViewModelDelegate>())
32 {
33  auto layout = new QVBoxLayout;
34  layout->setContentsMargins(0, 0, 0, 0);
35  layout->addWidget(m_layerView);
36  setLayout(layout);
37  m_layerView->setItemDelegate(m_delegate.get());
38 }
39 
41 
43 {
44  m_viewModel = std::make_unique<LayerViewModel>(models->sampleModel());
46 
47  m_delegate->setEditorFactory(std::make_unique<CustomLayerTreeEditorFactory>(models));
48  m_viewModel->setRootSessionItem(models->sampleModel()->topItem<MultiLayerItem>());
50  m_layerView->setSelectionModel(m_selectionModel);
51 }
52 
54 {
55  return m_selectionModel;
56 }
57 
58 } // namespace gui2
Defines class CLASS?
T * topItem() const
Returns top item of the given type.
Definition: sessionmodel.h:126
Model delegate to provide editing/painting for custom variants.
Main class to holds all models of GUI session.
void setModels(ApplicationModels *models)
LayerTreeView * m_layerView
std::unique_ptr< LayerViewModel > m_viewModel
std::unique_ptr< ModelView::ViewModelDelegate > m_delegate
LayerEditorWidget(QWidget *parent=nullptr)
LayerSelectionModel * m_selectionModel
LayerSelectionModel * selectionModel() const
Custom selection model for layer view model (AbstractViewModel).
Extension of QTreeView for layer editing.
Definition: layertreeview.h:25
void setModel(QAbstractItemModel *model) override
Multi layer capable of holding layers and other multi-layers.
Definition: sampleitems.h:51
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?