Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Sep 1, 2022
1 parent 3394a23 commit d598c62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 74 deletions.
1 change: 0 additions & 1 deletion src/ServerConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class ignition::gazebo::ServerConfig::PluginInfoPrivate

/// \brief XML elements associated with this plugin
public: sdf::ElementPtr sdf = nullptr;

};

//////////////////////////////////////////////////
Expand Down
94 changes: 21 additions & 73 deletions src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <list>
#include <regex>
#include <unordered_map>
#include <QColorDialog>
#include <ignition/common/Console.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/gui/Application.hh>
Expand Down Expand Up @@ -346,22 +345,22 @@ void ignition::gazebo::setData(QStandardItem *_item,
_item->setData(QString("Material"),
ComponentsModel::RoleNames().key("dataType"));
_item->setData(QList({
QVariant(_data.Ambient().R() * 255),
QVariant(_data.Ambient().G() * 255),
QVariant(_data.Ambient().B() * 255),
QVariant(_data.Ambient().A() * 255),
QVariant(_data.Diffuse().R() * 255),
QVariant(_data.Diffuse().G() * 255),
QVariant(_data.Diffuse().B() * 255),
QVariant(_data.Diffuse().A() * 255),
QVariant(_data.Specular().R() * 255),
QVariant(_data.Specular().G() * 255),
QVariant(_data.Specular().B() * 255),
QVariant(_data.Specular().A() * 255),
QVariant(_data.Emissive().R() * 255),
QVariant(_data.Emissive().G() * 255),
QVariant(_data.Emissive().B() * 255),
QVariant(_data.Emissive().A() * 255)
QVariant(_data.Ambient().R()),
QVariant(_data.Ambient().G()),
QVariant(_data.Ambient().B()),
QVariant(_data.Ambient().A()),
QVariant(_data.Diffuse().R()),
QVariant(_data.Diffuse().G()),
QVariant(_data.Diffuse().B()),
QVariant(_data.Diffuse().A()),
QVariant(_data.Specular().R()),
QVariant(_data.Specular().G()),
QVariant(_data.Specular().B()),
QVariant(_data.Specular().A()),
QVariant(_data.Emissive().R()),
QVariant(_data.Emissive().G()),
QVariant(_data.Emissive().B()),
QVariant(_data.Emissive().A())
}), ComponentsModel::RoleNames().key("data"));

// TODO(anyone) Only shows colors of material,
Expand Down Expand Up @@ -1155,55 +1154,8 @@ void ComponentInspector::OnMaterialColor(
double _rDiffuse, double _gDiffuse, double _bDiffuse, double _aDiffuse,
double _rSpecular, double _gSpecular, double _bSpecular, double _aSpecular,
double _rEmissive, double _gEmissive, double _bEmissive, double _aEmissive,
QString _type, QColor _currColor)
QString /*_type*/, QColor /*_currColor*/)
{
// when type is not empty, open qt color dialog
std::string type = _type.toStdString();
if (!type.empty())
{
QColor newColor = QColorDialog::getColor(
_currColor, nullptr, "Pick a color",
{QColorDialog::DontUseNativeDialog, QColorDialog::ShowAlphaChannel});

// returns if the user hits cancel
if (!newColor.isValid())
return;

if (type == "ambient")
{
_rAmbient = newColor.red();
_gAmbient = newColor.green();
_bAmbient = newColor.blue();
_aAmbient = newColor.alpha();
}
else if (type == "diffuse")
{
_rDiffuse = newColor.red();
_gDiffuse = newColor.green();
_bDiffuse = newColor.blue();
_aDiffuse = newColor.alpha();
}
else if (type == "specular")
{
_rSpecular = newColor.red();
_gSpecular = newColor.green();
_bSpecular = newColor.blue();
_aSpecular = newColor.alpha();
}
else if (type == "emissive")
{
_rEmissive = newColor.red();
_gEmissive = newColor.green();
_bEmissive = newColor.blue();
_aEmissive = newColor.alpha();
}
else
{
ignerr << "Invalid material type: " << type << std::endl;
return;
}
}

std::function<void(const ignition::msgs::Boolean &, const bool)> cb =
[](const ignition::msgs::Boolean &/*_rep*/, const bool _result)
{
Expand All @@ -1216,17 +1168,13 @@ void ComponentInspector::OnMaterialColor(
req.set_id(this->dataPtr->entity);

msgs::Set(req.mutable_material()->mutable_ambient(),
math::Color(_rAmbient / 255.0, _gAmbient / 255.0,
_bAmbient / 255.0, _aAmbient / 255.0));
math::Color(_rAmbient, _gAmbient, _bAmbient, _aAmbient));
msgs::Set(req.mutable_material()->mutable_diffuse(),
math::Color(_rDiffuse / 255.0, _gDiffuse / 255.0,
_bDiffuse / 255.0, _aDiffuse / 255.0));
math::Color(_rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse));
msgs::Set(req.mutable_material()->mutable_specular(),
math::Color(_rSpecular / 255.0, _gSpecular / 255.0,
_bSpecular / 255.0, _aSpecular / 255.0));
math::Color(_rSpecular, _gSpecular, _bSpecular, _aSpecular));
msgs::Set(req.mutable_material()->mutable_emissive(),
math::Color(_rEmissive / 255.0, _gEmissive / 255.0,
_bEmissive / 255.0, _aEmissive / 255.0));
math::Color(_rEmissive, _gEmissive, _bEmissive, _aEmissive));

auto materialCmdService = "/world/" + this->dataPtr->worldName
+ "/visual_config";
Expand Down

0 comments on commit d598c62

Please sign in to comment.