33 #include <QColorDialog>
37 std::map<QString, QString> get_tag_map()
39 std::map<QString, QString> result = {
50 if (
name.contains(
"Vacuum")) {
51 return QColor(179, 242, 255);
52 }
else if (
name.contains(
"Substrate")) {
53 return QColor(205, 102, 0);
54 }
else if (
name.contains(
"Default")) {
55 return QColor(Qt::green);
56 }
else if (
name.contains(
"Particle")) {
57 return QColor(146, 198, 255);
73 std::unique_ptr<Material>
80 std::unique_ptr<Material>
86 throw GUIHelpers::Error(
"MaterialUtils::createDomainMaterial() -> Error. Can't find "
87 "material with name '"
88 + material_property.
text() +
"'.");
96 "Attempt to access non-existing material model");
102 "material with name '"
103 + material_property.
text() +
"'.");
114 }
else if (item.
modelType() ==
"Layer") {
124 return {
"Particle",
"Layer"};
146 result.
setText(QString(
"[%1, %2, %3] (%4)")
150 .arg(color.alpha()));
158 if (dialog.exec() == QDialog::Accepted) {
169 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
170 auto oldColor = previous.
color();
171 auto newColor = QColorDialog::getColor(oldColor);
172 if (oldColor != newColor)
176 QRgb oldRgba = previous.
color().rgba();
177 QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok,
nullptr);
178 if (ok && newRgba != oldRgba)
187 static const std::map<QString, QString> tag_map = get_tag_map();
188 QVector<SessionItem*> materials;
189 QList<SessionItem*> particle_holders{item};
190 while (!particle_holders.isEmpty()) {
191 auto item = particle_holders.takeFirst();
197 if (iter != tag_map.end()) {
198 particle_holders.append(QList<SessionItem*>::fromVector(item->
getItems(iter->second)));
208 "Error in MaterialItemUtils::materialProperties: cannot handle passed model type '"
Defines class ComboProperty.
Defines class DesignerHelper.
Defines class GUIHelpers functions.
Defines class MainWindow.
Defines MaterialDataItems classes.
Defines class MaterialEditorDialog.
Defines class MaterialItemContainer.
Defines class MaterialItemUtils.
Defines class MaterialModel.
Defines and implements class Material.
Defines class MesoCrystalItem.
Defines class ParticleCompositionItem.
Defines class ParticleCoreShellItem.
Defines class ParticleDistributionItem.
Defines class ParticleItem.
Defines class ParticleLayoutItem.
static MaterialModel * materialModel()
static QColor getRandomColor()
The ExternalProperty class defines custom QVariant property to carry the text, color and an identifie...
QString identifier() const
void setColor(const QColor &color)
void setText(const QString &name)
void setIdentifier(const QString &identifier)
static const QString P_MATERIAL
static MainWindow * instance()
Returns the one and only instance of this class.
Dialog to hold MaterialEditor.
void setMaterialProperty(const ExternalProperty &matProperty)
ExternalProperty selectedMaterialProperty()
const MaterialItem * findMaterialById(QString id) const
static const QString P_IDENTIFIER
static const QString P_COLOR
std::unique_ptr< Material > createMaterial() const
MaterialItem * materialFromIdentifier(const QString &identifier)
static const QString T_BASIS_PARTICLE
static const QString T_PARTICLES
static const QString T_PARTICLES
static const QString P_MATERIAL
static const QString T_PARTICLES
QString itemName() const
Get item name, return display name if no name is set.
QVector< SessionItem * > getItems(const QString &tag="") const
Returns vector of all items of given tag.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
QString modelType() const
Get model type.
QVector< T * > topItems() const
ExternalProperty selectMaterialProperty(const ExternalProperty &previous=ExternalProperty())
Calls material selector dialog.
QString materialTag(const SessionItem &item)
Returns material tag for given item. Returns empty string, if item doesn't have materials.
MaterialItem * findMaterial(const ExternalProperty &material_property)
QColor suggestMaterialColor(const QString &name)
std::unique_ptr< Material > createDomainMaterial(const ExternalProperty &material_property)
QVector< SessionItem * > materialPropertyItems(SessionItem *item)
Gather material property items from a given item.
QStringList materialRelatedModelTypes()
Returns list of model types which contains registered MaterialProperty.
ExternalProperty colorProperty(const QColor &color)
Constructs color property from given color.
ExternalProperty materialProperty(const SessionItem &materialItem)
Constructs material property corresponding to given material.
ExternalProperty defaultMaterialProperty()
ExternalProperty selectColorProperty(const ExternalProperty &previous=ExternalProperty())
Calls color selector dialog.
QString const & name(EShape k)