Skip to content
Snippets Groups Projects
Commit 14d9f254 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

MaterialItem is refactored to gret rid from FixedGroupProperty

parent 8bac253e
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ MaterialItem::MaterialItem()
ColorProperty color;
addProperty(P_COLOR, color.getVariant());
addGroupProperty(P_REFRACTIVE_INDEX, Constants::RefractiveIndexType);
addGroupPropertyTmp(P_REFRACTIVE_INDEX, Constants::RefractiveIndexType);
addProperty(P_IDENTIFIER, QUuid::createUuid().toString());
getItem(P_IDENTIFIER)->setVisible(false);
}
......@@ -49,15 +49,17 @@ QString MaterialItem::getIdentifier() const
QColor MaterialItem::getColor() const
{
ColorProperty color_property = getItemValue(P_COLOR).value<ColorProperty>();
return color_property.getColor();
ColorProperty property = getItemValue(P_COLOR).value<ColorProperty>();
return property.getColor();
}
std::unique_ptr<IMaterial> MaterialItem::createMaterial() const
{
const RefractiveIndexItem *refractiveIndexItem
= dynamic_cast<const RefractiveIndexItem *>(
getGroupItem(MaterialItem::P_REFRACTIVE_INDEX));
getItem(MaterialItem::P_REFRACTIVE_INDEX));
Q_ASSERT(refractiveIndexItem);
double delta = refractiveIndexItem->getDelta();
double beta = refractiveIndexItem->getBeta();
......
......@@ -42,7 +42,7 @@ MaterialItem *MaterialModel::addMaterial(const QString &name, double delta, doub
materialItem->setItemName(name);
RefractiveIndexItem *refractiveIndexItem =
dynamic_cast<RefractiveIndexItem *>(materialItem->getGroupItem(MaterialItem::P_REFRACTIVE_INDEX));
dynamic_cast<RefractiveIndexItem *>(materialItem->getItem(MaterialItem::P_REFRACTIVE_INDEX));
Q_ASSERT(refractiveIndexItem);
refractiveIndexItem->setDelta(delta);
......
......@@ -30,6 +30,15 @@ RefractiveIndexItem::RefractiveIndexItem()
ScientificDoubleProperty beta(0.0);
addProperty(P_BETA, beta.getVariant());
mapper()->setOnPropertyChange(
[this](const QString &){
setValue(itemLabel());
}
);
setValue(itemLabel());
setEditable(false);
}
QString RefractiveIndexItem::itemLabel() const
......@@ -44,9 +53,9 @@ double RefractiveIndexItem::getDelta() const
void RefractiveIndexItem::setDelta(double delta)
{
ScientificDoubleProperty scd_property = getItemValue(P_DELTA).value<ScientificDoubleProperty>();
scd_property.setValue(delta);
setItemValue(P_DELTA, scd_property.getVariant());
ScientificDoubleProperty property = getItemValue(P_DELTA).value<ScientificDoubleProperty>();
property.setValue(delta);
setItemValue(P_DELTA, property.getVariant());
}
double RefractiveIndexItem::getBeta() const
......@@ -56,7 +65,7 @@ double RefractiveIndexItem::getBeta() const
void RefractiveIndexItem::setBeta(double beta)
{
ScientificDoubleProperty scd_property = getItemValue(P_BETA).value<ScientificDoubleProperty>();
scd_property.setValue(beta);
setItemValue(P_BETA, scd_property.getVariant());
ScientificDoubleProperty property = getItemValue(P_BETA).value<ScientificDoubleProperty>();
property.setValue(beta);
setItemValue(P_BETA, property.getVariant());
}
......@@ -171,20 +171,28 @@ ComponentEditor::componentItems(SessionItem *item) const
foreach (SessionItem *child, item->childItems()) {
if (!child->isVisible())
continue;
if (child->modelType() == Constants::PropertyType) {
result.append(child);
}
if (child->modelType() == Constants::GroupItemType) {
else if (child->modelType() == Constants::GroupItemType) {
result.append(child);
}
else if (child->modelType() == Constants::VectorType) {
result.append(child);
}
else if (child->modelType() == Constants::RefractiveIndexType) {
result.append(child);
}
if (item->modelType() == Constants::GroupItemType) {
foreach (SessionItem *childOfChild, child->childItems()) {
result.append(childOfChild);
}
}
if (child->modelType() == Constants::VectorType) {
result.append(child);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment