BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
custombeampropertyeditorfactory.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/quicksimeditor/custombeampropertyeditorfactory.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 
20 #include "gui2/model/modelutils.h"
23 #include "mvvm/model/modelutils.h"
25 #include <QModelIndex>
26 #include <algorithm>
27 
28 using namespace ModelView;
29 
30 namespace gui2 {
31 
32 namespace {
33 
34 //! Returns vector of ExternalProperty representing imported graphs.
35 //! Use "Undefined graph" as a first item in a list.
36 
37 std::vector<ModelView::ExternalProperty> available_graph_properties(ExperimentalDataModel* model)
38 {
39  std::vector<ModelView::ExternalProperty> result{ExternalProperty::undefined()};
40  auto properties = Utils::CreateGraphProperties(model);
41  std::copy(properties.begin(), properties.end(), std::back_inserter(result));
42  return result;
43 }
44 } // namespace
45 
46 CustomBeamPropertyEditorFactory::~CustomBeamPropertyEditorFactory() = default;
47 
48 CustomBeamPropertyEditorFactory::CustomBeamPropertyEditorFactory(ApplicationModels* models)
49  : m_models(models)
50 {
51 }
52 
53 std::unique_ptr<CustomEditor>
54 CustomBeamPropertyEditorFactory::createEditor(const QModelIndex& index) const
55 {
56  auto value = index.data(Qt::EditRole);
58  auto choice_callback = [this]() {
59  return available_graph_properties(m_models->experimentalDataModel());
60  };
61  return std::make_unique<ExternalPropertyComboEditor>(choice_callback);
62  } else {
64  }
65 }
66 
67 } // namespace gui2
Defines class CLASS?
std::unique_ptr< CustomEditor > createEditor(const QModelIndex &index) const override
Creates editor for given model index basing either on editorType() or specific variant name.
static ExternalProperty undefined()
Main class to holds all models of GUI session.
ExperimentalDataModel * experimentalDataModel()
std::unique_ptr< ModelView::CustomEditor > createEditor(const QModelIndex &index) const
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
MVVM_MODEL_EXPORT bool IsExtPropertyVariant(const Variant &variant)
Returns true in the case of ExternalProperty based variant.
materialitems.h Collection of materials to populate MaterialModel.
DAREFLCORE_EXPORT std::vector< ModelView::ExternalProperty > CreateGraphProperties(ExperimentalDataModel *model)
Returns vector of properties representing GraphItem content of the model.
Definition: modelutils.cpp:46
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20