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() ...@@ -37,7 +37,7 @@ MaterialItem::MaterialItem()
ColorProperty color; ColorProperty color;
addProperty(P_COLOR, color.getVariant()); addProperty(P_COLOR, color.getVariant());
addGroupProperty(P_REFRACTIVE_INDEX, Constants::RefractiveIndexType); addGroupPropertyTmp(P_REFRACTIVE_INDEX, Constants::RefractiveIndexType);
addProperty(P_IDENTIFIER, QUuid::createUuid().toString()); addProperty(P_IDENTIFIER, QUuid::createUuid().toString());
getItem(P_IDENTIFIER)->setVisible(false); getItem(P_IDENTIFIER)->setVisible(false);
} }
...@@ -49,15 +49,17 @@ QString MaterialItem::getIdentifier() const ...@@ -49,15 +49,17 @@ QString MaterialItem::getIdentifier() const
QColor MaterialItem::getColor() const QColor MaterialItem::getColor() const
{ {
ColorProperty color_property = getItemValue(P_COLOR).value<ColorProperty>(); ColorProperty property = getItemValue(P_COLOR).value<ColorProperty>();
return color_property.getColor(); return property.getColor();
} }
std::unique_ptr<IMaterial> MaterialItem::createMaterial() const std::unique_ptr<IMaterial> MaterialItem::createMaterial() const
{ {
const RefractiveIndexItem *refractiveIndexItem const RefractiveIndexItem *refractiveIndexItem
= dynamic_cast<const RefractiveIndexItem *>( = dynamic_cast<const RefractiveIndexItem *>(
getGroupItem(MaterialItem::P_REFRACTIVE_INDEX)); getItem(MaterialItem::P_REFRACTIVE_INDEX));
Q_ASSERT(refractiveIndexItem);
double delta = refractiveIndexItem->getDelta(); double delta = refractiveIndexItem->getDelta();
double beta = refractiveIndexItem->getBeta(); double beta = refractiveIndexItem->getBeta();
......
...@@ -42,7 +42,7 @@ MaterialItem *MaterialModel::addMaterial(const QString &name, double delta, doub ...@@ -42,7 +42,7 @@ MaterialItem *MaterialModel::addMaterial(const QString &name, double delta, doub
materialItem->setItemName(name); materialItem->setItemName(name);
RefractiveIndexItem *refractiveIndexItem = RefractiveIndexItem *refractiveIndexItem =
dynamic_cast<RefractiveIndexItem *>(materialItem->getGroupItem(MaterialItem::P_REFRACTIVE_INDEX)); dynamic_cast<RefractiveIndexItem *>(materialItem->getItem(MaterialItem::P_REFRACTIVE_INDEX));
Q_ASSERT(refractiveIndexItem); Q_ASSERT(refractiveIndexItem);
refractiveIndexItem->setDelta(delta); refractiveIndexItem->setDelta(delta);
......
...@@ -30,6 +30,15 @@ RefractiveIndexItem::RefractiveIndexItem() ...@@ -30,6 +30,15 @@ RefractiveIndexItem::RefractiveIndexItem()
ScientificDoubleProperty beta(0.0); ScientificDoubleProperty beta(0.0);
addProperty(P_BETA, beta.getVariant()); addProperty(P_BETA, beta.getVariant());
mapper()->setOnPropertyChange(
[this](const QString &){
setValue(itemLabel());
}
);
setValue(itemLabel());
setEditable(false);
} }
QString RefractiveIndexItem::itemLabel() const QString RefractiveIndexItem::itemLabel() const
...@@ -44,9 +53,9 @@ double RefractiveIndexItem::getDelta() const ...@@ -44,9 +53,9 @@ double RefractiveIndexItem::getDelta() const
void RefractiveIndexItem::setDelta(double delta) void RefractiveIndexItem::setDelta(double delta)
{ {
ScientificDoubleProperty scd_property = getItemValue(P_DELTA).value<ScientificDoubleProperty>(); ScientificDoubleProperty property = getItemValue(P_DELTA).value<ScientificDoubleProperty>();
scd_property.setValue(delta); property.setValue(delta);
setItemValue(P_DELTA, scd_property.getVariant()); setItemValue(P_DELTA, property.getVariant());
} }
double RefractiveIndexItem::getBeta() const double RefractiveIndexItem::getBeta() const
...@@ -56,7 +65,7 @@ double RefractiveIndexItem::getBeta() const ...@@ -56,7 +65,7 @@ double RefractiveIndexItem::getBeta() const
void RefractiveIndexItem::setBeta(double beta) void RefractiveIndexItem::setBeta(double beta)
{ {
ScientificDoubleProperty scd_property = getItemValue(P_BETA).value<ScientificDoubleProperty>(); ScientificDoubleProperty property = getItemValue(P_BETA).value<ScientificDoubleProperty>();
scd_property.setValue(beta); property.setValue(beta);
setItemValue(P_BETA, scd_property.getVariant()); setItemValue(P_BETA, property.getVariant());
} }
...@@ -171,20 +171,28 @@ ComponentEditor::componentItems(SessionItem *item) const ...@@ -171,20 +171,28 @@ ComponentEditor::componentItems(SessionItem *item) const
foreach (SessionItem *child, item->childItems()) { foreach (SessionItem *child, item->childItems()) {
if (!child->isVisible()) if (!child->isVisible())
continue; continue;
if (child->modelType() == Constants::PropertyType) { if (child->modelType() == Constants::PropertyType) {
result.append(child); 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); result.append(child);
} }
else if (child->modelType() == Constants::RefractiveIndexType) {
result.append(child);
}
if (item->modelType() == Constants::GroupItemType) { if (item->modelType() == Constants::GroupItemType) {
foreach (SessionItem *childOfChild, child->childItems()) { foreach (SessionItem *childOfChild, child->childItems()) {
result.append(childOfChild); 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