19 #include <QApplication>
20 #include <QFontMetrics>
41 if (role != Qt::DisplayRole)
50 return "Material parameters";
52 return "Magnetization [A/m]";
65 if (role == Qt::DisplayRole) {
66 switch (index.column()) {
75 return QString(
"delta: %1, beta: %2").arg(material->
delta()).arg(material->
beta());
77 return QString(
"re: %1, im: %2").arg(material->
sldRe()).arg(material->
sldIm());
80 return QString(
"%1/%2/%3")
85 }
else if (role == Qt::DecorationRole) {
86 switch (index.column()) {
88 const int size = qApp->fontMetrics().height();
89 QPixmap pixmap(size, size);
102 emit dataChanged(index, index);
108 emit dataChanged(index, index);
114 R3 m = material->magnetization();
116 material->setMagnetization(m);
117 const auto magIndex = this->index(index.row(),
MAGNETIZATION);
118 emit dataChanged(magIndex, magIndex);
124 R3 m = material->magnetization();
126 material->setMagnetization(m);
127 const auto magIndex = this->index(index.row(),
MAGNETIZATION);
128 emit dataChanged(magIndex, magIndex);
134 R3 m = material->magnetization();
136 material->setMagnetization(m);
137 const auto magIndex = this->index(index.row(),
MAGNETIZATION);
138 emit dataChanged(magIndex, magIndex);
144 m->setRefractiveIndex(value, m->beta());
145 const auto paramIndex = this->index(index.row(),
PARAMETERS);
146 emit dataChanged(paramIndex, paramIndex);
152 m->setRefractiveIndex(m->delta(), value);
153 const auto paramIndex = this->index(index.row(),
PARAMETERS);
154 emit dataChanged(paramIndex, paramIndex);
160 m->setScatteringLengthDensity(complex_t(value, m->sldIm()));
161 auto paramIndex = this->index(index.row(),
PARAMETERS);
162 emit dataChanged(paramIndex, paramIndex);
168 m->setScatteringLengthDensity(complex_t(m->sldRe(), value));
169 auto paramIndex = this->index(index.row(),
PARAMETERS);
170 emit dataChanged(paramIndex, paramIndex);
181 for (
int row = 0; row < materials.size(); row++)
182 if (materials[row]->identifier() == identifier)
183 return index(row, 0);
184 return QModelIndex();
190 for (
int row = 0; row < materials.size(); row++)
191 if (materials[row] == m)
192 return index(row, 0);
193 return QModelIndex();
228 beginRemoveRows(QModelIndex(), index.row(), index.row());
Defines class DoubleDescriptor.
Defines class MaterialEditorModel.
Defines class MaterialItem.
Defines class MaterialItems.
MaterialItem * materialFromIndex(const QModelIndex &index) const
void setDelta(const QModelIndex &index, double value)
QModelIndex indexFromMaterial(const MaterialItem *m) const
MaterialItem * addRefractiveMaterial(const QString &name, double delta, double beta)
void setY(const QModelIndex &index, double value)
void setColor(const QModelIndex &index, const QColor &color)
void setRe(const QModelIndex &index, double value)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void setIm(const QModelIndex &index, double value)
MaterialItem * addSLDMaterial(const QString &name, double sld, double abs_term)
void setZ(const QModelIndex &index, double value)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setX(const QModelIndex &index, double value)
MaterialItem * cloneMaterial(const QModelIndex &index)
MaterialEditorModel(MaterialItems *p)
void removeMaterial(const QModelIndex &index)
void setMaterialItemName(const QModelIndex &index, const QString &name)
QModelIndex first() const
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setBeta(const QModelIndex &index, double value)
bool hasRefractiveIndex() const
QString matItemName() const
void setMatItemName(const QString &name)
void setColor(const QColor &color)
MaterialItem * addRefractiveMaterial(const QString &name, double delta, double beta)
MaterialItem * addSLDMaterial(const QString &name, double sld, double abs_term)
void removeMaterial(const QString &identifier)
MaterialItem * insertCopy(const MaterialItem &material)
Inserts a copy of the given material and returns the newly inserted item.
const QVector< MaterialItem * > & materialItems() const
QString const & name(EShape k)