+ fixes #0000976: Usability: default Material drop-down is not the active material type
This commit is contained in:
parent
93e5668967
commit
6a9252744d
|
@ -246,10 +246,11 @@ void DlgDisplayPropertiesImp::on_buttonColorPlot_clicked()
|
|||
/**
|
||||
* Sets the 'ShapeMaterial' property of all selected view providers.
|
||||
*/
|
||||
void DlgDisplayPropertiesImp::on_changeMaterial_activated(const QString& material)
|
||||
void DlgDisplayPropertiesImp::on_changeMaterial_activated(int index)
|
||||
{
|
||||
std::vector<Gui::ViewProvider*> Provider = getSelection();
|
||||
App::Material mat(Materials[material]);
|
||||
App::Material::MaterialType matType = static_cast<App::Material::MaterialType>(changeMaterial->itemData(index).toInt());
|
||||
App::Material mat(matType);
|
||||
App::Color diffuseColor = mat.diffuseColor;
|
||||
buttonColor->setColor(QColor((int)(diffuseColor.r*255.0f), (int)(diffuseColor.g*255.0f), (int)(diffuseColor.b*255.0f)));
|
||||
|
||||
|
@ -418,14 +419,20 @@ void DlgDisplayPropertiesImp::setDisplayModes(const std::vector<Gui::ViewProvide
|
|||
void DlgDisplayPropertiesImp::setMaterial(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool material = false;
|
||||
App::Material::MaterialType matType = App::Material::DEFAULT;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("ShapeMaterial");
|
||||
if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
|
||||
material = true;
|
||||
matType = static_cast<App::PropertyMaterial*>(prop)->getValue().getType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int index = changeMaterial->findData(matType);
|
||||
if (index >= 0) {
|
||||
changeMaterial->setCurrentIndex(index);
|
||||
}
|
||||
changeMaterial->setEnabled(material);
|
||||
buttonUserDefinedMaterial->setEnabled(material);
|
||||
}
|
||||
|
@ -446,33 +453,28 @@ void DlgDisplayPropertiesImp::setColorPlot(const std::vector<Gui::ViewProvider*>
|
|||
|
||||
void DlgDisplayPropertiesImp::fillupMaterials()
|
||||
{
|
||||
Materials[QLatin1String("Brass")] = App::Material::BRASS;
|
||||
Materials[QLatin1String("Bronze")] = App::Material::BRONZE;
|
||||
Materials[QLatin1String("Copper")] = App::Material::COPPER;
|
||||
Materials[QLatin1String("Gold")] = App::Material::GOLD;
|
||||
Materials[QLatin1String("Pewter")] = App::Material::PEWTER;
|
||||
Materials[QLatin1String("Plaster")] = App::Material::PLASTER;
|
||||
Materials[QLatin1String("Plastic")] = App::Material::PLASTIC;
|
||||
Materials[QLatin1String("Silver")] = App::Material::SILVER;
|
||||
Materials[QLatin1String("Steel")] = App::Material::STEEL;
|
||||
Materials[QLatin1String("Stone")] = App::Material::STONE;
|
||||
Materials[QLatin1String("Shiny plastic")] = App::Material::SHINY_PLASTIC;
|
||||
Materials[QLatin1String("Satin")] = App::Material::SATIN;
|
||||
Materials[QLatin1String("Metalized")] = App::Material::METALIZED;
|
||||
Materials[QLatin1String("Neon GNC")] = App::Material::NEON_GNC;
|
||||
Materials[QLatin1String("Chrome")] = App::Material::CHROME;
|
||||
Materials[QLatin1String("Aluminium")] = App::Material::ALUMINIUM;
|
||||
Materials[QLatin1String("Obsidian")] = App::Material::OBSIDIAN;
|
||||
Materials[QLatin1String("Neon PHC")] = App::Material::NEON_PHC;
|
||||
Materials[QLatin1String("Jade")] = App::Material::JADE;
|
||||
Materials[QLatin1String("Ruby")] = App::Material::RUBY;
|
||||
Materials[QLatin1String("Emerald")] = App::Material::EMERALD;
|
||||
|
||||
QStringList material = Materials.keys();
|
||||
material.sort();
|
||||
changeMaterial->addItem(QLatin1String("Default"));
|
||||
changeMaterial->addItems(material);
|
||||
Materials[QLatin1String("Default")] = App::Material::DEFAULT;
|
||||
changeMaterial->addItem(tr("Default"), App::Material::DEFAULT);
|
||||
changeMaterial->addItem(tr("Aluminium"), App::Material::ALUMINIUM);
|
||||
changeMaterial->addItem(tr("Brass"), App::Material::BRASS);
|
||||
changeMaterial->addItem(tr("Bronze"), App::Material::BRONZE);
|
||||
changeMaterial->addItem(tr("Copper"), App::Material::COPPER);
|
||||
changeMaterial->addItem(tr("Chrome"), App::Material::CHROME);
|
||||
changeMaterial->addItem(tr("Emerald"), App::Material::EMERALD);
|
||||
changeMaterial->addItem(tr("Gold"), App::Material::GOLD);
|
||||
changeMaterial->addItem(tr("Jade"), App::Material::JADE);
|
||||
changeMaterial->addItem(tr("Metalized"), App::Material::METALIZED);
|
||||
changeMaterial->addItem(tr("Neon GNC"), App::Material::NEON_GNC);
|
||||
changeMaterial->addItem(tr("Neon PHC"), App::Material::NEON_PHC);
|
||||
changeMaterial->addItem(tr("Obsidian"), App::Material::OBSIDIAN);
|
||||
changeMaterial->addItem(tr("Pewter"), App::Material::PEWTER);
|
||||
changeMaterial->addItem(tr("Plaster"), App::Material::PLASTER);
|
||||
changeMaterial->addItem(tr("Plastic"), App::Material::PLASTIC);
|
||||
changeMaterial->addItem(tr("Ruby"), App::Material::RUBY);
|
||||
changeMaterial->addItem(tr("Satin"), App::Material::SATIN);
|
||||
changeMaterial->addItem(tr("Shiny plastic"), App::Material::SHINY_PLASTIC);
|
||||
changeMaterial->addItem(tr("Silver"), App::Material::SILVER);
|
||||
changeMaterial->addItem(tr("Steel"), App::Material::STEEL);
|
||||
changeMaterial->addItem(tr("Stone"), App::Material::STONE);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*>& views)
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
Gui::SelectionSingleton::MessageType Reason);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_changeMaterial_activated(const QString&);
|
||||
void on_changeMaterial_activated(int);
|
||||
void on_changeMode_activated(const QString&);
|
||||
void on_changePlot_activated(const QString&);
|
||||
void on_buttonColor_changed();
|
||||
|
@ -91,7 +91,6 @@ private:
|
|||
void setTransparency(const std::vector<ViewProvider*>&);
|
||||
void setLineTransparency(const std::vector<ViewProvider*>&);
|
||||
std::vector<ViewProvider*> getSelection() const;
|
||||
QMap<QString, App::Material::MaterialType> Materials;
|
||||
|
||||
DlgDisplayPropertiesImp_Connection connectChangedObject;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user