Skip to content

Commit

Permalink
+ fixes #976: Usability: default Material drop-down is not the active…
Browse files Browse the repository at this point in the history
… material type
  • Loading branch information
wwmayer committed Dec 26, 2014
1 parent 93e5668 commit 6a92527
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
60 changes: 31 additions & 29 deletions src/Gui/DlgDisplayPropertiesImp.cpp
Expand Up @@ -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)));

Expand Down Expand Up @@ -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);
}
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/Gui/DlgDisplayPropertiesImp.h
Expand Up @@ -62,7 +62,7 @@ class DlgDisplayPropertiesImp : public QDialog, public Ui_DlgDisplayProperties,
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();
Expand Down Expand Up @@ -91,7 +91,6 @@ private Q_SLOTS:
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;
};
Expand Down

0 comments on commit 6a92527

Please sign in to comment.