27 std::unique_ptr<ItemCatalogue> CreateItemCatalogue()
29 auto result = std::make_unique<ModelView::ItemCatalogue>();
35 const double rho_si = 2.0704e-06;
36 const double mu_si = 5.96e-07;
38 const double rho_default = 9.4245e-06;
39 const double mu_default = 0.0;
41 const std::string air_material_name =
"Air";
42 const std::string substrate_material_name =
"Si";
43 const std::string default_material_name =
"Default";
47 std::map<std::string, QColor> name_to_color_map()
49 std::map<std::string, QColor> result = {{air_material_name, QColor(179, 242, 255)},
50 {substrate_material_name, QColor(205, 102, 0)},
51 {default_material_name, QColor(Qt::green)}};
57 static auto color_map = name_to_color_map();
58 auto it = color_map.find(
name);
80 std::vector<ExternalProperty> result;
82 if (!containers.empty() && container_id.empty())
83 container_id = topItem<MaterialContainerItem>()->identifier();
85 for (
auto container : containers) {
86 if (container->identifier() != container_id)
88 for (
auto item : container->children()) {
90 result.push_back(material->external_property());
101 if (prop.identifier() ==
id)
120 material->set_properties(
"Default", QColor(Qt::green), rho_default, mu_default);
130 auto container = insertItem<MaterialContainerItem>();
131 auto material = insertItem<SLDMaterialItem>(container);
133 material = insertItem<SLDMaterialItem>(container);
135 rho_default, mu_default);
136 material = insertItem<SLDMaterialItem>(container);
137 material->set_properties(substrate_material_name,
suggestMaterialColor(substrate_material_name),
143 return topItem<MaterialContainerItem>();
MaterialModel(QObject *parent=nullptr)
Property to carry text, color and identifier.
static ExternalProperty undefined()
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.
std::vector< SessionItem * > children() const
Returns vector of children formed from all chidlren from all tags.
TagRow tagRow() const
Returns TagRow of this item under which it is accessible through its parent.
Main class to hold hierarchy of SessionItem objects.
SessionItem * copyItem(const SessionItem *item, SessionItem *parent, const TagRow &tagrow={})
Copy item and insert it in parent's tag and row. Item could belong to any model/parent.
void setItemCatalogue(std::unique_ptr< ItemCatalogue > catalogue)
Sets brand new catalog of user-defined items.
SessionItem * rootItem() const
Returns root item of the model.
Aggregate to hold (tag, row) information for SessionModel.
TagRow next() const
Constructs new tagrow representing next row in given tag.
Base class with all materials with name and color defined.
Container to hold MaterialItems.
MaterialContainerItem * materialContainer()
MaterialBaseItem * cloneMaterial(const MaterialBaseItem *item)
Clones material and adds it at the bottom of MaterialContainerItem.
void init_model()
Populates the model with some default content.
std::vector< ModelView::ExternalProperty > material_data(std::string container_id=std::string()) const
Returns vector of properties representing possible choice of materials for the given container.
ModelView::ExternalProperty material_property(const std::string &id)
Returns property from given material id.
SLDMaterialItem * addDefaultMaterial(const ModelView::TagRow &tagrow={})
Adds default material.
Represents material based on scattering length density.
QColor suggestMaterialColor(const QString &name)
MVVM_VIEW_EXPORT QColor RandomColor()
Returns random color.
materialitems.h Collection of materials to populate MaterialModel.
QString const & name(EShape k)
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.