BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
jobmodel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/model/jobmodel.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/jobmodel.h"
17 #include "gui2/model/jobitem.h"
20 #include "mvvm/model/modelutils.h"
25 
26 using namespace ModelView;
27 
28 namespace gui2 {
29 
30 namespace {
31 
32 std::unique_ptr<ItemCatalogue> CreateItemCatalogue()
33 {
34  auto result = std::make_unique<ModelView::ItemCatalogue>();
35  result->registerItem<JobItem>();
36  result->registerItem<CanvasItem>();
37  result->registerItem<SLDCanvasItem>();
38  return result;
39 }
40 
41 } // namespace
42 
43 JobModel::JobModel(std::shared_ptr<ItemPool> pool) : SessionModel("JobModel", pool)
44 {
45  setItemCatalogue(CreateItemCatalogue());
46  insertItem<JobItem>();
47 }
48 
49 GraphViewportItem* JobModel::sldViewport() const
50 {
51  return jobItem()->sldViewport();
52 }
53 
54 CanvasItem* JobModel::specularViewport() const
55 {
56  return jobItem()->specularViewport();
57 }
58 
59 GraphViewportItem* JobModel::diffViewport() const
60 {
61  return jobItem()->diffViewport();
62 }
63 
64 void JobModel::updateReferenceGraph(const ModelView::GraphItem* graph)
65 {
66  jobItem()->updateReferenceGraph(graph);
67 }
68 
69 //! Updates specular data in JobItem from simulation results.
70 
71 void JobModel::updateSpecularData(const SimulationResult& data)
72 {
73  auto specularData = jobItem()->specularData();
74  specularData->item<PointwiseAxisItem>(Data1DItem::T_AXIS)->setParameters(data.qvalues);
75  specularData->setValues(data.amplitudes);
76 
77  // updating difference graph
78  jobItem()->updateDifferenceData();
79 }
80 
81 //! Updates SLD profile data.
82 
83 void JobModel::updateSLDProfile(const SLDProfile& data)
84 {
85  auto sldData = jobItem()->sldData();
86  // sldData->setAxis<FixedBinAxisItem>(data.sld_real_values.size(), data.zmin, data.zmax);
87  sldData->item<FixedBinAxisItem>(Data1DItem::T_AXIS)
88  ->setParameters(data.sld_real_values.size(), data.zmin, data.zmax);
89  sldData->setValues(data.sld_real_values);
90 }
91 
92 JobItem* JobModel::jobItem() const
93 {
94  return Utils::TopItem<JobItem>(this);
95 }
96 
97 } // namespace gui2
Defines class CLASS?
JobModel(QObject *parent=0)
Definition: JobModel.cpp:32
Item to represent fixed bin axis.
Definition: axisitems.h:75
One-dimensional graph representation of Data1DItem.
Definition: graphitem.h:29
2D viewport specialized for showing multiple GraphItem's.
Item to represent pointwise axis.
Definition: axisitems.h:94
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
Definition: sessionitem.h:156
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
virtual QVariant data(const QModelIndex &index, int role) const
Holds a collection of GraphItem's for simultaneous plotting, as well as all information related to pl...
Represents state of QuickSimEditor.
Definition: jobitem.h:46
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
Defines class CLASS?
Represents results of SLD profile calculations.
Represents results of the simulation.