BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
experimentaldatacontroller.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/model/experimentaldatacontroller.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"
22 #include "mvvm/model/modelutils.h"
23 
24 namespace gui2 {
25 
27  InstrumentModel* instrument_model)
28  : ModelListener(data_model), m_instrument_model(instrument_model)
29 {
30  setOnDataChange([this](auto, auto) { update_all(); });
31  setOnItemInserted([this](auto, auto) { update_all(); });
32  setOnItemRemoved([this](auto, auto) { update_all(); });
33  setOnModelReset([this](auto) { update_all(); });
34 
35  update_all();
36 }
37 
38 //! Updates all material properties in LayerItems to get new material colors and labels.
39 
41 {
42  for (auto scan : ModelView::Utils::FindItems<ExperimentalScanItem>(m_instrument_model)) {
43  auto property =
45  auto updated =
46  Utils::FindProperty(Utils::CreateGraphProperties(model()), property.identifier());
47  if (property != updated)
48  scan->setProperty(ExperimentalScanItem::P_IMPORTED_DATA, updated);
49  }
50 }
51 
52 } // namespace gui2
Property to carry text, color and identifier.
void setOnItemRemoved(Callbacks::item_tagrow_t f, Callbacks::slot_t client={}) override
Sets callback to be notified on item remove.
void setOnItemInserted(Callbacks::item_tagrow_t f, Callbacks::slot_t client={}) override
Sets callback to be notified on item insert.
void setOnDataChange(Callbacks::item_int_t f, Callbacks::slot_t client={}) override
Sets callback to be notified on item's data change.
void setOnModelReset(Callbacks::model_t f, Callbacks::slot_t client={}) override
Sets the callback to be notified after model was fully reset (root item recreated).
Templated class for all objects willing to listen for changes in concrete SessionModel.
Definition: modellistener.h:26
void update_all()
Updates all material properties in LayerItems to get new material colors and labels.
ExperimentalDataController(ExperimentalDataModel *data_model, InstrumentModel *instrument_model)
The model to store imported reflectometry data.
static const std::string P_IMPORTED_DATA
Model to store specular instruments settings.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
DAREFLCORE_EXPORT ModelView::ExternalProperty FindProperty(const std::vector< ModelView::ExternalProperty > &properties, const std::string &id)
Finds the property with the same id in given vector and returns it.
Definition: modelutils.cpp:56
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