BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
vectoritem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/standarditems/vectoritem.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 Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
18 #include <sstream>
19 
20 using namespace ModelView;
21 
23 {
24  addProperty(P_X, 0.0)->setDisplayName("X");
25  addProperty(P_Y, 0.0)->setDisplayName("Y");
26  addProperty(P_Z, 0.0)->setDisplayName("Z");
27 
28  setEditable(false);
29 
30  update_label();
31 }
32 
34 {
35  auto on_property_change = [this](SessionItem*, const std::string&) { update_label(); };
36  mapper()->setOnPropertyChange(on_property_change, this);
37 }
38 
40 {
41  std::ostringstream ostr;
42  ostr << "(" << property<double>(P_X) << ", " << property<double>(P_Y) << ", "
43  << property<double>(P_Z) << ")";
44  setData(Variant::fromValue(ostr.str()), ItemDataRole::DATA, /*direct*/ true);
45 }
Complex item holding mixed SessionItem types (single properties and other CompountItems).
Definition: compounditem.h:28
T * addProperty(const std::string &name)
Adds property item of given type.
Definition: compounditem.h:43
void setOnPropertyChange(Callbacks::item_str_t f, Callbacks::slot_t owner) override
Sets callback to be notified on item's property change.
Definition: itemmapper.cpp:189
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
SessionItem * setEditable(bool value)
Sets editable flag to given value (fluent interface).
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
Definition: sessionitem.h:141
ItemMapper * mapper()
Returns item mapper. Allows subscribing to various events happening to the item.
void activate() override
Definition: vectoritem.cpp:33
static const std::string P_X
Definition: vectoritem.h:26
static const std::string P_Z
Definition: vectoritem.h:28
static const std::string P_Y
Definition: vectoritem.h:27
Defines class CLASS?
Defines class CLASS?
const model_type VectorItemType
Definition: mvvm_types.h:61
const int DATA
main data role
Definition: mvvm_types.h:30
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?