diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index e1b5c7b761..9bed833140 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -3303,12 +3303,16 @@ PropertyMaterialItem::PropertyMaterialItem() emissive->setPropertyName(QLatin1String("EmissiveColor")); this->appendChild(emissive); - shininess = static_cast(PropertyFloatItem::create()); + shininess = static_cast(PropertyIntegerConstraintItem::create()); + shininess->setRange(0, 100); + shininess->setStepSize(5); shininess->setParent(this); shininess->setPropertyName(QLatin1String("Shininess")); this->appendChild(shininess); - transparency = static_cast(PropertyFloatItem::create()); + transparency = static_cast(PropertyIntegerConstraintItem::create()); + transparency->setRange(0, 100); + transparency->setStepSize(5); transparency->setParent(this); transparency->setPropertyName(QLatin1String("Transparency")); this->appendChild(transparency); @@ -3404,45 +3408,45 @@ void PropertyMaterialItem::setEmissiveColor(const QColor& color) setValue(QVariant::fromValue(mat)); } -float PropertyMaterialItem::getShininess() const +int PropertyMaterialItem::getShininess() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) return 0; auto val = value.value(); - return val.shininess; + return int(100 * val.shininess); } -void PropertyMaterialItem::setShininess(float s) +void PropertyMaterialItem::setShininess(int s) { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) return; auto mat = value.value(); - mat.shininess = s; + mat.shininess = float(s) / 100.0F; setValue(QVariant::fromValue(mat)); } -float PropertyMaterialItem::getTransparency() const +int PropertyMaterialItem::getTransparency() const { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) return 0; auto val = value.value(); - return val.transparency; + return int (100 * val.transparency); } -void PropertyMaterialItem::setTransparency(float t) +void PropertyMaterialItem::setTransparency(int t) { QVariant value = data(1, Qt::EditRole); if (!value.canConvert()) return; auto mat = value.value(); - mat.transparency = t; + mat.transparency = float(t) / 100.0F; setValue(QVariant::fromValue(mat)); } @@ -3491,8 +3495,8 @@ QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const .arg(ac.red()).arg(ac.green()).arg(ac.blue()) .arg(sc.red()).arg(sc.green()).arg(sc.blue()) .arg(ec.red()).arg(ec.green()).arg(ec.blue()) - .arg(value.shininess) - .arg(value.transparency) + .arg(int(100 * value.shininess)) + .arg(int(100 * value.transparency)) ; return {data}; diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index 29df6e606e..1b4ce6e571 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -1026,10 +1026,10 @@ class GuiExport PropertyMaterialItem : public PropertyItem void setSpecularColor(const QColor&); QColor getEmissiveColor() const; void setEmissiveColor(const QColor&); - float getShininess() const; - void setShininess(float); - float getTransparency() const; - void setTransparency(float); + int getShininess() const; + void setShininess(int); + int getTransparency() const; + void setTransparency(int); protected: PropertyMaterialItem(); @@ -1046,8 +1046,8 @@ private: PropertyColorItem* diffuse; PropertyColorItem* specular; PropertyColorItem* emissive; - PropertyFloatItem* shininess; - PropertyFloatItem* transparency; + PropertyIntegerConstraintItem* shininess; + PropertyIntegerConstraintItem* transparency; }; class GuiExport PropertyMaterialListItem : public PropertyItem